/* Inter variable autoalojada (OFL, ver fonts/Inter-OFL.txt). Dos subconjuntos: el extendido trae la «Ā» de Gārate. */
@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@layer tokens, reset, components;

@layer tokens {
  :root {
    color-scheme: light;

    /* Solo negro, blanco y grises. */
    --color-ink: oklch(15.5% 0 0);
    --color-paper: oklch(98.5% 0 0);
    --color-ground: oklch(91.5% 0 0);
    --color-pill: oklch(24% 0 0);
    --color-pill-text: oklch(78% 0 0);
    --color-dim: oklch(48% 0 0);
    --color-line: oklch(78% 0 0 / 40%);

    --font-sans: "Inter", "Helvetica Neue", Arial, sans-serif;

    --shadow-pill: 0 12px 64px oklch(0% 0 0 / 12%);
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-expo-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-power3-out: cubic-bezier(0.33, 1, 0.68, 1);

    --vp-height: 100vh;
    @supports (height: 100svh) {
      --vp-height: 100svh;
    }
  }
}

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    background: var(--color-ground);
    color: var(--color-ink);
    font-size: 16px;
    font-size-adjust: from-font;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;

    /* La composición entera escala con el ancho a partir de 64rem. */
    @media (min-width: 64rem) {
      font-size: clamp(16px, 1vw, 20px);
    }
  }

  body {
    margin: 0;
    font-family: var(--font-sans);
    line-height: 1.5;
  }
}

