/* The Hidden Workshop in 3D (main.js, intro.js). Everything is scoped to the
   stage (the element holding <canvas id="view">) and the opening overlay, so
   it can sit on the homepage beside the illustrated workbench. Colours and
   type come from the page: --night, --pink, --cyan, --green, --amber, --paper,
   --paper-ink, --paper-pink, --display, --body. */
.splat-stage { position: relative; overflow: hidden; background: #000; color: #eee; }
/* On a touch screen, an up or down swipe scrolls the page past the room; a
   sideways drag looks around it. */
.splat-stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }
.splat-stage .sr-only { position: absolute; overflow: hidden; clip-path: inset(50%); width: 1px; height: 1px; }
.splat-stage :focus-visible { outline: 3px solid var(--amber); outline-offset: 4px; }

/* Status line and the camera button. */
.splat-stage #ui {
  position: absolute; left: 50%; top: 16px; z-index: 6; transform: translateX(-50%);
  display: flex; gap: 12px; align-items: center; padding: 8px 14px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px); transition: opacity .6s;
  font: 14px/1.4 var(--body);
  width: max-content; max-width: calc(100% - 24px); box-sizing: border-box;
}
/* A phone's room is a short strip: keep the line to one row along its top. */
@media (max-width: 480px) {
  .splat-stage #ui { top: 8px; gap: 8px; padding: 4px 5px 4px 12px; font-size: 12.5px; }
  .splat-stage #ui button { padding: 4px 10px; }
}
.splat-stage #ui[hidden] { display: none; }
.splat-stage #status { margin: 0; color: #eee; }
.splat-stage #ui button { font: inherit; color: #000; background: #eee; border: 0; border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.splat-stage #ui button[hidden] { display: none; }
.intro-running .splat-stage #ui { opacity: 0; }

/* The camera notice (main.js "Webcam"): a photocopied workshop safety notice,
   with a pen note on it. Shown as a modal dialog before the browser's own
   camera question. */
