/* Tune-O-Works 98: desktop shell on top of 98.css */
:root {
  --teal: #008080;
  --navy: #000080;
  --silver: #c0c0c0;
  --taskbar-h: 30px;
  --ui-font: "Pixelated MS Sans Serif", "MS Sans Serif", "Microsoft Sans Serif", Arial, sans-serif;
  --mono-font: "Px437 IBM BIOS", "Px437_IBM_BIOS", Fixedsys, "Courier New", monospace;
  --phosphor: #39ff6a;
  --vfd-bg: #031a08;
  --raised: inset -1px -1px #0a0a0a, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
  --sunken: inset -1px -1px #fff, inset 1px 1px #808080, inset -2px -2px #dfdfdf, inset 2px 2px #0a0a0a;
}

[hidden] { display: none !important; }

/* Pixel cursors are set as custom properties by js/desktop.js */
html { cursor: var(--cur-arrow), default; }
button, label, select, summary, a, input[type="range"], input[type="checkbox"], input[type="file"] { cursor: inherit; }
input[type="text"], input[type="number"], textarea { cursor: text; }
html.busy, html.busy * { cursor: var(--cur-wait), wait !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--teal);
  font-family: var(--ui-font);
  -webkit-font-smoothing: none;
}

/* ---------- Desktop ---------- */
#desktop {
  position: fixed;
  inset: 0 0 calc(var(--taskbar-h) + var(--dock-h, 0px)) 0;
  overflow: hidden;
}
body.has-player { --dock-h: 30px; }

#icons {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(auto-fill, 80px);
  gap: 6px;
  padding: 8px;
  height: 100%;
  box-sizing: border-box;
  justify-content: start;
}

button.icon,
button.icon:not(:disabled):active {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 76px;
  min-width: 0;
  min-height: 0;
  padding: 2px;
  background: none;
  box-shadow: none;
  border: 0;
  color: #fff;
  text-align: center;
}
button.icon img { image-rendering: pixelated; width: 32px; height: 32px; }
button.icon span { padding: 1px 2px; line-height: 1.2; word-break: break-word; }
button.icon:focus { outline: none; }
button.icon:focus span { background: var(--navy); color: #fff; outline: 1px dotted #fff; }
button.icon:focus img { filter: sepia(1) hue-rotate(190deg) saturate(4) brightness(0.7); }

/* ---------- Windows ---------- */
.app-window {
  position: absolute;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
}
.app-window .title-bar { touch-action: none; user-select: none; flex: none; }
.app-window .title-bar-text { display: flex; align-items: center; gap: 4px; }
.app-window .title-bar-text img { image-rendering: pixelated; }
.app-window .window-body { flex: 1; min-height: 0; overflow: auto; }
.app-window .status-bar { flex: none; }
.app-window .status-bar-field { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-window.maximized {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100%;
}

/* ---------- Taskbar ---------- */
#taskbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--taskbar-h);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  box-sizing: border-box;
  background: var(--silver);
  box-shadow: inset 0 1px #dfdfdf, inset 0 2px #fff;
  z-index: 10000;
}
#taskbar button { min-height: 22px; }

#start-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 0 6px;
  flex: none;
}
#start-btn img, .task img, #tray img, .start-items img { image-rendering: pixelated; flex: none; }
#start-btn.pressed { box-shadow: var(--sunken); }

#tasks { display: flex; gap: 3px; flex: 1; min-width: 0; }
.task {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 0 1 160px;
  min-width: 0;
  padding: 0 4px;
  text-align: left;
}
.task span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.task.active {
  box-shadow: var(--sunken);
  font-weight: bold;
  background: repeating-conic-gradient(#fff 0 25%, var(--silver) 0 50%) 0 0 / 2px 2px;
}

#tray {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 22px;
  padding: 0 6px 0 4px;
  box-shadow: inset -1px -1px #fff, inset 1px 1px #808080;
  flex: none;
}
#tray button,
#tray button:not(:disabled):active {
  position: relative;
  min-width: 0;
  min-height: 0 !important;
  width: 20px;
  height: 20px;
  padding: 0;
  background: none;
  box-shadow: none;
  display: grid;
  place-items: center;
}
#tray button[aria-pressed="false"]::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: linear-gradient(45deg, transparent 44%, #ff0000 44% 56%, transparent 56%);
}
#clock { padding-left: 4px; white-space: nowrap; }

/* ---------- MP3 player dock ---------- */
#player {
  position: fixed;
  left: 0; right: 0;
  bottom: var(--taskbar-h);
  height: 30px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  z-index: 9999;
}
#player button { min-width: 0; min-height: 22px; padding: 0 6px; display: grid; place-items: center; }
#player img { image-rendering: pixelated; flex: none; }
#pl-name { flex: 0 1 220px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#pl-seek { flex: 1; min-width: 60px; }
#pl-vol { width: 80px; }
#pl-time { padding: 3px 6px; white-space: nowrap; background: #fff; box-shadow: var(--sunken); font-variant-numeric: tabular-nums; }
#pl-comp[aria-pressed="true"] {
  box-shadow: var(--sunken);
  color: #000080;
  background: repeating-conic-gradient(#fff 0 25%, var(--silver) 0 50%) 0 0 / 2px 2px;
}

