/* Pen Design System: tokens v0.3.0
 * The only source of truth for colour, type, space, radius, shadow, blur, motion and layout.
 * The look: compact, precise controls with small radii and crisp 1 px borders, inside a spacious layout;
 * Apple-style system type; soft, calm motion with no bounce.
 * Light is the default. Dark follows the system unless the page sets data-theme on <html>:
 *   <html data-theme="light">  forces light,  <html data-theme="dark">  forces dark, no attribute = system.
 * The default brand below is a neutral indigo that works for any product. A product sets its own colour by
 * overriding the six --brand-* tokens (copy brands/_template.css; brands/examples/ has two filled-in presets).
 * Never write a raw value in a rule: use a token.
 */

:root {
  color-scheme: light;

  /* ---- Neutrals (light) ---- */
  --bg: #ffffff;               /* page canvas */
  --bg-subtle: #f6f7f9;        /* alternate section band, sidebar */
  --surface: #ffffff;          /* cards, popovers, dialogs */
  --surface-2: #f3f4f6;        /* hover rows, inset wells, code */
  --field: #ffffff;            /* inputs */
  --line: rgb(13 16 24 / 0.10);   /* 1 px borders on cards, dividers */
  --line-2: rgb(13 16 24 / 0.18); /* input borders, popups, stronger edges (3:1 with --ink-3 text around it) */
  --ink: #0b0d12;              /* titles, body. 19.4:1 on --bg */
  --ink-2: #4a5060;            /* secondary text. 8.0:1 */
  --ink-3: #666d7c;            /* meta, captions, placeholders. 5.2:1 (4.85 on --bg-subtle) */
  --overlay: rgb(9 10 14 / 0.24);   /* subtle dim behind dialogs, with --scrim-blur */
  --hl: rgb(255 255 255 / 0);  /* top highlight on cards: none in light */

  /* ---- Semantic and status (light) ---- */
  --ok: #15803d;   --ok-soft: rgb(21 128 61 / 0.10);
  --bad: #b91c1c;  --bad-soft: rgb(185 28 28 / 0.08); --bad-fill: #b91c1c; /* fill behind --on-fill text: 6.5:1 */
  --on-fill: #ffffff;  /* text on --bad-fill, switch knobs: white in both themes */
  --warn: #b45309; --warn-soft: rgb(180 83 9 / 0.10);
  --info: #1d4ed8; --info-soft: rgb(29 78 216 / 0.08);

  /* ---- Brand slot: the default accent (indigo). Override all six for a product. ---- */
  --brand: #4f46e5;        /* fill of the one primary button. White on it 6.3:1 */
  --brand-hover: #4338ca;
  --brand-ink: #ffffff;    /* text on --brand, at least 4.5:1 */
  --brand-text: #4f46e5;   /* brand as text, links, icons on --bg: 6.3:1 (5.7 on --surface-2) */
  --brand-soft: rgb(79 70 229 / 0.08); /* icon tiles, selected rows, badges */
  --brand-ring: #4f46e5;   /* the solid 2 px focus ring, at least 3:1 on --bg (6.3:1) */

  /* ---- Elevation ---- */
  /* Border first. A crisp 1 px edge does the work; popups get at most a very tight, low shadow; never a soft blur. */
  --sh-1: 0 0 0 1px var(--line);                                                                  /* cards: border only */
  --sh-2: 0 0 0 1px var(--line-2), 0 1px 2px rgb(13 16 24 / 0.06), 0 2px 4px -2px rgb(13 16 24 / 0.06); /* menus, popovers, selects, toasts */
  --sh-3: 0 0 0 1px var(--line-2), 0 1px 2px rgb(13 16 24 / 0.06), 0 4px 8px -4px rgb(13 16 24 / 0.10); /* dialogs */
  --sh-btn: 0 1px 0 rgb(255 255 255 / 0.14) inset, 0 0 0 1px rgb(13 16 24 / 0.06);                /* primary button */

  /* ---- Typography ---- */
  /* Apple devices get SF Pro (the system font); every other device gets Inter, loaded from Google Fonts, then its own
   * system font. Both cover Latin, Greek and Cyrillic. To use another typeface, change this one token (and the font
   * link in <head>); nothing else names a font. */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", system-ui, "Segoe UI", Roboto, "Noto Sans", "PingFang TC", "Hiragino Sans", "Apple SD Gothic Neo", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  /* role: size / line height / tracking / weight. SF Pro Display metrics: tight tracking on large sizes,
   * looser as text gets small. Firm weights for titles, regular for reading. */
  --t-display: clamp(36px, 5vw, 64px);    --lh-display: 1.05; --tr-display: -0.022em; --w-display: 700;
  --t-h2: clamp(28px, 3.2vw, 40px);       --lh-h2: 1.1;       --tr-h2: -0.02em;       --w-h2: 650;
  --t-h3: 18px;                           --lh-h3: 1.3;       --tr-h3: -0.012em;      --w-h3: 600;
  --t-lead: clamp(17px, 1.5vw, 20px);     --lh-lead: 1.5;     --tr-lead: -0.008em;
  --t-body: 16px;                         --lh-body: 1.55;    /* marketing pages: never smaller */
  --t-app: 15px;                          --lh-app: 1.5;      /* apps and dashboards: 14 to 15 */
  --t-small: 14px;                        --lh-small: 1.45;
  --t-micro: 13px;                        --lh-micro: 1.4;    --tr-micro: 0.006em; /* labels, meta, badges only */
  --t-mono: 14px;                         --lh-mono: 1.65;
  --t-stat: clamp(28px, 3vw, 40px);       /* numbers in stat cards, tabular */
  --measure: 65ch;     /* body text */
  --measure-lead: 56ch;
  --measure-title: 22ch;

  /* ---- Space (4 / 8 scale) ---- */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px;
  --s-10: 40px; --s-12: 48px; --s-16: 64px; --s-20: 80px; --s-24: 96px; --s-32: 128px;

  /* ---- Radius (nothing else is allowed) ---- */
  --r-xs: 4px;    /* chips, badges, menu items, kbd */
  --r-sm: 6px;    /* buttons, inputs, icon tiles, segmented */
  --r-md: 8px;    /* cards, popovers, toasts, code */
  --r-lg: 10px;   /* dialogs, big panels, pricing cards */
  --r-xl: 12px;   /* hero product frame only */
  --r-pill: 999px;/* only what is a pill: the floating pill nav, switches, status dots */

  /* ---- Blur and translucency ---- */
  --nav-bg: color-mix(in oklab, var(--bg) 72%, transparent);
  --nav-bg-pill: color-mix(in oklab, var(--surface) 80%, transparent);
  --nav-blur: blur(16px) saturate(180%);
  --nav-blur-pill: blur(20px) saturate(180%);
  --scrim-blur: blur(8px);   /* behind dialogs and sheets, with the --overlay dim */

  /* ---- Motion: soft and calm like iOS. No bounce, no overshoot; off for reduced motion ---- */
  --ease-move: cubic-bezier(.32, .72, 0, 1);     /* anything that moves or scales: popups, dialogs, sheets, drawers, indicators */
  --ease-fade: cubic-bezier(.25, .1, .25, 1);    /* opacity, colour, blur, and exits */
  --dur-1: 160ms;  /* hover, press, colour, copy tick: soft but quick */
  --dur-2: 240ms;  /* menus, selects, popovers, tooltips, tabs, accordion, toasts */
  --dur-3: 320ms;  /* dialogs */
  --dur-4: 420ms;  /* sheets, drawers, scroll reveal */
  --dur-exit: 200ms; /* leaving is a little faster than arriving */

  /* ---- Layout ---- */
  --container: 1200px;
  --gutter: 24px;
  --gap: 24px;
  --sec: 128px;         /* space between two sections: generous, so each section holds little */
  --control-h: 36px;    /* compact buttons and inputs (30 small, 44 large; 44 for everything on phones) */
  --nav-h: 56px;
  --nav-pill-h: 48px;
  --sidebar-w: 248px;
  --z-nav: 50; --z-dialog: 60; --z-pop: 70; --z-toast: 80; /* popups (Select, Menu, Tooltip) open above dialogs */
}

