/* Hallmark · shape: app screen · genre: editorial · theme: custom, after the China Numismatic Museum site the owner named (by request) · redesign: full
 * nav: top bar, wordmark and three controls · signature: the coin of the year, both faces as the museum photographed them, framed on linen beside the map · states: loading, empty, full
 * axes: dark/brush-wordmark-over-serif/bronze-gold · posture: drenched · contrast: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P4 H4 E3 S5 R4 V4 · weakest: E, the map is the atlas's own drawing and keeps its literals; everything around it was rebuilt on tokens */

:root {
  --space-3xs: 2px; --space-2xs: 4px; --space-xs: 8px; --space-sm: 12px; --space-md: 16px; --space-lg: 24px; --space-xl: 40px; --space-2xl: 64px;
  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-md: 1rem; --text-lg: 1.2rem; --text-xl: 1.44rem; --text-2xl: 1.728rem; --text-3xl: 2.074rem; --text-figure: 4rem;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-land: cubic-bezier(0.05, 0.7, 0.1, 1); /* Material 3 emphasized decelerate, for things arriving */
  --ease-exit: cubic-bezier(0.3, 0, 0.8, 0.15); /* Material 3 emphasized accelerate, for things leaving */
  --dur-micro: 120ms; --dur-short: 220ms;
  --color-paper: oklch(19% 0.006 75); --color-paper-2: oklch(14.5% 0.005 75); --color-paper-3: oklch(25% 0.009 75);
  --color-ink: oklch(90% 0.03 85); --color-ink-2: oklch(78% 0.035 85); --color-muted: oklch(63% 0.035 82);
  --color-rule: oklch(33% 0.022 78);
  --color-accent: oklch(76% 0.105 82); --color-accent-2: oklch(84% 0.09 85); --color-accent-deep: oklch(47% 0.075 72); --color-accent-ink: oklch(17% 0.012 75); --color-focus: oklch(84% 0.09 85);
  --color-scrim: oklch(14.5% 0.005 75 / 0.95);
  --color-plate-shade: oklch(17% 0.01 75 / 0.36);
  --color-linen: oklch(92% 0.014 78); --color-linen-edge: oklch(80% 0.03 78);
  --color-terracotta: oklch(52% 0.13 40); /* hoards and finds: the colour of fired clay */
  --font-wordmark: "Coin Brush", "STKaiti", "KaiTi", var(--font-display);
  --font-display: "Prata", "Coin Serif", "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", ui-sans-serif, system-ui, sans-serif;
  --radius-card: 0; --radius-pill: 999px;
  --panel-w: clamp(380px, 33vw, 480px);
  --shadow-float: 0 2px 10px oklch(8% 0.01 75 / 0.45), 0 0 0 1px oklch(8% 0.01 75 / 0.2);
}

@font-face { font-family: "Prata"; src: url("../assets/fonts/prata-subset.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Coin Brush"; src: url("../assets/fonts/wordmark-subset.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Coin Serif"; src: url("../assets/fonts/coin-serif-subset.woff2") format("woff2"); font-weight: 600; font-display: swap; }

html.coin-ed, html.coin-ed body { overflow-x: clip; }
html.coin-ed { color-scheme: dark; scrollbar-color: var(--color-muted) var(--color-paper); }
html.coin-ed body { background: var(--color-paper); color: var(--color-ink); font-family: var(--font-body); }
html.coin-ed :focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
html.coin-ed ::selection { background: color-mix(in oklab, var(--color-accent) 24%, transparent); color: var(--color-ink); }

/* Everything upstream styles with its own tokens reads these inside the dark shell. */
html.coin-ed #nav-bar, html.coin-ed #scrubber-dock, html.coin-ed #coin-panel, html.coin-ed #layers-popover, html.coin-ed #map-key,
html.coin-ed #hover-tip, html.coin-ed #canvas-br-dock, html.coin-ed #map-search-box, html.coin-ed #milestone-balloon, html.coin-ed #genealogy-card {
  --text-main: var(--color-ink); --text-secondary: var(--color-ink-2); --text-muted: var(--color-muted);
  --hairline: var(--color-rule); --vermilion: var(--color-accent); --amber-gold: var(--color-accent);
  --bg-parchment: var(--color-paper); --bg-parchment-alt: var(--color-paper-2);
  --serif-stack: var(--font-display); --sans-stack: var(--font-body); --calligraphy-stack: var(--font-display);
  --card-shadow: none; --corner-radius: 0;
}

/* The atlas's own place card (empty map, a city with no coin) wears the dark surface too. */
html.coin-ed #genealogy-card { background: var(--color-scrim); border-color: var(--color-rule); box-shadow: var(--shadow-float); color: var(--color-ink); backdrop-filter: none; }
html.coin-ed #genealogy-card .gen-filter-pill.is-active { color: var(--color-accent-ink); }

/* ---------- top bar ---------- */
html.coin-ed #nav-bar { background: var(--color-paper-2); border-top: 2px solid var(--color-accent-deep); border-bottom: 1px solid var(--color-rule); backdrop-filter: none; padding: var(--space-xs) var(--space-lg); gap: var(--space-md); min-height: 56px; }
html.coin-ed .brand-group h1 { gap: var(--space-sm); align-items: baseline; }
html.coin-ed .brand-group .seal-mark { font-family: var(--font-wordmark); font-weight: 400; font-synthesis: none; font-size: var(--text-3xl); line-height: 1; color: var(--color-accent); letter-spacing: 0; }
html.coin-ed .brand-group .subtitle-mark { font-family: var(--font-body); font-size: var(--text-sm); color: var(--color-muted); letter-spacing: 0; }
html.coin-ed .home-link { text-decoration: none; }
html.coin-ed .control-strip { gap: var(--space-xs); }
html.coin-ed .toolbar-divider, html.coin-ed .music-pill-group, html.coin-ed #act-narrator, html.coin-ed #act-challenge, html.coin-ed .github-pill-group,
html.coin-ed #more-popover, html.coin-ed #start-guide, html.coin-ed #gesture-guide, html.coin-ed #map-key, html.coin-ed #act-toggle-pane, html.coin-ed #chronicle-pane,
html.coin-ed #act-mobile-chronicle { display: none !important; }
html.coin-ed .action-btn { min-height: 36px; padding: 0 var(--space-md); font-size: var(--text-sm); font-weight: 500; border-radius: var(--radius-pill); transition: background-color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out); }
html.coin-ed .action-btn.subtle { background: none; color: var(--color-ink); border: 1px solid var(--color-rule); box-shadow: none; }
html.coin-ed .action-btn.subtle:hover { background: var(--color-paper-3); border-color: var(--color-muted); }
html.coin-ed .action-btn.subtle:active { background: var(--color-paper); transform: none; }
html.coin-ed .layers-trigger-btn.is-active { background: var(--color-paper-3); border-color: var(--color-accent); }
html.coin-ed .locale-pill-group { background: none; border: 0; box-shadow: none; padding: 0; gap: var(--space-2xs); }
html.coin-ed .locale-pill-group .action-btn { min-width: 44px; border-radius: var(--radius-pill); }
html.coin-ed #coin-credit { font-size: var(--text-xs); color: var(--color-muted); white-space: nowrap; }
html.coin-ed #coin-credit a, .cp-credit-foot a, .cp-credit a { color: inherit; text-decoration: underline; text-decoration-color: var(--color-rule); text-underline-offset: 0.2em; }
html.coin-ed #coin-credit a:hover, .cp-credit-foot a:hover, .cp-credit a:hover { color: var(--color-ink); }
.cp-hero .cp-credit, .cp-credit-foot { margin: 0; font-size: var(--text-xs); color: var(--color-muted); }
.cp-credit-foot { display: none; }
html.coin-ed #layers-popover { background: var(--color-paper-3); border: 1px solid var(--color-rule); border-radius: 0; box-shadow: none; backdrop-filter: none; color: var(--color-ink); }
html.coin-ed .layers-pop-heading { color: var(--color-muted); letter-spacing: 0; font-size: var(--text-xs); }
html.coin-ed .layer-chip { background: none; border: 1px solid var(--color-rule); border-radius: var(--radius-pill); color: var(--color-ink-2); }
html.coin-ed .layer-chip:hover { border-color: var(--color-muted); }
html.coin-ed .layer-chip:has(input:checked) { background: var(--color-paper); border-color: var(--color-accent); color: var(--color-ink); }

