:root {
  --wall: #e3f2ea;
  --ink: #17241c;
  --deep: #1d4a38;
  --stamp: #d6452f;
  --stamp-ink: #fff8f3;
  --band: 110px;
  --margin: 28px;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", "Times New Roman", serif;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
  background: var(--wall);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior: none;
  background: var(--wall);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 500;
  font-size: 18px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  /* Stop iOS drag from exposing the page edges. */
  position: relative;
}

::selection {
  background: var(--deep);
  color: var(--wall);
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--wall);
  color: var(--ink);
  transition: opacity 0.45s ease;
}

#loading.is-done {
  opacity: 0;
  pointer-events: none;
}

.loading-name,
.loading-label {
  margin: 0;
}

.loading-name {
  font-size: clamp(40px, 6vw, 72px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.loading-track {
  width: min(220px, 56vw);
  height: 2px;
  background: rgba(23, 36, 28, 0.16);
}

#loading-bar {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--deep);
}

.loading-label {
  font-size: 16px;
  letter-spacing: 0.12em;
}

html.is-loading {
  overflow: hidden;
}

#table {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 0;
  pointer-events: auto;
  display: block;
  background: var(--wall);
  /* Vertical = native scroll; JS only claims horizontal swipes. */
  touch-action: pan-y;
}

.sound {
  position: fixed;
  top: 20px;
  right: calc(var(--margin) + 132px);
  z-index: 5;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: var(--deep);
  color: var(--wall);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sound svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.sound .sound-off { display: none; }

.sound[aria-pressed="true"] .sound-on { display: none; }
.sound[aria-pressed="true"] .sound-off { display: block; }

.sound:hover,
.sound:focus-visible {
  background: var(--ink);
}

.stamp {
  position: fixed;
  top: 20px;
  right: var(--margin);
  z-index: 5;
  background: var(--stamp);
  color: var(--stamp-ink);
  text-decoration: none;
  padding: 12px 16px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  font-size: 18px;
  line-height: 1;
}

.stamp:hover,
.stamp:focus-visible {
  background: var(--deep);
  color: var(--wall);
}

.stamp:focus-visible,
.sound:focus-visible,
.mark a:focus-visible,
.chapter-copy a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.mark {
  position: fixed;
  top: 22px;
  left: var(--margin);
  z-index: 5;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.mark a {
  color: var(--ink);
  text-decoration: none;
}

.mark a:hover {
  color: var(--deep);
}

.sign {
  position: fixed;
  z-index: 3;
  margin: 0;
  width: max-content;
  max-width: calc(100% - 8.5rem);
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -62%);
}

.sign h1 {
  margin: 0;
  font-size: clamp(40px, 5.2vw, 78px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.sign .lede {
  margin: 10px auto 0;
  font-size: clamp(18px, 1.5vw, 22px);
  line-height: 1.3;
}

.sign.is-top {
  top: 22px !important;
  left: 50% !important;
  transform: translate(-50%, 0) !important;
  width: min(34rem, calc(100% - 7.5rem));
}

body:not(.is-scene-ready) .sign {
  opacity: 0 !important;
  visibility: hidden;
}

body.is-scene-ready .sign {
  visibility: visible;
}


main {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

html.is-locked {
  overflow: hidden;
}

.chapter-copy > p,
.chapter-copy > a {
  display: none;
}

#banner-detail {
  grid-column: 1;
  grid-row: 2;
  max-width: 40rem;
}

#banner-detail[hidden] {
  display: none;
}

#banner-detail p {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.5;
}

#banner-detail a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-top: 4px;
  text-decoration: underline;
  text-underline-offset: 4px;
  font-size: 14px;
}

body.is-dish .sign,
body.is-dish .mark {
  opacity: 0 !important;
}

/* Detail: horizontal yaw only — block native pan so vertical can't fight the drag. */
body.is-dish #table {
  touch-action: none;
  cursor: grab;
}

