/*
 * Design tokens. Everything the screens look like is decided in this one file, in two layers:
 *
 *   1. PRIMITIVES  the raw material: the palette, the type scale, the spacing scale, the radii, the shadows,
 *                  under PowerPages' own names. The look is PowerPages' own, made from two style references:
 *                  a crisp white desk with flat, hairline-edged surfaces, pill-shaped controls and one signal
 *                  blue for what is pointed at (from the second); warm ink and greys, a serif headline, the
 *                  clay mark and a compact build (from the first). Colour is rare and always means something:
 *                  a soft tint for each kind of page, and a state.
 *   2. ROLES       what each value is FOR: the page's background, a button's fill, a card's corner, the colour
 *                  of the "Full story" chapter. A role only ever points at a primitive.
 *
 * The stylesheet (app.css) uses roles only, never a primitive and never a value of its own
 * (tests/pages.test.ts holds the same rule for pages.css). So:
 *   - to restyle one thing everywhere (all buttons, all cards), change its role;
 *   - to change the whole look, change the primitives;
 *   - nothing has to be hunted down in the stylesheet or the markup.
 */

/* Self-hosted fonts, open licences (fonts/LICENSE-*.txt). No third-party font requests.
   Source Serif 4 for headlines (set tight and medium, not light and loose), Inter for everything else. */
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    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;
}
@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  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: "Source Serif 4 Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url("fonts/source-serif-4-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    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;
}
@font-face {
  font-family: "Source Serif 4 Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url("fonts/source-serif-4-latin-wght-normal.woff2") format("woff2-variations");
  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;
}

/* ==================================================================================================
   1. PRIMITIVES
   ================================================================================================== */
