/*
 * Design tokens for yuvivi.com.
 *
 * The values every page and component shares. They come from the decisions
 * in docs/ui-principles.md and match docs/style-guide.html. Change a value
 * here, not in the components, and keep the style guide in step.
 *
 * Loaded today by the reference pages only (/dev/style-guide, /dev/ui-kit).
 * Phase 3 → Styling, step 2 loads it on every page before main.css
 * (template/template.js) and moves main.css onto these names. Custom
 * properties pass into Lit components' shadow DOM, so components can use
 * them too.
 *
 * Status: every value decided (2026-11-14).
 */

/* 中文: always PingFang SC Regular, at every weight (decided 2026-11-14).
   Without this, a bold Gaegu line falls back to PingFang SC Semibold for its
   Chinese characters. The face only offers weight 400, so a bold request
   still gets it; PingFang is a variable font on new macOS, and the 400 also
   stops the browser turning its weight axis up. Gaegu lines also set
   font-synthesis-weight: none, so the Chinese isn't faked bold either.
   unicode-range keeps it to CJK characters and punctuation. */
@font-face {
  font-family: 'Vivi PingFang';
  src: local('PingFangSC-Regular'), local('PingFang SC Regular');
  font-weight: 400;
  unicode-range: U+2E80-2FDF, U+3000-303F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF;
}

