/* Doublespeak v6 — The Quarterly.
   Aesthetic target: refined print quarterly. Cream paper, ink-blue accent, rust red rules.
   IA: 3 modes — COVER → CONTENTS → SPREAD. No vertical scroll on cover or spread.
   Distinct from v2 (Manus cream/gold/wine, long scroll) by IA + ink-blue accent + Garamond family. */

:root {
  /* Print-quarterly palette */
  --paper:        #f1ecdd;        /* warm cream */
  --paper-2:      #faf6e9;        /* lighter cream for cards / cover */
  --ink:          #161311;        /* warm near-black */
  --muted:        #6a6053;        /* warm gray text */
  --faint:        #a4998a;        /* faintest text / dividers */
  --line:         #d6cab2;        /* hairline */
  --line-strong:  #2c2520;        /* strong divider */
  --rust:         #7a1f0e;        /* deep rust red — heads & rules */
  --ink-blue:     #2c3e5c;        /* ink-blue — links + accents (only v6 uses blue) */
  --highlight:    #ebe1c6;        /* hover / selected wash */
  --gilt:         #b08530;        /* very subtle gilt for ornaments — used sparingly */

  --max:    1400px;
  --pad-x:  clamp(20px, 3.2vw, 56px);

  /* Garamond family — distinct from v2's Libre Baskerville */
  --font-display: "Hoefler Text", "Cormorant Garamond", "Garamond Premier Pro", "EB Garamond", Garamond, "Apple Garamond", "Times New Roman", serif;
  --font-text:    "Iowan Old Style Text", "Iowan Old Style", Charter, Georgia, "Times New Roman", serif;
  --font-mono:    ui-monospace, "SF Mono", Menlo, "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "liga" on, "kern" on, "onum" on;
  /* Reserve top + bottom bar room (the lead form bar at bottom is ~78-92px tall) */
  padding-top: 52px;
  padding-bottom: 96px;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--ink-blue); text-decoration: none; }
a:hover { color: var(--rust); }
button { font: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ===== Top bar — minimal print-shop chrome ===== */
.bar {
  position: fixed; left: 0; right: 0; z-index: 200;
  display: flex; align-items: center;
  background: var(--paper);
}
.bar-top {
  top: 0; height: 52px;
  padding: 0 clamp(16px, 2vw, 32px);
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
}
.bar-bottom {
  bottom: 0; min-height: 60px;
  padding: 8px clamp(16px, 2vw, 32px);
  border-top: 1px solid var(--line);
  flex-direction: column; align-items: stretch; gap: 4px;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 13px;
  letter-spacing: 0.04em; font-style: italic;
}
.brand-name {
  color: var(--ink); font-family: var(--font-display); font-weight: 700;
  font-size: 16px; letter-spacing: 0.01em; font-style: italic;
}
.bar-nav { display: none; }    /* v6: nav happens via mode transitions */
.bar-status {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  color: var(--muted); text-transform: uppercase;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gilt); }

/* Lead form bar */
.bar-bottom-skus {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.12em;
  color: var(--muted); text-transform: uppercase;
}
.bar-bottom-skus span::before { content: "▸ "; color: var(--rust); }
.bar-bottom-form { display: flex; align-items: center; gap: 8px; width: 100%; }
#leadEmail {
  flex: 1 1 auto; min-width: 0;
  background: var(--paper-2); color: var(--ink);
  border: 1px solid var(--line);
  padding: 9px 12px; font: 14px var(--font-text); letter-spacing: 0.01em;
  outline: none;
}
#leadEmail:focus { border-color: var(--ink-blue); }
#leadEmail::placeholder { color: var(--faint); font-style: italic; }
.lead-submit {
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink);
  padding: 9px 18px; cursor: pointer;
  font: 700 12px var(--font-display); letter-spacing: 0.08em; text-transform: uppercase;
  font-style: italic;
  transition: background 0.15s, color 0.15s;
}
.lead-submit:hover { background: var(--rust); border-color: var(--rust); }
.lead-qr {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line);
  width: 38px; height: 38px;
  display: grid; place-items: center;
  cursor: pointer; padding: 0;
}
.lead-qr svg { width: 18px; height: 18px; fill: currentColor; }
.lead-qr:hover { border-color: var(--ink-blue); color: var(--ink-blue); }
.bar-bottom-msg { font-family: var(--font-mono); font-size: 11px; color: var(--muted); min-height: 14px; }

