/* App shell: header + view container. Atlas view is a 3-zone grid that
   collapses gracefully on narrow viewports. */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--header-h);
  padding: 0 1rem;
  background: var(--bg);   /* one surface with the page; the hairline marks the edge */
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.brand-glyph { height: 1.85rem; width: auto; flex: none; display: block; }
.brand .mark {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  padding-left: 0.55rem;
  border-left: 1px solid var(--line);
}
.brand .subtitle {
  font-size: 0.78rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-nav { display: flex; gap: 0.15rem; margin-left: auto; }
.mode-nav a {
  padding: 0.42rem 0.8rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.9rem;
}
.mode-nav a[aria-current="page"] {
  background: var(--bg-inset);
  color: var(--ink);
  font-weight: 600;
}
.mode-nav a:hover { color: var(--ink); }


main { min-height: calc(100vh - var(--header-h)); }
.view[hidden] { display: none; }

/* ---- Orientation (scrollytelling) ---- */
.orient {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.25rem 5rem;
}
.orient .scene { margin-bottom: 3.5rem; }
.orient .scene-kicker {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.4rem;
}
.orient h2 { font-size: 1.7rem; }
.orient .lede { font-size: 1.08rem; color: var(--ink-soft); }
.orient .thesis {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  line-height: 1.4;
  border-left: 3px solid var(--economic);
  padding: 0.4rem 0 0.4rem 1.2rem;
  margin: 1.6rem 0;
}
.orient .thesis small { display: block; font-family: var(--font-sans); margin-top: 0.5rem; }

/* Opening scene: editorial two-column hero (copy + five-panel illustration) */
.orient .scene-hero {
  display: grid;
  grid-template-columns: 38% 62%;
  gap: clamp(1.5rem, 3vw, 3rem);
  align-items: center;
  min-height: min(68vh, 600px);
  /* break out of the 720px reading column so the hero has room (max ~1200) */
  width: min(1200px, 92vw);
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 2rem;
}
.scene-hero .hero-copy { min-width: 0; }
.hero-headline { font-size: clamp(1.9rem, 3.7vw, 3rem); line-height: 1.05; letter-spacing: -0.015em; text-wrap: balance; }
.scene-hero .lede { max-width: 34ch; }
.hero-purpose { max-width: 46ch; font-size: 0.92rem; color: var(--ink-soft); margin: 0.6rem 0 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.7rem; }
.btn-hero {
  font: inherit; font-size: 0.95rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.62rem 1.15rem; border-radius: var(--radius);
  border: 1px solid transparent; text-decoration: none;
  min-height: 44px; /* touch target */
}
.btn-hero-primary { background: var(--ink); color: var(--bg); }
.btn-hero-primary:hover { background: var(--ink-soft); }
.btn-hero-secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-hero-secondary:hover { background: var(--bg-inset); }

/* Five-panel illustration (art only; all text is live HTML below) */
.hero-art { min-width: 0; }
.hero-art picture { display: block; }
.hero-art img {
  display: block; width: 100%; height: auto; max-width: 100%;
  object-fit: contain;
}
/* Dark mode: rest the light artwork on a restrained warm surface (no stark box) */
[data-theme="dark"] .hero-art {
  background: radial-gradient(120% 120% at 50% 40%, rgba(247,242,232,0.07), rgba(247,242,232,0) 72%);
  border-radius: calc(var(--radius) * 1.6);
  padding: clamp(0.5rem, 1.6vw, 1.2rem);
}

/* Live Five Orders key — accessible HTML; five equal categorical colors (not a scale) */
.orders-key {
  list-style: none; margin: 0 auto 2.4rem; padding: 0;
  width: min(1200px, 92vw);
  position: relative; left: 50%; transform: translateX(-50%);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1.4rem;
}
.orders-key li { border-top: 3px solid var(--sw, var(--line)); padding-top: 0.7rem; min-width: 0; }
.orders-key .dot { display: none; }
.orders-key .ok-label { display: block; font-weight: 700; font-size: 0.92rem; color: var(--ink); margin-bottom: 0.28rem; }
.orders-key .ok-desc { display: block; font-size: 0.82rem; line-height: 1.4; color: var(--ink-soft); }
.orders-key .k-formal { --sw: var(--brand-formal); }
.orders-key .k-institutional { --sw: var(--brand-institutional); }
.orders-key .k-economic { --sw: var(--brand-economic); }
.orders-key .k-relational { --sw: var(--brand-relational); }
.orders-key .k-civic { --sw: var(--brand-civic); }

/* Lead statement directly below the hero */
.scene-lead { text-align: center; }
.lead-statement {
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 2.6vw, 2rem);
  line-height: 1.3; max-width: 22ch; margin: 0 auto; text-wrap: balance;
}
.lead-statement span { color: var(--ink-soft); }
/* the one sentence that states the project's epistemology (Scene 10) */
.orient .epistemic {
  font-family: var(--font-serif); font-size: clamp(1.15rem, 1.9vw, 1.45rem); line-height: 1.35;
  margin: 1.2rem 0; padding: 0.2rem 0 0.2rem 1rem; border-left: 3px solid var(--relational);
}
.orient .epistemic span { color: var(--ink-soft); }

