/* Sangam Atlas mockup. Tokens first, then layout, then components, then views. */

/* Fonts are loaded from index.html with preconnect, not @import. */

:root {
  /* Warm paper neutrals, oklch hue ~80, low chroma */
  --bg: oklch(0.975 0.008 80);
  --bg-sunk: oklch(0.955 0.010 80);
  --surface: oklch(0.99 0.005 85);
  --surface-2: oklch(0.965 0.009 80);
  --line: oklch(0.88 0.012 80);
  --line-strong: oklch(0.78 0.015 75);
  --ink: oklch(0.24 0.015 60);
  --ink-2: oklch(0.45 0.015 60);
  --ink-3: oklch(0.53 0.012 60);
  --accent: oklch(0.46 0.12 28);          /* madder red, desaturated */
  --accent-ink: oklch(0.98 0.01 80);
  --accent-soft: oklch(0.46 0.12 28 / 0.12);
  --focus: oklch(0.46 0.12 28 / 0.35);

  /* map */
  --sea: oklch(0.905 0.028 220);
  --sea-deep: oklch(0.87 0.034 220);
  --land: oklch(0.972 0.012 85);
  --land-edge: oklch(0.70 0.02 70);
  --ghats: oklch(0.86 0.035 95);
  --hill: oklch(0.80 0.045 90);
  --river: oklch(0.62 0.05 220);
  --graticule: oklch(0.86 0.01 80);
  --palaeo: oklch(0.55 0.08 40);

  /* tinai, categorical, data only */
  --kurinci: #5f63b3; --mullai: #4f7f5a; --marutam: #a8893a; --neytal: #3b7f8c; --palai: #b0613a;

  --font-display: 'Fraunces', Georgia, serif;
  --font-ui: 'Instrument Sans', 'Helvetica Neue', sans-serif;
  --font-ta: 'Tiro Tamil', 'Noto Serif Tamil', serif;
  --font-ta-ui: 'Noto Sans Tamil', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --shadow-1: 0 1px 2px oklch(0.2 0.02 60 / 0.06), 0 1px 3px oklch(0.2 0.02 60 / 0.08);
  --shadow-2: 0 4px 12px oklch(0.2 0.02 60 / 0.10), 0 1px 3px oklch(0.2 0.02 60 / 0.08);
  --shadow-3: 0 12px 32px oklch(0.2 0.02 60 / 0.14), 0 2px 6px oklch(0.2 0.02 60 / 0.08);

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --t-micro: 120ms; --t-pop: 180ms; --t-panel: 240ms; --t-view: 280ms;

  --header-h: 60px;
  --rail-w: 272px;
  --panel-w: 376px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.17 0.008 60);
    --bg-sunk: oklch(0.15 0.008 60);
    --surface: oklch(0.21 0.009 60);
    --surface-2: oklch(0.25 0.010 60);
    --line: oklch(1 0 0 / 0.09);
    --line-strong: oklch(1 0 0 / 0.18);
    --ink: oklch(0.94 0.008 80);
    --ink-2: oklch(0.72 0.01 75);
    --ink-3: oklch(0.62 0.01 75);
    --accent: oklch(0.70 0.11 30);
    --accent-ink: oklch(0.17 0.01 60);
    --accent-soft: oklch(0.70 0.11 30 / 0.16);
    --focus: oklch(0.70 0.11 30 / 0.4);
    --sea: oklch(0.18 0.022 230);
    --sea-deep: oklch(0.16 0.024 230);
    --land: oklch(0.30 0.012 70);
    --land-edge: oklch(0.48 0.02 70);
    --ghats: oklch(0.34 0.03 90);
    --hill: oklch(0.40 0.04 90);
    --river: oklch(0.55 0.06 220);
    --graticule: oklch(1 0 0 / 0.05);
    --palaeo: oklch(0.72 0.08 45);
    --shadow-1: 0 0 0 1px oklch(1 0 0 / 0.06);
    --shadow-2: 0 0 0 1px oklch(1 0 0 / 0.08), 0 8px 24px oklch(0 0 0 / 0.4);
    --shadow-3: 0 0 0 1px oklch(1 0 0 / 0.1), 0 16px 40px oklch(0 0 0 / 0.5);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; overflow-x: hidden; }