/* ---------- Start menu ---------- */
#start-menu {
  position: fixed;
  left: 2px;
  bottom: calc(var(--taskbar-h) - 2px);
  display: flex;
  padding: 3px;
  z-index: 10001;
}
.start-banner {
  width: 24px;
  background: linear-gradient(to top, var(--navy), #1084d0);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.start-banner span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: #c0c0c0;
  font-size: 15px;
  font-weight: bold;
  padding: 6px 0;
  white-space: nowrap;
  letter-spacing: 1px;
}
.start-banner b { color: #fff; }
.start-items { position: relative; display: flex; flex-direction: column; min-width: 180px; }
.start-items > button, #programs-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px 0 6px;
  background: none;
  box-shadow: none;
  text-align: left;
}
.start-items > button img { width: 24px; height: 24px; }
.start-items > button:hover, .start-items > button:focus,
#programs-menu button:hover, #programs-menu button:focus {
  background: var(--navy);
  color: #fff;
  outline: none;
}
.start-items .arrow { margin-left: auto; font-size: 9px; }
.start-items hr { width: 100%; border: 0; border-top: 1px solid #808080; border-bottom: 1px solid #fff; margin: 2px 0; }
#programs-menu {
  position: absolute;
  left: calc(100% + 3px);
  top: 0;
  min-width: 190px;
  padding: 2px;
}
#programs-menu button { min-height: 24px; }

/* ---------- CRT + shut down ---------- */
#crt {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20000;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.45) 100%);
  animation: crt-flicker 0.15s infinite alternate;
}
@keyframes crt-flicker { from { opacity: 0.9; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #crt { animation: none; } }

#shutdown {
  position: fixed;
  inset: 0;
  z-index: 30000;
  background: #000;
  color: #ff8c00;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  text-align: center;
  font-family: var(--mono-font);
}
#shutdown p { font-size: clamp(20px, 4vw, 40px); line-height: 1.4; margin: 0; }

/* ---------- GIF slots ---------- */
.gif-slot {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  vertical-align: middle;
  background: repeating-conic-gradient(#dfdfdf 0 25%, #c0c0c0 0 50%) 0 0 / 8px 8px;
  box-shadow: var(--sunken);
}
.gif-slot::before {
  content: attr(data-label);
  font: 9px var(--mono-font);
  color: var(--navy);
  background: #fff;
  padding: 1px 3px;
}
.gif-slot img { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }

/* ---------- Shared app bits ---------- */
.sunken { box-shadow: var(--sunken); background: #fff; padding: 2px 4px; }
.vfd { background: var(--vfd-bg); box-shadow: var(--sunken); padding: 3px; margin: 6px 0; }
.vfd canvas { display: block; width: 100%; image-rendering: pixelated; cursor: crosshair; }
.vfd-readout {
  font: 18px var(--mono-font);
  color: var(--phosphor);
  background: var(--vfd-bg);
  padding: 2px 8px;
  box-shadow: var(--sunken);
  text-shadow: 0 0 4px var(--phosphor);
}
.button-link {
  display: inline-block;
  min-width: 75px;
  min-height: 23px;
  line-height: 23px;
  padding: 0 12px;
  background: var(--silver);
  box-shadow: var(--raised);
  color: #222;
  text-align: center;
  text-decoration: none;
}
.button-link:active { box-shadow: var(--sunken); }
.button-link:focus { outline: 1px dotted #000; outline-offset: -4px; }

/* Notepad */
.notepad { display: flex; flex-direction: column; gap: 6px; }
.readme-banner { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.notepad textarea {
  flex: 1;
  min-height: 300px;
  width: 100%;
  box-sizing: border-box;
  resize: none;
  font: 13px/1.35 var(--mono-font);
}

/* Recorder */
.rec-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.rec-display { font-size: 22px; white-space: pre; }
.rec-grid { display: flex; gap: 10px; }
.rec-main { flex: 1; min-width: 0; }
.rec-main .field-row { margin: 6px 0; }
.rec-main select, .rec-main #rec-custom { flex: 1; min-width: 0; }
.rec-main #rec-gain { flex: 1; }
.rec-label { flex: none; width: 76px; }
.rec-gain-lbl { width: 56px; text-align: right; }
.rec-side { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-left: 10px; border-left: 1px solid #808080; box-shadow: inset 1px 0 #fff; }
.rec-side .is-vertical { height: 150px; transform: none; margin: 4px 0; }
.rec-side .is-vertical > input[type="range"] { transform: rotate(270deg) translateX(-100%); margin: 0; }
.rec-side button { min-width: 0; padding: 0 8px; }
.rec-buttons button { flex: 1; min-width: 0; }

/* Cutter */
.cut-times input[type="number"] { width: 70px; }
#cut-fo + label { margin-left: 36px; } /* 98.css draws the box in the 19px left margin */
.cut-times .vfd-readout { margin-left: auto; font-size: 14px; }

/* Explorer */
.explorer { display: flex; flex-direction: column; gap: 6px; }
.explorer-addr { display: flex; align-items: center; gap: 6px; }
.explorer-addr .sunken { flex: 1; }
.explorer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 84px);
  gap: 8px;
  padding: 8px;
  min-height: 180px;
  align-content: start;
}
.explorer-grid button.icon { color: #000; }
.explorer-grid button.icon.planned { color: #808080; }
.explorer-grid button.icon.planned img { filter: grayscale(1); opacity: 0.6; }
.explorer-note { display: flex; align-items: center; gap: 8px; }

/* Message boxes */
.dialog .window-body { margin: 12px; }
.msg { line-height: 1.4; }
.msg-buttons { text-align: center; margin-top: 12px; }
.about { display: flex; gap: 12px; align-items: flex-start; }

/* ---------- Narrow screens: windows fill the desktop, dragging is off ---------- */
@media (max-width: 767px) {
  .app-window:not(.dialog) {
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100%;
  }
  .app-window.dialog {
    left: 8px !important;
    width: calc(100% - 16px) !important;
  }
  .notepad textarea { min-height: 0; }
  #pl-name, .pl-vol-label, #pl-vol { display: none; }
  .rec-label { width: auto; }
  .task { flex-basis: 110px; }
  #programs-menu { left: 24px; top: auto; bottom: 100%; }
}
