/* ─────────────────────────────────────────────────────────────
   TinyDocx — Design Tokens
   "Every rule has a place. Every decision has a path."

   A warm literary library. Paper + ink, brass ornaments,
   marginalia in IM Fell English, typewriter labels in Special
   Elite, and a six-volume color set lifted directly from the
   book spines on the shelf.
   ───────────────────────────────────────────────────────────── */

@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=IM+Fell+English:ital@0;1&family=Special+Elite&family=JetBrains+Mono:wght@400;500&family=Dancing+Script:wght@500&display=swap");

:root {
  /* ───────── Paper + Ink ───────── */
  --paper:      #f4ead3;   /* default page — old paper, warm cream */
  --paper-deep: #ebdfc2;   /* one step deeper — page-fold shadow */
  --paper-soft: #faf3e0;   /* softest — cards, library checkout slips */
  --ink:        #221810;   /* primary ink — text, buttons */
  --ink-soft:   #3e2e20;   /* body alt — body in lower-emphasis blocks */
  --ink-muted:  #6b5742;   /* tertiary — captions, marginalia, hints */
  --rule:       #c9b998;   /* hairlines, table rules, dashed divides */

  /* ───────── The Six Book Spines ─────────
     Each is the cover color of a Big Book on the shelf.
     Use as section accents, not as primary surface color. */
  --medicare-green: #4a5a3d;  /* Medicare — moss / forest binding */
  --memory-purple:  #6a4e6e;  /* MemoryBook — dusty plum */
  --json-blue:      #5d7a92;  /* JSONs — slate library blue */
  --academy-cream:  #d9c79a;  /* Academy — uncoated buckram cream */
  --mascot-silver:  #c9c3b8;  /* TinyDocx mascot — paper grey */
  --ai-navy:        #1f2a48;  /* AI Etiquette — midnight navy */

  /* ───────── Brass + accent system ───────── */
  --brass:       #b88a2e;   /* lamp brass, drop-cap, ornament glow */
  --brass-deep:  #8c6420;   /* button-hover, chapter numerals */
  --oxblood:     #8a3a2a;   /* stamps, footnote markers, "due dates" */
  --forest:      #3a4a3a;   /* secondary serious accent */
  --sunbeam:     #f6d88a;   /* the golden door, selection highlight */
  --sun-glow:    #fae5a8;   /* sunbeam falloff, dust mote core */

  /* Semantic re-exposes — match codebase usage */
  --bg:        var(--paper);
  --fg:        var(--ink);
  --fg-soft:   var(--ink-soft);
  --fg-muted:  var(--ink-muted);
  --accent:    var(--brass-deep);
  --danger:    var(--oxblood);
  --success:   var(--forest);

  /* ───────── Type families ───────── */
  --font-display:    "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --font-body:       "EB Garamond", Georgia, serif;
  --font-marginalia: "IM Fell English", "EB Garamond", Georgia, serif;
  --font-typewriter: "Special Elite", "Courier New", monospace;
  --font-mono:       "JetBrains Mono", ui-monospace, monospace;
  --font-script:     "Dancing Script", "Cormorant Garamond", cursive;

  /* ───────── Type scale (rem-anchored, 18px body) ───────── */
  --fs-display-xl: clamp(48px, 7.2vw, 108px);  /* hero */
  --fs-display-lg: clamp(34px, 4.6vw, 58px);   /* section title */
  --fs-display:    clamp(28px, 3.6vw, 44px);   /* sub-section */
  --fs-h2:         32px;
  --fs-h3:         24px;
  --fs-h4:         22px;
  --fs-body:       18px;     /* default */
  --fs-body-sm:    15px;     /* card body, caption text */
  --fs-label:      11px;     /* uppercase tracked label */
  --fs-mono-sm:    12px;
  --fs-script:     30px;

  /* ───────── Letter-spacing ───────── */
  --tracking-display: -0.01em;  /* tight on serif headlines */
  --tracking-label:    0.18em;  /* very open on uppercase labels */
  --tracking-chapter:  0.22em;  /* "Chapter Three" tracking */

  /* ───────── Spacing scale (loose, generous) ───────── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  48px;
  --space-8:  64px;
  --space-9:  96px;
  --section-pad-default: 110px;
  --section-pad-airy:    140px;
  --section-pad-snug:    80px;

  /* ───────── Borders + radii ─────────
     Library aesthetic: things are almost square. Radii are
     small (0–4px). Big rounding looks foreign. */
  --radius-sharp:   0;     /* book spines, labels */
  --radius-card:    2px;   /* checkout card */
  --radius-soft:    3px;   /* hardcover corner */
  --radius-pill:    999px; /* dust motes, knobs */
  --border-rule:    1px solid var(--rule);
  --border-dashed:  1px dashed var(--rule);
  --border-double:  2px double var(--brass-deep);   /* bookplate */

  /* ───────── Shadows + elevation ───────── */
  --shadow-card:    0 8px 20px -12px rgba(40, 28, 14, .20);
  --shadow-book:    0 14px 30px -14px rgba(40, 28, 14, .35);
  --shadow-shelf:   0 24px 50px -18px rgba(40, 28, 14, .50), 0 2px 0 rgba(0, 0, 0, .10);
  --shadow-hero:    0 40px 80px -30px rgba(40, 28, 14, .35);
  --shadow-press:   inset 0 2px 6px rgba(40, 28, 14, .30);
  --inset-page:     inset 0 0 60px rgba(40, 28, 14, .06);

  /* ───────── Motion ───────── */
  --ease-slow:  cubic-bezier(.2, .7, .2, 1);
  --ease-out:   cubic-bezier(.16, 1, .3, 1);
  --dur-fast:   .22s;
  --dur-base:   .35s;
  --dur-slow:   .55s;
  --dur-page:   .8s;

  /* ───────── Backgrounds ───────── */
  --bg-page-gradient:
    radial-gradient(ellipse 1200px 600px at 20% -10%, rgba(250, 229, 168, .55), transparent 60%),
    radial-gradient(ellipse 800px 500px at 85% 8%, rgba(246, 216, 138, .32), transparent 65%);
  --bg-noise:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .13  0 0 0 0 .09  0 0 0 0 .04  0 0 0 .06 0'/></filter><rect width='260' height='260' filter='url(%23n)'/></svg>");
}

