/* ============================================================
   Healing Through Expression — Final design
   Ren FangRui · 5143MAPA CW01 · Coventry University · 30 May 2026
   Palette: warm cream paper + deep slate ink + terracotta accent.
   Type: Fraunces (display) / Source Serif 4 (body) / Inter (UI).
   ============================================================ */

:root {
  --bg:        #F7F4EE;
  --paper:     #FFFFFF;
  --ink:       #1F2937;
  --ink-soft:  #374151;
  --muted:     #6B7280;
  --rule:        rgba(31, 41, 55, 0.10);
  --rule-strong: rgba(31, 41, 55, 0.22);
  --accent:      #C75E4E;
  --accent-deep: #9F3C2D;
  --accent-bg:   rgba(199, 94, 78, 0.07);

  --display: 'Fraunces', 'Source Serif 4', Georgia, serif;
  --serif:   'Source Serif 4', Georgia, serif;
  --sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--accent-deep); text-decoration: none; }
a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* ============================================================
   STICKY TOPNAV with reading-progress bar
   ============================================================ */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247, 244, 238, 0.93);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.topnav-inner {
  padding: 14px clamp(24px, 4vw, 64px);
  display: flex; align-items: center; gap: 28px;
  font-family: var(--sans); font-size: 13px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink); font-weight: 600;
  font-family: var(--display);
  flex-shrink: 0;
}
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: var(--ink); color: var(--bg);
  border-radius: 2px;
  font-family: var(--sans);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.05em;
}
.brand-text { font-size: 14px; letter-spacing: -0.01em; }
@media (max-width: 760px) { .brand-text { display: none; } }
.toc {
  list-style: none; margin: 0 0 0 auto; padding: 0;
  display: flex; gap: 2px; flex-wrap: wrap;
}
.toc a {
  display: inline-block;
  padding: 6px 10px;
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.02em;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}
.toc a:hover { color: var(--ink); background: rgba(31,41,55,0.05); text-decoration: none; }
.toc a.active { color: var(--accent); background: var(--accent-bg); }
@media (max-width: 1100px) { .toc { display: none; } }
.topnav-progress {
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.05s linear;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  padding: clamp(64px, 8vh, 120px) clamp(24px, 5vw, 80px) 0;
}
.hero-inner {
  max-width: 1240px; margin: 0 auto;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 64px;
  align-items: end;
}
@media (max-width: 980px) { .hero-inner { grid-template-columns: 1fr; gap: 32px; } }
.kicker {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 24px;
  font-weight: 700;
}
.hero h1 {
  font-family: var(--display);
  font-size: clamp(40px, 8vw, 100px);
  line-height: 0.98;
  letter-spacing: -0.025em;
  margin: 0 0 32px;
  font-weight: 500;
  color: var(--ink);
}
.deck {
  font-family: var(--display);
  font-size: clamp(20px, 1.6vw, 24px);
  line-height: 1.45;
  color: var(--ink-soft);
  margin: 0 0 28px;
  font-weight: 400;
  font-style: italic;
}
.byline {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0;
  text-transform: uppercase;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}
.byline strong { color: var(--ink); font-weight: 600; }
.hero-image { margin-top: 32px; }
.hero-image figure { margin: 0; }
.hero-image img {
  border-radius: 4px;
  box-shadow: 0 24px 60px rgba(31,41,55,0.14);
}
.hero-caption {
  margin: 14px 0 0;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  line-height: 1.5;
}

/* ============================================================
   ARTICLE — narrow editorial measure
   ============================================================ */
article {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 clamp(24px, 5vw, 40px);
}

.chapter, .references {
  margin: clamp(72px, 10vh, 128px) 0;
}

