@layer reset, base, tokens, type, layout, components, motion, utilities;

/* ============================= RESET ============================= */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body { margin: 0; }
  img, svg { display: block; max-width: 100%; }
  h1, h2, h3, h4, p, blockquote, dl, dd, figure { margin: 0; }
  ul, ol { margin: 0; padding: 0; list-style: none; }
  a { color: inherit; text-decoration: none; }
  button { font: inherit; color: inherit; background: none; border: 0; padding: 0; }
  table { border-collapse: collapse; width: 100%; }
}

/* ============================= TOKENS ============================= */
@layer tokens {
  :root {
    color-scheme: light;

    /* tier 1 — literal, from the design brief */
    --ivory: #F6F1EA;
    --ivory-2: #F4EEE7;
    --graphite: #2B2A28;
    --burgundy: #6E2C3A;
    --burgundy-light: #7A2E3F;
    --burgundy-deep: #5E1F2B;
    --dusty-rose: #B28C93;
    --taupe: #CFC3B8;

    /* tier 2 — semantic */
    --bg: var(--ivory);
    --bg-alt: var(--ivory-2);
    --surface: #FBF8F3;
    --text: var(--graphite);
    --text-muted: color-mix(in oklab, var(--graphite) 72%, var(--ivory) 28%);
    --text-soft: color-mix(in oklab, var(--graphite) 80%, var(--ivory) 20%);
    --accent: var(--burgundy);
    --accent-deep: var(--burgundy-deep);
    --accent-wash: color-mix(in oklab, var(--burgundy) 7%, var(--bg) 93%);
    --rule: var(--taupe);
    --rule-soft: color-mix(in oklab, var(--taupe) 50%, var(--ivory) 50%);

    /* type */
    --font-serif: "Fraunces", "Iowan Old Style", Georgia, serif;
    --font-sans: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    /* rhythm */
    --radius: 3px;
    --radius-frame: 14px;
    --content-max: 1240px;
    --col-max: 62ch;
    --gutter: clamp(1.25rem, 5vw, 4rem);
    --ease-draw: cubic-bezier(.22,1,.36,1);
    --ease-sheen: cubic-bezier(.4,0,.2,1);
    --ease-bump: cubic-bezier(.34,1.56,.64,1);
  }
}

/* ============================= BASE ============================= */
@layer base {
  html {
    font-size: 100%; scroll-behavior: smooth;
    scrollbar-color: var(--accent) var(--bg-alt);
    scrollbar-width: thin;
  }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

  ::-webkit-scrollbar { width: 12px; height: 12px; }
  ::-webkit-scrollbar-track { background: var(--bg-alt); }
  ::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 999px;
    border: 3px solid var(--bg-alt);
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--accent-deep); }
  ::-webkit-scrollbar-corner { background: var(--bg-alt); }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    text-rendering: optimizeLegibility;
    overflow-wrap: break-word;
  }

  h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; text-wrap: balance; color: var(--text); }
  p { text-wrap: pretty; }

  a:focus-visible, button:focus-visible, summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 1px;
  }

  ::selection { background: var(--burgundy); color: var(--ivory); }

  .skip-link {
    position: absolute; left: 1rem; top: -3rem;
    background: var(--accent); color: var(--ivory);
    padding: .6rem 1rem; border-radius: var(--radius);
    font-size: .85rem; z-index: 200; transition: top .2s var(--ease-sheen);
  }
  .skip-link:focus { top: 1rem; }

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

/* ============================= TYPE HELPERS ============================= */
@layer type {
  .hero__title em,
  .pull-quote,
  .step__num, .block-divider__num,
  .note__label, .ask-label, .example__label,
  figcaption { font-style: italic; }
}