/* Palette themes (toggle via body class) */
body.theme-deep { --paper: #ead6a8; --paper-deep: #d9c290; --paper-soft: #f1e2b8; }
body.theme-cool { --paper: #e8e4d0; --paper-deep: #d6d1ba; --paper-soft: #f2eedc; --sunbeam: #d8e3c4; --sun-glow: #e9f0d8; }

/* ─────────────────────────────────────────────────────────────
   SEMANTIC TYPE — drop-in classes / element styles
   ───────────────────────────────────────────────────────────── */

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image: var(--bg-page-gradient), var(--bg-noise);
  background-blend-mode: multiply, normal, multiply;
}

::selection { background: var(--sunbeam); color: var(--ink); }

/* Display headlines — Cormorant Garamond, medium, tight */
h1, .h1, .display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: var(--tracking-display);
  line-height: 1.02;
  color: var(--ink);
  margin: 0;
}
h1, .h1   { font-size: var(--fs-display-xl); }
h2, .h2   { font-family: var(--font-display); font-weight: 500; font-size: var(--fs-display-lg); letter-spacing: var(--tracking-display); line-height: 1.05; margin: 0; }
h3, .h3   { font-family: var(--font-display); font-weight: 500; font-size: var(--fs-h3); margin: 0; }
h4, .h4   { font-family: var(--font-display); font-weight: 500; font-size: var(--fs-h4); margin: 0; }

p { margin: 0 0 1em; text-wrap: pretty; }

/* Italic serif — used for poetic lines + book titles */
.serif-italic {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
}

/* Marginalia — old book hand, italic, muted */
.marginalia, em.marginalia {
  font-family: var(--font-marginalia);
  font-style: italic;
  color: var(--ink-muted);
}

/* Typewriter — call numbers, due dates, library stamps */
.typewriter {
  font-family: var(--font-typewriter);
  letter-spacing: .02em;
}

/* Code / system tokens — JetBrains Mono */
code, kbd, .mono {
  font-family: var(--font-mono);
  font-size: var(--fs-mono-sm);
}

/* Uppercase tracked label — section eyebrows, form labels */
.label {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Chapter number — italic small caps in brass */
.chapter-no {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 13px;
  letter-spacing: var(--tracking-chapter);
  text-transform: uppercase;
  color: var(--brass-deep);
}

/* Drop cap — leads founder notes, forewords */
.drop-cap::first-letter {
  font-family: var(--font-display);
  font-size: 78px;
  line-height: .85;
  float: left;
  padding: 8px 10px 0 0;
  color: var(--brass-deep);
  font-weight: 500;
}

/* Signature — Dancing Script, the founder's hand */
.signature {
  font-family: var(--font-script);
  font-style: italic;
  font-weight: 500;
  font-size: var(--fs-script);
  color: var(--ink);
}

/* Footnote markers — small superscript in oxblood mono */
sup.fn {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--oxblood);
  padding-left: 2px;
  cursor: help;
  vertical-align: super;
}
