/*
 * miguelbrito.solutions - lead magnet landing for «Punto Final».
 *
 * Design read: lead-magnet landing for Spanish YouTube viewers curious about
 * building games with AI, with a typewriter/dossier editorial language from
 * the video «Punto Final», native HTML + CSS + a few lines of vanilla JS.
 * Dials: DESIGN_VARIANCE 7 / MOTION_INTENSITY 5 / VISUAL_DENSITY 3.
 *
 * Justified overrides of taste-skill defaults:
 * - Palette: ink #141210, cream #EFE6D2, paper shadow #D6C9AC and a single
 *   accent red #C3212B. This is the brand identity of the video (the red dot
 *   of the game logo and the "PERDISTE" screen), not a premium-consumer
 *   default. Amber is never used on the page; it only appears inside the real
 *   game screenshot. In dark mode, small red TEXT (errors) uses a lighter
 *   tint of the same hue (#F06A6F) because #C3212B on ink is only 3.2:1.
 * - Fonts: Anton (display, uppercase) + Courier Prime (all body and UI, the
 *   typewriter voice of the game). No serif. Self-hosted, OFL licensed.
 * - Theme: auto via prefers-color-scheme. Light = cream paper page, ink text.
 *   Dark = ink page, cream text. Same hierarchy in both.
 * - Shape: all-sharp. Every corner radius on the page is 0 (paper/dossier).
 *
 * Contrast notes (WCAG): cream on red button 4.74:1, red on cream 4.74:1,
 * ink on cream 15.9:1, muted #4A443B on cream 7.7:1, muted #B8AE98 on ink
 * 8.5:1, red focus ring on cream 4.7:1, tinted
 * focus ring #F06A6F on ink 6.2:1.
 *
 * Z-index scale: 1 = content lift, 10 = skip link, 50 = paper grain overlay.
 *
 * Access page (acceso.html): same system. Dials 6 / 4 / 4 (utility page that
 * delivers instructions). Code blocks are ink on the light page and a lifted
 * ink (#1C1916) on the dark page, cream text in both (15.9:1 / 14.6:1).
 * Brand marks in buttons are Simple Icons 16.35.0 SVGs (CC0 1.0), vendored in
 * assets/icons and painted with currentColor through CSS masks.
 */

