/* datamusak — "early-MTV × 90s demoscene".
   Pure black. Colour comes only from objects. The logo is the one wild hero; the rest is calm,
   but alive: glossy plastic stickers (fat #050505 outline, hard offset shadow in another hue,
   chrome stripes on the upper half, hard white specular), checkerboards on secondary surfaces,
   yellow/cyan zigzags, low-cadence steps() motion, and a VHS glitch only on interaction. */
@font-face {
  font-family: 'Titan One';
  src: url('../vendor/titan-one.woff2') format('woff2');
  font-display: swap;
}
:root {
  --black: #000;
  --ink: #050505;
  --white: #f2f2f2;
  --or: #ff8018; --pk: #f3256c; --vi: #9900ca; --ul: #3f25fd; --az: #197fe7; --mi: #3fda93; --li: #99ff35; --ye: #f3da02;
  --zz-y: #ffe61a; --zz-c: #1af2ff;
  --checks: repeating-conic-gradient(#f2f2f2 0 25%, #0f0f0f 0 50%) 0 0 / 8px 8px;
  --checks-sm: repeating-conic-gradient(#f2f2f2 0 25%, #0f0f0f 0 50%) 0 0 / 4px 4px;
  --chrome: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.25) 0 2px, transparent 2px 5px);
  --display: 'Titan One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --beat: 0.652s;
  --gap: clamp(8px, 1.6vw, 14px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--black); }
body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column; background: var(--black); color: var(--white);
  font: 14px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-tap-highlight-color: transparent;
}
button, select, input { font: inherit; color: inherit; }
a { color: var(--zz-c); }
a:hover { color: var(--li); }
small { font-size: 11px; }

/* ---------- calm controls ---------- */
select, input[type='text'] {
  background: var(--black); color: var(--white); border: 2px solid var(--white); border-radius: 10px; padding: 4px 8px; min-width: 0; max-width: 100%;
}
:focus-visible { outline: 3px solid var(--li); outline-offset: 2px; }
button {
  font-family: var(--display); text-transform: uppercase; letter-spacing: -0.02em; font-size: 12px; line-height: 1;
  background: var(--black); color: var(--white); border: 2px solid var(--white); border-radius: 999px; padding: 7px 12px; cursor: pointer;
}
button:hover { border-color: var(--li); color: var(--li); }
input[type='range'] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 80px; height: 10px; border-radius: 99px; background: var(--checks); vertical-align: middle; }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--li); box-shadow: 0 0 0 2px var(--ink), 3px 3px 0 2px var(--pk); cursor: grab; }
input[type='range']::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--li); box-shadow: 0 0 0 2px var(--ink), 3px 3px 0 2px var(--pk); cursor: grab; }
input[type='checkbox'] {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin: 0; flex: none; cursor: pointer;
  border: 2px solid var(--white); border-radius: 6px; background: var(--black); display: inline-grid; place-content: center;
}
input[type='checkbox']:checked { background: var(--li); border-color: var(--ink); box-shadow: 2px 2px 0 var(--pk); }
input[type='checkbox']:checked::after { content: '✓'; font: 13px/1 var(--display); color: var(--ink); }

/* ---------- glossy plastic (the 3D look) ---------- */
.plastic, .power, .pop, .chip.on, .online.on, .rec.on, .tile.on .tile-main, .sticker {
  position: relative; overflow: hidden; isolation: isolate;
  box-shadow: 0 0 0 2px var(--ink), 4px 4px 0 2px var(--sh, var(--pk));
}
.power::before, .pop::before, .chip.on::before, .online.on::before, .rec.on::before, .tile.on .tile-main::before, .sticker::before {
  content: ''; position: absolute; inset: 0 0 52% 0; background: var(--chrome); z-index: -1; pointer-events: none;
}
.power::after, .pop::after, .sticker::after, .tile.on .tile-main::after {
  content: ''; position: absolute; left: 9%; top: 12%; width: 16%; max-width: 22px; height: 18%; max-height: 8px;
  border-radius: 50%; background: #fff; z-index: -1; pointer-events: none;
}

