/* ==========================================================================
   CodeROG Design System — Tokens
   Single source of truth for colour, type, spacing, radius, motion.
   Never hard-code values in components: always reference a token.
   ========================================================================== */

:root {
  /* ---- Primitive: neutrals (indigo-tinted) ---- */
  --n-0: #ffffff;
  --n-50: #fafaff;
  --n-100: #f3f4fb;
  --n-150: #ebecf6;
  --n-200: #dcdeec;
  --n-300: #c0c3d6;
  --n-400: #9a9db5;
  --n-500: #6d7089;
  --n-600: #50536b;
  --n-700: #34364b;
  --n-800: #24263a;
  --n-900: #1a1b2c;
  --n-950: #121321;
  --n-1000: #0b0c17;

  /* ---- Primitive: brand (CodeROG indigo → violet) ---- */
  --brand-100: #eceeff;
  --brand-200: #cfd4ff;
  --brand-300: #aab3ff;
  --brand-400: #8792ff;
  --brand-500: #6672ff;
  --brand-600: #4d5bfa;
  --brand-700: #3d49d6;
  --brand-800: #303ab0;
  --violet-400: #a99cff;
  --violet-500: #8b7cff;
  --blue-500: #2f6bff;

  /* ---- Primitive: status ---- */
  --green-400: #6fd3a0;
  --green-600: #17885a;
  --red-400: #ff8fb0;
  --red-600: #d5326f;
  --amber-400: #ffc46b;
  --amber-600: #b56a00;

  --gradient-brand: linear-gradient(100deg, #4a56f9 0%, #6d6efb 50%, #9085fe 100%);
  --gradient-text: linear-gradient(100deg, #8792ff 0%, #b9aaff 60%, #e3dcff 100%);

  /* ---- Typography ---- */
  --font-sans: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font-sans);
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --fw-light: 300;
  --fw-book: 360;
  --fw-regular: 400;
  --fw-medium: 480;
  --fw-semibold: 560;
  --fw-bold: 700;

  --text-xxs: 0.625rem;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.125rem;
  --text-lg: 1.313rem;
  --text-xl: 1.5rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2rem;
  --text-4xl: 2.25rem;
  --text-5xl: 2.625rem;
  --text-6xl: 3rem;
  --text-7xl: 3.438rem;

  /* fluid display sizes */
  --display-1: clamp(2.625rem, 0.979rem + 4.116vw, 6rem);
  --display-2: clamp(2.25rem, 0.79rem + 3.66vw, 5.25rem);
  --display-3: clamp(2rem, 0.75rem + 3.126vw, 4.563rem);
  --display-4: clamp(1.75rem, 0.683rem + 2.668vw, 3.938rem);
  --heading-1: clamp(1.75rem, 1.1rem + 1.9vw, 3.438rem);
  --heading-2: clamp(1.75rem, 1.2rem + 1.5vw, 3rem);
  --heading-3: clamp(1.5rem, 1.15rem + 1.1vw, 2.625rem);
  --heading-4: clamp(1.5rem, 1.25rem + 0.8vw, 2.25rem);
  --heading-5: clamp(1.313rem, 1.15rem + 0.55vw, 1.75rem);
  --heading-6: clamp(1.125rem, 1.05rem + 0.35vw, 1.5rem);

  /* ---- Spacing (px scale) ---- */
  --s-0: 0;
  --s-2: 2px;
  --s-4: 4px;
  --s-8: 8px;
  --s-12: 12px;
  --s-16: 16px;
  --s-20: 20px;
  --s-24: 24px;
  --s-32: 32px;
  --s-40: 40px;
  --s-48: 48px;
  --s-56: 56px;
  --s-64: 64px;
  --s-72: 72px;
  --s-80: 80px;
  --s-96: 96px;
  --s-112: 112px;
  --s-128: 128px;
  --s-144: 144px;
  --s-160: 160px;

  /* responsive gaps — mobile first, widened at breakpoints below */
  --gap-xs: var(--s-8);
  --gap-sm: var(--s-16);
  --gap-md: var(--s-16);
  --gap-lg: var(--s-24);
  --gap-xl: var(--s-32);
  --gap-2xl: var(--s-56);
  --gap-3xl: var(--s-80);
  --section-y: var(--s-96);

  --grid-max: 1440px;
  --grid-margin: var(--gap-lg);
  --grid-gutter: var(--gap-md);
  --nav-h: 72px;

  /* ---- Radius ---- */
  --r-sm: 0.25rem;
  --r-md: 0.375rem;
  --r-lg: 0.5rem;
  --r-xl: 0.75rem;
  --r-2xl: 1rem;
  --r-3xl: 1.5rem;
  --r-4xl: 2rem;
  --r-pill: 999px;

  /* ---- Motion ---- */
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-smooth: cubic-bezier(0.16, 0, 0.13, 1);   /* signature long ease */
  --ease-spring: cubic-bezier(0.2, 1, 0.4, 1);     /* quick settle */
  --ease-cubic: cubic-bezier(0.65, 0.05, 0.36, 1);
  --dur-fast: 0.15s;
  --dur: 0.3s;
  --dur-slow: 0.6s;
  --dur-reveal: 1s;
  --reveal-distance: 50px;

  --z-nav: 99;
  --z-overlay: 200;
  --z-toast: 300;
}

@media (min-width: 768px) {
  :root {
    --gap-xs: var(--s-12);
    --gap-sm: var(--s-24);
    --gap-md: var(--s-24);
    --gap-lg: var(--s-32);
    --gap-xl: var(--s-40);
    --gap-2xl: var(--s-72);
    --gap-3xl: var(--s-112);
    --section-y: var(--s-128);
  }
}
@media (min-width: 1280px) {
  :root {
    --gap-md: var(--s-32);
    --gap-2xl: var(--s-80);
    --gap-3xl: var(--s-128);
    --section-y: var(--s-144);
    --grid-margin: var(--s-48);
  }
}

/* ==========================================================================
   Semantic tokens — dark is default. Put data-theme="light" on <html> or on
   any section to flip just that block (sections can alternate themes).
   ========================================================================== */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--n-950);
  --bg-secondary: var(--n-900);
  --bg-frosted: rgb(18 19 33 / 0.72);
  --surface: var(--n-900);
  --surface-hover: var(--n-800);
  --surface-elevated: var(--n-800);
  --surface-elevated-hover: var(--n-700);
  --surface-frosted: rgb(175 180 220 / 0.12);
  --surface-frosted-hover: rgb(175 180 220 / 0.2);
  --surface-frosted-active: rgb(175 180 220 / 0.28);
  --surface-tint: rgb(135 146 255 / 0.14);
  --surface-tint-hover: rgb(135 146 255 / 0.22);
  --surface-primary: var(--brand-600);
  --surface-primary-hover: var(--brand-700);
  --surface-primary-active: var(--brand-800);
  --surface-inverted: var(--n-100);
  --surface-input: rgb(175 180 220 / 0.08);

  --border-subtle: rgb(175 180 220 / 0.1);
  --border: rgb(175 180 220 / 0.18);
  --border-strong: rgb(175 180 220 / 0.36);
  --border-focus: var(--brand-400);

  --text: var(--n-150);
  --text-strong: var(--n-0);
  --text-subdued: var(--n-400);
  --text-disabled: var(--n-500);
  --text-primary: var(--brand-400);
  --text-on-primary: var(--n-0);
  --text-inverted: var(--n-950);
  --text-success: var(--green-400);
  --text-error: var(--red-400);
  --text-warning: var(--amber-400);

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow-md: 0 8px 24px -8px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 32px 64px -24px rgb(0 0 0 / 0.65);
  --shadow-glow: 0 0 0 1px rgb(135 146 255 / 0.25), 0 16px 48px -12px rgb(77 91 250 / 0.55);
  --logo-wordmark: var(--n-0);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: var(--n-50);
  --bg-secondary: var(--n-100);
  --bg-frosted: rgb(250 250 255 / 0.76);
  --surface: var(--n-100);
  --surface-hover: var(--n-150);
  --surface-elevated: var(--n-0);
  --surface-elevated-hover: var(--n-50);
  --surface-frosted: rgb(80 85 130 / 0.08);
  --surface-frosted-hover: rgb(80 85 130 / 0.14);
  --surface-frosted-active: rgb(80 85 130 / 0.2);
  --surface-tint: rgb(77 91 250 / 0.09);
  --surface-tint-hover: rgb(77 91 250 / 0.15);
  --surface-primary: var(--brand-600);
  --surface-primary-hover: var(--brand-700);
  --surface-primary-active: var(--brand-800);
  --surface-inverted: var(--n-950);
  --surface-input: var(--n-0);

  --border-subtle: rgb(80 85 130 / 0.1);
  --border: rgb(80 85 130 / 0.2);
  --border-strong: rgb(80 85 130 / 0.38);
  --border-focus: var(--brand-600);

  --text: var(--n-800);
  --text-strong: var(--n-950);
  --text-subdued: var(--n-600);
  --text-disabled: var(--n-400);
  --text-primary: var(--brand-600);
  --text-on-primary: var(--n-0);
  --text-inverted: var(--n-0);
  --text-success: var(--green-600);
  --text-error: var(--red-600);
  --text-warning: var(--amber-600);

  --shadow-sm: 0 1px 2px rgb(18 19 33 / 0.06);
  --shadow-md: 0 8px 24px -8px rgb(18 19 33 / 0.14);
  --shadow-lg: 0 32px 64px -24px rgb(18 19 33 / 0.22);
  --shadow-glow: 0 0 0 1px rgb(77 91 250 / 0.18), 0 16px 48px -12px rgb(77 91 250 / 0.35);
  --logo-wordmark: var(--n-950);
}