/* ---------- Fonts ---------- */
@font-face {
  font-family: "Anton";
  src: url("assets/fonts/anton/Anton-Regular.woff2") format("woff2"),
       url("assets/fonts/anton/Anton-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Courier Prime";
  src: url("assets/fonts/courierprime/CourierPrime-Regular.woff2") format("woff2"),
       url("assets/fonts/courierprime/CourierPrime-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Courier Prime";
  src: url("assets/fonts/courierprime/CourierPrime-Bold.woff2") format("woff2"),
       url("assets/fonts/courierprime/CourierPrime-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Courier Prime";
  src: url("assets/fonts/courierprime/CourierPrime-Italic.woff2") format("woff2"),
       url("assets/fonts/courierprime/CourierPrime-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --ink: #141210;
  --cream: #EFE6D2;
  --paper-shadow: #D6C9AC;
  --red: #C3212B;

  --bg: var(--cream);
  --fg: var(--ink);
  --muted: #4A443B;
  --shadow: var(--paper-shadow);
  --field-bg: #F6F0E2;
  --field-border: var(--ink);
  --frame: var(--ink);
  --error-text: var(--red);
  --accent-text: var(--red);
  --focus: var(--red);
  --code-bg: var(--ink);
  --code-fg: var(--cream);
  --code-border: var(--ink);
  --grain-opacity: .55;
  --grain-filter: none;

  --font-display: "Anton", "Impact", "Arial Narrow", sans-serif;
  --font-body: "Courier Prime", "Courier New", ui-monospace, monospace;

  --gutter: 16px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--ink);
    --fg: var(--cream);
    --muted: #B8AE98;
    --shadow: #2B2621;
    --field-bg: #1C1916;
    --field-border: #B8AE98;
    --frame: #4A443B;
    --error-text: #F06A6F;
    --accent-text: #F06A6F;
    --focus: #F06A6F;
    --code-bg: #1C1916;
    --code-fg: var(--cream);
    --code-border: #4A443B;
    --grain-opacity: .35;
    --grain-filter: invert(1);
    color-scheme: dark;
  }
}

@media (min-width: 768px) {
  :root { --gutter: 40px; }
}
@media (min-width: 1280px) {
  :root { --gutter: 64px; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.55;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

/* Static paper grain on a fixed, non-interactive layer (never on scrollers). */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background-image: url("assets/img/grain.png");
  background-size: 160px 160px;
  opacity: var(--grain-opacity);
  filter: var(--grain-filter);
}

[hidden] { display: none !important; }

img { display: block; max-width: 100%; height: auto; }
figure { margin: 0; }
p { margin: 0; }

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}
a:hover { text-decoration-color: var(--red); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 10;
  padding: 10px 14px;
  background: var(--fg);
  color: var(--bg);
  font-weight: 700;
}
.skip:focus { top: 12px; }

.wrap {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Header ---------- */
.site-header__inner {
  display: flex;
  align-items: center;
  height: 64px;
}

.wordmark {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -.01em;
  text-decoration: none;
}
.wordmark__dot { color: var(--red); }

/* ---------- Hero ---------- */
.hero { padding-block: 12px 64px; }

.hero__title {
  margin: 0 0 28px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 1.2rem + 4.8vw, 5.25rem);
  /* 1.18 keeps the Ñ tilde clear of the line above. */
  line-height: 1.18;
  letter-spacing: .005em;
  text-transform: uppercase;
}
.type { display: block; text-wrap: balance; }
.type .w { white-space: nowrap; }
.type .c { position: relative; }

.hero__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

.hero__media {
  order: 2;
  box-shadow: 10px 10px 0 var(--shadow);
}
.hero__media img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }

.hero__aside { order: 1; display: grid; gap: 24px; align-content: start; }

.hero__sub {
  font-size: 1.125rem;
  line-height: 1.5;
  max-width: 44ch;
}

@media (min-width: 1024px) {
  .hero__grid {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 48px;
    align-items: start;
  }
  .hero__media { order: 0; }
  .hero__aside { order: 0; }
}

/* ---------- Lead form ---------- */
.lead { max-width: 34rem; outline: none; }

.lead__form { display: grid; gap: 14px; }

.field { display: grid; gap: 6px; }

.field__label {
  font-weight: 700;
  font-size: 1rem;
}

.field__input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 2px solid var(--field-border);
  border-radius: 0;
  background: var(--field-bg);
  color: var(--fg);
  font: inherit;
  font-size: 1rem;
}
.field__input::placeholder { color: var(--muted); opacity: 1; }
.field__input:focus-visible { outline-offset: 2px; }
.field__input[aria-invalid="true"] { border-color: var(--error-text); border-width: 2px; box-shadow: inset 4px 0 0 var(--error-text); }

.field__help {
  font-size: .875rem;
  color: var(--muted);
}

.field__error {
  font-size: .9375rem;
  font-weight: 700;
  color: var(--error-text);
}
.field__error:empty { display: none; }

.check {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: start;
}
.check__input {
  appearance: none;
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  border: 2px solid var(--field-border);
  border-radius: 0;
  background: var(--field-bg);
  display: grid;
  place-content: center;
  cursor: pointer;
}
.check__input::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--red);
  transform: scale(0);
  transition: transform .15s var(--ease-out);
}
.check__input:checked::before { transform: scale(1); }
.check__input[aria-invalid="true"] { border-color: var(--error-text); }
.check__label { font-size: .9375rem; line-height: 1.45; cursor: pointer; }

/* Honeypot field: off-screen for people, still in the form for bots. */
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.lead__alert {
  padding: 12px 14px;
  border-left: 4px solid var(--red);
  background: var(--field-bg);
  font-size: .9375rem;
  font-weight: 700;
}