/* Breakpoints (mobile first): sm 640, md 768, lg 1024, xl 1280. Narrowest supported width: 360. */
@media (max-width: 1023px) { :root { --sec: 96px; } }
@media (max-width: 639px)  { :root { --sec: 72px; --gutter: 20px; --gap: 16px; --control-h: 44px; } }
@media (max-width: 360px)  { :root { --gutter: 16px; } }

/* ---- Dark: system setting, unless the page forced light ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #09090b; --bg-subtle: #0c0c0f; --surface: #111114; --surface-2: #18181c; --field: #0e0e11;
    --line: rgb(255 255 255 / 0.10); --line-2: rgb(255 255 255 / 0.17);
    --ink: #f4f4f5; --ink-2: #cdcdd4; --ink-3: #a1a1aa;
    --overlay: rgb(0 0 0 / 0.48); --hl: rgb(255 255 255 / 0.05);
    --ok: #4ade80; --ok-soft: rgb(74 222 128 / 0.12);
    --bad: #f87171; --bad-soft: rgb(248 113 113 / 0.12); --bad-fill: #dc2626; /* 4.8:1 with white */
    --warn: #fbbf24; --warn-soft: rgb(251 191 36 / 0.12);
    --info: #60a5fa; --info-soft: rgb(96 165 250 / 0.12);
    --brand: #818cf8; --brand-hover: #a5b4fc; --brand-ink: #0b0d12; --brand-text: #a5b4fc; /* ink on fill 6.5:1, text and ring 10:1 */
    --brand-soft: rgb(129 140 248 / 0.16); --brand-ring: #a5b4fc;
    --sh-1: 0 0 0 1px var(--line), inset 0 1px 0 var(--hl);
    --sh-2: 0 0 0 1px var(--line-2), inset 0 1px 0 var(--hl), 0 2px 4px -1px rgb(0 0 0 / 0.50);
    --sh-3: 0 0 0 1px var(--line-2), inset 0 1px 0 var(--hl), 0 4px 10px -4px rgb(0 0 0 / 0.60);
    --sh-btn: 0 1px 0 rgb(255 255 255 / 0.18) inset;
  }
}