/* ============================= LAYOUT ============================= */
@layer layout {
  main { display: block; }

  .hero, .route, .block, .site-footer { padding-inline: var(--gutter); }

  .hero__grid, .route__inner, .block-content, .site-footer {
    max-width: var(--content-max);
    margin-inline: auto;
  }

  /* ---- hero ---- */
  .hero {
    min-block-size: 100dvh;
    display: flex;
    align-items: center;
    padding-block: clamp(5rem, 10vh, 7rem) clamp(3rem, 8vh, 5rem);
  }
  .hero__grid {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(2.5rem, 6vw, 4rem);
    align-items: center;
  }
  @media (min-width: 900px) {
    .hero__grid { grid-template-columns: 1.05fr .95fr; }
  }
  .hero__figure { order: -1; }
  @media (min-width: 900px) { .hero__figure { order: 0; } }
  .hero__figure .frame img {
    width: 100%; height: auto;
    max-height: 72dvh; object-fit: cover;
    border-radius: var(--radius-frame);
  }

  /* ---- route ---- */
  .route { background: var(--bg-alt); padding-block: clamp(4rem, 9vw, 6rem); }
  .route__inner { max-width: 760px; }

  /* ---- block divider + content ---- */
  .block-divider { max-width: var(--content-max); margin-inline: auto; padding-block: clamp(4rem, 9vw, 6.5rem) clamp(1.5rem, 4vw, 2.5rem); }
  .block--alt { background: var(--bg-alt); }
  .block-content { padding-block-end: clamp(2rem, 5vw, 3rem); }

  .feature, .step {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(2rem, 5vw, 3.25rem);
    padding-block: clamp(2.5rem, 5vw, 3.75rem);
    border-top: 1px solid var(--rule-soft);
  }
  @media (min-width: 860px) {
    .feature, .step { grid-template-columns: 1.05fr .95fr; align-items: start; }
  }
  .feature__text > * + *, .step__text > * + * { margin-top: 1rem; }
  .feature__text, .step__text { max-width: var(--col-max); }

  .bonus-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(2.5rem, 5vw, 3.5rem);
    padding-block: clamp(2.5rem, 5vw, 3.75rem);
    border-top: 1px solid var(--rule-soft);
  }
  @media (min-width: 860px) {
    .bonus-grid { grid-template-columns: 1.2fr .8fr; align-items: start; }
  }

  .scene-examples {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: clamp(1.5rem, 3vw, 2.5rem);
    margin-block-start: clamp(2rem, 4vw, 3rem);
  }
  .scene-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: clamp(1.25rem, 2.5vw, 2rem);
    margin-block-start: clamp(1.5rem, 3vw, 2rem);
  }

  .site-footer { padding-block: clamp(3rem, 6vw, 4.5rem); border-top: 1px solid var(--rule-soft); }
}

