/* The Cellar's surfaces outside the finale engine (cellar-progress.js + the
 * gateway secret-finale.js renders). Two scopes:
 *   - body.hall-body .hall-cellar … : the Grand-Room tile + the bookshelf reveal.
 *   - body.cellar-body .cellar-gateway … : the locked-door gateway page.
 * Shell-only; spends the --hall-x/--hall-y tilt vars hall-scene.js publishes.
 * Filenames stay "cellar-" (never "the-cellar") so the secrecy test holds. */

:root {
  --cellar-accent: #e8a33c;
}

/* ===================================================================== *
 * The Grand-Room tile (cellar-progress.js)                              *
 * ===================================================================== */
body.hall-body .hall-cellar {
  display: block;
  width: min(100%, 22rem);
  margin: 1.4rem auto 0;
  padding: 0;
  border: 0;
  background: none;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
body.hall-body button.hall-cellar {
  font: inherit;
  text-align: center;
}

/* The reveal stage: the door, with the bookshelf sliding off it once. */
body.hall-body .cellar-reveal {
  position: relative;
  display: block;
  width: 8.5rem;
  margin: 0 auto;
  overflow: hidden;
}
body.hall-body .cellar-door-art,
body.hall-body .cellar-door-svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Door materials. */
body.hall-body .cellar-door-surround {
  fill: #0c0a12;
  stroke: rgba(232, 163, 60, 0.32);
  stroke-width: 2;
}
body.hall-body .cellar-door-leaf {
  fill: #1a1410;
  stroke: #3a2c1d;
  stroke-width: 1.2;
}
body.hall-body .cellar-door-seam,
body.hall-body .cellar-door-band {
  fill: none;
  stroke: #3a2c1d;
  stroke-width: 1.4;
  stroke-linecap: round;
}
body.hall-body .cellar-door-rim {
  stroke: rgba(232, 163, 60, 0.4);
  stroke-width: 1.4;
}
body.hall-body .cellar-door-keyhole {
  fill: var(--cellar-accent);
  opacity: 0.5;
}
body.hall-body .cellar-door-leaves {
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 0.6s ease;
}

/* Stage 1: the door is dim and unknowable behind its bookshelf. */
body.hall-body .hall-cellar--stage1 .cellar-door-keyhole {
  opacity: 0.28;
}
body.hall-body .hall-cellar--stage1 .cellar-reveal {
  opacity: 0.92;
}

/* Stage 3: the keyhole burns and the leaves stand a hair ajar. */
body.hall-body .hall-cellar--stage3 .cellar-door-keyhole {
  opacity: 0.9;
}
body.hall-body .hall-cellar--stage3 .cellar-door-leaf--l {
  transform: translateX(-3px);
}
body.hall-body .hall-cellar--stage3 .cellar-door-leaf--r {
  transform: translateX(3px);
}

/* The bookshelf rests slid-aside (door shown); it only covers during reveal. */
body.hall-body .cellar-bookshelf {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform: translateX(-120%);
}
body.hall-body .cellar-shelf-svg {
  width: 86%;
  height: auto;
}
body.hall-body .cellar-shelf-board {
  fill: #17110d;
  stroke: #2c2017;
  stroke-width: 2;
}
body.hall-body .cellar-shelf-lines {
  fill: none;
  stroke: #2c2017;
  stroke-width: 1.4;
}
body.hall-body .cellar-shelf-book {
  fill: #2a1d2a;
}
body.hall-body .cellar-shelf-book:nth-of-type(3n) {
  fill: #3a2330;
}
body.hall-body .cellar-shelf-book:nth-of-type(3n + 1) {
  fill: #243042;
}

/* The reveal beats (cellar-progress.js toggles .is-revealing). */
body.hall-body .cellar-reveal[data-stage="1"].is-revealing .cellar-bookshelf {
  animation: cellar-shelf-slide 2400ms cubic-bezier(0.5, 0, 0.2, 1);
}
body.hall-body .cellar-reveal[data-stage="1"].is-revealing .cellar-door-art {
  animation: cellar-door-dawn 2400ms ease;
}
body.hall-body .cellar-reveal[data-stage="2"].is-revealing .cellar-door-keyhole {
  animation: cellar-keyhole-wake 2000ms ease;
}
body.hall-body .cellar-reveal[data-stage="3"].is-revealing .cellar-door-art {
  animation: cellar-door-open-glow 2000ms ease;
}

@keyframes cellar-shelf-slide {
  0%, 18% { transform: translateX(0); }
  100% { transform: translateX(-120%); }
}
@keyframes cellar-door-dawn {
  0%, 24% { opacity: 0.2; }
  100% { opacity: 1; }
}
@keyframes cellar-keyhole-wake {
  0% { opacity: 0.28; }
  55% { opacity: 1; }
  100% { opacity: 0.9; }
}
@keyframes cellar-door-open-glow {
  0% { filter: none; }
  50% { filter: drop-shadow(0 0 14px rgba(232, 163, 60, 0.5)); }
  100% { filter: drop-shadow(0 0 6px rgba(232, 163, 60, 0.25)); }
}

/* The locked rattle when a stage-1 player tries the impassable door. */
body.hall-body .hall-cellar--stage1.is-locked .cellar-reveal {
  animation: cellar-locked-rattle 0.4s ease;
}
@keyframes cellar-locked-rattle {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}

/* The little plate under the tile. */
body.hall-body .cellar-tile-plate {
  display: block;
  margin: 0.5rem auto 0;
  text-align: center;
}
body.hall-body .cellar-tile-name {
  display: block;
  font-size: 0.96rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #f3ecd9;
}
body.hall-body .cellar-tile-line {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
  font-style: italic;
  color: rgba(232, 163, 60, 0.72);
}
body.hall-body .hall-cellar:hover .cellar-tile-name,
body.hall-body .hall-cellar:focus-visible .cellar-tile-name {
  color: #fff4dd;
}
body.hall-body .hall-cellar:focus-visible {
  outline: 2px solid rgba(232, 163, 60, 0.6);
  outline-offset: 4px;
  border-radius: 8px;
}

/* Fully unlocked: promote the earned destination above the hunt doors as one
 * compact card. The shared door stays recognisable, but is half the old tile's
 * width so the message — not a second full-size door — leads the composition. */
body.hall-body .hall-cellar--featured {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.5rem;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin: 0;
  padding: 1rem 1.1rem 1rem 1.2rem;
  overflow: hidden;
  border: 1px solid rgba(232, 163, 60, 0.52);
  border-radius: 18px;
  background:
    radial-gradient(90% 150% at 100% 50%, rgba(232, 163, 60, 0.17), transparent 62%),
    linear-gradient(135deg, rgba(34, 24, 16, 0.92), rgba(17, 12, 20, 0.94));
  box-shadow:
    inset 0 0 28px rgba(232, 163, 60, 0.06),
    0 12px 30px rgba(0, 0, 0, 0.32);
  text-align: left;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
body.hall-body .hall-cellar--featured:hover,
body.hall-body .hall-cellar--featured:focus-visible {
  border-color: rgba(232, 163, 60, 0.88);
  border-radius: 18px;
  transform: translateY(-2px);
  box-shadow:
    inset 0 0 32px rgba(232, 163, 60, 0.1),
    0 16px 36px rgba(0, 0, 0, 0.42),
    0 0 26px rgba(232, 163, 60, 0.1);
}
body.hall-body .cellar-feature-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
}
body.hall-body .cellar-feature-state {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cellar-accent);
}
body.hall-body .cellar-feature-name {
  margin-top: 0.22rem;
  font-size: 1.28rem;
  font-weight: 600;
  letter-spacing: 0.055em;
  color: #fff4dd;
}
body.hall-body .cellar-feature-line {
  margin-top: 0.26rem;
  color: #bdb19b;
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.4;
}
body.hall-body .cellar-feature-cue {
  margin-top: 0.62rem;
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cellar-accent);
}
body.hall-body .hall-cellar--featured .cellar-reveal {
  justify-self: end;
  width: 4.5rem;
  margin: -0.5rem 0;
  overflow: visible;
}
body.hall-body .hall-cellar--featured .cellar-door-art {
  filter: drop-shadow(0 0 8px rgba(232, 163, 60, 0.3));
  transform-origin: 50% 80%;
}

