/* The small things on top of the 3D room are paper: a sticky note left on the door,
   the "Press E" note, paper tags. The panel that opens on E is a plain dark sheet. */
:root {
  color-scheme: light;
  --ground: #231c1f;        /* the dark around the room */
  --chalk: #efe6d6;         /* text sitting directly on the dark */
  --chalk-dim: #a89e93;
  --paper: #f3ead2;         /* paper tags */
  --margin: #cf5f52;        /* red-pen underline */
  --ink: #1f2b4d;           /* blue-black ballpoint */
  --note: #ffe36a;          /* sticky note */
  --note-edge: #e9c843;
  --marker: #ff9d6c;        /* highlighter stroke */
  --tape: rgba(238, 226, 192, .8);
  --font-hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --font-type: "Courier Prime", "Courier New", Courier, monospace;
  --font-sans: "Libre Franklin", "Segoe UI", Helvetica, Arial, sans-serif;
  --panel: #2b2527;         /* the dark panel that opens on E */
  --panel-line: #453c3f;
}
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--chalk);
  font-family: var(--font-type);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }

button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.topbar :focus-visible { outline-color: var(--chalk); }

/* ---- top bar: name in chalk, two paper tags ---- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  pointer-events: none;
  z-index: 2;                                     /* the shortcuts stay clickable over an open note or page */
}
.topbar > * { pointer-events: auto; }
.brand { font-family: var(--font-hand); font-weight: 700; font-size: 30px; line-height: 1; }
.shortcuts { display: flex; gap: 10px; }
.tag {
  background: var(--paper); color: var(--ink); border: 0; border-radius: 2px;
  padding: 5px 12px 4px; font-size: 13px; font-weight: 700;
  box-shadow: 1px 2px 0 rgba(0, 0, 0, .35);
  rotate: -1.5deg;
}
.tag + .tag { rotate: 1deg; }
.tag:hover { background: var(--note); }

.hint {
  position: fixed; left: 16px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  font-size: 12px; color: var(--chalk-dim);
}
kbd {
  font-family: var(--font-type); font-size: .85em; font-weight: 700;
  border: 1px solid currentColor; border-radius: 3px; padding: 0 4px; margin-right: 2px;
}

/* ---- "Press E" prompt: a small sticky note ---- */
.prompt {
  position: fixed; left: 50%; bottom: calc(52px + env(safe-area-inset-bottom, 0px)); translate: -50% 0;
  max-width: calc(100% - 32px);
  background: var(--note); color: var(--ink); border: 0; border-bottom: 3px solid var(--note-edge); border-radius: 1px;
  padding: 6px 18px 4px; font-family: var(--font-hand); font-size: 24px; font-weight: 600; white-space: nowrap;
  box-shadow: 2px 5px 10px rgba(0, 0, 0, .45);
  rotate: -1deg;
}
.prompt kbd { font-size: 15px; vertical-align: 2px; }
.prompt b { font-weight: 700; background: linear-gradient(transparent 55%, var(--marker) 55%, var(--marker) 92%, transparent 92%); }

.veil {
  position: fixed; inset: 0; display: grid; place-items: center;
  padding: 16px; background: rgba(20, 15, 17, .5);
}

