/* ==========================================================================
   Sublinea · design tokens v2 · identity B "Marca-texto"
   One file for canvas boards, the website and the app's WKWebView.

   Runtime floor: WebKit of macOS 11 (Safari 14.1). So, in this file:
   - no color-mix(), no @property, no linear() easing, no :has()
   - alpha colours come from RGB triplets:  rgba(var(--butter-rgb), .6)
     (custom properties are substituted before rgba() is parsed, which
     works in every WebKit we ship to)
   - everything newer is an enhancement in components.css, never a need.

   Email cannot read CSS variables. The "--mail-*" block and the
   "-solid" colours are mirrored by hand in libraread/emailer.py.
   ========================================================================== */

:root {
  /* ------------------------------------------------------------------ *
   * 1. Brand                                                            *
   * ------------------------------------------------------------------ */
  --brand-name: "Sublinea";

  /* ------------------------------------------------------------------ *
   * 2. Colour · neutrals                                                *
   * ------------------------------------------------------------------ */
  --ink-rgb: 35, 38, 43;
  --ink: #23262B;            /* graphite: all primary text, primary button   15.2:1 on white */
  --ink-2: #5A5F68;          /* secondary text                                6.4:1 on white, 4.9 on butter mark */
  --ink-3: #6B7079;          /* placeholder, tertiary meta: only on >= .86 white (5.0:1). Never on a band */
  --ink-hover: #30343A;      /* primary button face on hover (lifts toward the light) */

  --paper-rgb: 251, 250, 247;
  --paper: #FBFAF7;          /* page */
  --surface-rgb: 255, 255, 255;
  --surface: #FFFFFF;        /* solid card, input fill, reduced-transparency fallback */
  --paper-deep: #F5F2EC;     /* the email outer page and print-like slabs */

  --line: rgba(var(--ink-rgb), 0.09);         /* hairline divider (decorative) */
  --line-strong: rgba(var(--ink-rgb), 0.16);  /* quiet button / pill ring (text carries meaning) */
  --line-control: rgba(var(--ink-rgb), 0.24); /* input & chip resting ring */
  --line-signal: rgba(var(--ink-rgb), 0.55);  /* 3.5:1: the "writing line" under inputs, off tracks, unselected radios */

  /* ------------------------------------------------------------------ *
   * 3. Colour · the four Kindle highlight colours                       *
   *    aura   = the light source at the edges (glows, auras, washes)    *
   *    mark   = the marker band behind text (web, with alpha)           *
   *    mark-solid = the same band flattened on white (email, icons)     *
   *    wash   = a very light field tint (error field, filled code box)  *
   *    deep   = decorative strokes and dots (< 3:1, never a state)      *
   *    signal = state indicators that must reach 3:1 on white           *
   *    on-mark = text colour on that band: always ink                   *
   * ------------------------------------------------------------------ */
  --butter-rgb: 251, 231, 161;
  --butter-aura: #FBE7A1;
  --butter-mark-rgb: 250, 222, 146;
  --butter-mark: rgba(var(--butter-mark-rgb), 0.95);
  --butter-mark-solid: #FAE097;
  --butter-wash: #FCF1C9;
  --butter-deep: #EFC85A;
  --butter-signal: #A97F1E;   /* 3.7:1 */
  --butter-on-mark: var(--ink);

  --rose-rgb: 246, 201, 214;
  --rose-aura: #F6C9D6;
  --rose-mark-rgb: 244, 190, 207;
  --rose-mark: rgba(var(--rose-mark-rgb), 0.95);   /* was .9; now the same alpha as the others */
  --rose-mark-solid: #F5C1D1;
  --rose-wash: #FAE1E8;       /* "not finished / try again" field: ink on it 13:1. Errors are never red */
  --rose-deep: #E79AB2;
  --rose-signal: #C2687F;     /* 3.8:1: attention dot, error ring accent */
  --rose-on-mark: var(--ink);

  --sky-rgb: 199, 221, 244;
  --sky-aura: #C7DDF4;
  --sky-mark-rgb: 190, 216, 242;
  --sky-mark: rgba(var(--sky-mark-rgb), 0.95);
  --sky-mark-solid: #C1DAF3;
  --sky-wash: #E6EFF9;
  --sky-deep: #8DB7E3;        /* the Insights thread line */
  --sky-signal: #4F7FB8;      /* 4.2:1 */
  --sky-on-mark: var(--ink);

  --peach-rgb: 248, 211, 176;
  --peach-aura: #F8D3B0;
  --peach-mark-rgb: 247, 203, 162;
  --peach-mark: rgba(var(--peach-mark-rgb), 0.95);
  --peach-mark-solid: #F7CEA7;
  --peach-wash: #FCEADB;
  --peach-deep: #F0B98A;
  --peach-signal: #B5763A;    /* 3.7:1 */
  --peach-on-mark: var(--ink);

  /* The wordmark's band: one brand-only butter, a step stronger than the
     text marker so the symbol holds at 16 px. Nowhere else. */
  --brand-band: #F8D682;
  --brand-band-glow: #F8D3B0;

  /* Semantic roles (map to the four, never new hues) */
  --mark-default: var(--butter-mark);
  --state-selected-bg: var(--ink);          /* single choice (radio chip) */
  --state-toggled-bg: var(--butter-aura);   /* multi choice (day chip) reads as a highlight */
  --state-attention: var(--rose-signal);
  --state-attention-wash: var(--rose-wash);
  --state-done: var(--ink);                 /* a finished step: ink check / ink segment on white. Butter stays for "chosen among many" */

  /* Book cover placeholders (illustration only; real covers replace them) */
  --cover-1: #2F4A3A;  /* green  */
  --cover-2: #2B3A55;  /* navy   */
  --cover-3: #5E4560;  /* plum   */
  --cover-4: #7A4A3C;  /* brick  */
  --cover-5: #8A6A22;  /* ochre  */
  --cover-6: #4A5763;  /* slate  */

  /* macOS imitation (illustrations of the menu bar / Finder only) */
  --sys-text: #1F2024;
  --sys-red: #FF5F57;
  --sys-yellow: #FEBC2E;
  --sys-green: #28C840;
  --sys-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --sys-r-menu: 10px;
  --sys-hairline: rgba(0, 0, 0, 0.12);
  --sys-control: 0 0 0 0.5px rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.08);
  --sys-select: rgba(var(--ink-rgb), 0.08);

  /* ------------------------------------------------------------------ *
   * 4. Type                                                             *
   * ------------------------------------------------------------------ */
  --font: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  /* Site: fluid, 360 → 1440 px viewport */
  --fs-display: clamp(2.75rem, 1.667rem + 4.815vw, 6rem);       /* 44 → 96  hero H1 only */
  --fs-h1: clamp(2.25rem, 1.583rem + 2.963vw, 4.25rem);         /* 36 → 68  closing line, privacy line */
  --fs-h2: clamp(1.875rem, 1.417rem + 2.037vw, 3.25rem);        /* 30 → 52  section heads */
  --fs-h3: clamp(1.25rem, 1.167rem + 0.37vw, 1.5rem);           /* 20 → 24  step / fact / plan titles */
  --fs-quote-lg: clamp(1.3125rem, 1.167rem + 0.648vw, 1.75rem); /* 21 → 28  the one featured highlight */
  --fs-quote: clamp(1.125rem, 1.0625rem + 0.278vw, 1.3125rem);  /* 18 → 21  highlight cards */
  --fs-lede: clamp(1.0625rem, 1rem + 0.278vw, 1.25rem);         /* 17 → 20  sub-head under H1/H2 */
  --fs-body: clamp(1rem, 0.979rem + 0.093vw, 1.0625rem);        /* 16 → 17 */
  --fs-small: 0.9375rem;   /* 15  buttons, nav, list text */
  --fs-caption: 0.8125rem; /* 13  book line, meta */
  --fs-micro: 0.75rem;     /* 12  pills, axis labels. Floor: nothing smaller except cover art */

  /* App: fixed, for the 760 × 480 window (px on purpose: the window never reflows) */
  --app-fs-title: 28px;     /* setup step H1 (was 26/30) */
  --app-fs-title-sm: 22px;  /* panel headline, sheet title (was 24) */
  --app-fs-code: 26px;      /* one digit in the 6-box code */
  --app-fs-quote: 16px;     /* the highlight in a card */
  --app-fs-quote-lg: 22px;  /* the one found highlight (A-03c) */
  --app-fs-body: 15px;      /* lede, buttons, inputs */
  --app-fs-label: 14px;     /* field labels, row labels, chips */
  --app-fs-small: 13px;     /* help, notes, book line, errors */
  --app-fs-micro: 12px;     /* step label, pills */

  --lh-display: 1;
  --lh-heading: 1.08;
  --lh-title: 1.2;
  --lh-quote: 1.5;
  --lh-body: 1.6;
  --lh-ui: 1.35;

  --track-display: -0.035em;  /* display, h1 */
  --track-heading: -0.025em;  /* h2, app title */
  --track-snug: -0.012em;     /* h3, quotes */
  --track-none: 0;            /* body, UI */
  --track-code: 0.04em;       /* code digits (tabular) */

  --measure-prose: 34em;      /* ≈ 68 ch at body size */
  --measure-quote: 30em;
  --measure-lede: 32em;

  /* ------------------------------------------------------------------ *
   * 5. Space (4 px base)                                               *
   * ------------------------------------------------------------------ */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;
  --sp-9: 48px;
  --sp-10: 64px;
  --sp-11: 80px;
  --sp-12: 96px;
  --sp-13: 128px;
  --sp-14: 160px;

  /* Site layout */
  --container: 1240px;
  --gutter: clamp(1.25rem, 0.5rem + 3.33vw, 3rem);           /* 20 → 48 */
  --space-section: clamp(6rem, 3.75rem + 8vw, 11rem);        /* 96 → 176 between sections */
  --space-stack: clamp(2.5rem, 1.75rem + 2.5vw, 4rem);       /* 40 → 64 heading block → content */

  /* App window layout (760 × 480) */
  --app-w: 760px;
  --app-h: 480px;
  --app-pad-x: 52px;        /* content inset left/right */
  --app-pad-top: 64px;      /* first line under the step indicator */
  --app-bar-y: 14px;        /* step indicator / title baseline row */
  --app-foot-h: 80px;
  --app-foot-pad: 28px;
  --app-sheet-pad: 40px;    /* sheet content inset and sheet footer padding (the window footer stays 28) */

  /* ------------------------------------------------------------------ *
   * 6. Radius                                                           *
   * ------------------------------------------------------------------ */
  --r-xs: 4px;     /* cover spine side */
  --r-sm: 8px;     /* cover outer side, small swatches */
  --r-md: 14px;    /* inputs, code boxes, inner rows, error lines */
  --r-lg: 20px;    /* cards, sheets */
  --r-xl: 24px;    /* app window, email card, big site panels */
  --r-2xl: 36px;   /* the site's closing slab */
  --r-pill: 999px; /* buttons, pills, chips */
  --r-mark: 0.32em;

  /* ------------------------------------------------------------------ *
   * 7. Elevation: one warm ambient brown + one contact brown            *
   * ------------------------------------------------------------------ */
  --shadow-rgb: 124, 98, 74;   /* ambient, under glass and paper */
  --contact-rgb: 80, 62, 48;   /* under ink objects: buttons, covers */

  --edge: inset 0 0 0 1px rgba(255, 252, 246, 0.95);   /* the frosted rim */
  --elev-0: none;
  --elev-1: 0 1px 2px rgba(var(--shadow-rgb), 0.06), 0 10px 24px -16px rgba(var(--shadow-rgb), 0.34);                                 /* resting card on glass */
  --elev-2: 0 6px 14px -8px rgba(var(--shadow-rgb), 0.16), 0 26px 50px -24px rgba(var(--shadow-rgb), 0.38);                           /* raised card, featured highlight */
  --elev-3: 0 6px 16px -10px rgba(var(--shadow-rgb), 0.16), 0 30px 60px -24px rgba(var(--shadow-rgb), 0.42);                          /* window, sheet */
  --elev-4: 0 10px 24px -12px rgba(var(--shadow-rgb), 0.2), 0 48px 90px -36px rgba(var(--shadow-rgb), 0.46);                          /* hovered card, floating hero card */
  --elev-button: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 12px 24px -12px rgba(var(--contact-rgb), 0.55);
  --elev-button-hover: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 18px 32px -14px rgba(var(--contact-rgb), 0.6);
  --elev-cover: inset 3px 0 0 rgba(0, 0, 0, 0.12), 0 10px 20px -12px rgba(var(--contact-rgb), 0.5);

  /* ------------------------------------------------------------------ *
   * 8. Glass recipes (fill + backdrop). Elevation is separate.          *
   * ------------------------------------------------------------------ */
  --glass-thin: rgba(255, 255, 255, 0.55);    /* fog cards, ghosts behind */
  --glass: rgba(255, 255, 255, 0.62);         /* the app window, big site slabs */
  --glass-card: rgba(255, 255, 255, 0.86);    /* cards on glass, the email preview */
  --glass-solid: rgba(255, 255, 255, 0.94);   /* inputs, sheets, anything you type in */
  --glass-blur: blur(28px) saturate(150%);    /* windows and slabs */
  --glass-blur-sm: blur(20px) saturate(140%); /* lists and cards inside a window */
  --veil: rgba(251, 250, 247, 0.4);           /* paper veil over a fogged panel behind a sheet */

  /* ------------------------------------------------------------------ *
   * 9. Focus                                                            *
   *    A box-shadow ring, because outline ignores border-radius in      *
   *    WebKit before Safari 16.4 (pills would get square rings).        *
   * ------------------------------------------------------------------ */
  --focus-gap: var(--paper);
  --focus-ring: 0 0 0 3px var(--focus-gap), 0 0 0 5px var(--ink);
  --focus-halo: 0 0 0 10px rgba(var(--butter-rgb), 0.55);   /* the butter light behind the ring */
  --focus-ring-inset: inset 0 0 0 1.5px var(--ink);         /* for fields and code boxes */

  /* ------------------------------------------------------------------ *
   * 10. Layers                                                          *
   * ------------------------------------------------------------------ */
  --z-aura: 0;      /* edge light */
  --z-fog: 1;       /* fogged memories, parallax depth layers */
  --z-content: 2;
  --z-float: 10;    /* floating hero card, hovered card */
  --z-sticky: 20;   /* site nav */
  --z-sheet: 40;    /* app sheet over the panel */
  --z-overlay: 50;  /* mobile menu */
  --z-toast: 60;

  /* ------------------------------------------------------------------ *
   * 11. Motion                                                          *
   *     Thesis: depth is time. Blur is distance in memory; focus is     *
   *     now. Things arrive fogged and come into focus (desembaçar),     *
   *     then the marker passes (traço). Nothing else invents motion.    *
   * ------------------------------------------------------------------ */

  /* Durations */
  --dur-instant: 90ms;    /* press */
  --dur-quick: 160ms;     /* hover colour, ring */
  --dur-base: 240ms;      /* control state change, chip select */
  --dur-calm: 420ms;      /* step change in the app, sheet in, hover bloom */
  --dur-slow: 700ms;      /* card lift settling, parallax catch-up */
  --dur-reveal: 900ms;    /* defog of content entering on scroll */
  --dur-defog: 1600ms;    /* the full gesture: hero card, first-run highlight */
  --dur-sweep: 1100ms;    /* marker sweep after the full defog */
  --dur-sweep-short: 650ms; /* marker sweep on scroll reveal, one-line marks, hover bands */
  --dur-word: 2500ms;     /* each word of the hero rotator (one cycle of 4 words = 10 s, then it rests on Kindle) */
  --dur-drift: 28s;       /* aura breathing loop */
  --dur-exit: 180ms;      /* exits are faster than entrances */

  /* Easings (cubic-bezier only: linear() needs Safari 17.2) */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);        /* the house curve (the shipping value) */
  --ease-defog: cubic-bezier(0.16, 1, 0.3, 1);       /* expo out: focus pulls in fast, settles long */
  --ease-sweep: cubic-bezier(0.22, 0.8, 0.24, 1);    /* a hand pulling a marker: quick start, slow finish (one-line marks, UI bands) */
  --ease-hand: cubic-bezier(0.42, 0.06, 0.28, 1);     /* a steady hand across several lines (multi-line marks on scroll and load) */
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);     /* loops, drift, rotator */
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);         /* exits only */
  --ease-press: cubic-bezier(0.3, 0, 0.5, 1);        /* press down */
  --ease-overshoot: cubic-bezier(0.34, 1.56, 0.64, 1); /* release after press, icon nudge. Max one per control */

  /* Stagger */
  --stagger-tight: 50ms;   /* code digits, list rows */
  --stagger: 90ms;         /* lines, words, chips */
  --stagger-loose: 140ms;  /* cards in a group */
  --stagger-cap: 600ms;    /* no group waits longer than this in total */

  /* Depth scale: the same four levels drive blur, opacity, parallax speed.
     0 = now (sharp), 3 = far past. Speed is the fraction of scroll the
     layer moves against the page (negative = drifts up slower). */
  --depth-0-blur: 0px;    --depth-0-opacity: 1;    --depth-0-speed: 0;
  --depth-1-blur: 1.5px;  --depth-1-opacity: 0.78; --depth-1-speed: -0.05;
  --depth-2-blur: 3px;    --depth-2-opacity: 0.56; --depth-2-speed: -0.11;
  --depth-3-blur: 5.5px;  --depth-3-opacity: 0.36; --depth-3-speed: -0.18;

  /* Blur amounts (anything else is a smell) */
  --blur-defog-start: 12px;  /* where an arriving memory starts */
  --blur-pass: 2.5px;        /* scrubbed fog at the viewport edges ("passing over") */
  --blur-veil: 4px;          /* panel behind an open sheet */
  --blur-aura: 48px;         /* the edge light */
  --blur-glow: 16px;         /* button bloom, halo behind a card */

  /* Distances */
  --rise-sm: 8px;
  --rise: 18px;
  --rise-lg: 36px;
  --lift: -2px;              /* hover lift */
  --lift-card: -6px;
  --press-scale: 0.97;
  --nudge: 3px;              /* icon nudge on hover */
  --magnet-max: 6px;         /* magnetic CTA pull, set by JS as --mx/--my, clamped to this */

  /* ------------------------------------------------------------------ *
   * 12. Email (mirror into emailer.py; email cannot read variables)     *
   * ------------------------------------------------------------------ */
  --mail-width: 600px;
  --mail-card-radius: 20px;
  --mail-sheet-pad-top: 32px;
  --mail-sheet-pad-x: 40px;
  --mail-sheet-pad-bottom: 48px;
  --mail-hairline: #ECE9E3;
  --mail-fs-quote: 21px;     --mail-lh-quote: 37px;   /* full-sentence marks need the tall line */
  --mail-fs-moment: 23px;    --mail-lh-moment: 39px;  /* the reading-moment closing quote */
  --mail-fs-book: 15px;      --mail-lh-book: 20px;
  --mail-fs-body: 15px;      --mail-lh-body: 22px;
  --mail-fs-meta: 13px;      --mail-lh-meta: 18px;
  --mail-mark-pad: 3px 1px;
  --mail-mark-radius: 3px;
  --mail-cover-w: 40px;      --mail-cover-h: 60px;
  --mail-gap-book: 44px;     /* between two books */
  --mail-gap-hl: 18px;       /* between two highlights of one book */
  --mail-gap-chapter: 48px;  /* before the reading moment (chapter break) */
  --mail-wash-rose: #FAE1E8; /* edge rows: Kindle signed out, nothing new */
  --mail-wash-radius: 14px;

  /* ------------------------------------------------------------------ *
   * 13. Legacy aliases (app.css / site.css keep working while they     *
   *     migrate; delete once nothing reads them)                        *
   * ------------------------------------------------------------------ */
  --hl-yellow: var(--butter-aura);   --mark-yellow: var(--butter-mark);
  --hl-pink: var(--rose-aura);       --mark-pink: var(--rose-mark);
  --hl-blue: var(--sky-aura);        --mark-blue: var(--sky-mark);
  --hl-orange: var(--peach-aura);    --mark-orange: var(--peach-mark);
  --glass-strong: var(--glass-card);
  --glass-edge: rgba(255, 252, 246, 0.95);
  --shadow-warm: var(--elev-3);
  --shadow-card: var(--edge), var(--elev-2);
  --r-window: var(--r-xl);
  --r-card: var(--r-lg);
  --r-inner: var(--r-md);
  --product-name: var(--brand-name);
}

/* Reduced motion: keep state changes (colour, opacity) legible, remove travel.
   Components read these, so one switch calms everything. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-calm: 200ms;
    --dur-slow: 200ms;
    --dur-reveal: 240ms;
    --dur-defog: 0ms;
    --dur-sweep: 0ms;
    --dur-sweep-short: 0ms;
    --rise-sm: 0px; --rise: 0px; --rise-lg: 0px;
    --lift: 0px; --lift-card: 0px; --nudge: 0px; --magnet-max: 0px;
    --press-scale: 1;
    --depth-1-speed: 0; --depth-2-speed: 0; --depth-3-speed: 0;
    --blur-defog-start: 0px; --blur-pass: 0px;
  }
}