/* Long stillness, then a short pressure-rattle: something on the other side
 * has put its hand against the door. This is page life, not solve evidence. */
@media (prefers-reduced-motion: no-preference) {
  body.hall-body .hall-cellar--featured .cellar-door-art {
    animation: cellar-door-something-behind 5.8s ease-in-out 1.2s infinite;
  }
}
@keyframes cellar-door-something-behind {
  0%, 42%, 58%, 100% { transform: translateX(0) rotate(0); }
  45% { transform: translateX(-1.5px) rotate(-0.65deg); }
  48% { transform: translateX(2px) rotate(0.85deg); }
  51% { transform: translateX(-1.5px) rotate(-0.55deg); }
  54% { transform: translateX(1px) rotate(0.35deg); }
}

/* ===================================================================== *
 * The gateway page (secret-finale.js renderGateway, on body.cellar-body) *
 * ===================================================================== */
body.cellar-body .cellar-gateway {
  text-align: center;
}
body.cellar-body .cellar-door-frame {
  position: relative;
  width: min(15rem, 62vw);
  margin: 0.6rem auto 0;
}
body.cellar-body .cellar-door-svg {
  display: block;
  width: 100%;
  height: auto;
  /* a hair of parallax against the device lean */
  transform: translateX(calc(var(--hall-x, 0) * 4px));
}
body.cellar-body .cellar-door-surround {
  fill: #0c0a12;
  stroke: rgba(232, 163, 60, 0.4);
  stroke-width: 2;
}
body.cellar-body .cellar-door-leaf {
  fill: #1a1410;
  stroke: #3a2c1d;
  stroke-width: 1.2;
}
body.cellar-body .cellar-door-seam,
body.cellar-body .cellar-door-band {
  fill: none;
  stroke: #3a2c1d;
  stroke-width: 1.4;
}
body.cellar-body .cellar-door-rim {
  stroke: rgba(232, 163, 60, 0.45);
  stroke-width: 1.4;
}
body.cellar-body .cellar-door-keyhole {
  fill: var(--cellar-accent);
  opacity: 0.85;
}