/* ---------- header: the hero ---------- */
.top {
  position: relative; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 6px var(--gap); padding: 4px var(--gap) 14px;
}
.top::after { /* cyan zigzag divider, scrolling at a demo cadence */
  content: ''; position: absolute; left: 0; right: 0; bottom: 2px; height: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='8'%3E%3Cpath d='M0 6.5 5.5 1.5 11 6.5 16.5 1.5 22 6.5' fill='none' stroke='%231af2ff' stroke-width='2.5'/%3E%3C/svg%3E") 0 0 / 22px 8px repeat-x;
  animation: zz 1.47s steps(22) infinite;
}
@keyframes zz { to { background-position: -22px 0; } }
.hero { margin: 0; line-height: 0; flex: 1 1 360px; max-width: 600px; }
/* on wide screens the logo shares the row with the controls; a little smaller leaves room for the tiles */
@media (min-width: 1000px) { .hero { max-width: min(600px, max(360px, 36vw)); } }
.hero video { width: 100%; height: auto; aspect-ratio: 800 / 220; display: block; background: var(--black); object-fit: contain; }
.controls { display: flex; align-items: center; gap: 12px; }
.power { font-size: clamp(16px, 2.4vw, 22px); padding: 12px 24px; border: 0; color: var(--ink); background: var(--ye); --sh: var(--pk); }
.power:hover { color: var(--ink); }
.power.on { background: var(--li); --sh: var(--ul); animation: beat var(--beat) steps(6) infinite; }
@keyframes beat { 0% { scale: 1.1; } 20% { scale: 1.04; } 40%, 100% { scale: 1; } }
.power:active { translate: 3px 3px; }
.power.nudge { animation: nudge 1.6s steps(1) infinite; } /* until the first play */
@keyframes nudge { 0%, 70% { scale: 1; } 75% { scale: 1.08; } 85% { scale: 1.02; } }
.tagline { margin: 0 4px; font: 500 12.5px/1.4 system-ui, sans-serif; color: var(--white); opacity: 0.85; }
.tagline b { color: var(--ye); }
.rec { font-size: 13px; padding: 10px 14px; }
.rec.on { border: 0; color: var(--white); background: var(--pk); --sh: var(--ye); animation: beat var(--beat) steps(6) infinite; }
.rec.on:hover { color: var(--white); }
.online { font-size: 11px; }
.online.on { border: 0; color: var(--ink); background: var(--mi); --sh: var(--vi); }
.gear { width: 42px; height: 42px; padding: 0; font-size: 22px; display: grid; place-items: center; }
.gear:hover { animation: spin 0.8s steps(12); }
@keyframes spin { to { rotate: 360deg; } }

/* ---------- layout ---------- */
.app { flex: 1; min-height: 0; display: grid; gap: var(--gap); padding: var(--gap); grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(300px, 58dvh) auto; }
.stage, .dock { min-width: 0; }
@media (max-width: 700px) { .app { grid-template-rows: minmax(240px, 44dvh) auto; } }
@media (min-width: 1000px) {
  body { height: 100dvh; }
  .app { grid-template-columns: minmax(0, 1fr) clamp(320px, 30vw, 440px); grid-template-rows: minmax(0, 1fr); }
  .dock { overflow-y: auto; }
}
.stage, .dock {
  border: 3px solid transparent; border-radius: 18px; min-height: 0;
  background: linear-gradient(var(--black), var(--black)) padding-box, var(--checks) border-box;
}
.stage { position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--black); }
#roll { position: absolute; left: 0; right: 0; bottom: 0; height: 30%; width: 100%; pointer-events: none; z-index: 450; }
.stage-chips { position: absolute; top: 10px; right: 10px; z-index: 700; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.stage-chips button { background: var(--black); padding: 6px 10px; }
.stage-chips button.on { background: var(--ye); color: var(--ink); border-color: var(--ink); }
.log {
  position: absolute; z-index: 600; left: 10px; top: 52px; width: min(640px, calc(100% - 20px)); max-height: calc(70% - 52px); overflow: auto;
  padding: 6px 10px; border: 3px solid transparent; border-radius: 12px;
  background: linear-gradient(var(--black), var(--black)) padding-box, var(--checks) border-box;
  font: 11px/1.6 ui-monospace, 'SF Mono', Menlo, monospace;
}
.log-row { display: grid; grid-template-columns: 58px 10px minmax(90px, 200px) minmax(0, 1fr) auto; gap: 6px; align-items: center; white-space: nowrap; color: var(--az); }
.log-row > span { overflow: hidden; text-overflow: ellipsis; }
.log-row.played { color: var(--white); }
.log-row .dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--ink); }
.log-row .midi { color: var(--li); text-align: right; }
@media (max-width: 640px) { .log-row { grid-template-columns: 10px minmax(0, 1fr) auto; } .log-row .t, .log-row .raw { display: none; } }

