/* Inter Variable — Synadia's body font. Imported first so @layer base can
   rely on it; served from Google Fonts with font-display: swap so the page
   paints immediately with the system fallback and upgrades when loaded. */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap");

/* Geist Mono — monospace face used by every `font-mono` utility. Same Google
   Fonts + font-display: swap model as Inter so the page paints immediately in
   the ui-monospace fallback and upgrades when Geist Mono arrives. */
@import url("https://fonts.googleapis.com/css2?family=Geist+Mono:wght@100..900&display=swap");

@layer base {
  :root:has(input.theme-controller[value="synadia"]:checked),
  [data-theme="synadia"] {
    color-scheme: dark;
    --color-base-100: #101013;
    --color-base-200: #18181B;
    --color-base-300: #27272A;
    --color-base-content: #FAFAFA;
    --color-primary: #5E55ED;
    --color-primary-content: #ffffff;
    --color-accent: #A855F7;
    --color-accent-content: #ffffff;
    --color-neutral: #A1A1AA;
    --color-neutral-content: #101013;
    --color-info: #3B82F6;
    --color-info-content: #EFF6FF;
    --color-success: #00E492;
    --color-success-content: #042F2E;
    --color-warning: #F59E0B;
    --color-warning-content: #422006;
    --color-error: #EF4444;
    --color-error-content: #FEF2F2;
    --radius-selector: 1rem;
    --radius-field: 0.25rem;
    --radius-box: 0.5rem;
    --size-selector: 0.25rem;
    --size-field: 0.25rem;
    --border: 1px;
    --depth: 0;
    --noise: 0;

    /* Brand tokens (not consumed by DaisyUI; used by utilities below) */
    --brand-synadia-base: #5E55ED;
    --brand-synadia-accent: #A855F7;
    --brand-synadia-indigo: #4F46E5;
    --brand-nats-base: #00E492;
    --brand-nats-aqua: #4BEBED;
    --brand-border: #27272A;

    /* Semantic extensions consumed by Synadia-branded apps.
       --color-live shares the NATS-teal hue with --color-success; the live
       pulse animation conveys "ongoing", a static dot conveys "evaluated OK".
       --color-spark is the primary sparkline series (Tailwind emerald-500);
       --color-spark-2 is paired with it (in/out) using Tailwind teal-500 so
       the dual-series pair reads as analogous-but-distinct at sparkline
       stroke widths. Both align with the GridSparks loader palette below.
       --color-brand mirrors the emerald gradient endpoint in the logo and
       is the hover accent for sidebar navigation and theme controls — kept
       separate from --color-primary (indigo) which still drives the
       synadia-dusk gradient endpoints. */
    --color-live: #00E492;
    --color-live-content: #042F2E;
    --color-spark: #10B981;
    --color-spark-2: #14B8A6;
    --color-spark-ref: oklch(0.55 0 0 / 0.5);
    --color-brand: #10B981;

    /* Motion scale — used by loaders, hover lifts, and tab transitions. The
       three durations cover micro (color tweaks), routine (pill hover, tab
       swap), and macro (modal enter, search width). ease-out is the only
       curve callers should reach for unless they explicitly need symmetric
       easing — terminating decel feels alive, accelerating-in feels lazy. */
    --motion-fast: 150ms;
    --motion-base: 200ms;
    --motion-slow: 300ms;
    --ease-out: cubic-bezier(0, 0, 0.2, 1);

    /* GridSparks palette — cyan/teal/emerald drives the loader canvas.
       Stored as raw `R, G, B` so canvas code can build `rgba(...)` strings. */
    --spark-hue-1: 6, 182, 212;   /* cyan-500 */
    --spark-hue-2: 20, 184, 166;  /* teal-500 */
    --spark-hue-3: 16, 185, 129;  /* emerald-500 */
  }

  :root:has(input.theme-controller[value="synadia-light"]:checked),
  [data-theme="synadia-light"] {
    color-scheme: light;
    --color-base-100: #FFFFFF;
    --color-base-200: #F4F4F5;
    --color-base-300: #E4E4E7;
    --color-base-content: #18181B;
    --color-primary: #5E55ED;
    --color-primary-content: #ffffff;
    --color-accent: #A855F7;
    --color-accent-content: #ffffff;
    --color-neutral: #52525B;
    --color-neutral-content: #FAFAFA;
    --color-info: #2563EB;
    --color-info-content: #EFF6FF;
    --color-success: #00B87A;
    --color-success-content: #ECFDF5;
    --color-warning: #D97706;
    --color-warning-content: #422006;
    --color-error: #DC2626;
    --color-error-content: #FEF2F2;
    --radius-selector: 1rem;
    --radius-field: 0.25rem;
    --radius-box: 0.5rem;
    --size-selector: 0.25rem;
    --size-field: 0.25rem;
    --border: 1px;
    --depth: 0;
    --noise: 0;

    --brand-synadia-base: #5E55ED;
    --brand-synadia-accent: #A855F7;
    --brand-synadia-indigo: #4F46E5;
    --brand-nats-base: #00E492;
    --brand-nats-aqua: #4BEBED;
    --brand-border: #E4E4E7;

    /* Live shares the NATS-teal hue with --color-success; the darker variant
       preserves WCAG AA on white. blue-600 / amber-600 used elsewhere for the
       same reason. Spark series use Tailwind emerald-600 / teal-600 — one
       shade darker than the dark theme so they hold AA contrast on white.
       --color-brand likewise steps to emerald-600 on light theme.
       See the synadia (dark) block above for context. */
    --color-live: #00B87A;
    --color-live-content: #ECFDF5;
    --color-spark: #059669;
    --color-spark-2: #0D9488;
    --color-spark-ref: oklch(0.55 0 0 / 0.6);
    --color-brand: #059669;

    /* Motion scale — see synadia (dark) block above for context. */
    --motion-fast: 150ms;
    --motion-base: 200ms;
    --motion-slow: 300ms;
    --ease-out: cubic-bezier(0, 0, 0.2, 1);

    /* GridSparks palette — one shade darker than dark theme so the canvas
       holds AA contrast against the light page background. */
    --spark-hue-1: 6, 148, 173;
    --spark-hue-2: 16, 148, 134;
    --spark-hue-3: 13, 148, 102;
  }
}

