/* 博物 BoWu — the bowu.org teaser's night gallery: a warm near-black ground, cream ink, a gold
   glow on 博物; the cinnabar seal stays the one loud element and marks only the national list.
   System fonts only (no third-party requests — the CSP is style-src 'self'); Songti stands in for
   the teaser's Noto Serif SC and the system sans at weight 300 for its Inter. */
:root {
  --ground: #080604;
  --ground-warm: #130d08;
  --surface: #120c08;
  --ink: #ede4d0;
  --ink-soft: rgba(237, 228, 208, .62);
  --ink-faint: rgba(237, 228, 208, .3);
  --accent: #c9a86a;       /* gold */
  --accent-bright: #d9b97f;
  --line: rgba(237, 228, 208, .14);
  --cinnabar: #d65a4a;     /* seal paste, lifted for a dark ground */
  --glow: 0 0 40px rgba(201, 168, 106, .35), 0 0 80px rgba(201, 168, 106, .2);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "Noto Serif SC", serif;
  --sans: -apple-system, "PingFang SC", "PingFang TC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color-scheme: dark;
}
:lang(zh-Hant) { --serif: "Songti TC", "Noto Serif CJK TC", "Source Han Serif TC", "Noto Serif TC", serif; }

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* Reason: .filters/.wall set display, which beats the hidden attribute. */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font: 300 16px/1.65 var(--sans); letter-spacing: .01em;
  background: radial-gradient(ellipse at 50% 0%, var(--ground-warm) 0%, var(--ground) 70%) fixed var(--ground);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
/* The teaser's dust motes, still: a faint fixed field behind everything. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .6;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(237, 228, 208, .4), transparent 60%),
    radial-gradient(1px 1px at 78% 22%, rgba(237, 228, 208, .35), transparent 60%),
    radial-gradient(1px 1px at 32% 54%, rgba(201, 168, 106, .35), transparent 60%),
    radial-gradient(1.5px 1.5px at 65% 72%, rgba(237, 228, 208, .3), transparent 60%),
    radial-gradient(1px 1px at 88% 88%, rgba(201, 168, 106, .3), transparent 60%),
    radial-gradient(1px 1px at 8% 82%, rgba(237, 228, 208, .35), transparent 60%),
    radial-gradient(1px 1px at 92% 42%, rgba(237, 228, 208, .3), transparent 60%),
    radial-gradient(1px 1px at 48% 8%, rgba(201, 168, 106, .3), transparent 60%);
}
body.drawer-open { overflow: hidden; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-bright); }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.masthead {
  display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: 0 20px;
  padding: 28px clamp(16px, 4vw, 48px) 16px; border-bottom: 1px solid var(--line);
}
.logo {
  font: 500 clamp(44px, 9vw, 76px)/1 var(--serif); color: var(--ink); text-decoration: none;
  letter-spacing: .08em; text-shadow: var(--glow);
}
.logo:hover { color: var(--ink); }
/* Reason: the teaser's one reveal, on the Collection Wall only — not replayed on every page. */
@media (prefers-reduced-motion: no-preference) {
  body:has(#wall) .logo { animation: reveal 1.4s cubic-bezier(.2, .8, .2, 1) both; }
  @keyframes reveal { from { opacity: 0; filter: blur(6px); } }
}
.tagline { margin: 0 0 8px; color: var(--ink-soft); font-family: var(--serif); font-size: 16px; letter-spacing: .18em; }
.top-links { display: flex; gap: 18px; align-items: center; margin-bottom: 6px; font-size: 14px; letter-spacing: .08em; }
.top-links > a { color: var(--ink-soft); text-decoration: none; }
.top-links > a:hover { color: var(--ink); }
.langs {
  display: inline-flex; gap: 2px; padding: 3px; border: 1px solid rgba(237, 228, 208, .18); border-radius: 999px;
  background: rgba(255, 255, 255, .04); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.langs button {
  border: 0; background: none; padding: 3px 12px; border-radius: 999px; cursor: pointer;
  color: var(--ink-soft); font-size: 13px; transition: background .2s, color .2s;
}
.langs button:hover { color: var(--ink); background: rgba(237, 228, 208, .06); }
.langs button[aria-pressed="true"] { background: var(--ink); color: var(--ground); }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end;
  padding: 14px clamp(16px, 4vw, 48px); font-size: 14px; color: var(--ink-soft);
}
.filters label { display: grid; gap: 2px; }
.filters label > span { font-size: 12px; letter-spacing: .12em; color: var(--ink-faint); }
.filters select, .museum-search select, .museum-search input[type="search"] {
  min-width: 8.5em; padding: 6px 2px; border: 0; border-bottom: 1px solid var(--ink-faint); border-radius: 0;
  background: transparent; color: var(--ink); transition: border-color .3s;
}
.filters select:focus, .museum-search select:focus, .museum-search input[type="search"]:focus { border-color: var(--accent); outline: none; }
.filters select option, .museum-search select option { background: var(--surface); color: var(--ink); }
.filters .check { display: flex; gap: 6px; align-items: center; padding-bottom: 6px; }
.filters .check input { accent-color: var(--accent); }
.count { margin-left: auto; padding-bottom: 6px; }

main { padding: 8px clamp(16px, 4vw, 48px) 64px; }
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 210px), 1fr)); gap: 28px 18px; }
.empty { color: var(--ink-soft); font-size: 17px; padding: 40px 0; }

