/* ══════════════════════════════════════════════════════════════
   Runi Services dashboard — shared base stylesheet.

   Single source of truth for tokens, reset, and surface primitives
   used across every dashboard page. Each page links this file and
   keeps only its page-specific component styles.

   Token namespace is --rc-* per the runi.services design system.
   Legacy aliases (--fg-*, --bg-*, --runi-*, --font-sans, --radius-*,
   --shadow-soft) are kept as thin wrappers so existing page CSS
   continues to render during migration — new work should reference
   --rc-* directly.
   ══════════════════════════════════════════════════════════════ */

:root {
  /* ── Canonical tokens ─────────────────────────────── */
  --rc-ink: #111214;
  --rc-bg: #F6F3EA;
  --rc-bg-sub: #EFEBDF;
  --rc-accent: #7A1C17;         /* Runestone Red — single accent */
  --rc-navy: #0B1320;           /* Fjord Navy */
  --rc-navy-2: #141D2E;
  --rc-text-2: #2C3138;
  --rc-line: #7A7E86;
  --rc-card: #FFFFFF;
  --rc-success: #3C5A40;        /* Pine Moss */
  --rc-warn: #A1783A;           /* Forged Bronze */

  /* Dashboard status tokens (specs/007-dashboard-v2/design.md) */
  --ok: #3E6B4F;                /* good — muted pine, editorial */
  --warn: #8B6B3F;              /* degraded — the logo-animation gold */
  --bad: #7A1C17;               /* down/urgent — --rc-accent family */

  --rc-font-h: 'Inter', system-ui, sans-serif;
  --rc-font-b: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
  --rc-font-mono: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, monospace;

  --rc-radius: 12px;
  --rc-radius-sm: 2px;
  --rc-radius-pill: 100px;

  --rc-shadow: 0 1px 3px rgba(17,18,20,0.04), 0 4px 12px rgba(17,18,20,0.03);
  --rc-shadow-hover: 0 1px 4px rgba(17,18,20,0.05), 0 4px 16px rgba(17,18,20,0.04);
  --rc-shadow-navy: 0 2px 8px rgba(11,19,32,0.12), 0 8px 32px rgba(11,19,32,0.08);

  /* ── Legacy aliases (migration compat) ─────────────── */
  --bg-canvas: var(--rc-bg);
  --bg-subtle: var(--rc-bg-sub);
  --bg-strong: var(--rc-navy);
  --bg-panel: var(--rc-navy-2);
  --bg-card: var(--rc-card);
  --bg-inset: var(--rc-bg-sub);

  --fg-default: var(--rc-ink);
  --fg-muted: var(--rc-line);
  --fg-dim: var(--rc-line);
  --fg-bright: var(--rc-ink);
  --fg-inverse: #F6F3EA;

  --border-default: rgba(17,18,20,0.08);
  --border-muted: rgba(17,18,20,0.06);
  --border-subtle: rgba(17,18,20,0.04);
  --border-accent: var(--rc-accent);
  --border: rgba(17,18,20,0.08);

  --runi-accent: var(--rc-navy);   /* legacy: --runi-accent was misnamed, it was navy */
  --runi-cta: var(--rc-accent);    /* legacy: --runi-cta is the real accent */
  --runi-success: var(--rc-success);
  --runi-warning: var(--rc-warn);

  --font-sans: var(--rc-font-h);
  --font-body: var(--rc-font-b);
  --font-display: var(--rc-font-h);
  --font-mono: var(--rc-font-mono);

  --radius-sm: var(--rc-radius);
  --radius-md: var(--rc-radius);
  --radius-xs: 6px;
  --radius: var(--rc-radius);

  --shadow-soft: var(--rc-shadow);
  --shadow: var(--rc-shadow);
  --shadow-glow: 0 0 24px rgba(122,28,23,0.15);

  --accent: var(--rc-accent);
  --success: var(--rc-success);
  --warning: var(--rc-warn);
  --error: var(--rc-accent);

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

  --transition: 0.15s ease;
}

[data-theme="dark"] {
  --rc-ink: #F6F3EA;
  --rc-bg: #0B1320;
  --rc-bg-sub: #141D2E;
  --rc-text-2: rgba(246,243,234,0.65);
  --rc-line: rgba(246,243,234,0.55);
  --rc-card: #141D2E;

  --border-default: rgba(255,255,255,0.08);
  --border-muted: rgba(255,255,255,0.06);
  --border-subtle: rgba(255,255,255,0.04);
  --border: rgba(255,255,255,0.08);
}

/* ══════════════════════════════════════════════════════════════
   Reset
   ══════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
img { display: block; max-width: 100%; }

/* ══════════════════════════════════════════════════════════════
   Body & canvas
   ══════════════════════════════════════════════════════════════ */

body {
  font-family: var(--rc-font-h);
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 400;
  color: var(--rc-ink);
  background: var(--rc-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(17,18,20,0.04) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(17,18,20,0.04) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.3), transparent 70%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,0.3), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

[data-theme="dark"] body::before {
  background-image: linear-gradient(rgba(246,243,234,0.04) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(246,243,234,0.04) 1px, transparent 1px);
}

/* ══════════════════════════════════════════════════════════════
   Accessibility primitives
   ══════════════════════════════════════════════════════════════ */

:focus-visible {
  outline: 2px solid var(--rc-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
  .reveal, .fade-in { opacity: 1 !important; transform: none !important; }
}

/* ══════════════════════════════════════════════════════════════
   Reveal animation (shared pattern)
   ══════════════════════════════════════════════════════════════ */

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 500ms cubic-bezier(.2,.65,.2,1),
              transform 500ms cubic-bezier(.2,.65,.2,1);
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }
.reveal-d1 { transition-delay: 60ms; }
.reveal-d2 { transition-delay: 120ms; }
.reveal-d3 { transition-delay: 180ms; }

/* ══════════════════════════════════════════════════════════════
   Theme toggle (shared button in top-right)
   ══════════════════════════════════════════════════════════════ */

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(17,18,20,0.08);
  color: var(--rc-ink);
  font-family: var(--rc-font-h);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.15s ease, border-color 0.15s ease;
}

[data-theme="dark"] .theme-toggle {
  background: rgba(20,29,46,0.82);
  border-color: rgba(255,255,255,0.08);
}

.theme-toggle:hover { border-color: var(--rc-accent); }