.sw-notice {
  width: min(31rem, calc(100vw - 2rem)); max-height: calc(100svh - 2rem); overflow: auto;
  padding: 0; border: 0; color: var(--paper-ink, #1d1236);
  background: var(--material-photocopy, none) 17% 29% / 640px repeat, var(--paper, #efe7d4); background-blend-mode: multiply, normal;
  rotate: -.8deg; box-shadow: 6px 6px 0 var(--pink, #ff3ea5);
  font: 400 .95rem/1.45 var(--mono, monospace);
}
.sw-notice::backdrop { background: rgba(11, 4, 32, .72); }
.sw-notice form { padding: 0 1.3rem 1.15rem; }
.sw-notice-bar {
  margin: 0 -1.3rem .9rem; padding: .5rem 1.3rem .35rem; background: var(--paper-ink, #1d1236); color: var(--paper, #efe7d4);
  font: 400 1.7rem/1 var(--display, Impact, sans-serif); letter-spacing: .12em; text-transform: uppercase;
}
.sw-notice h2 { margin: 0; font: 400 clamp(1.7rem, 7vw, 2.3rem)/.95 var(--display, Impact, sans-serif); letter-spacing: -.02em; text-transform: uppercase; }
.sw-notice-ref { margin: .35rem 0 .9rem; font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; opacity: .72; }
.sw-notice ol { display: grid; gap: .45rem; margin: 0; padding-left: 1.5rem; }
.sw-notice-aside { margin: 1rem 0 .1rem; color: var(--paper-pink, #b1005f); font: 400 1.15rem/1.25 "Permanent Marker", cursive; rotate: -2deg; }
.sw-notice-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.1rem; }
.sw-notice button {
  padding: .75rem 1.05rem; border: 2px solid var(--paper-ink, #1d1236); border-radius: 0; cursor: pointer;
  background: transparent; color: var(--paper-ink, #1d1236); font: 700 .95rem/1 var(--mono, monospace);
}
.sw-notice button[value="on"] { background: var(--paper-ink, #1d1236); color: var(--paper, #efe7d4); box-shadow: 3px 3px 0 var(--cyan, #2ee6ff); }
.sw-notice :focus-visible { outline: 3px solid var(--amber, #ffb03b); outline-offset: 3px; }
.sw-notice-small { margin: .85rem 0 0; font-size: .74rem; opacity: .8; }

/* --- The opening ident, as the static homepage's transmission ------------- */
.intro { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; pointer-events: none; }
.intro-dark { position: absolute; inset: 0; background: #100e1b; }
/* The tube face: the same shape and framing as the TV's glass in 3D. */
.intro-screen {
  position: relative; overflow: hidden; background: #020203;
  width: min(calc(100vw - 32px), calc((100vh - 64px) * 1.3016)); aspect-ratio: 1.3016; /* GLASS_ASPECT in main.js */
  box-shadow: 0 0 3rem #2ee6ff0b; will-change: transform;
}
/* Artwork box inside the tube face: matches FRAME in main.js. */
.intro-screen img { position: absolute; left: 3%; top: 4%; width: 94%; height: 92%; object-fit: contain; display: block; }
.ident-plate { mix-blend-mode: screen; }
.ident-noise { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 4; image-rendering: pixelated; }
.ident-roll { position: absolute; inset: 0 0 auto; height: 25%; z-index: 3; background: linear-gradient(transparent, #2ee6ff40, transparent); }
.intro-wait {
  position: absolute; left: 0; right: 0; bottom: 14px; margin: 0; text-align: center;
  color: var(--green); font: 700 1rem/1 var(--body); letter-spacing: .12em; text-transform: uppercase;
  opacity: 0; transition: opacity .4s;
}
.intro.waiting .intro-wait { opacity: .8; }
@media (prefers-reduced-motion: reduce) { .intro-wait { transition: none; } }

/* --- The TV's dial -------------------------------------------------------- */
.splat-stage #tv-ui[hidden] { display: none; }
/* Sits on the TV's upper dial; main.js moves it with the TV every frame. */
.sw-dial {
  --dial-diameter: 40px;
  position: absolute; left: 0; top: 0; z-index: 9; transform: translateY(-50%);
  display: flex; align-items: center; gap: 3px; min-height: 44px; margin: 0; padding: 0;
  border: 0; border-radius: 0; background: transparent; box-shadow: none; cursor: pointer;
}
.sw-dial::before {
  content: ""; width: var(--dial-diameter); aspect-ratio: 1; box-sizing: border-box;
  border: 3px dashed var(--green); border-radius: 50%; filter: drop-shadow(0 1px 1px var(--night));
}
.sw-dial-label {
  color: var(--night); background: var(--pink); padding: .27rem .46rem .27rem .75rem;
  clip-path: polygon(0 50%, .42rem 0, 100% 0, 100% 100%, .42rem 100%);
  font: 700 .9rem/1 var(--body); letter-spacing: .07em; text-transform: uppercase;
}
.sw-dial:hover .sw-dial-label, .sw-dial:focus-visible .sw-dial-label { background: var(--amber); }
.sw-dial:active .sw-dial-label { transform: translateX(-2px); }
@media (forced-colors: active) { .sw-dial-label { border: 2px solid ButtonText; clip-path: none; } }

/* --- Paper tags on things in the room ------------------------------------- */
/* As on the static homepage's workshop picture; main.js pins each one to its
   object every frame and shows it while the object is poked. */
.splat-stage #room-links { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.splat-stage #room-links[hidden] { display: none; }
.sw-tag {
  position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; pointer-events: auto;
  padding: .32rem .55rem .22rem; white-space: nowrap;
  background: linear-gradient(#f4ecd978, #f4ecd978), url("../textures/photocopy-stock.webp") 61% 37% / 640px repeat, var(--paper);
  color: var(--paper-ink); border: 1px solid var(--paper-ink); box-shadow: 2px 2px 0 var(--paper-ink);
  font: 1rem/1.25 var(--display); text-decoration: none;
  transition: opacity .2s;
}
.sw-tag::before { content: "+"; margin-right: .35em; color: var(--paper-pink); }
.sw-tag:hover, .sw-tag.hot, .sw-tag:focus-visible { background: var(--cyan); color: var(--night); }
.sw-tag:hover::before, .sw-tag.hot::before, .sw-tag:focus-visible::before { color: inherit; }
.sw-tag.out, #room-links[data-mode="poke"] .sw-tag:not(.hot) { opacity: 0; pointer-events: none; }
.sw-tag:focus-visible { opacity: 1; outline: 2px solid var(--pink); outline-offset: 2px; }
@media (max-width: 760px) { .sw-tag { font-size: .77rem; } }
@media (prefers-reduced-motion: reduce) { .sw-tag { transition: none; } }

/* Developer readout (?tune=1&debug=1). */
.splat-stage #debug { position: absolute; top: 12px; left: 12px; z-index: 7; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.splat-stage #debug[hidden] { display: none; }
.splat-stage #cam { width: 200px; transform: scaleX(-1); border-radius: 6px; opacity: .85; }
.splat-stage #readout { margin: 0; padding: 8px 10px; border-radius: 6px; background: rgba(0, 0, 0, .6); color: #eee; font: 12px/1.35 ui-monospace, monospace; }

/* Developer tuning panel (?tune=1, then T). main.js appends it to <body>. */
#tuner { position: fixed; top: 12px; right: 12px; z-index: 60; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 8px; background: rgba(0, 0, 0, .6); color: #eee; font: 12px/1.3 system-ui, sans-serif; }
#tuner[hidden] { display: none; }
#tuner label { display: flex; flex-direction: column; gap: 2px; }
#tuner input, #tuner select { width: 180px; }