/* ---------- workspace: the map is the lit table, the panel reads beside it ---------- */
html.coin-ed #workspace-body { position: relative; grid-template-columns: minmax(0, 1fr) var(--panel-w); }
html.coin-ed #viewport-frame { border-right: 0; }
html.coin-ed #map-search-box .search-input-wrap { background: var(--color-paper); border: 1px solid var(--color-rule); border-radius: 0; box-shadow: var(--shadow-float); backdrop-filter: none; }
html.coin-ed #inp-map-search { color: var(--color-ink); font-family: var(--font-body); font-size: var(--text-sm); }
html.coin-ed #inp-map-search::placeholder { color: var(--color-muted); }
html.coin-ed #map-search-results { background: var(--color-paper); border: 1px solid var(--color-rule); border-radius: 0; box-shadow: none; color: var(--color-ink); }
html.coin-ed #map-search-results li:hover, html.coin-ed #map-search-results li.is-active { background: var(--color-paper-3); }
html.coin-ed #map-key { background: var(--color-scrim); border: 1px solid var(--color-rule); border-radius: 0; box-shadow: none; backdrop-filter: none; color: var(--color-ink-2); }
html.coin-ed #canvas-br-dock .canvas-reset-btn { background: var(--color-paper); color: var(--color-ink); border: 1px solid var(--color-rule); border-radius: var(--radius-pill); box-shadow: var(--shadow-float); min-height: 36px; }
html.coin-ed #canvas-br-dock .canvas-reset-btn:hover { background: var(--color-paper-3); }
html.coin-ed #hover-tip { background: var(--color-scrim); color: var(--color-ink); border: 1px solid var(--color-rule); border-radius: 0; box-shadow: none; }
html.coin-ed #hover-tip .tt-title { font-family: var(--font-display); font-weight: 600; }
html.coin-ed #milestone-balloon { background: var(--color-scrim); color: var(--color-ink); border: 1px solid var(--color-rule); border-radius: 0; box-shadow: none; }
html.coin-ed.is-coin-playing #milestone-balloon { display: none; }
/* the capital's "click for its 2,000-year story" tag sits exactly where the coin of that capital goes */
html.coin-ed .cap-hint-tag { display: none; }

/* coin markers. Entering, leaving and picture changes run in script (Web Animations), which the atlas's own
   "stop every SVG animation while the camera moves" rule cannot reach; the CSS transitions and the focus ring here
   carry two ids so they outrank that rule as well. */