.card { display: grid; gap: 2px; text-align: left; padding: 0; border: 0; background: none; cursor: pointer; }
.card-visual {
  position: relative; display: block; aspect-ratio: 4 / 5; overflow: hidden;
  background: var(--surface); border-radius: 2px; margin-bottom: 10px;
  box-shadow: 0 0 0 1px var(--line); transition: box-shadow .35s;
}
.card:hover .card-visual, .card:focus-visible .card-visual { box-shadow: 0 0 0 1px rgba(201, 168, 106, .45), 0 0 32px rgba(201, 168, 106, .14); }
.card-visual img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-visual img { filter: brightness(.94); transition: filter .35s; }
.card:hover .card-visual img { filter: brightness(1.04); }
.card-name { font: 500 17px/1.35 var(--serif); letter-spacing: .03em; }
.card-meta { font-size: 13px; color: var(--ink-soft); line-height: 1.4; }
.card.is-seen .card-name::after { content: " ✓"; color: var(--accent); font-family: var(--sans); font-size: 13px; }

.seal {
  display: inline-grid; place-items: center; width: 1.75em; padding: 4px 2px;
  font: 700 13px/1.05 var(--serif); color: var(--cinnabar); border: 2px solid var(--cinnabar);
  border-radius: 3px; writing-mode: vertical-rl; letter-spacing: .1em;
  background: color-mix(in srgb, var(--ground) 78%, transparent);
}
.card-visual .seal { position: absolute; top: 8px; right: 8px; transform: rotate(-4deg); }
.video-mark {
  position: absolute; left: 8px; bottom: 8px; display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: color-mix(in srgb, var(--ground) 70%, transparent); color: var(--accent);
  box-shadow: 0 0 0 1px rgba(201, 168, 106, .5);
}
.video-mark svg { width: 13px; height: 13px; fill: currentColor; margin-left: 2px; }

.typo-card {
  display: grid; place-content: center; gap: 10px; height: 100%; min-height: 200px; padding: 16px; text-align: center;
  background: repeating-linear-gradient(0deg, transparent 0 31px, var(--line) 31px 32px), var(--surface);
}
.typo-name { font: 500 22px/1.3 var(--serif); letter-spacing: .06em; text-shadow: var(--glow); }
.typo-era { color: var(--ink-soft); font-size: 14px; }

.backdrop { position: fixed; inset: 0; background: rgba(4, 3, 2, .7); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -12px 0 40px rgba(0, 0, 0, .5); padding: 0 24px 40px;
  overscroll-behavior: contain;
}
@media (prefers-reduced-motion: no-preference) {
  .drawer:not([hidden]) { animation: slide .22s ease-out; }
  @keyframes slide { from { transform: translateX(24px); } }
}
.drawer-bar { position: sticky; top: 0; display: flex; gap: 8px; padding: 12px 0; background: var(--surface); z-index: 1; }
.drawer-bar button { border: 1px solid var(--line); background: none; border-radius: 999px; padding: 4px 14px; cursor: pointer; color: var(--ink-soft); }
.drawer-bar button:not(:disabled):hover { color: var(--ink); border-color: rgba(201, 168, 106, .55); }
.drawer-bar button:disabled { opacity: .35; cursor: default; }
.drawer-bar .close { margin-left: auto; }
.drawer-image img { width: 100%; max-height: 62vh; object-fit: contain; display: block; background: var(--ground); border-radius: 4px; }
.drawer-name { font: 500 28px/1.25 var(--serif); letter-spacing: .04em; text-shadow: 0 0 30px rgba(201, 168, 106, .25); margin: 18px 0 8px; }
.facts { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 4px 24px; margin: 0 0 12px; font-size: 14px; }
.facts dt { color: var(--ink-faint); font-size: 12px; letter-spacing: .1em; }
.facts dd { margin: 0; }
.badge { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--cinnabar); }
.story { font: 17px/1.85 var(--serif); }
.story p { margin: 0 0 1em; max-width: 34em; }
.clip { position: relative; aspect-ratio: 16 / 9; margin: 8px 0 16px; }
.clip iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 4px; }
.drawer h3 { font-size: 13px; color: var(--ink-faint); font-weight: 400; letter-spacing: .14em; margin: 20px 0 6px; }
.related-list { display: flex; flex-wrap: wrap; gap: 8px; }
.related { border: 1px solid var(--line); background: none; border-radius: 999px; padding: 3px 12px; cursor: pointer; font-family: var(--serif); color: var(--ink-soft); }
.related:hover { color: var(--ink); border-color: rgba(201, 168, 106, .55); }
.sources { padding-left: 1.1em; margin: 0; font-size: 13px; color: var(--ink-soft); }

