/* david: one empty room in a game nobody remembers installing. */
@font-face { font-family: "Silkscreen"; src: url("/font/silkscreen-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Silkscreen"; src: url("/font/silkscreen-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Space Mono"; src: url("/font/space-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --wall: #8A7B66; --wall-d: #6E6150; --floor: #4A4440; --chair: #D9D4CE;
  --green: #5E7F25; --cream: #E3D3B8; --paper-ink: #2B2622; --plate: #1E1B18;
  --bg: var(--wall-d); --ink: var(--cream); --accent: #F2EEE4;
  --font-display: "Silkscreen", system-ui, sans-serif;
  --font-body: "Silkscreen", system-ui, sans-serif;
  --container: min(1640px, 100% - 2 * var(--s5));
  --reading: min(760px, 100% - 2 * var(--s3));
  --display: clamp(44px, 5vw, 96px);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-pop: cubic-bezier(.3, 1.5, .5, 1);
}

html { background: var(--floor); }
body { background: var(--floor) url("/img/room/carpet.webp") 0 0 / 256px 256px; overflow-x: hidden; }
img { -webkit-user-drag: none; }
button, a { -webkit-tap-highlight-color: transparent; }

/* level load: fades from black, fails open (pure CSS) */
.load { position: fixed; inset: 0; z-index: 50; background: #000; pointer-events: none; animation: load-out .9s .15s var(--ease-out) forwards; }
@keyframes load-out { to { opacity: 0; visibility: hidden; } }

/* ---------- the room ---------- */
.hero { position: relative; height: 100svh; min-height: 660px; max-height: 1300px; overflow: hidden; isolation: isolate; }
.room { position: absolute; inset: -24px; z-index: -2; background: var(--wall) url("/img/room/room.webp") 50% 62% / cover no-repeat; will-change: transform; }
.dust { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; }

.stage { width: var(--container); height: 100%; margin-inline: auto; display: grid; grid-template-columns: 1.1fr 1fr; gap: var(--s5); align-items: end; }

.seat { height: 100%; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 5svh; }
.david { position: relative; height: min(76svh, 980px); aspect-ratio: 820 / 968; will-change: transform; }
.frames { position: relative; width: 100%; height: 100%; cursor: pointer; }
.frames::after { /* contact shadow on the carpet */
  content: ""; position: absolute; left: 4%; right: 2%; bottom: -2.5%; height: 9%; z-index: -1;
  background: radial-gradient(closest-side, rgba(20,16,14,.55), rgba(20,16,14,0)); }
.f { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; visibility: hidden; image-rendering: auto; }
.f.is-on { visibility: visible; }
.blorp { position: absolute; left: 64%; top: -7%; width: 36%; height: auto; z-index: 1; pointer-events: none;
  opacity: 0; transform: scale(.6) rotate(-4deg); transform-origin: 8% 92%;
  transition: opacity .2s var(--ease-out), transform .2s var(--ease-out); }
.blorp.is-on { opacity: 1; transform: none; transition: opacity .08s linear, transform .22s var(--ease-pop); }

/* the game's interaction prompt: the one primary action */
.prompt {
  position: absolute; left: 63%; bottom: calc(100% + 2.2svh); z-index: 2;
  width: clamp(300px, 26vw, 460px); aspect-ratio: 900 / 181; min-height: 0; padding: 0;
  border: 0; background: url("/img/ui/plate.webp") center / 100% 100% no-repeat; color: var(--cream);
  cursor: pointer; translate: -50% 0;
  animation: bob 2.6s ease-in-out infinite;
  transition: transform .25s var(--ease-pop), filter .25s var(--ease-out), opacity .25s var(--ease-out);
}
.prompt-text { position: absolute; left: 24%; right: 4%; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center;
  font-size: clamp(18px, 1.55vw, 28px); letter-spacing: .02em; white-space: nowrap; }
.prompt:hover { transform: translateY(-4px); filter: brightness(1.12); }
.prompt:active { transform: translateY(1px) scale(.97); transition-duration: 35ms; }
.prompt.is-busy { opacity: .55; cursor: default; }
@keyframes bob { 0%, 100% { margin-top: 0; translate: -50% 0; } 50% { translate: -50% -3px; } }

/* ---------- right wall ---------- */
.side { align-self: center; display: flex; flex-direction: column; align-items: center; gap: var(--s3); padding-block: var(--s5); }
.mark { margin: 0; width: min(720px, 100%); line-height: 0; }
.mark img { width: 100%; height: auto; }
.line { margin: calc(-1 * var(--s2)) 0 0; font-size: clamp(18px, 1.5vw, 30px); color: var(--cream); text-align: center; }

.paper {
  position: relative; width: min(660px, 100%); padding: 13% 9% 9% 14%;
  background: url("/img/ui/paper.webp") center / 100% 100% no-repeat; color: var(--paper-ink);
  display: grid; justify-items: center; gap: var(--s2); text-align: center; rotate: -1.2deg;
}
.paper-head { margin: 0; font: 700 clamp(32px, 2.6vw, 46px)/1 var(--font-display); }
.ca-label { margin: 0 0 calc(-1 * var(--s1)); font-size: 16px; color: #5b5048; }
.paper code { font: clamp(16px, 1vw, 19px)/1.45 "Space Mono", ui-monospace, monospace; max-width: 100%; color: var(--paper-ink); }
.copy {
  min-height: 52px; min-width: 150px; padding: 0 var(--s3); border: 0; color: var(--paper-ink); font-size: clamp(17px, 1.05vw, 20px); cursor: pointer;
  background: url("/img/ui/btn-copy.webp") center / 100% 100% no-repeat;
  transition: transform .25s var(--ease-pop), filter .2s;
}
.buy {
  position: relative; display: flex; align-items: center; justify-content: center; gap: var(--s2);
  width: 100%; min-height: 64px; padding: 0 var(--s4); text-decoration: none; color: #fff; white-space: nowrap;
  font-size: clamp(16px, 1.15vw, 22px); text-shadow: 0 2px 0 rgba(30,50,10,.6);
  background: url("/img/ui/btn-green.webp") center / 100% 100% no-repeat;
  transition: transform .25s var(--ease-pop), filter .2s;
}
.buy img { width: 30px; height: 30px; }
.notes { display: grid; grid-template-columns: repeat(2, clamp(124px, 9vw, 160px)); gap: var(--s4); }
.note {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s1);
  padding: 12%; text-decoration: none; color: var(--paper-ink); font-size: clamp(16px, .95vw, 18px); text-align: center; line-height: 1.15;
  transition: transform .25s var(--ease-pop), filter .2s;
}
.note img { width: 38%; height: auto; }
.chart-name { display: none; }
.note-y { background: url("/img/ui/note-yellow.webp") center / 100% 100% no-repeat; rotate: -3deg; }
.note-b { background: url("/img/ui/note-blue.webp") center / 100% 100% no-repeat; rotate: 2.5deg; }

.copy:hover, .buy:hover, .note:hover { transform: translateY(-3px); filter: brightness(1.06); }
.copy:active, .buy:active, .note:active { transform: translateY(1px) scale(.97); transition-duration: 35ms; }
.is-off, .is-off:hover { filter: grayscale(.85) brightness(.95); transform: none; cursor: not-allowed; opacity: .6; }

/* ---------- LOAD GAME: the camera looks down at the carpet ---------- */
.saves { width: var(--container); margin-inline: auto; padding: var(--s7) 0; display: grid; gap: var(--s6); }
.board {
  justify-self: center; width: min(980px, 100%); padding: var(--s5) var(--s6);
  background: url("/img/ui/panel.webp") center / 100% 100% no-repeat; text-align: center;
}
.board h1, .board h2 { margin: 0 0 var(--s2); font: 700 var(--display)/1 var(--font-display); color: var(--cream); text-transform: uppercase; }
.board p { margin: 0; font-size: var(--body); line-height: 1.45; color: var(--cream); }
.lore { font-size: clamp(18px, 1.4vw, 22px) !important; }
.risk { margin-top: var(--s3) !important; font-size: 16px !important; color: #b9ab93 !important; }

.slots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s4); }
.slot {
  position: relative; display: block; width: 100%; aspect-ratio: 800 / 596; padding: 0; border: 0; cursor: pointer; color: var(--cream);
  background: url("/img/ui/slot.webp") center / 100% 100% no-repeat;
  transition: transform .25s var(--ease-pop), filter .2s;
}
.slot img { position: absolute; left: 6.2%; top: 9%; width: 87.6%; height: 65%; object-fit: cover; }
.slot-n, .slot-c { position: absolute; top: 80%; bottom: 6.9%; display: flex; align-items: center; font-size: clamp(16px, 1.05vw, 19px); white-space: nowrap; }
.slot-n { left: 8%; color: #b9ab93; }
.slot-c { right: 8%; text-transform: uppercase; }
.slot:hover { transform: translateY(-4px); filter: brightness(1.08); }
.slot:active { transform: translateY(1px) scale(.98); transition-duration: 35ms; }

/* viewer: loading a save */
.viewer { width: min(1180px, 100% - 2 * var(--s3)); max-height: 100svh; padding: 3.2% 3.6% 2.4%; border: 0; color: var(--cream);
  background: url("/img/ui/panel.webp") center / 100% 100% no-repeat; overflow: visible; }
.viewer::backdrop { background: rgba(14, 11, 9, .82); }
.viewer[open] { animation: load-in .28s var(--ease-out); }
@keyframes load-in { from { opacity: 0; transform: scale(.97); } }
.viewer figure { margin: 0; display: grid; gap: var(--s2); }
.viewer img { width: 100%; height: auto; max-height: calc(100svh - 220px); object-fit: contain; }
.viewer figcaption { text-align: center; font-size: clamp(18px, 1.6vw, 26px); text-transform: uppercase; }
.viewer-keys { display: flex; justify-content: center; gap: var(--s3); margin-top: var(--s2); }
.key { min-width: 120px; min-height: 48px; border: 0; color: var(--paper-ink); cursor: pointer;
  background: url("/img/ui/btn-copy.webp") center / 100% 100% no-repeat; transition: transform .25s var(--ease-pop); }
.key:hover { transform: translateY(-3px); }
.key:active { transform: translateY(1px) scale(.97); transition-duration: 35ms; }

/* ---------- smaller screens ---------- */
@media (max-width: 1280px) {
  .slots { grid-template-columns: repeat(3, 1fr); }
}
@media (max-height: 820px) and (min-width: 861px) {
  .side { gap: var(--s2); }
  .paper { width: min(560px, 100%); gap: 12px; }
  .mark { width: min(540px, 100%); }
  .notes { grid-template-columns: repeat(2, 112px); }
}
@media (max-width: 860px) {
  :root { --container: calc(100% - 2 * var(--s3)); }
  .hero { height: auto; max-height: none; min-height: 0; background: var(--wall) url("/img/room/wall.webp") 0 0 / 256px 256px; }
  .room { inset: 0 0 auto; height: calc(100svh + 24px); background-image: url("/img/room/room-tall.webp"); background-position: 50% 100%; }
  .stage { display: block; height: auto; }
  .seat { height: 100svh; min-height: 560px; flex-direction: column; justify-content: flex-end; padding-bottom: 6svh; }
  .david { height: min(56svh, 110vw); }
  .prompt { width: min(340px, 86vw); left: 50%; bottom: calc(100% + 16px); }
  .prompt-text { font-size: 19px; }
  .side { display: contents; }
  .mark { position: absolute; top: 4svh; left: 50%; translate: -50% 0; width: min(78vw, 420px); }
  .line { position: absolute; top: calc(4svh + min(78vw, 420px) * .281 + 10px); left: 0; right: 0; margin: 0; padding-inline: var(--s3); font-size: 18px; }
  .paper { margin: var(--s5) auto var(--s4); width: 100%; max-width: 520px; padding: 15% 8% 10% 13%; }
  .notes { justify-content: center; padding-bottom: var(--s6); grid-template-columns: repeat(2, 132px); }
  .saves { padding: var(--s6) 0; gap: var(--s5); }
  .slots { grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
  .board { padding: var(--s4) var(--s4); }
}
@media (max-width: 520px) {
  .slots { grid-template-columns: 1fr; }
  .paper { padding: 64px 36px 44px 48px; }
  .paper-head { font-size: 28px; }
  .buy { min-height: 76px; padding: 10px 28px; gap: var(--s2); font-size: 16px; line-height: 1.25; white-space: normal; text-align: left; }
  .slot-n, .slot-c { font-size: 16px; }
}
@media (max-width: 860px) and (max-height: 700px) {
  .david { height: 50svh; }
}
@media (prefers-reduced-motion: reduce) {
  .prompt { animation: none; }
  .load { display: none; }
}
