:root {
  --room-bg: #0b0b0d;
  --room-vignette: #000000;
  --ink: #e9e6df;
  --ink-dim: #9a968c;
  --serif-display: 'Fraunces', Georgia, serif;
  --serif-body: 'Newsreader', Georgia, serif;
  --sans: 'Inter', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--room-bg);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  background:
    radial-gradient(ellipse at center, #131316 0%, var(--room-bg) 55%, var(--room-vignette) 100%);
}

#stage.dragging {
  cursor: grabbing;
}

#wall {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.piece {
  position: absolute;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: #050505;
}

.piece img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.25s ease;
}

/* --- Focus / spotlight (Phase C) ------------------------------------- */

#wall.focus-active .piece {
  transition: opacity 0.6s ease, filter 0.6s ease;
}

#wall.focus-active .piece:not(.piece--focused) {
  opacity: 0.1;
  filter: brightness(0.45) saturate(0.7);
}

.piece--focused {
  z-index: 5;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.14);
}

/* The focused piece's own (wall-transform-scaled) image is hidden -- the
   #focus-image overlay below carries the actual visible content instead.
   Why: an <img> inside an ancestor with an animated transform: scale() can
   get GPU-rasterized at whatever tiny size it happened to be when it first
   painted, then just stretched (blurry) as the ancestor scales up, instead
   of being re-rendered crisply at the final size. #focus-image is
   positioned with real px width/height, not a scaled transform, so it is
   never subject to that. */
.piece--focused img {
  opacity: 0;
}

#stage.focus-active {
  cursor: default;
}

#focus-image {
  position: fixed;
  z-index: 6;
  display: block;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  background: #050505;
  transition: opacity 0.25s ease;
}

#focus-image.visible {
  opacity: 1;
}

#back-to-wall {
  position: fixed;
  left: 28px;
  top: 26px;
  z-index: 16;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 9px 12px;
  background: rgba(14, 14, 15, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: var(--ink-dim);
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
  opacity: 0;
  translate: -8px 0;
  transition: opacity 0.5s ease, translate 0.5s ease, color 0.2s ease, border-color 0.2s ease;
  pointer-events: none;
}

#back-to-wall.visible {
  opacity: 1;
  translate: 0 0;
  pointer-events: auto;
}

#back-to-wall:hover {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.3);
}

/* --- Placard (Phase C) -------------------------------------------------
   One shared DOM structure; the .placard--* class picks the design, and
   JS toggles .below-mode for the adaptive side-card variant when a wide
   piece pushes it into below-the-work placement. */

.placard {
  position: fixed;
  z-index: 15;
  opacity: 0;
  translate: 0 14px;
  transition: opacity 0.7s ease, translate 0.7s ease;
  pointer-events: none;
}

.placard.visible {
  opacity: 1;
  translate: 0 0;
  pointer-events: auto;
}

.placard-name {
  font-family: var(--serif-display);
  color: var(--ink);
  margin: 0;
}

.placard-size {
  font-family: var(--sans);
  color: var(--ink-dim);
  text-transform: uppercase;
  margin: 0;
}

.placard-desc {
  font-family: var(--serif-body);
  color: var(--ink);
  margin: 0;
}

.placard-insp-label {
  font-family: var(--sans);
  color: var(--ink-dim);
  text-transform: uppercase;
  margin: 0;
}

.placard-insp {
  font-family: var(--serif-body);
  color: var(--ink-dim);
  font-style: italic;
  margin: 0;
}

/* Variant A -- Side Card: adaptive, placed by the piece's height in maps
   (see decidePlacement in JS) -- right side for anything taller than 3
   maps, below for short pieces. Width is set inline by JS: it measures
   the piece's own name so multi-word titles never wrap awkwardly, within
   SIDE_CARD_MIN_WIDTH/MAX_WIDTH bounds; the value below is a fallback. */

.placard--side-card {
  width: 460px;
  padding: 34px 36px;
  background: linear-gradient(180deg, rgba(20, 20, 22, 0.97), rgba(9, 9, 10, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}

.placard--side-card .placard-header {
  margin-bottom: 26px;
}

.placard--side-card .placard-name {
  font-size: 31px;
  font-weight: 600;
  line-height: 1.22;
  margin-bottom: 12px;
}

.placard--side-card .placard-size {
  font-size: 11px;
  letter-spacing: 0.14em;
}

.placard--side-card .placard-body {
  display: block;
}

.placard--side-card .placard-desc {
  font-size: 18.5px;
  line-height: 1.68;
}

.placard--side-card .placard-insp-block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.placard--side-card .placard-insp-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  margin-bottom: 8px;
}

.placard--side-card .placard-insp {
  font-size: 18px;
  line-height: 1.6;
}

/* Variant B -- Wide Plate: always below, centered, two columns so the
   extra horizontal room reads as considered rather than just wide. */

.placard--wide-plate {
  width: 760px;
  max-width: 86vw;
  padding: 32px 44px 38px;
  text-align: center;
  background: rgba(9, 9, 10, 0.97);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
}

.placard--wide-plate .placard-header {
  margin-bottom: 24px;
}

.placard--wide-plate .placard-name {
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 6px;
}

.placard--wide-plate .placard-size {
  font-size: 11px;
  letter-spacing: 0.14em;
}

.placard--wide-plate .placard-body {
  display: flex;
  gap: 44px;
  text-align: left;
}

.placard--wide-plate .placard-desc-block {
  flex: 1.1;
}

.placard--wide-plate .placard-insp-block {
  flex: 1;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  padding-left: 44px;
}

.placard--wide-plate .placard-desc {
  font-size: 14.5px;
  line-height: 1.65;
}

.placard--wide-plate .placard-insp-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  margin-bottom: 8px;
}

.placard--wide-plate .placard-insp {
  font-size: 14px;
  line-height: 1.6;
}

/* Variant C -- Caption: always below, compact and translucent, name and
   size share a baseline for a minimal contemporary-gallery-app feel. */

.placard--caption {
  width: 640px;
  max-width: 84vw;
  padding: 20px 28px 26px;
  background: rgba(8, 8, 9, 0.88);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.placard--caption .placard-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 12px;
}

.placard--caption .placard-name {
  font-size: 21px;
  font-weight: 600;
}

.placard--caption .placard-size {
  font-size: 10.5px;
  letter-spacing: 0.12em;
}

.placard--caption .placard-body {
  display: flex;
  gap: 32px;
  text-align: left;
}

.placard--caption .placard-desc-block {
  flex: 1.2;
}

.placard--caption .placard-insp-block {
  flex: 1;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  padding-left: 32px;
}

.placard--caption .placard-desc {
  font-size: 13px;
  line-height: 1.55;
}

.placard--caption .placard-insp-label {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
}

.placard--caption .placard-insp {
  font-size: 12.5px;
  line-height: 1.5;
  opacity: 0.85;
}