#grp-coins .coin-find { cursor: pointer; }
#grp-coins .coin-find.is-leaving { pointer-events: none; }
#grp-coins .cf-in, #grp-coins .cf-lift, #grp-coins .cf-ripple { transform-box: view-box; transform-origin: 0 0; }
/* photo or dot: when photos would pile up, the less relevant fold to a dot, cross-fading rather than snapping */
#atlas-svg #grp-coins .coin-find, #atlas-svg #grp-coins .cf-dim { transition: opacity 380ms ease !important; }
#grp-coins .coin-layer-photos .coin-find.is-compact, #grp-coins .coin-dot:not(.is-compact) { opacity: 0; pointer-events: none; }
#grp-coins .cf-ripple { fill: none; stroke: var(--color-accent-deep); stroke-width: 1.6; opacity: 0; }
#grp-coins .cf-plate { fill: var(--color-linen); stroke: var(--color-accent-deep); stroke-width: 1.5; }
#grp-coins .cf-shadow { fill: var(--color-plate-shade); }
#grp-coins .cf-photo { clip-path: circle(50%); }
#grp-coins .cf-note .cf-photo { clip-path: none; }
/* tokens: small shapes for places without a photo; the shape says what kind of record it is (the legend reuses them) */
.tk-spec-rim { fill: var(--color-linen); stroke: var(--color-accent-ink); stroke-width: 0.9; }
.tk-spec { fill: var(--color-accent-deep); }
.tk-mint { fill: var(--color-accent); stroke: var(--color-accent-deep); stroke-width: 1.1; }
.tk-hole { fill: var(--color-linen); stroke: var(--color-accent-deep); stroke-width: 0.6; }
.tk-find { fill: var(--color-linen); fill-opacity: 0.85; stroke: var(--color-terracotta); stroke-width: 1.5; stroke-dasharray: 2.3 1.5; }
.tk-find-dot { fill: var(--color-terracotta); }
.tk-note { fill: var(--color-linen); stroke: var(--color-accent-deep); stroke-width: 1.3; }
.tk-photo { fill: var(--color-linen); stroke: var(--color-accent-deep); stroke-width: 1.2; }
.tk-photo-in { fill: var(--color-accent-deep); }
#grp-coins .cf-hit { fill: transparent; }
#grp-coins .cf-ring { fill: none; stroke: var(--color-accent); stroke-width: 1.8; opacity: 0; }
#grp-coins .coin-find.is-active .cf-ring { opacity: 1; }
#grp-coins .coin-find:hover .cf-ring { opacity: 0.7; }
#grp-coins .coin-find.is-active:hover .cf-ring { opacity: 1; }
#grp-coins .coin-find.is-off-era .cf-photo, #grp-coins .coin-find.is-off-era .cf-tok { opacity: 0.5; }
#grp-coins .coin-find.is-off-era .cf-plate { stroke-dasharray: 2 2; }
#grp-coins .coin-find.is-active .cf-plate { stroke: var(--color-accent); stroke-width: 3.2; }
#grp-coins .coin-find:hover .cf-plate { stroke-width: 2.4; }
/* tour focus: the place in the caption lifts and rings gold twice; the rest of the map steps back */
#grp-coins:has(.is-tour-focus) .coin-find:not(.is-tour-focus) .cf-dim { opacity: 0.35; }
#atlas-svg #grp-coins .cf-lift { transition: transform 560ms cubic-bezier(0.16, 1, 0.3, 1) !important; }
#grp-coins .coin-find.is-tour-focus .cf-lift { transform: scale(1.3); }
#atlas-svg #grp-coins .coin-find.is-tour-focus .cf-ripple { stroke: var(--color-accent); stroke-width: 2; animation: coin-pulse 1800ms cubic-bezier(0.16, 1, 0.3, 1) 650ms 2 both !important; }
@keyframes coin-pulse { 0% { opacity: 0.9; transform: scale(0.95); } 100% { opacity: 0; transform: scale(2.4); } }
@keyframes coin-fade { from { opacity: 0; } }
/* banknotes: a small turned sheet in a linen mount, alone or tucked behind the coin of the same place */
#grp-coins .cf-note-plate { fill: var(--color-linen); stroke: var(--color-accent-deep); stroke-width: 1.2; }
#grp-coins .cf-note-shadow { fill: var(--color-plate-shade); }
#grp-coins .cf-note.is-tucked .cf-note-plate { stroke-width: 1; }
#grp-coins .coin-find.is-active .cf-note:not(.is-tucked) .cf-note-plate { stroke: var(--color-accent); stroke-width: 2.6; }
#grp-coins .cf-count-bg { fill: var(--color-accent-ink); }
#grp-coins .cf-count { font: 600 8px/1 var(--font-body); fill: var(--color-ink); text-anchor: middle; pointer-events: none; font-variant-numeric: tabular-nums; }

/* legend: bottom-left of the map on a wide screen (foldable), inside the Layers popover on a phone */
.coin-legend { position: absolute; left: 14px; bottom: 14px; z-index: 5; max-width: min(300px, calc(100% - 28px)); background: var(--color-paper); color: var(--color-ink); border: 1px solid var(--color-rule); box-shadow: var(--shadow-float); font: 400 var(--text-xs)/1.3 var(--font-body); }
.coin-legend .cl-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); width: 100%; padding: 5px 10px; background: none; border: 0; color: var(--color-ink-2); font: 600 var(--text-xs)/1.3 var(--font-body); letter-spacing: 0.04em; cursor: pointer; }
.coin-legend .cl-caret { transition: transform var(--dur-short) var(--ease-out); }
.coin-legend.is-folded .cl-caret { transform: rotate(180deg); }
.coin-legend.is-folded .cl-list { display: none; }
html.is-coin-playing .coin-legend { visibility: hidden; } /* the tour caption takes the same corner */
.cl-list { list-style: none; margin: 0; padding: 0 10px 7px; display: grid; gap: 4px; }
.cl-list li { display: flex; align-items: center; gap: 7px; }
.cl-ico { flex: none; width: 15px; height: 15px; overflow: visible; }
.coin-legend-pop .cl-list { padding: 0; color: var(--text-main, inherit); font-size: 12px; }
.coin-legend-pop { display: none; }
@media (max-width: 640px) {
  .coin-legend { display: none; }
  .coin-legend-pop { display: block; }
}