/* ---- Dark: forced by the toggle ---- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b; --bg-subtle: #0c0c0f; --surface: #111114; --surface-2: #18181c; --field: #0e0e11;
  --line: rgb(255 255 255 / 0.10); --line-2: rgb(255 255 255 / 0.17);
  --ink: #f4f4f5; --ink-2: #cdcdd4; --ink-3: #a1a1aa;
  --overlay: rgb(0 0 0 / 0.48); --hl: rgb(255 255 255 / 0.05);
  --ok: #4ade80; --ok-soft: rgb(74 222 128 / 0.12);
  --bad: #f87171; --bad-soft: rgb(248 113 113 / 0.12); --bad-fill: #dc2626;
  --warn: #fbbf24; --warn-soft: rgb(251 191 36 / 0.12);
  --info: #60a5fa; --info-soft: rgb(96 165 250 / 0.12);
  --brand: #818cf8; --brand-hover: #a5b4fc; --brand-ink: #0b0d12; --brand-text: #a5b4fc; /* ink on fill 6.5:1, text and ring 10:1 */
  --brand-soft: rgb(129 140 248 / 0.16); --brand-ring: #a5b4fc;
  --sh-1: 0 0 0 1px var(--line), inset 0 1px 0 var(--hl);
  --sh-2: 0 0 0 1px var(--line-2), inset 0 1px 0 var(--hl), 0 2px 4px -1px rgb(0 0 0 / 0.50);
  --sh-3: 0 0 0 1px var(--line-2), inset 0 1px 0 var(--hl), 0 4px 10px -4px rgb(0 0 0 / 0.60);
  --sh-btn: 0 1px 0 rgb(255 255 255 / 0.18) inset;
}

/* No backdrop-filter (old browsers, some Linux setups): make translucent surfaces nearly opaque. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --nav-bg: color-mix(in oklab, var(--bg) 96%, transparent); --nav-bg-pill: color-mix(in oklab, var(--surface) 97%, transparent); }
}

/* Reduced motion: no movement and no blur; opacity changes stay, short. motion.css removes the transforms. */
@media (prefers-reduced-motion: reduce) {
  :root { --dur-1: 1ms; --dur-2: 120ms; --dur-3: 120ms; --dur-4: 120ms; --dur-exit: 100ms; }
}