/* ============================= TYPOGRAPHY SCALE ============================= */
@layer components {
  .hero__title {
    font-size: clamp(2.7rem, 2rem + 3.6vw, 5.1rem);
    line-height: .98;
    font-weight: 600;
    letter-spacing: -.01em;
  }
  .hero__title em { font-weight: 420; }
  .hero__lede {
    margin-top: 1.1rem;
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--accent);
    font-size: clamp(1.15rem, 1rem + .8vw, 1.55rem);
  }
  .hero__desc {
    margin-top: 1.1rem;
    max-width: 42ch;
    color: var(--text-soft);
    font-size: 1.02rem;
    line-height: 1.7;
  }
  .hero__cta {
    display: inline-block;
    margin-top: 2rem;
    font-size: .95rem;
    padding-bottom: .2rem;
    border-bottom: 1px solid var(--accent);
    transition: color .2s, border-color .2s, transform .2s;
  }
  .hero__cta:hover { color: var(--accent); transform: translateX(2px); }

  .hero__figure figcaption {
    margin-top: .65rem;
    color: var(--text-muted);
    font-size: .85rem;
  }

  .route h2 { font-size: clamp(1.8rem, 1.5rem + 1.4vw, 2.4rem); }
  .route__intro {
    margin-top: 1.1rem;
    color: var(--text-soft);
    font-size: 1rem;
    line-height: 1.75;
    max-width: 68ch;
  }

  .route__list { margin-top: 2.25rem; }
  .route__list li a {
    display: flex;
    align-items: baseline;
    gap: 1.1rem;
    padding-block: .95rem;
    border-top: 1px solid var(--rule-soft);
    font-size: 1.02rem;
    transition: color .2s, transform .25s var(--ease-draw), padding-inline-start .25s var(--ease-draw);
  }
  .route__list li:last-child a { border-bottom: 1px solid var(--rule-soft); }
  .route__list li a span {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--accent);
    inline-size: 1.6rem;
    flex: none;
  }
  .route__list li a:hover { color: var(--accent); padding-inline-start: .4rem; }

  .pull-quote {
    margin-top: 2.5rem;
    padding-inline-start: 1.25rem;
    border-left: 2px solid var(--accent);
    font-family: var(--font-serif);
    font-style: italic;
    font-size: clamp(1.1rem, 1rem + .6vw, 1.4rem);
    line-height: 1.6;
    max-width: 56ch;
  }
  .pull-quote em {
    font-style: normal;
    font-family: var(--font-sans);
    font-weight: 700;
    color: var(--accent-deep);
  }
  .pull-quote--close { margin-top: 2.5rem; max-width: none; }

  /* ---- block divider ---- */
  .block-divider__num {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 600;
    font-size: clamp(3.6rem, 3rem + 4vw, 6.5rem);
    line-height: 1;
    color: var(--accent);
    opacity: .82;
  }
  .block-divider__title {
    margin-top: .2rem;
    font-size: clamp(1.9rem, 1.5rem + 1.8vw, 2.9rem);
  }
  .block-divider__intro {
    margin-top: 1.1rem;
    color: var(--text-soft);
    max-width: 54ch;
    font-size: 1.02rem;
    line-height: 1.65;
  }
  .block-divider__rule {
    display: block;
    height: 1px; width: 100%; max-width: 120px;
    margin: 1rem 0 0;
    background: linear-gradient(90deg, var(--accent), rgba(110,44,58,0));
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 1.1s var(--ease-draw);
  }
  .block-divider__rule.is-on { transform: scaleX(1); }

  /* ---- feature / step text ---- */
  .feature__text h3, .step__title {
    font-size: clamp(1.3rem, 1.15rem + .5vw, 1.6rem);
  }
  .feature__text p, .step__lead {
    color: var(--text-soft);
    font-size: 1rem;
    line-height: 1.7;
  }
  .step__num {
    font-family: var(--font-serif);
    font-weight: 600;
    color: var(--accent);
    font-size: clamp(1.9rem, 1.6rem + 1vw, 2.5rem);
    line-height: 1;
    display: inline-block;
    transition: transform .3s var(--ease-bump), text-shadow .3s;
  }
  .step:hover .step__num { transform: translateY(-2px); text-shadow: 0 8px 22px color-mix(in oklab, var(--accent) 35%, transparent); }

  .formula {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--accent-deep);
    font-size: clamp(1.05rem, 1rem + .4vw, 1.3rem);
    line-height: 1.5;
  }

  .feature__figure figcaption, .step__figure figcaption {
    margin-top: .6rem;
    color: var(--text-muted);
    font-size: .85rem;
  }
  .feature__figure img, .step__figure img {
    width: 100%; height: auto; object-fit: cover;
    transition: transform .7s var(--ease-draw);
  }
  @media (hover: hover) and (pointer: fine) {
    .feature__figure:hover img, .step__figure:hover img { transform: scale(1.035); }
  }

  /* ---- photo frame ----
     Steamgate's own card principle: rounded corners, a barely-there
     hairline border, nothing else at rest. On hover the border resolves
     to full accent colour and a soft accent-tinted shadow lifts the
     photo slightly — same signal their game cards use, just in these
     colours instead of theirs. */
  .frame {
    display: block;
    overflow: hidden;
    border-radius: var(--radius-frame);
    border: 1px solid color-mix(in oklab, var(--accent) 16%, transparent);
    transition: border-color .3s, box-shadow .3s;
  }
  @media (hover: hover) and (pointer: fine) {
    .frame:hover {
      border-color: color-mix(in oklab, var(--accent) 55%, transparent);
      box-shadow: 0 18px 36px -22px color-mix(in oklab, var(--accent) 55%, transparent);
    }
  }

  /* the hero photo tilts in 3D toward the cursor — a flat clipped border
     around a rotating image reads as broken (edges swim past the frame),
     so the hero gets no frame chrome; the image rounds its own corners
     instead, and those corners simply turn with it. */
  .hero__figure .frame {
    overflow: visible;
    border: none;
    border-radius: 0;
  }
  .hero__figure .frame:hover {
    border-color: transparent;
    box-shadow: none;
  }

  /* ---- ask block: what you actually copy and hand to the AI assistant ----
     The frame belongs to the text alone — no header row eating into its
     padding. The copy button lives outside it, beside it, top-aligned. */
  .ask-label {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--accent);
    font-size: .82rem;
    letter-spacing: .01em;
    margin-bottom: .5rem;
  }
  .ask-wrap {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
  }
  @media (max-width: 480px) {
    .ask-wrap { flex-direction: column; align-items: stretch; }
    .ask-wrap .prompt__copy { align-self: flex-end; }
  }
  .ask {
    flex: 1;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
  }
  .ask__text {
    font-size: .98rem;
    line-height: 1.62;
    color: var(--text);
  }
  .prompt__copy {
    position: relative;
    overflow: hidden;
    flex: none;
    inline-size: 9.5rem;
    text-align: center;
    font-size: .8rem;
    font-weight: 600;
    color: var(--accent-deep);
    background: var(--accent-wash);
    border: 1px solid color-mix(in oklab, var(--accent) 45%, transparent);
    border-radius: 4px;
    padding: .4rem .6rem;
    cursor: pointer;
    transition: color .2s, background .2s, border-color .2s, transform .2s var(--ease-bump);
  }
  .prompt__copy::after {
    content: '';
    position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(105deg, transparent 40%, color-mix(in oklab, var(--accent) 22%, transparent) 50%, transparent 60%);
    transform: translateX(-140%);
  }
  .prompt__copy:hover { color: var(--ivory); background: var(--accent); border-color: var(--accent); }
  .prompt__copy.is-copied { color: var(--ivory); background: var(--accent); border-color: var(--accent); }

  /* ---- example: the author's own reference text — read-only, quieter ---- */
  .example {
    margin-block: 1.1rem;
    padding-inline-start: 1rem;
    border-left: 2px solid var(--rule);
  }
  .example__label {
    display: block;
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-muted);
    font-size: .8rem;
    margin-bottom: .35rem;
  }
  .example__text {
    font-family: var(--font-sans);
    font-size: .9rem;
    line-height: 1.58;
    color: var(--text-muted);
  }

  /* ---- notes ---- */
  .note { margin-block: 1.35rem; padding-inline-start: 1rem; border-left: 2px solid var(--accent); }
  .note__label { font-family: var(--font-serif); color: var(--accent); margin-right: .5rem; font-size: .95rem; }
  .note p { color: var(--text-soft); font-size: .96rem; line-height: 1.65; }
  .note--important {
    background: var(--accent-wash);
    padding: 1rem 1.15rem;
    border-radius: 0 var(--radius) var(--radius) 0;
  }

  /* ---- bonus ---- */
  .bonus-col h3 { font-size: clamp(1.3rem, 1.15rem + .5vw, 1.6rem); }

  /* ---- table ---- */
  .table-wrap { overflow-x: auto; margin-top: 1.25rem; }
  .tool-table { font-size: .95rem; min-width: 480px; }
  .tool-table thead th {
    background: var(--accent);
    color: var(--ivory);
    text-align: left;
    padding: .8rem 1rem;
    font-weight: 600;
    font-size: .85rem;
  }
  .tool-table tbody th, .tool-table tbody td {
    text-align: left;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--rule-soft);
    vertical-align: top;
  }
  .tool-table tbody th { color: var(--text); font-weight: 600; white-space: nowrap; }
  .tool-table tbody td { color: var(--text-soft); }
  .tool-table tbody tr:last-child th, .tool-table tbody tr:last-child td { border-bottom: none; }

  /* ---- check list ---- */
  .check-list { margin-top: 1rem; }
  .check-list li {
    position: relative;
    padding-inline-start: 1.4rem;
    margin-block: .65rem;
    color: var(--text-soft);
    line-height: 1.6;
  }
  .check-list li::before {
    content: ''; position: absolute; left: 0; top: .72em;
    width: .55rem; height: 1px; background: var(--accent);
  }

  /* ---- gallery ---- */
  .gallery-intro {
    max-width: var(--col-max);
    color: var(--text-soft);
    margin-top: 2.5rem;
    font-size: 1rem;
    line-height: 1.7;
  }
  .gallery-intro--more { margin-top: 3.5rem; padding-top: 2rem; border-top: 1px solid var(--rule-soft); }
  .scene-example img, .scene-grid img { width: 100%; height: auto; object-fit: cover; transition: transform .7s var(--ease-draw); }
  @media (hover: hover) and (pointer: fine) {
    .scene-example figure:hover img, .scene-grid figure:hover img { transform: scale(1.035); }
  }
  .scene-example figcaption, .scene-grid figcaption { margin-top: .6rem; color: var(--text-muted); font-size: .85rem; }
  .scene-example .ask, .scene-example .example { margin-top: 1rem; }

  /* ---- glossary ---- */
  .glossary { margin-top: 1.25rem; }
  .glossary > div {
    display: grid;
    grid-template-columns: 1fr;
    gap: .2rem;
    padding-block: .75rem;
    border-top: 1px solid var(--rule-soft);
  }
  @media (min-width: 640px) {
    .glossary > div { grid-template-columns: 9.5rem 1fr; gap: 1rem; }
  }
  .glossary dt { font-family: var(--font-serif); font-style: italic; color: var(--accent); }
  .glossary dd { color: var(--text-soft); line-height: 1.6; }

  /* ---- signup form ---- */
  .signup { max-width: 34rem; margin-inline: auto; }
  .signup-form { display: grid; gap: 1.15rem; }
  .field { display: grid; gap: .45rem; }
  .field label {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--accent);
    font-size: .92rem;
  }
  .field__optional {
    font-style: normal;
    font-family: var(--font-sans);
    color: var(--text-muted);
    font-size: .8rem;
  }
  .field input, .field textarea {
    font: inherit;
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: .75rem .9rem;
    transition: border-color .2s, box-shadow .2s;
  }
  .field textarea { resize: vertical; min-block-size: 4.5rem; }
  .field input:focus-visible, .field textarea:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 16%, transparent);
  }
  .signup-form__submit {
    justify-self: start;
    background: var(--accent);
    color: var(--ivory);
    border: none;
    border-radius: 4px;
    padding: .9rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: .01em;
    cursor: pointer;
    transition: background .2s, transform .2s var(--ease-bump);
  }
  .signup-form__submit:hover { background: var(--accent-deep); transform: translateY(-1px); }
  .signup-form__submit:disabled { opacity: .6; cursor: default; }
  .signup-form__status {
    min-block-size: 1.3em;
    margin: 0;
    font-size: .92rem;
    color: var(--text-muted);
  }
  .signup-form__status.is-ok { color: var(--accent-deep); }
  .signup-form__status.is-err { color: var(--burgundy-light); }

  /* ---- footer ---- */
  .site-footer p { color: var(--text-soft); font-size: .95rem; }
  .site-footer__muted { margin-top: .4rem; color: var(--text-muted); font-size: .85rem; }
}

