@import './charts/chart-common.css';
@import './charts/year-range-filter.css';
@import './charts/theme-river.css';
@import './charts/paper-force.css';
@import './charts/butterfly-path.css';
@import './charts/institution-map.css';
@import './charts/metro-map.css';

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-soft: #f8f8f6;
  --text: #2c2c2c;
  --text-secondary: #666666;
  --muted: #888888;
  --muted-strong: #555555;
  --line: #e8e6e0;
  --line-strong: #d4cfc4;
  --accent: #176b87;
  --accent-strong: #0f4c5c;
  --accent-soft: #f0f5f8;
  --warm: #c98f42;
  --warm-soft: #f9f6f0;
  --danger: #a63a2e;
  --canvas-bg: #fcfbf9;
  --shadow: 0 10px 30px rgba(15, 76, 92, 0.06);
  --card-shadow: 0 12px 36px rgba(15, 76, 92, 0.08);
  --elev-shadow-small: 0 4px 12px rgba(15, 76, 92, 0.04);

  --font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', 'Noto Sans SC', sans-serif;
  --font-weight-normal: 400;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --line-height-base: 1.58;
  --fs-100: 0.72rem;
  --fs-200: 0.78rem;
  --fs-250: 0.84rem;
  --fs-300: 0.88rem;
  --fs-400: 1rem;
  --fs-500: 1.08rem;
  --fs-600: 1.24rem;
  --fs-700: 2.35rem;
  --fs-700-mobile: 1.42rem;

  --space-0: 0;
  --space-1: 4px;
  --space-2: 6px;
  --space-3: 10px;
  --space-4: 14px;
  --space-5: 18px;
  --space-6: 22px;
  --space-7: 26px;
  --space-8: 30px;
  --space-9: 36px;
  --space-10: 44px;
  --space-11: 56px;

  --container-max-width: 1200px;
  --canvas-min-height: 300px;
  --border-width: 0.5px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: var(--space-0);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family-base);
  line-height: var(--line-height-base);
  font-weight: var(--font-weight-normal);
  font-size: var(--fs-400);
}

h1,
h2,
h3,
p {
  margin: var(--space-0);
}

h1 {
  font-weight: var(--font-weight-bold);
  color: var(--text);
}

h2 {
  font-weight: var(--font-weight-bold);
  color: var(--text);
}

h3 {
  font-weight: var(--font-weight-semibold);
  color: var(--text);
}

code {
  padding: 2px 6px;
  border: var(--border-width) solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: var(--fs-300);
}

.page {
  max-width: var(--container-max-width);
  margin: var(--space-0) auto;
  padding: var(--space-0) var(--space-7) var(--space-10);
}

.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: var(--space-7);
  align-items: center;
  /* Full-bleed: break out of .page max-width */
  width: 100vw;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-6) max(var(--space-7), calc((100vw - var(--container-max-width)) / 2 + var(--space-7)));
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: var(--space-8);
}

.eyebrow,
.section-kicker,
.module-tag,
.hero-timeline__eyebrow {
  color: var(--accent);
  font-size: var(--fs-100);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.site-header h1 {
  max-width: 820px;
  margin-top: var(--space-2);
  font-size: var(--fs-700);
  line-height: 1.08;
  font-weight: var(--font-weight-bold);
  color: var(--text);
}

.site-subtitle {
  max-width: 760px;
  margin-top: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--fs-300);
  line-height: 1.58;
}

.hero-timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.hero-timeline__head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hero-timeline__hint {
  color: var(--text-secondary);
  font-size: var(--fs-200);
}

.hero-timeline__hint a {
  color: var(--accent);
  text-decoration: none;
}

.hero-timeline__hint a:hover,
.hero-timeline__hint a:focus-visible {
  text-decoration: underline;
}

