/* ==========================================================================
   Bloop design tokens — the single source of truth.

   Every colour, size, space, type step, radius, shadow and timing used
   anywhere in the app is defined here and nowhere else. The other
   stylesheets, the templates and the scripts may only refer to these names
   (core/tests/test_design_system.py enforces it).

   The language is quiet and orbital. An off-white field, small tracked
   type, soft white cards, and one piece of strong colour: a glossy sphere
   in deep teal and red that shows what the strap is doing. Surfaces are
   solid and lightly lifted — not translucent glass.

   Three tiers:
     1. Palette      raw colours. Never used directly outside this file.
     2. Semantic     what a colour is FOR. One light theme; no dark mode.
     3. Scales       space, size, type, radius, shadow, motion, layers.
   ========================================================================== */

:root {
  /* ── 1. Palette ───────────────────────────────────────────────────────── */
  --paper: #F4F5F3;
  --sand: #E6E7E4;
  --white: #FFFFFF;
  --mist: #F7F7F5;
  --stone: #E1E2DE;
  --pebble: #C5C7C2;
  --ink: #1C1E1C;
  --ink-soft: #4A4E4A;
  --ink-faint: #6E726C;
  /* the sphere: deep ocean, a pale aqua band, and one red */
  --coral: #C4475A;
  --peach: #E7B7BC;
  --lilac: #12323C;
  --sky: #8ED4CE;
  --mint: #1A6570;
  --amber: #E6D3B8;
  --rose: #7A2434;
  /* functional */
  --green: #1B7A56;
  --red: #B43344;

  /* ── 2. Semantic colour ───────────────────────────────────────────────── */
  color-scheme: light;

  --surface-page: var(--paper);
  --surface-card: var(--white);

  --text-primary: var(--ink);
  --text-quiet: var(--ink-soft);
  --text-faint: var(--ink-faint);
  --text-on-inverse: var(--paper);

  --border: var(--stone);
  --positive: var(--green);
  --danger: var(--red);
  --focus: var(--ink);

  /* data marks: the day in focus is teal, the rest step back */
  --mark: var(--mint);
  --mark-rest: var(--pebble);
  /* the dark side of the sphere, where the gloss falls off */
  --sphere: var(--lilac);

  /* one gradient per sync phase, painted across the sphere */
  --aura-idle: conic-gradient(from 0deg, var(--mist), var(--white), var(--sand), var(--stone), var(--mist));
  --aura-connecting: conic-gradient(from 0deg, var(--amber), var(--peach), var(--mint), var(--sky), var(--amber));
  --aura-syncing: conic-gradient(from 0deg, var(--coral), var(--rose), var(--lilac), var(--mint), var(--coral));
  --aura-connected: conic-gradient(from 40deg, var(--lilac), var(--mint), var(--sky), var(--coral), var(--rose), var(--lilac));
  --aura-waiting: conic-gradient(from 0deg, var(--lilac), var(--sky), var(--mint), var(--lilac));
  --aura-error: conic-gradient(from 0deg, var(--rose), var(--coral), var(--peach), var(--rose));
  /* the logo, reduced to an icon: the same planet, seen from above */
  --aura-logo: conic-gradient(from 200deg, var(--lilac), var(--mint), var(--sky), var(--coral), var(--rose), var(--lilac));
  /* a barely-there cool wash, fixed behind every page */
  --aura-ambient:
    radial-gradient(90% 55% at 50% -8%, color-mix(in srgb, var(--sand) 80%, transparent), transparent 70%),
    radial-gradient(45% 35% at 100% 100%, color-mix(in srgb, var(--sky) 10%, transparent), transparent 72%);

  /* the ocean panel: deep teal, a breath of aqua along the bottom */
  --ocean:
    radial-gradient(80% 55% at 70% 120%, color-mix(in srgb, var(--sky) 35%, transparent), transparent 62%),
    linear-gradient(180deg, var(--lilac), var(--mint));

  /* surfaces: nearly solid white, a hairline edge, no blur */
  --glass-fill: var(--white);
  --glass-fill-strong: var(--mist);
  --glass-fill-inset: color-mix(in srgb, var(--ink) 4%, var(--white));
  --glass-fill-ink: color-mix(in srgb, var(--ink) 94%, transparent);
  --glass-filter: none;
  --glass-edge: 0 0 0 var(--hairline) color-mix(in srgb, var(--ink) 8%, transparent);
  --glass-edge-ink: 0 0 0 var(--hairline) color-mix(in srgb, var(--white) 16%, transparent);

  --progress-fill: linear-gradient(90deg, var(--mint), var(--sky));
  --progress-fill-low: linear-gradient(90deg, var(--rose), var(--coral));

  /* ── 3. Scales ────────────────────────────────────────────────────────── */

  /* space — a 4px grid. Margins, padding and gaps use only these. */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-18: 72px;

  /* size — fixed dimensions of things */
  --hairline: 1px;
  --control-sm: 36px;
  --control-md: 44px;
  --tabbar-height: 62px;
  --tab-width: 84px;
  --tab-icon: 22px;
  --dot: 8px;
  --logo: 88px;
  --orb: 188px;
  --orb-sm: 112px;
  --orb-lg: 240px;
  --progress-height: 6px;
  --graph-height: 128px;
  --bar-width: 8px;
  --log-height: 220px;

  /* layout — column widths */
  --measure-narrow: 400px;
  --measure: 560px;
  --measure-prose: 640px;
  --measure-wide: 1040px;
  --gutter: var(--space-5);
  /* insets that depend on the device's safe area and the floating tab bar */
  --tabbar-inset: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  --page-bottom-inset: calc(var(--tabbar-height) + var(--space-12) + env(safe-area-inset-bottom, 0px));

  /* type — two voices, as on iOS: a serif for headings and figures,
     the system sans (Inter where it is not the platform font) for everything read or pressed */
  --font-serif: "Instrument Serif", ui-serif, Georgia, serif;
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* type — sizes. Small on purpose: the sphere is the headline. */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 22px;
  --text-2xl: 40px;
  --text-display: 26px;

  /* type — weight, leading, tracking.
     Light for the few large lines. Medium only for things you press
     and for the small-caps wordmark. */
  --weight-light: 300;
  --weight-regular: 400;
  --weight-medium: 500;
  --leading-none: 1;
  --leading-tight: 1.15;
  --leading-snug: 1.4;
  --leading-normal: 1.55;
  --tracking-tight: -0.03em;
  --tracking-normal: 0;
  --tracking-wide: 0.16em;

  /* radius — soft, not bubbly */
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-full: 9999px;

  /* shadow — low and diffuse; cards sit, they do not glow */
  --shadow-drop: 0 18px 40px -28px color-mix(in srgb, var(--ink) 55%, transparent);
  --shadow-card: var(--glass-edge), var(--shadow-drop);
  --shadow-float: var(--glass-edge), 0 16px 40px -20px color-mix(in srgb, var(--ink) 35%, transparent);
  --shadow-ink: var(--glass-edge-ink), 0 12px 28px -16px color-mix(in srgb, var(--ink) 70%, transparent);
  --shadow-well: inset 0 0 0 var(--hairline) color-mix(in srgb, var(--ink) 6%, transparent);
  --blur-aura: 22px;

  /* motion */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --duration-fast: 0.15s;
  --duration-base: 0.35s;
  --duration-slow: 0.7s;
  --duration-aura: 18s;
  --stagger: 28ms;

  /* opacity */
  --opacity-disabled: 0.45;

  /* layers */
  --layer-nav: 20;
}

