:root {
  color-scheme: dark;
  --ground: #102a20;
  --panel: #17392b;
  --ink: #f6eddb;
  --muted: #bdc8b5;
  --line: #b9af8449;
  --gold: #dfbd78;
  --sans: "Encyclopedia Han", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --serif: "Encyclopedia Serif", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 15px/1.5 var(--sans); }
button { font: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
.wrap { width: min(100% - 64px, 1560px); margin-inline: auto; }
.skip-link { position: fixed; top: 8px; left: 12px; transform: translateY(-160%); padding: 10px 14px; background: var(--ink); color: var(--ground); z-index: 4; }
.skip-link:focus { transform: none; }
.topbar { border-bottom: 1px solid var(--line); }
.masthead { display: flex; align-items: center; gap: 18px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); font-size: 13px; font-weight: 600; letter-spacing: .015em; white-space: nowrap; }
.brand img {
  display: block;
  flex: none;
  width: 36px;
  height: 36px;
  clip-path: inset(3% round 23%);
  filter: grayscale(1) brightness(.87) contrast(5) sepia(.16);
  mix-blend-mode: screen;
}
.masthead h1 { margin: 0; border-left: 1px solid var(--line); padding-left: 18px; font-weight: 500; font-size: 21px; line-height: 1.2; }
.masthead h1 span { margin-inline-start: 9px; font: 23px/1.2 var(--serif); }
.topbar-actions { display: flex; align-items: center; gap: 14px; margin-inline-start: auto; }
.back { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; white-space: nowrap; text-decoration: none; }
.back:hover { color: var(--gold); }
.zoo-fullscreen {
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--gold);
  white-space: nowrap;
  cursor: pointer;
}
.zoo-fullscreen:hover { background: var(--panel); }
:root:fullscreen { background: var(--ground); }
:is(.zoo-expanded, :fullscreen) .masthead { min-height: 48px; }
:is(.zoo-expanded, :fullscreen) .zoo-map { margin-top: 6px; }

