/*
 * room.laurenshof.online — Het Kamertje, late afternoon.
 * No HTML chrome on the room view; everything visible inside the room is
 * pixel art rendered via SVG <use> from Kenney CC0 tiles.
 */

:root {
  /* Palette (per DESIGN.md) */
  --parchment-cream: oklch(94% 0.018 80);
  --plank-shadow:    oklch(78% 0.025 60);
  --aubergine-ink:   oklch(26% 0.06 320);
  --aubergine-deep:  oklch(20% 0.05 320);
  --ink-wash:        oklch(38% 0.04 320);
  --amber-gold:      oklch(72% 0.13 75);

  /* Type — only the prose serif loads on this page; in-room labels use
     pixel art rendered as SVG, not webfonts. */
  --font-prose: "Source Serif 4", "Iowan Old Style", Charter, Georgia, serif;
  --font-pixel: ui-monospace, "SF Mono", monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 18px;
  --space-5: 28px;
  --space-6: 44px;
  --space-7: 72px;

  --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
  --tile-step: 120ms;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html, body { background: var(--parchment-cream); }

body {
  color: var(--ink-wash);
  font-family: var(--font-prose);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--aubergine-ink);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
a:hover { color: var(--ink-wash); }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.focusable:focus,
.focusable:focus-visible {
  position: fixed;
  top: 12px; left: 12px;
  width: auto; height: auto; clip: auto;
  background: var(--parchment-cream);
  color: var(--aubergine-ink);
  border: 1px solid var(--aubergine-ink);
  padding: 8px 14px;
  font-family: var(--font-prose);
  font-size: 14px;
  z-index: 200;
}

/* ------------------------------------------------------------------
 * Plain view
 * ------------------------------------------------------------------ */

.plain {
  max-width: 64ch;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 80px) clamp(20px, 5vw, 32px) 96px;
}

.plain__eyebrow {
  font-family: var(--font-prose);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--ink-wash);
  margin: 0 0 var(--space-4);
  text-transform: lowercase;
}

.plain__title {
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.05;
  color: var(--aubergine-ink);
  margin: 0 0 var(--space-4);
  letter-spacing: 0;
}
.plain__title:focus { outline: none; }

.plain__lede {
  font-size: 1.125rem;
  color: var(--ink-wash);
  margin: 0 0 var(--space-7);
  max-width: 56ch;
}

.plain__section { margin-bottom: var(--space-7); }

.plain__section h2 {
  font-weight: 500;
  font-size: 1.375rem;
  color: var(--aubergine-ink);
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--plank-shadow);
}
.plain__section p { margin: 0 0 var(--space-3); max-width: 65ch; }

.plain__list { list-style: none; padding: 0; margin: 0; }
.plain__list li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--plank-shadow);
}
.plain__list li:last-child { border-bottom: 0; }
.plain__list a { font-weight: 500; font-size: 1.0625rem; }
.plain__meta {
  display: block;
  margin-top: 4px;
  font-size: 0.95rem;
  color: var(--ink-wash);
}

.plain__action { margin: var(--space-5) 0 0; display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.plain__cta {
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: var(--parchment-cream);
  background: var(--aubergine-ink);
  padding: 12px 22px;
  border: 1px solid var(--aubergine-ink);
  transition: background var(--tile-step) var(--ease-out-quart),
              transform   var(--tile-step) var(--ease-out-quart);
}
.plain__cta:hover { background: var(--aubergine-deep); transform: translateY(-1px); }
.plain__cta:focus-visible { outline: 2px solid var(--amber-gold); outline-offset: 2px; }
.plain__cta-note { font-size: 0.9375rem; color: var(--ink-wash); }

.plain__footer {
  border-top: 1px solid var(--plank-shadow);
  padding-top: var(--space-4);
  margin-top: var(--space-7);
  font-size: 0.9375rem;
  color: var(--ink-wash);
}

/* No JS: plain visible by default, room hidden */
.no-js .plain { display: block; }
.no-js .room  { display: none; }

/* JS booted: room visible, plain hidden */
.has-js .plain { display: none; }
.has-js .room  { display: block; }
.has-js.show-plain .plain { display: block; }
.has-js.show-plain .room  { display: none; }

/* ------------------------------------------------------------------
 * Room view (full-bleed pixel-art canvas)
 * ------------------------------------------------------------------ */

.room {
  position: fixed;
  inset: 0;
  background: var(--parchment-cream);
}

.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: transparent;
  padding: 24px 24px 104px 24px;
  overflow: hidden;
}

