/* Parchment theme: loaded after style.css and overrides it.
   Paper grain and mottling are small SVG tiles that the browser rasterises once,
   so there are no image downloads and nothing is recalculated while scrolling. */

:root {
  --bg: #e6d5b0;
  --surface: #f4e8cc;
  --surface-2: #eadbb8;
  --text: #3a2817;
  --muted: #74603f;
  --border: #d1bb8e;
  --accent: #9e2f1f;          /* wax-seal red */
  --accent-ink: #fbefd8;
  --ok: #55703a;
  --err: #a3301f;
  --gold: #a9791f;
  --serif: 'IM Fell English', 'Amiri', Georgia, serif;
  --book: 'EB Garamond', 'Amiri', Georgia, serif;
  --script: 'Pinyon Script', 'Snell Roundhand', cursive;
  --caps: 'Cinzel', Georgia, serif;
  --shadow: 0 1px 2px rgba(70, 45, 15, .14), 0 8px 22px rgba(70, 45, 15, .12);
  --edge: rgba(130, 90, 35, .2);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .29 0 0 0 0 .12 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --mottle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='640'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .38 0 0 0 0 .15 0 0 0 .16 -.03'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    /* candlelit: dark aged paper, warm ink */
    --bg: #18120c;
    --surface: #261c13;
    --surface-2: #31251a;
    --text: #eedfc1;
    --muted: #b49f7b;
    --border: #4b3a27;
    --accent: #d2714e;
    --accent-ink: #1a110a;
    --ok: #9cba7f;
    --err: #ef8f7c;
    --gold: #d9ae55;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 26px rgba(0, 0, 0, .35);
    --edge: rgba(0, 0, 0, .35);
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .95 0 0 0 0 .8 0 0 0 0 .55 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    --mottle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='640'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .9 0 0 0 0 .65 0 0 0 0 .3 0 0 0 .08 -.02'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");
  }
}

/* ── paper ──────────────────────────────────────────────── */
body {
  background:
    var(--grain),
    var(--mottle),
    radial-gradient(ellipse at 50% 20%, transparent 45%, var(--edge) 100%),
    var(--bg);
  font-family: var(--book);
  font-size: 17px;
}
.card, dialog.privacy {
  background:
    var(--grain),
    radial-gradient(ellipse at 50% 50%, transparent 58%, var(--edge) 100%),
    var(--surface);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: 6px;
}

/* ── type ───────────────────────────────────────────────── */
.brand-name { font-family: var(--serif); font-weight: 400; }
.brand-sub { font-family: var(--caps); letter-spacing: .16em; color: var(--accent); }
.hero h1 { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; }
.hero h1 em {
  font-family: var(--script); font-style: normal; font-size: 1.32em; line-height: 1.05;
  color: var(--accent); display: inline-block; margin-top: .05em;
}
.hero p { font-size: 18px; color: var(--muted); }
.step-body h2, .story-head h2, .analysis h2, .privacy h2 { font-family: var(--serif); font-weight: 400; }
.step-num {
  font-family: var(--caps); font-weight: 600; font-size: 64px; color: var(--gold);
  text-shadow: 0 1px 0 rgba(255, 240, 200, .5);
}
@media (prefers-color-scheme: dark) { .step-num { text-shadow: none; } }
.step.done .step-num { color: var(--ok); }
.placeholder { font-family: var(--book); }

/* controls stay in a clean sans so they read as clickable */
.btn, .tab, select, input[type=text], input[type=number], .field, .note, .hint, .estimate, .privacy-note,
.steps, .detail, .cost, .chips, .char, .timeline, .dialogue, .privacy-list, .privacy .small, .rec-timer, .drop {
  font-family: var(--sans);
}
.step-body > p:not(.note):not(.hint):not(.estimate):not(.privacy-note), .privacy .lead { font-size: 17px; }