@media (max-width: 820px) {
  .orient .scene-hero {
    grid-template-columns: 1fr; gap: 1.4rem; min-height: 0;
    width: auto; left: auto; transform: none;
  }
  /* DOM order already gives: eyebrow → headline → copy → actions → illustration */
  .orders-key {
    width: auto; left: auto; transform: none;
    gap: 1rem 1.4rem;
  }
}

/* ---- Atlas ---- */
.atlas {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 360px;
  height: calc(100vh - var(--header-h));
}
.atlas-side {
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 1rem;
}
.atlas-profile {
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 1rem;
}
.atlas-map-wrap { position: relative; min-height: 320px; }
#map { position: absolute; inset: 0; }

.map-legend {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  z-index: 10;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.6rem 0.8rem;
  font-size: 0.78rem;
  max-width: 260px;
}
.map-presets {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-width: calc(100% - 5rem);
}

/* ---- Compare / Relationships ---- */
.page-pane {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1rem;
}
.explore-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1.5rem;
  margin-top: 1rem;
}
.chart-box {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1rem;
  position: relative;
  min-height: 380px;
}

/* ---- Responsive ---- */
@media (max-width: 1080px) {
  .atlas { grid-template-columns: 260px minmax(0, 1fr); }
  .atlas-profile {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 45vh;
  }
  .atlas { grid-template-rows: minmax(0, 1fr) auto; }
}
/* Tablet: the full subtitle + wrapping button labels overflow the fixed-
   height header well above the phone breakpoint — keep actions on one line
   and drop the subtitle first. */
@media (max-width: 980px) {
  .brand .subtitle { display: none; }
}
@media (max-width: 720px) {
  .app-header { flex-wrap: wrap; height: auto; padding: 0.5rem 0.75rem; row-gap: 0.3rem; }
  .mode-nav { order: 3; width: 100%; overflow-x: auto; }
  /* 44px touch targets for header and footer controls on narrow screens */
  .footer-actions .btn { min-height: 44px; }
  .mode-nav a { min-height: 44px; display: inline-flex; align-items: center; }
  main { min-height: 0; }
  .atlas {
    display: flex;
    flex-direction: column;
    height: auto;
  }
  .atlas-side { border-right: 0; border-bottom: 1px solid var(--line); max-height: none; overflow: visible; }
  .atlas-map-wrap { height: 58vh; }
  .atlas-profile { max-height: none; overflow: visible; border-top: 1px solid var(--line); }
  .compare-grid, .explore-grid { grid-template-columns: 1fr; }
}
.view:focus { outline: none; }   /* programmatic focus on a view switch */

/* Footer: site tools (methods, copy link, theme) above the credits. */
.app-footer {
  border-top: 1px solid var(--line);
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
}
.footer-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; flex-basis: 100%; }
.footer-actions .btn { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.footer-actions svg { width: 1em; height: 1em; }