@media (max-width: 640px) {
  .masthead { grid-template-columns: auto 1fr; padding-top: 20px; }
  .tagline { grid-column: 1 / -1; order: 3; margin-top: 8px; }
  .top-links { justify-self: end; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
  .filters select { min-width: 0; width: 100%; }
  .filters label { flex: 1 1 40%; }
  .count { margin-left: 0; }
  .drawer { padding: 0 16px 32px; }
  .facts { grid-template-columns: 1fr 1fr; }
}

.prose { max-width: 40em; padding-top: 24px; }
.prose h1 { font: 500 30px/1.3 var(--serif); margin: 0 0 12px; }
.prose h2 { font: 500 19px/1.4 var(--serif); margin: 28px 0 6px; }
.prose p { font: 17px/1.85 var(--serif); margin: 0 0 1em; }

/* Museum directory */
.page-title, .museum-title { font: 500 clamp(26px, 4vw, 34px)/1.25 var(--serif); margin: 18px 0 6px; }
.page-intro { color: var(--ink-soft); max-width: 40em; margin: 0 0 16px; }
.museum-search { padding-left: 0; padding-right: 0; }
.museum-search input[type="search"] { min-width: min(320px, 100%); }
.region h2 { font: 500 19px/1.3 var(--serif); margin: 28px 0 10px; }
.museum-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.museum-card {
  display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 2px;
  background: rgba(19, 13, 8, .6); transition: border-color .3s, box-shadow .3s; color: inherit; text-decoration: none;
}
.museum-card:hover, .museum-card:focus-visible { border-color: rgba(201, 168, 106, .55); box-shadow: 0 0 28px rgba(201, 168, 106, .1); }
.museum-name { font: 500 17px/1.35 var(--serif); letter-spacing: .03em; }
.museum-city, .museum-count { font-size: 13px; color: var(--ink-soft); }
.museum-detail { max-width: 44em; }
.museum-overview p { margin: 0 0 1em; }
.museum-facts dd { white-space: pre-line; }
.map-button {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--accent); border-radius: 999px;
  color: var(--accent); text-decoration: none; font-size: 14px; letter-spacing: .08em;
}
.map-button:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.checked, .crumb { font-size: 13px; color: var(--ink-soft); }
.museum-objects { columns: 2 220px; padding-left: 1.1em; }

/* Drawer photo strip */
.gallery { display: flex; gap: 6px; margin: 8px 0 4px; overflow-x: auto; }
.shot { flex: none; width: 64px; height: 64px; padding: 0; border: 2px solid transparent; border-radius: 6px; background: var(--surface); cursor: pointer; }
.shot img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; display: block; }
.shot[aria-pressed="true"] { border-color: var(--accent); }
.shot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* View switch and the dynasty view, "Halls of time" (BW-31) */
.views {
  display: inline-flex; gap: 2px; margin: 16px clamp(16px, 4vw, 48px) 0; padding: 3px;
  border: 1px solid rgba(237, 228, 208, .18); border-radius: 999px;
}
.views button {
  border: 0; background: none; padding: 4px 16px; border-radius: 999px; cursor: pointer;
  color: var(--ink-soft); font-size: 14px; letter-spacing: .08em; transition: background .2s, color .2s;
}
.views button:hover { color: var(--ink); background: rgba(237, 228, 208, .06); }
.views button[aria-pressed="true"] { background: var(--ink); color: var(--ground); }

