/* Editorial line drawing book stylesheet layered cleanly over Guidedog's built-in theme. */

:root,
html[data-theme="light"] {
  --bg: #f6f2e9;
  --paper: #fcfaf5;
  --surface: #efe9dc;
  --ink: #172e38;
  --muted: #4e616a;
  --rule: #d5cdbe;
  --teal: #08716d;
  --teal-soft: #e4f3f1;
  --red: #ae3d2c;
  --red-soft: #faeae7;
  --gold: #a66f10;
  --gold-soft: #fcf3de;
}

html[data-theme="dark"] {
  --bg: #10191f;
  --paper: #16222a;
  --surface: #1d2d37;
  --ink: #ecf0f2;
  --muted: #a3b4bc;
  --rule: #2c3e4a;
  --teal: #38b2ac;
  --teal-soft: #153538;
  --red: #e56b58;
  --red-soft: #381e1c;
  --gold: #e0a84b;
  --gold-soft: #352a16;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #10191f;
    --paper: #16222a;
    --surface: #1d2d37;
    --ink: #ecf0f2;
    --muted: #a3b4bc;
    --rule: #2c3e4a;
    --teal: #38b2ac;
    --teal-soft: #153538;
    --red: #e56b58;
    --red-soft: #381e1c;
    --gold: #e0a84b;
    --gold-soft: #352a16;
  }
}

body {
  background: var(--bg);
  color: var(--ink);
}

.book-header {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.gd-footer-credit {
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.gd-brand-symbol {
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 1.5rem;
}

.gd-language > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
}

.gd-language > summary::-webkit-details-marker {
  display: none;
}

.lang-current-code {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-left: 0.25rem;
}

.header-pdf-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.62rem;
  border-radius: 999px;
  border: 1px solid var(--teal);
  color: var(--teal) !important;
  font-weight: 600;
  font-size: 0.8rem;
  text-decoration: none;
}

.header-pdf-pill:hover {
  background: var(--teal);
  color: #fff !important;
}

.gd-sidebar {
  background: var(--paper);
  border-right: 1px solid var(--rule);
}

.sidebar-edition-card {
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.eyebrow-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal);
}

.sidebar-pdf-btn {
  display: inline-block;
  text-align: center;
  padding: 0.42rem 0.65rem;
  border-radius: 6px;
  background: var(--teal);
  color: #ffffff !important;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}

.sidebar-pdf-btn:hover {
  opacity: 0.92;
}

.sidebar-legal-note {
  margin-top: 1.2rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--rule);
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--muted);
}

/* Literary book typography & line drawing frames */
.book-prose {
  font-size: 1.05rem;
  line-height: 1.74;
}

.book-prose h1 {
  font-size: clamp(1.85rem, 3.2vw, 2.55rem);
  line-height: 1.16;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.book-prose h2 {
  margin-top: 2.4rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--rule);
  font-size: 1.42rem;
  line-height: 1.28;
}

.book-prose blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-left: 4px solid var(--teal);
  border-radius: 0 8px 8px 0;
  font-style: italic;
}

.book-prose figure {
  margin: 1.85rem 0;
  padding: 0.85rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 6px 22px rgba(23, 46, 56, 0.06);
}

.book-prose figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.book-prose figcaption {
  margin-top: 0.65rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Keep bespoke Typst & adaptive Graphviz SVGs crisp in both light & dark themes */
html[data-theme="dark"] img.typst-diagram {
  filter: none !important;
  background: #f9f6ef;
  padding: 4px;
  border-radius: 8px;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] img.typst-diagram {
    filter: none !important;
    background: #f9f6ef;
    padding: 4px;
    border-radius: 8px;
  }
}

/* Graphviz semantic node dark-mode palette */
html[data-theme="dark"] svg .gd-input polygon,
html[data-theme="dark"] svg .gd-input path { fill: #1e2d36 !important; stroke: #4fd1c5 !important; }
html[data-theme="dark"] svg .gd-choice polygon,
html[data-theme="dark"] svg .gd-choice path { fill: #352915 !important; stroke: #ecc94b !important; }
html[data-theme="dark"] svg .gd-output polygon,
html[data-theme="dark"] svg .gd-output path { fill: #153538 !important; stroke: #38b2ac !important; }
html[data-theme="dark"] svg .gd-stop polygon,
html[data-theme="dark"] svg .gd-stop path { fill: #3b1d1b !important; stroke: #fc8181 !important; }
html[data-theme="dark"] svg text { fill: #eef2f5 !important; }
html[data-theme="dark"] svg .edge path { stroke: #8fa6b2 !important; }
html[data-theme="dark"] svg .edge polygon { fill: #8fa6b2 !important; stroke: #8fa6b2 !important; }

/* Interactive Explorer Toolbar (Atlas & Scenarios) */
.interactive-toolbar {
  margin: 1.5rem 0;
  padding: 1.1rem 1.2rem;
  background: var(--paper);
  border: 1.5px solid var(--teal);
  border-radius: 10px;
}

.toolbar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.toolbar-kicker {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal);
}

.toolbar-count {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
}

.toolbar-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
}

.toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.toolbar-field input,
.toolbar-field select {
  padding: 0.5rem 0.68rem;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.9rem;
}

/* 40-Point Atlas Cards authored in native RST */
.atlas-card {
  margin: 0.95rem 0;
  padding: 1rem 1.15rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
}

.atlas-card.atlas-prohibited {
  border-left-color: var(--red);
}

.atlas-card p:first-child {
  margin-top: 0;
  margin-bottom: 0.4rem;
  font-size: 0.98rem;
}

.atlas-card p:last-child {
  margin-bottom: 0;
  font-size: 0.93rem;
  color: var(--muted);
}

/* Scenario & Government Contact Cards */
.scenario-card,
.contact-card {
  margin: 1.15rem 0;
  padding: 1.1rem 1.25rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--teal);
  border-radius: 8px;
}

.contact-card.china-card {
  border-top-color: var(--red);
}

.scenario-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.scenario-pill {
  padding: 0.38rem 0.78rem;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
}

.scenario-pill[aria-selected="true"] {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

/* Editorial line work: white space, flat framing, and semantic accent colors. */
.book-prose figure {
  padding: 0;
  background: #fff;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.book-prose figure img { border-radius: 0; }
.book-prose figcaption {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--rule, var(--lp-rule));
  background: var(--paper, var(--lp-paper));
  max-width: 100%;
}
