:root {
  --ground: #ffffff;
  --paper: #f7f9fc;
  --grid-minor: #e3eaf3;
  --grid-major: #cdd8e8;
  --rule: #dbe3ee;
  --ink: #10203a;
  --ink-soft: #51607a;
  --blue: #0a6cff;
  --blue-deep: #0052cc;
  --blue-wash: #eef4ff;
  --orange: #f07c00;
  --magenta: #d6247a;
  --green: #1c8f4e;

  --font-body: 'Instrument Sans', -apple-system, 'Helvetica Neue', sans-serif;
  --font-math: 'STIX Two Text', 'STIX Two Math', 'Times New Roman', serif;

  --gutter: clamp(1.25rem, 4.4vw, 3.5rem);
  --measure: 35rem;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 1.125rem/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--blue-deep);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
  border-radius: 4px;
}

h1,
h2,
h3,
p,
figure,
blockquote {
  margin: 0;
}

h2 {
  font: 700 clamp(2rem, 4.4vw, 2.75rem)/1.08 var(--font-body);
  letter-spacing: -0.03em;
}

h3 {
  font: 600 1.125rem/1.3 var(--font-body);
}

canvas {
  display: block;
  width: 100%;
}

.math {
  font-family: var(--font-math);
  font-style: italic;
  font-weight: 500;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- top bar ---- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem var(--gutter);
  border-bottom: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font: 700 1.125rem/1 var(--font-body);
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.wordmark img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.bar nav {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2.5vw, 1.75rem);
  font-size: 0.9375rem;
  font-weight: 500;
}

.bar nav a {
  color: var(--ink);
  text-decoration: none;
}

.bar nav a:hover {
  text-decoration: underline;
}

.bar nav .optional {
  display: none;
}

@media (min-width: 48rem) {
  .bar nav .optional {
    display: inline;
  }
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: 0 1.5rem;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  font: 600 1.0625rem/1 var(--font-body);
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  background: var(--blue-deep);
  color: #fff;
}

.badge {
  display: inline-block;
  flex: none;
  line-height: 0;
  border-radius: 9px;
}

.badge img {
  display: block;
  width: auto;
  height: 54px;
}

.badge.small img {
  height: 40px;
}

.text-link {
  font-weight: 600;
}

/* ---- phone frame ---- */

.phone {
  width: min(100%, var(--phone-width, 17rem));
  padding: 0.55rem;
  border-radius: 2.75rem;
  background: var(--ink);
}

.phone img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1170 / 2532;
  border-radius: 2.25rem;
  background: #fff;
}

.figure figcaption {
  max-width: 17rem;
  margin-top: 0.75rem;
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.4;
}

.paper-fill {
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid-minor) 1px, transparent 1px), linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: center;
}

/* ---- home: hero ---- */

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(2.5rem, 6vw, 4.5rem) var(--gutter) 0;
}

.hero-curves {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: clamp(16rem, 34vw, 26rem);
}

.hero-curves canvas {
  height: 100%;
}

/* a lo ancho las curvas pasan detras del texto: se desvanecen antes de llegar a el */
@media (min-width: 54rem) {
  .hero-curves {
    -webkit-mask-image: linear-gradient(90deg, transparent 44%, #000 60%);
    mask-image: linear-gradient(90deg, transparent 44%, #000 60%);
  }
}

.hero-layout {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2.5rem 4rem;
}

.hero-copy {
  flex: 1 1 28rem;
  max-width: 40rem;
  padding-bottom: clamp(1rem, 7vw, 6rem);
}

.hero-copy h1 {
  font: 700 clamp(2.9rem, 7.4vw, 5rem)/1 var(--font-body);
  letter-spacing: -0.04em;
}

.hero-copy .lead {
  max-width: 32.5rem;
  margin-top: 1.5rem;
  color: var(--ink-soft);
  font-size: clamp(1.125rem, 2vw, 1.3125rem);
  line-height: 1.4;
}

.try {
  max-width: 28.75rem;
  margin-top: 2rem;
}

.try label {
  display: block;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  font-weight: 500;
}

.equation-field {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem 1rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: italic 500 clamp(1.5rem, 4vw, 1.875rem)/1.2 var(--font-math);
  caret-color: var(--blue);
}

.equation-field:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-wash);
}

.status {
  min-height: 1.4em;
  margin-top: 0.5rem;
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.4;
}

.status[data-state='problem'] {
  color: #a3261b;
}

