/*
  You Had to Be There: design tokens.

  The only place a raw size, colour, time or layer number is written. Every other
  stylesheet uses these names; `scripts/` checks that (see design/README.md, "Checks").
  What JavaScript needs and CSS can't hold (lane positions, springs, haptics, sound
  levels) is in design/tokens.js. The decade palettes stay data, in themes.js.

  Sizes are in rem so the page follows the reader's text size. 1rem = 16px at default.
*/

@layer tokens {
  :root {
    /* ── Space: a 4 px scale ─────────────────────────────────────────────── */
    --space-0: 0;
    --space-1: 0.25rem; /*  4 */
    --space-2: 0.5rem; /*  8 */
    --space-3: 0.75rem; /* 12 */
    --space-4: 1rem; /* 16 */
    --space-5: 1.5rem; /* 24 */
    --space-6: 2rem; /* 32 */
    --space-7: 3rem; /* 48 */
    --space-8: 4rem; /* 64 */
    --space-9: 6rem; /* 96 */

    /* ── Layout (phone first; the breakpoints below change these) ────────── */
    --margin: var(--space-4); /* page edge to content */
    --sheet-pad: var(--margin); /* a sheet's inset is the page margin: one left edge down the page */
    --cols: 4; /* wall columns */
    --rows-per-screen: 6; /* wall rows that fill one screen under the bar */
    --control: 2.75rem; /* 44: height of buttons, and the smallest touch target */
    --bar: calc(var(--control) + 2 * var(--space-2)); /* 60 touch, 48 with a mouse */
    --bar-mast: var(--space-8); /* Round 8, flag "masthead": the masthead from 600 px up, 64 */
    --bar-phone: 6rem; /* Round 8, flag "phoneBar": the two-row bar on a wall under 600 px, 96 */
    --row: max(calc((100dvh - var(--bar)) / var(--rows-per-screen)), 4.5rem);
    --measure: 34rem; /* longest line of running text, about 65 characters */
    --curl: var(--space-5); /* a sheet's curled corner at rest */
    --curl-lifted: var(--space-6); /* on hover or focus */
    --roll: var(--space-6); /* how thick a rolled-up sheet is, along its own top edge */
    --lift: var(--space-1); /* how far a sheet rises under the pointer (the living wall) */
    --tilt: 1.5deg; /* and how far it leans toward the pointer, at most */
    --sheen: 8%; /* the strength of the light that crosses a lifted sheet; light, never colour */
    --perspective: calc(var(--space-9) * 10); /* 960: the depth a lifted sheet leans in (added in the build) */
    --icon: 1rem; /* 16: an icon (added in the build: README "Icons are 16 px in a 20 px box") */
    --icon-box: 1.25rem; /* 20: the box it sits in */
    --switch-bar: 0.1875rem; /* 3: one of the switch's level bars (added in the build) */

    /* ── Lines and shape ─────────────────────────────────────────────────── */
    --line: 1px; /* rules and control borders */
    --line-strong: 2px; /* focus ring, the field's underline */
    --line-heavy: 4px; /* the field's underline in focus, a visited decade */
    --radius: 0; /* paper has square corners; nothing is rounded */
    --focus-offset: 2px; /* outside a control */
    --focus-inset: -4px; /* inside a sheet, so the ring is never clipped by a neighbour */

    /* ── Colour: the product (Now) ───────────────────────────────────────── */
    --stock: #edede8; /* plain paper */
    --black: #000000; /* print black */
    --now-ground: var(--stock);
    --now-ink: var(--black);
    --now-ink-soft: color-mix(in srgb, var(--black) 68%, var(--stock)); /* 7.3:1 on stock: sources, hints */
    --now-ink-disabled: color-mix(in srgb, var(--black) 42%, var(--stock));
    --now-inverse-ground: var(--black); /* hover, pressed, "on" */
    --now-inverse-ink: var(--stock);
    --overlay: color-mix(in srgb, var(--stock) 88%, transparent);

    /* ── Colour: the era (Then). Set per sheet from the decade's pair ─────── */
    --paper: var(--stock); /* the decade's paper, set on the wall */
    --deep: var(--black); /* the decade's darkest ink, set on the wall */
    --ground: var(--now-ground); /* this sheet's ground */
    --ink: var(--now-ink); /* this sheet's ink: text, borders, focus ring, halftone dots */
    --flap-ground: var(--paper); /* the back of the paper: a curl, a flap being peeled, a roll */
    --under-ground: color-mix(in srgb, var(--paper) 92%, var(--black)); /* only the cell uncovered beneath a sheet: its story */
    --under-ink: var(--deep);
    --placeholder: 10%;
    --hero: 60dvh; /* an open sheet's hero photo or video (round 6) */
    --strip-photo: calc(var(--space-9) * 3); /* one photo in an open sheet's strip (round 6) */
    --cover-strength: 0.16; /* how strongly the start screen's drifting photos show through the stock (round 6) */
    --t-drift: 90s; /* one slow drift of the start screen's photos (round 6) */ /* how much ink tints the ground of a block that is still loading (added in round 5) */
    --shade: 18%; /* how much darker paper gets towards a fold, and around a roll (added in the build) */
    /* Round 8: the paper's tooth, one static tile under the type, in normal blend (design/tokens.js TOOTH makes it) */
    --tooth: url("/prototypes/paper/paper/tooth.png");
    --tooth-now: url("/prototypes/paper/paper/tooth-now.png"); /* the Now surfaces, at half the sheets' strength */
    --tooth-size: 16rem; /* the 512 px tile at 256 CSS px: crisp at dpr 2 */
    --fold-strength: 0; /* how deep a sheet's folds are, set per wall from its age (0 is unfolded) */
    --fold-valley: 6px; /* the shaded side of a fold, beside its 1 px ridge */
    --fold-x: 50%; /* where a sheet's folds fall, set per sheet between 38% and 46% so they miss the type's middle */
    --fold-y: 50%;
    --seam-strength: 0.35; /* the inner shade along a sheet's edge, as a share of --shade */
    --seam-width: 2px;

    /* ── Shadow: only on paper that is off the wall ──────────────────────── */
    --shadow-flap: 0 2px 6px rgb(0 0 0 / 0.28); /* a curl or a peeled flap */
    --shadow-lift: 0 12px 28px rgb(0 0 0 / 0.22); /* a sheet on its way to open */
    --shadow-living: 0 3px 10px rgb(0 0 0 / 0.18); /* a sheet lifted under the pointer */
    --shadow-roll: 0 4px 8px rgb(0 0 0 / 0.3); /* under a rolled-up sheet */

    /* ── Type: the product's face ────────────────────────────────────────── */
    --now: "Instrument Sans", system-ui, sans-serif;
    --text-1: 0.8125rem; /* 13: the floor; nothing is smaller */
    --text-2: 0.875rem; /* 14 */
    --text-3: 1rem; /* 16 */
    --text-4: 1.25rem; /* 20 */
    --text-5: 1.5rem; /* 24 */
    --text-6: 2rem; /* 32 */
    --text-field: clamp(2rem, 0.5rem + 6vw, 5.5rem); /* 32 at 390, 54 at 768, 88 from about 1400 */

    /* Named by job: weight size/line-height family. Use as `font: var(--font-label)`. */
    --font-field: 600 var(--text-field) / 1.05 var(--now); /* the start field */
    --font-prompt: 500 var(--text-3) / 1.5 var(--now); /* "Take me back to" */
    --font-label: 600 var(--text-3) / 1.25 var(--now); /* a sheet's label */
    --font-mark: 700 condensed var(--text-5) / 1 var(--now); /* Round 8: the wordmark, Instrument Sans at 75% width */
    --font-mast-title: 700 var(--text-5) / 1.1 var(--now); /* Round 8: the moment's name in the masthead, fitted down to --text-3 */
    --font-cell: 600 var(--text-3) / 1.1 var(--now); /* Round 8: an answer in the masthead's dateline */
    --font-source: 500 var(--text-1) / 1.35 var(--now); /* a sheet's source line, captions, credits */
    --font-control: 600 var(--text-2) / 1 var(--now); /* buttons, tabs, the switch */
    --font-bar-title: 600 var(--text-2) / 1.2 var(--now); /* the moment and its date in the bar */
    --font-link: 600 var(--text-3) / 1.25 var(--now); /* topics on a decade card */
    --font-body: 400 var(--text-3) / 1.5 var(--now); /* the story behind a sheet */
    --font-dialog-title: 600 var(--text-5) / 1.15 var(--now);
    --font-status: 500 var(--text-1) / 1.35 var(--now); /* "Asking Wikipedia about …" */
    --font-narration-title: 700 clamp(1.5rem, 1.1rem + 1.6vw, 2rem) / 1.1 var(--now); /* "The 1990s" */
    --font-narration-line: 500 var(--text-3) / 1.35 var(--now); /* the decade's moment */
    --font-hint: 500 var(--text-2) / 1.35 var(--now);

    --track-field: -0.02em;
    --track-tight: -0.01em; /* narration and dialog titles */
    --track-none: 0;
    --track-small: 0.005em; /* 13 px text */

    /* ── Type: the era's face. Set on the wall from the decade's theme ───── */
    --then-face: var(--now);
    --then-weight: 800;
    --then-leading: 0.95; /* per face, 0.9 to 1 */
    --then-tracking: 0;
    --answer-min: 2rem; /* an answer is never set smaller (phone) */
    --answer-min-face: var(--answer-min); /* the face lane's name: the photo carries that sheet, so on desktop it may be smaller */
    --answer-max-share: 0.42; /* of the sheet's height, for one line */
    --answer-lines: 4; /* at most */
    --decade-size: 1.75rem; /* a decade's name on its card, in its face */
    --counter-size: clamp(4rem, 2rem + 8vw, 8rem); /* the rolling year */
    --counter-digit: 0.66em; /* one digit's cell in the rolling year (added in the build) */

    /* ── Layers. An open sheet is a modal <dialog>: the top layer, above all of these ── */
    --z-cover: -1; /* the start screen's drifting photos, under everything on the present (round 6) */
    --z-wall: 0;
    --z-raised: 1; /* a control floating over a photo inside a component, like an open sheet's Close (round 6) */
    --z-sheet-lifted: 10; /* a sheet being peeled or on its way to open */
    --z-bar: 20;
    --z-fall: 30;
    --z-hud: 40; /* narration, the counter, the fall's controls */
    --z-bubble: 50; /* hints, "Link copied" */

    /* ── Motion ──────────────────────────────────────────────────────────── */
    --t-press: 120ms; /* hover, press, a switch flipping */
    --t-quick: 180ms; /* a hint, a bubble, a curl lifting */
    --t-move: 280ms; /* something small changing place */
    --t-paste: 420ms; /* one sheet going on the wall */
    --t-open: 560ms; /* a sheet opening or closing */
    --t-land: 720ms; /* the settle after a fall */
    --t-fade: 160ms; /* what replaces all of the above under reduced motion */
    --stagger-paste: 90ms; /* between one sheet and the next */
    --stagger-digit: 45ms; /* Round 8: between one digit of an odometer and the one to its left */
    --ruler-bar: var(--space-7); /* Round 8: the busiest year's bar on a decade card's ruler */
    --ease-arrive: cubic-bezier(0.16, 1, 0.3, 1); /* things coming to rest */
    --ease-leave: cubic-bezier(0.7, 0, 0.84, 0); /* things going away */
    --ease-travel: cubic-bezier(0.65, 0, 0.35, 1); /* from one place to another */
    --ease-press: cubic-bezier(0.3, 0, 0.5, 1);
  }

  /* Tablet: 600 and up */
  @media (min-width: 600px) {
    :root {
      --margin: var(--space-5);
      --cols: 8;
      --rows-per-screen: 8;
      --answer-min: 2.25rem;
    }
  }

  /* Desktop: 1024 and up. The wall is one screen: 12 columns by 8 rows, no scroll */
  @media (min-width: 1024px) {
    :root {
      --cols: 12;
      --rows-per-screen: 8;
      --answer-min: 2.5rem;
      --answer-min-face: 2.125rem; /* 34: for the face lane only, a little under the desktop minimum */
    }
  }

  /* Wide: 1600 and up */
  @media (min-width: 1600px) {
    :root {
      --margin: var(--space-6);
    }
  }

  /* A mouse or trackpad: controls can be 32 high (targets stay 24 or more) */
  @media (hover: hover) and (pointer: fine) {
    :root {
      --control: 2rem;
    }
  }

  /* Reduced motion: nothing travels; things appear in place with a short fade */
  @media (prefers-reduced-motion: reduce) {
    :root {
      --t-press: 0.01ms;
      --t-quick: 0.01ms;
      --t-move: 0.01ms;
      --t-paste: var(--t-fade);
      --t-open: var(--t-fade);
      --t-land: var(--t-fade);
      --stagger-paste: 60ms;
    }
  }
}