@layer components {
  .skip-link {
    position: absolute;
    inset-block-start: 0.75rem;
    inset-inline-start: 0.75rem;
    z-index: 100;
    padding: 0.5rem 0.875rem;
    background: var(--color-ink);
    color: var(--color-paper);
    font-size: 0.875rem;
    translate: 0 -200%;

    &:focus-visible {
      translate: 0 0;
    }
  }

  .brand {
    position: absolute;
    inset-block-start: 1.5rem;
    inset-inline: 0;
    z-index: 40;
    width: fit-content;
    margin-inline: auto;
    color: var(--color-ink);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-decoration: none;

    @media (min-width: 64rem) {
      inset-block-start: 2rem;
    }
  }

  .hero {
    position: relative;
    min-height: var(--vp-height);
    overflow: hidden;
  }

  /* Retícula de puntos con gradiente: el CSP no admite imágenes data:. */
  .hero__background {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-color: var(--color-ground);
    background-image: radial-gradient(circle at 7.5px 7.5px, oklch(0% 0 0 / 8%) 1px, transparent 1.25px);
    background-size: 15px 15px;
  }

  .hero__stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    pointer-events: none;
  }

  .hero__ribbon {
    position: absolute;
    z-index: 10;
    display: flex;
    width: 200vw;
    align-items: center;
    justify-content: center;

    @media (min-width: 64rem) {
      width: 120vw;
    }
  }

  .hero__ribbon-svg {
    width: 100%;
    color: var(--color-pill);
    scale: 0.45;

    @media (prefers-reduced-motion: no-preference) {
      animation: ribbon-grow 3s var(--ease-power3-out) 0.3s both;
    }
  }

  .hero__canvas {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: block;
    width: 100%;
    height: 100%;
  }

  .hero__content {
    position: relative;
    z-index: 35;
    display: flex;
    min-height: var(--vp-height);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* El relleno vertical encoge en pantallas bajas para que la portada quepa sin scroll (1280 × 720). */
    padding: clamp(2.5rem, 9svh, 5rem) 1.25rem;

    @media (min-width: 64rem) {
      padding-inline: 2rem;
    }
  }

  .hero__title {
    margin: 0;
    display: flex;
    flex-direction: column;
    text-align: center;
    /* La pendiente deja margen a los lados en tableta (unos 590 px de línea a 768) y llega al máximo hacia 1440. */
    font-size: clamp(2.5rem, 0.6rem + 5.6vw, 5.75rem);
    font-weight: 580;
    line-height: 0.88;
    letter-spacing: -0.035em;
    text-wrap: balance;
  }

  .hero__intro {
    margin-block-start: 14.5rem;
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 2.25rem;

    @media (min-width: 64rem) {
      margin-block-start: 19rem;
    }
  }

  /* Entrada: aparecen y se asientan desde 1,2 cuando la galería ya está en marcha. */
  .hero__title,
  .hero__intro {
    animation: intro-fade 1.5s var(--ease-expo-out) 1.1s both;

    @media (prefers-reduced-motion: no-preference) {
      animation-name: intro-settle;
    }
  }

  .hero__intro {
    animation-delay: 1.3s;
  }

  /* Variante sin galería (404): sin el hueco de la cinta y con la entrada sin esperar a las fichas. */
  .hero--plain {
    .hero__intro {
      margin-block-start: 2.75rem;
      animation-delay: 0.25s;
    }

    .hero__title {
      animation-delay: 0.05s;
    }
  }

  .hero__subtitle {
    margin: 0;
    max-width: 22rem;
    text-align: center;
    text-wrap: balance;
    font-size: 1rem;
    line-height: 1.32;
    letter-spacing: -0.01em;

    @media (min-width: 64rem) {
      max-width: 30rem;
    }
  }

  /* En móvil el botón va debajo: al lado no deja sitio para dos líneas de ejemplo. */
  /* El botón queda a 0,5rem de los bordes por igual; solo el texto se separa más, con su propio margen. */
  .prompt {
    width: 100%;
    max-width: 38rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--color-pill);
    color: var(--color-pill-text);
    border: 1px solid var(--color-line);
    border-radius: 16px;
    box-shadow: var(--shadow-pill);
    font-size: 0.875rem;
    line-height: 1.2;
    letter-spacing: -0.02em;

    @media (min-width: 40rem) {
      flex-direction: row;
      align-items: center;
      font-size: 0.9375rem;
    }
  }

  .prompt__field {
    position: relative;
    display: grid;
    /* minmax(0, 1fr): sin él la pista toma el ancho del texto entero y el tecleo no salta de línea. */
    grid-template-columns: minmax(0, 1fr);
    /* Alto fijo de dos líneas: la píldora no cambia de tamaño con el largo de cada ejemplo ni al escribir. */
    flex: 1;
    min-width: 0;
    height: 2.4em;
    margin: 0.5rem 0.5rem 0;
    align-items: start;

    @media (min-width: 40rem) {
      margin: 0 0 0 0.625rem;
    }
  }

  .prompt__field > * {
    grid-area: 1 / 1;
  }

  /* Medidor invisible: calcula dónde salta la línea para que el tecleo no reflowee a mitad de palabra. */
  .prompt__measure {
    position: absolute;
    inset-inline: 0;
    inset-block-start: 0;
    visibility: hidden;
    white-space: pre-wrap;
    pointer-events: none;
  }

  .prompt__typed {
    height: 2.4em;
    overflow: hidden;
    white-space: pre-wrap;
    pointer-events: none;
    transition: opacity 350ms;

    &.is-fading {
      opacity: 0;
    }
  }

  .prompt__input {
    z-index: 1;
    width: 100%;
    height: 2.4em;
    min-width: 0;
    padding: 0;
    resize: none;
    border: 0;
    background: transparent;
    outline: none;
    caret-color: var(--color-paper);
    color: var(--color-paper);
    font: inherit;
    letter-spacing: inherit;
  }

  .prompt:has(.prompt__input:focus-visible) {
    outline: 2px solid var(--color-ink);
    outline-offset: 3px;
  }

  .noscript-mail {
    margin: 0;
    font-size: 0.875rem;
  }
}

@keyframes ribbon-grow {
  from { scale: 0; }
}

@keyframes intro-fade {
  from { opacity: 0; }
}

@keyframes intro-settle {
  from {
    opacity: 0;
    scale: 1.2;
  }
}