/* No-JS form errors: the server redirects to /#error-...; :target shows it. */
.lead__alert--target { display: none; scroll-margin-top: 16px; }
.lead__alert--target:target { display: block; }

/* ---------- Qualification survey ----------
   Without JS every step is visible, stacked as a normal form. main.js shows
   one step at a time (the others get [hidden]) and reveals the progress row,
   the back button and, once a step has an answer, its "Siguiente" button. */
.survey__intro {
  max-width: 44ch;
  padding-left: 14px;
  border-left: 4px solid var(--red);
  font-size: 1rem;
  line-height: 1.5;
}

.survey__progress {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px 16px;
}
.survey__count {
  grid-column: 2;
  justify-self: end;
  font-size: .9375rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.survey__bar {
  grid-column: 1 / -1;
  height: 8px;
  border: 2px solid var(--fg);
  background: var(--field-bg);
  overflow: hidden;
}
.survey__fill {
  display: block;
  height: 100%;
  background: var(--red);
  transform: scaleX(.2);
  transform-origin: left;
  transition: transform .35s var(--ease-out);
}
.survey__bar[data-step="2"] .survey__fill { transform: scaleX(.4); }
.survey__bar[data-step="3"] .survey__fill { transform: scaleX(.6); }
.survey__bar[data-step="4"] .survey__fill { transform: scaleX(.8); }
.survey__bar[data-step="5"] .survey__fill { transform: none; }

/* Text-style buttons of the survey (back, next). */
.survey__back,
.survey__next {
  grid-column: 1;
  justify-self: start;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
  cursor: pointer;
}
.survey__back:hover,
.survey__next:hover { text-decoration-color: var(--red); }

.survey__step {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
/* Floated legend behaves like a normal block (margins, wrapping). */
.survey__question {
  float: left;
  width: 100%;
  margin: 0 0 4px;
  padding: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.5rem, 1.25rem + 1vw, 1.875rem);
  /* 1.2 keeps accents on capitals clear of the line above. */
  line-height: 1.2;
  text-transform: uppercase;
}
.survey__question + * { clear: both; }
.survey__contact { gap: 14px; }
/* Without JS the steps are stacked: give each question some air. */
:root:not(.js) .survey__step + .survey__step { margin-top: 16px; }

.survey__options { display: grid; gap: 12px; }

/* Answer cards: a real radio input, visually hidden but focusable, inside a
   large label. The checked state shows on the letter (sibling selector, works
   everywhere) and on the whole card where :has() is supported. */
.option {
  position: relative;
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 14px 10px 10px;
  border: 2px solid var(--field-border);
  background: var(--field-bg);
  box-shadow: 4px 4px 0 var(--shadow);
  cursor: pointer;
  transition: transform .15s var(--ease-out), box-shadow .15s var(--ease-out), border-color .15s var(--ease-out);
}
.option:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--shadow); }
.option:active { transform: translateY(1px); box-shadow: 2px 2px 0 var(--shadow); }

.option__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.option__key {
  display: grid;
  place-items: center;
  height: 2.25rem;
  border: 2px solid var(--fg);
  font-weight: 700;
  font-size: .9375rem;
  transition: background-color .15s var(--ease-out), color .15s var(--ease-out);
}
.option__text { font-size: 1rem; line-height: 1.4; }

.option__input:checked + .option__key {
  border-color: var(--red);
  background: var(--red);
  color: var(--cream);
}
.option:has(.option__input:checked) {
  border-color: var(--red);
  box-shadow: 4px 4px 0 var(--red);
}
.option__input:focus-visible + .option__key { outline: 3px solid var(--focus); outline-offset: 2px; }
.option:has(.option__input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.option:has(.option__input:focus-visible) .option__key { outline: none; }

.survey__step.is-invalid .option { border-color: var(--error-text); }

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0 28px;
  border: 0;
  border-radius: 0;
  background: var(--red);
  color: var(--cream);
  font-family: var(--font-display);
  font-size: 1.375rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 6px 6px 0 var(--shadow);
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out);
  justify-self: start;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 7px 7px 0 var(--shadow); }