.app-loading { padding: 60px 32px; color: var(--muted); font-family: var(--font-display); font-style: italic; font-size: 18px; }

/* ===== Mag modes — only one visible at a time, fade between ===== */

#appMain {
  position: relative;
  min-height: calc(100vh - 52px - 96px);
}

.mag-mode {
  display: none;
  opacity: 0;
  transition: opacity 0.32s ease;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(28px, 4vh, 56px) var(--pad-x);
  min-height: calc(100vh - 52px - 96px);
}
body[data-mode="cover"]   .mag-cover  { display: flex; opacity: 1; flex-direction: column; }
body[data-mode="toc"]     .mag-toc    { display: flex; opacity: 1; flex-direction: column; }
body[data-mode="spread"]  .mag-spread { display: flex; opacity: 1; flex-direction: column; }

/* default before JS sets mode — show cover */
body:not([data-mode]) .mag-cover { display: flex; opacity: 1; flex-direction: column; }

/* ===== COVER mode ===== */

.mag-cover {
  justify-content: space-between;
  position: relative;
}
.mag-cover::before {
  /* Decorative top rule with gilt center dot */
  content: "";
  position: absolute; top: clamp(16px, 2.5vh, 32px); left: var(--pad-x); right: var(--pad-x);
  height: 1px;
  background: linear-gradient(to right, var(--line) 0%, var(--line) 48%, var(--gilt) 49%, var(--gilt) 51%, var(--line) 52%, var(--line) 100%);
}
.cover-meta {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 10px; margin-top: 24px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.22em;
  color: var(--muted); text-transform: uppercase;
}
.cover-meta-sep { color: var(--faint); }

.cover-body {
  display: flex; flex-direction: column;
  gap: clamp(28px, 4vh, 48px);
  margin: auto 0;
  max-width: 1100px;
}
.cover-eyebrow {
  font-family: var(--font-display); font-style: italic;
  color: var(--rust);
  font-size: clamp(15px, 1.3vw, 19px);
  max-width: 60ch;
  letter-spacing: 0.005em;
}
.cover-title {
  font-family: var(--font-display);
  font-weight: 400; font-style: italic;
  font-size: clamp(72px, 11vw, 192px);
  line-height: 0.88;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 0;
  text-wrap: balance;
}
.cover-thesis {
  display: flex; flex-direction: column; gap: 4px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(28px, 3.6vw, 56px);
  line-height: 1.12;
  letter-spacing: -0.012em;
  color: var(--ink);
  max-width: 26ch;
}
.cover-thesis p { margin: 0; }
.cover-thesis p:last-child { color: var(--rust); font-style: italic; }
.cover-conclusion {
  font-family: var(--font-text);
  font-size: clamp(16px, 1.3vw, 20px);
  line-height: 1.55;
  color: var(--muted);
  max-width: 60ch;
  border-left: 2px solid var(--rust);
  padding-left: 18px;
  margin: 0;
}
.cover-conclusion strong { color: var(--ink); font-weight: 600; }

.cover-foot {
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 16px;
  padding-top: clamp(20px, 3vh, 36px);
  border-top: 1px solid var(--line);
}
.cover-open {
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(20px, 2vw, 30px);
  color: var(--ink-blue);
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
  transition: color 0.15s, transform 0.15s;
}
.cover-open:hover { color: var(--rust); transform: translateX(4px); }
.cover-edition {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em;
  color: var(--muted); text-transform: uppercase;
}

/* ===== CONTENTS (TOC) mode ===== */

.mag-toc {
  gap: clamp(20px, 3vh, 36px);
}
.toc-header {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}
.toc-back {
  font-family: var(--font-display); font-style: italic;
  font-size: 17px; color: var(--ink-blue);
}
.toc-back:hover { color: var(--rust); }
.toc-folio, .toc-meta {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em;
  color: var(--muted); text-transform: uppercase;
}

.toc-eyebrow {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.22em;
  color: var(--rust); text-transform: uppercase;
  margin-top: 12px;
}
.toc-title {
  font-family: var(--font-display);
  font-weight: 400; font-style: italic;
  font-size: clamp(40px, 5.6vw, 96px);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 8px 0 0;
  max-width: 16ch;
}
.toc-subtitle {
  font-family: var(--font-text);
  font-size: clamp(15px, 1.2vw, 19px);
  line-height: 1.55;
  color: var(--muted);
  max-width: 64ch;
  margin: 0;
}