.chapter-head, .refs-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin: 0 0 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--ink);
}
.chapter-num {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  text-transform: uppercase;
  flex-shrink: 0;
  padding-top: 14px;
  min-width: 64px;
}
.chapter-head h2, .refs-head h2 {
  font-family: var(--display);
  font-size: clamp(26px, 3.6vw, 46px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
  font-weight: 500;
  color: var(--ink);
  flex: 1;
}

.chapter p {
  font-size: 18px;
  line-height: 1.75;
  color: var(--ink);
  margin: 0 0 22px;
}
.chapter p strong { font-weight: 600; color: var(--ink); }

.cite {
  color: var(--accent-deep);
  border-bottom: 1px dotted var(--accent-deep);
  padding-bottom: 1px;
}
.cite:hover {
  text-decoration: none;
  border-bottom-color: var(--ink);
  color: var(--ink);
}

/* PULL QUOTE — terracotta side rail */
.pull {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(22px, 2.2vw, 30px);
  line-height: 1.3;
  color: var(--accent-deep);
  margin: 48px 0;
  padding: 8px 0 8px 28px;
  border-left: 3px solid var(--accent);
  font-weight: 400;
}

/* ============================================================
   FIGURE — universal wrapper (APA 7 figure block)
   ============================================================ */
.figure { margin: 56px 0; break-inside: avoid; }
.figure-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 4px;
}
.figure-title {
  font-family: var(--display);
  font-size: 18px;
  font-style: italic;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 16px;
  line-height: 1.3;
}
.figure-body {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 24px;
}
.figure.photo .figure-body {
  background: transparent;
  border: 0;
  padding: 0;
}
.figure-body img { width: 100%; height: auto; border-radius: 2px; }
.figure-body svg { display: block; width: 100%; height: auto; }
.figure-note {
  margin: 12px 0 0;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
}
.figure-note .label { font-style: italic; color: var(--ink-soft); font-weight: 600; }

/* ============================================================
   SVG chart colours (used inline via classes on shapes)
   ============================================================ */
.bar-track { fill: rgba(199,94,78,0.16); }
.bar-fill  { fill: var(--accent); }
.bar-label { fill: var(--ink); font-family: var(--sans); font-size: 12px; font-weight: 600; }
.bar-value { fill: var(--accent-deep); font-family: var(--display); font-size: 16px; font-weight: 600; }
.axis-tick { stroke: var(--rule-strong); stroke-width: 1; }
.axis-text { fill: var(--muted); font-family: var(--sans); font-size: 10px; letter-spacing: 0.04em; }
.dot-on   { fill: var(--accent); }
.dot-off  { fill: rgba(199,94,78,0.18); }

/* Trait cards (Figure 2) */
.trait-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .trait-grid { grid-template-columns: 1fr; } }
.trait {
  padding: 20px;
  background: var(--bg);
  border-radius: 4px;
  border-top: 3px solid var(--accent);
}
.trait-tag {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}
.trait h4 {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink);
}
.trait-desc {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.55;
}

/* Region bands (Figure 7) */
.region-stack { display: flex; flex-direction: column; gap: 8px; }
.region-band {
  padding: 16px 20px;
  background: var(--bg);
  border-left: 4px solid var(--accent);
  border-radius: 0 4px 4px 0;
}
.region-band.present { border-left-color: rgba(199, 94, 78, 0.55); }
.region-band.sparse  { border-left-color: rgba(199, 94, 78, 0.25); }
.band-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}
.region-band.present .band-label { color: var(--accent-deep); opacity: 0.85; }
.region-band.sparse  .band-label { color: var(--muted); }
.band-regions {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 6px;
}
.band-desc {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.55;
}

/* People-grid SVG-specific helpers */
.kaimal-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; align-items: center; }
@media (max-width: 720px) { .kaimal-grid { grid-template-columns: 1fr; } }
.kaimal-stat { font-family: var(--display); font-size: 56px; color: var(--accent); font-weight: 600; line-height: 1; margin: 0; }
.kaimal-stat-lbl { font-family: var(--sans); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin: 8px 0 24px; line-height: 1.5; }
.kaimal-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag-critique {
  display: inline-block;
  padding: 5px 11px;
  background: var(--accent-bg);
  color: var(--accent-deep);
  border: 1px solid rgba(199,94,78,0.3);
  border-radius: 100px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
}

