/* ============================================================
   base.css
   Reset, root tokens, typography, and global element styles.
   All colour values reference CSS custom properties defined
   in theme-dark.css (default) or theme-light.css.
   ============================================================ */

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

/* ── Root design tokens (structural — not colours) ── */
:root {
  --radius-sm:  6px;
  --radius:     12px;
  --radius-lg:  18px;
  --radius-pill: 100px;

  --shadow-sm:  0 2px 8px  rgba(0, 0, 0, 0.25);
  --shadow-md:  0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg:  0 8px 48px rgba(0, 0, 0, 0.45);

  --transition: 0.18s ease;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont,
               'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code',
               ui-monospace, 'Courier New', monospace;

  /* Accent palette — same across both themes */
  --accent:      #6c63ff;
  --accent-mid:  #9d97ff;
  --accent-light: rgba(108, 99, 255, 0.15);
  --accent-ring:  rgba(108, 99, 255, 0.25);

  --green:       #22c55e;
  --green-bg:    rgba(34, 197, 94, 0.15);
  --orange:      #f59e0b;
  --orange-bg:   rgba(245, 158, 11, 0.15);
  --red:         #ef4444;
  --red-bg:      rgba(239, 68, 68, 0.15);

  /* Ring geometry */
  --ring-size:   96px;
  --ring-stroke: 8;
  --ring-circ:   251.2;   /* 2 * π * (96/2 - 8/2) ≈ 251.2 */
}

/* ── HTML / Body ── */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  transition:
    background var(--transition),
    color var(--transition);
}

/* ── Typography scale ── */
h1, h2, h3, h4 {
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.025em;
}

h1 { font-size: clamp(28px, 5vw, 46px); }
h2 { font-size: 22px; }
h3 { font-size: 15px; }

p { color: var(--color-muted); }

a {
  color: var(--accent-mid);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ── Scrollbar (Webkit) ── */
::-webkit-scrollbar        { width: 5px; height: 5px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  {
  background: var(--color-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--color-muted); }

/* ── Focus ring ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ── SVG icon helper ── */
.icon {
  display: inline-block;
  width:  1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  vertical-align: middle;
}

.icon-sm { width: 13px; height: 13px; }
.icon-md { width: 16px; height: 16px; }
.icon-lg { width: 20px; height: 20px; }

/* ── Spinner animation ── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── Tooltip ── */
[data-tip] {
  position: relative;
  cursor: help;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 100;
}

[data-tip]:hover::after { opacity: 1; }

/* ── Utility: visually hidden ── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
