/* SPDX-License-Identifier: MIT OR Apache-2.0 */
/* Copyright (c) 2026 R.F. van Ee */

:root {
  color-scheme: dark;
  --bg: #17171b; --panel: #222228; --line: #34343c; --text: #ddd; --muted: #8a8a95; --accent: #9fd;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, sans-serif;
  margin: 0; min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
}
header {
  width: 100%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; border-bottom: 1px solid var(--line); background: #1c1c21;
  position: sticky; top: 0; z-index: 20;
}
header h1 { font-size: 15px; font-weight: 600; margin: 0 8px 0 0; color: var(--accent); }
header .spacer { flex: 1; }
#driveStatus, #speedReadout { font: 12px/1.4 ui-monospace, monospace; color: var(--muted); }
#volume { width: 90px; }
button, select, input[type=text], textarea {
  background: #2b2b33; color: #eee; border: 1px solid #45454f; border-radius: 5px;
  padding: 5px 10px; font: inherit;
}
button, select { cursor: pointer; }
button:hover { background: #34343e; }
button:disabled { opacity: .4; cursor: default; }
button.on { border-color: #6c6; color: #bfb; }
button.icon { padding: 4px 7px; line-height: 0; display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 30px; }
input[type=text] { width: 100%; }
textarea { width: 100%; font: 12px/1.4 ui-monospace, monospace; resize: vertical; }
code { font: 12px ui-monospace, monospace; color: #cde; }

/* ---- the stage ---- */
#viewport { width: 100%; overflow: hidden; display: flex; justify-content: center; padding: 12px 16px 6px; }
/* the stage has the aspect ratio of the desk photo in use */
#stage { --aspect: calc(2320 / 1440); }
#stage.flat { --aspect: calc(2400 / 1792); }
#stage {
  position: relative; outline: none; overflow: hidden;
  width: min(100%, calc((100vh - 110px) * var(--aspect)), 1856px);
  aspect-ratio: var(--aspect);
  border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.55);
  background: #0c0c0e;
}
#stage:focus-visible { box-shadow: 0 0 0 2px #6af, 0 10px 40px rgba(0,0,0,.55); }
#stage.flat .crt-only, #stage.crt .flat-only { display: none !important; }
#scene {
  position: absolute; inset: 0; transform-origin: 0 0;
  transition: transform .7s cubic-bezier(.3,.7,.2,1);
}
#scene > img.photo { position: absolute; inset: 0; width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
/* glass: the mask box measured from the photo, see assets/glass-mask.png */
#scene > #crt { position: absolute; left: 9.0948%; top: 12.6389%; width: 37.8448%; height: 46.7361%; }
#crt { display: block; cursor: text; }
#spill {
  position: absolute; left: 1%; top: 3%; width: 54%; height: 66%;
  pointer-events: none; mix-blend-mode: screen; opacity: 0;
  background: radial-gradient(closest-side, rgba(var(--spill, 0,0,0), .55), rgba(var(--spill, 0,0,0), .18) 70%, transparent 100%);
}
.led { position: absolute; pointer-events: none; transform: translate(-50%, -50%); }
.led .off, .led .core, .led .halo { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 50%; }
.led .off { mix-blend-mode: multiply; }
.led .core, .led .halo { mix-blend-mode: screen; opacity: 0; }
#ledC64 { left: 68.922%; top: 77.708%; width: 1.25%; height: 0.9%; }
#ledC64 .off { width: 100%; height: 100%; background: radial-gradient(closest-side, #2c2020 30%, #6a5a5a 80%, transparent); }
#ledC64 .core { width: 120%; height: 130%; background: radial-gradient(closest-side, #fff3ee 0%, #ff5a4a 35%, rgba(255,40,30,.6) 65%, transparent); }
#ledC64 .halo { width: 600%; height: 1100%; background: radial-gradient(closest-side, rgba(255,60,40,.42), rgba(255,40,30,.12) 45%, transparent 75%); }
#ledPower { left: 57.629%; top: 71.424%; width: 0.82%; height: 1.32%; }
#ledPower .off { width: 100%; height: 100%; background: radial-gradient(closest-side, #1a2a1a 40%, #3d4a3d 85%, transparent); }
#ledPower .core { width: 110%; height: 110%; background: radial-gradient(closest-side, #f4fff0 0%, #5dff60 35%, rgba(40,230,60,.55) 70%, transparent); }
#ledPower .halo { width: 700%; height: 700%; background: radial-gradient(closest-side, rgba(70,255,90,.35), rgba(40,220,60,.10) 45%, transparent 75%); }
#ledAct { left: 63.060%; top: 71.354%; width: 0.62%; height: 1.0%; }
#ledAct .off { width: 100%; height: 100%; background: radial-gradient(closest-side, #241414 45%, #3a2a2a 85%, transparent); }
#ledAct .core { width: 120%; height: 120%; background: radial-gradient(closest-side, #fff0ea 0%, #ff4030 38%, rgba(255,30,20,.55) 70%, transparent); }
#ledAct .halo { width: 900%; height: 900%; background: radial-gradient(closest-side, rgba(255,50,30,.40), rgba(255,30,20,.10) 45%, transparent 75%); }
.hotspot { position: absolute; cursor: pointer; border-radius: 6px; }
.hotspot:hover { box-shadow: inset 0 0 0 2px rgba(120,190,255,.55); }
/* the Commodore 2002's power LED: a small red rectangle */
#ledMonitor { left: 47.87%; top: 68.32%; width: 1.78%; height: 0.59%; }
#ledMonitor .off { width: 100%; height: 100%; border-radius: 1px; background: linear-gradient(#5a3c36, #3a2622); }
#ledMonitor .core { width: 100%; height: 100%; border-radius: 1px; background: linear-gradient(#ff8a70, #ff3020 60%, #d01a10); }
#ledMonitor .halo { width: 260%; height: 900%; background: radial-gradient(closest-side, rgba(255,60,40,.38), rgba(255,40,30,.10) 50%, transparent 78%); }

