/* ─────────────────────────────────────────────────────────────
   Enthousiasmes — Commonplace redesign.
   Warm-paper editorial type system. Used by all variations.
   ─────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300..800;1,9..144,300..800&family=JetBrains+Mono:wght@400;500&family=Inter:wght@300;400;500;600&display=swap');

:root {
  /* Light (default) */
  --paper: #f4ede0;
  --paper-2: #ece2d0;
  --card: #fbf5e8;
  --card-2: #f8f1df;
  --ink: #1a1612;
  --ink-soft: #6b5f52;
  --ink-faint: #a79786;
  --line: #d9ccb5;
  --line-soft: #e5dbc6;
  --rubric: #b83a28;       /* vermilion — rubricated */
  --rubric-soft: #e7c8c0;
  --moss: #3d5b4a;
  --indigo: #2d3e6b;
  --gold: #a78339;
  /* lighter accent variants — legible on dark paper */
  --moss-d: #7c9d88;
  --indigo-d: #7488c9;
  --gold-d: #caa75f;

  /* Dark (fallback / alt) */
  --d-paper: #1a1713;
  --d-card: #221d17;
  --d-ink: #ede3d0;
  --d-ink-soft: #9a8e7d;
  --d-line: #3a3227;

  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', -apple-system, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* Dark theme — "reading by oil lamp": warm walnut (not near-black) with a
   glowing vermilion. Remaps the tokens so every component using
   var(--paper/--ink/--card/--line/...) turns dark, instead of the old thin
   per-component fallback. Legacy --d-* kept in step for inline isDark checks. */
body.theme-dark {
  --paper: #211b14;
  --paper-2: #1b1610;
  --card: #2a2219;
  --card-2: #33291e;
  --ink: #ece2d0;
  --ink-soft: #b4a692;
  --ink-faint: #897a64;
  --line: #43392c;
  --line-soft: #362d22;
  --rubric: #e3694f;
  --rubric-soft: #6b3a30;
  --moss: #7c9d88;
  --indigo: #7488c9;
  --gold: #caa75f;
  --d-paper: #211b14;
  --d-card: #2a2219;
  --d-ink: #ece2d0;
  --d-ink-soft: #b4a692;
  --d-line: #43392c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: #2a2520;
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
}

button { font-family: inherit; cursor: pointer; background: none; border: none; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }
a { color: inherit; }

/* ─────────────────────────────────────────────────────────────
   The "paper" surface — a subtle linen/deckle texture.
   ─────────────────────────────────────────────────────────── */
.paper {
  position: relative;
  background: var(--paper);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(184, 58, 40, 0.025), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(61, 91, 74, 0.025), transparent 40%);
}
.paper::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(90deg, rgba(26,22,18,0.012) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(0deg, rgba(26,22,18,0.008) 0 1px, transparent 1px 2px);
  pointer-events: none;
  mix-blend-mode: multiply;
}

/* ─────────────────────────────────────────────────────────────
   Typography primitives
   ─────────────────────────────────────────────────────────── */
.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
}
.folio {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.serif-display {
  font-family: var(--serif);
  font-weight: 400;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  letter-spacing: -0.015em;
  line-height: 1;
  font-variant-numeric: oldstyle-nums;   /* old-style figures in titles (1Q84, No. 5, 1857) */
}
.serif-ital {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "opsz" 144;
  font-variant-numeric: oldstyle-nums;
  hanging-punctuation: first;            /* opening quote/bracket hangs into the margin (Safari/iOS) */
}
.rubric { color: var(--rubric); }
.moss   { color: var(--moss); }
.indigo { color: var(--indigo); }

/* Per-category mark accents — quiet tonal signatures on CategoryMark.
   Single-class so they override .eyebrow by source order; dark variants
   below win on specificity. */
.cat-accent            { color: var(--ink-soft); }
.cat-accent--rubric    { color: var(--rubric); }
.cat-accent--moss      { color: var(--moss); }
.cat-accent--indigo    { color: var(--indigo); }
.cat-accent--gold      { color: var(--gold); }
body.theme-dark .cat-accent           { color: var(--d-ink-soft); }
body.theme-dark .cat-accent--rubric   { color: var(--rubric); }
body.theme-dark .cat-accent--moss     { color: var(--moss-d); }
body.theme-dark .cat-accent--indigo   { color: var(--indigo-d); }
body.theme-dark .cat-accent--gold     { color: var(--gold-d); }

/* Drop cap helper used by big quotes */
.dropcap::first-letter {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 3.4em;
  line-height: 0.85;
  float: left;
  padding: 0.08em 0.08em 0 0;
  color: var(--rubric);
}

/* Pressed card */
.card-paper {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(26,22,18,0.04),
    inset 0 0 0 0.5px rgba(217, 204, 181, 0.5);
}

/* Divider flourish */
.flourish {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-faint);
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  margin: 18px 0;
}
.flourish::before, .flourish::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

/* Hide scrollbar inside phone */
.phone-scroll::-webkit-scrollbar { width: 0; height: 0; }
.phone-scroll { scrollbar-width: none; }

/* Tweaks panel */
.tweaks-panel {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 280px;
  background: rgba(255, 251, 242, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(217, 204, 181, 0.8);
  border-radius: 6px;
  padding: 20px 18px 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  z-index: 1000;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.tweaks-panel h3 {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 12px;
  font-weight: 500;
}
.tweaks-panel .tweak-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.tweaks-panel label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.tweaks-panel .tweak-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tweaks-panel .tweak-opt {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 100px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  transition: all .15s;
}
.tweaks-panel .tweak-opt.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.tweaks-panel .close {
  position: absolute;
  top: 12px; right: 14px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
}

/* ─────────────────────────────────────────────────────────────
   Print — a clean "bound volume" PDF (Print → Save as PDF).
   Force the light palette, drop all chrome, flow entries full-width.
   ─────────────────────────────────────────────────────────── */
@media print {
  :root, body.theme-dark {
    --paper: #fff; --paper-2: #fff; --card: #fff; --card-2: #fff;
    --ink: #1a1612; --ink-soft: #5a5045; --ink-faint: #8a7c6a;
    --line: #cdbfa6; --line-soft: #e2d8c2; --rubric: #b83a28;
  }
  html, body { background: #fff !important; padding: 0 !important; display: block !important; }
  .no-print, .tab-bar, .tweaks-panel { display: none !important; }
  .app-shell, .paper { max-width: none !important; width: auto !important; box-shadow: none !important; border: none !important; background: #fff !important; }
  .paper::before { display: none !important; }
  section button, article { break-inside: avoid; page-break-inside: avoid; }
}
