/* ============================================================
   Exchange Rate Dynamics — dissertation hub
   Warm paper, serif display, hairline rules. Light and dark.
   The palette is Chapter 2's, so the hub reads as the parent
   of both laboratories rather than a third visual language.
   ============================================================ */

:root {
  color-scheme: light;

  --bg:        #fcfbf8;
  --bg-sunk:   #f5f2ea;
  --bg-raise:  #ffffff;
  --ink:       #1d1c19;
  --ink-soft:  #4a4741;
  --ink-mute:  #6f6b62;
  --rule:      #e2ddd2;
  --rule-hard: #c9c2b4;

  --accent:    #1d4e6b;   /* the house blue; cards override it locally */
  --gold:      #a07a3c;
  --accent-wash: #eef3f6;

  --optimist:      #2f8f7d;
  --pessimist:     #c05a3e;
  --fundamentalist:#77798a;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans:  ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --page: 76rem;
  --gutter: clamp(1rem, 4vw, 3rem);
  --shadow: 0 1px 2px rgba(29, 28, 25, .04), 0 8px 24px rgba(29, 28, 25, .05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121316; --bg-sunk: #1a1c20; --bg-raise: #1c1e22;
    --ink: #e9e7e1; --ink-soft: #c3c0b8; --ink-mute: #948f86;
    --rule: #2c2e33; --rule-hard: #454850;
    --accent: #74b6d6; --gold: #d8ad69; --accent-wash: #1a242b;
    --optimist: #52c2a8; --pessimist: #e8906f; --fundamentalist: #a5a8b5;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.28);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121316; --bg-sunk: #1a1c20; --bg-raise: #1c1e22;
  --ink: #e9e7e1; --ink-soft: #c3c0b8; --ink-mute: #948f86;
  --rule: #2c2e33; --rule-hard: #454850;
  --accent: #74b6d6; --gold: #d8ad69; --accent-wash: #1a242b;
  --optimist: #52c2a8; --pessimist: #e8906f; --fundamentalist: #a5a8b5;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.28);
}

*, *::before, *::after { box-sizing: border-box; }

/* The hidden attribute only sets display:none at user-agent weight, so any
   component rule that sets its own display silently defeats it. .titlepage is
   a flex column and did exactly that. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; line-height: 1.14; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
cite { font-style: italic; }

:where(a, button):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip { position: absolute; left: 1rem; top: -4rem; z-index: 20; background: var(--bg-raise);
        padding: .6rem 1rem; border: 1px solid var(--rule-hard); border-radius: 6px; }
.skip:focus { top: 1rem; }

/* ── masthead ───────────────────────────────────────────── */

.masthead {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--ink);
         text-decoration: none; font-size: .8rem; letter-spacing: .04em; }
.brand svg { color: var(--accent); flex: none; }
.brand b { font-weight: 650; }
.brand-sep { margin: 0 .5rem; color: var(--rule-hard); }
.masthead nav { display: flex; align-items: center; gap: 1.4rem; }
.masthead nav a { color: var(--ink-soft); text-decoration: none; font-size: .875rem; }
.masthead nav a:hover { color: var(--accent); }

.theme-toggle {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--rule); border-radius: 6px;
  background: transparent; color: var(--ink-mute); cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--rule-hard); }

/* Phone: the brand plus three links plus the toggle do not fit. The links are
   anchors into a short page, so they lose nothing by going. */
@media (max-width: 34rem) {
  .masthead nav a { display: none; }
  .masthead nav { gap: 0; }
  .brand span { font-size: .8rem; }
  .brand-sep, .brand span br + *, .brand-tail { display: none; }
}

/* ── shared layout ──────────────────────────────────────── */

main { max-width: var(--page); margin-inline: auto; padding-inline: var(--gutter); }

/* The masthead is sticky, so an anchor jump would otherwise land the heading
   underneath it. */
main[id], main section[id] { scroll-margin-top: 4.75rem; }

.section-head { max-width: 44rem; margin-bottom: 2rem; }
.section-head h2 { font-size: clamp(1.6rem, 3.2vw, 2.2rem); }
.section-head p { color: var(--ink-mute); margin-top: .5rem; }

.eyebrow {
  font-family: var(--sans); font-size: .7rem; font-weight: 650;
  letter-spacing: .13em; text-transform: uppercase; color: var(--gold);
}

/* ── chapters as the hero ───────────────────────────────── */

.chapters { padding-block: clamp(1.8rem, 4vw, 3rem) clamp(3rem, 7vw, 4.5rem); }

