/* Semantic token map, type scale, and the component specs from the design
   system. Everything downstream consumes these, never the primitives. */

:root {
  --font-sans: 'Anek Latin', 'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'Roboto Mono', 'Geist Mono', ui-monospace, SFMono-Regular, monospace;

  /* Two-Weight Rule: exactly these two exist. */
  --fw-normal: 400;
  --fw-medium: 550;

  --background: var(--neutral-50);
  --foreground: var(--secondary-900);
  --card: var(--neutral-50);
  --card-foreground: var(--secondary-900);
  --popover: var(--neutral-50);
  --popover-foreground: var(--secondary-900);
  --primary: var(--secondary-900);
  --primary-foreground: var(--neutral-50);
  --secondary: var(--secondary-100);
  --secondary-foreground: var(--secondary-900);
  --muted: var(--neutral-200);
  --muted-foreground: var(--neutral-700);
  --accent: var(--neutral-300);
  --accent-foreground: var(--secondary-900);
  --destructive: var(--alert-500);
  --destructive-foreground: var(--neutral-50);
  --success: var(--primary-500);
  --success-foreground: var(--primary-900);
  --warning: var(--featured-500);
  --warning-foreground: var(--featured-900);
  --border: var(--neutral-400);
  --input: var(--neutral-400);
  --ring: var(--dc-500);

  --radius: 0.625rem;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-2xl: 18px;

  --shadow-2xs: 0 1px 3px 0px rgb(19 15 53 / 0.05);
  --shadow-xs:  0 1px 3px 0px rgb(19 15 53 / 0.05);
  --shadow-sm:  0 1px 3px 0px rgb(19 15 53 / 0.10), 0 1px 2px -1px rgb(19 15 53 / 0.10);
  --shadow-md:  0 1px 3px 0px rgb(19 15 53 / 0.10), 0 2px 4px -1px rgb(19 15 53 / 0.10);
  --shadow-lg:  0 1px 3px 0px rgb(19 15 53 / 0.10), 0 4px 6px -1px rgb(19 15 53 / 0.10);
  --shadow-xl:  0 1px 3px 0px rgb(19 15 53 / 0.10), 0 8px 10px -1px rgb(19 15 53 / 0.10);
  --shadow-soft: 0 4px 12px rgba(19, 15, 53, 0.08);

  /* Chart / timeline slots: slot 1 is the active product primary, then
     featured, dc, rp, alert in fixed order. */
  --chart-1: var(--primary-500);
  --chart-2: var(--featured-500);
  --chart-3: var(--dc-500);
  --chart-4: var(--rp-500);
  --chart-5: var(--alert-500);

  /* Timeline: one block per sampled frame. Named for what the block means,
     so the reader is not decoding "good" and "warn" at the call site. */
  --tl-pov-hands: var(--chart-1);
  --tl-pov:       var(--chart-2);
  --tl-not-pov:   var(--neutral-500);
  --tl-synthetic: var(--chart-4);

  /* A data URI cannot reference a custom property, so the chevron colour is
     pinned here rather than in the component. */
  --select-chevron: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23646D90' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
}

/* Outside any layer so it beats a reset. Constant-Width Rule: 'wdth' 106 on
   every text element, every role. */
