/* Studio — an immersive, presentation-focused front-end for the extracted game assets.
   The viewer canvas fills the whole viewport; a floating control window (top-left menu)
   selects the game and level; a fullscreen toggle sits bottom-right. */

:root {
  --bg: #07090d;
  --panel: rgba(17, 21, 29, 0.72);
  --panel-solid: #11151d;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e7eaf1;
  --muted: #8b94a7;
  --faint: #5b6377;
  --accent: #5ad1e6;
  --accent-dim: rgba(90, 209, 230, 0.16);
  --amber: #f0b75e;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* the stage hosts the active viewer's canvas, full-bleed */
#stage {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 0%, #0d1119 0%, #07090d 60%, #05060a 100%);
}
#stage .mount { position: absolute; inset: 0; }
#stage canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
  image-rendering: pixelated; /* crisp pixels for the 2-D tile/sprite games */
}
/* the 3-D games (and Marble's slope overlay) render smooth, not pixelated */
#stage [data-render="3d"] canvas,
#stage canvas.mm-three { image-rendering: auto; }

/* the global CRT post-process overlay sits on top of the viewers; pointer-events pass
   through so the viewer's own drag/zoom/rotate still work underneath */
#crt {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 10;
  pointer-events: none;
  image-rendering: auto;
}

/* ---- title / loading card (shown until a viewer paints) ---- */
#titlecard {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 10px;
  pointer-events: none;
  transition: opacity .5s ease;
  z-index: 5;
}
#titlecard.hidden { opacity: 0; }
#titlecard .kicker {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
#titlecard h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 56px);
  font-weight: 600;
  letter-spacing: -.01em;
  background: linear-gradient(180deg, #fff 0%, #aeb6c6 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#titlecard p { margin: 4px auto 0; max-width: 540px; color: var(--muted); font-size: 14px; line-height: 1.5; }
#titlecard .cta {
  margin-top: 16px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: .04em;
}
.spinner {
  position: fixed;
  left: 50%; bottom: 40px;
  width: 26px; height: 26px;
  margin-left: -13px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
  z-index: 16;
}
.spinner.on { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- floating action buttons ---- */
.fab {
  position: fixed;
  z-index: 20;
  width: 46px; height: 46px;
  display: grid; place-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .45);
  transition: transform .15s ease, border-color .15s ease, background .15s ease, color .15s ease;
}
.fab:hover { transform: translateY(-1px); border-color: var(--accent); color: var(--accent); }
.fab:active { transform: translateY(0); }
.fab svg { width: 20px; height: 20px; display: block; }
#menuBtn { top: 18px; left: 18px; }
/* the menu button gives way to the panel that grows out of it */
#menuBtn.hidden { opacity: 0; transform: scale(.7); pointer-events: none; }
#fsBtn { right: 18px; bottom: 18px; }
#fsBtn.on { color: var(--accent); border-color: var(--accent); }

/* ---- floating control window: grows out of the menu button (same top-left anchor) ---- */
.panel {
  position: fixed;
  z-index: 19;
  top: 18px;
  left: 18px;
  width: 304px;
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .05);
  opacity: 0;
  transform: scale(.12);            /* start ~menu-button-sized, growing from the top-left */
  transform-origin: 30px 30px;      /* the menu button's centre */
  pointer-events: none;
  transition: opacity .18s ease, transform .2s cubic-bezier(.22, 1, .36, 1);
}
.panel.open { opacity: 1; transform: none; pointer-events: auto; }