.chapters-intro {
  display: grid; gap: clamp(1.75rem, 4vw, 3rem);
  align-items: start;
  margin-bottom: clamp(1.75rem, 4vw, 2.75rem);
}
@media (min-width: 54rem) {
  .chapters-intro { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
}

.intro-copy { max-width: 40rem; }
.chapters-intro h1 {
  font-size: clamp(1.95rem, 4.4vw, 3.05rem);
  letter-spacing: -.022em;
  margin: .75rem 0 0;
}
.lede {
  margin-top: 1rem; color: var(--ink-soft);
  font-size: clamp(.98rem, 1.4vw, 1.08rem); line-height: 1.66; max-width: 36rem;
}
.status-line {
  display: flex; align-items: center; gap: .5rem;
  margin-top: 1.15rem; font-size: .82rem; color: var(--ink-mute);
}
.status-line .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--optimist); flex: none;
}

/* ── the printed title page ─────────────────────────────── */

.cover { margin: 0; display: grid; justify-items: center; gap: .7rem; }
.cover figcaption {
  font-size: .72rem; color: var(--ink-mute); text-align: center; max-width: 17rem;
}

/* A document facsimile is a photograph of paper: it keeps its own ink and
   ground in both themes rather than inverting with the page. */
.titlepage, .cover img {
  width: clamp(186px, 23vw, 236px);
  border: 1px solid rgba(29, 28, 25, .16);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(29,28,25,.10), 0 14px 30px rgba(29,28,25,.14);
  transform: rotate(-1.1deg);
  transition: transform .3s ease;
}
.cover:hover .titlepage, .cover:hover img { transform: rotate(0deg); }
.cover img { height: auto; display: block; background: var(--bg-sunk); }
/* The photograph links to itself at full size, where the jury is legible. */
.cover a { display: block; line-height: 0; border-radius: 2px; }
.cover a:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }

.titlepage {
  aspect-ratio: 1 / 1.414;
  background: #f6f3ea;
  color: #221f1b;
  font-family: var(--serif);
  padding: 7% 9%;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; line-height: 1.42;
  overflow: hidden;
}
.titlepage p { margin: 0; }
.tp-univ {
  font-family: var(--sans); font-size: .46rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: #4a4640;
  padding-bottom: .35rem; border-bottom: 1.5px solid #221f1b;
}
.tp-head { margin-top: 13% !important; font-size: .6rem; text-transform: uppercase; letter-spacing: .04em; }
.tp-disc { margin-top: 12% !important; font-size: .56rem; }
.tp-par  { margin-top: .35rem !important; font-size: .56rem; }
.tp-name { margin-top: .5rem !important; font-size: .72rem; letter-spacing: .01em; }
.tp-name b { font-weight: 700; }
.tp-title {
  margin-top: 13% !important; font-size: .62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .005em; line-height: 1.34;
}
.tp-date { margin-top: auto !important; font-size: .53rem; color: #3b3832; }

@media (max-width: 54rem) {
  .cover { justify-items: start; }
  .cover figcaption { text-align: left; }
}

/* ── the live panel ─────────────────────────────────────── */

.hero-panel {
  margin: 0; min-width: 0;
  background: var(--bg-raise);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1rem; border-bottom: 1px solid var(--rule); background: var(--bg-sunk);
}
.panel-title { font-size: .72rem; font-weight: 650; letter-spacing: .1em;
               text-transform: uppercase; color: var(--ink-mute); }
.panel-title::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--optimist); margin-right: .55rem; vertical-align: middle;
}
.panel-seed { font-family: var(--mono); font-size: .7rem; color: var(--ink-mute); }
#hero-canvas { display: block; width: 100%; height: 290px; }
.hero-panel figcaption {
  padding: .9rem 1rem 1.05rem; border-top: 1px solid var(--rule);
  font-size: .8rem; line-height: 1.6; color: var(--ink-mute);
}

/* ── chapter cards ──────────────────────────────────────── */

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.5rem; }
@media (min-width: 58rem) { .cards { grid-template-columns: 1fr 1fr; } }

.card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--bg-raise);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
}
.card.live {
  box-shadow: var(--shadow);
  transition: border-color .16s ease, transform .16s ease;
}
.card.live:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--rule)); transform: translateY(-2px); }

.card-figure {
  height: 132px; border-bottom: 1px solid var(--rule);
  background: var(--bg-sunk); position: relative;
}
.card-figure canvas { display: block; width: 100%; height: 100%; }

.card-body { padding: 1.35rem 1.35rem 1.5rem; display: flex; flex-direction: column; gap: .7rem; flex: 1; }

