/* Room: shelf and wall. Colours follow the site theme when it defines tokens. */
.room {
  --r-bg: var(--bg, #0a0a0a); --r-fg: var(--fg, #fafafa); --r-muted: var(--muted, #a1a1a1); --r-faint: var(--faint, #6b6b6b);
  --r-line: var(--line, rgba(255, 255, 255, 0.1)); --r-card: var(--card, #111111); --r-hover: var(--hover, rgba(255, 255, 255, 0.05));
  --r-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  /* The room's surfaces: one wall, one plank, the frames' mats and mouldings. */
  --r-wall: #151515; --r-plank: #1f1f1f; --r-plank-top: #2c2c2c; --r-mat: #e4e1da; --r-frame: #101010;
  --r-gutter: max(24px, (100vw - 1024px) / 2 + 24px);
  position: relative; color: var(--r-fg); background: var(--r-bg); min-height: 100svh; padding-top: var(--room-top, 44px); overflow: hidden;
}
[data-theme="light"] .room { --r-wall: #ecebe8; --r-plank: #d6d3cd; --r-plank-top: #c8c4bd; --r-mat: #fbfaf7; --r-frame: #1c1c1c; }
.room-head { display: flex; align-items: baseline; gap: 8px 24px; flex-wrap: wrap; width: min(1024px, 100%); margin: 0 auto; padding: 0 24px; box-sizing: border-box; }
.room-head h1 { margin: 0; font-size: clamp(44px, 7vw, 64px); line-height: 1; font-weight: 700; letter-spacing: -0.04em; }
/* One quiet index of every section, wall and shelf. */
.room-index { display: flex; gap: 4px 16px; flex-wrap: wrap; margin-left: auto; }
.room-index button { flex: none; padding: 4px 0; font: inherit; font-size: 13px; line-height: 18px; color: var(--r-faint); background: none; border: 0;
  border-radius: 4px; cursor: pointer; transition: color 0.15s; }
.room-index button:hover { color: var(--r-fg); }
.room-index button:focus-visible { outline: 2px solid var(--r-fg); outline-offset: 2px; }
/* The wall: one full-bleed band of one tone. The hang and the shelf both sit on it. */
.room-band { margin-top: 40px; background: var(--r-wall); }

/* ---------- shelf ---------- */
/* Measures in cm at the room's scale (--cm, set by shelf.js): headroom for a record pulled from the run, the plank,
   then the label line, then bare wall. */
.shelf-unit { --cm: 9px; --pad: calc(var(--cm) * 11); --plank: 27px; --label: calc(var(--plank) + 12px); padding-bottom: calc(var(--cm) * 10); }
.shelf-wrap { position: relative; }
/* 3D row: drawn over the DOM row, which stays in place (invisible) for layout, hover and clicks. */
.shelf-gl { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.shelf-wrap.is-3d .shelf-item { opacity: 0 !important; transform: none !important; }
.shelf-wrap.is-3d .shelf-copy::before { display: none; }
.shelf, .wall { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: none; cursor: grab; }
.shelf::-webkit-scrollbar, .wall::-webkit-scrollbar { display: none; }
.shelf.dragging, .wall.dragging { cursor: grabbing; }
.shelf-track, .wall-track { display: flex; width: max-content; padding: 0 var(--r-gutter); }
.shelf { padding: var(--pad) 0 calc(var(--label) + 18px); }
.shelf-copy { position: relative; display: flex; align-items: flex-end; gap: 1px; height: var(--shelf-h, 283px); padding-right: 2px; }
/* The plank without 3D: one matte board reaching 24px past the first and last items, a hairline on its top front edge. */
.shelf-copy::before { content: ''; position: absolute; left: -24px; right: -22px; top: 100%; height: var(--plank); box-sizing: border-box;
  pointer-events: none; background: var(--r-plank); border-top: 1px solid var(--r-plank-top); }
/* A thin divider stands before each section. Each label sits under its divider. */
.shelf-section { position: relative; flex: none; align-self: flex-end; width: 4px; height: 58%; margin: 0 10px; border-radius: 2px 2px 0 0;
  background: color-mix(in srgb, var(--r-fg) 28%, var(--r-bg)); }
.shelf-wrap.is-3d .shelf-section { background: transparent; }
.shelf-wrap.is-3d .shelf-copy .shelf-label { visibility: hidden; }
.shelf-labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.shelf-labels-in { position: absolute; inset: 0; will-change: transform; }
.shelf-section:first-child { width: 0; margin: 0; background: none; }
.shelf-copy > .shelf-section + .shelf-item { margin-left: 0; }
/* A label names its section and its count. */
.shelf-label { position: absolute; left: 0; top: calc(100% + var(--label)); display: flex; gap: 8px; white-space: nowrap; font-size: 13px; line-height: 18px;
  color: var(--r-muted); pointer-events: none; }
.shelf-label b { font-weight: 500; color: var(--r-fg); }
.shelf-label b, .shelf-label span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.shelf-label span { flex-shrink: 4; }
.shelf-label i { flex: none; font-style: normal; font-variant-numeric: tabular-nums; }
.shelf-item { position: relative; flex: none; padding: 0; border: 0; cursor: pointer; color: var(--ink, #eee);
  background: var(--cloth, #333) center / cover no-repeat; border-radius: 1px;
  box-shadow: inset 2px 0 2px rgba(255, 255, 255, 0.1), inset -3px 0 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s var(--r-ease), opacity 0.15s ease; }
/* Hover: the item eases up off the plank and the rest of the shelf steps back a little.
   The hit area reaches down to the plank so the lift never pulls the item out from under the cursor. */
.shelf-item::before { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: var(--cm); }
.shelf-item.hot { transform: translateY(calc(var(--cm) * -1)); }
.shelf-copy:has(.hot) .shelf-item:not(.hot) { opacity: 0.6; }
html.room-open .shelf-item { opacity: 1 !important; transform: none !important; }
.shelf-item.is-spine::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.22), rgba(255, 255, 255, 0.06) 30%, transparent 60%, rgba(0, 0, 0, 0.24)); }
.shelf-item.dvd, .shelf-item.game { background-color: #0c0c0d; background-position: 50% 50%; border-radius: 2px; }
.shelf-item.baked { background-color: transparent; background-repeat: no-repeat; box-shadow: none; border-radius: 0; }
.shelf-item.baked::after { display: none; }
.shelf-item .t, .shelf-item .a { position: absolute; left: 50%; writing-mode: vertical-rl; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; transform: translateX(-50%); font-family: Georgia, 'Times New Roman', serif; line-height: 1; }
.shelf-item .t { top: 8%; max-height: 62%; font-size: clamp(7px, calc(var(--w, 20px) * 0.4), 14px); }
.shelf-item .a { bottom: 5%; max-height: 22%; font-size: 9px; opacity: 0.75; }
.shelf-item.is-front { background: none; box-shadow: none; margin: 0 2px; }
.shelf-item.is-playing { margin-left: calc(var(--cm) * 2); }
.shelf-item.is-front img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 1px; }
.shelf-item:focus-visible { outline: none; }
/* The board game pile: each box's side panel, bottom first. */
.shelf-item.stack { display: flex; flex-direction: column-reverse; align-items: center; margin: 0 2px; }
.shelf-item.stack img { flex: none; display: block; }
/* The run of records: sleeves edge-on at true thickness. Its hit area reaches a little past both ends. */
.shelf-item.is-run { display: flex; background: none; box-shadow: none; }
.shelf-item.is-run span { flex: 1; background: center / cover no-repeat; box-shadow: inset -1px 0 rgba(0, 0, 0, 0.35); }
.shelf-item.is-run::after { content: ''; position: absolute; top: 0; bottom: 0; left: calc(-1 * var(--pad, 0px)); right: calc(-1 * var(--pad, 0px)); }
/* Keyboard focus: a short bar just under the plank, below the focused item. */
.shelf-focus { position: absolute; top: calc(100% + var(--plank) + 4px); height: 2px; background: var(--r-fg); pointer-events: none; }
.shelf-said { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---------- wall ---------- */
/* A flat, matte wall in one plane. Frames hang where data/wall.json and the hang rules put them, measured in cm and
   drawn at the room's scale, the hang's left edge on the column's. Every frame is the same: a thin black moulding with
   a rebate where it meets the mat, a warm white mat with a bevel-cut window, and light from above, so the moulding's
   top edge catches it, the bevel's top and left catch it, and the frame casts a short shadow down the wall. */
.wall-wrap { position: relative; background: transparent;
  --frame-tone: #0b0b0b; --frame-edge: #1c1c1c; --rebate: rgba(0, 0, 0, 0.4); --mat-tone: #d9d5cc;
  --bevel: rgba(255, 255, 255, 0.18); --window-shade: rgba(0, 0, 0, 0.4); --cast: rgba(0, 0, 0, 0.55); }
[data-theme="light"] .wall-wrap { --frame-tone: var(--r-frame); --frame-edge: #363636; --rebate: rgba(0, 0, 0, 0.14); --mat-tone: var(--r-mat);
  --bevel: rgba(0, 0, 0, 0.05); --window-shade: rgba(30, 24, 18, 0.07); --cast: rgba(40, 30, 20, 0.22); }
.wall { cursor: auto; }
.wall.pans { cursor: grab; }
.wall-track { min-width: 100%; box-sizing: border-box; }
.wall-hang { position: relative; flex: none; }
.wall-piece { position: absolute; box-sizing: border-box; padding: var(--f); margin: 0; border: 0; border-radius: 0; font: inherit; color: inherit;
  cursor: pointer; background: none;
  transition: opacity 0.15s ease; }
.wall-mat { display: block; box-sizing: border-box; width: 100%; height: 100%; padding: 0; background: none; }
/* The window: the bevel where the mat is cut, lit on its top and left, and the mat's edge shading the top of the print. */
.wall-art { position: relative; display: block; width: 100%; height: 100%; overflow: hidden; background: #111; }
.wall-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* Each section's label sits on the wall under its lower-left corner. It names the section, or the piece under the pointer. */
.wall-label { position: absolute; display: flex; gap: 8px; margin: 0; min-width: 0; font-size: 13px; line-height: 18px; color: var(--r-muted);
  white-space: nowrap; pointer-events: none; font-variant-numeric: tabular-nums; }
.wall-label b { flex: none; color: var(--r-fg); font-weight: 500; }
.wall-label span { overflow: hidden; text-overflow: ellipsis; }
/* Hover: the rest of the wall steps back, as on the shelf. */
.wall-hang:has(.wall-piece:hover) .wall-piece:not(:hover) { opacity: 0.8; }
html.room-open .wall-piece { opacity: 1 !important; }
.wall-piece:focus-visible { outline: 2px solid var(--r-fg); outline-offset: 4px; }
/* Arrange mode: the wall's centre and centre line show as guides, and frames move instead of opening. */
.wall-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: min(1024px, 100%); margin: 0 auto; padding: 14px 24px 0;
  box-sizing: border-box; font-size: 13px; color: var(--r-muted); font-variant-numeric: tabular-nums; white-space: pre; }
.wall-tools b { color: var(--r-fg); font-weight: 500; }
.wall-tools button { flex: none; height: 32px; padding: 0 14px; font: inherit; font-size: 13px; font-weight: 500; color: var(--r-bg); background: var(--r-fg);
  border: 0; border-radius: 999px; cursor: pointer; }
.arranging .wall-hang { background:
  linear-gradient(var(--r-line), var(--r-line)) var(--centre) 0 / 1px 100% no-repeat,
  linear-gradient(var(--r-line), var(--r-line)) 0 var(--line) / 100% 1px no-repeat; }
.arranging .wall-piece { cursor: move; touch-action: none; user-select: none; }
.arranging .wall-piece.moving { z-index: 1; outline: 1px solid var(--r-fg); outline-offset: 2px; }
.arranging .wall-hang:has(.moving) .wall-piece:not(.moving) { opacity: 0.8; }
/* An opened piece shows as the clean print, matte and square-cornered. */
.wall-lifted { position: fixed; z-index: 12; overflow: hidden; background: #111; animation: wall-fade 0.3s ease; }
.wall-lifted.leaving { pointer-events: none; animation: wall-fade 0.3s ease reverse forwards; }
@keyframes wall-fade { from { opacity: 0; } }
.wall-lifted img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* ---------- opened item ---------- */
html.room-open { overflow: hidden; }
html.room-open .site-head { z-index: auto; }
.room-veil { position: fixed; inset: 0; z-index: 10; background: transparent; opacity: 0; visibility: hidden;
  transition: opacity 0.4s ease, visibility 0s 0.4s; }
.part-open .room-veil { opacity: 1; visibility: visible; transition: opacity 0.4s ease; }
.room-gl { position: fixed; inset: 0; z-index: 11; width: 100vw; height: 100vh; pointer-events: none; touch-action: none; opacity: 0; transition: opacity 0.35s ease; }
.part-open .room-gl { pointer-events: auto; opacity: 1; }
.room-gl.grab { cursor: grab; }
.room-panel { position: fixed; z-index: 12; top: 50%; right: var(--r-gutter); width: min(400px, 40vw); max-height: min(80vh, 680px); overflow: auto;
  overscroll-behavior: contain; padding: 8px 0 16px; border-radius: 20px; color: var(--r-fg); background: var(--r-card); border: 1px solid var(--r-line);
  opacity: 0; visibility: hidden; transform: translate(12px, -50%);
  transition: opacity 0.3s ease, transform 0.5s var(--r-ease), visibility 0s 0.5s; }
html .part-open .room-panel { opacity: 1; visibility: visible; transform: translate(0, -50%);
  transition: opacity 0.4s ease 0.15s, transform 0.6s var(--r-ease) 0.1s, visibility 0s; }
.room-back { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--r-hover); color: var(--r-muted); cursor: pointer; font-size: 15px; }
.room-back:hover { color: var(--r-fg); }
.rp-top { padding: 16px 56px 16px 20px; }
.rp-top h3 { margin: 0; font-size: 19px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
.rp-top p { margin: 4px 0 0; font-size: 14px; color: var(--r-muted); }
/* Groups sit on the panel's own surface, as hairline rows. */
.rp-card { margin: 0 20px 16px; border-top: 1px solid var(--r-line); }
.rp-card:last-child { margin-bottom: 0; }
.rp-note { padding: 14px 0 0; font-size: 15px; line-height: 1.55; white-space: pre-line; }
.rp-kv, .rp-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 0; font-size: 14px; }
.rp-kv + .rp-kv, .rp-row + .rp-row { border-top: 1px solid var(--r-line); }
.rp-kv span:first-child { color: var(--r-muted); }
.rp-text { padding: 14px 0 0; }
.rp-text h4 { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--r-muted); }
.rp-text p { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--r-muted); white-space: pre-line; }
.rp-links { overflow: hidden; }
.rp-row { justify-content: flex-start; color: var(--r-fg); text-decoration: none; }
.rp-row:hover { color: var(--r-muted); }
.rp-row img, .rp-thumb { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; background: var(--r-hover); flex: none; }
.rp-row > span:not(.icon):not(.rp-thumb) { flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.rp-row small { font-size: 11px; color: var(--r-muted); }
.rp-row .icon { color: var(--r-faint); }

@media (max-width: 720px) {
  .room { --r-gutter: 16px; }
  .room-head { padding: 0 16px; row-gap: 12px; }
  .room-head h1 { flex-basis: 100%; }
  .room-index { flex: 0 0 calc(100% + 32px); flex-wrap: nowrap; margin: 0 -16px; padding: 0 16px; box-sizing: border-box; overflow-x: auto; scrollbar-width: none; }
  .room-index::-webkit-scrollbar { display: none; }
  /* More of the index lies to the right until it is scrolled to its end. */
  .room-index:not(.at-end) { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .room-band { margin-top: 28px; }
  .room-panel { top: auto; right: 0; left: 0; bottom: -80px; width: auto; max-height: calc(46vh + 80px); padding-bottom: calc(96px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0; border-bottom: 0; transform: translateY(24px); }
  html .part-open .room-panel { transform: none; }
  /* The shelf steps back behind an opened item, which otherwise stands over a crowded row. */
  .room .room-veil { background: color-mix(in srgb, var(--r-bg) 82%, transparent); }
  .wall-tools { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .room *, .room *::before, .room *::after { transition-duration: 0.01s !important; transition-delay: 0s !important; animation: none !important; }
}
/* Each shelf sits in a card, as content does on every other page. The wall band goes; the cards sit on the page. */
.room-band { background: none; display: flex; flex-direction: column; gap: 16px; margin-bottom: 72px; }
.room-part { width: min(1024px - 48px, 100% - 32px); margin: 0 auto; box-sizing: border-box; overflow: hidden;
  background: var(--r-card); border: 1px solid var(--r-line); border-radius: 16px; }
.room-part .shelf-unit { --pad: calc(var(--cm) * 3); padding-bottom: 16px; }
.room-part .shelf-track { padding: 0 24px; }
#room-shelf-low .shelf-unit { --pad: calc(var(--cm) * 8); }

/* An item opened over another page: the room's veil, 3D view and panel, with the site's colours. */
.room-peek {
  --r-fg: var(--fg); --r-muted: var(--muted); --r-faint: var(--faint); --r-line: var(--line); --r-card: var(--card); --r-hover: var(--hover);
  --r-ease: cubic-bezier(0.2, 0.8, 0.2, 1); --r-gutter: max(24px, (100vw - 1024px) / 2 + 24px);
  position: fixed; inset: 0; z-index: 40; pointer-events: none; color: var(--r-fg);
}
.room-peek > * { pointer-events: auto; }
.room-peek .room-veil { background: rgba(0, 0, 0, 0.6); }
.room-peek:not(.part-open) .room-gl, .room-peek:not(.part-open) .room-veil { pointer-events: none; }
.rp-open { display: inline-flex; align-items: center; gap: 4px; height: 32px; margin-top: 12px; padding: 0 12px 0 14px; border-radius: 999px;
  background: var(--r-fg); color: var(--r-card); font-size: 13px; font-weight: 500; text-decoration: none; }
.rp-open:hover { opacity: 0.9; }
/* Previous and next record, under the title of a record from the run. */
.rp-steps { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--r-muted); font-variant-numeric: tabular-nums; }
.rp-steps button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--r-line); border-radius: 50%;
  background: var(--r-hover); color: var(--r-fg); cursor: pointer; font-size: 15px; }
.rp-steps button:disabled { opacity: 0.35; cursor: default; }
.rp-steps .flip { transform: rotate(180deg); }
@media (max-width: 720px) { .room-peek { --r-gutter: 16px; } }