.panel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 4px 16px;
  user-select: none;
}
.panel-bar .group-label { margin: 0; }
.panel-x {
  width: 32px; height: 32px;
  display: grid; place-content: center;
  border: none; border-radius: 10px;
  background: transparent; color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.panel-x:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.panel-x svg { width: 16px; height: 16px; display: block; }

.panel-body {
  padding: 4px 12px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
/* never let a section collapse to absorb overflow -- the panel body scrolls instead */
.panel-body > * { flex-shrink: 0; }
.group-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 8px 4px 4px;
}
.group-label:first-child { margin-top: 2px; }

.list { display: flex; flex-direction: column; gap: 3px; }
.list-scroll { max-height: 38vh; overflow-y: auto; padding-right: 2px; }

.item {
  text-align: left;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  padding: 9px 11px;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.25;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background .12s ease, border-color .12s ease;
}
.item:hover { background: rgba(255, 255, 255, .045); }
.item .sub {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .04em;
  color: var(--faint);
}
.item.active {
  background: var(--accent-dim);
  border-color: rgba(90, 209, 230, .35);
}
.item.active .sub { color: var(--accent); }
.item.active .name { color: #fff; }

/* ---- accordions: systems in the game list; courses in the Marble asset list ---- */
.sys-group, .asset-group { display: flex; flex-direction: column; }
.sys-header, .asset-header {
  flex-direction: row;   /* override .item's column layout */
  align-items: center;
  font-weight: 600;
}
.sys-header .name, .asset-header .name { flex: 1; }
.sys-header .chevron, .asset-header .chevron {
  width: 15px; height: 15px;
  flex: 0 0 auto;
  color: var(--faint);
  transition: transform .18s ease, color .18s ease;
}
.sys-group.open > .sys-header,
.asset-group.open > .asset-header { color: #fff; }
.sys-group.open > .sys-header .chevron,
.asset-group.open > .asset-header .chevron { transform: rotate(90deg); color: var(--accent); }
.sys-games, .asset-children {
  display: none;
  flex-direction: column;
  gap: 3px;
  margin: 2px 0 4px 8px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}
.sys-group.open > .sys-games,
.asset-group.open > .asset-children { display: flex; }

/* ---- CRT toggle switch + controls ---- */
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px 9px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  position: relative;
  width: 36px; height: 20px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid var(--line-strong);
  transition: background .15s ease, border-color .15s ease;
  flex: 0 0 auto;
}
.switch .knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #c7ccd8;
  transition: transform .16s ease, background .16s ease;
}
.switch input:checked + .track { background: var(--accent-dim); border-color: rgba(90, 209, 230, .55); }
.switch input:checked + .track .knob { transform: translateX(16px); background: var(--accent); }
.switch input:disabled + .track { opacity: .4; }
.switch-label { font-size: 13.5px; color: var(--text); }

.layer-toggles { display: flex; flex-direction: column; }
.crt-row { display: flex; align-items: center; justify-content: space-between; }
.gear-btn {
  width: 28px; height: 28px;
  flex: 0 0 auto;
  display: grid; place-content: center;
  border: none; border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s ease, background .15s ease, transform .2s ease;
}
.gear-btn:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.gear-btn.on { color: var(--accent); transform: rotate(40deg); }
.gear-btn svg { width: 16px; height: 16px; display: block; }

.crt-controls {
  display: none;
  flex-direction: column;
  gap: 7px;
  padding: 4px 4px 2px;
}
.crt-controls.shown { display: flex; }
.ctl { display: flex; flex-direction: column; gap: 4px; }
.ctl label {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
}
.ctl label span { font-family: var(--mono); color: var(--accent); font-size: 11px; }
.ctl input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .14);
  outline: none;
}
.ctl input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(90, 209, 230, .14);
}
.ctl input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border: none; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}
.reset-btn {
  margin-top: 6px;
  align-self: flex-start;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.reset-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

/* ---- music transport ---- */
.transport {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 8px 4px 4px;
}
.transport-seek { display: flex; align-items: center; gap: 9px; }
.transport-buttons { display: flex; align-items: center; gap: 7px; }
.mus-btn {
  width: 30px; height: 30px;
  flex: 0 0 auto;
  display: grid; place-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.mus-btn:hover { color: var(--accent); border-color: var(--accent); }
.mus-btn svg { width: 13px; height: 13px; display: block; }
.mus-play,
.mus-btn.on { color: var(--accent); border-color: rgba(90, 209, 230, .4); background: var(--accent-dim); }
.mus-seek {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .14);
  outline: none;
}
.mus-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.mus-seek::-moz-range-thumb {
  width: 12px; height: 12px; border: none; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}
.mus-time {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  min-width: 32px;
  text-align: right;
}

/* tidy scrollbars inside the panel */
.panel-body::-webkit-scrollbar, .list-scroll::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb, .list-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.12); border-radius: 8px;
}

/* ---- info panel: technical details, tabbed; fills the space beside the control window ---- */
#infoBtn { top: 18px; right: 18px; }
#infoBtn.hidden { opacity: 0; transform: scale(.7); pointer-events: none; }

.info-panel {
  position: fixed;
  z-index: 18;
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: 796px;                               /* hug the 720px text column + padding/scrollbar */
  max-width: calc(100vw - 36px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .05);
  opacity: 0;
  transform: scale(.12);                      /* start ~info-button-sized, growing from top-right */
  transform-origin: calc(100% - 23px) 23px;   /* the info button's centre */
  pointer-events: none;
  transition: opacity .18s ease, transform .2s cubic-bezier(.22, 1, .36, 1);
}
.info-panel.open { opacity: 1; transform: none; pointer-events: auto; }

/* fixed header: a scrollable row of tabs + a close button */
.info-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 9px 9px 9px 14px;
  border-bottom: 1px solid var(--line);
}
.info-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.info-tabs::-webkit-scrollbar { display: none; }
.info-tab {
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  padding: 7px 13px;
  cursor: pointer;
  transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.info-tab:hover { color: var(--text); background: rgba(255, 255, 255, .045); }
.info-tab.active { color: #fff; background: var(--accent-dim); border-color: rgba(90, 209, 230, .35); }

/* scrolling body holding the technical text */
.info-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 32px 40px;
}
.info-doc { max-width: 720px; }
.info-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.info-doc h2 { font-size: 21px; font-weight: 600; letter-spacing: -.01em; margin: 28px 0 10px; }
.info-doc h2:first-child { margin-top: 0; }
.info-doc h3 { font-size: 15.5px; font-weight: 600; color: var(--text); margin: 22px 0 8px; }
.info-doc p { font-size: 14px; line-height: 1.62; color: #c8cedb; margin: 0 0 14px; }
.info-doc ul, .info-doc ol { margin: 0 0 14px; padding-left: 20px; }
.info-doc li { font-size: 14px; line-height: 1.6; color: #c8cedb; margin: 0 0 6px; }
.info-doc code {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--amber);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}
.info-doc strong { color: #fff; font-weight: 600; }
.info-doc a { color: var(--accent); text-decoration: none; }
.info-doc a:hover { text-decoration: underline; }
.info-todo { color: var(--muted); font-style: italic; }
.info-empty { color: var(--muted); font-size: 14px; }

.info-body::-webkit-scrollbar { width: 9px; }
.info-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 8px; }

/* narrow viewports: the details window goes full-width and sits above the control window */
@media (max-width: 860px) {
  .info-panel { width: auto; left: 18px; z-index: 21; }
}

/* ---- caption / HUD ---- */
.hud {
  position: fixed;
  z-index: 15;
  left: 18px; bottom: 18px;
  max-width: min(60vw, 540px);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
  pointer-events: none;
  line-height: 1.4;
}
.hud b { color: var(--text); font-weight: 600; }

@media (max-width: 520px) {
  .panel { width: calc(100vw - 36px); }
}
