/* Craft world: paper, string, cardboard, warm light. Never shared with surface.css. */
:root {
  --paper: #f3f2f2;
  --ink: #201e1d;
  --accent: #d1591a;
  --cardboard: #cda878;
  --cardboard-dark: #a9835a;
  --kraft: #b98e5f;
  --floor: #ece7dd;
  --string: #3a2f28;
  --bad: #b3261e;
  --wood: #2a2522;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --chrome-h: 52px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--wood); color: var(--ink); font-family: var(--sans); }
body { overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; box-shadow: 0 0 0 6px var(--paper); }

/* Top chrome */
.chrome { position: fixed; inset: 0 0 auto 0; height: var(--chrome-h); display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--ink); color: var(--paper); z-index: 20; }
.chrome__mark { font-family: var(--serif); font-size: 24px; letter-spacing: .01em; margin-right: auto; white-space: nowrap; }
.chrome__mark small { font-family: var(--sans); font-size: 11px; opacity: .7; margin-left: 8px; letter-spacing: .06em; text-transform: uppercase; }
.chrome button { background: transparent; border: 1px solid rgba(243,242,242,.45); color: var(--paper); border-radius: 18px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.chrome button:hover { background: rgba(243,242,242,.14); }
.chrome button[hidden] { display: none; }
.chrome .short { display: none; }

/* Camera and stage */
.camera { position: fixed; inset: var(--chrome-h) 0 0 0; overflow: hidden; background: radial-gradient(ellipse at 50% 10%, #3b322c, var(--wood) 70%); }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.stage > * { position: absolute; }

.back-wall { left: 0; top: 0; background:
  repeating-linear-gradient(90deg, rgba(255,255,255,.07) 0 6px, rgba(0,0,0,.05) 6px 9px),
  linear-gradient(var(--cardboard), var(--cardboard-dark)); box-shadow: inset 0 -14px 24px rgba(60,35,10,.28); }
.floor { left: 0; background:
  repeating-linear-gradient(0deg, rgba(0,0,0,.035) 0 1px, transparent 1px 38px),
  linear-gradient(var(--floor), #e2dccf); box-shadow: inset 0 18px 30px rgba(90,60,20,.18); }
.wall { background:
  repeating-linear-gradient(0deg, rgba(255,255,255,.08) 0 5px, rgba(0,0,0,.06) 5px 7px),
  linear-gradient(90deg, var(--cardboard-dark), var(--cardboard)); box-shadow: inset 0 0 22px rgba(60,35,10,.3); }
.wall--right { background:
  repeating-linear-gradient(0deg, rgba(255,255,255,.08) 0 5px, rgba(0,0,0,.06) 5px 7px),
  linear-gradient(270deg, var(--cardboard-dark), var(--cardboard)); }
.dome { background: radial-gradient(ellipse at 50% 100%, #fff3dc, #f0cf95 55%, var(--cardboard-dark)); border-radius: 50% 50% 0 0 / 100% 100% 0 0; box-shadow: 0 8px 22px rgba(255,214,150,.45); }
.column { width: 16px; background: linear-gradient(90deg, #d9d3c7, var(--paper) 45%, #cfc8ba); border-radius: 3px; box-shadow: 2px 0 6px rgba(0,0,0,.18); }
.column::before, .column::after { content: ""; position: absolute; left: -4px; right: -4px; height: 8px; background: var(--paper); border-radius: 2px; box-shadow: 0 2px 4px rgba(0,0,0,.18); }
.column::before { top: 0; } .column::after { bottom: 0; }
.warm-light { inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 0%, rgba(255,226,170,.38), transparent 62%); mix-blend-mode: screen; }

/* Door */
.door { background: var(--accent); border-radius: 10px 10px 0 0; padding: 8px; box-shadow: 0 6px 0 rgba(0,0,0,.2), inset 0 0 0 3px rgba(32,30,29,.35); perspective: 600px; }
.door__leaf { position: absolute; inset: 8px; background: linear-gradient(#e7b78a, #d49e6e); border-radius: 6px 6px 0 0; transform-origin: left center; box-shadow: inset 0 0 0 3px rgba(32,30,29,.25); }
.door__leaf::before { content: ""; position: absolute; inset: 14% 18%; border: 3px solid rgba(32,30,29,.28); border-radius: 4px; }
.door__knob { position: absolute; right: 12%; top: 52%; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); }
.door.is-open .door__leaf { transform: rotateY(-72deg); }
.door__lock { position: absolute; left: 50%; top: -14px; transform: translateX(-50%); padding: 2px 10px; border-radius: 10px; background: var(--ink); color: var(--paper); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.door__lock::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #e0452b; }
.door.is-open .door__lock::before { background: #4caf50; }
.control-panel { width: 54px; height: 78px; background: var(--ink); border-radius: 6px; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.control-panel::before { content: ""; position: absolute; left: 10px; top: 10px; width: 34px; height: 22px; background: #5b6b57; border-radius: 3px; }
.control-panel::after { content: ""; position: absolute; left: 12px; bottom: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 16px 0 0 #8a8581; animation: blink 1.1s steps(2) infinite; }

/* Consoles */
.console { background: linear-gradient(var(--kraft), var(--cardboard-dark)); border: 0; border-radius: 8px; box-shadow: 0 7px 0 rgba(60,35,10,.4), 0 14px 20px rgba(0,0,0,.18); cursor: pointer; padding: 10px; text-align: left; }
.console:hover, .console.is-followed { transform: translateY(-3px); }
.console__screen { display: block; height: 34px; border-radius: 4px; background: #232830; box-shadow: inset 0 0 0 3px rgba(243,242,242,.5); position: relative; overflow: hidden; }
.console__screen::after { content: ""; position: absolute; left: 8px; right: 36px; top: 11px; height: 4px; background: rgba(243,242,242,.45); box-shadow: 0 9px 0 rgba(243,242,242,.25); border-radius: 2px; }
.console__label { display: block; margin-top: 8px; padding: 3px 8px; background: var(--paper); border-radius: 3px; font-size: 13px; line-height: 1.2; color: var(--ink); box-shadow: 0 1px 0 rgba(0,0,0,.25); transform: rotate(-.8deg); }
.console--client .console__screen { box-shadow: inset 0 0 0 3px var(--accent); }

/* Units: matchbox boxes with craft-paper labels */
.unit { background: linear-gradient(var(--kraft), #a67c4e); border: 0; border-radius: 5px; box-shadow: 0 5px 0 rgba(60,35,10,.45); cursor: pointer; padding: 5px; text-align: center; display: flex; flex-direction: column; justify-content: space-between; }
.unit__drawer { display: block; height: 5px; margin: 0 auto; width: 38%; background: rgba(32,30,29,.55); border-radius: 3px; }
.unit__label { display: block; background: var(--paper); border-radius: 2px; font-size: 12px; line-height: 1.1; padding: 3px 2px; color: var(--ink); transform: rotate(.7deg); }
.unit--planned { opacity: .82; outline: 2px dashed rgba(32,30,29,.5); outline-offset: -3px; }
.unit--error { box-shadow: 0 5px 0 rgba(179,38,30,.55); }
.unit.is-followed, .unit:hover { transform: translateY(-2px); }
.badge { background: var(--paper); border-radius: 15px; text-align: center; font-size: 12px; line-height: 30px; box-shadow: 0 3px 0 rgba(0,0,0,.25); }

/* Strings */
.strings { left: 0; top: 0; pointer-events: none; overflow: visible; }
.string { fill: none; stroke: var(--string); stroke-width: 3; stroke-linecap: round; }
.string--planned { stroke-dasharray: 1 7; stroke-width: 4; opacity: .8; }
.string--error { stroke: var(--bad); }
.string-g.is-followed .string { stroke-width: 6; stroke: var(--accent); }
.string-g.is-followed .string--error { stroke: var(--bad); }
.string { animation: jitter 480ms steps(2) infinite; }
.tag rect { fill: var(--paper); stroke: var(--ink); stroke-width: 1; }
.tag text { font: 11px var(--sans); fill: var(--ink); }
.tag--error rect { stroke: var(--bad); }
.tag--error text { fill: var(--bad); }

/* Explorer: a doll, to scale with the room */
.doll { width: 22px; height: 56px; }
.doll::before { content: ""; position: absolute; left: 4px; top: 0; width: 14px; height: 14px; border-radius: 50%; background: #f2d3b3; box-shadow: 0 -3px 0 var(--ink) inset; }
.doll::after { content: ""; position: absolute; left: 0; top: 15px; width: 22px; height: 38px; background: var(--accent); border-radius: 11px 11px 3px 3px; box-shadow: 0 3px 0 rgba(0,0,0,.25); }

/* Stop-motion pop-in: stepped so it reads as frames, not a smooth fade */
.pop { animation: pop 520ms steps(4, end) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) rotate(-1.5deg); } to { opacity: 1; transform: none; } }
@keyframes jitter { 0% { transform: translate(0, 0); } 100% { transform: translate(.7px, -.6px); } }
@keyframes blink { 50% { opacity: .25; } }

/* Door panel (screen-space overlay on the door view) */
.door-panel { position: fixed; left: 50%; top: 50%; transform: translateX(-50%); width: min(600px, calc(100% - 24px)); max-height: calc(50% - 12px); overflow: auto; background: var(--paper); color: var(--ink); border-radius: 12px; padding: 18px 20px; box-shadow: 0 10px 0 rgba(0,0,0,.22), 0 18px 40px rgba(0,0,0,.35); z-index: 10; }
.door-panel[hidden] { display: none; }
.door-panel h1 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 0 0 4px; }
.door-panel .lore { margin: 0 0 12px; font-size: 16px; line-height: 1.35; }
.picker { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.picker button { width: 100%; text-align: left; background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 10px 12px; cursor: pointer; display: block; }
.picker button:hover, .picker button:focus-visible { background: #fff3ea; border-color: var(--accent); }
.picker button[disabled] { opacity: .5; cursor: not-allowed; }
.picker strong { display: block; font-size: 15px; }
.picker span { font-size: 13px; opacity: .8; }
.why h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; margin: 4px 0 6px; }
.why ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.4; }
.why p { margin: 0; font-size: 14px; opacity: .75; }

/* Why this room changed, in the hall */
.why-sheet { position: fixed; right: 12px; top: calc(var(--chrome-h) + 10px); width: min(360px, calc(100% - 24px)); background: var(--paper); border-radius: 10px; padding: 14px 16px; box-shadow: 0 8px 0 rgba(0,0,0,.2), 0 14px 30px rgba(0,0,0,.3); z-index: 10; }
.why-sheet[hidden] { display: none; }

@media (max-width: 640px) {
  .chrome { padding: 0 10px; gap: 8px; }
  .chrome__mark { font-size: 20px; }
  .chrome__mark small { display: none; }
  .chrome .long { display: none; }
  .chrome .short { display: inline; }
  .console__label { font-size: 12px; }
  .unit__label { font-size: 10px; }
  .door-panel { padding: 14px; top: 42%; max-height: calc(58% - 8px); }
  .door-panel h1 { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .pop, .string, .control-panel::after { animation: none !important; }
  .stage, .console, .unit, .door__leaf { transition: none !important; }
}