#hotDrive { left: 59.3%; top: 63.4%; width: 15.6%; height: 10.6%; }
#hotDisks { left: 78.0%; top: 75.6%; width: 19.4%; height: 12.8%; }
#hotControls { left: 6.36%; top: 69.9%; width: 31.4%; height: 5.2%; }
#hotMonitorPower { left: 45.8%; top: 70.05%; width: 3.93%; height: 2.26%; }

/* the add-on 16x2 LCD on the 1541, and its 4x enlargement on hover */
#driveLcd, #driveLcdZoom { position: absolute; border-radius: 2px; image-rendering: auto; }
#driveLcd {
  left: 76.2%; top: 69.88%; width: 5.0%; height: 1.75%; z-index: 2; cursor: zoom-in;
  box-shadow: 0 0 0 1px #1b1b1d, 0 0 0 2px #3a3a3e, 0 1px 3px rgba(0,0,0,.5);
}
#driveLcdZoom {
  left: 68.7%; top: 62.1%; width: 20%; height: 7%; z-index: 3; pointer-events: none;
  box-shadow: 0 0 0 3px #1b1b1d, 0 0 0 5px #3a3a3e, 0 8px 24px rgba(0,0,0,.6);
  opacity: 0; transform: scale(.9); transform-origin: 50% 100%; transition: opacity .15s, transform .15s;
}
#driveLcd:hover ~ #driveLcdZoom { opacity: 1; transform: none; }