/* ============================= NAV: RAIL + QUICK-NAV + PROGRESS ============================= */
@layer components {
  .scroll-progress {
    position: fixed; inset-inline: 0; top: 0; height: 2.5px;
    background: var(--accent);
    transform-origin: 0 50%;
    transform: scaleX(0);
    z-index: 100;
    opacity: 0;
  }

  .rail {
    position: fixed;
    right: clamp(1rem, 3vw, 2.5rem);
    top: 50%;
    transform: translateY(-50%);
    z-index: 60;
    display: none;
  }
  @media (min-width: 1080px) { .rail { display: block; } }
  .rail ol { position: relative; display: flex; flex-direction: column; gap: 1.05rem; }
  .rail ol::before {
    content: '';
    position: absolute; left: 12px; top: 12px; bottom: 12px; width: 1px;
    background: var(--rule-soft);
    z-index: -1;
  }
  .rail a { display: flex; align-items: center; gap: .7rem; }
  .rail-num {
    display: grid; place-items: center;
    inline-size: 26px; block-size: 26px; border-radius: 50%;
    background: var(--bg); border: 1px solid var(--rule);
    font-family: var(--font-serif); font-style: italic; font-size: .8rem;
    color: var(--text-muted);
    transition: background .25s, border-color .25s, color .25s, box-shadow .3s;
  }
  .rail-label {
    font-size: .78rem; color: var(--text-muted);
    opacity: 0; transform: translateX(-6px);
    transition: opacity .2s, transform .2s;
    white-space: nowrap;
  }
  .rail a:hover .rail-label, .rail a.is-active .rail-label { opacity: 1; transform: translateX(0); }
  .rail a.is-active .rail-num {
    background: var(--accent); border-color: var(--accent); color: var(--ivory);
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 16%, transparent);
  }
  .rail a.is-active .rail-label { color: var(--accent-deep); }

  .quick-nav {
    position: fixed; right: 1rem; bottom: 1rem; z-index: 70;
  }
  @media (min-width: 1080px) { .quick-nav { display: none; } }
  .quick-nav summary {
    list-style: none;
    display: grid; place-items: center;
    inline-size: 3rem; block-size: 3rem; border-radius: 50%;
    background: var(--accent); color: var(--ivory);
    font-family: var(--font-serif); font-style: italic; font-size: .82rem;
    cursor: pointer;
    box-shadow: 0 10px 28px -10px color-mix(in oklab, var(--graphite) 55%, transparent);
  }
  .quick-nav summary::-webkit-details-marker { display: none; }
  .quick-nav[open] summary { border-radius: var(--radius); inline-size: auto; padding-inline: 1rem; }
  .quick-nav ol {
    position: absolute; right: 0; bottom: calc(100% + .6rem);
    background: var(--bg); border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: .5rem;
    min-inline-size: 15rem;
    box-shadow: 0 16px 40px -12px color-mix(in oklab, var(--graphite) 40%, transparent);
  }
  .quick-nav ol a {
    display: block; padding: .55rem .7rem; font-size: .9rem; border-radius: 2px;
    color: var(--text-soft);
  }
  .quick-nav ol a:hover { background: var(--accent-wash); color: var(--accent-deep); }
}