.toc-list {
  margin-top: clamp(16px, 2.4vh, 28px);
  border-top: 1px solid var(--line-strong);
  display: flex; flex-direction: column;
}
.toc-row {
  display: grid;
  grid-template-columns: 80px 1fr auto auto;
  gap: 18px;
  align-items: baseline;
  padding: clamp(14px, 1.8vh, 22px) 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  transition: background 0.15s, padding 0.15s;
  position: relative;
}
.toc-row:hover {
  background: var(--highlight);
  padding-left: 12px; padding-right: 12px;
  color: var(--rust);
}
.toc-row:hover .toc-num { color: var(--rust); }
.toc-num {
  font-family: var(--font-display); font-style: italic;
  font-weight: 400;
  font-size: clamp(28px, 3vw, 44px);
  color: var(--rust);
  letter-spacing: -0.02em;
  line-height: 1;
}
.toc-body {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.toc-name {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(20px, 1.8vw, 30px);
  line-height: 1.1;
  color: inherit;
  letter-spacing: -0.005em;
}
.toc-role {
  font-family: var(--font-text); font-style: italic;
  font-size: clamp(13px, 1vw, 15px);
  color: var(--muted);
}
.toc-leader {
  flex: 1; min-width: 30px;
  border-bottom: 1px dotted var(--line);
  align-self: end;
  margin-bottom: 8px;
}
.toc-page {
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(15px, 1.2vw, 19px);
  color: var(--muted);
  font-variant-numeric: oldstyle-nums;
  font-feature-settings: "onum" on;
  min-width: 32px; text-align: right;
}
.toc-row:hover .toc-page { color: var(--rust); }

/* ===== SPREAD mode (2-page chapter spread) ===== */

.mag-spread {
  gap: clamp(16px, 2vh, 28px);
  position: relative;
}
.spread-loading {
  padding: 80px 24px; text-align: center;
  font-family: var(--font-display); font-style: italic; font-size: 22px;
  color: var(--muted);
}
.spread-error { color: var(--rust); }

.spread-header {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.spread-back {
  font-family: var(--font-display); font-style: italic;
  font-size: 17px; color: var(--ink-blue);
}
.spread-back:hover { color: var(--rust); }
.spread-issue-meta {
  display: flex; gap: 18px; align-items: baseline;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em;
  color: var(--muted); text-transform: uppercase;
}
.issue-tag { color: var(--rust); font-weight: 700; }

.spread-pages {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(40px, 6vw, 96px);
  flex: 1;
  position: relative;
  align-items: start;
}
.spread-pages::before {
  /* Center gutter line — thin double rule */
  content: "";
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  border-left: 1px solid var(--line);
  margin-left: -0.5px;
}

.spread-page { padding: 0; min-width: 0; }
.page-folio {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em;
  color: var(--muted); text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
  margin-bottom: clamp(16px, 2.4vh, 28px);
}
.page-folio.right { color: var(--rust); }
.page-folio .folio-no {
  font-family: var(--font-display); font-style: italic;
  font-size: 18px; letter-spacing: 0;
  color: var(--rust);
  font-variant-numeric: oldstyle-nums;
  font-feature-settings: "onum" on;
}
.page-folio .folio-role {
  font-family: var(--font-text); font-style: italic;
  letter-spacing: 0.02em; text-transform: none;
  color: var(--ink-blue);
  font-size: 13px;
  font-feature-settings: "kern" on;
}

.spread-title {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(40px, 4.6vw, 80px);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 12px;
  max-width: 16ch;
  text-wrap: balance;
}
.spread-deck {
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(16px, 1.4vw, 22px);
  color: var(--muted);
  margin: 0 0 18px;
  max-width: 50ch;
  line-height: 1.4;
}
.spread-rule {
  border-top: 2px solid var(--rust);
  width: 60px;
  margin: 18px 0;
}
.spread-punch {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(22px, 2vw, 32px);
  line-height: 1.32;
  color: var(--ink);
  margin: 0 0 22px;
  max-width: 32ch;
  letter-spacing: -0.005em;
  /* Drop cap on first letter */
}
.spread-punch::first-letter {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--rust);
  font-size: 1.6em;
  line-height: 0.9;
  float: left;
  padding: 6px 8px 0 0;
  margin-top: 4px;
}
.spread-lede {
  font-family: var(--font-text);
  font-size: clamp(14.5px, 1.1vw, 17px);
  line-height: 1.55;
  color: var(--muted);
  margin: 0;
  max-width: 50ch;
  /* Smaller text — like a magazine standfirst */
}

/* RIGHT page — fingerprint + stories */
.spread-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  border-top: 2px solid var(--rust);
  margin-bottom: clamp(20px, 3vh, 32px);
}
.stat-cell {
  padding: 16px 18px 16px 0;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.stat-cell:nth-child(2n) { border-right: 0; padding-right: 0; padding-left: 18px; }
.stat-cell.wide { grid-column: 1 / -1; border-right: 0; padding-right: 0; }
.stat-v {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(28px, 3vw, 44px); line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: oldstyle-nums;
  font-feature-settings: "onum" on;
}
.stat-v-small {
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(15px, 1.2vw, 19px);
  color: var(--ink);
  margin-top: 4px;
}
.stat-l {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
  margin-top: 8px; line-height: 1.3;
}
.stat-cell.wide .stat-l { margin-top: 0; }
.stat-cell.wide .stat-v-small { margin-top: 6px; }

.spread-stories.empty {
  font-family: var(--font-display); font-style: italic; color: var(--muted);
  padding: 18px 0;
}
.stories-eyebrow {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.18em;
  color: var(--rust); text-transform: uppercase;
  margin-bottom: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.story-line {
  display: grid;
  grid-template-columns: 36px 1fr 24px;
  gap: 14px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px dotted var(--line);
  color: var(--ink);
  transition: color 0.15s, padding 0.15s;
}
.story-line:hover { color: var(--rust); padding-left: 6px; }
.story-no {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em;
  color: var(--muted);
}
.story-line:hover .story-no { color: var(--rust); }
.story-title {
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(15px, 1.2vw, 19px);
  line-height: 1.35;
  color: inherit;
}
.story-arrow {
  font-family: var(--font-display); color: var(--ink-blue);
  font-size: 16px;
}
.story-line:hover .story-arrow { color: var(--rust); transform: translateX(2px); }

.spread-foot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: baseline;
  padding-top: clamp(16px, 2.4vh, 28px);
  border-top: 1px solid var(--line);
  font-family: var(--font-display); font-style: italic;
  font-size: clamp(13px, 1vw, 16px);
}
.spread-prev { text-align: left; color: var(--ink-blue); }
.spread-next { text-align: right; color: var(--ink-blue); }
.spread-prev.empty, .spread-next.empty { color: var(--faint); }
.spread-prev:hover, .spread-next:hover { color: var(--rust); }
.spread-toc-link {
  text-align: center;
  font-family: var(--font-mono); font-style: normal;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted);
}
.spread-toc-link:hover { color: var(--rust); }