.card-num {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  font-size: .7rem; font-weight: 650; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-mute);
}
.pill {
  font-size: .62rem; letter-spacing: .09em; padding: .16rem .5rem; border-radius: 999px;
  background: var(--accent-wash); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.pill.quiet { background: transparent; color: var(--ink-mute); border-color: var(--rule); }

.card h2 { font-size: 1.42rem; line-height: 1.2; }
.card h2 a { color: var(--ink); text-decoration: none; }
.card h2 a:hover { color: var(--accent); text-decoration: underline; }

.card-text { color: var(--ink-soft); font-size: .93rem; line-height: 1.64; }

.card-meta { margin: .2rem 0 0; padding: 0; list-style: none; display: grid; gap: .38rem; }
.card-meta li {
  position: relative; padding-left: 1.05rem;
  font-size: .82rem; line-height: 1.5; color: var(--ink-mute);
}
.card-meta li::before {
  content: ""; position: absolute; left: 0; top: .58em;
  width: 5px; height: 5px; border-radius: 1px; background: var(--accent); opacity: .65;
}

.card-cite {
  margin-top: auto; padding-top: .85rem; border-top: 1px solid var(--rule);
  font-size: .78rem; line-height: 1.55; color: var(--ink-mute);
}
.card-links { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.go { font-size: .9rem; font-weight: 600; color: var(--accent); text-decoration: none; }
.go:hover { text-decoration: underline; }
.src { font-size: .8rem; color: var(--ink-mute); text-decoration: none; }
.src:hover { color: var(--accent); }

.card.pending {
  background: transparent;
  border-style: dashed;
  border-color: var(--rule-hard);
}
.card.pending .card-body { padding-block: 1.6rem; gap: .55rem; }
.card.pending h2 { font-size: 1.2rem; color: var(--ink-mute); font-weight: 500; }
@media (min-width: 58rem) {
  .card.pending { flex-direction: row; align-items: center; }
}

/* ── why crises ─────────────────────────────────────────── */

.why { padding-block: clamp(3rem, 7vw, 4.5rem); border-top: 1px solid var(--rule); }
.why .section-head h2 { margin-top: .5rem; }

.why-layout { display: grid; gap: clamp(2rem, 5vw, 3.25rem); align-items: start; }
@media (min-width: 62rem) {
  .why-layout { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
}

.prose { display: grid; gap: 1.05rem; max-width: 38rem; }
.prose p { color: var(--ink-soft); font-size: 1rem; line-height: 1.74; }
.prose b { color: var(--ink); font-weight: 650; }
.prose em { color: var(--ink); font-style: italic; }
.prose .first { font-size: 1.08rem; color: var(--ink); }

.aside {
  margin-top: .6rem; padding: 1.1rem 1.25rem;
  background: var(--bg-sunk); border-left: 2px solid var(--gold); border-radius: 0 8px 8px 0;
  font-size: .88rem !important; line-height: 1.65 !important;
}

.why-side { display: grid; gap: 1.25rem; }

.facts {
  padding: 1.5rem 1.5rem 1.6rem;
  background: var(--bg-raise); border: 1px solid var(--rule); border-radius: 12px;
}
.facts h3 { font-size: .72rem; font-family: var(--sans); font-weight: 650;
            letter-spacing: .13em; text-transform: uppercase; color: var(--ink-mute); }
.facts .pub-h { margin-top: 1.6rem; }
.facts dl { margin: 1rem 0 0; display: grid; gap: .7rem; }
.facts dl > div { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: .75rem; }
.facts dt { font-size: .78rem; color: var(--ink-mute); }
.facts dd { margin: 0; font-size: .86rem; color: var(--ink); }
.pub { margin-top: .8rem; font-size: .84rem; line-height: 1.6; color: var(--ink-soft); }

/* ── defence ────────────────────────────────────────────── */

.defence { padding-block: clamp(3rem, 7vw, 4.5rem); border-top: 1px solid var(--rule); }
.jury { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
@media (min-width: 46rem) { .jury { grid-template-columns: 1fr 1fr; column-gap: 2.5rem; } }
.jury li {
  display: grid; gap: .15rem; padding: .85rem 0; border-top: 1px solid var(--rule);
}
.jury b { font-family: var(--serif); font-size: 1.02rem; font-weight: 600; }
.jury span { font-size: .82rem; color: var(--ink-mute); }

/* ── footer ─────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--rule);
  padding: 2rem var(--gutter) 2.5rem;
  max-width: var(--page); margin-inline: auto;
}
footer p { font-size: .8rem; line-height: 1.65; color: var(--ink-mute); max-width: 44rem; }
.colophon {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--rule);
}
.colophon a { color: var(--ink-mute); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