.stage__svg {
  width: min(100%, 960px);
  height: auto;
  max-height: 100%;
  aspect-ratio: 576 / 432;
  display: block;
  background: oklch(34% 0.06 145);
  border-radius: 10px;
  box-shadow: 0 6px 28px oklch(15% 0.04 280 / 0.18);
  shape-rendering: crispEdges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Player smooth-step easing. Reduced-motion override at the bottom.
   `will-change` promotes the player to its own GPU layer so movement
   doesn't recomposite the surrounding SVG tree. */
.player {
  transition: transform var(--tile-step) var(--ease-out-quart);
  will-change: transform;
}

/* Adjacency rim: hidden by default, lit gold on data-active=true */
.object__rim {
  opacity: 0;
  transition: opacity var(--tile-step) var(--ease-out-quart);
  pointer-events: none;
}
.object[data-active="true"] .object__rim {
  opacity: 1;
  animation: rim-pulse 1.6s ease-in-out infinite;
}
@keyframes rim-pulse {
  0%, 100% { opacity: 0.95; }
  50%      { opacity: 0.65; }
}

.prompt { pointer-events: none; transition: opacity 180ms var(--ease-out-quart); }
.prompt__text { font-family: var(--font-prose); font-size: 12px; fill: var(--aubergine-ink); }

/* ------------------------------------------------------------------
 * Dialogue overlay
 * ------------------------------------------------------------------ */

.dialogue {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: clamp(16px, 4vw, 48px);
}
.dialogue[data-open="true"] { display: flex; }

.dialogue__scrim {
  position: absolute; inset: 0;
  background: oklch(20% 0.05 320 / 0.55);
}

.dialogue__panel {
  position: relative;
  max-width: 540px; width: 100%;
  background: var(--parchment-cream);
  border: 1px solid var(--aubergine-ink);
  padding: var(--space-5) var(--space-5) var(--space-4);
  color: var(--ink-wash);
  outline: none;
  animation: dialogue-in 220ms var(--ease-out-quart);
}
@keyframes dialogue-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dialogue__corners { position: absolute; inset: 0; pointer-events: none; }
.dialogue__corner { position: absolute; width: 6px; height: 6px; background: var(--amber-gold); }
.dialogue__corner--tl { top: -1px; left: -1px; }
.dialogue__corner--tr { top: -1px; right: -1px; }
.dialogue__corner--bl { bottom: -1px; left: -1px; }
.dialogue__corner--br { bottom: -1px; right: -1px; }

.dialogue__title {
  font-weight: 500; font-size: 1.5rem;
  color: var(--aubergine-ink);
  margin: 0 0 var(--space-3); letter-spacing: 0;
}
.dialogue__body { font-size: 1.0625rem; line-height: 1.65; max-width: 56ch; }
.dialogue__body p { margin: 0 0 var(--space-3); }
.dialogue__body p:last-child { margin-bottom: 0; }
.dialogue__body ul { list-style: none; padding: 0; margin: 0; }
.dialogue__body li { padding: var(--space-3) 0; border-bottom: 1px solid var(--plank-shadow); }
.dialogue__body li:last-child { border-bottom: 0; }
.dialogue__body li a { display: block; font-weight: 500; font-size: 1.0625rem; color: var(--aubergine-ink); text-decoration: none; }
.dialogue__body li a:hover { color: var(--amber-gold); }
.dialogue__body li a:focus-visible { outline: 2px solid var(--amber-gold); outline-offset: 3px; }
.dialogue__body .item-meta { display: block; font-size: 0.9375rem; color: var(--ink-wash); margin-top: 4px; font-weight: 400; }

/* Compact list used by the bookshelf dialogue: title and author render on
   the same line (link is inline, not block), and rows use a tighter
   vertical rhythm so eight or so books fit without dwarfing the room. */
.dialogue__body .bookshelf-list li { padding: var(--space-2) 0; }
.dialogue__body .bookshelf-list li a { display: inline; }
.dialogue__body .bookshelf-list .item-meta { margin-top: 2px; }

.dialogue__action {
  font-size: 1rem;
  color: var(--parchment-cream);
  background: var(--aubergine-ink);
  padding: 10px 18px;
  border: 1px solid var(--aubergine-ink);
  transition: background var(--tile-step) var(--ease-out-quart);
}
.dialogue__action:hover { background: var(--aubergine-deep); }
.dialogue__action:focus-visible { outline: 2px solid var(--amber-gold); outline-offset: 2px; }
.dialogue__action:disabled { opacity: 0.6; cursor: not-allowed; }

/* The claim panel injected at the bottom of the win dialogue. A thin
   plank-shadow rule above it sets it off from the win prose without
   leaning on color, since the panel still belongs to the same dialogue. */
.dialogue__body .claim {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--plank-shadow);
}
.dialogue__body .claim__status {
  margin-left: var(--space-2);
  font-size: 0.9375rem;
  color: var(--ink-wash);
}