/* ==========================================================================
   Web-only tokens: the landing page and the dashboard.

   Kept out of the first :root block on purpose — scripts/gen_ios_tokens.py
   reads only that block, and the app has its own native equivalents
   (DisplayRole sizes, ZonePalette, SleepStageStrip, MetricRating).
   ========================================================================== */
:root {
  /* colours the app also uses, named for their job */
  --night: #0F1C1F;            /* the app icon's ground */
  --sea: #4FA3A5;              /* heart-rate zone 2 */
  --honey: #D9A441;            /* recovery between 34 and 66 */
  --rating-yellow: #E2B54E;
  --rating-green: #5FAE84;
  --stage-awake: #C4804F;
  --stage-rem: #9175AD;
  --stage-light: #5CA3A8;
  --stage-deep: #295270;

  --zone-0: var(--pebble);
  --zone-1: var(--sky);
  --zone-2: var(--sea);
  --zone-3: var(--mint);
  --zone-4: var(--lilac);
  --zone-5: var(--coral);

  --score-recovery-high: var(--green);
  --score-recovery-mid: var(--honey);
  --score-recovery-low: var(--coral);
  --score-strain: var(--mint);
  --score-strain-muscular: var(--lilac);
  --score-sleep: var(--stage-deep);

  /* frosted glass over the aura; the one place the web blurs */
  --veil: color-mix(in srgb, var(--white) 62%, transparent);
  --veil-strong: color-mix(in srgb, var(--white) 72%, transparent);
  --veil-edge: color-mix(in srgb, var(--white) 75%, transparent);
  --veil-dark: color-mix(in srgb, var(--lilac) 38%, transparent);
  --veil-dark-edge: color-mix(in srgb, var(--white) 14%, transparent);
  --veil-dark-fill: color-mix(in srgb, var(--paper) 8%, transparent);
  --veil-filter: blur(22px) saturate(160%);
  --shadow-glass: 0 0 0 1px color-mix(in srgb, var(--ink) 6%, transparent), 0 30px 60px -30px color-mix(in srgb, var(--lilac) 35%, transparent);
  --shadow-glass-dark: 0 30px 60px -30px color-mix(in srgb, var(--ink) 50%, transparent);
  --shadow-phone: 0 50px 100px -40px color-mix(in srgb, var(--lilac) 55%, transparent), 0 0 0 1px color-mix(in srgb, var(--ink) 20%, transparent);
  --text-on-dark-quiet: color-mix(in srgb, var(--paper) 75%, transparent);
  --rule-on-dark: color-mix(in srgb, var(--paper) 16%, transparent);
  --wash-positive: color-mix(in srgb, var(--green) 12%, transparent);
  --wash-mark: color-mix(in srgb, var(--mint) 25%, transparent);
  --wash-quiet: color-mix(in srgb, var(--ink-faint) 22%, transparent);
  --wash-danger: color-mix(in srgb, var(--coral) 22%, transparent);
  --wash-hover: color-mix(in srgb, var(--ink) 4%, transparent);
  --fill-chart: linear-gradient(180deg, color-mix(in srgb, var(--mint) 16%, transparent), transparent);

  --aura-hero:
    radial-gradient(40% 40% at 35% 45%, color-mix(in srgb, var(--sky) 75%, transparent), transparent 70%),
    radial-gradient(35% 35% at 68% 60%, color-mix(in srgb, var(--coral) 28%, transparent), transparent 70%),
    radial-gradient(45% 45% at 52% 35%, color-mix(in srgb, var(--mint) 40%, transparent), transparent 70%);
  --aura-sky: radial-gradient(closest-side, color-mix(in srgb, var(--sky) 55%, transparent), transparent);
  --aura-peach: radial-gradient(closest-side, color-mix(in srgb, var(--peach) 60%, transparent), transparent);
  --aura-coral: radial-gradient(closest-side, color-mix(in srgb, var(--coral) 45%, transparent), transparent);
  --aura-teal: radial-gradient(closest-side, color-mix(in srgb, var(--mint) 35%, transparent), color-mix(in srgb, var(--sky) 20%, transparent) 60%, transparent);
  --aura-pair:
    radial-gradient(40% 50% at 30% 50%, color-mix(in srgb, var(--sky) 60%, transparent), transparent 70%),
    radial-gradient(40% 50% at 75% 50%, color-mix(in srgb, var(--peach) 55%, transparent), transparent 70%);
  --ocean-deep:
    radial-gradient(80% 55% at 70% 120%, color-mix(in srgb, var(--sky) 38%, transparent), transparent 62%),
    linear-gradient(180deg, var(--lilac), var(--mint));
  --blur-soft: blur(50px);
  --blur-wide: blur(64px);

  /* type — the serif figures and headings (iOS DisplayRole), and two web steps */
  --text-lede: 19px;
  --text-stat: 30px;
  --text-figure: 52px;
  --text-large: 72px;
  --text-giant: 104px;
  --text-page: clamp(38px, 4vw, 52px);
  --text-section: clamp(40px, 5.4vw, 72px);
  --text-pair: clamp(36px, 4vw, 52px);
  --text-hero: clamp(52px, 8vw, 116px);
  --text-cta: clamp(56px, 9vw, 132px);
  --leading-display: 0.92;
  --tracking-display: -0.025em;

  /* sizes */
  --page-max: 1240px;
  --page-max-wide: 1392px;
  --sidebar-width: 232px;
  --sidebar-max: 280px;
  --icon: 18px;
  --icon-sm: 14px;
  --tile: 48px;
  --tile-sm: 36px;
  --tile-xs: 28px;
  --ring-xs: 54px;
  --ring-sm: 64px;
  --ring-md: 84px;
  --ring-lg: 104px;
  --ring-xl: 150px;
  --spark-width: 120px;
  --spark-height: 40px;
  --chart-sm: 140px;
  --chart-md: 220px;
  --chart-lg: 260px;
  --chart-xl: 280px;
  --phone-width: 300px;
  --phone-height: 620px;
  --orbit-max: 1120px;
  --orbit-height: 780px;
  --orbit-height-sm: 680px;
  --orbit-card-width: 228px;
  --orbit-card-height: 118px;
  --aura-size: 900px;
  --aura-size-md: 700px;
  --aura-size-sm: 560px;
  --cell-min: 220px;
  --card-min: 320px;
  --label-col: 132px;
  --stage-label: 84px;
  --stage-value: 64px;
  --radius-xl: 32px;
  --row-tall: 60px;
  --measure-head: 680px;
  --browser-max: 1080px;
  --browser-side: 190px;
  --instrument-width: 440px;
  --summary-min: 180px;
  --basis-xs: 280px;
  --basis-sm: 380px;
  --basis-md: 440px;
  --basis-lg: 520px;
  --basis-main: 560px;
  --basis-xl: 600px;
  --aura-size-xs: 420px;
  --blur-card: blur(30px);
  --blur-mid: blur(40px);
  --radius-2xl: 40px;
  --radius-phone: 52px;
  --radius-screen: 43px;
}
