/* ═══ LEGAL DOC — the shared full-page reader shell ═══ */
:root {
  --doc-hue: 40;
  --doc-rot: 0deg;
  --doc-scale: 1;
}
#field-fx {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
}
/* broken-treaty renders its OWN opaque background inside the canvas
   (the metaball merge requires it) — hide the canvas edge flicker */
body[data-theme="broken-treaty"] #field-fx { opacity: 1; }

.doc-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000;
  background: rgba(255, 255, 255, 0.06);
}
.doc-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--stage-accent, #d4a843), #fff8e8);
  box-shadow: 0 0 10px var(--stage-accent, #d4a843);
  transition: width .1s linear;
}

.doc-header {
  position: sticky; top: 0; z-index: 900;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--stage-bg, #06060f) 88%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--stage-accent, #d4a843) 30%, transparent);
  backdrop-filter: blur(10px);
}
.doc-back { color: var(--stage-accent, #d4a843); text-decoration: none; font-size: 13px; }
.doc-back:hover { text-decoration: underline; }
.doc-header-center { display: flex; gap: 12px; align-items: baseline; }
.doc-cat-chip { font-size: 11px; letter-spacing: .22em; color: var(--stage-accent, #d4a843); }
.doc-number { font-size: 12px; color: var(--stage-ink-dim, #8a8577); }
.doc-tts-btn {
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--stage-accent, #d4a843);
  border: 1px solid var(--stage-accent, #d4a843);
  font-size: 12.5px; font-weight: 600; letter-spacing: .04em;
  transition: background .2s, box-shadow .2s;
}
.doc-tts-btn:hover { box-shadow: 0 0 16px color-mix(in srgb, var(--stage-accent, #d4a843) 35%, transparent); }
.doc-tts-btn[aria-pressed="true"] { background: var(--stage-accent, #d4a843); color: var(--stage-bg, #06060f); }

.doc-stage {
  position: relative; z-index: 1;
  min-height: 100vh;
  padding: 26px 18px 120px;
}
.doc-parchment {
  position: relative;
  width: min(860px, 94vw);
  margin: 0 auto;
  background: var(--parchment, #0d0d1a);
  border: 1px solid var(--parchment-edge, rgba(212, 168, 67, .3));
  border-radius: 4px;
  padding: clamp(26px, 5vw, 56px);
  color: var(--stage-ink, #e8e2d4);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}

/* ── the Two Row Wampum belt (geometry-only tribute) ──
   A white wampum field with two parallel purple rows — two peoples
   traveling side by side, never steering each other's vessel.
   Broken-treaty themes TEAR the belt; garden themes keep it whole. */
.doc-belt {
  width: min(860px, 94vw);
  margin: 0 auto 18px;
  background: #e9e2d2;
  border-radius: 3px;
  padding: 10px 0;
  position: relative;
}
.doc-belt-rows { display: flex; flex-direction: column; gap: 7px; padding: 0 4%; }
.doc-belt-rows i {
  display: block; height: 8px; border-radius: 2px;
  background: #3d2a5e;   /* wampum purple */
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .5);
}
.doc-belt-tear { display: none; }
body[data-theme="broken-treaty"] .doc-belt-tear {
  display: block; position: absolute; top: 0; bottom: 0;
  left: calc(58% + var(--doc-scale) * 1%); width: 30px;
  background:
    linear-gradient(103deg, transparent 0 46%, #e9e2d2 47% 53%, transparent 54%),
    repeating-linear-gradient(180deg, #e9e2d2 0 5px, transparent 5px 9px);
  clip-path: polygon(40% 0, 62% 6%, 34% 17%, 66% 26%, 30% 41%, 64% 52%, 36% 63%, 60% 74%, 38% 88%, 58% 100%, 50% 100%, 44% 86%, 52% 71%, 40% 54%, 54% 34%, 42% 18%, 56% 6%, 46% 0);
  filter: drop-shadow(1px 0 0 rgba(0,0,0,.35));
}
body[data-theme="broken-treaty"] .doc-belt-rows i {
  mask: linear-gradient(#000 0 0) 0 0 / 100% 100% no-repeat;
}
/* the fray: bead scatter at the tear on broken themes */
body[data-theme="broken-treaty"] .doc-belt::after {
  content: ''; position: absolute; top: -4px; bottom: -4px;
  left: calc(58% + var(--doc-scale) * 1% - 2px); width: 34px;
  background-image:
    radial-gradient(circle 2px at 20% 12%, #3d2a5e 0 1.6px, transparent 2px),
    radial-gradient(circle 2px at 70% 26%, #3d2a5e 0 1.4px, transparent 2px),
    radial-gradient(circle 2px at 32% 38%, #3d2a5e 0 1.5px, transparent 2px),
    radial-gradient(circle 2px at 78% 52%, #3d2a5e 0 1.7px, transparent 2px),
    radial-gradient(circle 2px at 24% 66%, #3d2a5e 0 1.4px, transparent 2px),
    radial-gradient(circle 2px at 62% 82%, #3d2a5e 0 1.6px, transparent 2px);
}

/* ── bullet wounds (broken-treaty) / bloom marks (garden) ── */
.doc-wound { display: none; }
body[data-theme="broken-treaty"] .doc-wound {
  display: block; position: absolute; width: 84px; height: 84px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 46% 44%, #050208 0 34%, rgba(15,4,10,.92) 40%,
      rgba(120,16,26,.35) 46%, transparent 62%);
  box-shadow: 0 0 26px rgba(200, 30, 45, .18), inset 0 0 12px rgba(0,0,0,.9);
}
body[data-theme="broken-treaty"] .doc-wound-1 { top: -34px; right: 8%; transform: rotate(calc(var(--doc-rot) * 0.2)); }
body[data-theme="broken-treaty"] .doc-wound-2 { bottom: 6%; left: -26px; width: 58px; height: 58px; }
/* torn edge on the parchment itself (broken only) */
body[data-theme="broken-treaty"] .doc-parchment {
  mask: linear-gradient(#000 0 0) 0 0 / 100% 100% no-repeat;
}

/* ── the medicine wheel: four directions, no words — the geometry
   speaks for the nations whose promises were recorded and broken ── */
.doc-wheel {
  display: none;
  position: absolute; top: 90px; right: 30px;
  width: 120px; height: 120px; opacity: .16; pointer-events: none;
}
body[data-theme="broken-treaty"] .doc-wheel,
body[data-theme="garden"] .doc-wheel { display: block; }
.doc-wheel-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--wheel-color, #8a8577);
}
.doc-wheel-cross {
  position: absolute; inset: 0;
  background:
    linear-gradient(0deg, transparent calc(50% - 1px), var(--wheel-color, #8a8577) calc(50% - 1px), var(--wheel-color, #8a8577) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(90deg, transparent calc(50% - 1px), var(--wheel-color, #8a8577) calc(50% - 1px), var(--wheel-color, #8a8577) calc(50% + 1px), transparent calc(50% + 1px));
}
.doc-wheel-dot {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: var(--wheel-color, #8a8577);
}
.d-n { top: -5px; left: calc(50% - 5px); }
.d-e { right: -5px; top: calc(50% - 5px); }
.d-s { bottom: -5px; left: calc(50% - 5px); }
.d-w { left: -5px; top: calc(50% - 5px); }
body[data-theme="garden"] .doc-wheel { --wheel-color: #2e7d4f; }
body[data-theme="garden"] .d-n { background: #e8e2d4; }
body[data-theme="garden"] .d-e { background: #d4a843; }
body[data-theme="garden"] .d-s { background: #2e7d4f; }
body[data-theme="garden"] .d-w { background: #b4552d; }

/* ── document typography (theme-agnostic defaults; themes may override) ── */
.doc-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.12; margin: 0 0 14px;
  color: var(--stage-title, #e8e2d4);
}
.doc-meta { margin: 0 0 30px; color: var(--stage-ink-dim, #8a8577); }
.doc-summary { font-size: 15px; line-height: 1.7; margin: 0 0 12px; }
.doc-meta-chip {
  display: inline-block; margin: 0 8px 6px 0; padding: 4px 10px;
  font-size: 11px; letter-spacing: .08em;
  border: 1px solid color-mix(in srgb, var(--stage-accent, #d4a843) 40%, transparent);
  border-radius: 999px;
}
.doc-body { font-size: 16.5px; line-height: 1.8; }
.doc-body h1, .doc-body h2, .doc-body h3 {
  font-family: 'Cormorant Garamond', serif;
  color: var(--stage-accent, #d4a843);
  margin: 1.6em 0 .5em;
}
.doc-body h1 { font-size: 1.7em; } .doc-body h2 { font-size: 1.4em; } .doc-body h3 { font-size: 1.15em; }
.doc-body a { color: var(--stage-accent, #d4a843); }
.doc-body blockquote {
  margin: 1.2em 0; padding: 4px 0 4px 18px;
  border-left: 3px solid color-mix(in srgb, var(--stage-accent, #d4a843) 55%, transparent);
  color: var(--stage-ink-dim, #b8b2a4);
}
.doc-body code { background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 4px; font-size: .88em; }
.doc-body pre { overflow-x: auto; background: rgba(0,0,0,.25); padding: 14px; border-radius: 8px; }
.doc-body table { border-collapse: collapse; width: 100%; margin: 1.2em 0; font-size: .92em; }
.doc-body th, .doc-body td { border: 1px solid rgba(255,255,255,.14); padding: 7px 10px; text-align: left; }
.doc-body th { color: var(--stage-accent, #d4a843); }
.doc-body hr { border: none; border-top: 1px dashed rgba(255,255,255,.18); margin: 2em 0; }

.doc-end { margin-top: 60px; text-align: center; padding: 26px 0 6px; }
.doc-end-bloom {
  width: 70px; height: 70px; margin: 0 auto 14px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, var(--stage-accent, #d4a843), transparent 70%);
  animation: doc-end-breathe 3s ease-in-out infinite;
}
@keyframes doc-end-breathe {
  0%, 100% { transform: scale(1); opacity: .7; }
  50% { transform: scale(1.25); opacity: 1; }
}
.doc-end-note { font-size: 13px; color: var(--stage-ink-dim, #8a8577); }
.doc-end-chat {
  display: inline-block; margin-top: 12px; padding: 11px 20px;
  border-radius: 999px; background: var(--stage-accent, #d4a843);
  color: var(--stage-bg, #06060f); text-decoration: none; font-weight: 700;
}

.curator-mode .doc-body { font-size: 19px; letter-spacing: .02em; line-height: 2.0; }

@media (max-width: 720px) {
  .doc-header { flex-wrap: wrap; }
  .doc-wheel { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .doc-end-bloom { animation: none; }
}
