/* ==========================================================================
   Dantong Xue — Cartographic Frontier Theme
   Default: Light ("Editorial Atlas") | Toggle: Dark ("Night Cartography")
   ========================================================================== */

:root {
  /* Light theme — Editorial Atlas (default) */
  --bg: #fafbfd;
  --bg-elevated: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-code: #0f172a;
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --accent: #0284c7;
  --accent-soft: rgba(2, 132, 199, 0.1);
  --accent-2: #059669;
  --accent-2-soft: rgba(5, 150, 105, 0.1);
  --grid-line: rgba(15, 23, 42, 0.045);
  --contour-stroke: rgba(2, 132, 199, 0.16);
  --contour-stroke-2: rgba(15, 23, 42, 0.07);
  --map-land: #e8eef5;
  --map-land-stroke: #cbd5e1;
  --map-road: rgba(15, 23, 42, 0.09);
  --map-road-major: rgba(15, 23, 42, 0.16);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 30px -12px rgba(15, 23, 42, 0.1);
  --hud-bg: rgba(255, 255, 255, 0.86);
  --header-bg: rgba(250, 251, 253, 0.82);

  --font-display: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --max-w: 1080px;
}

[data-theme="dark"] {
  --bg: #080c12;
  --bg-elevated: #0f1621;
  --bg-subtle: #141e2c;
  --bg-code: #05080d;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --border: rgba(241, 245, 249, 0.09);
  --border-strong: rgba(241, 245, 249, 0.18);
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --accent-2: #34d399;
  --accent-2-soft: rgba(52, 211, 153, 0.12);
  --grid-line: rgba(148, 163, 184, 0.06);
  --contour-stroke: rgba(56, 189, 248, 0.18);
  --contour-stroke-2: rgba(148, 163, 184, 0.08);
  --map-land: #131d2b;
  --map-land-stroke: #243449;
  --map-road: rgba(148, 163, 184, 0.1);
  --map-road-major: rgba(148, 163, 184, 0.2);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 14px 36px -14px rgba(0, 0, 0, 0.55);
  --hud-bg: rgba(15, 22, 33, 0.84);
  --header-bg: rgba(8, 12, 18, 0.8);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background-color 0.25s ease, color 0.25s ease;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

.mono {
  font-family: var(--font-mono);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 4px var(--accent-2-soft);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.nav-links a {
  transition: color 0.18s ease;
}

.nav-links a:hover {
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, transform 0.15s ease, background-color 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle svg {
  width: 15px;
  height: 15px;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 92px 0 84px;
  border-bottom: 1px solid var(--border);
}

#topo-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.95;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 760px;
}

.coord-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.coord-pill .pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  animation: pulse 2.2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(5, 150, 105, 0); }
  100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5.5vw, 4.1rem);
  line-height: 1.06;
  letter-spacing: -0.035em;
  margin: 0 0 20px;
  font-weight: 700;
}

.hero-lead {
  font-size: clamp(1.06rem, 1.8vw, 1.24rem);
  color: var(--text-muted);
  margin: 0 0 14px;
  max-width: 650px;
}

.hero-sub {
  font-size: 0.96rem;
  color: var(--text-faint);
  margin: 0 0 32px;
  max-width: 600px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  border-color: var(--accent);
}

/* ---------- Sections ---------- */
.section {
  padding: 84px 0;
  border-bottom: 1px solid var(--border);
}

.section-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 40px;
  max-width: 680px;
}

.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  letter-spacing: -0.025em;
  line-height: 1.18;
  margin: 0;
}

.section-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.98rem;
}

/* ---------- Interactive MCP Grounding Demo ---------- */
.demo-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.demo-tab {
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.18s ease;
}

.demo-tab:hover {
  border-color: var(--accent);
  color: var(--text);
}

.demo-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.demo-shell {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 20px;
  align-items: stretch;
}

.demo-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-2-soft);
  color: var(--accent-2);
  font-weight: 500;
}

.demo-prompt-box {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.94rem;
}

.demo-prompt-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.demo-code {
  margin: 0;
  padding: 16px 18px;
  background: var(--bg-code);
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.55;
  overflow-x: auto;
  flex: 1;
}

.demo-summary {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 0.88rem;
  color: var(--text);
}

.demo-map-wrap {
  position: relative;
  flex: 1;
  min-height: 300px;
  background: var(--bg);
}

.demo-map-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.route-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 420;
  stroke-dashoffset: 420;
  animation: drawRoute 1.1s ease forwards;
}

@keyframes drawRoute {
  to {
    stroke-dashoffset: 0;
  }
}

.demo-map-legend {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.legend-chip.active {
  border-color: var(--accent);
  color: var(--text);
}

/* ---------- Launches Grid ---------- */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
}

.card h3 {
  font-family: var(--font-display);
  font-size: 1.18rem;
  margin: 0;
  letter-spacing: -0.015em;
}

.card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.93rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: auto;
  padding-top: 6px;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 6px;
}

.media-strip {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  margin-top: 4px;
}

.card-link:hover {
  text-decoration: underline;
}

/* ---------- Waypoints Timeline ---------- */
.timeline {
  position: relative;
  padding-left: 32px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--border-strong));
}

.waypoint {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}

.waypoint::before {
  content: "";
  position: absolute;
  left: -30px;
  top: 26px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.waypoint-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.waypoint-role {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
}

.waypoint-org {
  color: var(--accent);
  font-weight: 500;
}

.waypoint-period {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-faint);
}

.waypoint-loc {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.waypoint p {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.94rem;
}

.pub-callout {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-2);
}

.pub-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.pub-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  display: block;
}

.pub-title:hover {
  color: var(--accent);
}

/* ---------- Field Notes: Travel & Photography Atlas ---------- */
.atlas-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.atlas-map-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 960 / 340;
  min-height: 220px;
  background: var(--bg);
}

.atlas-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.atlas-pin {
  cursor: pointer;
}

.atlas-pin circle.pin-ring {
  fill: var(--accent-soft);
  transition: r 0.2s ease, fill 0.2s ease;
}

.atlas-pin circle.pin-dot {
  fill: var(--accent);
  stroke: var(--bg-elevated);
  stroke-width: 2;
  transition: transform 0.2s ease, fill 0.2s ease;
}

.atlas-pin.active circle.pin-dot {
  fill: var(--accent-2);
}

.atlas-pin.active circle.pin-ring {
  fill: var(--accent-2-soft);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.photo-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.photo-card:hover,
.photo-card.active {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.photo-frame {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: 14px;
  color: #ffffff;
}

.photo-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-frame-overlay {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.photo-body {
  padding: 16px 18px;
}

.photo-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.photo-body h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0;
}

.photo-region {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-faint);
}

.photo-body p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ---------- Floating Coordinate HUD ---------- */
.coord-hud {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--hud-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
  box-shadow: var(--shadow-md);
}

.hud-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 48px 0 72px;
  font-size: 0.88rem;
  color: var(--text-faint);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a:hover {
  color: var(--text);
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .demo-shell,
  .bento-grid,
  .media-strip,
  .photo-grid {
    grid-template-columns: 1fr;
  }

  .nav-links {
    display: none;
  }

  .hero {
    padding: 64px 0 56px;
  }

  .section {
    padding: 60px 0;
  }

  .coord-hud {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .route-path {
    animation: none;
    stroke-dashoffset: 0;
  }
  .coord-pill .pulse {
    animation: none;
  }
}