/* ===== Drawer (story L3) ===== */
.drawer { position: fixed; inset: 0; z-index: 300; display: none; }
.drawer[aria-hidden="false"] { display: block; }
.drawer-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 14, 10, 0.55);
  backdrop-filter: blur(2px);
  border: 0; cursor: pointer;
}
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(720px, 92vw);
  background: var(--paper-2); color: var(--ink);
  overflow-y: auto;
  border-left: 1px solid var(--line-strong);
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.18);
}

/* ===== QR popover ===== */
.qr-popover { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center;
  background: rgba(20, 14, 10, 0.5); backdrop-filter: blur(2px); }
.qr-popover[hidden] { display: none; }
.qr-popover-card {
  background: var(--paper-2); color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 24px; max-width: 360px; text-align: center;
  font-family: var(--font-text);
}
.qr-popover-card strong { display: block; margin-bottom: 12px; font-family: var(--font-display); font-style: italic; font-size: 18px; }
.qr-canvas { width: 200px; height: 200px; margin: 0 auto 12px; background: white; }
.qr-close {
  margin-top: 14px; background: var(--ink); color: var(--paper);
  border: 0; padding: 8px 16px; cursor: pointer;
  font: 700 11px var(--font-display); font-style: italic; letter-spacing: 0.08em; text-transform: uppercase;
}
.qr-close:hover { background: var(--rust); }

/* ===== Responsive ===== */
@media (max-width: 980px) {
  .spread-pages {
    grid-template-columns: 1fr;
    gap: clamp(28px, 4vh, 48px);
  }
  .spread-pages::before { display: none; }
  .toc-row {
    grid-template-columns: 60px 1fr auto;
    gap: 14px;
  }
  .toc-leader { display: none; }
  .toc-page { font-size: 14px; }
  .cover-thesis { font-size: clamp(22px, 5vw, 36px); max-width: 100%; }
  .cover-title { font-size: clamp(56px, 14vw, 100px); }
}

/* end v6 */