.btn:active { transform: translateY(1px); box-shadow: 4px 4px 0 var(--shadow); }

/* Loading state: label stays, a thin bar fills along the bottom edge. */
.btn__progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: var(--cream);
  transform: scaleX(0);
  transform-origin: left;
}
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"] .btn__progress {
  animation: progress 1.4s var(--ease-out) forwards;
}
@keyframes progress { to { transform: scaleX(.92); } }

/* ---------- Sections ---------- */
.section-title {
  margin: 0 0 32px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.25rem, 1.4rem + 3vw, 3.75rem);
  /* 1.18 keeps accents on capitals (Ñ, É, Á) clear of the line above. */
  line-height: 1.18;
  text-transform: uppercase;
}

/* Results */
.results { padding-block: 48px 80px; }
@media (min-width: 1024px) {
  .results { padding-block: 96px 112px; }
}

.results__shot img {
  width: 100%;
  height: auto;
  border: 2px solid var(--frame);
  box-shadow: 12px 12px 0 var(--shadow);
}
/* The capture is 640x360 pixel art: keep pixels crisp only when it is
   upscaled. Downscaled (narrow 1x screens) it uses smooth filtering. */
@media (min-width: 700px), (min-resolution: 2dppx) {
  .results__shot img { image-rendering: pixelated; }
}
.results__shot figcaption {
  margin-top: 18px;
  font-size: .9375rem;
  color: var(--muted);
}

.ledger {
  display: grid;
  gap: 40px;
  margin-top: 56px;
}
.ledger__big {
  font-family: var(--font-display);
  font-size: clamp(3rem, 1.6rem + 6vw, 6.5rem);
  line-height: .95;
  text-transform: uppercase;
}
.ledger__text {
  margin-top: 10px;
  font-size: 1.25rem;
  font-weight: 700;
}
.ledger__rest { display: grid; gap: 24px; align-content: end; }
.ledger__item {
  padding-top: 14px;
  border-top: 3px solid var(--fg);
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1.4;
}

@media (min-width: 900px) {
  .ledger {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 64px;
    align-items: end;
  }
}

/* Credit */
.credit { padding-block: 32px 128px; }
.credit__inner { display: grid; }
.credit__body {
  display: grid;
  gap: 18px;
  max-width: 58ch;
  padding-left: 20px;
  border-left: 4px solid var(--red);
  font-size: 1.125rem;
}
@media (min-width: 1024px) {
  .credit__inner { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; }
  .credit__inner > * { grid-column: 4 / span 8; }
}

.text-link {
  justify-self: start;
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-decoration-thickness: 3px;
  text-underline-offset: .2em;
}
.text-link:hover { color: var(--red); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 2px solid var(--fg);
  padding-block: 28px 40px;
  font-size: .9375rem;
}
.site-footer__inner {
  display: grid;
  gap: 12px;
}
.site-footer__links { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.site-footer__note { color: var(--muted); }
@media (min-width: 768px) {
  .site-footer__inner {
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 32px;
  }
}

/* ---------- Privacy page ---------- */
.notice {
  background: var(--red);
  color: var(--cream);
  font-weight: 700;
}
.notice .wrap { padding-block: 12px; }

.legal { padding-block: 24px 112px; }
.legal__inner { max-width: 72ch; }
.legal h1 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 1.6rem + 3vw, 4rem);
  line-height: 1;
  text-transform: uppercase;
}
.legal h2 {
  margin: 48px 0 12px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.75rem;
  line-height: 1.1;
  text-transform: uppercase;
}
.legal p, .legal li { margin: 0 0 12px; }
.legal ul { padding-left: 1.25em; margin: 0 0 12px; }
.legal__meta { color: var(--muted); }
.ph {
  padding: 0 .2em;
  background: var(--shadow);
  font-weight: 700;
  outline: 1px dashed var(--muted);
}

/* ---------- Access page (acceso.html) ---------- */