body {
  margin: 0; min-height: 100dvh; overflow-x: hidden; background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: 15px; line-height: 1.5; font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
:lang(ta) { font-family: var(--font-ta); line-height: 1.75; overflow-wrap: anywhere; }
.ta-ui:lang(ta), .ta-ui { font-family: var(--font-ta-ui); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.02em; line-height: 1.12; text-wrap: balance; margin: 0; font-optical-sizing: auto; }
h1 { font-variation-settings: 'opsz' 144; }
h1 { font-size: clamp(2rem, 1rem + 3.4vw, 3.75rem); }
h2 { font-size: clamp(1.5rem, 1rem + 1.5vw, 2.25rem); }
h3 { font-size: 1.25rem; font-variation-settings: 'opsz' 24; }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--font-mono); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 0.8125rem; }
.label { font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: 12px; top: 12px; transform: translateY(-72px); background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: var(--r-sm); z-index: 100; transition: transform var(--t-micro) var(--ease-out); }
.skip:focus { transform: translateY(0); }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px;
  padding: 0 24px; background: color-mix(in oklab, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.wordmark { display: flex; align-items: baseline; gap: 12px; text-decoration: none; }
.wordmark .en { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; font-variation-settings: 'opsz' 24; }
.wordmark .ta { font-family: var(--font-ta-ui); font-size: 0.9375rem; color: var(--ink-2); }
.nav { display: flex; gap: 4px; justify-content: center; }
.nav a {
  text-decoration: none; padding: 8px 12px; border-radius: var(--r-sm); font-weight: 500; color: var(--ink-2);
  transition: background-color var(--t-micro) var(--ease-out), color var(--t-micro) var(--ease-out);
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }
.header-tools { display: flex; align-items: center; gap: 8px; }
.search {
  display: flex; align-items: center; gap: 8px; height: 40px; min-width: 260px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); color: var(--ink-2);
  transition: border-color var(--t-micro) var(--ease-out), box-shadow var(--t-micro) var(--ease-out);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.search .placeholder { flex: 1; text-align: left; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9375rem; }
.search kbd { font-family: var(--font-mono); font-size: 0.6875rem; border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 5px; color: var(--ink-3); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; height: 40px; }
.seg button { border: 0; background: transparent; padding: 0 12px; color: var(--ink-2); cursor: pointer; transition: background-color var(--t-micro) var(--ease-out), color var(--t-micro) var(--ease-out), transform 160ms var(--ease-out); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button:active { transform: scale(0.97); }

/* ---------- draft status ---------- */
.draft-chip { font: 600 0.625rem/1 var(--font-ui); letter-spacing: 0.1em; color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 3px 5px; margin-left: 4px; align-self: center; }
.status-strip { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; padding: 6px 16px; font-size: 0.8125rem; color: var(--ink-2); background: var(--bg-sunk); border-bottom: 1px solid var(--line); }
.status-strip strong { color: var(--accent); }
.status-strip a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.origins { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.origins .label { display: block; margin-bottom: 8px; }
.origins p { font-size: 0.875rem; color: var(--ink-2); }
.origins p + p { margin-top: 8px; }
.origins p[lang="ta"] { font-family: var(--font-ta); font-size: 0.9375rem; }
@media (max-width: 639px) { .status-strip { font-size: 0.75rem; gap: 8px; padding: 6px 12px; } .draft-chip { display: none; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 500; text-decoration: none;
  transition: transform 160ms var(--ease-out), background-color var(--t-micro) var(--ease-out), border-color var(--t-micro) var(--ease-out);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 90%, black); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.icon-btn { width: 40px; padding: 0; justify-content: center; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 0.8125rem; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background-color var(--t-micro) var(--ease-out), border-color var(--t-micro) var(--ease-out), transform 160ms var(--ease-out);
}
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--ink-3)); }
.chip svg { width: 14px; height: 14px; }
@media (pointer: coarse) { .chip { height: 36px; padding: 0 12px; } }
.chip[aria-pressed="true"] .dot { outline: 2px solid var(--bg); }
.chip.static { cursor: default; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; padding: 2px 8px 2px 5px; border-radius: 999px; white-space: nowrap; }
.badge svg { width: 14px; height: 14px; }
.badge-certain { background: oklch(0.92 0.05 150); color: oklch(0.32 0.08 150); }
.badge-less { background: oklch(0.93 0.06 85); color: oklch(0.38 0.09 70); }
.badge-uncertain { background: oklch(0.93 0.03 30); color: oklch(0.40 0.10 30); }
.badge-unlocated { background: var(--surface-2); color: var(--ink-2); border: 1px dashed var(--line-strong); }
@media (prefers-color-scheme: dark) {
  .badge-certain { background: oklch(0.32 0.06 150); color: oklch(0.9 0.06 150); }
  .badge-less { background: oklch(0.36 0.07 80); color: oklch(0.92 0.07 85); }
  .badge-uncertain { background: oklch(0.34 0.07 30); color: oklch(0.92 0.05 30); }
}

/* ---------- layout ---------- */
.view { display: none; }
.view.is-active { display: block; animation: view-in var(--t-view) var(--ease-out) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.stack > * + * { margin-top: var(--gap, 16px); }

/* ---------- map ---------- */
.map {
  position: relative; background: var(--sea); overflow: hidden; border-radius: var(--r-lg); isolation: isolate;
  background-image: radial-gradient(120% 80% at 70% 30%, var(--sea) 0%, var(--sea-deep) 100%);
  touch-action: none; user-select: none;
}
.map svg { width: 100%; height: 100%; display: block; cursor: grab; }
.map.is-dragging svg { cursor: grabbing; }
.map .land { fill: var(--land); stroke: var(--land-edge); stroke-width: 0.6; vector-effect: non-scaling-stroke; }
.map .coast-glow { fill: none; stroke: var(--sea-deep); stroke-width: 7; vector-effect: non-scaling-stroke; opacity: 0.7; filter: blur(2.5px); }
.map .ghats { fill: var(--ghats); opacity: 0.9; }
.map .hill { fill: var(--hill); opacity: 0.55; }
.map .river { fill: none; stroke: var(--river); stroke-width: 1.1; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; opacity: 0.9; }
.map .river.minor { stroke-width: 0.7; opacity: 0.7; }
.map .lake { fill: var(--sea); stroke: var(--river); stroke-width: 0.5; vector-effect: non-scaling-stroke; }
.map .graticule { fill: none; stroke: var(--ink-3); stroke-width: 0.35; vector-effect: non-scaling-stroke; opacity: 0.35; }
.map .river-label { font-family: var(--font-ui); font-style: italic; font-size: 9.5px; fill: var(--river); letter-spacing: 0.04em; paint-order: stroke; stroke: var(--land); stroke-width: 2.5px; }
.map .palaeo-band { stroke: var(--palaeo); stroke-width: 0.8; vector-effect: non-scaling-stroke; opacity: 0.6; }
.map .palaeo-label { font-family: var(--font-ui); font-size: 7px; fill: var(--palaeo); font-style: italic; }
.map .leader { stroke: var(--accent); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: 0.6; }
.map .marker.nonpoint text.nonpoint-ta { font-size: 10.5px; fill: var(--ink-2); }
.map .marker.nonpoint text.nonpoint-iso { font-family: var(--font-ui); font-size: 8.5px; letter-spacing: 0.18em; fill: var(--ink-3); font-style: italic; }
.map .marker { cursor: pointer; }
.map .marker .halo { fill: var(--accent); opacity: 0.12; transition: opacity var(--t-micro) var(--ease-out); pointer-events: none; }
.map .marker .hit { fill: transparent; }
.map .marker .precision { fill: none; stroke: var(--accent); stroke-width: 0.5; vector-effect: non-scaling-stroke; opacity: 0.3; pointer-events: none; }
.map .marker .core { fill: var(--accent); stroke: var(--bg); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.map .marker.less .core { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.map .marker.uncertain .core { fill: var(--bg); stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 2 2; }
.map .marker.anchor .core { fill: var(--ink-2); stroke: var(--bg); stroke-width: 1.4; }
.map .marker.anchor.pre .core { fill: var(--bg); stroke: var(--ink-2); stroke-dasharray: 2 1.5; }
.map .marker.hill.certain .core { fill: var(--hill); stroke: var(--accent); }
.map .marker.hill.less .core { fill: var(--bg); stroke: var(--accent); stroke-width: 1.8; }
.map .marker.hill.uncertain .core { fill: var(--bg); stroke: var(--accent); stroke-dasharray: 2 2; }
.map .marker:focus-visible { outline: none; }
.map .marker:focus-visible .core { stroke: var(--ink); stroke-width: 3; }
.map .marker:hover .halo, .map .marker.is-hot .halo { opacity: 0.32; }
.map .marker.is-selected .core { stroke: var(--ink); }
.map .marker text { pointer-events: none; font-family: var(--font-ta-ui); font-size: 11.5px; font-weight: 500; fill: var(--ink); paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.map .marker text.tier-1 { font-size: 13px; font-weight: 600; }
.map .marker text.tier-3 { font-size: 10.5px; font-weight: 400; }
.map .marker text.iso { font-family: var(--font-ui); font-size: 10.5px; fill: var(--ink-2); font-style: normal; }
.map .marker text { transition: opacity var(--t-micro) var(--ease-out); }
.map .marker.no-label text { opacity: 0; }
.map .candidate-link { stroke: var(--accent); stroke-width: 1.4; vector-effect: non-scaling-stroke; stroke-dasharray: 0 4; stroke-linecap: round; opacity: 0.8; fill: none; }
.map .route { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.map .route.ghost { opacity: 0.25; }
.map .route-stop { fill: var(--bg); stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.map .route-stop.done { fill: var(--accent); }
.map .route-head { fill: var(--accent); stroke: var(--bg); stroke-width: 2; vector-effect: non-scaling-stroke; }
.map .vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 60%, color-mix(in oklab, var(--sea-deep) 85%, black 6%) 100%); mix-blend-mode: multiply; opacity: 0.25; }
@media (prefers-color-scheme: dark) { .map .vignette { mix-blend-mode: normal; opacity: 0.7; } }
.map .grain { display: none; position: absolute; inset: 0; pointer-events: none; opacity: 0.35; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 0.08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) { .map .grain { mix-blend-mode: screen; opacity: 0.12; } }
.map-controls { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.map-controls .btn { width: 36px; height: 36px; padding: 0; justify-content: center; box-shadow: var(--shadow-1); }
.map-legend { position: absolute; left: 12px; bottom: 12px; z-index: 2; background: color-mix(in oklab, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-radius: var(--r-md); padding: 10px 12px; box-shadow: var(--shadow-1); display: grid; gap: 6px; font-size: 0.75rem; color: var(--ink-2); }
.map-legend .row { display: flex; align-items: center; gap: 8px; }
.map-legend svg { width: 16px; height: 16px; }
.map-attrib { position: absolute; right: 12px; top: 10px; z-index: 2; font-size: 0.6875rem; color: var(--ink-3); background: color-mix(in oklab, var(--surface) 80%, transparent); padding: 2px 8px; border-radius: 999px; }
.map-layers { position: absolute; left: 12px; top: 12px; z-index: 2; display: flex; gap: 6px; flex-wrap: wrap; max-width: 60%; }
.map-scale { position: absolute; left: 12px; bottom: 150px; z-index: 2; font: 500 10px var(--font-mono); color: var(--ink-2); display: grid; gap: 3px; }
.map-scale .bar { height: 4px; border: 1px solid var(--ink-2); border-top: 0; }
.map:not(.has-legend) .map-scale { bottom: 14px; left: 60px; }
.map-edge { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.map-edge span { position: absolute; font: 9px var(--font-mono); color: var(--ink-3); transform: translateX(-50%); }
.map-edge span[style*='right'] { transform: translateY(-50%); }

/* marker enter stagger: animated on the inner group only, so the outer positioning transform is untouched */
.map .marker .mk { opacity: 0; transform-box: fill-box; transform-origin: center; animation: marker-in 240ms var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 30ms); }
.map .marker .mk.live { animation: none; opacity: 1; }
@keyframes marker-in { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 48px; align-items: stretch; padding: 56px 0 40px; min-height: calc(100dvh - var(--header-h)); }
.hero-copy { display: flex; flex-direction: column; justify-content: center; gap: 24px; animation: rise var(--t-view) var(--ease-out) both; }
.hero-copy .eyebrow { display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: 0.875rem; }
.hero-copy .eyebrow .ta { font-family: var(--font-ta-ui); }
.hero-copy .lede { font-size: 1.125rem; color: var(--ink-2); max-width: 46ch; }
.hero-copy .ta-line { font-family: var(--font-ta); font-size: 1.375rem; color: var(--ink); line-height: 1.6; border-left: 2px solid var(--accent); padding-left: 16px; }
.hero-copy .ta-line small { display: block; font-family: var(--font-ui); font-size: 0.8125rem; color: var(--ink-3); margin-top: 6px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-map { min-height: 520px; box-shadow: var(--shadow-3); animation: rise var(--t-view) var(--ease-out) 80ms both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.ledger { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 24px 0 64px; }
.ledger > div { padding: 20px 16px 20px 0; border-right: 1px solid var(--line); animation: rise var(--t-view) var(--ease-out) both; animation-delay: calc(var(--i) * 40ms + 160ms); }
.ledger > div + div { padding-left: 16px; }
.ledger > div:last-child { border-right: 0; }
.ledger .big { font-family: var(--font-display); font-size: 2rem; font-variation-settings: 'opsz' 48; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.ledger .label { margin-top: 8px; display: block; }

.doors { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 48px; margin-bottom: 96px; align-items: start; }
.door-list { display: grid; gap: 0; border-top: 1px solid var(--line); }
.door { display: grid; grid-template-columns: 72px 1fr auto; gap: 20px; align-items: center; padding: 20px 0; border-bottom: 1px solid var(--line); text-decoration: none; transition: background-color var(--t-micro) var(--ease-out); position: relative; }
.door:hover { background: var(--surface-2); }
.door:active { transform: scale(0.995); transition: transform 160ms var(--ease-out); }
.door .ta { font-family: var(--font-ta-ui); color: var(--ink-3); font-size: 0.875rem; }
.door h3 { margin-bottom: 4px; }
.door .arrow { transition: transform var(--t-micro) var(--ease-out); color: var(--ink-3); }
.door:hover .arrow { transform: translateX(4px); color: var(--ink); }
.aside-note { background: var(--surface); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow-1); }
.aside-note h3 { margin-bottom: 12px; }
.aside-note ol { margin: 0; padding-left: 20px; color: var(--ink-2); }
.aside-note li + li { margin-top: 8px; }

.feature-poem { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; padding: 64px 0; border-top: 1px solid var(--line); margin-bottom: 64px; }
.feature-poem blockquote { margin: 0; font-family: var(--font-ta); font-size: 1.375rem; line-height: 1.75; }
.feature-poem blockquote .iso { display: block; font-family: var(--font-ui); font-style: italic; color: var(--ink-2); font-size: 0.9375rem; margin-top: 12px; line-height: 1.5; }
.feature-poem .toponym { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; text-decoration-color: color-mix(in oklab, var(--accent) 50%, transparent); }

/* ---------- explorer ---------- */
.explorer { display: grid; grid-template-columns: var(--rail-w) 1fr; height: calc(100dvh - var(--header-h)); }
.rail { border-right: 1px solid var(--line); overflow: auto; padding: 20px; background: var(--bg-sunk); }
.rail section + section { margin-top: 24px; }
.rail .label { display: block; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rail .list { display: grid; gap: 2px; }
.rail .list button { display: grid; grid-template-columns: 1fr auto; align-items: center; text-align: left; gap: 8px; height: 36px; padding: 0 10px; border: 0; background: transparent; border-radius: var(--r-sm); cursor: pointer; color: var(--ink); transition: background-color var(--t-micro) var(--ease-out); }
.rail .list button:hover { background: var(--surface-2); }
.rail .list button:active { transform: scale(0.99); }
.rail .list .glyph { display: inline-flex; width: 14px; height: 14px; flex-shrink: 0; }
.rail .list .glyph svg { width: 14px; height: 14px; }
.rail .anchors-note { font-size: 0.75rem; color: var(--ink-3); margin: 0 0 8px; }
.rail .list button[aria-current="true"] { background: var(--accent-soft); }
.rail .list .name { display: flex; align-items: baseline; gap: 8px; min-width: 0; overflow: hidden; }
.rail .list .name .ta { font-family: var(--font-ta-ui); font-size: 0.9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; max-width: 70%; }
.rail .list .name .iso { color: var(--ink-3); font-size: 0.8125rem; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail .list .count { font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-3); }
.rail .unlocated { padding: 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); color: var(--ink-2); font-size: 0.8125rem; }
.rail .unlocated strong { color: var(--ink); }
.stage { position: relative; min-width: 0; }
.stage .map { height: 100%; border-radius: 0; }
.panel {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: var(--panel-w); z-index: 5;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow: auto;
  transform: translateX(16px); opacity: 0; pointer-events: none; transform-origin: right center;
  transition: transform 160ms var(--ease-out), opacity 160ms var(--ease-out);
}
.panel.is-open { transform: none; opacity: 1; pointer-events: auto; transition-duration: var(--t-panel); }
.panel[inert], .palette[inert] { visibility: hidden; transition: transform var(--t-panel) var(--ease-out), opacity var(--t-panel) var(--ease-out), visibility 0s linear var(--t-panel); }
.panel-head { position: sticky; top: 0; background: color-mix(in oklab, var(--surface) 94%, transparent); backdrop-filter: blur(8px); padding: 20px 20px 12px; border-bottom: 1px solid var(--line); z-index: 1; }
.panel-head .ta { font-family: var(--font-ta); font-size: 2rem; line-height: 1.3; }
.panel-head .iso { font-family: var(--font-display); font-style: italic; font-size: 1.125rem; color: var(--ink-2); font-variation-settings: 'opsz' 24; }
.panel-head .close { position: absolute; top: 12px; right: 12px; }
.panel-body { padding: 16px 20px 24px; }
.panel-body section + section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.panel-body .label { display: block; margin-bottom: 8px; }
.ident { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); margin-bottom: 8px; }
.ident .who { grid-column: 1 / -1; font-size: 0.8125rem; color: var(--ink-2); }
.ident .modern { font-weight: 600; }
.ident .coords { grid-column: 1 / -1; }
.cite-box { font-family: var(--font-mono); font-size: 0.75rem; background: var(--surface-2); padding: 10px 12px; border-radius: var(--r-md); color: var(--ink-2); line-height: 1.6; word-break: break-word; }
.mention-list { display: grid; gap: 6px; }
.mention { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: var(--r-sm); text-decoration: none; transition: background-color var(--t-micro) var(--ease-out); }
.mention:hover { background: var(--surface-2); }
.mention:active { transform: scale(0.99); }
.mention { transition: background-color var(--t-micro) var(--ease-out), transform 160ms var(--ease-out); }
.mention .ref { font-family: var(--font-mono); font-size: 0.75rem; color: var(--accent); white-space: nowrap; }
.mention .ta { font-family: var(--font-ta); font-size: 0.9375rem; }
.linkrow { display: flex; flex-wrap: wrap; gap: 6px; }
.coast-note { font-size: 0.8125rem; color: var(--ink-2); border-left: 2px solid var(--palaeo); padding-left: 10px; }

/* ---------- poems index ---------- */
.poems-view { padding: 48px 0 96px; }
.poems-group { margin-top: 40px; }
.poems-group h2 { font-size: 1.5rem; margin-bottom: 12px; display: flex; gap: 10px; align-items: baseline; }
.poems-rows { border-top: 1px solid var(--line); }
.poem-row { display: grid; grid-template-columns: 120px 1fr auto auto; gap: 16px; align-items: center; min-height: 56px; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; transition: background-color var(--t-micro) var(--ease-out), transform 160ms var(--ease-out); }
.poem-row:hover { background: var(--surface-2); }
.poem-row:active { transform: scale(0.995); }
.poem-row .ref { color: var(--accent); }
.poem-row .first { font-family: var(--font-ta); font-size: 1.0625rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poem-row .who { font-size: 0.8125rem; color: var(--ink-2); display: flex; gap: 6px; align-items: center; white-space: nowrap; }
@media (max-width: 639px) { .poem-row { grid-template-columns: 1fr auto; } .poem-row .first, .poem-row .who { grid-column: 1 / -1; } }
.ledger-item { text-decoration: none; color: inherit; transition: background-color var(--t-micro) var(--ease-out); }
.ledger-item:hover { background: var(--surface-2); }
.mention .rel { grid-column: 2; margin-top: 2px; font-size: 0.625rem; }

/* ---------- poem ---------- */
.poem-view { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 44%); gap: 40px; padding: 40px 0 80px; }
.poem-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; color: var(--ink-2); font-size: 0.875rem; margin: 12px 0 24px; }
.poem-meta .mono { color: var(--ink-3); }
.poem-title .work { font-family: var(--font-ta-ui); color: var(--ink-2); font-size: 1rem; display: block; margin-bottom: 8px; }
.poem-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.poem-text { counter-reset: line; display: grid; gap: 4px; max-width: 64ch; }
.poem-text .line { display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding: 2px 8px 2px 0; border-radius: var(--r-sm); scroll-margin-top: 80px; }
.poem-text .line:target { background: var(--accent-soft); }
.poem-text .n { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--ink-3); text-align: right; padding-top: 0.7em; }
.poem-text .ta { font-family: var(--font-ta); font-size: 1.25rem; line-height: 1.8; }
.poem-text .iso { font-style: italic; color: var(--ink-2); font-size: 0.9375rem; line-height: 1.5; display: block; margin-bottom: 4px; }
.poem-text[data-mode="ta"] .iso { display: none; }
.poem-text[data-mode="iso"] .ta { display: none; }
.poem-text[data-mode="iso"] .iso { font-size: 1.0625rem; color: var(--ink); }
.toponym { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; text-decoration-color: color-mix(in oklab, var(--accent) 45%, transparent); cursor: pointer; border-radius: 3px; transition: background-color var(--t-micro) var(--ease-out); }
.toponym:hover, .toponym.is-hot { background: var(--accent-soft); text-decoration-color: var(--accent); }
.poem-side { position: sticky; top: calc(var(--header-h) + 24px); align-self: start; display: grid; gap: 16px; max-height: calc(100dvh - var(--header-h) - 48px); overflow: auto; }
.poem-side .panel.inline { position: static; width: auto; transform: none; opacity: 1; pointer-events: auto; box-shadow: var(--shadow-1); }
.poem-side .panel.inline[hidden] { display: none; }
.poem-side .panel.inline .panel-head { position: static; }
.poem-side .map { height: 440px; box-shadow: var(--shadow-2); }
.poem-summary { background: var(--surface); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-1); }
.poem-summary .label { display: block; margin-bottom: 8px; }
.colophon { font-family: var(--font-ta); font-size: 0.9375rem; color: var(--ink-2); background: var(--surface-2); padding: 12px 16px; border-radius: var(--r-md); margin-top: 24px; max-width: 64ch; }
.colophon .label { font-family: var(--font-ui); display: block; margin-bottom: 6px; }
.places-in-poem { display: grid; gap: 6px; }
.places-in-poem button { display: grid; grid-template-columns: 1fr auto; text-align: left; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px; border: 0; border-top: 1px solid var(--line); background: transparent; border-radius: 0; cursor: pointer; transition: background-color var(--t-micro) var(--ease-out), border-color var(--t-micro) var(--ease-out); }
.places-in-poem button:hover { background: var(--surface-2); }
.places-in-poem button:active { transform: scale(0.99); }
.places-in-poem { gap: 0; }
.places-in-poem .ta { font-family: var(--font-ta-ui); }
.poem-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 32px; }

/* ---------- route ---------- */
.route-view { display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 50%); gap: 40px; padding: 40px 0 80px; }
.route-head { margin-bottom: 24px; }
.route-head h1 { font-size: clamp(1.5rem, 1rem + 1.8vw, 2.5rem); line-height: 1.3; }
.route-head h1 .iso { display: block; font-size: 0.55em; font-style: italic; color: var(--ink-2); margin-top: 4px; }
.scrubber { display: grid; gap: 8px; background: var(--surface); padding: 16px; border-radius: var(--r-lg); box-shadow: var(--shadow-1); margin: 20px 0; }
.scrubber input[type=range] { width: 100%; accent-color: var(--accent); }
.scrubber .ticks { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.6875rem; color: var(--ink-3); }
.stations { display: grid; gap: 0; border-left: 2px solid var(--line); margin: 0 0 0 12px; padding: 0; list-style: none; }
.station { position: relative; padding: 12px 0 20px 28px; opacity: 0.55; cursor: pointer; transition: opacity var(--t-pop) var(--ease-out), transform 160ms var(--ease-out); }
.station:active { transform: scale(0.995); }
.station.is-active, .station.is-done { opacity: 1; }
.station::before { content: ''; position: absolute; left: -7px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--line-strong); transition: background-color var(--t-micro) var(--ease-out), border-color var(--t-micro) var(--ease-out), box-shadow var(--t-micro) var(--ease-out); }
.station.is-done::before { background: var(--accent); border-color: var(--accent); }
.station.is-active::before { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.station .head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.station .ordinal { font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-3); }
.station .ta { font-family: var(--font-ta); font-size: 1.25rem; }
.station .iso { font-style: italic; color: var(--ink-2); }
.station .stanza { font-family: var(--font-ta); color: var(--ink-2); font-size: 0.9375rem; margin-top: 6px; line-height: 1.7; }
.station .ev { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--accent); margin-top: 4px; }
.route-side { position: sticky; top: calc(var(--header-h) + 24px); align-self: start; }
.route-side .map { height: 560px; box-shadow: var(--shadow-2); }

/* ---------- tinai ---------- */
.tinai-view { padding: 48px 0 96px; }
.tinai-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 48px; align-items: start; margin-top: 32px; }
.tinai-bands { display: grid; gap: 2px; border-radius: var(--r-lg); overflow: hidden; }
.band { display: grid; grid-template-columns: 8px 1fr 1fr 1fr; gap: 16px; padding: 18px 20px 18px 0; background: var(--surface); align-items: center; cursor: pointer; border: 0; text-align: left; transition: background-color var(--t-micro) var(--ease-out); }
.band:hover, .band[aria-pressed="true"] { background: var(--surface-2); }
.band:active { transform: scale(0.995); }
.band .bar { height: 100%; background: var(--c); border-radius: 0 2px 2px 0; }
.band .name .ta { font-family: var(--font-ta); font-size: 1.375rem; display: block; }
.band .name .iso { font-style: italic; color: var(--ink-2); }
.band .k { font-size: 0.8125rem; color: var(--ink-2); }
.band .k strong { display: block; color: var(--ink); font-weight: 500; }
.band[data-id="palai"] .bar { background: repeating-linear-gradient(45deg, var(--c) 0 4px, transparent 4px 8px); }
.tinai-wheel { position: sticky; top: calc(var(--header-h) + 24px); background: var(--surface); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow-1); }
.tinai-wheel svg { width: 100%; height: auto; display: block; }
.tinai-wheel .seg { transition: opacity var(--t-pop) var(--ease-out); }
.tinai-wheel .seg.dim { opacity: 0.25; }
.tinai-wheel text { font-family: var(--font-ta-ui); font-size: 13px; fill: var(--ink); }
.tinai-wheel text.hour { font-family: var(--font-mono); font-size: 9px; fill: var(--ink-3); }
.tinai-note { margin-top: 16px; color: var(--ink-2); font-size: 0.875rem; }