/* Bolwerk side-by-side */
.bolwerk-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .bolwerk-split { grid-template-columns: 1fr; } }
.bolwerk-side {
  padding: 22px;
  background: var(--bg);
  border-radius: 4px;
  border-top: 3px solid var(--accent);
}
.bolwerk-side.dim { border-top-color: var(--rule-strong); opacity: 0.78; }
.bolwerk-side h4 { font-family: var(--display); font-size: 17px; margin: 0 0 4px; color: var(--ink); font-weight: 600; }
.bolwerk-side .sub { font-family: var(--sans); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0 0 16px; }
.bolwerk-side .figures { font-family: var(--display); font-size: 48px; color: var(--accent); font-weight: 600; line-height: 1; margin: 0; }
.bolwerk-side.dim .figures { color: var(--muted); }
.bolwerk-side .desc { font-family: var(--serif); font-size: 13px; color: var(--ink-soft); margin: 14px 0 0; line-height: 1.55; }
.bolwerk-meta {
  display: flex; gap: 20px; margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-family: var(--sans); font-size: 11px; color: var(--muted);
  letter-spacing: 0.04em; flex-wrap: wrap;
}
.bolwerk-meta strong { color: var(--ink-soft); font-weight: 600; }

/* ============================================================
   AI SPLIT (Path A vs Path B) — Section 05
   ============================================================ */
.ai-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  background: var(--paper);
  margin: 32px 0;
}
@media (max-width: 760px) { .ai-split { grid-template-columns: 1fr; } }
.ai-side { padding: 26px; display: flex; flex-direction: column; gap: 8px; }
.ai-side + .ai-side { border-left: 1px solid var(--rule); }
@media (max-width: 760px) { .ai-side + .ai-side { border-left: 0; border-top: 1px solid var(--rule); } }
.ai-side .label {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
}
.ai-side .word {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(22px, 2.4vw, 28px);
  color: var(--ink);
  margin: 4px 0 0;
  font-weight: 500;
  line-height: 1.15;
}
.ai-side .time {
  font-family: var(--display);
  font-size: 42px;
  color: var(--accent);
  font-weight: 600;
  margin: 12px 0 4px;
  line-height: 1;
}
.ai-side .time .unit {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 4px;
  letter-spacing: 0.04em;
}
.ai-side .time-unit {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}
.ai-side .desc {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink-soft);
  margin: 12px 0 0;
  line-height: 1.6;
}
.ai-side img {
  width: 100%; height: auto;
  margin: 8px 0 4px;
  border-radius: 2px;
  filter: saturate(0.92);
}

/* ============================================================
   TWENGE SCATTER — JS-populated dots (Section 05)
   ============================================================ */
.scatter {
  position: relative;
  height: 280px;
  margin: 12px 0 8px;
  background:
    linear-gradient(to right, rgba(199,94,78,0.04) 0%, transparent 60%),
    repeating-linear-gradient(to right,
      transparent 0,
      transparent calc(25% - 1px),
      var(--rule) calc(25% - 1px),
      var(--rule) 25%);
  border-bottom: 1px solid var(--rule-strong);
  border-left: 1px solid var(--rule-strong);
}
.scatter .dot {
  position: absolute;
  width: 5px; height: 5px;
  background: var(--ink-soft);
  border-radius: 50%;
  opacity: 0.55;
}
.scatter .threshold {
  position: absolute;
  top: 0; bottom: 0;
  width: 0;
  border-left: 2px dashed var(--accent);
}
.scatter .threshold-lbl {
  position: absolute;
  top: -18px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--sans);
  font-size: 10px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.scatter-axes {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ============================================================
   REFERENCES — single column cards
   ============================================================ */
.references ol.ref-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: ref;
}
.references ol.ref-list li {
  counter-increment: ref;
  padding: 22px 24px 22px 56px;
  border-top: 1px solid var(--rule);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-soft);
  position: relative;
}
.references ol.ref-list li:last-child { border-bottom: 1px solid var(--rule); }
.references ol.ref-list li::before {
  content: counter(ref);
  position: absolute;
  left: 18px;
  top: 22px;
  font-family: var(--display);
  font-size: 18px;
  color: var(--accent);
  font-weight: 600;
  line-height: 1;
}
.references a {
  word-break: break-word;
  font-size: 13px;
  color: var(--ink-soft);
  border-bottom: 1px dotted var(--rule-strong);
}
.references a:hover { color: var(--accent-deep); border-bottom-color: var(--accent-deep); }