html {
  font-family: var(--font-sans);
  font-variation-settings: 'wdth' 106;
  -webkit-text-size-adjust: 100%;
}
code, pre, kbd, samp {
  font-family: var(--font-mono);
  font-variation-settings: normal;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-size: 0.875rem;
  font-weight: var(--fw-normal);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Type scale ---- */
h1 { font-size: 1.5rem;  font-weight: var(--fw-medium); line-height: 1.2; margin: 0; }
h2 { font-size: 1.25rem; font-weight: var(--fw-medium); line-height: 1.3; margin: 0; }
h3 { font-size: 1rem;    font-weight: var(--fw-medium); line-height: 1.4; margin: 0; }
@media (max-width: 640px) {
  h1 { font-size: 1.125rem; }
  body { font-size: 1rem; }
}
.label {
  font-size: 0.75rem;
  font-weight: var(--fw-medium);
  line-height: 1.4;
  letter-spacing: 0.01em;
}
.muted { color: var(--muted-foreground); }
.prose { max-width: 72ch; }

code, pre {
  font-size: 0.8125rem;
  line-height: 1.5;
  font-weight: var(--fw-normal);
}
code {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: .1rem .35rem;
  border-radius: var(--radius-sm);
}
pre {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 1rem;
  border-radius: var(--radius-lg);
  overflow-x: auto;
}
pre code { padding: 0; border-radius: 0; }

a { color: var(--dc-700); }
a:hover { text-decoration: underline; }

/* One Cobalt Rule: the same ring on everything focusable, in every theme. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
}

/* ---- Button ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: var(--fw-medium);
  font-variation-settings: 'wdth' 106;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  background: var(--primary);
  color: var(--primary-foreground);
  transition: background-color .12s ease, opacity .12s ease, color .12s ease;
}
.btn:hover { background: color-mix(in srgb, var(--primary) 90%, transparent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm  { height: 32px; padding: 0 12px; }
.btn-lg  { height: 40px; padding: 0 24px; }
.btn-icon    { width: 36px; padding: 0; }
.btn-icon-sm { width: 32px; height: 32px; padding: 0; }

.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover { background: color-mix(in srgb, var(--secondary) 80%, transparent); }

.btn-outline {
  background: var(--background);
  color: var(--foreground);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover { background: var(--accent); color: var(--accent-foreground); }

.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover { background: color-mix(in srgb, var(--secondary) 45%, transparent); }

.btn-destructive { background: var(--destructive); color: var(--background); }
.btn-destructive:hover { background: color-mix(in srgb, var(--destructive) 90%, transparent); }

/* ---- Input / Select / Textarea ---- */
.input, .select, .textarea {
  height: 36px;
  padding: 4px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--input);
  background: transparent;
  color: var(--foreground);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: var(--fw-normal);
  font-variation-settings: 'wdth' 106;
  box-shadow: var(--shadow-xs);
  width: 100%;
}
.textarea { height: auto; padding: 8px 12px; line-height: 1.5; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted-foreground); }
.input:disabled, .textarea:disabled, .select:disabled { opacity: .5; cursor: not-allowed; }
.input[aria-invalid='true'], .textarea[aria-invalid='true'] {
  border-color: var(--destructive);
  box-shadow: 0 0 0 3px var(--alert-alpha-20);
}
.select {
  appearance: none;
  cursor: pointer;
  padding-right: 30px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
}
input[type='range'] { accent-color: var(--primary); }

/* ---- Card ---- */
.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card + .card { margin-top: 24px; }

/* ---- Badge / chip ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border-radius: var(--radius-sm);
  padding: .15rem .45rem;
  background: var(--muted);
  color: var(--foreground);
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: var(--fw-medium);
  line-height: 1.4;
  letter-spacing: 0.01em;
}
.badge-success { background: var(--primary-150); color: var(--primary-900); }
.badge-destructive { background: var(--alert-150); color: var(--alert-900); }
.badge-warning { background: var(--featured-150); color: var(--featured-900); }
.badge-info { background: var(--dc-150); color: var(--dc-900); }

/* ---- Separator ---- */
.sep { height: 1px; background: var(--border); border: 0; margin: 0; }

/* Motion: transform and opacity only, and clamped when asked. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Tabs ----
   shadcn new-york: a tinted track holding the triggers, with the active one
   lifted onto the card surface. */
.tabs-list {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--muted);
  border-radius: var(--radius-md);
}
.tabs-trigger {
  border: 0;
  background: transparent;
  color: var(--muted-foreground);
  padding: .3rem .8rem;
  border-radius: calc(var(--radius-md) - 3px);
  font-family: inherit;
  font-size: .78rem;
  font-weight: var(--fw-medium);
  font-variation-settings: 'wdth' 106;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s ease, background-color .12s ease;
}
.tabs-trigger:hover { color: var(--foreground); }
.tabs-trigger.on {
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}

/* ---- Dropdown ----
   A genuinely floating surface, so shadow-md is the right elevation here
   rather than a smell. */
.dropdown { position: relative; display: inline-flex; }
.dropdown-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  padding: .9rem 1rem;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.dropdown-panel.right { left: auto; right: 0; }
.dropdown-panel h3 {
  font-size: .64rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted-foreground);
  font-weight: var(--fw-medium);
  margin-bottom: .6rem;
}
.dropdown .chev { transition: transform .12s ease; }
.dropdown [aria-expanded='true'] .chev { transform: rotate(180deg); }

/* ---- Alert ---- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .7rem .85rem;
  background: var(--muted);
  color: var(--foreground);
  font-size: 0.875rem;
}
.alert-destructive {
  background: var(--alert-150);
  border-color: color-mix(in srgb, var(--destructive) 35%, transparent);
  color: var(--alert-900);
}
.alert-destructive .alert-icon { color: var(--destructive); }
.alert-icon { margin-top: .1rem; }

/* ---- Field ---- */
.field { display: grid; gap: .35rem; }
.field > label {
  font-size: 0.75rem;
  font-weight: var(--fw-medium);
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: var(--foreground);
}
.field-hint { font-size: 0.75rem; color: var(--muted-foreground); }

/* ---- Spinner ---- */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
