/* ==========================================================================
   MWR 世界宗教博物館 — Design tokens & base
   ========================================================================== */

:root {
  --color-bg: #161618;
  --color-surface: #1d1d1f;
  --color-surface-2: #242426;
  --color-border: rgba(255, 255, 255, 0.1);
  --color-border-strong: rgba(255, 255, 255, 0.24);

  /* Text: every tier at or above WCAG AA 4.5:1 against --color-bg, except
     -disabled which is reserved for genuinely inactive demo elements (WCAG
     exempts disabled controls from contrast requirements). Verified via
     the sRGB relative-luminance formula, not eyeballed:
       text 100%      -> 15.75:1
       secondary 72%   -> 8.56:1
       muted 58%       -> 5.96:1
       disabled 42%    -> 3.72:1 (large-text tier only, never body copy) */
  --color-text: #f3efe6;
  --color-text-secondary: rgba(243, 239, 230, 0.72);
  --color-text-muted: rgba(243, 239, 230, 0.58);
  --color-text-disabled: rgba(243, 239, 230, 0.42);
  --color-accent: #ffffff;

  /* Cultural accent palette — used sparingly, one dominant accent per page.
     Never combine all three at once. */
  --color-gold: #c5a86a;
  --color-terracotta: #a86248;
  --color-mineral-blue: #657b86;
  --color-warm-white: #f3efe6;

  --font-serif: "Noto Serif TC", "Source Han Serif TC", serif;
  --font-sans: "Noto Sans TC", "Source Han Sans TC", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Space Mono", ui-monospace, monospace;

  --container: 1440px;
  --gutter: clamp(24px, 5vw, 96px);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--color-bg);
  scroll-behavior: smooth;
  font-size: 100%; /* 16px base */
  /* Reserves the scrollbar's width permanently so that locking scroll while
     the nav overlay is open (body.nav-open { overflow: hidden }) doesn't
     remove the scrollbar and shift all fixed-position content (header,
     hero, etc.) rightward by its width when the overlay opens. */
  scrollbar-gutter: stable;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

p {
  font-size: 1rem;
  line-height: 1.7;
}

img {
  display: block;
  max-width: 100%;
}

/* ---- immersive photo treatment: desaturate + darken so photography reads as
   part of the dark environment rather than a bright rectangle sitting on top ---- */

.photo {
  position: relative;
  overflow: hidden;
  background: var(--color-bg);
}

.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.62) contrast(1.22) brightness(0.78);
  transition: filter 2.4s var(--ease-out), transform 0.85s var(--ease-out);
  will-change: filter, transform;
}

.photo.is-revealed img {
  filter: grayscale(0.12) contrast(1.02) brightness(0.96);
}

.photo:hover img {
  transform: scale(1.02);
}

@media (prefers-reduced-motion: reduce) {
  .photo img {
    transition: none;
    filter: grayscale(0.12) contrast(1.02) brightness(0.96);
  }
}

.photo::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to top, rgba(22, 22, 24, 0.55) 0%, rgba(22, 22, 24, 0) 45%);
}

.photo-tag {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(240, 237, 230, 0.75);
  background: rgba(22, 22, 24, 0.72);
  padding: 4px 9px;
}

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

ul {
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: -48px;
  left: 16px;
  background: var(--color-accent);
  color: var(--color-bg);
  padding: 12px 20px;
  z-index: 1000;
  transition: top 0.2s var(--ease);
}
.skip-link:focus {
  top: 16px;
}

:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- eyebrow / label / mono utilities ---- */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

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

.stat-number {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  letter-spacing: -0.02em;
  color: var(--color-gold);
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 8px;
  letter-spacing: 0.02em;
}

/* ---- display headline (huge titles like 展覽 / 館藏) ---- */

.display-title {
  font-family: var(--font-serif);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -0.01em;
  font-size: clamp(4.5rem, 13vw, 9rem);
}

/* ---- page intro (shared by exhibitions / collection / about / visit) ---- */

.page-intro {
  padding: 170px 0 40px;
}

.page-intro .eyebrow {
  display: block;
  margin-bottom: 24px;
}

.page-intro .display-title {
  margin-bottom: 8px;
}