/* the controls behind the 2002's door */
#monitorPanel {
  position: absolute; left: 4.5%; bottom: 30.6%; z-index: 4;
  display: flex; align-items: flex-end; gap: clamp(6px, 1vw, 14px);
  padding: 10px 34px 8px 14px; border-radius: 6px;
  background: linear-gradient(#d9d1bf, #c6bda9); color: #3a352c;
  box-shadow: 0 0 0 1px #8f8776, 0 10px 30px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.6);
  font: 600 clamp(8px, .75vw, 11px)/1.15 system-ui, sans-serif; letter-spacing: .02em;
}
#monitorPanel .knobs { display: flex; gap: clamp(6px, 1vw, 14px); align-items: flex-start; }
#monitorPanelClose { position: absolute; top: 4px; right: 4px; min-width: 24px; min-height: 22px; padding: 0 4px; background: none; border: none; color: #4a443a; font-size: 16px; }
.knob { display: flex; flex-direction: column; align-items: center; gap: 5px; width: clamp(44px, 4.4vw, 70px); text-align: center; }
.knob .dial {
  width: clamp(26px, 2.6vw, 40px); aspect-ratio: 1; border-radius: 50%; outline: none; cursor: grab; touch-action: none;
  background: radial-gradient(circle at 35% 30%, #5a564f, #23211e 70%); box-shadow: 0 2px 3px rgba(0,0,0,.45), inset 0 -2px 3px rgba(0,0,0,.5);
}
.knob .dial:focus-visible { box-shadow: 0 0 0 2px #6af, 0 2px 3px rgba(0,0,0,.45); }
.knob .cap { width: 100%; height: 100%; border-radius: 50%; position: relative; }
.knob .mark { position: absolute; left: 50%; top: 9%; width: 2px; height: 32%; margin-left: -1px; border-radius: 1px; background: #e8e2d2; }
.knob .caption { text-transform: uppercase; font-size: .85em; }
.switch-box { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-left: 4px; }
.comp-sep { width: clamp(30px, 3vw, 44px); height: clamp(14px, 1.3vw, 20px); padding: 2px; border-radius: 3px; background: #2a2723; border: 1px solid #111; position: relative; }
.comp-sep .lever { position: absolute; top: 2px; bottom: 2px; left: 2px; width: 45%; border-radius: 2px; background: linear-gradient(#e9e3d4, #b9b2a2); transition: left .12s; }
.comp-sep.sep .lever { left: 53%; }
.switch-labels { display: flex; gap: 8px; font-size: .8em; }

/* ---- the flat-panel photo: positions measured on assets/setup-flat.jpg ---- */
#stage.flat #scene > #crt { left: 8.17%; top: 18.0%; width: 41.71%; height: 42.35%; }
#stage.flat #spill { left: 2%; top: 10%; width: 54%; height: 58%; }
#stage.flat #ledC64 { left: 68.33%; top: 78.07%; }
#stage.flat #ledPower { left: 57.36%; top: 72.99%; width: 0.72%; height: 0.96%; }
#stage.flat #ledAct { left: 62.63%; top: 72.98%; width: 0.52%; height: 0.70%; }
#stage.flat #hotDrive { left: 58.83%; top: 66.69%; width: 14.92%; height: 8.37%; }
#stage.flat #hotDisks { left: 77.5%; top: 77.0%; width: 19.0%; height: 9.5%; }
#stage.flat #driveLcd { left: 75.33%; top: 72.12%; width: 4.85%; height: 1.40%; }
#stage.flat #driveLcdZoom { left: 68.05%; top: 65.7%; width: 19.4%; height: 5.6%; }

.overlay-btn {
  position: absolute; top: 10px; right: 10px; z-index: 6;
  width: 38px; height: 38px; padding: 0; border-radius: 50%;
  background: rgba(20,20,26,.55); border: 1px solid rgba(255,255,255,.18); color: #fff;
  display: flex; align-items: center; justify-content: center;
  opacity: .55; transition: opacity .2s, background .2s;
}
#stage:hover .overlay-btn, .overlay-btn:focus-visible { opacity: 1; }
.overlay-btn:hover { background: rgba(30,30,40,.8); }
#dropHint {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(20,40,70,.55); color: #fff; font-size: 20px; pointer-events: none; z-index: 5;
}
#stage.dragging #dropHint { display: flex; }
#message {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 7;
  background: rgba(10,10,14,.85); color: #eee; padding: 7px 14px; border-radius: 6px;
  font-size: 13px; opacity: 0; transition: opacity .3s; pointer-events: none; max-width: 80%; text-align: center;
}
#message.show { opacity: 1; }

/* ---- panels ---- */
main { width: min(100%, 1100px); padding: 6px 16px 40px; display: grid; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
.panel h2, dialog h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 6px 0; }
.hint { color: var(--muted); font-size: 12px; }
a { color: #7cf; }

/* ---- settings dialog ---- */
dialog {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: #1f1f25; color: var(--text); border: 1px solid #3a3a44; border-radius: 10px;
  padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(0,0,0,.5); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 4px; margin: 0; }
.dlg-head h2 { margin: 0; font-size: 14px; color: #ddd; }
.tabs { display: flex; gap: 2px; padding: 4px 12px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 8px 12px; }
.tabs button[aria-selected=true] { color: #fff; border-bottom-color: var(--accent); }
dialog section { padding: 14px 18px 18px; display: grid; gap: 12px; }
dialog h3 { margin: 6px 0 0; font-size: 12px; color: #bbb; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.field { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 10px; }
.field.check { grid-template-columns: auto 1fr; }
.field select { width: 100%; }
.check { display: inline-flex; gap: 8px; align-items: center; }
.sliders { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 18px; }
.sliders label { display: grid; grid-template-columns: 100px 1fr 40px; align-items: center; gap: 8px; font-size: 12px; color: #bbb; }
.sliders output { font: 11px ui-monospace, monospace; color: var(--muted); text-align: right; }
@media (max-width: 600px) {
  .field { grid-template-columns: 1fr; gap: 4px; }
  header h1 { width: 100%; }
}

/* ---- first-run ROM dialog ---- */
#welcome { max-width: 640px; }
#wzRows { display: grid; gap: 0; }
button.primary { background: #2f6f4f; border-color: #3f8f66; color: #fff; }
.hint.bad { color: #e99; }

/* ---- ROMs ---- */
.wz-choices { display: flex; gap: 10px; flex-wrap: wrap; }
.wz-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px solid #2c2c34; }
.wz-row .id, .rom-entry .chip { font: 12px ui-monospace, monospace; color: #9c9; }
.wz-row .id.bad, .rom-entry .chip.unknown { color: #e99; }
#romManager { display: grid; gap: 12px; }
.rom-card { border: 1px solid #3a3a44; border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.rom-card h3 { margin: 0; }
.rom-list { display: grid; gap: 2px; }
.rom-entry { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.rom-entry label { display: flex; flex-direction: column; cursor: pointer; }
.rom-entry .src { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.rom-add input[type=text] { flex: 1; min-width: 180px; width: auto; }
.rom-status.ok { color: #9c9; }
.rom-status.bad { color: #e99; }
.rom-paste { display: grid; gap: 6px; }
button.link { background: none; border: none; padding: 0; color: #7cf; text-decoration: underline; }