:root {
  /* ---------- Colors: palette C, "Peach cream" (decided 2026-11-14) ---------- */

  /* Base */
  --color-bg: #fdf8ef;              /* page background (cream), about 60% */
  --color-surface: #ffffff;         /* cards, inputs, popups */
  --color-line: #eedfcb;            /* dividers and card edges (decoration, not UI edges) */
  --color-tag: #f3e8dc;             /* tag and quiet chip fill */

  /* Text */
  --color-text: #553636;            /* body text and titles: 10.1:1 on the page */
  --color-text-muted: #7a5e5a;      /* dates, intros, captions: 5.6:1 on the page */

  /* Brand */
  --color-ink: #9e1a12;             /* comic ink: logo, Gaegu lines, pixel outlines, button labels: 7.6:1 on the page */
  --color-link: #a8322b;            /* links, current nav, focus ring: 6.3:1 on the page */
  --color-petal: #ffc2bd;           /* main button, current filter. Ink on it: 5.2:1 */
  --color-petal-hover: #ffb3b0;     /* main button hover. Ink on it: 4.7:1 */
  --color-pink: #ff8f8f;            /* Vivi pink: pixel shadow, decoration. Never text (2.1:1 on the page) */
  --color-coral: #cc5f52;           /* the focus cursor on buttons: 3.7:1 on the page, 3.9:1 on white. Not for text */

  /* Text highlight (decided 2026-11-14): selected text (::selection) and
     the works search match (.highlight). Butter, like a highlighter pen:
     body text on it is 8.3:1, and it stays visible on the petal links and
     buttons (petal would vanish there). */
  --color-highlight: var(--color-dot-butter);
  --color-on-highlight: var(--color-text);

  /* Feedback */
  --color-success: #5f6619;         /* on --color-success-soft: 5.2:1 */
  --color-success-soft: #edefce;
  --color-error: #b0261f;           /* on --color-error-soft: 5.5:1 */
  --color-error-soft: #fde3da;

  /* The five dot pastels: falling dots, pixel art, decoration. Never a
     state, with one exception: butter is the text highlight (above).
     Body text on each passes (6.2 to 8.3:1). */
  --color-dot-pink: #ffb0c4;
  --color-dot-peach: #fcc9a8;
  --color-dot-butter: #fde08f;
  --color-dot-matcha: #d2d98a;
  --color-dot-sky: #b6def5;

  /* ---------- Type: two fonts (decided 2026-11-14) ---------- */

  /* Windows has no PingFang: Microsoft YaHei (simplified) is the fallback. */
  --font-zh: 'Vivi PingFang', PingFangSC-Regular, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  /* Everything you read or use: nav, titles, body, buttons, forms, tags, dates */
  --font-body: 'Source Sans Pro', var(--font-zh);
  /* A few words at a time: logo, greeting, section titles, map flags, 404 */
  --font-display: 'Gaegu', var(--font-body);
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; /* code in posts (Vivi, 2026-11-15): the system's own, nothing to load */
  --weight-display: 700;
  --weight-strong: 600;             /* bold words in reading text: Source Sans Pro Semibold (Vivi, 2026-11-15; never synthesised; 中文 stays 400, in ink). Italic: Source Sans Pro Italic, real, never slanted by the browser; 中文 upright, in ink */

  /* Decided 2026-11-14: the type scale. Nine steps; each role uses one.
     Gaegu reads about 15% smaller than Source Sans at the same size, so a
     Gaegu line sits one step above the Source Sans text it goes with. */
  --text-xs: 12px;                  /* small labels: dates, tags, captions (uppercase) */
  --text-nav: 14px;                 /* the header nav's labels (ui-button large) */
  --text-sm: 13px;                  /* labels: buttons, filters, tags (uppercase) */
  --text-base: 15px;                /* UI text: cards, sidebar, forms, popups, intros */
  --text-prose: 17px;               /* reading text: post and work body */
  --text-md: 20px;                  /* subheadings in posts and work pages */
  --text-lg: 24px;                  /* post titles in the list; Gaegu section titles */
  --text-xl: 28px;                  /* Gaegu logo */
  --text-2xl: 36px;                 /* page and post titles (28 on phones) */
  --text-3xl: 48px;                 /* Gaegu greeting and 404 (36 on phones) */

  --leading-tight: 1.15;            /* Gaegu display lines */
  --leading-title: 1.3;             /* titles */
  --leading-body: 1.6;              /* UI text */
  --leading-prose: 1.75;            /* reading text (1.85 for 中文, below) */
  --measure-prose: 68ch;            /* the widest a reading column gets */
  /* The blog post's text (Vivi, 2026-11-18, T2: today's 17px felt huge;
     the old site's small, spaced-out feeling, kept readable): 15px
     (--text-base) at 1.65 (1.75 中文), 0.5px apart (none in 中文), in a
     640px column (about 80 characters a line; 560 until Vivi's W3 the
     same day, with the page narrowed round it) */
  --leading-post: 1.65;
  --tracking-post: 0.5px;
  --measure-post: 640px;
  --tracking-label: 1px;            /* uppercase labels only */

  /* ---------- Space, shape, depth ---------- */

  /* Decided 2026-11-14: a 4px step. Small steps inside a component,
     bigger ones between groups and sections. The pixel sprites keep their
     own 5px pixel (pixel.css); this grid is for layout. */
  --space-1: 4px;                   /* icon to text, tag padding top and bottom */
  --space-2: 8px;                   /* label to field, between chips and buttons */
  --space-3: 12px;                  /* inside small components (button sides, popup rows) */
  --space-4: 16px;                  /* card padding, phone gutter, related items */
  --space-5: 24px;                  /* between groups, card grid gap, gutter from tablet */
  --space-6: 32px;                  /* between blocks in a section */
  --space-7: 48px;                  /* between sections on phones */
  --space-8: 64px;                  /* between sections from tablet up, page top */

  --content-max: 1200px;

  /* Corners (decided 2026-11-14): a 2px radius on everything structural
     (cards, inputs, buttons, panels): just softened. Stepped pixel corners
     only on game pieces (tags, level flags, the map popup, the 404 badge).
     First decided as 4px; buttons tried 4px, 2px, square, pill and pixel
     corners, and 2px won, then everything followed. */
  --radius-sm: 2px;                 /* small inner pieces (code chips, the lang toggle) */
  --radius: 2px;
  --radius-button: var(--radius);
  /* Links in text (decided 2026-11-14): a petal marker stroke under the
     words that rises to fill the line on hover */
  --link-marker: 38%;               /* the stroke's height, from the bottom of the line */
  --link-focus-bar: 3px;            /* link focus: the marker fills and an ink bar this thick runs under each line */
  /* Pixel corners (decided 2026-11-14, Vivi: A, one 4px notch, over a 2px
     stair of two or three steps): game pieces only (tags, the 404 badge,
     bubbles and cards). The same step as the game cursor's bevel.
     A clip-path shape: cut a fill with it, or cut each layer (line, fill,
     pixel shadow) with it, so the line and shadow follow the steps. */
  --pixel-corner: 4px;              /* the notch */
  --pixel-line: 2px;                /* the outline on a framed game piece (its flags and popup were removed 2026-11-16; kept for the next framed piece) */
  --pixel-corner-shape: polygon(
    0 var(--pixel-corner), var(--pixel-corner) var(--pixel-corner), var(--pixel-corner) 0,
    calc(100% - var(--pixel-corner)) 0, calc(100% - var(--pixel-corner)) var(--pixel-corner), 100% var(--pixel-corner),
    100% calc(100% - var(--pixel-corner)), calc(100% - var(--pixel-corner)) calc(100% - var(--pixel-corner)), calc(100% - var(--pixel-corner)) 100%,
    var(--pixel-corner) 100%, var(--pixel-corner) calc(100% - var(--pixel-corner)), 0 calc(100% - var(--pixel-corner)));

  /* Shadows are always the hard pixel shadow, never blurred */
  --shadow-pixel: 4px 4px 0 var(--color-pink);
  --shadow-pixel-sm: 3px 3px 0 var(--color-pink);

  /* Focus. Buttons: the game cursor (decided 2026-11-14): four solid coral
     corner brackets with a pixel bevel (the corner pixel left out), that grow
     out from the button edge and step out past the pixel shadow on hover.
     Links: the marker fills with an ink bar (--link-focus-bar; coral until
     2026-11-18, 2.6:1 on the petal marker). The
     dashed ring is for everything else (the kit's own links, summaries). */
  --focus-ring: 2px dashed var(--color-link);
  --focus-cursor-color: var(--color-coral);  /* 3.7:1 on the page, 3.9:1 on white (3:1 needed) */
  --focus-cursor-gap: 6px;                   /* from the button edge to the brackets */
  --focus-cursor-arm: 9px;                   /* each bracket's arm */
  --focus-cursor-width: 3px;
  --focus-cursor-bevel: 3px;                 /* the corner pixel left out (= the width) */

  /* ---------- Motion (decided 2026-11-14) ----------
     The UI moves smoothly and briefly; game pieces move in steps, like a
     sprite. "Reduce motion" turns movement off (colors still change). */
  --duration-instant: 80ms;         /* press */
  --duration-fast: 120ms;           /* hover: fill, pixel shadow, underline */
  --duration: 200ms;                /* menus, messages, fades */
  --duration-slow: 320ms;           /* the map popup, the phone menu */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);   /* UI: quick start, soft landing */
  --ease-pixel: steps(4, jump-end);              /* game pieces: four frames, like the 12fps sprites */

  /* Breakpoints can't be custom properties (@media can't read them):
     write 768px (tablet) and 1024px (desktop) as numbers. */
}

/* Phones: the two biggest title steps come down one step each */
@media (max-width: 767px) {
  :root {
    --text-2xl: 28px;
    --text-3xl: 36px;
  }
}

/* Chinese reading text gets a little more room between lines */
:lang(zh) {
  --leading-prose: 1.85;
  --leading-post: 1.75;
}