.n-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.9375rem;
}

.n-control[hidden] {
  display: none;
}

.n-control input {
  flex: 1;
  accent-color: var(--blue);
}

.n-control output {
  min-width: 3.2em;
  font-variant-numeric: tabular-nums;
}

.tries {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.tries button {
  min-height: 44px;
  padding: 0 0.85rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: italic 500 1.0625rem/1 var(--font-math);
  cursor: pointer;
}

.tries button:hover {
  border-color: var(--ink);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 1.75rem;
}

.hero-phone {
  --phone-width: 20.5rem;
  flex: none;
  width: min(100%, var(--phone-width));
  margin: 0 auto -6.5rem;
}

@media (min-width: 64rem) {
  .hero-phone {
    margin-right: 2.5rem;
  }
}

/* ---- home: sections ---- */

.section {
  padding: clamp(3rem, 7vw, 4.5rem) var(--gutter);
}

.section.after-hero {
  padding-top: clamp(9rem, 16vw, 12rem);
}

.section > h2 {
  max-width: 47.5rem;
}

.section > h2 + p {
  max-width: var(--measure);
  margin-top: 1.1rem;
  color: var(--ink-soft);
}

.plots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  margin-top: 2.5rem;
}

@media (min-width: 60rem) {
  .plots {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.plot canvas {
  aspect-ratio: 1;
  border-radius: 20px;
  background: var(--paper);
}

.plot figcaption {
  margin-top: 0.75rem;
}

.plot button {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: italic 500 1.3125rem/1.2 var(--font-math);
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 0.2em;
}

.plot button:hover {
  text-decoration-color: var(--ink);
}

.plot .kind {
  color: var(--ink-soft);
  font-size: 0.875rem;
}

.feature {
  display: grid;
  align-items: center;
  gap: 2.5rem clamp(2.5rem, 6vw, 5rem);
  padding: clamp(2rem, 5vw, 3.5rem) var(--gutter);
}

@media (min-width: 54rem) {
  .feature {
    grid-template-columns: minmax(0, 26rem) minmax(0, 32.5rem);
    justify-content: space-between;
  }

  .feature.flip {
    grid-template-columns: minmax(0, 32.5rem) minmax(0, 26rem);
  }

  .feature.flip .stage {
    order: 2;
  }
}

/* el telefono va completo dentro del panel: nada se recorta ni se sale */
.feature .stage {
  --phone-width: 15rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.5rem 2rem;
  border-radius: 28px;
}

.feature .words {
  max-width: 32.5rem;
}

.feature .words p {
  margin-top: 1.1rem;
  color: var(--ink-soft);
}

.feature .words .sample {
  margin-top: 1.75rem;
  color: var(--ink);
  font: italic 500 clamp(1.6rem, 4vw, 2.125rem)/1.2 var(--font-math);
}

.tiers {
  display: grid;
  gap: 2.5rem clamp(2rem, 6vw, 4.5rem);
  margin-top: 2.5rem;
}

@media (min-width: 44rem) {
  .tiers {
    grid-template-columns: 1fr 1fr;
  }
}

.tiers ul {
  margin: 0.9rem 0 0;
  padding: 0;
  list-style: none;
  border-top: 2px solid var(--ink);
}

.tiers li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}

.closing {
  position: relative;
  overflow: hidden;
  padding: clamp(3.5rem, 8vw, 5.5rem) var(--gutter);
  background: var(--ink);
  color: #fff;
}

.closing canvas {
  position: absolute;
  top: 0;
  right: 0;
  width: min(100%, 46rem);
  height: 100%;
  opacity: 0.28;
}

@media (min-width: 64rem) {
  .closing canvas {
    width: 50%;
    opacity: 0.6;
  }
}

.closing .words {
  position: relative;
  max-width: 38.75rem;
}

.closing blockquote {
  font: 700 clamp(2.1rem, 5.4vw, 3.25rem)/1.05 var(--font-body);
  letter-spacing: -0.035em;
}

.closing cite {
  display: block;
  margin-top: 1rem;
  color: #c3cfe2;
  font-style: normal;
}

.closing .badge {
  margin-top: 2.25rem;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  padding: 2rem var(--gutter) 3rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

/* ---- user guide ---- */

.guide {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0 4.5rem;
  padding: 0 var(--gutter);
}

.guide-nav {
  flex: 0 0 12.5rem;
  padding: 3.5rem 0 1.5rem;
  font-size: 0.9375rem;
}

@media (min-width: 58rem) {
  .guide-nav {
    position: sticky;
    top: 4.5rem;
  }
}

.guide-nav p {
  margin-bottom: 0.5rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.guide-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-nav a {
  display: block;
  padding: 0.45rem 0;
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}

.guide-nav a:hover {
  color: var(--blue-deep);
}

@media (max-width: 57.99rem) {
  .guide-nav {
    flex-basis: 100%;
    padding-top: 2rem;
  }

  .guide-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.5rem;
  }
}

.guide-main {
  flex: 999 1 35rem;
  min-width: 0;
  max-width: 55rem;
}

.guide-head {
  padding: 3.5rem 0 3rem;
}

.guide-head h1 {
  font: 700 clamp(2.6rem, 7vw, 4rem)/1 var(--font-body);
  letter-spacing: -0.04em;
}

.guide-head p {
  max-width: var(--measure);
  margin-top: 1.25rem;
  color: var(--ink-soft);
  font-size: clamp(1.125rem, 2vw, 1.25rem);
  line-height: 1.45;
}

.chapter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 2.5rem 3.5rem;
  padding: 3.5rem 0;
  border-top: 1px solid var(--rule);
  font-size: 1.0625rem;
  line-height: 1.55;
  scroll-margin-top: 4.5rem;
}

.chapter .text {
  flex: 1 1 22rem;
  min-width: 0;
}

.chapter.wide .text,
.chapter.wide .wide-block {
  flex: 1 1 100%;
  min-width: 0;
}

.chapter h2 {
  font-size: clamp(1.75rem, 4vw, 2.125rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.chapter .text > * + * {
  margin-top: 1rem;
}

.chapter .text > h3 {
  margin-top: 2rem;
}

.chapter ul,
.chapter ol {
  margin-bottom: 0;
  padding-left: 1.25rem;
}

.chapter li + li {
  margin-top: 0.5rem;
}

.chapter .math {
  font-size: 1.1em;
  white-space: nowrap;
}

.chapter .figure,
.chapter .figure-stack {
  --phone-width: 15.5rem;
  flex: none;
  margin-inline: auto;
}

.figure-stack {
  display: grid;
  gap: 2.5rem;
}

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.keys span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 36px;
  padding: 0 0.6rem;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 8px;
  background: #fff;
  font: 500 0.9375rem/1 var(--font-body);
}

.note {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--blue-wash);
  font-size: 1rem;
}

.table-scroll {
  overflow-x: auto;
}

.reference {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

.reference caption {
  padding-bottom: 0.5rem;
  font-weight: 600;
  text-align: left;
}

.reference th,
.reference td {
  padding: 0.6rem 1rem 0.6rem 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.reference thead th {
  border-bottom: 2px solid var(--ink);
  color: var(--ink-soft);
  font-weight: 500;
}

.reference td:first-child {
  font: italic 500 1.1875rem/1.3 var(--font-math);
  white-space: nowrap;
}

.tables {
  display: grid;
  gap: 2.5rem clamp(2rem, 5vw, 4rem);
  margin-top: 2.5rem;
}

@media (min-width: 50rem) {
  .tables {
    grid-template-columns: 1fr 1fr;
  }
}

/* ---- shared graph page and 404 ---- */

.shared {
  padding: clamp(2rem, 6vw, 4rem) var(--gutter) 2rem;
}

.shared h1 {
  max-width: 47.5rem;
  font: 700 clamp(2.1rem, 6vw, 3.25rem)/1.04 var(--font-body);
  letter-spacing: -0.035em;
}

.shared .lead {
  max-width: var(--measure);
  margin-top: 1rem;
  color: var(--ink-soft);
}

.legend {
  max-width: 47.5rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
  border-top: 2px solid var(--ink);
}

.legend li {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--rule);
}

.legend .dot {
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
}

.legend .dot[data-plain] {
  background: none;
  border: 2px solid var(--ink-soft);
}

.legend .math {
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.legend .aside {
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 0.875rem;
  text-align: right;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 1.75rem;
}

.empty {
  max-width: var(--measure);
  margin-top: 1rem;
}

.paper {
  margin: 0 var(--gutter) 3rem;
  border-radius: 28px;
  overflow: hidden;
  background: var(--paper);
}

.paper[hidden] {
  display: none;
}

.paper canvas {
  height: clamp(20rem, 56vh, 36rem);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