.hero-timeline__mount {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.llm-mini-timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.llm-mini-timeline__canvas {
  width: 100%;
  max-height: 180px;
}

.llm-mini-timeline__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.llm-mini-timeline__grid {
  stroke: var(--line);
  stroke-width: 1;
  opacity: 0.45;
}

.llm-mini-timeline__grid.is-major {
  opacity: 0.75;
}

.llm-mini-timeline__year-label {
  fill: var(--muted);
  font-size: 9px;
  font-family: var(--font-family-base);
}

.llm-mini-timeline__link {
  fill: none;
  stroke-width: 1;
  stroke-opacity: 0.35;
  transition: stroke-opacity 0.2s ease, stroke-width 0.2s ease;
}

.llm-mini-timeline__svg.has-selection .llm-mini-timeline__link {
  stroke-opacity: 0.08;
}

.llm-mini-timeline__link.is-highlighted {
  stroke-opacity: 0.95;
  stroke-width: 1.6;
}

.llm-mini-timeline__node {
  cursor: pointer;
}

.llm-mini-timeline__node-halo {
  opacity: 0;
  transition: opacity 0.18s ease;
}

.llm-mini-timeline__node-dot {
  stroke: #ffffff;
  stroke-width: 1;
  transition: r 0.18s ease, fill-opacity 0.18s ease;
}

.llm-mini-timeline__node:hover .llm-mini-timeline__node-halo,
.llm-mini-timeline__node.is-connected .llm-mini-timeline__node-halo {
  opacity: 0.25;
}

.llm-mini-timeline__node.is-selected .llm-mini-timeline__node-halo {
  opacity: 0.45;
}

.llm-mini-timeline__node.is-selected .llm-mini-timeline__node-dot {
  r: 4.6;
  stroke-width: 1.5;
}

.llm-mini-timeline__svg.has-selection .llm-mini-timeline__node-dot {
  fill-opacity: 0.25;
}

.llm-mini-timeline__svg.has-selection .llm-mini-timeline__node.is-selected .llm-mini-timeline__node-dot,
.llm-mini-timeline__svg.has-selection .llm-mini-timeline__node.is-connected .llm-mini-timeline__node-dot {
  fill-opacity: 1;
}

.llm-mini-timeline__detail {
  min-height: 48px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.llm-mini-timeline__detail.is-empty {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
  justify-content: center;
  align-items: flex-start;
  min-height: 36px;
}

.llm-mini-timeline__detail-hint {
  color: var(--muted);
  font-size: var(--fs-200);
}

.llm-mini-timeline__detail-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.llm-mini-timeline__detail-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.llm-mini-timeline__detail-title {
  font-size: var(--fs-300);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  line-height: 1.3;
}

.llm-mini-timeline__detail-meta {
  color: var(--text-secondary);
  font-size: var(--fs-100);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.llm-mini-timeline__detail-desc {
  color: var(--text-secondary);
  font-size: var(--fs-200);
  line-height: 1.5;
}

.llm-mini-timeline__detail-link {
  align-self: flex-start;
  font-size: var(--fs-200);
  color: var(--accent);
  text-decoration: none;
}

.llm-mini-timeline__detail-link:hover,
.llm-mini-timeline__detail-link:focus-visible {
  text-decoration: underline;
}

.story-nav {
  position: fixed;
  right: 0;
  top: 200px;
  z-index: 20;
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-right: none;
  border-radius: 8px 0 0 8px;
  box-shadow: -2px 4px 12px rgba(15, 76, 92, 0.08);
  transition: width 0.24s ease, padding 0.24s ease;
}

.story-nav.is-collapsed {
  width: 48px;
  padding: var(--space-3);
}

.story-nav.is-collapsed .nav-header,
.story-nav.is-collapsed .nav-focus-panel,
.story-nav.is-collapsed .nav-links-wrapper {
  display: none;
}

.nav-toggle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.nav-header {
  flex: 1;
  color: var(--accent);
  font-size: var(--fs-250);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  font-size: var(--fs-200);
  padding: 0;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  outline: none;
}

.toggle-icon {
  display: inline-block;
  font-size: var(--fs-500);
  line-height: 1;
}

.nav-focus-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
}

.nav-focus-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-focus-label {
  color: var(--accent);
  font-size: var(--fs-100);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.nav-focus-value {
  color: var(--text);
  font-size: var(--fs-250);
  font-weight: var(--font-weight-semibold);
  line-height: 1.3;
  word-break: break-word;
}

.nav-focus-paper {
  color: var(--text-secondary);
  font-size: var(--fs-200);
}

.nav-links-wrapper {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.nav-link {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.nav-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--fs-250);
  font-weight: var(--font-weight-bold);
}

.nav-text {
  color: var(--text-secondary);
  font-size: var(--fs-250);
  line-height: 1.4;
}

.nav-link:hover,
.nav-link:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  outline: none;
}

.nav-link:hover .nav-marker,
.nav-link:focus-visible .nav-marker {
  background: var(--accent);
  color: #fff;
}

.nav-link:hover .nav-text,
.nav-link:focus-visible .nav-text {
  color: var(--text);
  font-weight: var(--font-weight-semibold);
}

.quick-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: var(--space-3) var(--space-2);
  box-shadow: none;
  backdrop-filter: none;
  margin-bottom: var(--space-6);
}

.quick-nav a {
  border-radius: 999px;
  color: var(--accent-strong);
  padding: calc(var(--space-1) + 2px) var(--space-4);
  text-decoration: none;
  font-size: var(--fs-300);
  font-weight: var(--font-weight-semibold);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.18s ease;
}

.quick-nav a:hover,
.quick-nav a:focus-visible {
  background: var(--accent-soft);
  color: #fff;
  border-color: var(--accent);
  background-image: linear-gradient(90deg, var(--accent), var(--accent-strong));
  box-shadow: 0 2px 8px rgba(23, 107, 135, 0.12);
  outline: none;
}

.story-intro,
.story-section {
  margin-top: var(--space-8);
}

.story-intro {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  align-items: start;
  padding: var(--space-5) 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin-bottom: var(--space-6);
}

.story-intro h2,
.story-section h2 {
  font-size: var(--fs-600);
  font-weight: var(--font-weight-bold);
  color: var(--text);
}

.story-intro p,
.section-note {
  color: var(--text-secondary);
  font-size: var(--fs-300);
}

.story-intro p {
  margin-top: var(--space-2);
}

.insight-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.insight-strip article,
.method-grid article,
.story-section {
  border: none;
  border-radius: 0;
  background: transparent;
}

.insight-strip article {
  min-height: auto;
  padding: var(--space-3) 0;
  box-shadow: none;
  transition: none;
}

.insight-strip article:hover {
  box-shadow: none;
  border-color: transparent;
}

.insight-strip span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: var(--warm-soft);
  color: var(--warm);
  font-size: var(--fs-200);
  font-weight: var(--font-weight-bold);
}

