/* FD-10. Conventions do not matter. */

@font-face { font-family: 'Michroma'; src: url('../assets/fonts/michroma.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'VT323'; src: url('../assets/fonts/vt323.woff2') format('woff2'); font-display: swap; }

:root {
  color-scheme: dark;
  --ink: #e8efe6;
  --phosphor: #b7ff5a;
  --teal: #4fd8d0;
  --bruise: #a982e8;
  --error: #ff5a4f;
  --black: #05060a;
  --gut: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--black); color: var(--ink); font-family: 'VT323', ui-monospace, Menlo, monospace; font-size: 18px; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { font: inherit; border: 1px solid currentColor; padding: 0 4px; border-radius: 2px; }
[hidden] { display: none !important; }

/* --- the plain page: no JavaScript, no WebGL, or a search engine ------- */
html:not(.alive) #organism, html:not(.alive) .hud, html:not(.alive) #boot, html:not(.alive) #nodes, html:not(.alive) #toast { display: none; }
#flat { padding: var(--gut); max-width: 640px; margin: 0 auto; }
#flat h1 { font-family: 'Michroma', sans-serif; font-weight: 400; }
#flat a { color: var(--phosphor); }
html.alive #flat { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* --- the organism ------------------------------------------------------ */
html.alive, html.alive body { overflow: hidden; overscroll-behavior: none; }
#organism { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

/* --- hud --------------------------------------------------------------- */
.hud { position: fixed; z-index: 5; pointer-events: none; text-shadow: 0 0 6px #000, 0 1px 0 #000; }
.hud a, .hud button { pointer-events: auto; }
body.bare .hud, body.bare #nodes, body.bare .win, body.bare #strap, body.bare #hint { display: none !important; }

.hud-btn {
  background: rgba(5, 6, 10, .62); border: 1px solid rgba(232, 239, 230, .34); padding: 3px 10px 2px; letter-spacing: .06em;
  text-shadow: none; transition: background .12s, color .12s; text-decoration: none; color: inherit;
}
.hud-btn:hover { background: var(--ink); color: #000; }
.hud-btn:focus-visible, .win button:focus-visible, .win a:focus-visible, .knob:focus-visible, .node:focus-visible { outline: 2px solid var(--phosphor); outline-offset: 2px; }
.hud-btn[aria-pressed="true"] { background: var(--phosphor); color: #000; border-color: var(--phosphor); }

#hud-top { top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px var(--gut); }
#brand { display: block; background: none; border: 0; padding: 0; transition: transform .15s, filter .15s; }
#brand:hover, #brand:focus-visible { transform: rotate(-4deg) scale(1.12); filter: brightness(1.4) drop-shadow(0 0 8px var(--teal)); outline: none; }
#brand img { width: 56px; height: auto; display: block; }
#menu { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

#strap {
  position: fixed; left: 50%; top: 58%; transform: translateX(-50%); z-index: 3; width: max-content; max-width: calc(100vw - 32px);
  margin: 0; text-align: center; pointer-events: none;
  font-family: 'Michroma', sans-serif; font-size: clamp(11px, 1.45vw, 21px); letter-spacing: .32em; text-transform: uppercase;
  color: var(--ink); text-shadow: 0 0 10px #000, 0 0 2px #000, 2px 0 0 rgba(255, 0, 80, .45), -2px 0 0 rgba(0, 220, 255, .45);
}
#hint {
  position: fixed; left: 50%; top: calc(58% + 3em); transform: translateX(-50%); z-index: 3; color: var(--phosphor); margin: 0; pointer-events: none;
  letter-spacing: .1em; background: rgba(5, 6, 10, .78); padding: 1px 8px 0; white-space: nowrap; transition: opacity .8s; animation: blink 1.6s steps(2, jump-none) infinite;
}
#hint.gone { opacity: 0; animation: none; }
@keyframes blink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { #hint { animation: none; } }

#hud-bottom { left: 0; right: 0; bottom: 0; padding: 8px var(--gut) 10px; display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: end; }
#uptime { display: block; width: max-content; max-width: 100%; line-height: 1.1; color: var(--ink); text-decoration: none; cursor: pointer; }
#uptime:hover, #uptime:focus-visible { color: var(--phosphor); outline: none; }
#controls { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; grid-column: 2; grid-row: 1; }
#tuner { display: flex; align-items: stretch; gap: 0; }
#tuner button { background: rgba(5, 6, 10, .62); border: 1px solid rgba(232, 239, 230, .34); padding: 3px 9px 2px; text-shadow: none; }
#tuner button:hover { background: var(--ink); color: #000; }
#tuner #tuner-display {
  position: relative; background: #120e02; color: #ffb02e; border-width: 1px 0; padding: 3px 10px 3px; min-width: 22ch; display: flex; gap: 10px; justify-content: space-between; white-space: nowrap;
  text-shadow: 0 0 6px #ff8a00; touch-action: none; user-select: none; -webkit-user-select: none;
}
#tuner #tuner-display:hover { background: #2a2006; color: #ffb02e; }
#tuner #tuner-display:focus-visible { outline: 2px solid var(--phosphor); outline-offset: -2px; }
#tuner:not(.on) #tuner-display { color: #6c5426; text-shadow: none; }
/* Beats in the music, as far as anyone can tell from here. Set once a frame. */
#tuner-name { display: inline-block; transform: scale(calc(1 + var(--beat, 0) * .09)); transform-origin: right center; filter: brightness(calc(1 + var(--beat, 0) * .9)); }
#tuner-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: #ffb02e; box-shadow: 0 0 5px #ff8a00; transform-origin: left center; transform: scaleX(var(--done, 0)); }
#tuner:not(.on) #tuner-bar { display: none; }

/* --- nodes: the links that swim around --------------------------------- */
#nodes { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.node {
  position: absolute; left: 0; top: 0; pointer-events: auto; text-decoration: none; text-align: center; white-space: nowrap; will-change: transform;
  line-height: 1; padding: 3px 6px 2px; background: rgba(5, 6, 10, .7); opacity: 0; transition: opacity .15s;
}
.node:not(.on):not(:focus-visible) { pointer-events: none; }
.node.on, .node:focus-visible { opacity: 1; }
.node b { display: block; font-family: 'Michroma', sans-serif; font-weight: 400; font-size: 11px; letter-spacing: .1em; }
.node:hover, .node:focus-visible { background: var(--ink); color: #000; }

#toast {
  position: fixed; z-index: 40; left: 50%; bottom: 76px; transform: translateX(-50%); background: #000; color: var(--phosphor); padding: 3px 12px 2px; border: 1px solid var(--phosphor);
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
}
#toast.on { opacity: 1; }

/* --- windows: FD-07's X-Windows frame, back from 1998 ------------------ */
.win {
  position: fixed; z-index: 20; display: grid; grid-template: 24px minmax(0, 1fr) 24px / 24px minmax(0, 1fr) 24px; max-height: calc(100dvh - 80px); max-width: calc(100vw - 16px);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, .55); color: var(--ink);
}
.x { background-repeat: no-repeat; }
.xtl { background-image: url('../assets/x/xtl.gif'); }
.xtm { background: url('../assets/x/xtm.gif') repeat-x; cursor: move; touch-action: none; text-align: center; overflow: hidden; color: #000; }
.xtm h2 { margin: 0; font: 700 14px/22px Garamond, 'Times New Roman', serif; letter-spacing: .02em; user-select: none; white-space: nowrap; }
.xtrb { background-image: url('../assets/x/xtrb.gif'); }
.xls { background: url('../assets/x/xls.gif') repeat-y; }
.xrs { background: url('../assets/x/xrs.gif') repeat-y; }
.xbl { background-image: url('../assets/x/xbl.gif'); }
.xbm { background: url('../assets/x/xbm.gif') repeat-x; }
.xbr { background-image: url('../assets/x/xbr.gif'); }
.x-close { width: 24px; height: 24px; background: transparent; border: 0; padding: 0; display: block; }
.x-close:hover { background: rgba(255, 255, 255, .35); }
.win-body { overflow: auto; background: #0a0d10 url('../assets/art/tile-metal.webp'); background-blend-mode: multiply; min-height: 0; overscroll-behavior: contain; }

#win-mods { top: 58px; left: var(--gut); width: 420px; }
#win-radio { bottom: 52px; right: var(--gut); width: 320px; }
#win-wall { top: 90px; right: 80px; width: 420px; }
#win-help { top: 120px; left: 50%; margin-left: -160px; width: 320px; }

/* rack */
.rack { padding: 8px 10px 10px; display: grid; gap: 8px; }
.rack-group { border: 1px solid rgba(232, 239, 230, .24); margin: 0; padding: 4px 6px 7px; min-width: 0; }
.rack-group legend { padding: 0 6px; color: var(--phosphor); letter-spacing: .1em; font-size: 16px; }
.knobs { display: flex; justify-content: space-around; gap: 2px; flex-wrap: wrap; }
.knob-wrap { display: flex; flex-direction: column; align-items: center; gap: 1px; width: 62px; }
.knob-wrap label { font-size: 15px; letter-spacing: .04em; }
.knob {
  width: 50px; height: 50px; border-radius: 50%; touch-action: none; cursor: ns-resize;
  background: url('../assets/art/knob.webp') center/contain no-repeat; transform: rotate(var(--a, 0deg)); filter: drop-shadow(0 3px 2px #000);
}
.randomizer { width: 100%; background: var(--phosphor); border: 0; padding: 9px 4px 7px; color: #000; font-family: 'Michroma', sans-serif; font-size: 14px; letter-spacing: .14em; cursor: pointer; }
.randomizer:hover { background: var(--ink); }
.mod-layers { display: flex; align-items: center; gap: 8px; }
.mod-layers span { font-size: 22px; color: var(--phosphor); line-height: 1; }
.mod-layers button { flex: 1; min-width: 0; background: #000; border: 1px solid rgba(232, 239, 230, .4); padding: 7px 4px 5px; color: var(--ink); font-family: 'Michroma', sans-serif; font-size: 13px; letter-spacing: .08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod-layers button:hover { background: var(--ink); color: #000; }
.mod-layers button[aria-pressed="true"] { background: var(--phosphor); color: #000; border-color: var(--phosphor); }
.mod-head { display: flex; gap: 3px; align-items: stretch; }
.mod-head .grow { flex: 1; }
.mod-grid button { font-size: 15px; padding: 2px 6px 1px; }
.rack-more { border: 1px solid rgba(232, 239, 230, .24); padding: 2px 6px; }
.rack-more summary { cursor: pointer; color: var(--phosphor); letter-spacing: .1em; font-size: 16px; }
.rack-more[open] { padding-bottom: 7px; }
.seg { display: flex; flex-wrap: wrap; gap: 3px; }
.mod-head button, .seg button, .acts button, .act-file, .wall-form button {
  background: #000; border: 1px solid rgba(232, 239, 230, .4); padding: 3px 8px 2px; font-size: 16px; letter-spacing: .04em; color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block;
}
.mod-head button:hover, .seg button:hover, .acts button:hover, .act-file:hover, .wall-form button:hover { background: var(--ink); color: #000; }
.mod-head button[aria-pressed="true"], .seg button[aria-pressed="true"] { background: var(--phosphor); color: #000; }
.acts { display: flex; flex-wrap: wrap; gap: 4px; }
.act-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.act-file:focus-within { outline: 2px solid var(--phosphor); }

/* the track list */
.radio { padding: 8px 10px 10px; display: grid; gap: 8px; }
.radio-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 52dvh; overflow: auto; }
.radio-list button { width: 100%; display: flex; gap: 12px; background: #120e02; border: 1px solid rgba(232, 239, 230, .2); padding: 3px 8px 2px; color: #ffb02e; text-align: left; white-space: nowrap; }
.radio-list i { font-style: normal; opacity: .65; min-width: 3.4em; }
.radio-list button:hover, .radio-list button:focus-visible { background: #ffb02e; color: #000; outline: none; }
.radio-list button:hover i, .radio-list button:focus-visible i { opacity: 1; }
.radio-list button[aria-pressed="true"] { background: var(--phosphor); border-color: var(--phosphor); color: #000; }
.radio-stop { background: #000; border: 1px solid var(--error); color: var(--error); padding: 4px 8px 3px; font-family: 'Michroma', sans-serif; font-size: 13px; letter-spacing: .14em; }
.radio-stop:hover:not(:disabled) { background: var(--error); color: #000; }
.radio-stop:disabled { opacity: .35; cursor: default; }

/* wall */
.wall { padding: 8px 12px 10px; }
.wall h3 { margin: 0 0 6px; text-align: center; font-family: 'Michroma', sans-serif; font-weight: 400; color: var(--phosphor); font-size: 14px; letter-spacing: .1em; }
.wall-total { margin: 0 0 6px; text-align: center; color: var(--ink); opacity: .75; }
.wall-total:empty { display: none; }
.wall-list { list-style: none; margin: 0 0 10px; padding: 0; max-height: 52dvh; overflow: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.wall-list button { position: relative; width: 100%; display: block; background: #000; border: 1px solid rgba(232, 239, 230, .28); padding: 0; color: var(--ink); line-height: 1; }
.wall-list button:hover, .wall-list button:focus-visible { border-color: var(--phosphor); outline: 1px solid var(--phosphor); }
.wall-list canvas { display: block; width: 100%; height: auto; }
.ini, .when { position: absolute; background: rgba(0, 0, 0, .72); padding: 1px 4px 0; }
.ini { left: 0; bottom: 0; letter-spacing: .14em; color: var(--phosphor); }
.when { right: 0; top: 0; font-size: 13px; opacity: .8; }
.wall-older { grid-column: 1 / -1; }
.wall-list .wall-older button { padding: 3px 0 2px; color: var(--phosphor); letter-spacing: .14em; cursor: pointer; }
.wall-list .wall-older button:hover { background: var(--phosphor); color: #000; }
.wall-list .wall-older button:disabled { opacity: .5; cursor: wait; }
.wall-empty { grid-column: 1 / -1; color: var(--error); text-align: center; }
.wall-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.wall-form input {
  width: 4em; background: #000; border: 1px solid var(--phosphor); color: var(--phosphor); font: inherit; font-size: 22px; text-transform: uppercase; letter-spacing: .2em; padding: 0 0 0 .3em;
}
.wall-msg { margin: 6px 0 0; min-height: 1.1em; color: var(--phosphor); }

/* help */
.help { padding: 6px 12px 10px; line-height: 1.1; }
.help p { margin: 6px 0; }
.help dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 8px 0; }
.help dt { color: var(--phosphor); }
.help dd { margin: 0; }
.help .sig { color: var(--phosphor); }

/* --- boot -------------------------------------------------------------- */
#boot { position: fixed; inset: 0; z-index: 50; background: #000; color: var(--phosphor); display: flex; align-items: center; justify-content: center; padding: var(--gut); transition: opacity .8s; font-size: clamp(18px, 2.4vw, 24px); }
#boot.gone { opacity: 0; pointer-events: none; }
#boot.quick { transition: none; opacity: 0; pointer-events: none; }
.boot-inner { width: min(720px, 100%); }
#boot-log { min-height: 8.5em; line-height: 1.12; }
#boot-log > div:empty::before { content: '\200b'; }
.boot-quote { margin-top: .6em; color: var(--ink); }
.boot-cite { color: rgba(232, 239, 230, .55); margin-bottom: .6em; }
#boot-progress { color: var(--teal); margin-bottom: .6em; }
#boot-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
#boot-actions button { background: #000; border: 1px solid var(--phosphor); color: var(--phosphor); padding: 4px 14px 3px; }
#boot-actions button:hover, #boot-actions button:focus-visible { background: var(--phosphor); color: #000; outline: none; }
#boot-actions p { width: 100%; margin: 6px 0 0; font-size: 16px; color: rgba(232, 239, 230, .55); }

/* --- phones ------------------------------------------------------------ */
@media (max-width: 720px) {
  body { font-size: 17px; }
  #brand { flex: none; }
  #brand img { width: 32px; }
  #menu { flex: 1; min-width: 0; gap: 3px; flex-wrap: nowrap; }
  .hud-btn { padding: 2px 7px 1px; }
  #hud-bottom { grid-template-columns: 1fr; }
  #controls { grid-column: 1; grid-row: 2; justify-content: flex-start; }
  #tuner #tuner-display { min-width: 0; flex: 1; font-size: 15px; }
  #tuner { flex: 1 1 100%; }
  #uptime { font-size: 15px; }
  #strap { letter-spacing: .14em; }
  .win { left: 8px !important; right: 8px !important; top: auto !important; bottom: 8px !important; margin: 0 !important; width: auto !important; max-height: 72dvh; }
  .node b { font-size: 9px; }
  .wall-list { grid-template-columns: repeat(2, 1fr); }
}
