/* ══════════════════════════════════════════════════════════
   room.css — Common room scene, interactive items, sprite
══════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════
   ROOM SCREEN
══════════════════════════════════════════════════════════ */
.roomScreen {
  position: absolute;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.roomScreen[hidden] { display: none; }

.roomScreen.is-entering {
  animation: roomReveal 800ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes roomReveal {
  from {
    opacity: 0;
    transform: scale(1.12);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Room stage — contain-fit wrapper sized by JS ────────── */
.roomStage {
  position: absolute;
  overflow: hidden;
  background: #000 url('../../assets/noob_background.png') center center / 100% 100% no-repeat;
}

/* Back wall */
.roomWallBack {
  position: absolute;
  inset: 0 0 30% 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(107, 21, 21, 0.18), transparent 60%),
    linear-gradient(180deg, #1a0b07 0%, #2a1308 100%);
}

/* Floor — trapezoid illusion via perspective */
.roomFloor {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 38%;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(90, 52, 24, 0.9) 0px,
      rgba(90, 52, 24, 0.9) 1px,
      transparent 1px,
      transparent 48px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(60, 32, 10, 0.7) 0px,
      rgba(60, 32, 10, 0.7) 1px,
      transparent 1px,
      transparent 48px
    ),
    linear-gradient(180deg, #4a2a10 0%, #2a1408 100%);
  background-size: 48px 48px, 48px 48px, 100% 100%;
  transform: perspective(400px) rotateX(12deg);
  transform-origin: top center;
  box-shadow: inset 0 12px 32px rgba(0,0,0,0.4);
}

/* Side walls */
.roomWallLeft,
.roomWallRight {
  position: absolute;
  top: 0;
  bottom: 30%;
  width: 18%;
  background: linear-gradient(90deg, #1a0a06 0%, #2a1308 100%);
}

.roomWallLeft  { left: 0; background: linear-gradient(90deg, #0d0603, #1e0d07); }
.roomWallRight { right: 0; background: linear-gradient(270deg, #0d0603, #1e0d07); }

/* Fireplace */
.roomFireplace {
  position: absolute;
  bottom: 28%;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 100px;
}

.roomFireplace::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #1e0d07, #0d0503);
  border: 3px solid var(--hp-wood-mid);
  border-bottom: none;
}

.roomFireFlame {
  position: absolute;
  bottom: 4px;
  border-radius: 50% 50% 20% 20%;
  animation: flicker 1.4s ease-in-out infinite alternate;
}

.roomFireFlame1 {
  left: 30px; width: 28px; height: 52px;
  background: radial-gradient(ellipse at 50% 80%, #fff17a, #ff8c00 50%, #c03000 100%);
  animation-duration: 1.3s;
}
.roomFireFlame2 {
  left: 52px; width: 36px; height: 68px;
  background: radial-gradient(ellipse at 50% 80%, #fff7b0, #ffaa00 48%, #c84000 100%);
  animation-duration: 1.6s;
}
.roomFireFlame3 {
  left: 78px; width: 26px; height: 48px;
  background: radial-gradient(ellipse at 50% 80%, #fff17a, #ff8c00 50%, #c03000 100%);
  animation-duration: 1.1s;
}

@keyframes flicker {
  0%   { transform: scaleX(0.96) scaleY(1); opacity: 0.92; }
  50%  { transform: scaleX(1.04) scaleY(1.06); opacity: 1; }
  100% { transform: scaleX(0.98) scaleY(0.94); opacity: 0.88; }
}

/* Candle sconces */
.roomCandle {
  position: absolute;
  top: 24%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  transition: filter 600ms ease;
}

.roomCandleLeft  { left: 14%; }
.roomCandleRight { right: 14%; }

.roomCandleStick {
  width: 8px;
  height: 32px;
  background: linear-gradient(180deg, #e8d090, #b8902a);
  border-radius: 2px;
  box-shadow: inset -2px 0 4px rgba(0,0,0,0.3);
}

.roomCandleFlame {
  position: relative;
  width: 12px;
  height: 20px;
  border-radius: 50% 50% 30% 30%;
  background: radial-gradient(ellipse at 50% 70%, #fff7b0, #ffaa00 55%, transparent 100%);
  margin-top: -4px;
  opacity: 0;
  transition: opacity 500ms ease;
  animation: none;
}

.roomCandleGlow {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--hp-candle-on), transparent 70%);
  opacity: 0;
  transition: opacity 500ms ease;
  pointer-events: none;
}

/* Candles lit (lumos) */
.roomCandle.is-lit .roomCandleFlame {
  opacity: 1;
  animation: flicker 1.2s ease-in-out infinite alternate;
}

.roomCandle.is-lit .roomCandleGlow {
  opacity: 1;
}

/* Bookshelf */
.roomBookshelf {
  position: absolute;
  top: 8%;
  right: 20%;
  width: 100px;
  height: 110px;
  background: linear-gradient(180deg, var(--hp-wood-mid), var(--hp-wood));
  border-radius: 2px;
  display: flex;
  align-items: flex-end;
  padding: 4px 6px;
  gap: 4px;
  box-shadow: inset 0 8px 16px rgba(0,0,0,0.4), 2px 4px 12px rgba(0,0,0,0.5);
}

.roomBook {
  flex: 1;
  border-radius: 2px 2px 0 0;
  box-shadow: inset -2px 0 4px rgba(0,0,0,0.3);
}

.roomBook1 { height: 70px; background: #8b1a1a; }
.roomBook2 { height: 84px; background: #1a4a8b; }
.roomBook3 { height: 64px; background: #2a7a2a; }
.roomBook4 { height: 80px; background: #7a5a10; }
.roomBook5 { height: 72px; background: #6a1a6a; }
.roomBook6 { height: 68px; background: #8b3a1a; }

/* Table */
.roomTable {
  position: absolute;
  bottom: 28%;
  right: 18%;
  width: 120px;
  height: 56px;
  background: linear-gradient(180deg, var(--hp-wood-light), var(--hp-wood));
  border-radius: 4px 4px 0 0;
  box-shadow: 0 6px 0 var(--hp-wood), 4px 10px 20px rgba(0,0,0,0.5);
}

/* ── Blur overlay ────────────────────────────────────────── */
.roomBlurOverlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 3, 2, 0.64);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
  z-index: 2;
}

.roomBlurOverlay.is-visible {
  opacity: 1;
}

/* ── Room Items ──────────────────────────────────────────── */
.roomItems {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.roomItem {
  position: absolute;
  left: var(--item-x, 50%);
  top:  var(--item-y, 50%);
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  border: 0;
  background: transparent;
  color: var(--hp-ink);
  font: inherit;
  cursor: none;
  pointer-events: auto;
  transition: filter 200ms ease, transform 200ms ease;
}

.roomItem:focus-visible {
  outline: 2px solid var(--hp-gold);
  outline-offset: 4px;
}

/* Positions — percentages relative to the stage (background image).
   Refine these with room-grid-test.html. */
/* .roomItemPensieve { --item-x: 50%; --item-y: 65%; }
.roomItemClock    { --item-x: 16%; --item-y: 15%; }
.roomItemMap      { --item-x: 77%; --item-y: 64%; }
.roomItemOwl      { --item-x: 82%; --item-y: 22%; } */
/* Item positions — paste into room.css */
.roomItemClock { --item-x: 8.9%; --item-y: 50.7%; }
.roomItemPensieve { --item-x: 92.0%; --item-y: 76.5%; }
.roomItemOwl { --item-x: 10.7%; --item-y: 78.2%; }
.roomItemMap { --item-x: 49.6%; --item-y: 32.4%; }


/* Label hidden until hover */
.roomItemLabel {
  font-size: 0.78rem;
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  letter-spacing: 0.14em;
  color: var(--hp-gold-light);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 240ms ease, transform 240ms ease;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.roomItem.is-highlighted .roomItemLabel {
  opacity: 1;
  transform: translateY(0);
}

.roomItem.is-highlighted {
  filter: drop-shadow(0 0 14px var(--hp-gold));
  transform: translate(-50%, -50%) scale(1.06);
  z-index: 5;
}

/* ── Pensieve CSS art (room icon) ────────────────────────── */
.pensieveArt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.pensieveBasin {
  position: relative;
  width: 64px;
  height: 30px;
  border-radius: 0 0 60% 60%;
  background: linear-gradient(180deg, #5a4a2a, #3a2a14);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 -4px 8px rgba(0,0,0,0.4);
  border: 1px solid rgba(201,153,60,0.3);
  overflow: hidden;
}

.pensieveLiquid {
  position: absolute;
  inset: 4px 2px 0;
  border-radius: 0 0 60% 60%;
  background: radial-gradient(ellipse at 50% 60%, rgba(180, 220, 255, 0.7), rgba(100, 160, 240, 0.5));
  animation: pensieveSwirl 4s linear infinite;
}

@keyframes pensieveSwirl {
  0%   { transform: rotate(0deg) scaleX(1); }
  50%  { transform: rotate(180deg) scaleX(0.92); }
  100% { transform: rotate(360deg) scaleX(1); }
}

.pensieveGlow {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(140, 200, 255, 0.22), transparent 70%);
  animation: pensieveSwirl 3s linear infinite reverse;
}

.pensievePedestal {
  width: 28px;
  height: 18px;
  background: linear-gradient(180deg, #5a4a2a, #2a1a08);
  clip-path: polygon(15% 0%, 85% 0%, 100% 100%, 0% 100%);
}

/* ── Wall clock CSS art (room icon, not the Weasley clock) ── */
.clockArt {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wallClockFace {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(255,241,215,0.12), transparent 38%),
    linear-gradient(180deg, #1c140f, #0c0806);
  border: 3px solid rgba(201,153,60,0.5);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 0 8px rgba(0,0,0,0.5);
}

.wallClockHand {
  position: absolute;
  bottom: 50%;
  left: 50%;
  width: 2px;
  border-radius: 2px;
  background: var(--hp-gold-light);
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(var(--hand-rotation, 0deg));
}

.wallClockHandHour   { height: 30%; --hand-rotation: 150deg; }
.wallClockHandMinute { height: 40%; --hand-rotation: 240deg; opacity: 0.78; }

.wallClockCenter {
  position: absolute;
  top: 50%; left: 50%;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--hp-gold);
  transform: translate(-50%, -50%);
}

.wallClockBase {
  width: 6px;
  height: 14px;
  background: var(--hp-wood-mid);
  border-radius: 0 0 2px 2px;
}

/* ── Map art (table map room icon) ───────────────────────── */
.mapArt { display: flex; justify-content: center; }

.tableMapPaper {
  width: 64px;
  height: 48px;
  background:
    linear-gradient(180deg, rgba(232, 213, 176, 0.92), rgba(200, 175, 130, 0.9));
  border: 1px solid rgba(91, 56, 26, 0.5);
  border-radius: 2px;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.5);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: rotate(-3deg);
}

.tableMapLine {
  height: 2px;
  border-radius: 1px;
  background: rgba(102, 63, 28, 0.6);
}

/* ══════════════════════════════════════════════════════════
   ROOM SPRITE — cursor follower
══════════════════════════════════════════════════════════ */
@keyframes roomSpriteIdle {
  from { background-position-x: 0; }
  to   { background-position-x: -768px; }
}
@keyframes roomSpriteWalk {
  from { background-position-x: 0; }
  to   { background-position-x: -1024px; }
}

.roomSprite {
  position: absolute;
  z-index: 2;
  width:  128px;
  height: 128px;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background-image: url("../../assets/Idle.png");
  background-repeat: no-repeat;
  background-size: 768px 128px;
  background-position-y: 0;
  animation: roomSpriteIdle 0.8s steps(6) infinite;
  transform-origin: center bottom;
  will-change: left, top, transform;
}

.roomSprite.is-walking {
  background-image: url("../../assets/Walk.png");
  background-size: 1024px 128px;
  animation: roomSpriteWalk 0.8s steps(8) infinite;
}

.roomSprite.is-flipped {
  transform: scaleX(-1);
}

/* Responsive — stage scales uniformly so no breakpoint overrides needed */