/* States. The server (server/access.js) renders exactly one state block and
   sets html[data-estado]; no state is hidden or revealed with CSS. */

.access__kicker {
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--accent-text);
}

/* Typewriter caret after the headline: blinks twice, then goes away. */
.caret::after {
  content: "";
  display: inline-block;
  width: .07em;
  height: .78em;
  margin-left: .1em;
  background: var(--red);
  opacity: 0;
}

/* The cover is 2:1 and carries its licence caption, so the paper shadow sits
   on the image itself instead of the whole figure. */
.access__cover { box-shadow: none; }
.access__cover img {
  aspect-ratio: 2 / 1;
  box-shadow: 10px 10px 0 var(--shadow);
}
.access__cover figcaption {
  margin-top: 22px;
  font-size: .875rem;
  color: var(--muted);
}

.access__ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 20px;
}

.btn--ghost {
  border: 2px solid var(--fg);
  background: var(--bg);
  color: var(--fg);
}

/* Brand marks painted with the button text colour. */
.icon {
  flex: none;
  width: .95em;
  height: .95em;
  margin-right: .5em;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.icon--github { --icon: url("assets/icons/github.svg"); }
.icon--x { --icon: url("assets/icons/x.svg"); }

/* About */
.about { padding-block: 48px 80px; }
.about__title {
  max-width: 26ch;
  font-size: clamp(2rem, 1.3rem + 2.4vw, 3.25rem);
}
.about__grid {
  display: grid;
  gap: 48px;
}
.about__defs { display: grid; gap: 28px; align-content: start; }
.about__def {
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 3px solid var(--fg);
  font-size: 1.0625rem;
  max-width: 52ch;
}
.about__term {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.625rem;
  line-height: 1.2;
  text-transform: uppercase;
}
.about__compat {
  max-width: 52ch;
  font-weight: 700;
}
@media (min-width: 1024px) {
  .about { padding-block: 96px 112px; }
  .about__grid {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 64px;
    align-items: start;
  }
}

/* Install */
.install { padding-block: 32px 80px; }
.install__inner { display: grid; gap: 8px; }
.install__head .section-title { margin-bottom: 16px; }
.install__req {
  max-width: 40ch;
  margin-bottom: 32px;
  font-size: 1.125rem;
}
@media (min-width: 1024px) {
  .install { padding-block: 64px 112px; }
  .install__inner {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 24px;
    align-items: start;
  }
  .install__head {
    grid-column: 1 / span 4;
    position: sticky;
    top: 32px;
  }
  .steps { grid-column: 6 / span 7; }
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 48px;
}
.step {
  counter-increment: step;
  display: grid;
  gap: 12px;
  min-width: 0;
}
.step__title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.875rem;
  line-height: 1.2;
  text-transform: uppercase;
}
.step__title::before {
  content: counter(step) ".";
  margin-right: .35em;
  color: var(--accent-text);
}
.step__text { margin-top: 6px; }