/* ============================= MOTION ============================= */
@layer motion {
  /* scroll progress bar — native, decorative only, no fallback needed */
  @media (prefers-reduced-motion: no-preference) {
    @supports (animation-timeline: scroll()) {
      .scroll-progress {
        opacity: 1;
        animation: grow-progress linear;
        animation-timeline: scroll(root);
      }
      @keyframes grow-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
    }
  }

  /* hero: one orchestrated entrance, not a looping effect */
  @media (prefers-reduced-motion: no-preference) {
    .hero__title, .hero__lede, .hero__desc, .hero__cta, .hero__figure {
      animation: rise-in .9s var(--ease-draw) both;
    }
    .hero__title { animation-delay: .05s; }
    .hero__lede { animation-delay: .22s; }
    .hero__desc { animation-delay: .34s; }
    .hero__cta { animation-delay: .46s; }
    .hero__figure { animation-delay: .15s; }
    @keyframes rise-in { from { opacity: 0; transform: translateY(16px); } }

    /* the title's accent word catches the light once, like fabric under a studio lamp.
       two background layers, same trick as the other guides: a solid base (always
       fully covering, so the word is never less than fully legible) plus a narrow
       highlight that sweeps across it exactly once. */
    @supports ((-webkit-background-clip: text) or (background-clip: text)) {
      .hero__title em {
        background-image:
          linear-gradient(100deg, transparent 42%, color-mix(in oklab, var(--accent) 55%, white) 50%, transparent 58%),
          linear-gradient(var(--text), var(--text));
        background-size: 300% 100%, 100% 100%;
        background-position: -120% 0, 0 0;
        background-repeat: no-repeat;
        -webkit-background-clip: text; background-clip: text; color: transparent;
        animation: title-sheen 1.3s ease-out 1s both;
      }
      @keyframes title-sheen {
        from { background-position: -120% 0, 0 0; }
        to   { background-position: 220% 0, 0 0; }
      }
    }
  }

  /* generic scroll reveal for sequential content */
  .js-reveal {
    opacity: 0; transform: translateY(20px);
    transition: opacity .7s var(--ease-draw), transform .7s var(--ease-draw);
    transition-delay: calc(min(var(--i, 0), 3) * 70ms);
  }
  .js-reveal.is-in { opacity: 1; transform: none; }
  @media (prefers-reduced-motion: reduce) {
    .js-reveal { opacity: 1; transform: none; transition: none; }
  }

  /* prompt copy: a bright, bouncy confirmation */
  @media (prefers-reduced-motion: no-preference) {
    .prompt__copy:hover::after { animation: shine .8s var(--ease-sheen); }
    @keyframes shine { to { transform: translateX(140%); } }
    .prompt__copy.is-copied { animation: bump .4s var(--ease-bump); }
    @keyframes bump { 34% { transform: scale(1.08); } }
  }

  /* hero portrait tilts a few degrees toward the cursor, like turning to look at you */
  @media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
    .hero__figure { perspective: 1200px; }
    .hero__figure img {
      transform: rotateX(var(--tiltY, 0deg)) rotateY(var(--tiltX, 0deg));
      transition: transform .5s var(--ease-draw);
      will-change: transform;
    }
  }

  @media (hover: hover) and (pointer: fine) {
    .rail-num { transform: scale(var(--rail-scale, 1)); }
    .rail a:hover .rail-num { --rail-scale: 1.12; }
  }
}

