/* ============================================================
   Lines That Bind — base stylesheet
   Style after hgis.uw.edu (Morandi palette: dusty plum + clay
   gold on warm putty paper). Functional partisan colors stay
   recognisable (deep blue / red) but everything else is muted.
   ============================================================ */

:root {
  /* HGIS Morandi palette */
  --uw-purple: #6a5a6e;
  --uw-purple-deep: #4a3e4d;
  --uw-purple-soft: #9a8b9e;
  --uw-gold: #a08e6f;
  --uw-gold-soft: #c5b59a;
  --sage: #8e9c8a;
  --sage-soft: #b4bdaf;
  --rose: #c2a094;
  --rose-soft: #d8c4bb;
  --mist: #a8b1b3;

  --ink: #2c2823;
  --ink-soft: #6c6358;
  --ink-faint: #98907f;

  --rule: #d6cdbf;
  --rule-soft: #e9e2d4;
  --bg: #ece5d8;
  --bg-card: #f5efe2;
  --bg-deep: #ddd4c2;

  /* Functional partisan colors (subdued for paper register) */
  --r-blue: #4a6b87;       /* dusty navy */
  --r-blue-soft: #7a92a6;
  --r-red:  #a04a55;       /* dusty brick — same hue family as rose */
  --r-red-soft: #c08087;

  --serif:  "Fraunces", "Source Serif 4", "Charter", Georgia, serif;
  --display:"Cormorant Garamond", "Cormorant", Garamond, Georgia, serif;
  --sans:   "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono:   "JetBrains Mono", "SF Mono", Consolas, monospace;
  --zh:     "Noto Serif SC", "Source Han Serif SC", "Songti SC", "Source Serif 4", Georgia, serif;
  --zh-sans:"Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", "Inter", sans-serif;

  --measure: 38rem;
  --measure-wide: 62rem;
  --pad: clamp(1.25rem, 4vw, 3rem);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-feature-settings: "kern" 1, "liga" 1;
}

html { scroll-behavior: smooth; }

/* very subtle paper grain (HGIS motif) */
body {
  min-height: 100vh;
  background-image: radial-gradient(rgba(76, 64, 56, 0.022) 1px, transparent 1px);
  background-size: 3px 3px;
}

/* Chinese typography — switch font stack on the html-lang */
html[lang^="zh"] body { font-family: var(--zh); line-height: 1.85; }
html[lang^="zh"] .site-header__nav,
html[lang^="zh"] .hero__kicker,
html[lang^="zh"] .hero__cite,
html[lang^="zh"] .hero__scroll,
html[lang^="zh"] .act__num,
html[lang^="zh"] .site-footer__inner,
html[lang^="zh"] .midterm-map__legend,
html[lang^="zh"] .midterm-map__detail,
html[lang^="zh"] .pack-crack__instruction,
html[lang^="zh"] .pack-crack__panel,
html[lang^="zh"] .math-step p,
html[lang^="zh"] .court-event__summary,
html[lang^="zh"] .ma-panel p,
html[lang^="zh"] .rcv-controls p,
html[lang^="zh"] .rcv-controls h3,
html[lang^="zh"] .rcv-output,
html[lang^="zh"] .shape-card__nick,
html[lang^="zh"] .shape-card__note { font-family: var(--zh-sans); }

/* tabular figures for charts and tabular numerals */
.figures-tabular, .pc-stat-value, .court-event__year { font-variant-numeric: lining-nums tabular-nums; }

a {
  color: var(--uw-purple);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}
a:hover { border-bottom-color: var(--uw-gold); }

:focus-visible {
  outline: 2px solid var(--uw-purple);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  transform: translateY(-220%);
  background: var(--uw-purple);
  color: var(--bg-card);
  border: 1px solid var(--uw-purple-deep);
  border-radius: 2px;
  padding: 0.45rem 0.7rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: transform 0.18s ease;
}
.skip-link:focus-visible {
  transform: translateY(0);
  border-bottom-color: var(--uw-purple-deep);
}

em { font-style: italic; }
strong { font-weight: 600; }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.012em;
  color: var(--ink);
  font-variation-settings: "opsz" 36, "SOFT" 50;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--rule);
}
.site-header__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.85rem var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.site-header__brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  border-bottom: 0;
}
.site-header__brand:hover { border-bottom: 0; }