/* ---------- method ---------- */
.method-view { padding: 48px 0 96px; max-width: 768px; }
.method-view h2 { margin-top: 48px; margin-bottom: 12px; }
.method-view p + p { margin-top: 12px; }
.method-view .table-wrap { overflow-x: auto; }
.method-view table { width: 100%; min-width: 520px; border-collapse: collapse; margin-top: 16px; font-size: 0.9375rem; }
.method-view th, .method-view td { text-align: left; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.method-view th { font-weight: 600; color: var(--ink-2); font-size: 0.8125rem; }

/* ---------- search palette ---------- */
.palette-backdrop { position: fixed; inset: 0; background: oklch(0 0 0 / 0.4); backdrop-filter: blur(4px); z-index: 60; opacity: 0; pointer-events: none; transition: opacity var(--t-pop) var(--ease-out); }
.palette-backdrop.is-open { opacity: 1; pointer-events: auto; }
.palette { position: fixed; left: 50%; top: 14vh; transform: translateX(-50%) scale(0.97); width: min(640px, calc(100vw - 32px)); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3); z-index: 61; opacity: 0; pointer-events: none; transition: transform var(--t-pop) var(--ease-out), opacity var(--t-pop) var(--ease-out); transform-origin: top center; }
.palette.is-open { transform: translateX(-50%) scale(1); opacity: 1; pointer-events: auto; }
.palette:not(.is-open) { transition-duration: 120ms; }
.palette li a.is-active { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.palette input { width: 100%; height: 56px; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 0 20px; font: inherit; font-size: 1.125rem; color: var(--ink); outline: 0; }
.palette input:focus-visible { box-shadow: inset 0 -2px 0 var(--accent); }
.palette ul { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow: auto; }
.palette li a { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: var(--r-sm); text-decoration: none; transition: background-color var(--t-micro) var(--ease-out); }
.palette li a:hover, .palette li a:focus { background: var(--surface-2); }
.palette .kind { font-size: 0.6875rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.palette .ta { font-family: var(--font-ta-ui); }
.palette .hint { padding: 12px 20px; color: var(--ink-3); font-size: 0.8125rem; border-top: 1px solid var(--line); }
.palette .empty { padding: 24px 20px; color: var(--ink-2); }

/* ---------- marker tooltip ---------- */
.tip { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; display: grid; gap: 1px; padding: 8px 10px; background: var(--ink); color: var(--bg); border-radius: var(--r-md); box-shadow: var(--shadow-2); opacity: 0; transition: opacity var(--t-micro) var(--ease-out); max-width: 240px; will-change: transform; }
.tip.is-open { opacity: 1; }
.tip-ta { font-family: var(--font-ta-ui); font-size: 0.9375rem; }
.tip-iso { font-style: italic; font-size: 0.8125rem; opacity: 0.85; }
.tip-sub { font-size: 0.75rem; opacity: 0.75; margin-top: 2px; }
.tip-hint { font-size: 0.6875rem; opacity: 0.55; margin-top: 4px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(8px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r-md); font-size: 0.875rem; box-shadow: var(--shadow-2); opacity: 0; pointer-events: none; transition: transform var(--t-pop) var(--ease-out), opacity var(--t-pop) var(--ease-out); z-index: 70; }
.toast.is-open { opacity: 1; transform: translateX(-50%); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 32px 0 48px; color: var(--ink-3); font-size: 0.8125rem; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- responsive ---------- */
@media (max-width: 1023px) {
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-map { min-height: 420px; }
  .ledger { grid-template-columns: repeat(3, 1fr); }
  .ledger > div:nth-child(3) { border-right: 0; }
  .doors, .feature-poem, .tinai-grid { grid-template-columns: 1fr; }
  .poem-view, .route-view { grid-template-columns: 1fr; }
  .poem-side, .route-side { position: static; }
  .explorer { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); max-height: 36vh; }
  .panel { left: 12px; right: 12px; width: auto; top: auto; max-height: 60%; transform: translateY(16px); transform-origin: bottom center; }
}
@media (max-width: 479px) { .map-legend { display: none; } }
@media (max-width: 639px) {
  body { padding-bottom: 64px; }
  .site-header { grid-template-columns: 1fr auto; gap: 12px; padding: 0 16px; }
  .wordmark .ta { display: none; }
  /* The header must not be a containing block for the fixed tab bar, so no backdrop-filter here on mobile. */
  .site-header { backdrop-filter: none; background: var(--bg); }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: space-around; gap: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
  .nav a { font-size: 0.75rem; padding: 12px 4px; min-height: 48px; display: flex; align-items: center; justify-content: center; flex: 1; min-width: 0; text-align: center; white-space: nowrap; }
  .search { min-width: 0; width: 40px; padding: 0; justify-content: center; }
  .search .placeholder, .search kbd { display: none; }
  .seg button { font-size: 0; padding: 0 10px; min-width: 44px; }
  .map-controls .btn { width: 44px; height: 44px; }
  .seg button::after { content: attr(data-short); font-size: 0.8125rem; font-family: var(--font-ta-ui); }
  .explorer { height: calc(100dvh - var(--header-h) - 64px); }
  .rail { max-height: 34vh; padding: 12px 16px; mask-image: linear-gradient(to bottom, black 85%, transparent); }
  .rail .list button { height: 44px; }
  .rail .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .rail section + section { margin-top: 14px; }
  .panel { max-height: 55%; }
  .tip { display: none; }
  .map-scale { display: none; }
  .map-edge { display: none; }
  .wrap { padding: 0 16px; }
  .ledger { grid-template-columns: 1fr 1fr; }
  .ledger > div { border-right: 0; }
  .hero-map { min-height: 360px; }
  .band { grid-template-columns: 6px 1fr; }
  .band .k { display: none; }
  .tinai-wheel { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  /* Reduce, do not disable: keep opacity fades at 120 ms, remove every translate and scale. */
  *, *::before, *::after { transition-property: opacity, background-color, color, border-color, box-shadow !important; transition-duration: 120ms !important; }
  .map .marker .mk { opacity: 1; animation: none; }
  .view.is-active { animation: view-fade 120ms ease-out both; }
  .panel, .palette, .toast, .tip { transform: none !important; }
  .palette { transform: translateX(-50%) !important; }
  .toast { transform: translateX(-50%) !important; }
  .btn:active, .chip:active, .seg button:active, .door:active, .mention:active, .band:active, .station:active { transform: none !important; }
}
@keyframes view-fade { from { opacity: 0; } to { opacity: 1; } }

/* indirect toponym: the line names the ruler, the link goes to the seat */
.toponym.indirect { text-decoration-style: dotted; color: var(--ink-2); }

/* ---------- place dossier ---------- */
:root { --era-sangam: oklch(0.55 0.14 35); --era-post-sangam-epic: oklch(0.5 0.12 290); --era-greco-roman: oklch(0.55 0.11 120); --era-bhakti: oklch(0.52 0.13 70); --era-medieval: oklch(0.5 0.05 250); --era-colonial: oklch(0.55 0.03 60); --era-modern-scholarship: oklch(0.55 0.1 190); --era-now: oklch(0.45 0.02 90); }
.era-sangam { --era: var(--era-sangam); } .era-post-sangam-epic { --era: var(--era-post-sangam-epic); } .era-greco-roman { --era: var(--era-greco-roman); } .era-bhakti { --era: var(--era-bhakti); } .era-medieval { --era: var(--era-medieval); } .era-colonial { --era: var(--era-colonial); } .era-modern-scholarship { --era: var(--era-modern-scholarship); } .era-now { --era: var(--era-now); } .era-all { --era: var(--ink-2); }
.era-mark { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--era, var(--ink-3)); margin-right: 6px; vertical-align: middle; transform: rotate(45deg); }
.dossier .panel-head { padding-top: 16px; position: static; }
.dossier > .close { position: sticky; top: 12px; float: right; margin: 12px 12px 0 0; z-index: 2; background: var(--surface); box-shadow: var(--shadow-1); border-radius: 50%; }
.story-scene h2:focus { outline: none; }
@media (prefers-color-scheme: dark) { :root { --era-sangam: oklch(0.76 0.12 35); --era-post-sangam-epic: oklch(0.74 0.1 290); --era-greco-roman: oklch(0.75 0.1 120); --era-bhakti: oklch(0.78 0.12 70); --era-medieval: oklch(0.74 0.05 250); --era-colonial: oklch(0.74 0.03 60); --era-modern-scholarship: oklch(0.76 0.09 190); --era-now: oklch(0.74 0.02 90); } }
.dossier .headline { margin-top: 10px; font-family: var(--font-display); font-size: 1.0625rem; line-height: 1.4; color: var(--ink); text-wrap: pretty; }
.dossier .headline[lang="ta"] { font-family: var(--font-ta); font-size: 1rem; }
.dossier .chiprow { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.dossier .chip.accent { border-color: var(--accent); color: var(--accent); }
.dossier .chip.small { height: 24px; font-size: 0.6875rem; padding: 0 8px; }
.dossier .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.dossier .btn-story { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.dossier .btn-story:hover { background: var(--accent); border-color: var(--accent); }
.lang-toggle { margin-left: auto; display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.lang-toggle button { border: 0; background: transparent; padding: 4px 10px; font: inherit; font-size: 0.75rem; cursor: pointer; color: var(--ink-2); }
.lang-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.dossier .fallback { position: relative; }
.dossier .pending { display: block; font-size: 0.6875rem; color: var(--ink-3); margin-top: 4px; font-family: var(--font-ta-ui); }
.dossier .chip.accent.era-lock { cursor: pointer; }
.dossier a.chip.accent { text-decoration: none; }
.dossier .panel-body h2.label { display: flex; align-items: baseline; gap: 8px; }
.dossier .count { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--ink-3); font-weight: 400; }
.dossier h3 { font-family: var(--font-ui); font-size: 0.8125rem; font-weight: 600; letter-spacing: 0; color: var(--ink-2); margin: 0 0 6px; }
.dossier section.no-rule { border-top: 0; padding-top: 0; }
.then-now { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.then-now .col { font-size: 0.875rem; line-height: 1.55; }
.then-now .col h3 { font-family: var(--font-display); font-style: italic; font-size: 1.125rem; color: var(--ink); font-weight: 500; }
.then-now .then h3 { color: var(--era-sangam); } .then-now .now h3 { color: var(--era-now); }
.then-now .k { font-weight: 600; margin-bottom: 4px; }
.then-now p + p { margin-top: 6px; }
.then-now .goods { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.era-rail { position: sticky; top: 0; z-index: 1; display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 0 10px; background: color-mix(in oklab, var(--surface) 96%, transparent); backdrop-filter: blur(6px); margin-bottom: 8px; }
.era-tab { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; font: inherit; font-size: 0.75rem; color: var(--ink-2); cursor: pointer; transition: background-color var(--t-micro) var(--ease-out), border-color var(--t-micro) var(--ease-out); }
.era-tab:hover { background: var(--surface-2); }
.era-tab[aria-selected="true"] { background: var(--era, var(--ink)); border-color: var(--era, var(--ink)); color: oklch(0.98 0.01 80); }
.era-tab[aria-selected="true"] .count { color: inherit; opacity: 0.8; }
.era-tab[aria-selected="true"] .era-mark { background: oklch(0.98 0.01 80 / 0.9); }
.era-group + .era-group { margin-top: 16px; }
.era-head { display: flex; align-items: center; gap: 4px; color: var(--era); padding-bottom: 4px; border-bottom: 1px solid color-mix(in oklab, var(--era) 35%, transparent); }
.mention-row { display: grid; gap: 4px; padding: 10px 10px 10px 12px; border-left: 2px solid color-mix(in oklab, var(--era, var(--line-strong)) 60%, transparent); margin-top: 8px; border-radius: 0 var(--r-sm) var(--r-sm) 0; transition: background-color var(--t-micro) var(--ease-out); }
.mention-row:hover { background: var(--surface-2); }
.era-group .mention-row { --era: inherit; }
.mention-row .refline { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.mention-row .ref { font-family: var(--font-mono); font-size: 0.75rem; color: var(--accent); white-space: nowrap; }
.mention-row .work { font-size: 0.75rem; color: var(--ink-3); }
.mention-row .ta { font-family: var(--font-ta); font-size: 1.0625rem; line-height: 1.75; color: var(--ink); }
.mention-row .ta strong { font-weight: 400; text-decoration: underline 2px var(--era, var(--accent)); text-underline-offset: 0.18em; }
.mention-row .orig { font-family: var(--font-display); font-style: italic; font-size: 0.9375rem; color: var(--ink); line-height: 1.5; }
.mention-row .gloss { font-size: 0.8125rem; color: var(--ink-2); line-height: 1.5; margin: 0; }
.mention-row .meta { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: baseline; font-size: 0.75rem; color: var(--ink-3); }
.mention-row .meta .what { flex: 1 1 100%; color: var(--ink-2); }
.mention-row .read { color: var(--accent); text-decoration: none; margin-left: auto; white-space: nowrap; }
.mention-row .read:hover { text-decoration: underline; }
.story-card { background: var(--surface-2); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 8px; font-size: 0.875rem; line-height: 1.55; }
.story-card .kind { display: inline-block; font-size: 0.625rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; color: var(--ink-3); border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 6px; margin-bottom: 6px; }
.story-card .kind-legend { color: var(--era-post-sangam-epic); border-color: color-mix(in oklab, var(--era-post-sangam-epic) 50%, transparent); }
.story-card .kind-history { color: var(--era-modern-scholarship); border-color: color-mix(in oklab, var(--era-modern-scholarship) 50%, transparent); }
.story-card h3 { font-family: var(--font-display); font-size: 1.0625rem; color: var(--ink); font-weight: 500; }
.story-card p + p { margin-top: 6px; }
.timeline { list-style: none; margin: 12px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 10px; }
.timeline li { position: relative; display: grid; gap: 1px; font-size: 0.8125rem; }
.timeline li::before { content: ''; position: absolute; left: -19px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink-3); }
.timeline .when { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--accent); }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 0.8125rem; }
.people li { display: grid; gap: 2px; } .people .label { font-size: 0.625rem; } .people .small { color: var(--ink-2); }
.dossier .argument { font-size: 0.875rem; line-height: 1.55; margin-bottom: 12px; }
.candidate .fly-to { grid-column: 1 / -1; justify-self: start; height: 28px; font-size: 0.75rem; padding: 0 10px; }
.dossier .sub { margin-top: 14px; }
.dig { font-size: 0.8125rem; margin-bottom: 8px; } .dig p { margin: 2px 0 0; }
.open-q { margin-top: 12px; font-size: 0.8125rem; } .open-q summary { cursor: pointer; color: var(--ink-2); font-weight: 600; } .open-q ul { margin: 8px 0 0 18px; display: grid; gap: 4px; color: var(--ink-2); }
.sources { font-size: 0.75rem; color: var(--ink-2); margin: 0 0 10px 16px; display: grid; gap: 4px; }
.sources a { color: inherit; }
.dossier .cite-box { margin-top: 10px; }
.story-foot { display: grid; gap: 2px; text-decoration: none; background: var(--ink); color: var(--bg); border-radius: var(--r-md); padding: 14px 16px; transition: background-color var(--t-micro) var(--ease-out); }
.story-foot:hover { background: var(--accent); }
.story-foot .label, .story-foot .muted { color: inherit; opacity: 0.75; }
.story-foot strong { font-family: var(--font-display); font-size: 1.0625rem; font-weight: 500; }
.dossier.compact [data-block="stories-events"], .dossier.compact [data-block="people"], .dossier.compact [data-block="names"], .dossier.compact [data-block="sources"] { display: none; }
.sheet-handle { display: none; }
/* map: era fade */
.map .marker { transition: opacity var(--t-pop) var(--ease-out); }
.map .marker.is-faded { opacity: 0.22; }
.map .marker.is-faded text { opacity: 0.55; }
.map .marker.is-faded .core { fill: var(--bg); stroke: var(--ink-3); }
.map .marker.is-selected .halo { opacity: 0.4; }
.map .marker.is-selected .core { stroke-width: 2.4; }
.era-note { margin: -2px 0 10px; }
.kind-key { margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.story-scene .kind, .kind-key .kind { display: inline-block; font-size: 0.625rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; color: var(--ink-3); border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 6px; margin-left: 8px; }
.kind-key .kind { margin-left: 0; }
.story-card .kind-epic, .story-scene .kind-epic { color: var(--era-post-sangam-epic); }
.story-card .kind-scholarship, .story-scene .kind-scholarship { color: var(--era-modern-scholarship); }
.story-card .kind-tradition, .story-scene .kind-tradition { color: var(--era-medieval); }
.story-card .kind-poem, .story-scene .kind-poem { color: var(--era-sangam); }
.story-mode .map .marker .precision, .now-mode .map .marker .precision { opacity: 0.6; stroke-width: 1; }
/* story mode */
.panel.story-collapsed { transform: translateX(110%); opacity: 0; pointer-events: none; }
.story { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.story[hidden] { display: none; }
.story-rail { position: absolute; top: 16px; right: 16px; bottom: 136px; width: 44px; display: grid; grid-template-rows: auto 1fr auto; justify-items: center; gap: 12px; pointer-events: auto; }
.story-rail ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; align-content: start; }
.story-rail ol { gap: 0; }
.story-rail li a { display: grid; place-items: center; width: 24px; height: 24px; }
.story-rail li a::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink-3); background: var(--surface); transition: background-color var(--t-micro) var(--ease-out), transform var(--t-micro) var(--ease-out); }
.story-rail li a.is-done::before { background: var(--ink-3); } .story-rail li a.is-active::before { background: var(--accent); border-color: var(--accent); transform: scale(1.3); }
.story-exit { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-2); text-decoration: none; color: var(--ink); }
.story-progress { font-size: 0.6875rem; color: var(--ink-3); writing-mode: vertical-rl; }
.story-scene { position: absolute; right: 76px; bottom: 24px; width: min(420px, calc(100% - 100px)); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3); padding: 20px 22px; pointer-events: auto; display: grid; gap: 10px; border-top: 3px solid var(--era, var(--accent)); animation: scene-in var(--t-view) var(--ease-out); }
@keyframes scene-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.story-scene .when { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--era, var(--ink-3)); display: flex; align-items: center; }
.story-scene h2 { font-size: 1.375rem; line-height: 1.2; }
.story-scene blockquote { margin: 0; padding: 0 0 0 12px; border-left: 2px solid var(--era, var(--line-strong)); }
.story-scene blockquote.ta { font-family: var(--font-ta); font-size: 1.125rem; line-height: 1.75; }
.story-scene blockquote.orig { font-family: var(--font-display); font-style: italic; font-size: 1rem; line-height: 1.5; }
.story-scene p { font-size: 0.9375rem; line-height: 1.55; }
.story-scene .ref { font-family: var(--font-mono); font-size: 0.75rem; color: var(--accent); }
.story-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.story-nav a[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }
@media (max-width: 1023px) {
  .sheet-handle { display: grid; place-items: center; width: 100%; height: 22px; border: 0; background: transparent; cursor: pointer; position: absolute; top: 0; left: 0; }
  .sheet-handle span { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); }
  .dossier .panel-head { padding-top: 22px; }
  .panel[data-detent="peek"] { max-height: 112px; overflow: hidden; }
  .panel[data-detent="half"] { max-height: 55%; }
  .panel[data-detent="full"] { max-height: 92%; }
  .then-now { grid-template-columns: 1fr; }
  .story-rail { top: auto; bottom: calc(68px + env(safe-area-inset-bottom)); right: 12px; left: 12px; width: auto; grid-template-rows: none; grid-template-columns: auto 1fr auto; align-items: center; }
  .story-rail ol { grid-auto-flow: column; }
  .story-progress { writing-mode: horizontal-tb; }
  .story-scene { right: 12px; left: 12px; bottom: calc(116px + env(safe-area-inset-bottom)); width: auto; max-height: 55%; overflow: auto; }
  .panel.is-open { bottom: calc(68px + env(safe-area-inset-bottom)); }
  .explorer:has(.panel.is-open:not(.story-collapsed)) .rail { display: none; }
  .explorer:has(.panel.is-open:not(.story-collapsed)) { grid-template-rows: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .story-scene { animation: none; } .map .marker { transition: none; } }
