/* ════════════════════════════════════════════════
   base.css — tokens, reset, typography
   Fonts loaded via <link rel="preload"> in index.html
   ════════════════════════════════════════════════ */

/* ─── TOKENS ─── */
:root {
  /* Palette */
  --ink:          #0E0C0A;
  --ink-2:        #2A2520;
  --ink-3:        #4A4540;
  --paper:        #F4F0E8;
  --paper-2:      #EDE8DF;
  --paper-3:      #E4DED3;
  --paper-4:      #D8D2C7;
  --accent:       #B83228;
  --accent-2:     #8C2520;
  --accent-dim:   rgba(184, 50, 40, 0.07);
  --accent-glow:  rgba(184, 50, 40, 0.15);
  --stamp-blue:   #1B4B8A;
  --stamp-dim:    rgba(27, 75, 138, 0.07);
  --rule:         #C8C2B6;
  --rule-dark:    #A09890;
  --muted:        #7A7368;
  --muted-2:      #9E9890;
  --success:      #2D6A4F;
  --error:        #B83228;

  /* Typography */
  --font-serif:  'Libre Baskerville', Georgia, 'Times New Roman', serif;
  --font-sans:   'Outfit', 'Inter', system-ui, sans-serif;
  --font-mono:   'Courier Prime', 'Courier New', monospace;

  /* Spacing scale */
  --sp-1:   4px;
  --sp-2:   8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-20: 80px;
  --sp-24: 96px;
  --sp-32: 128px;

  /* Transitions */
  --ease:        cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast:  0.15s;
  --t-base:  0.25s;
  --t-slow:  0.4s;
  --t-page:  0.6s;

  /* Z-index scale */
  --z-base:    1;
  --z-above:   10;
  --z-drawer:  200;
  --z-overlay: 190;
  --z-nav:     100;
  --z-cursor:  9999;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
  overflow-x: hidden;
  cursor: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
ul, ol { list-style: none; }
input, textarea, select { font-family: inherit; }
textarea { resize: vertical; }

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

/* Scrollbar */
::-webkit-scrollbar         { width: 5px; height: 5px; }
::-webkit-scrollbar-track   { background: var(--paper-2); }
::-webkit-scrollbar-thumb   { background: var(--rule-dark); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── PAPER TEXTURE ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.032'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ─── SCREEN READER ONLY ─── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

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

/* ─── Mobile: restore default cursor for touch devices ─── */
@media (pointer: coarse) {
  body { cursor: auto; }
  #cursor-dot, #cursor-ring { display: none; }
}