/* Typography — Synadia uses Inter Variable as the body font. When the font is
   not available locally, the system-ui stack provides a close fallback. */
html,
body {
  font-family:
    "Inter Variable",
    "Inter",
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* Tailwind v4's `font-mono` utility expands to `font-family: var(--font-mono)`.
   Setting --font-mono on :root overrides Tailwind's default stack so every
   font-mono callsite picks up Geist Mono. ui-monospace next so the platform's
   native programming font (SF Mono on macOS, Cascadia/Consolas on Windows)
   carries the page until Geist loads. Defined as a plain custom property — not
   inside @theme — because synadia.css is loaded as a static stylesheet, not
   compiled by Tailwind, so @theme directives here would be ignored. */
:root {
  --font-mono:
    "Geist Mono",
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    "Courier New",
    monospace;
}

/* Geist Mono at weight 700 reads heavier than SF Mono at the same weight, so
   `font-mono` + `font-bold` callsites (metric values, sequence numbers, time
   controls) feel chunky. Step down to 600 on this combination only — leaves
   sans-serif `font-bold` and standalone `font-mono` untouched. Two-class
   selector outranks Tailwind's single-class `.font-bold` utility. */
.font-mono.font-bold {
  font-weight: 600;
}

/* Tight letter-spacing on display headings mirrors synadia.com's hero type.
   Percent-based tracking matches across scales (≈ -2.5% at 96px, -2.5% at 48px). */
h1 {
  letter-spacing: -0.025em;
}
h2 {
  letter-spacing: -0.02em;
}
h3 {
  letter-spacing: -0.0125em;
}

.tooltip::before {
  text-transform: none;
  font-size: 0.75rem;
  font-weight: normal;
  letter-spacing: normal;
  z-index: 50;
}
.tooltip::after {
  z-index: 50;
}

summary::-webkit-details-marker {
  display: none;
}

summary::marker {
  display: none;
  content: none;
}

/* --- Brand utilities ------------------------------------------------------
   These mirror the gradients and shadows exposed in synadia.com's tailwind
   config (synadia dusk/dawn, NATS gradient, NATS shadow). Use on hero CTAs,
   marketing surfaces, and feature highlights — not on routine UI chrome. */

.bg-synadia-dusk {
  background-image: linear-gradient(135deg, #5E55ED 0%, #A855F7 100%);
}

.bg-synadia-dawn {
  background-image: linear-gradient(135deg, #A855F7 0%, #5E55ED 100%);
}

.bg-nats-gradient {
  background-image: linear-gradient(135deg, #4BEBED 0%, #00E492 100%);
}

.text-gradient-synadia {
  background-image: linear-gradient(135deg, #5E55ED 0%, #A855F7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.text-gradient-nats {
  background-image: linear-gradient(135deg, #4BEBED 0%, #00E492 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.shadow-nats {
  box-shadow:
    0 -20px 48px 1px rgba(56, 255, 232, 0.21),
    0 20px 48px rgba(81, 245, 245, 0.4),
    0 4px 20px -3px rgba(0, 0, 0, 0.5);
}

.border-synadia {
  border-image-source: linear-gradient(to bottom, #5E55ED, #A855F7);
  border-image-slice: 1;
}

/* --- Brand hover utilities ------------------------------------------------
   Emerald accent for icon/text hover affordance on sidebar navigation and
   theme controls — keeps the visible highlight aligned with the logo's
   emerald gradient instead of the indigo --color-primary used by branded
   gradient surfaces. Selectors mirror what Tailwind v4 emits for `hover:`,
   `group-hover:`, and `group-hover/details:` so callers can keep the same
   class shape they use for `text-primary`. Defined manually because
   synadia.css is not run through Tailwind (see comment near --font-mono). */

.text-brand {
  color: var(--color-brand);
}

.border-brand {
  border-color: var(--color-brand);
}

.hover\:text-brand:hover {
  color: var(--color-brand);
}

.hover\:border-brand:hover {
  border-color: var(--color-brand);
}

.group:hover .group-hover\:text-brand {
  color: var(--color-brand);
}

.group:hover .group-hover\:border-brand {
  border-color: var(--color-brand);
}

.group\/details:hover .group-hover\/details\:text-brand {
  color: var(--color-brand);
}

.group\/details:hover .group-hover\/details\:border-brand {
  border-color: var(--color-brand);
}

/* --- Liveness utilities ---------------------------------------------------
   NATS-teal semantic for "currently flowing" indicators (live pulses, SSE
   activity, streaming connections). Separate from --color-success, which
   marks evaluated terminal states (check passed, upload complete). */

.text-live {
  color: var(--color-live);
}

.bg-live {
  background-color: var(--color-live);
  color: var(--color-live-content);
}

.border-live {
  border-color: var(--color-live);
}

.border-live\/30 {
  border-color: color-mix(in oklch, var(--color-live) 30%, transparent);
}

.hover\:bg-live\/10:hover {
  background-color: color-mix(in oklch, var(--color-live) 10%, transparent);
}

/* --- Motion keyframes -----------------------------------------------------
   live-breathe: calm 2.4s breathing halo. Replaces DaisyUI's animate-ping,
   which feels frantic at 1s. fade-up-sm: subtle 6px lift used by the
   [data-anim="enter"] utility on tab content + dialog enters. shimmer: the
   skeleton loader gradient. All three are zeroed out under
   prefers-reduced-motion. */

@keyframes live-breathe {
  0%, 100% { transform: scale(0.85); opacity: 0.55; }
  50%      { transform: scale(2);    opacity: 0; }
}

@keyframes fade-up-sm {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* live-dot: replacement for the animate-ping span pair. Two children:
   .core (solid 6px dot) + .halo (breathing aura). The wrapper itself sets
   the 8px footprint matching the existing `relative flex h-2 w-2` host. */
.live-dot {
  position: relative;
  display: inline-flex;
  width: 0.5rem;
  height: 0.5rem;
  flex-shrink: 0;
}
.live-dot .core {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--color-live);
  box-shadow: 0 0 5px color-mix(in oklch, var(--color-live) 60%, transparent);
}
.live-dot .halo {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background: var(--color-live);
  opacity: 0.55;
  animation: live-breathe 2.4s ease-in-out infinite;
}

/* Enter animation utility — apply to a container that should fade-up on
   appearance (tab content swap, dialog enter). Avoid wiring this onto
   anything that re-renders on every epoch — it will pulse every 5s. */
[data-anim="enter"] {
  animation: fade-up-sm var(--motion-slow) var(--ease-out) both;
}

/* --- Pill buttons --------------------------------------------------------
   synadia.com pill style sized for a working tool. Three sizes mirror DaisyUI
   density (xs ≈ btn-xs, sm ≈ btn-sm, default ≈ btn-md). Modifiers (`primary`,
   `live`, `warning`, `ghost`, `icon`) layer on top.

   Hover lift: border + shadow tighten — no transform — so an entire grid of
   pills doesn't jitter when the cursor crosses it. Reduced-motion users still
   see the color/border change, just without the timed transition. */

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 9999px;
  padding: 0.3125rem 0.75rem;
  font-size: 0.75rem;
  line-height: 1.25;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: var(--color-base-100);
  border: 1px solid var(--color-base-300);
  color: var(--color-base-content);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  transition-property: border-color, box-shadow, background-color;
  transition-duration: var(--motion-base);
  transition-timing-function: var(--ease-out);
}
.btn-pill:hover {
  border-color: color-mix(in oklch, var(--color-base-content) 32%, transparent);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.14);
}

.btn-pill.btn-pill-xs {
  padding: 0.125rem 0.5rem;
  font-size: 0.65625rem;
  gap: 0.25rem;
}
.btn-pill.btn-pill-sm {
  padding: 0.1875rem 0.625rem;
  font-size: 0.71875rem;
  gap: 0.3125rem;
}
.btn-pill.btn-pill-lg {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
}

.btn-pill.primary {
  background: var(--color-primary);
  color: var(--color-primary-content);
  border-color: color-mix(in oklch, var(--color-primary) 50%, transparent);
}
.btn-pill.primary:hover {
  border-color: var(--color-primary);
  box-shadow: 0 4px 12px color-mix(in oklch, var(--color-primary) 28%, transparent);
}

.btn-pill.live {
  background: color-mix(in oklch, var(--color-live) 10%, transparent);
  color: var(--color-live);
  border-color: color-mix(in oklch, var(--color-live) 32%, transparent);
}
.btn-pill.live:hover {
  border-color: color-mix(in oklch, var(--color-live) 55%, transparent);
  box-shadow: 0 3px 10px color-mix(in oklch, var(--color-live) 16%, transparent);
}
/* Active/pressed state — currently selected pill (e.g., Now toggle when
   live is active). Uses btn-active to match DaisyUI's existing toggle
   pattern so callers can keep the same templ.KV() wiring. */
.btn-pill.btn-active,
.btn-pill[aria-pressed="true"] {
  background: color-mix(in oklch, var(--color-base-content) 10%, transparent);
  border-color: color-mix(in oklch, var(--color-base-content) 32%, transparent);
}
.btn-pill.live.btn-active,
.btn-pill.live[aria-pressed="true"] {
  background: color-mix(in oklch, var(--color-live) 22%, transparent);
  border-color: color-mix(in oklch, var(--color-live) 55%, transparent);
}

.btn-pill.warning {
  background: color-mix(in oklch, var(--color-warning) 12%, transparent);
  color: var(--color-warning);
  border-color: color-mix(in oklch, var(--color-warning) 38%, transparent);
}
.btn-pill.warning:hover {
  border-color: color-mix(in oklch, var(--color-warning) 60%, transparent);
  box-shadow: 0 3px 10px color-mix(in oklch, var(--color-warning) 18%, transparent);
}

.btn-pill.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.btn-pill.ghost:hover {
  background: color-mix(in oklch, var(--color-base-content) 6%, transparent);
  border-color: transparent;
  box-shadow: none;
}

.btn-pill.icon {
  padding: 0.25rem;
  width: 1.625rem;
  height: 1.625rem;
  justify-content: center;
}
.btn-pill.icon.btn-pill-xs {
  width: 1.375rem;
  height: 1.375rem;
  padding: 0.1875rem;
}

@media (prefers-reduced-motion: reduce) {
  .btn-pill, .btn-pill * { transition: none !important; }
}

/* Skeleton line — text-shaped placeholder with a shimmering gradient pass.
   Use inside modals or panels that will fill with text-heavy content (config
   diffs, log lines) where a canvas loader would mis-suggest a chart. Pair
   `.short` / `.med` modifiers to vary widths and produce a paragraph-shaped
   stack. */
.skeleton-line {
  height: 0.75rem;
  border-radius: 0.25rem;
  background: linear-gradient(
    90deg,
    color-mix(in oklch, var(--color-base-content) 6%, transparent) 0%,
    color-mix(in oklch, var(--color-base-content) 12%, transparent) 40%,
    color-mix(in oklch, var(--color-base-content) 6%, transparent) 80%
  );
  background-size: 240% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.skeleton-line.short { width: 30%; }
.skeleton-line.med { width: 60%; }

@media (prefers-reduced-motion: reduce) {
  .live-dot .halo { animation: none; opacity: 0.4; }
  [data-anim="enter"] { animation: none; }
  .skeleton-line { animation: none; opacity: 0.6; }
}
