/* ============================================================
   Fit Notebook — tokens.css
   Primitive, theme-independent design tokens (DESIGN_SYSTEM §1.3).
   Rule: no color literals in module CSS — colors live only here
   (neutrals used by primitives) and in themes/*.css.
   ============================================================ */

@font-face {
  font-family: 'Manrope';
  src: url('../vendor/fonts/manrope/Manrope-Variable.ttf') format('truetype-variations');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Spacing scale (px values via rem where 1rem = 16px) */
  --space-1: 4px;   --space-2: 8px;   --space-3: 12px;  --space-4: 16px;
  --space-5: 20px;  --space-6: 24px;  --space-7: 32px;  --space-8: 40px;
  --space-9: 48px;  --space-10: 64px; --space-11: 80px; --space-12: 96px;

  /* Radii — soft, friendly wellness posture */
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px;
  --radius-xl: 24px; --radius-full: 999px;

  /* Fluid type scale */
  --fs-xs: clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: clamp(1.25rem, 1.2rem + 0.25vw, 1.375rem);
  --fs-2xl: clamp(1.5rem, 1.35rem + 0.7vw, 1.75rem);
  --fs-3xl: clamp(1.875rem, 1.6rem + 1.2vw, 2.25rem);
  --fs-display: clamp(2.25rem, 1.8rem + 2vw, 3rem);
  --lh-heading: 1.2;
  --lh-body: 1.55;

  /* Fonts: system body for zero-download speed; Manrope display
     (variable, OFL, vendored — DECISION_LOG D-13/D-26) for headings,
     numbers, wordmark. */
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Manrope', var(--font-body);

  /* Motion */
  --dur-fast: 120ms; --dur-base: 200ms; --dur-slow: 320ms;
  --ease: cubic-bezier(.2, .8, .2, 1);

  /* Z-index scale */
  --z-nav: 40; --z-dropdown: 50; --z-overlay: 60; --z-dialog: 70; --z-toast: 80;

  /* Elevation (alpha tuned per theme via --shadow-color) */
  --shadow-1: 0 1px 2px rgb(var(--shadow-color) / 0.08),
              0 1px 3px rgb(var(--shadow-color) / 0.06);
  --shadow-2: 0 4px 10px rgb(var(--shadow-color) / 0.10),
              0 2px 4px rgb(var(--shadow-color) / 0.06);
  --shadow-3: 0 12px 28px rgb(var(--shadow-color) / 0.14),
              0 4px 10px rgb(var(--shadow-color) / 0.08);

  /* Layout */
  --content-max: 1200px;
  --sidebar-w: 248px;
  --bottomnav-h: 64px;
  --touch-target: 44px;

  /* Density: user pages comfortable; admin layout sets compact. */
  --density-pad: var(--space-5);
}
[data-density="compact"] { --density-pad: var(--space-3); }

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  background: var(--bg-page);
  color: var(--text-primary);
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: var(--lh-heading);
  margin: 0 0 var(--space-3);
  font-weight: 700;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--space-4); }
a { color: var(--brand-strong); }
a:hover { color: var(--brand); }
img, svg { vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }

.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }

.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }

/* Focus visibility — every interactive element */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Skip link */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--bg-surface); color: var(--text-primary);
  padding: var(--space-3) var(--space-4); z-index: 100;
  border-radius: 0 0 var(--radius-md) 0;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Smooth theme switching */
body, .card, .btn, .site-header, .sidebar, .bottom-nav {
  transition: background-color var(--dur-slow) var(--ease),
              color var(--dur-slow) var(--ease),
              border-color var(--dur-slow) var(--ease);
}

/* Reduced motion: collapse all animation/transition */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