.halls { position: relative; }
.rail {
  position: fixed; left: clamp(4px, 1.4vw, 20px); top: 50%; transform: translateY(-50%); z-index: 2;
  display: grid; gap: 4px;
}
.rail button {
  border: 0; background: none; padding: 2px 6px; cursor: pointer;
  font: 15px/1.3 var(--serif); color: var(--ink-faint); transition: color .3s, text-shadow .3s;
}
.rail button:hover { color: var(--ink); }
.rail button[aria-current] { color: var(--accent); text-shadow: 0 0 14px rgba(201, 168, 106, .6); }

.hall {
  position: relative; min-height: 88vh; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px 48px; align-items: center; padding: 48px 0 48px clamp(28px, 4vw, 56px);
  border-bottom: 1px solid var(--line); scroll-margin-top: 12px; overflow: hidden;
  isolation: isolate; /* Reason: keeps the z-index:-1 glyph inside the hall, above the page ground. */
}
.hall-glyph {
  position: absolute; left: 24%; top: 50%; transform: translateY(-50%); z-index: -1; /* between the text and the key treasure */
  font: 500 clamp(220px, 34vw, 460px)/1 var(--serif); color: rgba(237, 228, 208, .05);
  text-shadow: 0 0 80px rgba(201, 168, 106, .18); pointer-events: none; user-select: none;
  transition: color 1.2s, text-shadow 1.2s;
}
.hall.in-view .hall-glyph { color: rgba(237, 228, 208, .085); text-shadow: 0 0 90px rgba(201, 168, 106, .32), 0 0 180px rgba(201, 168, 106, .14); }
.hall-name { font: 500 clamp(30px, 5vw, 44px)/1.2 var(--serif); letter-spacing: .2em; margin: 0; text-shadow: var(--glow); }
.hall-era { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; letter-spacing: .08em; }
.hall-hero-name { margin: 22px 0 0; font: 18px/1.4 var(--serif); color: var(--accent); letter-spacing: .06em; }
.hall-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 14px; max-width: 520px; }
.hall-thumb, .hall-hero { position: relative; padding: 0; border: 0; background: var(--surface); cursor: pointer; overflow: hidden; }
.hall-thumb { width: 44px; height: 55px; border-radius: 2px; box-shadow: 0 0 0 1px var(--line); transition: box-shadow .3s, transform .3s; }
.hall-thumb img, .hall-hero img { width: 100%; height: 100%; object-fit: cover; display: block; filter: brightness(.9); transition: filter .3s; }
.hall-hero img { object-fit: contain; background: var(--ground); } /* the whole object, uncropped */
.hall-thumb:hover, .hall-thumb:focus-visible { box-shadow: 0 0 0 1px rgba(201, 168, 106, .7), 0 0 18px rgba(201, 168, 106, .25); transform: translateY(-2px); }
.hall-thumb:hover img, .hall-hero:hover img { filter: brightness(1.05); }
.hall-hero {
  width: clamp(220px, 28vw, 340px); aspect-ratio: 4 / 5; margin-right: clamp(16px, 6vw, 96px); border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(201, 168, 106, .45), 0 0 48px rgba(201, 168, 106, .16);
}
.hall .is-seen::after {
  content: "✓"; position: absolute; right: 3px; bottom: 1px; font-size: 11px; color: var(--accent);
  text-shadow: 0 0 4px #000;
}
.hall-typo { display: grid; place-items: center; height: 100%; padding: 12px; font: 500 20px/1.3 var(--serif); text-align: center; }
.hall-count {
  border: 1px solid rgba(201, 168, 106, .5); background: none; border-radius: 999px; padding: 5px 16px;
  color: var(--accent); cursor: pointer; font-size: 13px; letter-spacing: .06em;
}
.hall-count:hover { color: var(--accent-bright); background: rgba(201, 168, 106, .08); }

@media (max-width: 720px) {
  .hall { grid-template-columns: 1fr; min-height: 0; padding: 36px 0 36px 30px; gap: 18px; }
  .hall-hero { order: -1; width: min(240px, 70vw); margin: 0; }
  .hall-glyph { left: auto; right: -4%; top: 40px; transform: none; font-size: 240px; }
  .hall-thumb { width: 38px; height: 48px; }
  .rail { left: 2px; gap: 0; }
  .rail button { font-size: 13px; padding: 2px 4px; }
}