/* ---------- the reading panel ---------- */
#coin-panel { display: grid; grid-template-rows: auto auto minmax(0, 1fr); min-width: 0; min-height: 0; background: var(--color-paper); color: var(--color-ink); border-left: 1px solid var(--color-rule); font: 400 var(--text-md)/1.6 var(--font-body); }
#coin-panel button { font: inherit; color: inherit; cursor: pointer; }
.cp-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--space-2xs) var(--space-md); padding: var(--space-lg) var(--space-lg) var(--space-md); }
.cp-year { font: 400 var(--text-figure)/1 var(--font-display); font-synthesis: none; font-variant-numeric: lining-nums tabular-nums; overflow-wrap: break-word; min-width: 0; }
.cp-year small { font-size: var(--text-xl); margin-right: var(--space-2xs); }
.cp-era { grid-column: 1 / -1; margin: 0; font-size: var(--text-md); color: var(--color-ink-2); }
.cp-sum { grid-column: 1 / -1; margin: 0; font-size: var(--text-sm); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.cp-sheet-toggle { display: none; }
.cp-tabs { display: flex; gap: var(--space-lg); padding: 0 var(--space-lg); border-bottom: 1px solid var(--color-rule); }
.cp-tabs button { min-height: 44px; padding: 0; border: 0; border-bottom: 2px solid transparent; background: none; font-size: var(--text-sm); font-weight: 500; color: var(--color-muted); transition: color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out); }
.cp-tabs button:hover { color: var(--color-ink); }
.cp-tabs button:active { color: var(--color-accent-2); }
.cp-tabs button[aria-selected="true"] { color: var(--color-ink); border-bottom-color: var(--color-accent); }
.cp-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--space-lg); }
.cp-body[hidden] { display: none; }

.cp-hero { display: grid; justify-items: start; gap: var(--space-xs); margin: 0 0 var(--space-lg); }
.cp-hero { animation: coin-fade var(--dur-short) var(--ease-out); }
.cp-hero-photo { display: grid; grid-template-columns: repeat(2, minmax(0, 150px)); justify-content: start; gap: var(--space-xs); width: 100%; margin: 0 0 var(--space-xs); padding: 0; border: 0; background: none; cursor: zoom-in; }
/* The museum's own photos, shown whole. The build frames each one so every coin is the same size; nothing is cut out or zoomed. */
.cp-hero-photo .ph { display: block; overflow: hidden; width: 100%; aspect-ratio: 5 / 6; background: var(--color-linen); border: 1px solid var(--color-linen-edge); }
.cp-hero-photo img { display: block; width: 100%; height: 100%; object-fit: contain; transition: opacity var(--dur-short) var(--ease-out); }
.cp-hero-photo:hover .ph { border-color: var(--color-accent); }
.cp-hero-photo:active img { opacity: 0.88; }
.cp-hero h2 { text-wrap: balance; margin: 0; font: 600 var(--text-3xl)/1.15 var(--font-display); font-synthesis: none; overflow-wrap: break-word; min-width: 0; }
.cp-hero .cp-facts { margin: 0; font-size: var(--text-sm); color: var(--color-ink-2); }
.cp-hero .cp-prov { margin: 0; font-size: var(--text-xs); color: var(--color-muted); }
.cp-actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-top: var(--space-xs); }
.cp-btn { display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--space-md); border: 1.5px solid var(--color-accent); border-radius: var(--radius-pill); background: none; font-size: var(--text-sm); font-weight: 700; color: var(--color-ink); text-decoration: none; transition: background-color var(--dur-micro) var(--ease-out); }
.cp-btn:hover { background: var(--color-paper-3); }
.cp-btn:active { background: var(--color-paper-2); }
#coin-panel .cp-btn.is-primary, #coin-zoom .cp-btn.is-primary { background: var(--color-accent); color: var(--color-accent-ink); }
#coin-panel a.cp-btn { text-decoration: none; }
#coin-zoom button { font: inherit; cursor: pointer; color: var(--color-ink); }
.cp-btn.is-primary:hover { background: var(--color-accent-2); border-color: var(--color-accent-2); }
.cp-btn.is-primary:active { background: var(--color-accent); }
.cp-btn:disabled { border-color: var(--color-rule); color: var(--color-muted); cursor: default; }
.cp-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: var(--space-2xs); width: 100%; margin-top: var(--space-xs); }
.cp-strip button { padding: 0; border: 1px solid var(--color-linen-edge); background: none; cursor: zoom-in; aspect-ratio: 1; overflow: hidden; }
.cp-strip img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cp-strip button:hover img { opacity: 0.86; }
.cp-strip button:active img { opacity: 0.74; }