/* Bidirectional citation back-links */
.back-cite-group {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: 1px;
}
.back-cite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--accent-bg);
  color: var(--accent-deep);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(199, 94, 78, 0.22);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}
.back-cite:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  text-decoration: none;
}
/* Highlight target reference + target citation on hash-jump */
.references ol.ref-list li:target {
  background: var(--accent-bg);
  box-shadow: inset 3px 0 0 var(--accent);
}
.cite:target {
  background: var(--accent);
  color: var(--bg) !important;
  border-bottom-color: var(--accent);
  padding: 1px 4px;
  border-radius: 2px;
}

/* ============================================================
   FOOTER + a11y
   ============================================================ */
.page-footer {
  margin: 96px 0 0;
  padding: 32px 24px 64px;
  border-top: 1px solid var(--rule);
  text-align: center;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.page-footer p { margin: 0; }
.page-footer .ai-note {
  margin: 14px auto 0;
  max-width: 64ch;
  font-size: 10.5px;
  font-style: italic;
  letter-spacing: 0.02em;
  text-transform: none;
  line-height: 1.6;
  opacity: 0.88;
}

::selection { background: var(--accent-bg); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   DARK MODE — respects prefers-color-scheme
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #1A1816;
    --paper:     #25221F;
    --ink:       #F2EFE9;
    --ink-soft:  #D8D4CC;
    --muted:     #8A857B;
    --rule:        rgba(242, 239, 233, 0.10);
    --rule-strong: rgba(242, 239, 233, 0.22);
    --accent:      #E37662;
    --accent-deep: #F4937F;
    --accent-bg:   rgba(227, 118, 98, 0.10);
  }
  .topnav { background: rgba(26, 24, 22, 0.93); }
  .brand-mark { background: var(--ink); color: var(--bg); }
  .hero-image img { box-shadow: 0 24px 60px rgba(0,0,0,0.5); }
  .ai-side img { filter: saturate(0.85) brightness(0.92); }
  .figure-body img { filter: saturate(0.92) brightness(0.95); }
  .scatter .dot { background: var(--ink-soft); opacity: 0.6; }
  .bar-track { fill: rgba(227, 118, 98, 0.18); }
  .dot-on  { fill: var(--accent); }
  .dot-off { fill: rgba(227, 118, 98, 0.20); }
}

/* ============================================================
   SMALL SCREEN tightening (≤ 440 px)
   ============================================================ */
@media (max-width: 440px) {
  body { font-size: 16px; }
  .hero { padding: 56px 20px 0; }
  .hero h1 { margin-bottom: 24px; }
  article { padding: 0 20px; }
  .chapter p, .ai-decl p { font-size: 16.5px; line-height: 1.7; }
  .figure-body { padding: 18px; }
  .figure { margin: 40px 0; }
  .pull { font-size: 20px; padding-left: 20px; margin: 36px 0; }
  .references ol.ref-list li { padding: 18px 18px 18px 48px; font-size: 14px; }
  .references ol.ref-list li::before { left: 14px; top: 18px; font-size: 16px; }
}