.site-header__logo {
  width: 2.4rem;
  height: 2.4rem;
  display: block;
  overflow: visible;
  --c-humanistic: #4A2F82;
  --c-geoai: #B5A57B;
  --c-fake: #D9D9D9;
  animation: logo-sway 14s ease-in-out infinite;
}
.site-header__logo .brand-bar { transform-box: fill-box; transform-origin: center center; }
.site-header__logo .brand-bar-humanistic { fill: var(--c-humanistic); stroke: var(--c-humanistic); }
.site-header__logo .brand-bar-geoai      { fill: var(--c-geoai);      stroke: var(--c-geoai); }
.site-header__logo .brand-bar-fake       { fill: var(--c-fake);       stroke: #b3b3b3; }
@keyframes logo-sway {
  0%, 100% { transform: rotate(-1.5deg); }
  50%      { transform: rotate(1.5deg);  }
}
.site-header__brand:hover .site-header__logo {
  animation: logo-spin 6s linear infinite;
  filter: drop-shadow(0 1px 4px rgba(50, 42, 38, 0.15));
}
@keyframes logo-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.site-header__wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.site-header__title {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
}
html[lang^="zh"] .site-header__title { font-family: var(--zh); }
.site-header__lab {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 2px;
}
html[lang^="zh"] .site-header__lab { font-family: var(--zh-sans); text-transform: none; letter-spacing: 0.04em; }

.site-header__nav {
  display: flex;
  gap: 1rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
}
.site-header__nav a {
  color: var(--ink);
  border: none;
  border-bottom: 1px solid transparent;
  padding: 0.25rem 0.1rem;
}
.site-header__nav a:hover,
.site-header__nav a.is-active {
  color: var(--uw-purple);
  border-bottom-color: var(--uw-gold);
}

.site-header__menu-btn {
  display: none;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
}
.site-header__menu-btn:hover {
  border-color: var(--uw-purple-soft);
  color: var(--uw-purple);
}

.site-header__lang {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.site-header__lang button {
  background: transparent;
  color: var(--ink-faint);
  border: none;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  padding: 2px 4px;
  font: inherit;
}
.site-header__lang button:hover { color: var(--uw-purple); }
.site-header__lang button.is-active { color: var(--uw-purple); border-bottom-color: var(--uw-gold); }
.site-header__lang-sep { color: var(--ink-faint); }

/* gold rule under header (HGIS motif) */
.site-header__rule {
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--uw-gold) 20%, var(--uw-gold) 80%, transparent 100%);
  opacity: 0.55;
}

.reading-progress {
  height: 2px;
  background: transparent;
}
.reading-progress__bar {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--uw-gold) 0%, var(--uw-purple) 100%);
  transition: width 0.15s ease;
}

/* ---------- Hero ---------- */
.hero {
  min-height: 92vh;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--rule);
  padding: 6rem var(--pad) 4rem;
}
.hero__inner {
  max-width: var(--measure);
  margin: 0 auto;
}
.hero__kicker {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--uw-gold);
  margin: 0 0 2rem;
}
.hero__kicker::after {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 1px;
  background: var(--uw-gold);
  vertical-align: middle;
  margin-left: 0.6rem;
}
.hero__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(3rem, 11vw, 7.5rem);
  line-height: 0.95;
  letter-spacing: -0.022em;
  margin: 0 0 2rem;
  font-variation-settings: "opsz" 96, "SOFT" 50;
}
html[lang^="zh"] .hero__title { font-family: var(--zh); letter-spacing: 0.04em; }
.hero__title em {
  font-family: var(--display);
  font-style: italic;
  color: var(--uw-purple);
  font-weight: 400;
}
html[lang^="zh"] .hero__title em { font-family: var(--zh); color: var(--uw-purple); font-style: normal; font-weight: 600; }

.hero__sub {
  font-size: 1.12rem;
  line-height: 1.65;
  margin: 0 0 1.4rem;
  color: var(--ink-soft);
  max-width: 34rem;
}
html[lang^="zh"] .hero__sub { line-height: 1.85; }

.hero__cite {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-faint);
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  max-width: 34rem;
}
.hero__scroll {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 4rem 0 0;
  border-bottom: 1px solid transparent;
}
.hero__scroll:hover { border-bottom-color: var(--uw-gold); color: var(--uw-purple); }
html[lang^="zh"] .hero__scroll { letter-spacing: 0.3em; text-transform: none; }

/* ---------- Acts ---------- */
.act {
  padding: 6rem var(--pad);
  border-bottom: 1px solid var(--rule);
}
.act--pivot { background: var(--bg-card); }
.act--finale {
  background: #2c2823;
  color: #e9e2d4;
  border-bottom: none;
}
.act--finale .act__num { color: var(--uw-gold-soft); }
.act--finale .act__caption,
.act--finale .act__epilogue { color: #b8b09e; }
.act--finale .act__lede { color: #e9e2d4; }
.act--finale .act__title em,
.act--finale .act__epilogue h3 { color: var(--uw-gold-soft); }

.act__intro {
  max-width: var(--measure);
  margin: 0 auto 3.5rem;
}

.act-illustration {
  max-width: min(30rem, 88vw);
  margin: 0 auto 2.25rem;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 10px 22px rgba(68, 58, 50, 0.1);
}
.act-illustration img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 26rem;
  object-fit: contain;
  background: #efe7d9;
}
.act-illustration figcaption {
  margin: 0;
  padding: 0.6rem 0.85rem 0.7rem;
  font-family: var(--sans);
  font-size: 0.76rem;
  color: var(--ink-faint);
  border-top: 1px solid var(--rule);
}
html[lang^="zh"] .act-illustration figcaption { font-family: var(--zh-sans); }
.act__num {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--uw-gold);
  margin: 0 0 1rem;
}
.act__num::after {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 1px;
  background: var(--uw-gold);
  vertical-align: middle;
  margin-left: 0.6rem;
}
html[lang^="zh"] .act__num { letter-spacing: 0.12em; text-transform: none; }

