/*
 * Straddle neutral skin tokens (value layer).
 *
 * Linear-informed neutral light + dark ladder in OKLCH. Components key off the
 * shadcn semantic tokens below; the [data-slot] polish lives in
 * straddle-components.css. Re-skin the whole neutral ladder by changing the two
 * knobs --tint-hue (temperature) and --tint-strength (tint amount).
 *
 * Action and brand are split: --primary and --ring carry interactive green,
 * while --accent-brand carries the brighter brand mark/accent. Field focus uses
 * --info in straddle-components.css, so green stays reserved for actions.
 */

:root {
  color-scheme: light;

  /* Palette knobs: --tint-hue = temperature (cool ~280, warm ~80),
     --tint-strength = tint amount (0 = pure grey). */
  --tint-hue: 92;
  --tint-strength: 1;

  /* Warm-paper ladder (hue 92), cards-pop. Content canvas low enough that cards
     lift above it; popover stays OFF pure white (no #fff). Near white the L-steps
     are tiny (ΔE ~1) — the border carries elevation here, not lightness:
       popover   oklch(0.998)   overlays (off-white cap)
       card      oklch(0.992)   cards (pop above canvas)
       canvas    oklch(0.986)   main content ground (tables sit here)
       background oklch(0.955)  app frame, sidebar, topbar (a bit dimmer)
       secondary oklch(0.930)   hover fill */
  --background: oklch(0.955 calc(0.004 * var(--tint-strength)) var(--tint-hue));
  --foreground: oklch(0.277 0 0);
  --card: oklch(0.992 calc(0.003 * var(--tint-strength)) var(--tint-hue));
  --card-foreground: oklch(0.277 0 0);
  /* Terminal stays dark in both themes so ANSI foreground colors remain legible. */
  --terminal: oklch(0.141 0.005 285.823);
  --terminal-foreground: oklch(0.967 0.001 286.375);
  --canvas: oklch(0.986 calc(0.0024 * var(--tint-strength)) var(--tint-hue));
  --popover: oklch(0.998 calc(0.0025 * var(--tint-strength)) var(--tint-hue));
  --popover-foreground: oklch(0.277 0 0);
  --primary: oklch(0.51 0.11 162);
  --primary-foreground: oklch(0.97 0.01 90);
  --secondary: oklch(0.93 calc(0.006 * var(--tint-strength)) var(--tint-hue));
  --secondary-foreground: oklch(0.277 0 0);
  /* Secondary-button hover: one step DARKER than --secondary 0.93 (same hue/tint),
     so the solid fill shifts one visible step on hover instead of dimming via /80.
     Consumed via var() in straddle-components.css. */
  --secondary-hover: oklch(
    0.9 calc(0.006 * var(--tint-strength)) var(--tint-hue)
  );
  --muted: oklch(0.945 calc(0.005 * var(--tint-strength)) var(--tint-hue));
  --muted-foreground: oklch(0.45 0 0);
  --accent: oklch(0.92 calc(0.004 * var(--tint-strength)) var(--tint-hue));
  --accent-foreground: oklch(0.277 0 0);
  /* Selected-row fill: ACHROMATIC ink at low alpha, a subtle wash (~1.1-1.8:1
     vs the row), never a 3:1 highlight. Held in light+dark, NOT tint-driven. */
  --selected: oklch(0.27 0 0 / 0.08);
  --destructive: oklch(0.54 0.22 27);
  --destructive-foreground: oklch(0.99 0.005 25);
  --success: oklch(0.54 0.14 150);
  --success-foreground: oklch(0.99 0.005 150);
  --warning: oklch(0.74 0.15 78);
  --warning-foreground: oklch(0.27 0.04 78);
  --info: oklch(0.52 0.104 235);
  --info-foreground: oklch(0.99 0.005 235);

  /* Border ladder (Linear's 3 line levels). Translucent near-black so each
     adapts on any surface; alpha is the step. */
  --border-subtle: oklch(0.16 0 0 / 0.05);
  --border: oklch(0.16 0 0 / 0.1);
  --border-strong: oklch(0.16 0 0 / 0.17);
  --input: oklch(0.16 0 0 / 0.1);
  --ring: oklch(0.5 0.1 162);

  /* Form field fill: the lightest surface (the popover white) so a field LIFTS off the
     grey page and canvas grounds, clean and crisp like a white input on a tinted page,
     rather than dimming into them. Inside a white card it reads border-defined (the thin
     --border-strong edge carries it). Focus on fields is a soft blue info glow (--info),
     so green stays the action color (--ring, --primary). Consumed directly by the form
     [data-slot] rules. */
  --field: oklch(0.998 calc(0.0025 * var(--tint-strength)) var(--tint-hue));

  /* Chart series: five distinct chromatic hues so a 5-series chart never
     collapses two lines to the same color. 1 red, 2 teal, 3 blue, 4 amber,
     5 violet; all separated from each other and from the axis-label gray. */
  --chart-1: oklch(0.59 0.198 4);
  --chart-2: oklch(0.697 0.135 172);
  --chart-3: oklch(0.5 0.13 250);
  --chart-4: oklch(0.7 0.15 85);
  --chart-5: oklch(0.55 0.2 300);

  --radius: 0.625rem;
  --radius-button: 0.5rem;
  /* Badge chip radius: brand rectangle, used directly like --radius-button. */
  --radius-badge: 0.25rem; /* 4px */

  /* Faintest ink tier: the lightest label/hint text. Faint by design. */
  --muted-foreground-3: oklch(0.56 0 0);

  /* Badge soft-fills + dedicated text inks for status pills (TE.3 Badge uses
     bg-badge-{tone}-bg text-badge-{tone}-fg). The bright --{tone} semantics are
     fill colors, too light to read as text on the tint, so each tone carries a
     darker hue-matched ink. Light fills are consistent L~0.965 tints; the ink is
     a dark L~0.44 hue. Every fg/bg pair is >=4.5:1 (success 6.71, warning 6.69,
     info 7.03, error 7.13). */
  --badge-success-bg: oklch(0.96 0.015 150);
  --badge-success-fg: oklch(0.3 0.074 150);
  --badge-warning-bg: oklch(0.95 0.04 80);
  --badge-warning-fg: oklch(0.32 0.06 70);
  --badge-info-bg: oklch(0.95 0.025 235);
  --badge-info-fg: oklch(0.3 0.06 235);
  --badge-error-bg: oklch(0.96 0.02 25);
  --badge-error-fg: oklch(0.3 0.115 27);
  /* Badge neutral chip fill: faint achromatic ink wash so the status chip reads as
     a contained unit on card/canvas. Dark overrides to a white wash below. */
  --badge-neutral-bg: oklch(0.22 0 0 / 0.04);
  /* Badge default fill: the calm base/functional green for the default badge, NOT the
     action pop; reserves the louder --primary for interactive elements. */
  --badge-default-bg: oklch(0.458 0.096 165);
  --badge-default-fg: oklch(0.97 0.012 165);

  /* Links: NEUTRAL ink (~text color), no hue; the underline carries them (a11y).
     >=4.5:1 on --background and --card; hover one step darker. */
  --link: oklch(0.25 0.006 85);
  --link-hover: oklch(0.18 0.006 85);

  /* Brand Spark (reserved, sparing): neon underlines, key highlights, and
     brand glyphs. Not a text color; verify contrast for every composition.
     NOT wired into shadcn --accent (that stays the achromatic hover surface). */
  --accent-brand: oklch(0.825 0.237 148);

  /* Table header surface: one perceptible step off --card (white) toward grey. */
  --table-header: oklch(
    0.986 calc(0.0024 * var(--tint-strength)) var(--tint-hue)
  );

  /* Modal scrim: foreground ink at partial alpha (replaces hardcoded bg-black/10). */
  --overlay-backdrop: oklch(0.22 0.015 265 / 0.55);

  /* Inner offset-ring color for two-tone focus rings: the surface behind the
     control (light frame/card). */
  --focus-ring-inner: oklch(
    0.955 calc(0.004 * var(--tint-strength)) var(--tint-hue)
  );

  /* Elevation: a soft cool-neutral ambient shadow (hue 265, low chroma ~0.012) that
     wraps the card on every side with a slight bottom weight, plus a faint inset top
     highlight so the top edge catches light (Linear-style lift). The crisp --border
     hairline carries the edge; the ambient shadow carries the float. Real :root vars
     (NOT @theme, which does not emit a usable runtime variable). */
  --shadow-raised:
    inset 0 1px 0 0 oklch(1 0 0 / 0.6),
    /* top highlight: light on the top edge */ 0 1px 2px 0
      oklch(0.21 0.012 265 / 0.06),
    /* tight contact shadow */ 0 3px 8px 0 oklch(0.21 0.012 265 / 0.05),
    /* mid layer, 0 spread wraps the sides */ 0 10px 24px -2px
      oklch(0.21 0.012 265 / 0.05); /* wide soft ambient halo */
  --shadow-raised-hover:
    0 0 0 0.5px oklch(0.22 0.015 265 / 0.06),
    0 2px 3px oklch(0.22 0.015 265 / 0.08),
    0 6px 6px -3px oklch(0.22 0.015 265 / 0.06),
    0 14px 28px -8px oklch(0.22 0.015 265 / 0.1);
  --shadow-elevated:
    0 1px 0 0 oklch(0.2 0.02 85 / 0.05),
    /* shared seat */ 0 6px 16px -6px oklch(0.24 0.03 85 / 0.12),
    0 14px 30px -12px oklch(0.2 0.025 85 / 0.1);

  /* Motion: durations + curves (strong ease-out beats the weak built-in). */
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-spin: 700ms;
  /* The over-300ms exception the spec allows, for drawer/sheet PANEL enters only.
     Larger surfaces travel farther, so a calmer 350ms reveal reads better than the
     standard base enter; exits still snap fast. */
  --duration-slow: 350ms;

  --sidebar: oklch(0.955 calc(0.004 * var(--tint-strength)) var(--tint-hue));
  --sidebar-foreground: oklch(0.277 0 0);
  --sidebar-primary: oklch(0.21 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(
    0.908 calc(0.004 * var(--tint-strength)) var(--tint-hue)
  );
  --sidebar-accent-foreground: oklch(0.277 0 0);
  /* Sidebar hover: 0.93, lighter than the 0.908 active --sidebar-accent fill, so a hovered
     rail item reads as a weaker step on the light ground than the selected one. */
  --sidebar-hover: oklch(
    0.93 calc(0.004 * var(--tint-strength)) var(--tint-hue)
  );
  --sidebar-border: oklch(0.16 0 0 / 0.1);
  --sidebar-ring: oklch(0.58 0 0);
}

.dark {
  color-scheme: dark;

  /* Deep cool substrate (hue 250). Non-uniform ladder: a big first lift off the
     near-black frame, then settling steps. frame/sidebar 0.120, canvas 0.170,
     cards 0.202, overlay 0.234; gentle chroma rise .012 to .024 keeps lifted
     surfaces cool, never gray/brown. The L-step carries separation; borders
     are the Linear ladder (white, lighter-than-surface, 3 / 7 / 14%) as finish.
     Text anchored calm at L.80 (not bright; the glow was font-smoothing). */
  --tint-hue: 250;
  --tint-strength: 1;
  --background: oklch(0.12 calc(0.012 * var(--tint-strength)) var(--tint-hue));
  --foreground: oklch(0.8 0 0);
  --card: oklch(0.202 calc(0.02 * var(--tint-strength)) var(--tint-hue));
  --card-foreground: oklch(0.8 0 0);
  --terminal: oklch(0.141 0.005 285.823);
  --terminal-foreground: oklch(0.967 0.001 286.375);
  --canvas: oklch(0.17 calc(0.016 * var(--tint-strength)) var(--tint-hue));
  --popover: oklch(0.234 calc(0.024 * var(--tint-strength)) var(--tint-hue));
  --popover-foreground: oklch(0.8 0 0);
  /* Action green (hue 162), L raised from v6 .42 to .51 so the fill is >=3:1 vs
     --card and the soft off-white label is >=4.5 on it; in sRGB. Dark --primary is
     ALREADY the rest (no canvas-flip in dark). Shared by checkbox/radio/switch. */
  --primary: oklch(0.51 0.11 162);
  --primary-foreground: oklch(0.95 0.018 162);
  --secondary: oklch(0.52 calc(0.022 * var(--tint-strength)) var(--tint-hue));
  --secondary-foreground: oklch(0.946 0 0);
  /* Secondary-button hover (dark): one step LIGHTER than --secondary 0.52 (same tint),
     so the fill lifts one visible step on hover (same direction as light: more
     prominent), instead of darkening via the stock /80. */
  --secondary-hover: oklch(
    0.58 calc(0.022 * var(--tint-strength)) var(--tint-hue)
  );
  --muted: oklch(0.15 calc(0.014 * var(--tint-strength)) var(--tint-hue));
  --muted-foreground: oklch(0.66 0 0);
  --accent: oklch(0.5 calc(0.022 * var(--tint-strength)) var(--tint-hue));
  --accent-foreground: oklch(0.946 0 0);
  --selected: oklch(1 0 0 / 0.1);
  --destructive: oklch(0.64 0.2 25);
  --destructive-foreground: oklch(0.22 0.03 25);
  --success: oklch(0.74 0.15 156);
  --success-foreground: oklch(0.22 0.03 156);
  --warning: oklch(0.84 0.145 88);
  --warning-foreground: oklch(0.25 0.04 88);
  --info: oklch(0.68 0.13 232);
  --info-foreground: oklch(0.21 0.04 250);
  --border-subtle: oklch(
    0.92 calc(0.045 * var(--tint-strength)) var(--tint-hue) / 0.03
  );
  --border: oklch(
    0.92 calc(0.045 * var(--tint-strength)) var(--tint-hue) / 0.07
  );
  --border-strong: oklch(
    0.92 calc(0.045 * var(--tint-strength)) var(--tint-hue) / 0.14
  );
  --input: oklch(
    0.92 calc(0.045 * var(--tint-strength)) var(--tint-hue) / 0.12
  );
  --ring: oklch(0.62 0.13 162);

  /* Field fill (dark): the lightest dark surface (the popover tone) so the field lifts
     off the ground, same logic as light rather than sinking into the dark page. */
  --field: oklch(0.234 calc(0.024 * var(--tint-strength)) var(--tint-hue));
  --chart-1: oklch(0.601 0.201 4.2);
  --chart-2: oklch(0.703 0.136 171.7);
  --chart-3: oklch(0.696 0.167 248.9);
  --chart-4: oklch(0.78 0.15 85);
  --chart-5: oklch(0.68 0.18 300);

  /* Faintest ink tier on dark: fainter (lower L) than 0.66. Faint by design. */
  --muted-foreground-3: oklch(0.54 0 0);

  /* Badge soft-fills + text inks (dark): consistent deep tints (L~0.30, lighter
     than --card 0.26 so the pill reads on a card) with a light hue-matched ink
     (L~0.87). Every fg/bg pair is >=4.5:1 (success 9.76, warning 9.51, info 8.77,
     error 8.24). */
  --badge-success-bg: oklch(0.3 0.045 150);
  --badge-success-fg: oklch(0.86 0.1 150);
  --badge-warning-bg: oklch(0.3 0.05 88);
  --badge-warning-fg: oklch(0.88 0.1 88);
  --badge-info-bg: oklch(0.3 0.045 250);
  --badge-info-fg: oklch(0.83 0.085 250);
  --badge-error-bg: oklch(0.3 0.05 27);
  --badge-error-fg: oklch(0.82 0.1 27);
  /* White wash: lighter-than-surface so the chip reads lifted, not recessed. */
  --badge-neutral-bg: oklch(1 0 0 / 0.05);
  /* Badge default fill (dark): same calm base/functional green for the default badge,
     NOT the action pop; reserves the louder --primary for interactive elements. */
  --badge-default-bg: oklch(0.458 0.096 165);
  --badge-default-fg: oklch(0.97 0.012 165);

  /* Links (dark): NEUTRAL ink (~text), no hue; underline carries them.
     >=4.5:1 on --background; hover one step lighter. */
  --link: oklch(0.76 0.006 270);
  --link-hover: oklch(0.85 0.006 270);

  /* Brand spark (reserved, sparing), dark-only voltage: NEON green #00ed64.
     NOT wired into shadcn --accent (achromatic hover surface stays put). */
  --accent-brand: oklch(0.825 0.237 148);

  /* Table header surface: one perceptible step lighter than --card (0.26). */
  --table-header: oklch(
    0.176 calc(0.026 * var(--tint-strength)) var(--tint-hue)
  );

  /* Modal scrim (dark): deeper, higher alpha against the dark frame. */
  --overlay-backdrop: oklch(0.1 0.01 265 / 0.7);

  /* Inner offset-ring color (dark): the surface behind the control = --background. */
  --focus-ring-inner: oklch(
    0.12 calc(0.012 * var(--tint-strength)) var(--tint-hue)
  );

  /* Dark elevation: flatten the shadow, lift the surface instead. */
  --shadow-raised: inset 0 0 0 1000px oklch(1 0 0 / 0.07);
  --shadow-raised-hover: inset 0 0 0 1000px oklch(1 0 0 / 0.11);
  --shadow-elevated: 0 0 0 1px oklch(1 0 0 / 0.07);

  --sidebar: oklch(0.12 calc(0.012 * var(--tint-strength)) var(--tint-hue));
  --sidebar-foreground: oklch(0.8 0 0);
  --sidebar-primary: oklch(0.313 0 0);
  --sidebar-primary-foreground: oklch(0.946 0 0);
  --sidebar-accent: oklch(
    0.5 calc(0.022 * var(--tint-strength)) var(--tint-hue)
  );
  --sidebar-accent-foreground: oklch(0.946 0 0);
  /* Sidebar hover (dark): the 12% white wash, a faint step that stays below the bolder
     active --sidebar-accent 0.50 on the rail. */
  --sidebar-hover: oklch(1 0 0 / 0.12);
  --sidebar-border: oklch(
    0.92 calc(0.045 * var(--tint-strength)) var(--tint-hue) / 0.07
  );
  --sidebar-ring: oklch(0.62 0 0);
}

/* ---------------------------------------------------------------------------
 * Theme bridge (merged in from the former straddle-theme.css).
 *
 * Maps the value layer above onto Tailwind v4 / shadcn theme tokens so
 * utilities (bg-background, text-foreground, border-border, ...) resolve.
 * @theme inline holds ONLY var() references to the tokens above — zero literal
 * values — so it correctly lives in the same file as the values it maps
 * (the canonical Tailwind v4 / shadcn globals shape). Add a new color in two
 * places: define --x in :root + .dark above, then add --color-x: var(--x) here.
 * ------------------------------------------------------------------------- */

@custom-variant dark (&:is(.dark *));

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-card: var(--card);
  --color-card-foreground: var(--card-foreground);
  --color-terminal: var(--terminal);
  --color-terminal-foreground: var(--terminal-foreground);
  --color-canvas: var(--canvas);
  --color-popover: var(--popover);
  --color-popover-foreground: var(--popover-foreground);
  --color-primary: var(--primary);
  --color-primary-foreground: var(--primary-foreground);
  --color-secondary: var(--secondary);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-muted: var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-muted-foreground-3: var(--muted-foreground-3);
  --color-accent: var(--accent);
  --color-accent-foreground: var(--accent-foreground);
  --color-accent-brand: var(--accent-brand);
  --color-destructive: var(--destructive);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-success: var(--success);
  --color-success-foreground: var(--success-foreground);
  --color-warning: var(--warning);
  --color-warning-foreground: var(--warning-foreground);
  --color-info: var(--info);
  --color-info-foreground: var(--info-foreground);
  --color-badge-success-bg: var(--badge-success-bg);
  --color-badge-success-fg: var(--badge-success-fg);
  --color-badge-warning-bg: var(--badge-warning-bg);
  --color-badge-warning-fg: var(--badge-warning-fg);
  --color-badge-info-bg: var(--badge-info-bg);
  --color-badge-info-fg: var(--badge-info-fg);
  --color-badge-error-bg: var(--badge-error-bg);
  --color-badge-error-fg: var(--badge-error-fg);
  --color-link: var(--link);
  --color-link-hover: var(--link-hover);
  --color-table-header: var(--table-header);
  --color-overlay-backdrop: var(--overlay-backdrop);
  --color-focus-ring-inner: var(--focus-ring-inner);

  --color-border: var(--border);
  --color-border-subtle: var(--border-subtle);
  --color-border-strong: var(--border-strong);
  --color-input: var(--input);
  --color-ring: var(--ring);

  --color-chart-1: var(--chart-1);
  --color-chart-2: var(--chart-2);
  --color-chart-3: var(--chart-3);
  --color-chart-4: var(--chart-4);
  --color-chart-5: var(--chart-5);

  --color-sidebar: var(--sidebar);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-ring: var(--sidebar-ring);

  --font-heading: var(--font-sans);
  --font-sans: var(--font-sans);
  --font-mono: var(--font-mono);
  --font-mono-data: var(--font-mono-data);

  /* Control heights = shadcn size variants (sm 28 / default 32 / lg 36). */
  --control-sm: 28px;
  --control: 32px;
  --control-lg: 36px;

  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);
  --radius-xl: 0.75rem;
  --radius-2xl: 1rem;
  --radius-3xl: calc(var(--radius) * 2.2);
  --radius-4xl: calc(var(--radius) * 2.6);
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }

  html {
    @apply font-sans;
  }

  body {
    @apply bg-background text-foreground;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }
}