.ledger-form {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
  margin: var(--space-3) 0;
  flex-wrap: wrap;
}
.ledger-form input {
  flex: 1 1 220px;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  color: var(--aubergine-ink);
  background: var(--parchment-cream);
  border: 1px solid var(--ink-wash);
  padding: 8px 12px;
}
.ledger-form input:focus-visible {
  outline: 2px solid var(--amber-gold);
  outline-offset: 2px;
  border-color: var(--aubergine-ink);
}
.ledger-error {
  color: oklch(45% 0.14 28);
  font-size: 0.9375rem;
  margin: 0 0 var(--space-3);
}

.dialogue__close {
  position: absolute;
  top: var(--space-3); right: var(--space-3);
  font-size: 0.8125rem;
  color: var(--ink-wash);
  letter-spacing: 0.02em;
  padding: 4px 8px;
}
.dialogue__close:hover { color: var(--amber-gold); }
.dialogue__close:focus-visible { outline: 2px solid var(--amber-gold); outline-offset: 2px; }

/* ------------------------------------------------------------------
 * Touch / narrow viewport: hide the room, show the plain page.
 * ------------------------------------------------------------------ */

@media (hover: none) and (pointer: coarse), (max-width: 720px) {
  .has-js .plain { display: block; }
  .has-js .room  { display: none; }
  .has-js.show-plain .room { display: none; }
  .plain__action { display: none; }
}

/* ------------------------------------------------------------------
 * Reduced motion
 * ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .player { transition: none; }
  .object__rim { transition: none; animation: none; }
  .prompt { transition: none; }
  .dialogue__panel { animation: none; }
  .plain__cta { transition: none; }
}

/* ------------------------------------------------------------------
 * Welcome / help overlay
 *
 * A modern, friendly modal that speaks for the page rather than for
 * the world inside the pixel-art room. Deliberately a different visual
 * register from the in-room dialogue chrome.
 * ------------------------------------------------------------------ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.overlay[data-open="true"] {
  pointer-events: auto;
  opacity: 1;
}
.overlay__backdrop {
  position: absolute;
  inset: 0;
  background: oklch(15% 0.04 280 / 0.55);
  cursor: pointer;
}
.overlay__card {
  position: relative;
  z-index: 1;
  background: oklch(97% 0.01 80);
  color: oklch(22% 0.03 290);
  border-radius: 14px;
  box-shadow: 0 16px 48px oklch(15% 0.04 280 / 0.35);
  max-width: 460px;
  width: 100%;
  padding: 28px 28px 24px;
  font-family: "Source Serif 4", Georgia, serif;
  transform: translateY(8px);
  transition: transform 200ms ease-out;
}
.overlay[data-open="true"] .overlay__card { transform: translateY(0); }

.overlay__title {
  margin: 0 0 12px;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.overlay__body p {
  margin: 0 0 12px;
  font-size: 1rem;
  line-height: 1.5;
  color: oklch(28% 0.03 290);
}
.overlay__body p:last-child { margin-bottom: 0; }
.overlay__small {
  margin: 12px 0 0;
  font-size: 0.875rem;
  color: oklch(45% 0.02 290);
}
.overlay__body a,
.overlay__small a {
  color: oklch(52% 0.14 250);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.overlay__body a:hover,
.overlay__small a:hover { color: oklch(45% 0.16 250); }

.overlay__auth {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid oklch(90% 0.01 80);
}
.overlay__form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.overlay__form input[type="text"] {
  flex: 1 1 200px;
  font-family: inherit;
  font-size: 0.9375rem;
  padding: 8px 12px;
  border: 1px solid oklch(85% 0.015 80);
  border-radius: 8px;
  background: oklch(99% 0.005 80);
  color: oklch(22% 0.03 290);
}
.overlay__form input[type="text"]:focus {
  outline: 2px solid oklch(52% 0.14 250);
  outline-offset: 1px;
  border-color: transparent;
}
.overlay__error {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: oklch(50% 0.18 25);
}

.overlay__actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.overlay__button {
  font-family: inherit;
  font-size: 0.9375rem;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 150ms ease-out, transform 80ms ease-out;
}
.overlay__button--primary {
  background: oklch(28% 0.06 290);
  color: oklch(97% 0.01 80);
}
.overlay__button--primary:hover { background: oklch(34% 0.07 290); }
.overlay__button--ghost {
  background: transparent;
  border-color: oklch(85% 0.015 80);
  color: oklch(28% 0.03 290);
}
.overlay__button--ghost:hover {
  background: oklch(95% 0.01 80);
  border-color: oklch(72% 0.02 80);
}
.overlay__button:focus-visible {
  outline: 2px solid oklch(52% 0.14 250);
  outline-offset: 2px;
}
.overlay__button:active { transform: translateY(1px); }

/* Floating control bar at the bottom-right. Visible only when JS is
   running and the room view is being shown. */
.controls {
  display: none;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  gap: 10px;
  flex-direction: row;
  align-items: center;
}
.has-js .controls { display: flex; }
.has-js.show-plain .controls { display: none; }