.act__title {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.012em;
  margin: 0 0 1.5rem;
  font-variation-settings: "opsz" 48, "SOFT" 50;
}
html[lang^="zh"] .act__title { font-family: var(--zh); letter-spacing: 0.01em; }

.act__lede {
  font-size: 1.08rem;
  line-height: 1.7;
  color: var(--ink-soft);
  margin: 0 0 1.2rem;
}
html[lang^="zh"] .act__lede { line-height: 1.95; font-size: 1.05rem; }

.act--finale .act__lede { color: #d8d0bb; }

.act__caption {
  max-width: var(--measure);
  margin: 3rem auto 0;
  font-family: var(--display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-faint);
  text-align: center;
  line-height: 1.55;
}
html[lang^="zh"] .act__caption { font-family: var(--zh); font-style: normal; font-size: 1rem; }

.act__epilogue {
  max-width: var(--measure);
  margin: 4rem auto 0;
  padding-top: 2rem;
  border-top: 1px solid #4a3e3a;
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.7;
}
html[lang^="zh"] .act__epilogue { font-family: var(--zh-sans); }
.act__epilogue h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.1rem;
  margin: 0 0 1rem;
  font-variation-settings: "opsz" 24, "SOFT" 50;
}
html[lang^="zh"] .act__epilogue h3 { font-family: var(--zh); }
.act__epilogue ul { list-style: none; padding: 0; margin: 0; }
.act__epilogue li { padding: 0.7rem 0; border-bottom: 1px solid #3a322e; }
.act__epilogue li:last-child { border-bottom: none; }
.act__epilogue strong { color: #e9e2d4; font-weight: 600; }

/* ---------- Footer ---------- */
.site-footer {
  background: #1f1c18;
  color: #b8b09e;
  padding: 4rem var(--pad);
  position: relative;
}
.site-footer::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--uw-gold) 20%, var(--uw-gold) 80%, transparent 100%);
  opacity: 0.55;
}
.site-footer__inner {
  max-width: var(--measure);
  margin: 0 auto;
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.75;
}
html[lang^="zh"] .site-footer__inner { font-family: var(--zh-sans); }
.site-footer__credit {
  font-family: var(--serif);
  font-size: 1rem;
  color: #e9e2d4;
  margin: 0 0 2rem;
}
html[lang^="zh"] .site-footer__credit { font-family: var(--zh); }
.site-footer__sources {
  border-top: 1px solid #3a322e;
  padding-top: 1.5rem;
  margin: 0 0 1.5rem;
}
.site-footer__sources strong { color: #e9e2d4; font-weight: 600; }
.site-footer__caveat {
  font-style: italic;
  color: #98907f;
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid #3a322e;
}
.site-footer a { color: var(--uw-gold-soft); border-color: transparent; }
.site-footer a:hover { color: #e9e2d4; border-bottom-color: var(--uw-gold-soft); }

.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 95;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.46rem 0.78rem;
  cursor: pointer;
}
.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.back-to-top:hover {
  border-color: var(--uw-purple-soft);
  color: var(--uw-purple);
}

/* ---------- Buttons / chrome ---------- */
.btn {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink-soft);
  border-radius: 2px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--ink); color: var(--bg-card); border-color: var(--ink); }
.btn--accent {
  color: var(--uw-purple);
  border-color: var(--uw-purple);
}
.btn--accent:hover { background: var(--uw-purple); color: var(--bg-card); }

html[lang^="zh"] .btn { font-family: var(--zh-sans); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, .site-header__logo {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  body { font-size: 17px; }
  .site-header__inner { gap: 0.85rem; padding: 0.8rem 1.25rem; }
  .site-header__menu-btn { display: inline-flex; }
  .site-header__nav {
    display: none;
    width: 100%;
    gap: 0.45rem 0.8rem;
    font-size: 0.8rem;
    flex-wrap: wrap;
    justify-content: flex-start;
    border-top: 1px solid var(--rule);
    padding-top: 0.55rem;
  }
  .site-header.is-nav-open .site-header__nav { display: flex; }
  .site-header__lang { margin-left: auto; }
  .site-header__wordmark { display: none; }
  .hero { min-height: 80vh; padding-top: 4rem; }
  .act-illustration {
    max-width: 82vw;
    margin-bottom: 1.6rem;
  }
  .act-illustration img { max-height: 19rem; }
  .act { padding: 4rem var(--pad); }
  .back-to-top { right: 0.75rem; bottom: 0.75rem; }
}