/* The painted figure peering up out of the keyhole. */
body.cellar-body .cellar-door-ghost {
  position: absolute;
  left: 50%;
  top: 56%;
  transform: translate(-50%, -50%);
  --ghost-size: 3.4em;
  --ghost-accent: var(--cellar-accent);
  opacity: 0.92;
  pointer-events: none;
}

/* The lock: a brass plate of three slots, seated at the door's foot. */
body.cellar-body .cellar-lock {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  width: min(15rem, 62vw);
  margin: -0.6rem auto 0;
  padding: 0.8rem 0.7rem;
  border: 1px solid rgba(232, 163, 60, 0.3);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(40, 30, 16, 0.6), rgba(12, 9, 6, 0.7));
}
body.cellar-body .cellar-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  flex: 1 1 0;
  min-width: 0;
}
body.cellar-body .cellar-slot-key {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  border: 1px solid rgba(232, 163, 60, 0.3);
}
body.cellar-body .cellar-slot-key svg {
  width: 1.1rem;
  height: 1.1rem;
}
body.cellar-body .cellar-slot-word {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: #6f6450;
}
/* A set slot: the key has turned, the word is lit. */
body.cellar-body .cellar-slot.is-set .cellar-slot-key {
  border-color: var(--cellar-accent);
  background: radial-gradient(circle, rgba(232, 163, 60, 0.32), transparent 70%);
  color: var(--cellar-accent);
}
body.cellar-body .cellar-slot.is-set .cellar-slot-key svg {
  transform: rotate(-90deg);
}
body.cellar-body .cellar-slot.is-set .cellar-slot-word {
  color: #f3ecd9;
}
body.cellar-body .cellar-slot.is-empty .cellar-slot-key {
  color: #4a4236;
}

body.cellar-body .cellar-gateway-note {
  margin: 1.3rem auto 0.4rem;
  max-width: 24rem;
  font-style: italic;
  color: #cdc4b1;
}

@media (prefers-reduced-motion: reduce) {
  body.hall-body .cellar-reveal[data-stage] .cellar-bookshelf,
  body.hall-body .cellar-reveal.is-revealing *,
  body.hall-body .hall-cellar--featured .cellar-door-art {
    animation: none !important;
  }
  body.hall-body .hall-cellar--featured,
  body.hall-body .hall-cellar--featured:hover,
  body.hall-body .hall-cellar--featured:focus-visible {
    transform: none;
    transition: none;
  }
  /* Skip the slide: rest with the door already shown. */
  body.hall-body .cellar-bookshelf {
    transform: translateX(-120%);
  }
  body.hall-body .cellar-door-leaves,
  body.cellar-body .cellar-slot-key svg,
  body.cellar-body .cellar-door-svg {
    transition: none;
    transform: none;
  }
  body.cellar-body .cellar-slot.is-set .cellar-slot-key svg {
    transform: rotate(-90deg);
  }
}
