/* ─── DTS base.css ───────────────────────────────────────────────────
   Design tokens, reset, typography, and shared primitives.
   Source of truth: prat inputs/design_direction_DTSUI.md
   ──────────────────────────────────────────────────────────────────── */

/* ── Font faces ─────────────────────────────────────────────────── */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/Inter-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/Inter-Medium.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/Inter-SemiBold.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/JetBrainsMono-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/JetBrainsMono-Medium.woff2') format('woff2');
}

/* ── Design tokens ──────────────────────────────────────────────── */

:root {
  /* Colors — core */
  --background: #0A0A0A;
  --background-subtle: #111111;
  --background-inset: #000000;

  --foreground: #F5F5F5;
  --foreground-secondary: rgba(245, 245, 245, 0.7);
  --foreground-muted: rgba(245, 245, 245, 0.45);
  --foreground-faint: rgba(245, 245, 245, 0.25);

  /* Colors — semantic (the accent system) */
  --semantic-ok: #3FB950;
  --semantic-warn: #D29922;
  --semantic-fail: #F85149;
  --semantic-info: #58A6FF;

  --semantic-ok-muted: rgba(63, 185, 80, 0.12);
  --semantic-warn-muted: rgba(210, 153, 34, 0.12);
  --semantic-fail-muted: rgba(248, 81, 73, 0.12);
  --semantic-info-muted: rgba(88, 166, 255, 0.12);

  /* Colors — stress heatmap (warm) */
  --stress-0: #3FB950;
  --stress-1: #B7D94C;
  --stress-2: #E8D247;
  --stress-3: #E89547;
  --stress-4: #F85149;

  /* Colors — instrument mode */
  --instrument-bg: #000000;
  --instrument-green: #00FF66;
  --instrument-green-dim: rgba(0, 255, 102, 0.5);
  --instrument-green-faint: rgba(0, 255, 102, 0.2);
  --instrument-glow: 0 0 8px rgba(0, 255, 102, 0.6);

  /* Borders — always alpha-white */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.2);
  --border-active: rgba(255, 255, 255, 0.35);
  --border-selected: #58A6FF;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Layout */
  --content-max-width: 1280px;
  --content-max-width-narrow: 720px;
  --content-padding: 24px;
  --panel-padding: 20px;
  --input-padding-y: 10px;
  --input-padding-x: 14px;

  /* Radius */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 9999px;

  /* Motion */
  --transition-fast: 120ms ease-out;
  --transition-medium: 200ms ease-out;
  --transition-slow: 400ms ease-out;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
}

/* ── Reset ──────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--background);
  color: var(--foreground-secondary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input, textarea, select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

textarea {
  resize: vertical;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Tabular numerals anywhere numbers appear in columns */
.num, [data-num] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* ── Nav ────────────────────────────────────────────────────────── */

.nav {
  position: sticky;
  top: 0;
  height: 48px;
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 50;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  padding: 0 var(--content-padding);
}

.nav__inner {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__brand {
  color: var(--foreground);
  letter-spacing: -0.01em;
}

.nav__brand-sub {
  color: var(--foreground-muted);
  margin-left: var(--space-2);
}

.nav__links {
  display: flex;
  gap: var(--space-5);
}

.nav__link {
  color: var(--foreground-muted);
  transition: color var(--transition-fast);
}

.nav__link:hover {
  color: var(--foreground);
}

/* ── Panel ──────────────────────────────────────────────────────── */

.panel {
  background: var(--background-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--panel-padding);
  min-height: 88px;
}

.panel__header {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--foreground-muted);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* ── Pills ──────────────────────────────────────────────────────── */

.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
}

.pill--ok    { background: var(--semantic-ok-muted);   color: var(--semantic-ok); }
.pill--warn  { background: var(--semantic-warn-muted); color: var(--semantic-warn); }
.pill--fail  { background: var(--semantic-fail-muted); color: var(--semantic-fail); }
.pill--info  { background: var(--semantic-info-muted); color: var(--semantic-info); }
.pill--muted { background: rgba(255,255,255,0.06);     color: var(--foreground-muted); }

/* ── Buttons ────────────────────────────────────────────────────── */

.btn {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.btn--primary {
  background: var(--foreground);
  color: var(--background);
  border-color: var(--foreground);
}

.btn--primary:hover {
  background: #ffffff;
}

.btn--secondary {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border-default);
}

.btn--secondary:hover {
  border-color: var(--border-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--foreground-secondary);
  border: none;
  padding: 8px 12px;
}

.btn--ghost:hover {
  color: var(--foreground);
}

.btn__hint {
  font-size: 11px;
  color: var(--foreground-muted);
  font-family: var(--font-mono);
}

.btn--primary .btn__hint {
  color: rgba(10, 10, 10, 0.5);
}

/* ── Toggle group ──────────────────────────────────────────────── */

.toggle-group {
  display: inline-flex;
  background: var(--background-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.toggle-group button {
  background: transparent;
  color: var(--foreground-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-xs);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.toggle-group button[aria-pressed="true"] {
  background: var(--background-subtle);
  color: var(--foreground);
}

/* ── Skeleton shimmer ──────────────────────────────────────────── */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--background-subtle) 0%,
    rgba(255, 255, 255, 0.04) 50%,
    var(--background-subtle) 100%
  );
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
  color: transparent;
  pointer-events: none;
}

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

/* ── Focus ring ─────────────────────────────────────────────────── */

:focus-visible {
  outline: 1px solid var(--border-active);
  outline-offset: 2px;
}

textarea:focus-visible,
input:focus-visible {
  outline: none;
}

/* ── Utilities ─────────────────────────────────────────────────── */

.mono { font-family: var(--font-mono); }
.muted { color: var(--foreground-muted); }
.secondary { color: var(--foreground-secondary); }

.hidden,
[hidden] { display: none !important; }

/* ── Body state swap ───────────────────────────────────────────── */

.dts-landing .view--analysis,
.dts-results .view--landing {
  display: none;
}

/* ── Reduced motion ─────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