.insight-strip p {
  margin-top: var(--space-3);
  color: var(--text-secondary);
  font-size: var(--fs-300);
  line-height: 1.58;
}

.story-section {
  padding: var(--space-6) 0 0;
  box-shadow: none;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: grid;
  gap: var(--space-1);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  margin-top: var(--space-1);
}

.module-slot {
  margin-top: var(--space-4);
}

.module-shell {
  display: grid;
  gap: var(--space-4);
}

.module-title {
  font-size: var(--fs-500);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
}

.module-subtitle {
  color: var(--text-secondary);
  font-size: var(--fs-300);
  line-height: 1.5;
}

.module-canvas {
  min-height: var(--canvas-min-height);
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-300);
  padding: var(--space-2) 0;
  box-shadow: none;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: var(--border-width) solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-300);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.legend-chip:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.module-notes {
  margin: var(--space-2) var(--space-0) var(--space-0);
  padding-left: var(--space-6);
  color: var(--text-secondary);
  font-size: var(--fs-300);
  line-height: 1.5;
}

.method-section {
  background: var(--bg);
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-6);
}

.method-grid article {
  padding: var(--space-4);
  box-shadow: none;
  transition: none;
  border-top: 1px solid var(--line);
}

.method-grid article:first-child {
  border-top: none;
}

/* add vertical separators between columns (not the first column) */
.method-grid article:not(:nth-child(3n+1)) {
  border-left: 1px solid var(--line);
  padding-left: calc(var(--space-4));
}

/* ensure responsive small screens don't keep left borders for single-column */
@media (max-width: 900px) {
  .method-grid article:not(:nth-child(3n+1)) {
    border-left: none;
    padding-left: var(--space-4);
  }
}

.method-grid article:hover {
  box-shadow: none;
  border-color: transparent;
}

.method-grid h3 {
  font-size: var(--fs-400);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
}

.method-grid p {
  margin-top: var(--space-3);
  color: var(--text-secondary);
  font-size: var(--fs-300);
  line-height: 1.58;
}

@media (max-width: 900px) {
  .site-header {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }

  .story-intro {
    grid-template-columns: 1fr;
  }

  .method-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .insight-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-timeline {
    max-width: none;
  }

  .story-nav {
    position: sticky;
    top: 0;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: var(--space-6);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--elev-shadow-small);
  }

  .story-nav.is-collapsed {
    width: 48px;
    margin-left: auto;
  }

  .nav-toggle-header {
    min-width: 100%;
  }

  .story-nav.is-collapsed .nav-toggle-header {
    min-width: 0;
  }

  .nav-focus-panel {
    flex: 1 1 220px;
  }

  .nav-links-wrapper {
    flex: 2 1 340px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page {
    padding: var(--space-7) var(--space-4) var(--space-9);
  }

  .site-header {
    gap: var(--space-4);
    margin-bottom: var(--space-7);
  }

  .site-header h1 {
    font-size: var(--fs-700-mobile);
  }

  .site-subtitle {
    font-size: var(--fs-300);
  }

  .quick-nav {
    position: static;
    gap: var(--space-1);
    padding: var(--space-3);
    margin-bottom: var(--space-7);
  }

  .quick-nav a {
    padding: var(--space-2) var(--space-2);
    font-size: var(--fs-300);
  }

  .story-intro {
    padding: var(--space-5);
    margin-bottom: var(--space-7);
  }

  .story-section {
    padding: var(--space-7);
    box-shadow: var(--elev-shadow-small);
  }

  .nav-links-wrapper {
    grid-template-columns: 1fr;
  }

  .insight-strip {
    grid-template-columns: 1fr;
  }

  .method-grid {
    grid-template-columns: 1fr;
  }

  .method-grid article {
    padding: var(--space-5);
  }
}