.control-button {
  height: 44px;
  padding: 0 18px;
  border-radius: 22px;
  border: 1px solid oklch(80% 0.015 80);
  background: oklch(98% 0.008 80);
  color: oklch(26% 0.03 290);
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px oklch(15% 0.04 280 / 0.18);
  transition: transform 100ms ease-out,
              background-color 150ms ease-out,
              box-shadow 150ms ease-out;
}
.control-button:hover {
  background: oklch(99.5% 0.004 80);
  box-shadow: 0 4px 16px oklch(15% 0.04 280 / 0.22);
  transform: translateY(-1px);
}
.control-button:focus-visible {
  outline: 2px solid oklch(52% 0.14 250);
  outline-offset: 2px;
}
.control-button:active { transform: translateY(0); }
.control-button--exit {
  background: oklch(95% 0.012 80);
  color: oklch(36% 0.03 290);
}
.control-button--exit:hover { background: oklch(97% 0.01 80); }

@media (hover: none) and (pointer: coarse), (max-width: 720px) {
  .controls { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .overlay,
  .overlay__card,
  .overlay__button,
  .control-button { transition: none; }
}

/* ------------------------------------------------------------------
 * Stats overlay + button
 *
 * Same modal pattern as the welcome overlay but wider, scrollable, and
 * carrying a live render of the actor.rpg.stats record.
 * ------------------------------------------------------------------ */

.stats-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.stats-overlay[data-open="true"] {
  pointer-events: auto;
  opacity: 1;
}
.stats-overlay__card {
  position: relative;
  z-index: 1;
  background: oklch(97% 0.01 80);
  color: oklch(22% 0.03 290);
  border-radius: 14px;
  box-shadow: 0 16px 48px oklch(15% 0.04 280 / 0.35);
  max-width: 640px;
  width: 100%;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  font-family: "Source Serif 4", Georgia, serif;
  transform: translateY(8px);
  transition: transform 200ms ease-out;
}
.stats-overlay[data-open="true"] .stats-overlay__card { transform: translateY(0); }
.stats-overlay__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 22px 28px 12px;
  border-bottom: 1px solid oklch(90% 0.01 80);
}
.stats-overlay__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.stats-overlay__close {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  color: oklch(45% 0.02 290);
  padding: 4px 8px;
  letter-spacing: 0.02em;
}
.stats-overlay__close:hover { color: oklch(22% 0.03 290); }
.stats-overlay__close:focus-visible {
  outline: 2px solid oklch(52% 0.14 250);
  outline-offset: 2px;
}
.stats-overlay__body {
  padding: 18px 28px 24px;
  overflow-y: auto;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: oklch(28% 0.03 290);
}
.stats-overlay__body p { margin: 0 0 12px; }
.stats-overlay__body p:last-child { margin-bottom: 0; }
.stats-overlay__body a {
  color: oklch(52% 0.14 250);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.stats__identity {
  margin: 0 0 4px !important;
  font-size: 0.9375rem;
  color: oklch(40% 0.02 290);
  font-style: italic;
}
.stats__quick {
  margin: 0 0 18px !important;
  font-size: 0.9375rem;
  color: oklch(28% 0.03 290);
}
.stats__quick strong { font-weight: 600; color: oklch(22% 0.03 290); }

.stats__abilities {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin: 0 0 22px;
}
.ability {
  text-align: center;
  padding: 8px 4px;
  background: oklch(94% 0.012 80);
  border: 1px solid oklch(88% 0.012 80);
  border-radius: 8px;
}
.ability__name {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: oklch(45% 0.02 290);
  text-transform: uppercase;
}
.ability__score {
  font-size: 1.25rem;
  font-weight: 600;
  color: oklch(22% 0.03 290);
  line-height: 1.1;
  margin-top: 2px;
}
.ability__mod {
  font-size: 0.8125rem;
  color: oklch(40% 0.02 290);
}

.stats__heading {
  margin: 18px 0 8px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: oklch(22% 0.03 290);
}
.stats__attacks {
  margin: 0 0 12px;
  padding-left: 18px;
}
.stats__attacks li { margin-bottom: 4px; }

.stats__footer {
  margin-top: 22px !important;
  padding-top: 14px;
  border-top: 1px solid oklch(90% 0.01 80);
  font-size: 0.8125rem;
  color: oklch(45% 0.02 290);
}

.stats__loading, .stats__error {
  font-size: 0.9375rem;
  color: oklch(45% 0.02 290);
  text-align: center;
  padding: 24px 0;
}

@media (prefers-reduced-motion: reduce) {
  .stats-overlay,
  .stats-overlay__card { transition: none; }
}

@media (max-width: 540px) {
  .stats__abilities { grid-template-columns: repeat(3, 1fr); }
}