/* ---- welcome: the note left on the door ---- */
.note {
  position: relative;
  width: min(440px, 100%);
  background: var(--note); color: var(--ink);
  border-bottom: 4px solid var(--note-edge);
  padding: 34px 28px 24px;
  box-shadow: 4px 12px 26px rgba(0, 0, 0, .5);
  rotate: -1.6deg;
  font-family: var(--font-hand); font-size: 25px; line-height: 1.25;
  display: flex; flex-direction: column; gap: 12px;
}
.note::before {                                   /* strip of masking tape */
  content: ""; position: absolute; top: -13px; left: 50%; translate: -50% 0; rotate: 2.5deg;
  width: 120px; height: 28px; background: var(--tape); box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.note h1 { margin: 0; font-size: 40px; font-weight: 700; line-height: 1.05; text-wrap: balance; }
.note p { margin: 0; }
.linklike { background: none; border: 0; padding: 0; font-weight: 700; text-decoration: underline wavy var(--margin); text-underline-offset: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: 6px; }
.inked {                                          /* hand-drawn box */
  background: none; border: 2.5px solid var(--ink);
  border-radius: 255px 14px 225px 14px / 14px 225px 14px 255px;
  padding: 2px 20px 0; font-size: 27px; font-weight: 700;
}
.inked:hover { background: var(--marker); }
.keys { font-family: var(--font-type); font-size: 12px; line-height: 1.4; flex: 1 1 160px; min-width: 0; }

/* ---- panels: a plain dark sheet, the one part of the interface that is not paper ---- */
.page {
  --pad: 28px;
  width: min(560px, 100%); max-height: min(80vh, 660px); overflow: hidden;    /* the heading stays put; only .page-body scrolls */
  color-scheme: dark;
  color: var(--chalk);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-top: 3px solid var(--note);
  border-radius: 4px;
  padding: 26px var(--pad) 0;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
  font-family: var(--font-sans); font-size: 15px; line-height: 1.55;
  display: flex; flex-direction: column; gap: 18px;
}
.page :focus-visible { outline-color: var(--note); }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.where { display: block; font-family: var(--font-type); font-size: 12px; color: var(--chalk-dim); margin-bottom: 4px; }
.page h2 { margin: 0; font-size: 24px; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; text-wrap: balance; }
.close {
  background: none; border: 1px solid var(--panel-line); border-radius: 3px; padding: 4px 10px;
  font-family: var(--font-type); font-size: 12px; color: var(--chalk-dim); flex: none;
}
.close:hover { color: var(--chalk); border-color: var(--chalk-dim); }
.page-body {
  display: flex; flex-direction: column; gap: 14px;
  min-height: 0; overflow-y: auto;
  margin-right: calc(-1 * var(--pad)); padding: 0 var(--pad) 28px 0;          /* scrollbar sits on the panel's edge */
}
.page-body > * { flex: none; }
.page p { margin: 0; max-width: 62ch; }
.stub { align-self: flex-start; font-family: var(--font-type); font-size: 12px; color: var(--note); }
.page a { color: inherit; text-underline-offset: 3px; }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rows li { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; padding: 12px 0; border-top: 1px solid var(--panel-line); }
.rows li > * { min-width: 0; }
.rows strong { font-weight: 600; }
.rows span { color: var(--chalk-dim); font-size: 14px; }
.rows .meta { font-family: var(--font-type); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; align-self: center; }
.rows .sub { grid-column: 1 / -1; }
.rows li.film { grid-template-columns: 44px 1fr auto; align-items: center; padding: 8px 0; }
.poster { width: 44px; height: 66px; object-fit: cover; border-radius: 2px; background: var(--panel-line); }
.rows .copyable { user-select: all; color: var(--chalk); font-size: 13px; overflow-wrap: anywhere; }

/* ---- prints: photos laid down on either side of the open panel ---- */
.photo-link { background: none; border: 0; padding: 0; font: inherit; color: var(--note); text-decoration: underline; text-underline-offset: 3px; }
.photo-link:hover { color: var(--chalk); }
.prints { position: fixed; inset: 0; pointer-events: none; }
.prints { --w: min(17vw, 230px, 23vh); --h: calc(var(--w) * 1.25 + 28px); --gap: 72px; }   /* print size, and the space between two stacked prints */
.print {
  position: absolute;                              /* the stack on each side is centred on the screen */
  top: calc(50% + (var(--row, 0) - var(--rows, 1) / 2) * (var(--h) + var(--gap)) + var(--gap) / 2);
  width: var(--w); margin: 0;
  background: var(--paper); padding: 10px 10px 8px;
  box-shadow: 3px 10px 22px rgba(0, 0, 0, .55);
  rotate: var(--tilt, -4deg);
  pointer-events: auto;
}
.print.left { right: calc(50% + 356px); }
.print.right { left: calc(50% + 356px); }
.print img, .print .missing { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: var(--panel-line); }
.print .missing { display: grid; place-items: center; padding: 10px; box-sizing: border-box; font-size: 12px; color: var(--chalk-dim); text-align: center; overflow-wrap: anywhere; }
.print figcaption { min-height: 30px; padding-top: 4px; font-family: var(--font-hand); font-size: 22px; line-height: 1.1; color: var(--ink); text-align: center; }
@media (max-width: 1100px) {                       /* no room beside the panel: lay them over it, tap to put away */
  .prints { pointer-events: auto; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 18px; padding: 16px; background: rgba(20, 15, 17, .8); overflow: auto; }
  .prints { gap: 30px 26px; }
  .print, .print.left, .print.right { position: static; width: min(40vw, 220px); }
}

@media (max-width: 560px) {
  .hint { display: none; }
  .prompt { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); white-space: normal; }
  .brand { font-size: 26px; }
  .note { padding: 30px 20px 20px; font-size: 23px; }
  .note h1 { font-size: 34px; }
  .page { --pad: 18px; padding-top: 20px; }
  .page h2 { font-size: 21px; }
}
@media (prefers-reduced-motion: no-preference) {
  .prompt, .note, .page, .print { animation: drop .18s ease-out; }
  @keyframes drop { from { opacity: .3; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}