:root {
  color-scheme: light;

  /* Colours: the desk and the ink. White paper, a warm cream for what is set into it, warm near-black ink. */
  --color-paper: #ffffff;
  --color-cream: #f6f5f1;
  --color-stone: #edebe5;
  --color-hairline: #e6e2d9;
  --color-edge: #8a867e;          /* the edge of anything that can be used: 3:1 or more on paper and cream */
  --color-ink: #141413;
  --color-ink-soft: #2e2d2a;
  --color-body: #403f3b;
  --color-muted: #64625c;         /* 5.5:1 on cream */
  --color-faint: #75726b;         /* 4.8:1 on paper */

  /* Colours: the one signal (links, the keyboard ring, what is being worked on), and its wash */
  --color-signal: #3557e8;
  --color-signal-deep: #2a46c4;
  --color-signal-wash: #edf1fd;

  /* Colours: the mark, and the states. Each strong colour has a wash it is written on. */
  --color-clay: #d97757;
  --color-clay-deep: #9a4322;
  --color-clay-wash: #fbeee8;
  --color-leaf: #1f6b3f;
  --color-leaf-wash: #e8f3ec;
  --color-amber: #8a5a00;
  --color-amber-wash: #fbf3e2;

  /* Typography: families (the serif for headlines only, the sans for everything else) */
  --font-serif: "Source Serif 4 Variable", ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --font-sans: "Inter Variable", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Typography: scale. The sans runs 12 to 17px, the serif 22 to 40px and is set tight. */
  --text-12: 12px;
  --text-13: 13px;
  --text-14: 14px;
  --text-15: 15px;
  --text-17: 17px;
  --text-22: 22px;
  --text-28: 28px;
  --text-32: 32px;
  --text-40: 40px;
  --leading-tight: 1.1;
  --leading-snug: 1.25;
  --leading-control: 1.4;
  --leading-text: 1.55;
  --tracking-display: -0.025em;
  --tracking-title: -0.02em;
  --tracking-heading: -0.01em;
  --tracking-none: normal;
  --tracking-label: 0.06em;
  --case-upper: uppercase;

  /* Typography: weights. 600 is the heaviest in use; headlines speak at 500. */
  --font-weight-400: 400;
  --font-weight-500: 500;
  --font-weight-600: 600;

  /* Spacing: a 4px base */
  --space-0: 0px;
  --space-4: 4px;
  --space-6: 6px;
  --space-8: 8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-20: 20px;
  --space-24: 24px;
  --space-32: 32px;
  --space-40: 40px;
  --space-48: 48px;
  --space-64: 64px;
  --space-80: 80px;

  /* Radii: soft, never sharp; anything that is pressed is a pill */
  --radius-0: 0px;
  --radius-8: 8px;
  --radius-10: 10px;
  --radius-14: 14px;
  --radius-20: 20px;
  --radius-24: 24px;
  --radius-pill: 999px;

  /* Shadows: flat by design. Edges are hairlines; only the main button has a touch of depth. */
  --shadow-press: 0 1px 1px 0 rgba(20, 20, 19, 0.16), inset 0 1px 0 0 rgba(255, 255, 255, 0.12);
  --shadow-none: 0 0 0 0 transparent;

  /* What a control and a list need */
  --stroke-1: 1px;
  --stroke-2: 2px;
  --stroke-icon: 1.75;
  --layer-raised: 2;
  --scale-sign: 60%;
  --size-12: 12px;
  --size-16: 16px;
  --size-20: 20px;
  --size-24: 24px;
  --size-40: 40px;
  --size-48: 48px;
  --switch-track-width: 36px;
  --switch-track-height: 20px;
  --switch-knob: 14px;
  --bar-thickness: 4px;
  --width-page: 1200px;
  --width-form: 800px;
  --width-auth: 420px;
  --width-tag: 200px;
  --width-card: 260px;
  --width-choice: 200px;
  --width-thumb: 128px;
  --height-list: 320px;
  --measure-reading: 68ch;
  --measure-short: 52ch;
  --ratio-film: 16 / 9;
  --opacity-off: 0.5;
  --opacity-solid: 1;
  --opacity-none: 0;
  --duration-none: 0s;
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-loop: 1400ms;
  --easing-out: cubic-bezier(0.2, 0, 0, 1);
  /* Shapes only: a sign takes its colour from the role that uses it, never from here. */
  --shape-chevron-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --shape-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

/* ==================================================================================================
   2. ROLES
   ================================================================================================== */
:root {
  /* The page: white paper */
  --page-bg: var(--color-paper);
  --page-max: var(--width-page);
  --page-form-max: var(--width-form);
  --page-auth-max: var(--width-auth);
  --page-gutter: var(--space-24);
  --page-top: var(--space-48);
  --page-bottom: var(--space-80);

  /* Ink: what is written. A link in a sentence is the signal blue, underlined. */
  --ink-headline: var(--color-ink);
  --ink: var(--color-ink);
  --ink-body: var(--color-body);
  --ink-muted: var(--color-muted);
  --ink-faint: var(--color-faint);
  --ink-on-dark: var(--color-paper);
  --ink-link: var(--color-signal);
  --ink-link-hover: var(--color-signal-deep);
  --ink-danger: var(--color-clay-deep);

  /* Lines */
  --line: var(--color-hairline);
  --line-strong: var(--color-ink);
  --line-width: var(--stroke-1);
  --line-width-strong: var(--stroke-2);

  /* Type: the two faces, and each kind of text with its size, line height, spacing and weight */
  --font-display: var(--font-serif);
  --font-ui: var(--font-sans);
  --weight-regular: var(--font-weight-400);
  --weight-medium: var(--font-weight-500);
  --weight-strong: var(--font-weight-600);
  --weight-display: var(--font-weight-500);
  --type-display-size: var(--text-40);
  --type-display-leading: var(--leading-tight);
  --type-display-tracking: var(--tracking-display);
  --type-title-size: var(--text-32);
  --type-title-leading: var(--leading-tight);
  --type-title-tracking: var(--tracking-title);
  --type-heading-size: var(--text-17);
  --type-heading-leading: var(--leading-snug);
  --type-heading-tracking: var(--tracking-heading);
  --type-subheading-size: var(--text-15);
  --type-subheading-leading: var(--leading-control);
  --type-subheading-tracking: var(--tracking-none);
  --type-lead-size: var(--text-17);
  --type-lead-leading: var(--leading-text);
  --type-lead-tracking: var(--tracking-none);
  --type-body-size: var(--text-15);
  --type-body-leading: var(--leading-text);
  --type-body-tracking: var(--tracking-none);
  --type-caption-size: var(--text-13);
  --type-caption-leading: var(--leading-control);
  --type-caption-tracking: var(--tracking-none);
  --type-eyebrow-size: var(--text-12);
  --type-eyebrow-tracking: var(--tracking-label);
  --type-eyebrow-case: var(--case-upper);
  --measure-text: var(--measure-reading);
  --measure-text-short: var(--measure-short);

  /* The name in the top bar, and the mark beside it: the one place the clay appears as a fill */
  --brand-font: var(--font-serif);
  --brand-size: var(--text-22);
  --brand-leading: var(--leading-snug);
  --brand-weight: var(--font-weight-500);
  --brand-tracking: var(--tracking-title);
  --mark-bg: var(--color-clay);
  --mark-ink: var(--color-paper);

  /* Space between things */
  --gap-none: var(--space-0);
  --gap-2xs: var(--space-4);
  --gap-xs: var(--space-8);
  --gap-sm: var(--space-12);
  --gap-md: var(--space-16);
  --gap-lg: var(--space-24);
  --gap-xl: var(--space-32);
  --gap-2xl: var(--space-40);
  --howto-indent: var(--space-40);
  --gap-section: var(--space-64);

  /* The top bar: white, with a hairline under it */
  --nav-bg: var(--color-paper);
  --nav-shadow: var(--shadow-none);
  --nav-line: var(--color-hairline);
  --nav-pad-y: var(--space-12);
  --nav-link-ink: var(--color-muted);
  --nav-link-ink-current: var(--color-ink);
  --nav-link-mark: var(--color-ink);
  --nav-link-size: var(--text-14);
  --nav-link-weight: var(--font-weight-500);

  /* The strip under the top bar that says one thing is still to do: the signal's wash */
  --announce-bg: var(--color-signal-wash);
  --announce-ink: var(--color-ink);
  --announce-pad-y: var(--space-8);

  /* A card: paper with a hairline edge, flat */
  --card-bg: var(--color-paper);
  --card-line: var(--color-hairline);
  --card-round: var(--radius-20);
  --card-pad: var(--space-24);
  --card-shadow: var(--shadow-none);
  --sunken-bg: var(--color-cream);
  --sunken-round: var(--radius-14);

  /* A feature: one card with a hairline edge; its name sits on a band of its chapter's tint, and what belongs to it
     on paper below, edge to edge */
  --feature-round: var(--radius-20);
  --feature-pad: var(--space-0);
  --feature-gap: var(--space-12);
  --feature-line: var(--color-hairline);
  --feature-label-pad-y: var(--space-16);
  --feature-panel-bg: var(--color-paper);
  --feature-panel-round: var(--radius-0);
  --feature-panel-pad: var(--space-24);
  --feature-chosen-line: var(--color-ink);
  --feature-chosen-line-width: var(--stroke-2);

  /* A frame: what holds the sentence */
  --frame-bg: var(--color-cream);
  --frame-ink: var(--color-ink);
  --frame-ink-muted: var(--color-muted);
  --frame-round: var(--radius-24);
  --frame-pad: var(--space-20);
  --frame-inner-round: var(--radius-14);
  --frame-field-line: var(--color-edge);

  /* The chapters: each part of the settings (each kind of page has its own, further down). The parts of the
     settings are cream, the same as every other frame. Ink is the same near-black on all of them. */
  --chapter-ai: var(--color-cream);
  --chapter-ai-ink: var(--color-ink);
  --chapter-assistant: var(--color-cream);
  --chapter-assistant-ink: var(--color-ink);
  --chapter-voice: var(--color-cream);
  --chapter-voice-ink: var(--color-ink);
  --chapter-plain: var(--color-cream);
  --chapter-plain-ink: var(--color-ink);

  /* Actions: the main button is an ink pill; the one beside it a paper pill with a visible edge */
  --action-bg: var(--color-ink);
  --action-bg-hover: var(--color-ink-soft);
  --action-ink: var(--color-paper);
  --action-shadow: var(--shadow-press);
  --action-round: var(--radius-pill);
  --action-weight: var(--font-weight-500);
  --action-size: var(--text-15);
  --action-leading: var(--leading-control);
  --ghost-bg: var(--color-paper);
  --ghost-bg-hover: var(--color-cream);
  --ghost-ink: var(--color-ink);
  --ghost-line: var(--color-edge);
  --quiet-bg-hover: var(--color-stone);
  --danger-bg: var(--color-clay-deep);
  --danger-bg-hover: var(--color-ink);
  --danger-ink: var(--color-paper);
  --action-pad-y: var(--space-8);
  --action-pad-x: var(--space-20);
  --action-pad-y-sm: var(--space-4);
  --action-pad-x-sm: var(--space-12);
  --action-pad-y-lg: var(--space-12);
  --action-pad-x-lg: var(--space-24);
  --focus-ring-colour: var(--color-signal);
  --focus-ring-width: var(--stroke-2);
  --off: var(--opacity-off);

  /* Fields: what is typed into */
  --field-bg: var(--color-paper);
  --field-ink: var(--color-ink);
  --field-line: var(--color-edge);
  --field-line-hover: var(--color-ink);
  --field-line-focus: var(--color-ink);
  --field-placeholder: var(--color-faint);
  --field-round: var(--radius-10);
  --field-pad-y: var(--space-8);
  --field-pad-x: var(--space-12);
  --switch-off: var(--color-edge);
  --switch-on: var(--color-ink);
  --switch-knob-bg: var(--color-paper);
  --switch-width: var(--switch-track-width);
  --switch-height: var(--switch-track-height);
  --switch-knob-size: var(--switch-knob);

  /* A choice shown as a card (a recipe for a page): its edge, and its edge when pointed at */
  --choice-line: var(--color-edge);
  --choice-line-hover: var(--color-ink);

  /* Tags: a short word in a small pill. A state is a wash with its colour's ink, a sign and a word. */
  --tag-round: var(--radius-pill);
  --tag-pad-y: var(--space-4);
  --tag-pad-x: var(--space-12);
  --tag-weight: var(--font-weight-500);
  --tag-plain-bg: var(--color-paper);
  --tag-plain-ink: var(--color-body);
  --tag-plain-line: var(--color-hairline);
  --state-making-bg: var(--color-signal-wash);
  --state-making-ink: var(--color-signal-deep);
  --state-making-line: var(--color-signal-wash);
  --state-ready-bg: var(--color-leaf-wash);
  --state-ready-ink: var(--color-leaf);
  --state-ready-line: var(--color-leaf-wash);
  --state-stopped-bg: var(--color-clay-wash);
  --state-stopped-ink: var(--color-clay-deep);
  --state-stopped-line: var(--color-clay-wash);
  --state-waiting-bg: var(--color-paper);
  --state-waiting-ink: var(--color-muted);
  --state-waiting-line: var(--color-hairline);
  --tag-on-frame-bg: var(--color-paper);
  --tag-on-frame-bg-hover: var(--color-stone);
  --tag-on-frame-ink: var(--color-ink);
  --tag-on-frame-line: var(--color-edge);
  --pill-chosen-bg: var(--color-ink);
  --pill-chosen-ink: var(--color-paper);

  /* Messages: a wash, ink words; a stop is said in the clay */
  --notice-round: var(--radius-14);
  --notice-pad: var(--space-16);
  --notice-good-bg: var(--color-leaf-wash);
  --notice-good-ink: var(--color-ink);
  --notice-warn-bg: var(--color-amber-wash);
  --notice-warn-ink: var(--color-ink);
  --notice-bad-bg: var(--color-clay-wash);
  --notice-bad-ink: var(--color-ink);
  --notice-bad-title: var(--color-clay-deep);

  /* How far along, and the steps: what is being worked on is the signal */
  --bar-track: var(--color-stone);
  --bar-fill: var(--color-signal);
  --bar-height: var(--bar-thickness);
  --step-done: var(--color-ink);
  --step-now: var(--color-signal);
  --step-todo: var(--color-edge);
  --step-stopped: var(--color-clay-deep);
  --step-sign: var(--shape-check);
  --step-sign-ink: var(--color-paper);
  --step-sign-scale: var(--scale-sign);
  --step-dot-size: var(--size-20);
  --spinner-track: var(--color-stone);
  --spinner-fill: var(--color-signal);

  /* Sizes of small things */
  --icon-sm: var(--size-16);
  --icon-md: var(--size-20);
  --icon-lg: var(--size-24);
  --mark-size: var(--size-24);
  --choice-tick-size: var(--size-20);
  --choice-tick-bg: var(--color-ink);
  --choice-tick-ink: var(--color-paper);
  --choice-tick-sign: var(--shape-check);
  --wizard-dot-size: var(--size-24);
  --empty-mark-size: var(--size-48);
  --icon-line: var(--stroke-icon);
  --round-small: var(--radius-8);
  --nav-layer: var(--layer-raised);
  --nav-tag-max: var(--width-tag);
  --card-min: var(--width-card);
  --choice-min: var(--width-choice);
  --filter-name-width: var(--space-64);
  /* A rating: filled stars in ink, the rest outlined in the edge colour (3:1 on paper). */
  --rating-on: var(--color-ink);
  --rating-off: var(--color-edge);
  --rating-star: var(--icon-sm);
  --rating-star-press: var(--icon-lg);
  /* Feedback: a green plus for what was good, an orange one for the opportunities for improvement, each with a
     white sign on its colour (3:1 or more, a graphic). */
  --point-good: var(--color-leaf);
  --point-better: var(--color-clay);
  --point-sign: var(--color-paper);
  --point-mark: var(--size-20);
  --point-sign-size: var(--size-12);
  --text-field-rows: var(--space-80);
  --list-max: var(--height-list);
  --film-thumb: var(--width-thumb);
  --film-ratio: var(--ratio-film);
  --film-pad: var(--space-16);
  --round-full: var(--radius-pill);
  --fold-sign: var(--shape-chevron-down);
  --fold-sign-ink: var(--color-ink);
  --shown: var(--opacity-solid);
  --hidden: var(--opacity-none);
  --no-shadow: var(--shadow-none);

  /* Motion: quick, and easing out */
  --motion-none: var(--duration-none);
  --motion-fast: var(--duration-fast);
  --motion-base: var(--duration-base);
  --motion-loop: var(--duration-loop);
  --ease: var(--easing-out);
}

/* On a phone the same roles take smaller steps of the same scale. */
@media (max-width: 40rem) {
  :root {
    --howto-indent: var(--space-24);
    --type-display-size: var(--text-32);
    --type-title-size: var(--text-28);
    --page-gutter: var(--space-16);
    --page-top: var(--space-24);
    --gap-section: var(--space-40);
    --card-pad: var(--space-16);
    --feature-panel-pad: var(--space-16);
    --feature-label-pad-y: var(--space-12);
    --film-pad: var(--space-12);
    --frame-pad: var(--space-16);
  }
}

/* ==================================================================================================
   THE LANDING PAGES (PAGES.md): their chapter's tint, and the screens a page is looked at on.
   Primitives first, then the roles that point at them; assets/pages.css uses the roles.
   ================================================================================================== */
:root {
  --color-tint-sage: #e9f2ec;
  --width-phone: 390px;
  --ratio-desktop: 1440 / 900;
  --ratio-phone: 390 / 844;
  --width-desktop: 1440px;
  --height-desktop: 900px;
  --scale-whole: 1;
  --width-pagetype-column: 176px;

  --chapter-full-story: var(--color-tint-sage);
  --chapter-full-story-ink: var(--color-ink);
  --chapter-full-story-2: var(--color-tint-sage);
  --chapter-full-story-2-ink: var(--color-ink);
  --chapter-full-story-3: var(--color-tint-sage);
  --chapter-full-story-3-ink: var(--color-ink);
  --chapter-scene-first: var(--color-tint-sage);
  --chapter-scene-first-ink: var(--color-ink);
  --chapter-vibe-design: var(--color-tint-sage);
  --chapter-vibe-design-ink: var(--color-ink);
  --chapter-conversion-copy: var(--color-tint-sage);
  --chapter-conversion-copy-ink: var(--color-ink);
  --chapter-phased-build: var(--color-tint-sage);
  --chapter-phased-build-ink: var(--color-ink);
  --chapter-systeme-prompt: var(--color-tint-sage);
  --chapter-systeme-prompt-ink: var(--color-ink);
  --pageview-desktop-ratio: var(--ratio-desktop);
  --pageview-desktop-width: var(--width-desktop);
  --pageview-desktop-height: var(--height-desktop);
  --pageview-scale: var(--scale-whole);
  --pageview-phone-width: var(--width-phone);
  --pageview-phone-ratio: var(--ratio-phone);
  --pageview-bg: var(--color-paper);
  --pageview-round: var(--radius-14);
  --pageview-phone-round: var(--radius-24);
  --pagetype-column: var(--width-pagetype-column);
  --pagetype-indent: var(--space-20);

  /* A page's film, on its screen: the curve of who is still watching, in the signal blue on paper. */
  --width-filmcurve: 640px;
  --height-filmcurve: 180px;
  --filmcurve-max: var(--width-filmcurve);
  --filmcurve-height: var(--height-filmcurve);
  --filmcurve-line: var(--color-signal);
  --filmcurve-line-width: var(--stroke-2);
  --filmcurve-area: var(--color-signal-wash);
  --filmcurve-grid: var(--color-hairline);
  --filmcurve-ink: var(--color-muted);
  --filmcurve-size: var(--text-12);
  --filmcurve-hover: var(--color-signal-wash);
}