.zoo-map { margin-top: 14px; position: relative; overflow: hidden; isolation: isolate; border: 1px solid var(--line); border-radius: 12px; }
.zoo-map img { display: block; width: 100%; height: auto; }
.zoo-map::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 55px #102a205c; }
.map-markers { position: absolute; inset: 0; z-index: 1; }
.map-marker {
  --marker-top-inset: 30px;
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid rgb(225 192 125 / 76%);
  border-radius: 5px;
  background: rgb(255 240 208 / 76%);
  box-shadow: 0 2px 6px #102a2047;
  color: #0b241a;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.map-marker span:first-child { font-weight: 650; }
.map-marker span[lang] { font: 14px/1.1 var(--serif); }
a.map-marker { text-decoration: none; }
.map-marker:active { transform: translate(-50%, -50%); }
.map-marker[aria-pressed="true"] { background: rgb(246 216 154 / 80%); box-shadow: 0 0 0 1px #fff4dc; }
.map-marker:is(:hover, :focus-visible) {
  z-index: 1;
  border-color: #f6d58e;
  background: rgb(255 244 216 / 92%);
  box-shadow: 0 3px 9px #102a2054;
  animation-play-state: paused;
}
.map-marker:is(:hover, :focus-visible):not(:active) { transform: translate(-50%, calc(-50% - 2px)); }

@media (prefers-reduced-motion: no-preference) {
  .map-marker { animation: map-marker-drift 4.8s ease-in-out infinite; }
  .map-marker:nth-child(2n) { animation-delay: -1.5s; }
  .map-marker:nth-child(3n) { animation-delay: -3.1s; }
  @keyframes map-marker-drift {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -3.5px; }
  }
}

.map-exit {
  --exit-inset: 28px;
  position: absolute;
  z-index: 2;
  left: var(--exit-x);
  top: clamp(var(--exit-inset), var(--exit-y), 100% - var(--exit-inset));
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 8px;
  min-height: 44px;
  padding: 5px 12px 5px 7px;
  transform: translate(-50%, -50%);
  border: 1px solid #89d7c1;
  border-radius: 24px;
  background: #133e3d;
  box-shadow: 0 2px 8px #071d1bc2;
  color: #e9fff7;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
}
.map-exit:hover, .map-exit:focus-visible { background: #205854; }
.map-exit:focus-visible { outline-color: #bbffec; }
.map-exit [lang] { color: #aadace; font: 11px/1.1 var(--serif); }
.map-exit-short { display: none; }
.map-wayfinding {
  position: absolute;
  z-index: 2;
  left: var(--wayfinding-x);
  top: var(--wayfinding-y);
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 10px;
  min-height: 44px;
  padding: 5px 10px;
  border: 1px solid #bacf9e;
  border-radius: 6px;
  background: #26432b;
  color: #f3f8e6;
  box-shadow: 0 2px 7px #11231a88;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.15;
  text-decoration: none;
}
.map-wayfinding [lang] { grid-row: 2; color: #cbdcb4; font: 11px/1.1 var(--serif); }
.map-wayfinding-arrow { grid-area: 1 / 2 / span 2; color: #d8ebad; font-size: 17px; }
.map-wayfinding:hover, .map-wayfinding:focus-visible { background: #355839; }
@media (prefers-reduced-motion: no-preference) {
  .map-wayfinding-arrow { transition: translate .18s ease; }
  .map-wayfinding:is(:hover, :focus-visible) .map-wayfinding-arrow { translate: 2px -2px; }
}
.map-exit-arrow {
  display: grid;
  grid-row: 1 / span 2;
  place-items: center;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: #b7f3e1;
  color: #143c38;
  font: 18px/1 system-ui, sans-serif;
}
@media (prefers-reduced-motion: no-preference) {
  .map-exit { transition: background .18s ease; }
  .map-exit-arrow { animation: map-exit-point 1.6s ease-in-out infinite; }
  @keyframes map-exit-point { 50% { translate: -3px 0; } }
}

.zone-index { display: flex; flex-wrap: wrap; gap: 6px 10px; padding-block: 12px; border-bottom: 1px solid var(--line); }
.zone-index :is(button, a) {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}
.zone-index :is(button, a):hover, .zone-index button[aria-pressed="true"], .zone-index a[aria-current="page"] {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}
.detailed-map .zone-index:empty { display: none; }
.detailed-map .map-marker {
  --marker-top-inset: 28px;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 36px;
  width: max-content;
  max-width: min(19vw, 190px);
  padding: 4px 8px;
  font-size: 13px;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
  text-wrap: balance;
}
.detailed-map .hall-name[lang] { font: 600 11px/1.15 var(--serif); }
.hall-number { display: none; }
.exhibit-section { padding: 19px 0 30px; }
.section-title { display: flex; gap: 14px; align-items: baseline; justify-content: space-between; margin-bottom: 13px; }
.section-title h2 { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 0; font-size: 20px; font-weight: 550; }
.section-title h2 span[lang] { color: var(--muted); font: 20px/1.2 var(--serif); }
.section-title > span { color: var(--muted); white-space: nowrap; font-size: 13px; }
.exhibit-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; padding: 0; margin: 0; list-style: none; }
.exhibit-grid a {
  display: block;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease;
}
.exhibit-grid a:hover { transform: translateY(-2px); border-color: var(--gold); }
.exhibit-grid a:active { transform: translateY(0); }
.exhibit-grid img { display: block; width: 100%; height: auto; background: #eee2cf; }
.exhibit-label { display: grid; gap: 3px; padding: 9px 10px; }
.exhibit-label span[lang] { color: var(--muted); font: 13px/1.2 var(--serif); }
.strip-button { display: none; }
[data-enter] { animation: enter .32s ease-out both; }
@keyframes enter { from { opacity: .76; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (max-width: 1050px) {
  .wrap { width: calc(100% - 36px); }
  .map-marker { padding-inline: 7px; gap: 5px; font-size: 13px; }
  .map-marker span[lang] { font-size: 12px; }
  .exhibit-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 721px) and (min-height: 500px), (min-width: 721px) and (pointer: fine) {
  .zoo-guide {
    display: grid;
    max-width: max(680px, calc(200svh - 290px));
    grid-template-columns: minmax(0, 1fr);
  }
  :is(.zoo-expanded, :fullscreen) body {
    --fullscreen-width: min(calc(100% - clamp(24px, 3vw, 72px)), max(680px, calc(200dvh - 260px)));
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 100dvh;
  }
  :is(.zoo-expanded, :fullscreen) :is(.masthead, .zoo-guide) { width: var(--fullscreen-width); }
  :is(.zoo-expanded, :fullscreen) .zoo-guide {
    align-self: center;
    padding-block: 12px;
  }
  :is(.zoo-expanded, :fullscreen) .zoo-map { margin-top: 0; }
  :is(.zoo-expanded, :fullscreen) .zone-index {
    justify-content: center;
    padding-block: 10px 0;
    border-bottom: 0;
  }
  .zoo-map, .exhibit-section { grid-area: 1 / 1; }
  .zone-index { grid-area: 2 / 1; }
  .exhibit-section {
    align-self: end;
    z-index: 2;
    min-width: 0;
    margin: 0 8px 8px;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(24px);
    transition: transform .24s ease, opacity .2s ease, visibility .24s;
  }
  .exhibit-section.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
  }
  .detailed-map .exhibit-section { display: none; }
  .section-title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .exhibit-strip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgb(16 42 32 / 84%);
  }
  .exhibit-grid {
    --cover-size: clamp(120px, 20svh, 184px);
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: calc(var(--cover-size) + 2px);
    gap: 8px;
    padding: 6px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--gold) transparent;
  }
  .exhibit-grid li { scroll-snap-align: start; }
  .exhibit-grid img { aspect-ratio: 1; object-fit: contain; }
  .exhibit-label { padding: 4px 6px; font-size: 13px; line-height: 1.25; }
  .exhibit-label span[lang] { font-size: 12px; }
  .strip-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ink);
    font: 24px/1 var(--sans);
    cursor: pointer;
  }
  .strip-button:not(:disabled):hover { background: var(--panel); color: var(--gold); }
  .strip-button:disabled { opacity: .35; cursor: default; }
}
@media (max-width: 720px) {
  .masthead { gap: 12px; }
  .masthead h1 { padding-left: 12px; }
  body:not(.detailed-map) .map-marker span[lang] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .detailed-map .map-marker {
    --marker-top-inset: 16px;
    min-height: 25px;
    min-width: 25px;
    padding: 0 4px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 650;
  }
  .hall-name { display: none; }
  .hall-number { display: inline; }
  .map-exit { --exit-inset: 24px; left: var(--exit-compact-x); column-gap: 5px; padding-inline: 5px 8px; font-size: 11px; }
  .map-exit [lang], .map-exit-label { display: none; }
  .map-exit-short { display: inline; }
  .map-exit-arrow { grid-row: 1; width: 22px; height: 22px; font-size: 15px; }
  .map-wayfinding { top: max(24px, calc(var(--wayfinding-y) - 7%)); column-gap: 4px; padding-inline: 5px; font-size: 10px; }
  .map-wayfinding [lang] { display: none; }
  .map-wayfinding-arrow { grid-row: 1; font-size: 14px; }
  .exhibit-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
}
@media (max-width: 480px) {
  .wrap { width: calc(100% - 24px); }
  .masthead { flex-wrap: wrap; gap: 0 9px; padding-block: 6px; }
  .brand { width: 100%; font-size: 11px; }
  .brand img { width: 28px; height: 28px; }
  .masthead h1 { padding-left: 0; border: 0; font-size: 19px; }
  .masthead h1 span { margin-left: 4px; font-size: 19px; }
  .topbar-actions { gap: 4px; font-size: 13px; }
  .back { gap: 3px; }
  .zoo-map { margin-top: 9px; }
  .map-marker { --marker-top-inset: 22px; font-size: 11px; min-height: 29px; padding: 2px 5px; }
  .zone-index { gap: 2px; padding-block: 8px; }
  .zone-index :is(button, a) { padding-inline: 7px; font-size: 13px; }
  .exhibit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  [data-enter] { animation: none; }
  .map-marker, .exhibit-grid a, .exhibit-section { transition: none; }
}