/* ==========================================================================
   Top navigation
   ========================================================================== */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px var(--gutter);
  background: transparent;
  border-bottom: 1px solid transparent;
  backdrop-filter: none;
  transition: background-color 0.4s var(--ease), border-color 0.4s var(--ease), backdrop-filter 0.4s var(--ease);
}

.site-header.is-scrolled {
  background: rgba(22, 22, 24, 0.94);
  border-bottom-color: var(--color-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-mark {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  color: var(--color-text);
}

.brand-sub {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  letter-spacing: 0.02em;
}

.crumb {
  margin-left: 18px;
  padding-left: 18px;
  border-left: 1px solid var(--color-border);
  font-size: 0.78rem;
  color: var(--color-text-secondary);
}

/* At the very narrowest supported width, the crumb competes with the full
   museum name for header space and forces an ugly multi-line wrap; the page
   heading right below the header already conveys the same section name, so
   it's safe to drop here. */
@media (max-width: 400px) {
  .crumb {
    display: none;
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 22px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--color-text-secondary);
  transition: color 0.2s var(--ease);
}
.lang-toggle:hover,
.lang-toggle:focus-visible {
  color: var(--color-text);
}

/* The hamburger + "選單" trigger is now the single, universal entry point
   to navigation at every viewport width — there's no separate desktop nav
   to swap in above 900px, so this has no display:none media override. */
.menu-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 2px;
  color: var(--color-text);
}

/* Shared bars->X icon, used by both the header's menu-toggle and the
   overlay's own close button (see .nav-overlay-close below) so the icon
   reads as the same control staying on screen rather than one icon
   vanishing and an unrelated one taking its place. */
.bars {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  width: 20px;
}
.bars span {
  height: 1px;
  background: currentColor;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}

.menu-toggle[aria-expanded="true"] .bars span:first-child,
.bars.is-x span:first-child {
  transform: translateY(5px) rotate(45deg);
}
.menu-toggle[aria-expanded="true"] .bars span:last-child,
.bars.is-x span:last-child {
  transform: translateY(-5px) rotate(-45deg);
}

/* ==========================================================================
   Full-screen nav overlay
   ========================================================================== */

.nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: var(--color-bg);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.45s var(--ease), visibility 0.45s var(--ease);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px var(--gutter) 40px;
}

.nav-overlay.is-open {
  visibility: visible;
  opacity: 1;
}

/* Positioned to land in the exact same spot as .menu-toggle in the header
   (same 28px/var(--gutter) offsets, same min-height/gap), so the bars->X
   icon reads as the one icon staying on screen instead of disappearing
   underneath the overlay's opaque background. */
.nav-overlay-close {
  position: absolute;
  top: 28px;
  right: var(--gutter);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-text-secondary);
}
.nav-overlay-close:hover,
.nav-overlay-close:focus-visible {
  color: var(--color-text);
}

.nav-overlay-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: center;
  flex: 1;
  padding-top: 80px;
}

.nav-overlay-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