/* Code blocks with a copy button */
.code {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  border: 2px solid var(--code-border);
  background: var(--code-bg);
  color: var(--code-fg);
  box-shadow: 6px 6px 0 var(--shadow);
}
.code__pre {
  margin: 0;
  padding: 14px 16px;
  /* Wrap instead of scrolling sideways; copy uses the raw text anyway. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--font-body);
  font-size: .9375rem;
  line-height: 1.6;
  tab-size: 2;
}
.code__pre code { font: inherit; }
.code__copy {
  min-width: 96px;
  min-height: 44px;
  margin: 6px 6px 6px 0;
  padding: 0 14px;
  border: 2px solid var(--code-fg);
  border-radius: 0;
  background: transparent;
  color: var(--code-fg);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: .9375rem;
  cursor: pointer;
  transition: transform .15s var(--ease-out);
}
.code__copy:hover { background: var(--red); border-color: var(--red); color: var(--cream); }
.code__copy:active { transform: translateY(1px); }
.code__copy.is-copied { background: var(--cream); border-color: var(--cream); color: var(--ink); }
.code__copy.is-failed { border-style: dashed; }

/* Prompt: intro, then template and filled example, button on top of each block. */
.prompt__intro {
  display: grid;
  gap: 12px;
  max-width: 56ch;
  margin-bottom: 32px;
  font-size: 1.125rem;
}
.prompt__grid { display: grid; gap: 40px; }
.prompt__item { display: grid; gap: 12px; align-content: start; min-width: 0; }
.prompt__label {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.2;
  text-transform: uppercase;
}
.code--doc {
  grid-template-columns: minmax(0, 1fr);
  border-color: var(--fg);
  background: var(--field-bg);
  color: var(--fg);
}
.code--doc .code__copy {
  justify-self: end;
  margin: 10px 10px 0;
  border-color: var(--fg);
  color: var(--fg);
}
.code--doc .code__copy:hover { border-color: var(--red); color: var(--cream); }
.code--doc .code__copy.is-copied { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.code--doc .code__pre { padding: 8px 20px 20px; font-size: .9375rem; }
@media (min-width: 1024px) {
  .prompt__grid {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 48px;
    align-items: start;
  }
}

/* Shared / expired states */
.notice-state { padding-block: 32px 128px; }
.notice-state__inner { display: grid; }
.notice-state__title { margin-bottom: 32px; }
.notice-state__body {
  display: grid;
  gap: 24px;
  max-width: 46ch;
  padding-left: 20px;
  border-left: 4px solid var(--red);
  font-size: 1.1875rem;
}

/* Expired state: renewal form inside the notice body. */
.renew { display: grid; gap: 18px; font-size: 1.0625rem; }
.renew .lead__alert a { color: inherit; }
@media (min-width: 1024px) {
  .notice-state { padding-block: 72px 160px; min-height: 62dvh; }
}

.site-footer__licence {
  grid-column: 1 / -1;
  max-width: 72ch;
  color: var(--muted);
}

/* ---------- Motion (only when the user has not asked for less) ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* Typewriter: each character appears in one step; a red caret rides the
     newest character, then blinks twice on the last one and stops. Total
     typing time: 120ms + 49 x 20ms = 1.1s. */
  .type .c {
    opacity: 0;
    animation: type-on 1ms linear forwards;
    animation-delay: calc(120ms + var(--i) * 20ms);
  }
  .type .c::after {
    content: "";
    position: absolute;
    top: .06em;
    bottom: .06em;
    left: 100%;
    width: .07em;
    background: var(--red);
    opacity: 0;
    animation: caret-pass 20ms linear;
    animation-delay: calc(120ms + var(--i) * 20ms);
  }
  .type .c--last::after {
    animation: caret-pass 20ms linear, caret-blink 1.1s steps(1) 2 forwards;
    animation-delay: calc(120ms + var(--i) * 20ms), calc(140ms + var(--i) * 20ms);
  }

  /* Section reveal, driven by IntersectionObserver in main.js. */
  .js .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .7s var(--ease-out), transform .7s var(--ease-out);
  }
  .js .reveal.is-in { opacity: 1; transform: none; }

  /* Access page headline caret: two blinks once the page is painted. */
  .caret::after { animation: caret-blink 1.1s steps(1) 250ms 2 both; }

  /* Survey: the new step fades in, moving up when going forward and down when going back (vertical, so it never widens the page). */
  .survey__step.is-entering { animation: step-in .32s var(--ease-out); }
  .survey__step.is-entering.is-back { animation-name: step-in-back; }
}

@keyframes step-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes step-in-back { from { opacity: 0; transform: translateY(-10px); } }

/* Constant keyframes avoid float rounding at the step boundary. */
@keyframes type-on { from, to { opacity: 1; } }
@keyframes caret-pass { 0%, 100% { opacity: 1; } }
@keyframes caret-blink { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .check__input::before, .code__copy, .option, .option__key, .survey__fill { transition: none; }
  .btn[aria-busy="true"] .btn__progress { animation: none; transform: scaleX(.6); }
}
