/* R8R3 measured stage direction. Loaded last; accepted A1-A7 styles remain untouched. */

:root {
  --r8r3-board-ratio: .625;
  --r8r3-board-copy-width: 76%;
  --r8r3-board-copy-y: 50%;
  --r8r3-brass: #c69a53;
  --r8r3-brass-light: #f1cf83;
  --r8r3-wood: #3a1412;
  --r8r3-wood-deep: #160807;
}

body[data-stage="CHAPTER_MENU"] .chapter-set--main {
  --stage-art: url("../image/stage/HovicMap_A7_empty_stage.png") !important;
  background-color: #090403 !important;
  background-image:
    linear-gradient(180deg, rgba(3, 1, 1, .26), rgba(3, 1, 1, .08) 55%, rgba(3, 1, 1, .3)),
    var(--stage-art) !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
}

/* One canonical DOM deck is used for entrance, menu interaction, and exit. */
body[data-stage="CHAPTER_MENU"] #chapterMenu.canonical-board-deck,
body[data-stage="CHAPTER_MENU"] #chapterMenu.canonical-board-deck.is-active {
  position: absolute !important;
  z-index: 96 !important;
  inset: 50% auto auto 50% !important;
  width: min(66vw, 1050px) !important;
  height: auto !important;
  padding: 0 !important;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  align-items: end !important;
  gap: clamp(18px, 2.5vw, 42px) !important;
  overflow: visible !important;
  transform: translate(-50%, -44%) !important;
  pointer-events: none;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu.canonical-board-deck[aria-hidden="true"] {
  visibility: hidden !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu.canonical-board-deck.is-active {
  visibility: visible !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .chapter-sign.story-board {
  --entry-x: 0%;
  --exit-x: 0%;
  position: relative !important;
  left: auto !important;
  top: auto !important;
  width: 100% !important;
  height: auto !important;
  max-height: 57svh !important;
  min-height: 0 !important;
  aspect-ratio: var(--r8r3-board-ratio) !important;
  padding: 0 !important;
  display: block !important;
  container-type: inline-size;
  overflow: visible !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  opacity: 1 !important;
  filter: brightness(.62) saturate(.86) !important;
  transform: translate3d(0, 0, 0) !important;
  transform-origin: 50% 100% !important;
  transition:
    opacity 900ms ease,
    filter 520ms ease,
    transform 1500ms cubic-bezier(.2, .78, .2, 1) !important;
  animation: none !important;
  pointer-events: auto;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .chapter-sign.story-board--left {
  --entry-x: -145%;
  --exit-x: -155%;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .chapter-sign.story-board--center {
  --entry-x: 0%;
  --exit-x: 0%;
  transform: translate3d(0, -4%, 0) scale(1.055) !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .chapter-sign.story-board--right {
  --entry-x: 145%;
  --exit-x: 155%;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__art {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  opacity: 1 !important;
  border: clamp(2px, .55cqw, 5px) solid var(--r8r3-brass) !important;
  border-radius: 44% 44% 2.5% 2.5% / 14% 14% 2.5% 2.5% !important;
  background:
    radial-gradient(ellipse at 50% 8%, rgba(244, 200, 118, .16), transparent 34%),
    linear-gradient(90deg, rgba(255,255,255,.045), transparent 17% 83%, rgba(0,0,0,.32)),
    repeating-linear-gradient(88deg, transparent 0 23px, rgba(255,255,255,.018) 24px 25px),
    linear-gradient(154deg, #612724, var(--r8r3-wood) 42%, var(--r8r3-wood-deep) 100%) !important;
  box-shadow:
    inset 0 0 0 clamp(4px, 1.3cqw, 10px) #1a0908,
    inset 0 0 0 clamp(6px, 1.8cqw, 14px) rgba(207, 153, 78, .7),
    inset 0 -18cqw 24cqw rgba(0, 0, 0, .35),
    .9cqw 1.2cqw 0 #130706,
    1.6cqw 2cqw 0 rgba(92, 55, 28, .86),
    0 7cqw 7cqw rgba(0, 0, 0, .66) !important;
  pointer-events: none;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__art::before {
  content: "";
  position: absolute;
  inset: 6.5%;
  border: max(1px, .32cqw) solid rgba(244, 201, 126, .56);
  border-radius: 42% 42% 1% 1% / 12% 12% 1% 1%;
  box-shadow: inset 0 0 0 max(2px, .75cqw) rgba(17, 6, 5, .7), inset 0 0 8cqw rgba(0, 0, 0, .28);
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__art::after {
  content: "";
  position: absolute;
  left: 11%;
  right: 11%;
  top: calc(100% + 1.5cqw);
  height: 4.8cqw;
  border: max(1px, .4cqw) solid #865c30;
  border-radius: .8cqw;
  background: linear-gradient(180deg, #7a4a28, #2e160e 72%, #120806);
  box-shadow: 0 2.2cqw 2.6cqw rgba(0, 0, 0, .72);
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__art > i {
  position: absolute;
  left: 50%;
  bottom: -7.3cqw;
  width: 48%;
  height: 5.6cqw;
  display: block;
  transform: translateX(-50%);
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__art > i::before,
body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__art > i::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 4.6cqw;
  aspect-ratio: 1;
  border: max(1px, .45cqw) solid #997047;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #8a6038 0 15%, #17100c 18% 54%, #050403 57%);
  box-shadow: 0 1.5cqw 2cqw rgba(0, 0, 0, .7);
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__art > i::before { left: 0; }
body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__art > i::after { right: 0; }

body[data-stage="CHAPTER_MENU"] #chapterMenu .chapter-sign > .story-board__copy {
  position: absolute !important;
  z-index: 3 !important;
  left: 50% !important;
  top: var(--r8r3-board-copy-y) !important;
  width: var(--r8r3-board-copy-width) !important;
  max-height: 64% !important;
  margin: 0 !important;
  padding: 0 !important;
  display: grid !important;
  justify-items: center !important;
  align-content: center !important;
  gap: clamp(4px, 1.7cqw, 12px) !important;
  text-align: center !important;
  transform: translate(-50%, -50%) !important;
  pointer-events: none;
  opacity: 1 !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__copy > * {
  position: static !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  display: block !important;
  opacity: 1 !important;
  text-align: center !important;
  transform: none !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__eyebrow {
  color: #dcbf85 !important;
  font-size: clamp(9px, 3.1cqw, 15px) !important;
  line-height: 1.2 !important;
  letter-spacing: 0 !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__title {
  color: #fff0d4 !important;
  font-size: clamp(12px, 5.2cqw, 28px) !important;
  font-weight: 560 !important;
  line-height: 1.24 !important;
  letter-spacing: 0 !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  text-wrap: balance;
  text-shadow: 0 3px 13px rgba(0, 0, 0, .94) !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__subtitle {
  color: rgba(255, 232, 196, .82) !important;
  font-size: clamp(8px, 2.65cqw, 14px) !important;
  font-style: normal !important;
  line-height: 1.38 !important;
  letter-spacing: 0 !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  text-wrap: balance;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu.is-spot-left .story-board--left,
body[data-stage="CHAPTER_MENU"] #chapterMenu.is-spot-center .story-board--center,
body[data-stage="CHAPTER_MENU"] #chapterMenu.is-spot-right .story-board--right {
  opacity: 1 !important;
  filter: brightness(1.03) saturate(1.02) !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu.is-copy-concealed .story-board__copy {
  opacity: 0 !important;
  transition: opacity 260ms ease !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu.is-copy-revealed .story-board__copy {
  opacity: 1 !important;
  transition: opacity 520ms ease !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu.is-transitioning-in:not(.is-boards-arriving) .story-board--left,
body[data-stage="CHAPTER_MENU"] #chapterMenu.is-transitioning-in:not(.is-boards-arriving) .story-board--right {
  opacity: .02 !important;
  transform: translate3d(var(--entry-x), 8%, 0) !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu.is-transitioning-in:not(.is-boards-arriving) .story-board--center {
  opacity: .02 !important;
  transform: translate3d(0, 84%, 0) scale(1.055) !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu.is-transitioning-out .story-board--left,
body[data-stage="CHAPTER_MENU"] #chapterMenu.is-transitioning-out .story-board--right {
  opacity: 0 !important;
  transform: translate3d(var(--exit-x), 4%, 0) !important;
  transition-duration: 1900ms !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu.is-transitioning-out .story-board--center {
  opacity: 0 !important;
  transform: translate3d(0, -125%, 0) scale(1.055) !important;
  transition-duration: 2100ms !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu.is-choice-locked .story-board:not(.is-selected) {
  filter: brightness(.22) saturate(.55) !important;
  opacity: .48 !important;
}

body[data-stage="CHAPTER_MENU"] #chapterMenu.is-choice-locked .story-board.is-selected {
  filter: brightness(1.12) saturate(1.04) !important;
  transform: translateY(-1.5%) !important;
}

body[data-flow="ANSWER_STAGE_BUILD"] #chapterMenu,
body[data-flow="ANSWER_ENCORE"] #chapterMenu,
body[data-flow="AFTERSTORY_CHASE"] #chapterMenu,
body[data-flow="AFTERSTORY_STAGE_BUILD"] #chapterMenu,
body[data-flow="AFTERSTORY_HUB"] #chapterMenu,
body[data-flow="AFTERSTORY_TRACK"] #chapterMenu {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.r8-film-transition,
.r8-transition-b,
.r8-transition-c,
.answer-stage-build-transition,
.afterstory-stage-build-transition {
  background: #050202 !important;
}

.answer-stage-build-transition,
.afterstory-stage-build-transition {
  position: absolute !important;
  z-index: 98 !important;
  inset: 0 !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.answer-stage-build-transition.is-active,
.afterstory-stage-build-transition.is-active {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto;
}

.answer-stage-build-transition.is-finishing,
.afterstory-stage-build-transition.is-finishing {
  opacity: 0 !important;
}

.scene-change-label { display: none; }

/* The Answer plaque is also a real DOM prop; no title pixels are baked in video. */
.r8-transition-b .answer-reveal-plaque,
.r8-transition-b.is-active .answer-reveal-plaque {
  width: min(31vw, 460px) !important;
  height: auto !important;
  aspect-ratio: .72 !important;
  border: clamp(2px, .25vw, 4px) solid var(--r8r3-brass) !important;
  border-radius: 44% 44% 2.5% 2.5% / 15% 15% 2.5% 2.5% !important;
  background:
    radial-gradient(ellipse at 50% 10%, rgba(244, 200, 118, .15), transparent 35%),
    linear-gradient(155deg, #662925, #32110f 48%, #160807) !important;
  box-shadow:
    inset 0 0 0 8px #1a0908,
    inset 0 0 0 11px rgba(207, 153, 78, .7),
    10px 14px 0 rgba(47, 25, 13, .85),
    0 34px 42px rgba(0, 0, 0, .74) !important;
  container-type: inline-size;
}

.r8-transition-b .answer-plaque-copy,
.r8-transition-b.is-active .answer-plaque-copy {
  inset: 18% 11% 14% !important;
  gap: clamp(4px, 1.4cqw, 11px) !important;
}

.r8-transition-b .answer-plaque-copy small { font-size: clamp(9px, 3.2cqw, 14px) !important; }
.r8-transition-b .answer-plaque-copy strong { font-size: clamp(18px, 6.2cqw, 31px) !important; line-height: 1.2 !important; }
.r8-transition-b .answer-plaque-copy em { font-size: clamp(9px, 2.8cqw, 14px) !important; line-height: 1.4 !important; }
.r8-transition-b .answer-plaque-copy b { font-size: clamp(9px, 2.7cqw, 13px) !important; }

.r8-transition-b.is-entering-answer .answer-reveal-plaque {
  opacity: 0 !important;
  transform: translate(-50%, -50%) translateX(46vw) scale(.96) !important;
  transition: opacity 380ms ease, transform 1600ms cubic-bezier(.2, .76, .2, 1) !important;
}

.r8-transition-b.is-entering-answer {
  z-index: 102 !important;
  background: transparent !important;
  pointer-events: none !important;
}

.r8-transition-b.is-entering-answer > .r8-transition-film,
.r8-transition-b.is-entering-answer > .r8-film-grade {
  opacity: 0 !important;
}

/* Canonical afterstory flats are the same nodes during build and Hub. */
.afterstory-programs {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.afterstory-program.afterstory-board {
  container-type: inline-size;
  aspect-ratio: .68 !important;
  height: auto !important;
  max-height: 45svh !important;
}

.afterstory-program.afterstory-board > .board-copy {
  width: 76% !important;
  top: 49% !important;
  gap: clamp(5px, 2.3cqw, 18px) !important;
}

.afterstory-program.afterstory-board .afterstory-program-number {
  font-size: clamp(8px, 3.1cqw, 13px) !important;
  letter-spacing: 0 !important;
}

.afterstory-program.afterstory-board .board-copy strong {
  font-size: clamp(12px, 6.1cqw, 27px) !important;
  line-height: 1.3 !important;
}

.afterstory-program.afterstory-board .board-copy em,
.afterstory-program.afterstory-board .afterstory-program-status {
  font-size: clamp(8px, 3cqw, 13px) !important;
}

body[data-flow="AFTERSTORY_STAGE_BUILD"] .afterstory-experience {
  z-index: 101 !important;
  background: transparent !important;
  pointer-events: none !important;
}

body[data-flow="AFTERSTORY_STAGE_BUILD"] .afterstory-hub {
  background: transparent !important;
}

body[data-flow="AFTERSTORY_STAGE_BUILD"] .afterstory-backstage,
body[data-flow="AFTERSTORY_STAGE_BUILD"] .afterstory-hub-heading,
body[data-flow="AFTERSTORY_STAGE_BUILD"] .afterstory-hub-navigation {
  opacity: 0 !important;
  visibility: hidden !important;
}

body[data-flow="AFTERSTORY_STAGE_BUILD"] .afterstory-programs {
  top: 50% !important;
  transform: translate(-50%, -43%) !important;
}

body[data-flow="AFTERSTORY_STAGE_BUILD"] .afterstory-program .board-copy {
  opacity: 0 !important;
}

body[data-flow="AFTERSTORY_STAGE_BUILD"] .afterstory-hub:not(.is-boards-arriving) .afterstory-program:nth-child(1) {
  opacity: 0 !important;
  transform: translateX(-150%) translateY(6%) !important;
}

body[data-flow="AFTERSTORY_STAGE_BUILD"] .afterstory-hub:not(.is-boards-arriving) .afterstory-program:nth-child(2) {
  opacity: 0 !important;
  transform: translateY(105%) !important;
}

body[data-flow="AFTERSTORY_STAGE_BUILD"] .afterstory-hub:not(.is-boards-arriving) .afterstory-program:nth-child(3) {
  opacity: 0 !important;
  transform: translateX(150%) translateY(6%) !important;
}

body[data-flow="AFTERSTORY_STAGE_BUILD"] .afterstory-program {
  transition: opacity 850ms ease, transform 1500ms cubic-bezier(.2, .78, .2, 1) !important;
}

.afterstory-hub.is-copy-revealed .afterstory-program .board-copy {
  opacity: 1 !important;
  transition: opacity 520ms ease !important;
}

/* Every narrative film is one-shot. Web-stage tails remain visible after a clip. */
.main-song-film video,
.answer-film-layer video,
.afterstory-film-layer video {
  animation: none !important;
}

.main-song-film.is-web-state,
.answer-film-layer.is-web-state,
.afterstory-film-layer.is-web-state {
  opacity: 1 !important;
}

.main-song-film.is-holding video,
.answer-film-layer.is-holding video,
.afterstory-film-layer.is-holding video {
  filter: brightness(.76) saturate(.9) contrast(1.06) !important;
}

@media (max-width: 760px) {
  body[data-stage="CHAPTER_MENU"] #chapterMenu.canonical-board-deck,
  body[data-stage="CHAPTER_MENU"] #chapterMenu.canonical-board-deck.is-active {
    inset: 50% auto auto 50% !important;
    width: 94vw !important;
    height: auto !important;
    gap: clamp(7px, 2vw, 12px) !important;
    transform: translate(-50%, -44%) !important;
  }

  body[data-stage="CHAPTER_MENU"] #chapterMenu .chapter-sign.story-board {
    top: auto !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    padding: 0 !important;
  }

  body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__copy {
    width: 80% !important;
    gap: clamp(2px, 1.35cqw, 5px) !important;
  }

  body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__eyebrow {
    font-size: clamp(7px, 4.4cqw, 10px) !important;
  }

  body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__title {
    font-size: clamp(9px, 7.2cqw, 14px) !important;
    line-height: 1.22 !important;
  }

  body[data-stage="CHAPTER_MENU"] #chapterMenu .story-board__subtitle {
    font-size: clamp(6px, 4cqw, 9px) !important;
    line-height: 1.25 !important;
  }

  .r8-transition-film { object-fit: contain !important; background: #050202; }

  .r8-transition-b .answer-reveal-plaque,
  .r8-transition-b.is-active .answer-reveal-plaque {
    width: min(53vw, 260px) !important;
    height: auto !important;
    aspect-ratio: .72 !important;
  }

  .afterstory-programs {
    width: 94vw !important;
    gap: 8px !important;
  }

  .afterstory-program.afterstory-board {
    height: auto !important;
    max-height: 35svh !important;
  }

  .afterstory-program.afterstory-board > .board-copy {
    width: 80% !important;
    gap: 5px !important;
  }

  .afterstory-program.afterstory-board .afterstory-program-number,
  .afterstory-program.afterstory-board .board-copy em,
  .afterstory-program.afterstory-board .afterstory-program-status {
    font-size: clamp(6px, 4cqw, 9px) !important;
  }

  .afterstory-program.afterstory-board .board-copy strong {
    font-size: clamp(9px, 7cqw, 16px) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-board,
  .afterstory-board {
    transition-duration: 1ms !important;
  }
}