@keyframes navItemIn {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes navFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes navImageIn {
  from { opacity: 0; transform: translateX(18px) scale(1.04); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.nav-overlay-main a {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 1.18;
  color: var(--color-text-muted);
  transition: color 0.25s var(--ease);
  width: fit-content;
  opacity: 0;
}

.nav-overlay.is-open .nav-overlay-main a {
  animation: navItemIn 700ms var(--ease-out) both;
}
.nav-overlay.is-open .nav-overlay-main a:nth-child(1) { animation-delay: 80ms; }
.nav-overlay.is-open .nav-overlay-main a:nth-child(2) { animation-delay: 150ms; }
.nav-overlay.is-open .nav-overlay-main a:nth-child(3) { animation-delay: 220ms; }
.nav-overlay.is-open .nav-overlay-main a:nth-child(4) { animation-delay: 290ms; }

.nav-overlay-main a:hover,
.nav-overlay-main a:focus-visible,
.nav-overlay-main a.is-active {
  color: var(--color-text);
}

.nav-overlay-side {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: start;
}

.nav-overlay-sub {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.nav-overlay-sub.is-swapping {
  animation: navFadeIn 260ms ease-out both;
}

.nav-overlay-sub .sub-heading {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.nav-overlay-sub a {
  font-size: 1.05rem;
  color: var(--color-text-secondary);
  transition: color 0.2s var(--ease);
}
.nav-overlay-sub a:hover,
.nav-overlay-sub a:focus-visible {
  color: var(--color-text);
}

.nav-overlay-figure {
  width: 220px;
  opacity: 0;
}
.nav-overlay.is-open .nav-overlay-figure {
  animation: navImageIn 900ms var(--ease-out) 80ms both;
}
.nav-overlay-photo {
  aspect-ratio: 3/4;
}
.nav-overlay-figure figcaption {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 8px;
}

.nav-overlay-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--color-border);
  padding-top: 20px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  opacity: 0;
}
.nav-overlay.is-open .nav-overlay-foot {
  animation: navFadeIn 500ms ease-out 400ms both;
}

.nav-overlay-foot .social {
  display: flex;
  gap: 24px;
}
.nav-overlay-foot .social a:hover {
  color: var(--color-text);
}

body.nav-open {
  overflow: hidden;
}

@media (max-width: 900px) {
  .nav-overlay-body {
    grid-template-columns: 1fr;
    padding-top: 100px;
    gap: 32px;
  }
  .nav-overlay-side {
    grid-template-columns: 1fr;
  }
  .nav-overlay-figure {
    display: none;
  }
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  padding: 15px 26px;
  min-height: 44px;
  border: 1px solid var(--color-border-strong);
  transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.btn-compact {
  padding: 10px 20px;
  min-height: 44px;
  font-size: 0.76rem;
}

.btn-primary {
  background: var(--color-text);
  color: var(--color-bg);
  border-color: var(--color-text);
}
.btn-primary:hover,
.btn-primary:focus-visible {
  background: transparent;
  color: var(--color-text);
}

.btn-ghost {
  color: var(--color-text-secondary);
}
.btn-ghost:hover,
.btn-ghost:focus-visible {
  color: var(--color-text);
  border-color: var(--color-text);
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border-bottom: 1px solid var(--color-border-strong);
  padding-bottom: 4px;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.text-link:hover,
.text-link:focus-visible {
  border-color: var(--color-text);
}

/* ---- disabled affordance: used wherever a link has no real destination
   yet, instead of a href="#" that goes nowhere. Uses the muted (not
   disabled) text tier deliberately — these are normal-size labels, and
   --color-text-disabled only clears WCAG AA at large-text sizes. ---- */

.is-disabled {
  color: var(--color-text-muted) !important;
  border-color: transparent !important;
  cursor: default;
  pointer-events: none;
}

/* ==========================================================================
   Sections / footer (shared across pages)
   ========================================================================== */

main {
  padding-top: 0;
}

.section {
  padding: 120px 0;
  border-top: 1px solid var(--color-border);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 56px;
}

.section-title {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: clamp(1.9rem, 3.4vw, 2.8rem);
  line-height: 1.2;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 40px;
  max-width: var(--container);
  margin: 0 auto;
  padding: 72px var(--gutter);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.site-footer {
  padding: 72px var(--gutter) 32px;
  border-top: 1px solid var(--color-border);
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 48px;
  max-width: var(--container);
  margin: 0 auto 56px;
}

.footer-brand .brand-mark {
  font-size: 1.2rem;
}
.footer-brand address {
  font-style: normal;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-top: 14px;
  line-height: 1.7;
}

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

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 0.85rem;
}
.footer-col a,
.footer-col .is-disabled {
  display: inline-block;
  padding: 3px 0;
  color: var(--color-text-secondary);
  transition: color 0.2s var(--ease);
}

/* Below ~900px the footer is the primary touch-navigation surface for the
   page, so links get a full 44px tap target here; above that, mouse
   precision makes the tighter desktop spacing fine and a 44px minimum
   would just add unwanted visual bulk to the footer. */
@media (max-width: 900px) {
  .footer-col a,
  .footer-col .is-disabled {
    display: flex;
    align-items: center;
    min-height: 44px;
  }
}
.footer-col a:hover {
  color: var(--color-text);
}

.footer-bottom {
  max-width: var(--container);
  margin: 0 auto;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.footer-disclaimer {
  max-width: 62ch;
}
.footer-disclaimer p {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}
.footer-disclaimer p:first-child {
  color: var(--color-text-secondary);
  font-weight: 500;
  margin-bottom: 6px;
}

.footer-bottom-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

@media (max-width: 720px) {
  .section {
    padding: 80px 0;
  }
  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .footer-top {
    flex-direction: column;
  }
}
