/* The historic rooms (tools/historic.mjs): the 3D viewer (assets/js/rooms/viewer.js), a room's page, the feed
   (/rooms) and the embed (/embed/rooms/<slug>). On top of base.css and post.css on the pages; alone in the embed.
   The viewer sits on a warm paper field by day and a deep blue field at dusk, as the app's share pictures do.
   The controls float on the picture in one glass pill. Colour lives only in the room. */

/* ---------- the viewer */
.rv { --field-day: radial-gradient(120% 95% at 50% 36%, #FCFAF6 0%, #F1ECE4 58%, #E5DED3 100%);
  --field-dusk: radial-gradient(120% 95% at 50% 34%, #343C5A 0%, #1E2336 58%, #13161F 100%);
  --glass: rgb(255 255 255 / 0.72); --glass-line: rgb(20 20 18 / 0.08); --glass-ink: #151514;
  position: relative; width: 100%; max-width: calc(1320px + 2 * var(--gutter, 20px)); margin: clamp(20px, 3vw, 36px) auto 0; padding-inline: var(--gutter, 20px); }
.rv-stage { position: relative; aspect-ratio: 16 / 10; max-height: max(440px, min(calc(100svh - 270px), 820px)); width: 100%; overflow: hidden; border-radius: 28px;
  background: var(--field-day); isolation: isolate; box-shadow: inset 0 0 0 1px rgb(20 20 18 / 0.05); }
/* the dusk field fades in over the day field */
.rv-stage::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--field-dusk); opacity: 0; transition: opacity 0.9s var(--ease, ease); }
.rv[data-light="dusk"] .rv-stage::before { opacity: 1; }
.rv[data-light="dusk"] { --glass: rgb(28 31 44 / 0.62); --glass-line: rgb(255 255 255 / 0.1); --glass-ink: #EEF0F2; }
.rv-poster, .rv-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.rv-poster { object-fit: contain; padding: 4% 6% 12%; transition: opacity 0.7s var(--ease, ease), filter 0.7s; user-select: none; -webkit-user-drag: none; }
.rv-canvas { opacity: 0; transition: opacity 0.7s var(--ease, ease); touch-action: none; cursor: grab; outline: none; }
.rv-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--ink, #151514); }
.rv[data-state="ready"] .rv-canvas { opacity: 1; }
.rv[data-state="ready"] .rv-poster { opacity: 0; pointer-events: none; }
.rv[data-state="loading"] .rv-poster { filter: saturate(0.92); }
.rv[data-state="flat"] .rv-poster { cursor: ew-resize; touch-action: pan-y; }

/* the quiet progress line: a hairline and the per cent, under the poster */
.rv-progress { position: absolute; left: 50%; bottom: 84px; translate: -50% 0; display: flex; align-items: center; gap: 10px; opacity: 0; transition: opacity 0.4s;
  font: 500 11px/1 var(--mono, ui-monospace, monospace); letter-spacing: 0.08em; color: var(--soft, #8E8E88); pointer-events: none; }
.rv[data-state="loading"] .rv-progress { opacity: 1; transition-delay: 0.3s; }
.rv-bar { position: relative; display: block; width: 96px; height: 2px; border-radius: 2px; background: rgb(20 20 18 / 0.1); overflow: hidden; }
.rv-bar i { position: absolute; inset: 0; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform 0.25s linear; }

/* the piece card: its name and size, beside the tap */
.rv-card { position: absolute; left: var(--x); top: var(--y); z-index: 3; display: grid; gap: 2px; max-width: min(300px, 80%); padding: 10px 14px 11px; border-radius: 14px;
  background: var(--glass); color: var(--glass-ink); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 0 0 1px var(--glass-line), 0 12px 32px -12px rgb(0 0 0 / 0.35); pointer-events: none;
  translate: -50% calc(-100% - 14px); opacity: 0; scale: 0.94; transform-origin: 50% 100%; transition: opacity 0.18s, scale 0.25s var(--press, ease); }
.rv-card.below { translate: -50% 18px; transform-origin: 50% 0; }
.rv-card.left { translate: calc(-100% + 24px) calc(-100% - 14px); }
.rv-card.left.below { translate: calc(-100% + 24px) 18px; }
.rv-card.on { opacity: 1; scale: 1; }
.rv-card b { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.rv-card span { font-size: 13px; line-height: 1.35; opacity: 0.72; font-variant-numeric: tabular-nums; }

/* the controls: one glass pill on the picture */
.rv-bar-ui { position: absolute; left: 50%; bottom: 16px; translate: -50% 0; z-index: 4; display: flex; align-items: center; gap: 6px; padding: 5px;
  border-radius: 999px; background: var(--glass); color: var(--glass-ink); -webkit-backdrop-filter: blur(20px) saturate(1.5); backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: 0 0 0 1px var(--glass-line), 0 10px 30px -14px rgb(0 0 0 / 0.4); transition: background 0.6s, color 0.6s; white-space: nowrap; }
.rv-bar-ui button { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border: 0; border-radius: 999px; background: none;
  font: 500 14px/1 var(--font, system-ui); color: inherit; cursor: pointer; text-decoration: none; transition: background 0.2s, opacity 0.2s; }
.rv-bar-ui button:hover { background: rgb(127 127 127 / 0.12); }
.rv-bar-ui button:active { scale: 0.97; }
.rv-bar-ui svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rv-seg { position: relative; display: flex; padding: 0; border-radius: 999px; background: rgb(127 127 127 / 0.1); }
.rv-seg button { position: relative; z-index: 1; }
.rv-seg button[aria-checked="true"] { background: #FFF; color: #151514; box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), 0 0 0 1px rgb(20 20 18 / 0.05); }
.rv[data-light="dusk"] .rv-seg button[aria-checked="true"] { background: #EEF0F2; }
.rv-light .moon { display: none; }
.rv-light .sun-c { fill: currentColor; stroke: none; }
.rv[data-light="dusk"] .rv-light .moon { display: block; fill: currentColor; stroke: none; }
.rv[data-light="dusk"] .rv-light .sun-c, .rv[data-light="dusk"] .rv-light .sun-r { display: none; }
.rv:not([data-state="ready"]) .rv-seg, .rv:not([data-state="ready"]) .rv-light { opacity: 0.45; pointer-events: none; }
.rv[data-state="flat"] .rv-seg, .rv[data-state="flat"] .rv-light { display: none; }
.rv-credit { position: absolute; top: 12px; right: 12px; z-index: 4; display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 999px; background: var(--glass); color: var(--glass-ink);
  -webkit-backdrop-filter: blur(20px) saturate(1.5); backdrop-filter: blur(20px) saturate(1.5); box-shadow: 0 0 0 1px var(--glass-line); font: 500 13px/1 var(--font, system-ui); text-decoration: none; }
.rv-credit:hover { text-decoration: underline; text-underline-offset: 3px; }

/* the toast after Share or Copy */
.rv-toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 50; translate: -50% 12px; padding: 12px 18px; border-radius: 999px;
  background: #151514; color: #FFF; font: 500 14px/1 var(--font, system-ui); opacity: 0; pointer-events: none; transition: opacity 0.2s, translate 0.3s var(--press, ease); }
.rv-toast.on { opacity: 1; translate: -50% 0; }

@media (max-width: 719px) {
  .rv { margin-top: 16px; padding-inline: 12px; }
  .rv-stage { aspect-ratio: 4 / 5; max-height: 74svh; border-radius: 22px; }
  .rv-poster { padding: 8% 4% 22%; }
  .rv-bar-ui { bottom: 12px; gap: 4px; padding: 4px; }
  .rv-bar-ui button { height: 40px; padding: 0 12px; font-size: 13.5px; }
  .rv-light .rv-light-label, .rv-share span { display: none; }   /* the icons say it on a phone; the labels stay for screen readers below */
  .rv-light, .rv-share { width: 40px; padding: 0; justify-content: center; }
  .rv-progress { bottom: 76px; }
}
@media (prefers-reduced-motion: reduce) {
  .rv-poster, .rv-canvas, .rv-card, .rv-stage::before, .rv-toast { transition: none; }
}

/* ---------- the embed: the viewer fills the frame */
.rv-embed-page { margin: 0; height: 100svh; overflow: hidden; background: #F1ECE4; font-family: system-ui, -apple-system, sans-serif;
  --font: system-ui, -apple-system, sans-serif; --mono: ui-monospace, monospace; --ease: cubic-bezier(0.25, 1, 0.5, 1); --press: cubic-bezier(0.34, 1.56, 0.64, 1); }
.rv-embed-page .rv { margin: 0; padding: 0; max-width: none; height: 100%; }
.rv-embed-page .rv-stage { aspect-ratio: auto; height: 100%; max-height: none; border-radius: 0; box-shadow: none; }
.rv-embed-page .vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.rv-embed-page img, .rv-embed-page canvas { display: block; max-width: 100%; }
@media (max-width: 719px) { .rv-embed-page .rv-stage { aspect-ratio: auto; max-height: none; } }

/* ---------- a room's page */
.room-page .rp-head { width: 100%; max-width: calc(1320px + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); display: grid; gap: 12px; }
.post-page main:has(> .room-page) { padding-top: clamp(96px, 8vw, 116px); }
.room-page .rp-head .title { font-size: clamp(34px, 3.6vw, 52px); }
.rp-where { font-size: clamp(15px, 1.2vw, 17px); color: var(--muted); }
.rp-grid { margin-top: clamp(36px, 4.5vw, 64px); padding-inline: var(--gutter); }
.rp-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 0; border-radius: 20px; overflow: hidden; background: var(--line); box-shadow: 0 0 0 1px var(--line); }
.prose > .rp-lore + .rp-facts { margin-top: 16px; }   /* the lore is a story, not the facts' heading: a gap between them */
.rp-facts div { display: grid; gap: 6px; padding: 16px 18px 18px; background: var(--page); }
.rp-facts dt { font: 500 11px/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--soft); }
.rp-facts dd { margin: 0; font-size: clamp(22px, 2vw, 28px); font-weight: 300; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.rp-facts dd span { display: block; margin-top: 4px; font-size: 14px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.rp-byline { font-size: 14px; color: var(--muted); }
.prose .rp-byline a { color: var(--muted); }
@media (max-width: 719px) { .rp-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* the plan, to scale (1 unit = 1 cm) */
.rp-plan { margin-inline: 0; padding: clamp(14px, 2.5vw, 28px); border-radius: 20px; background: var(--surface); }
.rp-plan-svg { display: block; width: 100%; height: auto; max-height: 640px; }
.rp-plan-svg .floor { fill: #FFFFFF; }
.rp-plan-svg .walls { fill: none; stroke: #151514; stroke-width: 14; stroke-linejoin: round; }
.rp-plan-svg .rugs rect { fill: #F4EEE4; stroke: #CDBFA8; stroke-width: 3; stroke-dasharray: 10 8; }
.rp-plan-svg .pieces rect { fill: #E6DDCF; stroke: #A8977F; stroke-width: 2.5; }
.rp-plan-svg .win { stroke: #FFFFFF; stroke-width: 9; }
.rp-plan-svg .door { stroke: #FFFFFF; stroke-width: 18; }
.rp-plan-svg .labels text { font: 500 var(--fs)/1 var(--font); fill: #151514; text-anchor: middle; dominant-baseline: middle; paint-order: stroke; stroke: rgb(255 255 255 / 0.85); stroke-width: 6; stroke-linejoin: round; }
.rp-plan-svg .dim line { stroke: #8E8E88; stroke-width: 2; }
.rp-plan-svg .dim text { font: 400 var(--fs)/1 var(--font); fill: #6B6B66; text-anchor: middle; dominant-baseline: middle; font-variant-numeric: tabular-nums; }
.rp-plan figcaption, .rp-inside figcaption { margin-top: 12px; font-size: 14px; line-height: 1.5; color: var(--muted); }

/* history */
.prose sup.refs { font-size: 0.62em; line-height: 0; margin-left: 1px; }
.prose sup.refs a { margin-left: 2px; color: var(--soft); text-decoration: none; font-variant-numeric: tabular-nums; }
.prose sup.refs a:hover { color: var(--ink); }
.prose .rp-dates { list-style: none; padding: 0; display: grid; gap: 0; border-left: 1px solid var(--line); margin-left: 4px; }
.prose .rp-dates li { position: relative; display: grid; grid-template-columns: 4.6em 1fr; gap: 12px; padding: 8px 0 8px 20px; margin: 0; font-size: 16px; line-height: 1.45; }
.prose .rp-dates li::before { content: ""; position: absolute; left: -3px; top: 16px; width: 5px; height: 5px; background: var(--ink); }
.prose .rp-dates b { font: 500 14px/1.6 var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.prose .rp-dates span { color: var(--muted); }

/* the pieces worth naming */
.prose .rp-pieces { list-style: none; padding: 0; display: grid; gap: 10px; }
.prose .rp-pieces li { display: grid; gap: 4px; padding: 16px 18px; margin: 0; border-radius: 16px; background: var(--surface); font-size: 16px; line-height: 1.5; }
.prose .rp-pieces li::before { display: none; }
.prose .rp-pieces b { font-weight: 500; font-size: 17px; }
.prose .rp-pieces .rp-size { font: 500 12.5px/1.4 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }

.rp-inside { margin-inline: 0; }
.rp-inside img { width: 100%; max-width: 440px; border-radius: 18px; }

/* share and embed */
.rp-share { margin-top: 3em; }
.rp-share-btn, .rp-copy { display: inline-flex; align-items: center; height: 40px; margin-left: 4px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--ink); color: #FFF;
  font: 500 14px/1 var(--font); cursor: pointer; transition: opacity 0.2s, scale 0.2s; vertical-align: middle; }
.rp-copy { margin-left: 0; background: var(--surface); color: var(--ink); }
.rp-share-btn:active, .rp-copy:active { scale: 0.97; }
.rp-share .agent-use { margin-top: 20px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.rp-share .agent-use summary { cursor: pointer; font: 500 11px/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--soft); }
.rp-share .agent-use[open] summary { margin-bottom: 10px; }
.prose .rp-share pre { margin: 10px 0 0; padding: 14px 16px; border-radius: 14px; background: var(--surface); color: var(--ink); font: 12.5px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.prose .rp-share pre code { font: inherit; background: none; padding: 0; }
.notes .checked { color: var(--soft); white-space: nowrap; }

/* ---------- the room cards: the feed and "More rooms" */
.rcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: clamp(14px, 1.6vw, 22px); }
.rooms-hub .rcards { margin-top: clamp(40px, 5vw, 64px); }
.rp-related .rcards { max-width: 1200px; margin-inline: auto; padding-inline: var(--gutter); }
.rcard { display: grid; align-content: start; gap: 14px; color: var(--ink); text-decoration: none; }
.rcard-pic { display: block; aspect-ratio: 7 / 5; border-radius: 22px; overflow: hidden; background: radial-gradient(120% 95% at 50% 36%, #FCFAF6 0%, #F1ECE4 58%, #E5DED3 100%);
  box-shadow: inset 0 0 0 1px rgb(20 20 18 / 0.05); }
.rcard-pic img { width: 100%; height: 100%; object-fit: contain; transform: scale(1.18); transition: transform 0.6s var(--ease); }
.rcard:hover .rcard-pic img { transform: scale(1.23) translateY(-1%); }
.rcard-text { display: grid; gap: 3px; padding-inline: 4px; }
.rcard-text b { font-size: 19px; font-weight: 500; letter-spacing: -0.015em; }
.rcard-text span { font-size: 14.5px; color: var(--muted); line-height: 1.4; }
.rcard-text .rcard-size { font: 500 12px/1.5 var(--mono); color: var(--soft); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .rcard-pic img { transition: none; } }
@media print { .rv-bar-ui, .rp-share { display: none; } }