/* calm neon map: vector coastlines on pure black */
.leaflet-container { font: inherit; background: var(--black); }
.leaflet-bar { border: 2px solid var(--white) !important; border-radius: 12px !important; overflow: hidden; }
.leaflet-bar a { background: var(--black) !important; color: var(--white) !important; border-color: var(--white) !important; font-family: var(--display); }
.leaflet-tooltip { background: var(--black); color: var(--white); border: 2px solid var(--white); border-radius: 10px; box-shadow: 3px 3px 0 var(--pk); font-weight: 600; }
.leaflet-tooltip::before { display: none; }
.leaflet-control-attribution { background: var(--black) !important; color: var(--white); font-size: 10px; }
.leaflet-control-attribution a { color: var(--zz-c); }

/* ---------- source dock ---------- */
.dock { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.filters .chips { flex-wrap: nowrap; overflow-x: auto; padding: 4px 10px 9px 4px; scrollbar-width: none; }
.filters .chips::-webkit-scrollbar { display: none; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 12px; padding: 0 6px 6px 0; }
.empty { grid-column: 1 / -1; }
.tile { position: relative; animation: domino 0.6s steps(9) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes domino { from { transform: perspective(600px) rotateY(-360deg); opacity: 0; } 15% { opacity: 1; } to { transform: none; } }
.tile-main {
  width: 100%; min-height: 92px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: start; align-items: center; gap: 8px;
  text-align: left; text-transform: none; letter-spacing: 0; padding: 10px; border-radius: 16px;
  background: var(--black); border: 2px solid var(--white); color: var(--white);
}
.tile-main:hover { color: var(--white); border-color: var(--c); }
.tile.on .tile-main, .tile.on .tile-main:hover { background: var(--c); border: 0; color: var(--fg); }
.sticker { width: 24px; height: 24px; border-radius: 50%; background: var(--c); }
.tile.on .sticker { background: var(--black); box-shadow: 0 0 0 2px var(--ink), 2px 2px 0 2px var(--white); }
.tile-main:hover .sticker { animation: flip 0.8s steps(12); }
@keyframes flip { to { transform: perspective(200px) rotateY(360deg); } }
.tile-name { grid-column: 1 / -1; grid-row: 2; font: 400 15px/1.05 var(--display); text-transform: uppercase; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.tile-name.long { font-size: 13px; }
.tile-name.longer { font-size: 11.5px; }
.tile-sub { display: flex; align-items: center; gap: 6px; padding-right: 26px; font: 600 11px system-ui, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--checks-sm); overflow: hidden; position: relative; }
.meter::after { content: ''; position: absolute; inset: 0 auto 0 0; width: calc(var(--m, 0) * 100%); background: var(--c); transition: width 0.4s steps(4); }
.tile.on .meter::after { background: var(--fg); }
.tile-more { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; padding: 0; font-size: 16px; display: grid; place-items: center; background: var(--black); z-index: 2; }
.status { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; background: var(--black); box-shadow: 0 0 0 2px currentColor; }
.status.connecting { background: var(--ye); animation: blink 0.8s steps(2) infinite; }
.status.ok { background: var(--mi); }
.status.error { background: var(--pk); }
@keyframes blink { 50% { background: var(--black); } }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 11px; padding: 6px 11px; white-space: nowrap; flex: none; }
.chip.on { border: 0; padding: 8px 13px; color: var(--ink); background: var(--ye); --sh: var(--vi); }
.chip.on:hover { color: var(--ink); }

/* ---------- sheet (one surface for a source and for settings) ---------- */
.sheet {
  border: 0; padding: 0; margin: 0; inset: 0 0 0 auto; width: min(460px, 100vw); height: 100dvh; max-height: 100dvh; max-width: 100vw;
  background: var(--black); color: var(--white); border-left: 4px solid transparent;
  background: linear-gradient(var(--black), var(--black)) padding-box, var(--checks) border-box;
}
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 0.3s steps(5); }
@keyframes sheet-in { from { translate: 60px 0; opacity: 0; } }
.sheet::backdrop { background: rgba(0, 0, 0, 0.7); }
@media (max-width: 700px) {
  .sheet { inset: auto 0 0 0; margin: 0; width: 100vw; height: auto; max-height: 90dvh; border-left: 0; border-top: 4px solid transparent; border-radius: 20px 20px 0 0; }
  @keyframes sheet-in { from { translate: 0 60px; opacity: 0; } }
}
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 12px; position: relative; }
.sheet-head::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='8'%3E%3Cpath d='M0 6.5 5.5 1.5 11 6.5 16.5 1.5 22 6.5' fill='none' stroke='%23ffe61a' stroke-width='2.5'/%3E%3C/svg%3E") 0 0 / 22px 8px repeat-x;
}
.sheet-head h2 { flex: 1; margin: 0; }
.sheet-head .close { width: 38px; height: 38px; padding: 0; font-size: 16px; }
.sheet-body { overflow-y: auto; padding: 14px 16px 40px; display: flex; flex-direction: column; gap: 12px; }
.sheet .info { margin: 0; }
.status-line { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 12px; overflow-wrap: anywhere; }
.listen { align-self: flex-start; font-size: 16px; padding: 11px 20px; border: 0; color: var(--ink); background: var(--ye); --sh: var(--pk); }
.listen.on { background: var(--li); --sh: var(--ul); }
.pop { border: 0; color: var(--ink); background: var(--ye); --sh: var(--pk); }
.pop:hover, .listen:hover { color: var(--ink); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row > span:first-child { min-width: 92px; font-weight: 700; }
.row output { min-width: 3ch; font-family: var(--display); }
.hint { margin: -6px 0 0; font-size: 12px; color: var(--zz-c); }
.msg { margin: 0; color: var(--li); overflow-wrap: anywhere; }
.msg:empty { display: none; }

/* faux-3D display headings: striped extrusion + hard hue shadow */
h2, h3, details.more > summary {
  font: 400 20px/1.05 var(--display); text-transform: uppercase; letter-spacing: -0.02em; color: var(--c, var(--ye));
  text-shadow: 1px 1px 0 var(--ink), 2px 2px 0 var(--white), 3px 3px 0 var(--ink), 4px 4px 0 var(--white), 5px 5px 0 var(--ink), 7px 7px 0 var(--sh, var(--pk));
}
h3 { margin: 10px 0 0; font-size: 16px; }
details.more { display: flex; flex-direction: column; gap: 12px; }
details.more > summary { cursor: pointer; list-style: none; font-size: 15px; padding: 10px 0 8px; border-top: 3px solid transparent; background: linear-gradient(var(--black), var(--black)) padding-box, var(--checks-sm) border-box; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: ' ▸'; }
details.more[open] > summary::after { content: ' ▾'; }
details.more[open] { padding-bottom: 6px; }
details.more > :not(summary) { margin-top: 12px; }

/* settings: save bar always on top, one tab at a time */
.save-bar { display: flex; gap: 8px; align-items: center; }
.save-bar input { flex: 1; min-width: 0; }
.save-bar .save { padding: 9px 14px; }
.tabs { display: flex; gap: 8px; padding: 4px 6px 6px 4px; flex-wrap: wrap; }
.tabs::-webkit-scrollbar { display: none; }
.panel { display: flex; flex-direction: column; gap: 12px; padding-top: 10px; border-top: 3px solid transparent; background: linear-gradient(var(--black), var(--black)) padding-box, var(--checks-sm) border-box; }
.preset, .recording { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-bottom: 2px solid transparent; background: linear-gradient(var(--black), var(--black)) padding-box, var(--checks-sm) border-box; }
.preset-name { display: flex; flex-direction: column; gap: 2px; }
.preset-name strong { font: 400 14px var(--display); text-transform: uppercase; letter-spacing: -0.02em; }
.preset-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-actions button { padding: 6px 11px; font-size: 11px; }
.preset-actions .preset-load { background: var(--ye); color: var(--ink); border-color: var(--ink); }
.preset-actions .x:hover { border-color: var(--pk); color: var(--pk); }
.recording audio { width: 100%; height: 36px; }
.mixer { display: grid; gap: 10px; }
.fader { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.fader .fam { justify-self: start; padding: 5px 8px; font-size: 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.fader .mute { display: flex; align-items: center; gap: 4px; font-size: 11px; }

/* ---------- footer: donate + install, like gifshooter ---------- */
.foot { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px var(--gap) calc(22px + env(safe-area-inset-bottom)); text-align: center; }
.foot::before { /* yellow zigzag divider, scrolling the other way */
  content: ''; position: absolute; left: 0; right: 0; top: 4px; height: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='8'%3E%3Cpath d='M0 6.5 5.5 1.5 11 6.5 16.5 1.5 22 6.5' fill='none' stroke='%23ffe61a' stroke-width='2.5'/%3E%3C/svg%3E") 0 0 / 22px 8px repeat-x;
  animation: zz 1.47s steps(22) infinite reverse;
}
.foot-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.coffee, .install, .foot-link {
  font: 400 15px/1 var(--display); text-transform: uppercase; letter-spacing: -0.02em; text-decoration: none;
  padding: 13px 20px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px;
}
.coffee { position: relative; overflow: hidden; isolation: isolate; color: var(--ink); background: var(--ye); box-shadow: 0 0 0 2px var(--ink), 5px 5px 0 2px var(--pk); animation: wiggle calc(var(--beat) * 4) steps(1) infinite; }
.coffee::before { content: ''; position: absolute; inset: 0 0 52% 0; background: var(--chrome); z-index: -1; }
.coffee::after { content: ''; position: absolute; left: 9%; top: 14%; width: 16px; height: 6px; border-radius: 50%; background: #fff; z-index: -1; }
.coffee:hover { color: var(--ink); animation: flip-x 0.8s steps(12); }
@keyframes wiggle { 0%, 80% { rotate: -2deg; } 85% { rotate: 3deg; scale: 1.08; } 90% { rotate: -3deg; } 95% { rotate: 2deg; scale: 1.04; } }
@keyframes flip-x { to { transform: perspective(300px) rotateY(360deg); } }
.install { color: var(--ink); background: var(--mi); border: 0; box-shadow: 0 0 0 2px var(--ink), 5px 5px 0 2px var(--vi); }
.install:hover { color: var(--ink); }
.foot-link { color: var(--white); border: 2px solid var(--white); }
.foot-link:hover { color: var(--li); border-color: var(--li); }
.fine { margin: 0; font-size: 12px; }
#made-with { display: inline-block; animation: beat var(--beat) steps(6) infinite; }

/* ---------- VHS glitch: RGB split + row tears, ~a quarter second, only on interaction ---------- */
body.glitching .top, body.glitching .app, body.glitching .sheet-body { animation: vhs 0.26s steps(1) both; }
@keyframes vhs {
  0% { filter: url(#rgb-split); translate: 8px 0; }
  33% { filter: url(#rgb-split); translate: -12px 0; clip-path: polygon(0 0, 100% 0, 100% 38%, 96% 38%, 96% 46%, 100% 46%, 100% 100%, 0 100%, 0 71%, 3% 71%, 3% 76%, 0 76%); }
  66% { filter: none; translate: 4px 0; }
  100% { filter: none; translate: 0; clip-path: none; }
}
body.glitching::after {
  content: ''; position: fixed; inset: 0; z-index: 9999; pointer-events: none; mix-blend-mode: difference;
  background: linear-gradient(transparent 21%, var(--pk) 21% 22.5%, transparent 22.5% 57%, var(--zz-c) 57% 58%, transparent 58% 83%, var(--li) 83% 84.5%, transparent 84.5%);
  animation: tear 0.26s steps(3) both;
}
@keyframes tear { 0% { translate: -30px 0; } 50% { translate: 24px 0; } 100% { translate: 0; opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* footer: the browsers this build was tested on, fading through one by one */
.tested { min-height: 1.4em; color: var(--mi); font-weight: 700; cursor: pointer; }
.tested .one { display: inline-block; animation: tested-fade 1.8s steps(6) both; }
.tested.done { opacity: 0.45; }
@keyframes tested-fade { 0% { opacity: 0; translate: 0 6px; } 25%, 70% { opacity: 1; translate: 0 0; } 100% { opacity: 0; translate: 0 -6px; } }
@media (prefers-reduced-motion: reduce) { .tested .one { animation: none; } }