/* any themed block paints its own background + text */
[data-theme] {
  background-color: var(--bg);
  color: var(--text);
}

/* ==========================================================================
   Theme flow — dark and light sections blend into each other on scroll.

   The colour tokens are registered as real colours so the browser can
   animate them. coderog.js moves the theme of plain .cr-section blocks onto
   <body> and switches it as each section reaches the middle of the screen;
   every element using the tokens then cross-fades together.
   Opt a section out with data-flow="off".
   ========================================================================== */
@property --bg { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --bg-secondary { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --bg-frosted { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --surface { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --surface-hover { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --surface-elevated { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --surface-elevated-hover { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --surface-frosted { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --surface-frosted-hover { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --surface-frosted-active { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --surface-tint { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --surface-tint-hover { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --surface-inverted { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --surface-input { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --border-subtle { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --border { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --border-strong { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --text { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --text-strong { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --text-subdued { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --text-disabled { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --text-primary { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --text-inverted { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --logo-wordmark { syntax: "<color>"; inherits: true; initial-value: transparent; }

body {
  --flow-dur: 0.9s;
  --flow-ease: cubic-bezier(0.4, 0, 0.2, 1);
  transition:
    --bg var(--flow-dur) var(--flow-ease), --bg-secondary var(--flow-dur) var(--flow-ease), --bg-frosted var(--flow-dur) var(--flow-ease),
    --surface var(--flow-dur) var(--flow-ease), --surface-hover var(--flow-dur) var(--flow-ease),
    --surface-elevated var(--flow-dur) var(--flow-ease), --surface-elevated-hover var(--flow-dur) var(--flow-ease),
    --surface-frosted var(--flow-dur) var(--flow-ease), --surface-frosted-hover var(--flow-dur) var(--flow-ease), --surface-frosted-active var(--flow-dur) var(--flow-ease),
    --surface-tint var(--flow-dur) var(--flow-ease), --surface-tint-hover var(--flow-dur) var(--flow-ease),
    --surface-inverted var(--flow-dur) var(--flow-ease), --surface-input var(--flow-dur) var(--flow-ease),
    --border-subtle var(--flow-dur) var(--flow-ease), --border var(--flow-dur) var(--flow-ease), --border-strong var(--flow-dur) var(--flow-ease),
    --text var(--flow-dur) var(--flow-ease), --text-strong var(--flow-dur) var(--flow-ease), --text-subdued var(--flow-dur) var(--flow-ease),
    --text-disabled var(--flow-dur) var(--flow-ease), --text-primary var(--flow-dur) var(--flow-ease), --text-inverted var(--flow-dur) var(--flow-ease),
    --logo-wordmark var(--flow-dur) var(--flow-ease);
}
/* a section can ask for the softer secondary background */
body[data-flow-tone="secondary"] { --bg: var(--bg-secondary); }
@media (prefers-reduced-motion: reduce) { body { --flow-dur: 0.01s; } }