.cp-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-md); margin: 0; padding: var(--space-xs) 0; border-top: 1.5px solid var(--color-accent); font-size: var(--text-sm); font-weight: 500; color: var(--color-ink-2); }
.cp-list { list-style: none; margin: 0 0 var(--space-lg); padding: 0; }
.cp-row { border-top: 1px solid var(--color-rule); }
.cp-row > button { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: var(--space-sm); width: 100%; min-height: 64px; padding: var(--space-2xs) 0; border: 0; background: none; text-align: left; }
.cp-row > button:hover .cp-name { color: var(--color-accent-2); }
.cp-row > button:active .cp-name { color: var(--color-accent); }
.cp-row.is-current { border-top-color: var(--color-accent); }
.cp-row .th { display: block; overflow: hidden; width: 52px; height: 52px; background: var(--color-linen); border: 1px solid var(--color-linen-edge); }
.cp-row .th img { display: block; width: 100%; height: 100%; object-fit: contain; }
.cp-name { display: block; font: 600 var(--text-lg)/1.3 var(--font-display); font-synthesis: none; overflow-wrap: anywhere; transition: color var(--dur-micro) var(--ease-out); }
.cp-sub { display: block; font-size: var(--text-xs); color: var(--color-muted); }
.cp-n { font-size: var(--text-sm); color: var(--color-ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cp-empty { margin: 0 0 var(--space-lg); padding: var(--space-md) 0; border-top: 1px solid var(--color-rule); color: var(--color-ink-2); }
.cp-skeleton { height: 64px; border-top: 1px solid var(--color-rule); background: linear-gradient(90deg, var(--color-paper) 0 52px, transparent 52px), var(--color-paper-2); }
.cp-more { margin: 0 0 var(--space-lg); }

.cp-back { display: inline-flex; align-items: center; min-height: 40px; margin: 0 0 var(--space-xs); padding: 0; border: 0; background: none; font-size: var(--text-sm); color: var(--color-ink-2); text-decoration: underline; text-decoration-color: var(--color-accent); text-underline-offset: 0.25em; }
.cp-back:hover { color: var(--color-ink); text-decoration-thickness: 2px; }
.cp-place-title { text-wrap: balance; margin: 0 0 var(--space-2xs); font: 600 var(--text-3xl)/1.15 var(--font-display); font-synthesis: none; overflow-wrap: break-word; min-width: 0; }
.cp-lede { margin: 0 0 var(--space-md); font-size: var(--text-sm); color: var(--color-muted); }
.cp-h { margin: var(--space-lg) 0 0; padding: var(--space-xs) 0; border-top: 1px solid var(--color-muted); font-size: var(--text-sm); font-weight: 500; color: var(--color-ink-2); }
.cp-item { border-top: 1px solid var(--color-rule); padding: var(--space-sm) 0; }
.cp-item p { margin: var(--space-2xs) 0 0; font-size: var(--text-sm); color: var(--color-ink-2); }
.cp-item .cp-cap, .cp-foot { font-size: var(--text-xs); color: var(--color-muted); }
.cp-note { margin: var(--space-xs) 0 var(--space-2xs); }
.cp-note button { display: block; width: 100%; padding: var(--space-xs); border: 1px solid var(--color-linen-edge); background: var(--color-linen); cursor: zoom-in; }
.cp-note button:hover { border-color: var(--color-accent); }
.cp-note img { display: block; width: 100%; max-height: 340px; object-fit: contain; }
.cp-note figcaption { margin-top: var(--space-2xs); font-size: var(--text-xs); color: var(--color-muted); }
#coin-zoom .cp-btn[hidden] { display: none; }
.cp-foot { margin: var(--space-lg) 0 0; padding-top: var(--space-xs); border-top: 1px solid var(--color-rule); }
#coin-panel a { color: var(--color-ink); text-decoration: underline; text-decoration-color: var(--color-accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
#coin-panel a:hover { text-decoration-thickness: 2px; }
.cp-chips { display: flex; flex-wrap: wrap; gap: var(--space-xs); padding: var(--space-xs) 0 0; }
.cp-chips button { min-height: 36px; padding: 0 var(--space-sm); border: 1px solid var(--color-rule); border-radius: var(--radius-pill); background: none; font-size: var(--text-sm); color: var(--color-ink-2); }
.cp-chips button:hover { border-color: var(--color-muted); color: var(--color-ink); }
.cp-chips button:active { background: var(--color-paper-2); }

/* the atlas's own chronicle, re-seated as the second tab */
#cp-history .dynasty-banner { background: none; border: 0; padding: 0; }
#cp-history #dynasty-title { font: 600 var(--text-2xl)/1.2 var(--font-display); font-synthesis: none; color: var(--color-ink); }
#cp-history .span-label, #cp-history .seat-tag { color: var(--color-muted); background: none; border: 0; padding: 0; letter-spacing: 0; }
#cp-history .seat-row { color: var(--color-ink-2); font-size: var(--text-sm); }
#cp-history .dynasty-desc { margin: var(--space-sm) 0 var(--space-md); font-size: var(--text-sm); line-height: 1.7; color: var(--color-ink-2); }
#cp-history .milestone-section h3 { margin: 0; padding: var(--space-xs) 0; border-top: 1.5px solid var(--color-accent); font: 500 var(--text-sm)/1.5 var(--font-body); color: var(--color-ink-2); letter-spacing: 0; }
#cp-history #milestone-list { gap: 0; }
#cp-history #milestone-list li { background: none; border: 0; border-top: 1px solid var(--color-rule); border-radius: 0; padding: var(--space-xs) 0; font-size: var(--text-sm); color: var(--color-ink-2); }
#cp-history #milestone-list li:hover { background: var(--color-paper-3); }
#cp-history #milestone-list li.is-current, #cp-history #milestone-list li.is-active { border-top-color: var(--color-accent); color: var(--color-ink); box-shadow: none; }
#cp-history #milestone-list .ev-yr { color: var(--color-ink); font-family: var(--font-display); font-variant-numeric: tabular-nums; }
#cp-history .disclaimer-box { margin-top: var(--space-lg); padding: var(--space-xs) 0 0; background: none; border: 0; border-top: 1px solid var(--color-rule); border-radius: 0; font-size: var(--text-xs); color: var(--color-muted); }

/* ---------- timeline dock ---------- */
html.coin-ed #scrubber-dock { --scrubber-surface: var(--color-paper-2); background: var(--color-paper-2); border-top: 1px solid var(--color-rule); backdrop-filter: none; padding: var(--space-sm) var(--space-lg) var(--space-md); gap: var(--space-md); }
html.coin-ed #scrubber-dock.is-autoplaying { background: var(--color-paper-2); }
html.coin-ed .playback-controls-group { gap: var(--space-xs); }
html.coin-ed .round-btn { width: 44px; height: 44px; border: 0; background: var(--color-accent); color: var(--color-accent-ink); box-shadow: none; transition: background-color var(--dur-micro) var(--ease-out); }
html.coin-ed .round-btn:hover { background: var(--color-accent-2); }
html.coin-ed .round-btn:active { background: var(--color-accent); }
html.coin-ed .play-speed-btn, html.coin-ed #act-coin-restart { min-width: 44px; height: 40px; padding: 0 var(--space-sm); border: 1px solid var(--color-rule); border-radius: var(--radius-pill); background: none; color: var(--color-ink); box-shadow: none; font-size: var(--text-sm); font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2xs); transition: background-color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out); }
html.coin-ed .play-speed-btn:hover, html.coin-ed #act-coin-restart:hover { background: var(--color-paper-3); border-color: var(--color-muted); }
html.coin-ed .play-speed-btn:active, html.coin-ed #act-coin-restart:active { background: var(--color-paper); }
html.coin-ed #scrubber-track { background: var(--color-paper); border-radius: 0; box-shadow: none; }
html.coin-ed #dynasty-bands { filter: saturate(0.5) brightness(0.84); }
html.coin-ed .band-label { color: #fff; text-shadow: 0 0 3px oklch(8% 0.01 75 / 0.9), 0 1px 2px oklch(8% 0.01 75 / 0.8); }
html.coin-ed #scrubber-Bubble { background: var(--color-ink); color: var(--color-accent-ink); border-radius: 0; font-family: var(--font-body); }
html.coin-ed #scrubber-handle { background: var(--color-accent); box-shadow: none; }
html.coin-ed #scrubber-ticks { color: var(--color-muted); }
html.coin-ed .year-stepper { background: var(--color-paper); border: 1px solid var(--color-rule); border-radius: 0; color: var(--color-ink); min-height: 40px; }
html.coin-ed .year-stepper input { background: none; color: var(--color-ink); font-variant-numeric: tabular-nums; }
html.coin-ed .year-stepper .unit-label { color: var(--color-muted); }
html.coin-ed .step-nav-btn { background: none; color: var(--color-ink); border: 0; min-width: 32px; min-height: 32px; }
html.coin-ed .step-nav-btn:hover { background: var(--color-paper-3); }
html.coin-ed .timeline-crop-mask { background: var(--color-scrim); }

/* ---------- the guided tour: caption card on the map, stops marked on the timeline ---------- */
#coin-tour-card { position: absolute; left: var(--space-lg); bottom: var(--space-lg); z-index: 30; width: min(380px, calc(100% - 2 * var(--space-lg))); padding: var(--space-md) var(--space-lg); background: var(--color-scrim); border: 1px solid var(--color-rule); border-top: 2px solid var(--color-accent); color: var(--color-ink); pointer-events: none; }
#coin-tour-card[hidden] { display: none; }
.ct-kicker { display: flex; justify-content: space-between; gap: var(--space-md); margin: 0 0 var(--space-2xs); font-size: var(--text-xs); color: var(--color-accent); font-variant-numeric: tabular-nums; }
.ct-count { color: var(--color-muted); }
.ct-title { margin: 0 0 var(--space-xs); font: 600 var(--text-xl)/1.25 var(--font-display); font-synthesis: none; text-wrap: balance; }
.ct-text { margin: 0; font-size: var(--text-sm); line-height: 1.7; color: var(--color-ink-2); text-wrap: pretty; }
.ct-progress { height: 2px; margin-top: var(--space-sm); background: var(--color-rule); overflow: hidden; }
.ct-progress span { display: block; height: 100%; background: var(--color-accent-deep); transform: scaleX(0); transform-origin: left center; }
#coin-tour-card.is-in { animation: ct-card-in 380ms var(--ease-out) 160ms both; }
#coin-tour-card.is-in > * { animation: ct-line-in 460ms var(--ease-out) both; }
#coin-tour-card.is-in .ct-kicker { animation-delay: 200ms; }
#coin-tour-card.is-in .ct-title { animation-delay: 270ms; }
#coin-tour-card.is-in .ct-text { animation-delay: 340ms; }
#coin-tour-card.is-in .ct-progress { animation-delay: 400ms; }
#coin-tour-card.is-out { animation: ct-out 220ms ease-in both; }
@keyframes ct-card-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes ct-line-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes ct-out { to { opacity: 0; transform: translateY(-6px); } }
#coin-tour-ticks { position: absolute; inset: 0; pointer-events: none; }
#coin-tour-ticks i { position: absolute; top: 0; width: 2px; height: 5px; margin-left: -1px; background: var(--color-accent-deep); transition: height var(--dur-short) var(--ease-out), background-color var(--dur-short) var(--ease-out); }
#coin-tour-ticks i.is-on { height: 9px; background: var(--color-accent-2); }
/* the year runs dim while the tour sweeps and lights up when it lands on a key year */
.cp-year { transition: color var(--dur-short) var(--ease-out); }
html.is-tour-moving .cp-year { color: var(--color-muted); }

/* ---------- close reading: one coin at full size ---------- */
#coin-zoom { position: fixed; inset: 0; z-index: 400; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--color-scrim); color: var(--color-ink); }
#coin-zoom[hidden] { display: none; }
.cz-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding: var(--space-sm) var(--space-lg); border-bottom: 1px solid var(--color-rule); }
.cz-bar h2 { text-wrap: balance; margin: 0; font: 600 var(--text-xl)/1.2 var(--font-display); font-synthesis: none; overflow-wrap: break-word; min-width: 0; }
.cz-bar p { margin: 0; font-size: var(--text-xs); color: var(--color-muted); }
.cz-bar p a { color: var(--color-ink-2); text-decoration: underline; text-decoration-color: var(--color-rule); text-underline-offset: 0.2em; }
.cz-bar p a:hover { color: var(--color-ink); }
.cz-tools { display: flex; gap: var(--space-xs); flex: none; }
.cz-stage { overflow: auto; display: flex; padding: var(--space-lg); cursor: zoom-in; }
.cz-stage.is-deep { cursor: zoom-out; }
.cz-stage img { margin: auto; max-width: 100%; max-height: calc(100dvh - 140px); object-fit: contain; display: block; }
.cz-stage.is-deep img { margin: 0; max-width: none; max-height: none; width: 240%; }

/* ---------- phone and narrow screens: the map on top, the panel as a sheet ---------- */
@media (max-width: 60rem) {
  html.coin-ed #nav-bar { padding: var(--space-xs) var(--space-md); min-height: 52px; }
  html.coin-ed .brand-group .seal-mark { font-size: var(--text-xl); }
  html.coin-ed .brand-group .subtitle-mark, html.coin-ed #coin-credit, html.coin-ed #map-key, html.coin-ed #scale-bar-box { display: none; }
  html.coin-ed .action-btn { padding: 0 var(--space-sm); }
  html.coin-ed #workspace-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  html.coin-ed #viewport-frame { grid-row: 1; grid-column: 1; }
  #coin-panel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 40; height: var(--sheet-peek, 148px); max-height: 100%; border-left: 0; border-top: 1px solid var(--color-rule); transition: transform var(--dur-short) var(--ease-out); grid-template-rows: auto minmax(0, 1fr); }
  #coin-panel.is-open { height: min(64%, 600px); grid-template-rows: auto auto minmax(0, 1fr); }
  #coin-panel:not(.is-open) .cp-tabs, #coin-panel:not(.is-open) #cp-history { display: none; }
  #coin-panel:not(.is-open) .cp-body { overflow: hidden; padding-top: 0; }
  #coin-panel:not(.is-open) .cp-hero { grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 0 var(--space-sm); margin: 0; }
  #coin-panel:not(.is-open) .cp-hero-photo { grid-row: 1 / span 2; grid-template-columns: 64px; margin: 0; }
  #coin-panel:not(.is-open) .cp-hero-photo .ph + .ph { display: none; }
  #coin-panel:not(.is-open) .cp-hero-photo .ph { aspect-ratio: 1; }
  #coin-panel:not(.is-open) .cp-hero h2 { font-size: var(--text-lg); }
  .cp-credit-foot { display: block; margin: var(--space-md) 0 0; padding-top: var(--space-xs); border-top: 1px solid var(--color-rule); }
  #coin-panel:not(.is-open) .cp-hero .cp-prov, #coin-panel:not(.is-open) .cp-hero .cp-credit, #coin-panel:not(.is-open) .cp-actions, #coin-panel:not(.is-open) .cp-strip { display: none; }
  #coin-panel:not(.is-open) .cp-back, #coin-panel:not(.is-open) .cp-lede { display: none; }
  /* the collapsed sheet shows whole elements only: the hero (or the place title) and nothing that would peek in below it */
  #coin-panel:not(.is-open) .cp-body > :not(.cp-hero):not(.cp-place-title):not(.cp-empty):not(.cp-skeleton), #coin-panel:not(.is-open) .cp-skeleton ~ .cp-skeleton { display: none; }
  #coin-panel:not(.is-open) .cp-body { padding-bottom: 0; }
  #coin-panel:not(.is-open) .cp-hero h2 { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #coin-panel:not(.is-open) .cp-hero .cp-facts { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; line-height: 1.4; }
  /* the reset-view button rides above the sheet, whichever height it has */
  html.coin-ed #canvas-br-dock { right: var(--space-sm); bottom: calc(var(--sheet-peek, 148px) + var(--space-sm)); transition: bottom var(--dur-short) var(--ease-out); }
  html.coin-ed #workspace-body:has(#coin-panel.is-open) #canvas-br-dock { bottom: calc(min(64%, 600px) + var(--space-sm)); }
  #coin-panel:not(.is-open) .cp-place-title { font-size: var(--text-lg); margin: 0 0 var(--space-2xs); }
  .cp-head { padding: var(--space-xs) var(--space-md) var(--space-2xs); align-items: center; }
  .cp-year { font-size: var(--text-2xl); }
  .cp-year small { font-size: var(--text-md); }
  .cp-era { grid-column: 1; grid-row: 2; font-size: var(--text-sm); }
  .cp-sum { display: none; }
  #coin-panel.is-open .cp-sum { display: block; }
  .cp-sheet-toggle { display: inline-flex; align-items: center; justify-content: center; grid-column: 2; grid-row: 1 / span 2; min-width: 72px; min-height: 44px; padding: 0 var(--space-sm); border: 1.5px solid var(--color-accent); border-radius: var(--radius-pill); background: none; font-size: var(--text-sm); font-weight: 700; }
  .cp-sheet-toggle:active { background: var(--color-paper-2); }
  .cp-body { padding: var(--space-md); }
  .cp-tabs { padding: 0 var(--space-md); }
  .cp-hero h2, .cp-place-title { font-size: var(--text-2xl); }
  html.coin-ed #scrubber-dock { padding: var(--space-xs) var(--space-md) var(--space-sm); gap: var(--space-xs); }
  html.coin-ed .round-btn { width: 44px; height: 44px; }
  html.coin-ed #act-play-speed, html.coin-ed #scrubber-Bubble { display: none; }
  .cz-bar { padding: var(--space-xs) var(--space-md); }
  .cz-stage { padding: var(--space-sm); }
  #coin-tour-card { top: 60px; bottom: auto; left: var(--space-sm); right: var(--space-sm); width: auto; padding: var(--space-sm) var(--space-md); }
  .ct-title { font-size: var(--text-lg); margin-bottom: var(--space-2xs); }
  .ct-text { line-height: 1.6; }
}

/* narrow phones: the English wordmark plus Layers, the two language buttons and the dock must all fit, so the wordmark
   shrinks and the buttons lose padding (checked at 360, 390 and 430 px in every language) */
@media (max-width: 30rem) {
  html.coin-ed #nav-bar { padding-inline: var(--space-sm); gap: var(--space-xs); }
  html.coin-ed .brand-group { min-width: 0; flex: 0 1 auto; }
  html.coin-ed .brand-group .seal-mark { font-size: 1.15rem; white-space: nowrap; }
  html.coin-ed .control-strip { flex: 0 0 auto; gap: var(--space-2xs); overflow: visible; }
  html.coin-ed .action-btn { padding: 0 var(--space-xs); min-height: 34px; }
  html.coin-ed .layers-trigger-btn .caret-mark { display: none; }
  html.coin-ed .locale-pill-group .action-btn { min-width: 36px; }
}

/* phone timeline: upstream lays the dock out as a 28px row over the track; our controls are bigger, so the row grows to fit them */
@media (max-width: 640px) {
  html.coin-ed #scrubber-dock { grid-template-rows: 40px auto; padding-inline: 20px; }
  html.coin-ed .round-btn { width: 40px; height: 40px; }
  html.coin-ed .year-stepper { align-self: center; min-height: 0; padding: 0; gap: 0; }
  html.coin-ed .step-nav-btn { width: 40px; height: 40px; min-width: 0; min-height: 0; font-size: 22px; line-height: 1; }
  /* crop handles sit beside the track, in the dock's side padding, so they never cover the first and last era labels */
  html.coin-ed .timeline-edge { width: 20px; }
  html.coin-ed .timeline-edge-start { left: -20px; justify-content: flex-end; }
  html.coin-ed .timeline-edge-end { right: -20px; justify-content: flex-start; }
  html.coin-ed .timeline-edge-start::after { right: 4px; }
  html.coin-ed .timeline-edge-end::after { left: 4px; }
}

/* desktop: a compact hero, so the year's list starts in the first screen */
@media (min-width: 60.0625rem) {
  .cp-hero-photo { grid-template-columns: repeat(2, auto); }
  .cp-hero-photo .ph { width: auto; height: clamp(88px, 13vh, 140px); aspect-ratio: 1; }
  .cp-hero h2 { font-size: var(--text-2xl); }
  .cp-strip { grid-template-columns: repeat(6, 40px); justify-content: start; }
  .cp-strip button { aspect-ratio: 1; width: 40px; height: 40px; }
  #coin-panel .cp-actions .cp-btn { min-height: 36px; padding: 0 10px; font-size: 0.8125rem; }
  .cp-strip button:nth-child(n+7) { display: none; }
}
@media (min-width: 60.0625rem) and (max-height: 860px) {
  .cp-head { padding: var(--space-md) var(--space-lg) var(--space-sm); }
  .cp-year { font-size: 3rem; }
  .cp-sum { font-size: var(--text-xs); }
  .cp-body { padding-top: var(--space-md); }
  .cp-hero { margin-bottom: var(--space-md); gap: var(--space-2xs); }
  /* the English title carries the Chinese name in brackets; at this height it must stay on one line so the year's list starts in the first screen */
  .cp-hero h2 { font-size: var(--text-xl); }
  .cp-hero h2 [lang="zh"] { font-size: 0.85em; }
  .cp-actions { margin-top: var(--space-2xs); }
  .cp-strip { grid-template-columns: repeat(6, 34px); } .cp-strip button { width: 34px; height: 34px; }
}

@media (min-width: 641px) {
  html.coin-ed #map-search-box { width: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  #atlas-svg #grp-coins .coin-find, #atlas-svg #grp-coins .cf-dim, #atlas-svg #grp-coins .cf-lift, #atlas-svg #grp-coins .cf-ripple { transition: none !important; animation: none !important; }
  .cp-hero, .cp-hero-photo img, #coin-panel, .cp-tabs button, .cp-btn, .cp-name,
  #coin-tour-card, #coin-tour-card > *, #coin-tour-ticks i, .cp-year { transition: none !important; animation: none !important; }
}

/* ---------- publish: font fallbacks ----------
 * The Google Fonts stylesheets load without blocking and may never arrive (blocked in mainland China), so every stack
 * ends in system CJK fonts for macOS/iOS, Windows, Android and Linux before the generic family. */
:root {
  --font-display: "Prata", "Coin Serif", "Noto Serif SC", "Songti SC", "STSong", "SimSun", "Source Han Serif SC", "Noto Serif CJK SC", serif;
  --font-body: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "WenQuanYi Micro Hei", ui-sans-serif, system-ui, sans-serif;
  --font-wordmark: "Coin Brush", "Ma Shan Zheng", "STKaiti", "KaiTi", "Kaiti SC", var(--font-display);
  --serif-stack: "Noto Serif SC", "Songti SC", "STSong", "SimSun", "Source Han Serif SC", "Noto Serif CJK SC", serif;
  --sans-stack: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --calligraphy-stack: "Ma Shan Zheng", "STKaiti", "KaiTi", "Kaiti SC", var(--serif-stack);
}
#atlas-svg {
  --serif-stack: "Songti SC", "STSong", "SimSun", "Source Han Serif SC", "Noto Serif CJK SC", serif;
  --sans-stack: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --calligraphy-stack: "STKaiti", "KaiTi", "Kaiti SC", var(--serif-stack);
}

/* keyboard focus on the map's coins: the SVG outline is unreliable, so the plate itself rings in the focus colour */
#grp-coins .coin-find:focus { outline: none; }
#grp-coins .coin-find:focus-visible .cf-plate, #grp-coins .coin-find:focus-visible .cf-note-plate { stroke: var(--color-focus); stroke-width: 3.4; }
#grp-coins .coin-find:focus-visible .cf-ring { stroke: var(--color-focus); stroke-width: 2.4; opacity: 1; }