/* ============================= CUSTOM CURSOR ============================= */
@layer components {
  /* The system cursor is only ever hidden by JS adding this class — never
     unconditionally in CSS — so a script failure leaves the real cursor
     intact instead of stranding the visitor with no pointer at all. */
  html.cursor-live, html.cursor-live * { cursor: none !important; }

  .cursor {
    position: fixed; top: 0; left: 0;
    inline-size: 0; block-size: 0;
    pointer-events: none;
    z-index: 999;
    opacity: 0;
    transition: opacity .25s;
  }

  /* a small ring with a smaller dot at its centre — nothing more. It just
     trails the pointer and tightens very slightly over anything clickable. */
  .cursor__dot, .cursor__ring {
    position: absolute; top: 0; left: 0;
    border-radius: 50%;
    transform: translate(-50%, -50%);
  }
  .cursor__dot {
    inline-size: 3px; block-size: 3px;
    background: var(--accent);
  }
  .cursor__ring {
    inline-size: 16px; block-size: 16px;
    border: 1px solid color-mix(in oklab, var(--accent) 55%, transparent);
    transition: inline-size .2s var(--ease-draw), block-size .2s var(--ease-draw),
      border-color .2s, transform .15s var(--ease-draw);
  }

  /* pressed: a small, quiet contraction */
  .cursor.is-down .cursor__ring { transform: translate(-50%, -50%) scale(.75); }

  /* over a link, button or other control: the ring tightens and solidifies */
  .cursor.is-link .cursor__ring {
    inline-size: 22px; block-size: 22px;
    border-color: var(--accent);
  }

  @media (prefers-reduced-motion: reduce) {
    .cursor__dot, .cursor__ring { transition-duration: .05s; }
  }
}

/* ============================= RESPONSIVE / MISC ============================= */
@layer utilities {
  @media (max-width: 480px) {
    .rail-label { display: none; }
  }
}