body.is-dish .chapter.is-active .chapter-copy {
  background: rgba(0, 0, 0, 0.64);
}

body.is-dish .chapter.is-active .chapter-copy h2,
body.is-dish .chapter.is-active .chapter-copy p,
body.is-dish .chapter.is-active .chapter-copy a {
  color: #f4efe6;
  text-shadow: none;
}


.chapter {
  min-height: 100vh;
}

#morning,
#bolo {
  min-height: 42vh;
}

.chapter-copy {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  min-height: 0;
  height: auto;
  padding: 14px var(--margin) 14px;
  /* No banner fill — text only over the 3D scene */
  background: none;
  display: grid;
  grid-template-columns: minmax(0, 40rem) auto;
  gap: 8px 32px;
  align-items: end;
  opacity: 0;
  pointer-events: none;
}

.chapter.is-active .chapter-copy {
  opacity: 1;
  pointer-events: auto;
  z-index: 3;
}

.chapter-copy h2 {
  margin: 0;
  grid-column: 1;
  font-size: clamp(24px, 3.2vw, 36px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  text-shadow: 0 1px 0 rgba(215, 238, 228, 0.85), 0 0 18px rgba(215, 238, 228, 0.55);
}

.chapter-copy p {
  margin: 8px 0 0;
  grid-column: 1;
  max-width: 42rem;
  font-size: 15px;
  line-height: 1.5;
  text-shadow: 0 1px 0 rgba(215, 238, 228, 0.85), 0 0 14px rgba(215, 238, 228, 0.5);
}

.chapter-copy a {
  grid-column: 2;
  align-self: end;
  justify-self: end;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
  white-space: nowrap;
  padding-bottom: 2px;
}

.chapter-copy a:first-of-type {
  grid-row: 1;
}

.chapter-copy a:last-of-type {
  grid-row: 2;
}

.chapter-close h2 {
  font-size: clamp(28px, 4.5vw, 52px);
}

.noscript-note {
  position: relative;
  z-index: 2;
  padding: 24px var(--margin);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.sign h1,
.sign .lede,
.stamp {
  animation: rise 0.7s ease both;
}

.sign .lede { animation-delay: 80ms; }
.stamp { animation-delay: 160ms; }

.chapter.is-active .chapter-copy h2,
.chapter.is-active .chapter-copy p,
.chapter.is-active .chapter-copy a {
  animation: rise 0.6s ease both;
}

.chapter.is-active .chapter-copy p { animation-delay: 70ms; }
.chapter.is-active .chapter-copy a { animation-delay: 140ms; }

@media (max-width: 720px) {
  :root {
    --margin: 20px;
    --band: 72px;
  }

  .sign.is-top {
    top: 76px !important;
    width: min(34rem, calc(100% - 2.5rem));
  }

  .sign h1 { font-size: clamp(40px, 12vw, 64px); }

  .chapter-copy {
    grid-template-columns: 1fr;
    padding: 10px var(--margin) 12px;
    min-height: 0;
  }

  .chapter-copy h2 {
    font-size: clamp(22px, 6.5vw, 28px);
  }

  #banner-detail p {
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.35;
  }

  #banner-detail a {
    min-height: 28px;
    margin-top: 2px;
    font-size: 13px;
  }

  .chapter-copy > a,
  .chapter-copy > a:first-of-type,
  .chapter-copy > a:last-of-type,
  .chapter-copy > p {
    display: none;
  }

  .chapter { min-height: 85vh; }
}

@media (max-height: 560px) {
  .sign h1 { font-size: 36px; }
  .sign .lede { font-size: 16px; margin-top: 6px; }
  .chapter-copy { padding: 8px var(--margin) 10px; }
  .chapter-copy h2 { font-size: clamp(20px, 5vw, 26px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  #loading { transition: none; }

  .sign h1,
  .sign .lede,
  .stamp,
  .chapter.is-active .chapter-copy h2,
  .chapter.is-active .chapter-copy p,
  .chapter.is-active .chapter-copy a {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