select, input[type=text], input[type=number] {
  background: color-mix(in srgb, var(--surface) 55%, #fffaf0 45%);
  border-color: var(--border);
}
@media (prefers-color-scheme: dark) {
  select, input[type=text], input[type=number] { background: color-mix(in srgb, var(--surface-2) 80%, #000 20%); }
}

/* wax-seal buttons */
.btn.primary {
  font-family: var(--caps); font-weight: 600; letter-spacing: .06em;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 80%, #fff 20%), var(--accent) 55%, color-mix(in srgb, var(--accent) 75%, #000 25%));
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18), 0 1px 3px rgba(60, 20, 10, .3);
}
.btn.primary.big { font-size: 17px; padding: 15px; }
.btn:not(.primary):not(.link) { background: color-mix(in srgb, var(--surface-2) 85%, #fff 15%); }
.tabs { background: color-mix(in srgb, var(--surface-2) 90%, #000 4%); }
.tab.active { background: var(--surface); }

/* flourish between the steps */
.steps-list > .step { position: relative; }
.steps-list > .step + .step { margin-top: 40px; }
.steps-list > .step + .step::before {
  content: '❦'; position: absolute; top: -36px; left: 0; right: 0; text-align: center;
  font-family: var(--serif); font-size: 22px; line-height: 30px; color: var(--gold); opacity: .8;
  background: linear-gradient(to right, transparent 20%, color-mix(in srgb, var(--gold) 45%, transparent) 40%, transparent 47%, transparent 53%, color-mix(in srgb, var(--gold) 45%, transparent) 60%, transparent 80%) center / 100% 1px no-repeat;
}

/* ── the story scroll ───────────────────────────────────── */
.story.scroll {
  position: relative; padding: 20px 0; background: none; border: none; box-shadow: none; border-radius: 0;
}
.story.scroll::before, .story.scroll::after {
  content: ''; position: absolute; left: 0; right: 0; height: 26px; border-radius: 13px; z-index: 2;
  background: linear-gradient(to bottom, #9c7e50 0%, #e9d7ae 32%, #f6ead0 45%, #d8c194 68%, #84663d 100%);
  box-shadow: 0 3px 7px rgba(60, 40, 15, .35);
}
.story.scroll::before { top: 0; }
.story.scroll::after { bottom: 0; }
@media (prefers-color-scheme: dark) {
  .story.scroll::before, .story.scroll::after {
    background: linear-gradient(to bottom, #3a2b1b 0%, #6d5434 32%, #84694a 45%, #5d4730 68%, #2a1f14 100%);
  }
}
.story .sheet {
  margin: 0 14px; padding: 30px 32px 34px;
  background:
    var(--grain),
    radial-gradient(ellipse at 50% 50%, transparent 60%, var(--edge) 100%),
    var(--surface);
  /* the paper curls into the rollers at top and bottom */
  box-shadow: inset 0 16px 14px -12px rgba(80, 55, 20, .38), inset 0 -16px 14px -12px rgba(80, 55, 20, .38), var(--shadow);
}
.story-head h2 { font-size: 34px; }
.story-body { font-family: var(--book); font-size: 21px; line-height: 1.65; color: var(--text); }
.story-body.screenplay { font-family: 'Courier New', monospace; font-size: 15px; }
.story-body.verse { font-style: italic; }
/* illuminated first letter */
.story-body:not(.verse):not(.screenplay):not(.rtl) > p:first-of-type::first-letter {
  float: left; font-family: var(--serif); font-size: 3.6em; line-height: .82; padding: 6px 10px 0 0;
  color: var(--gold); text-shadow: 1px 1px 0 color-mix(in srgb, var(--accent) 35%, transparent);
}

/* unroll once when the story first appears */
.story.unroll { max-height: 96px; overflow: hidden; animation: unroll 1.6s cubic-bezier(.25, .7, .3, 1) .1s forwards; }
@keyframes unroll { to { max-height: 1800px; } }
@media (prefers-reduced-motion: reduce) { .story.unroll { animation: none; max-height: none; } }

@media (max-width: 560px) {
  .step-num { font-size: 46px; }
  .story .sheet { margin: 0 8px; padding: 24px 18px 26px; }
  .story-body { font-size: 19px; }
  .hero h1 em { font-size: 1.25em; }
}

/* finished steps get a wax-seal tick instead of a modern green one */
.step.done .step-num { color: var(--gold); }
.step.done .step-num::after {
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 75%, #fff 25%), var(--accent) 60%, color-mix(in srgb, var(--accent) 70%, #000 30%));
  color: var(--accent-ink); box-shadow: 0 1px 2px rgba(60, 20, 10, .35);
}
.dot { background: var(--gold); }

/* right-to-left stories (Arabic and similar): right-aligned and set in Amiri.
   Joined letters can't be pulled apart for a drop cap, so the first paragraph
   opens with a printer's ornament block (gold frame, quill and flourish) instead. */
.story-body.rtl { line-height: 1.95; }
.story-body.rtl.verse { font-style: normal; }
.sheet[dir="rtl"] .story-head h2 { font-size: 36px; }
.story-body.rtl:not(.verse):not(.screenplay) > p:first-of-type::before {
  content: ''; float: right; width: 3.4em; height: 3.4em; margin: .35em 0 .1em .7em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23a9791f'%3E%3Crect x='2' y='2' width='60' height='60' rx='2' stroke-width='2'/%3E%3Crect x='7' y='7' width='50' height='50' rx='1.5' stroke-width='.8'/%3E%3Cpath d='M15 49 C21 44 27 52 33 47 C37 44 40 47 42 49' stroke-width='1' stroke-linecap='round'/%3E%3Cpath d='M20 50 L45.5 13' stroke='%238a5f17' stroke-width='1.2' stroke-linecap='round'/%3E%3C/g%3E%3Cg fill='%23a9791f'%3E%3Ccircle cx='11.5' cy='11.5' r='1.4'/%3E%3Ccircle cx='52.5' cy='11.5' r='1.4'/%3E%3Ccircle cx='11.5' cy='52.5' r='1.4'/%3E%3Ccircle cx='52.5' cy='52.5' r='1.4'/%3E%3Cpath d='M29.5 37 C25 27 32.5 16.5 46.5 11.5 C47 22 41.5 31.5 31.5 38.5 Z' fill='%23d4a646' stroke='%238a5f17' stroke-width='.7'/%3E%3Cpath d='M19.2 51.6 L21.4 48.4 L22.2 49 Z' fill='%233a2817'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

/* the AI's notes can be in any language: each line takes its own direction */
#a-setting, .chips li, .char, .timeline li, .dialogue .line { unicode-bidi: plaintext; text-align: start; }
