/*
 * lab.css: the Potato Synth Lab, in the Baked Potato Shrine style
 * (Comic Sans, teal tiles, yellow text, white boxes with hard shadows,
 * beveled buttons, green-on-black LED readouts, blinking title).
 *
 * Layout: one column on phones (potato, song, then the modules);
 * two columns on tablets; on a wide screen the potato and song sit in the
 * middle with the modules on both sides, so the cables have room to swing.
 */
:root {
  --comic: "Comic Sans MS", "Comic Sans", "Chalkboard SE", "Comic Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --spud: #c98d4b;
  --spud-dark: #5a3414;
}
* { box-sizing: border-box; }
html {
  background: #006699 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect fill="%23006699" width="100" height="100"/><circle fill="%23009999" cx="50" cy="50" r="30"/></svg>');
}
body {
  margin: 0 auto;
  max-width: 1500px;
  padding: 0 16px 40px;
  font-family: var(--comic);
  color: #ffff00;
  overflow-x: hidden;
}
button, input, select { font-family: var(--comic); }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px dashed #ff00ff; outline-offset: 2px;
}

/* --- header ---------------------------------------------------------- */
.construction {
  margin: 0 -16px 20px;
  padding: 10px 16px;
  background: repeating-linear-gradient(45deg, #000, #000 10px, #ffff00 10px, #ffff00 20px);
  border-bottom: 5px solid #ff0000;
  text-align: center;
  color: #000;
  font-weight: 700;
  text-shadow: 0 0 4px #fff, 0 0 4px #fff, 0 0 4px #fff;
}
.shrine-header {
  background: linear-gradient(to bottom, #ff6600, #ff0000);
  border: 5px ridge #ffd700;
  box-shadow: 5px 5px 0 #000;
  padding: 18px 12px;
  text-align: center;
}
h1 {
  color: #ffff00;
  font-size: clamp(28px, 7vw, 48px);
  line-height: 1.1;
  text-shadow: 3px 3px #ff0000, 5px 5px #000;
  animation: blink 1s infinite;
  margin: 6px 0;
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .3; } }
.subtitle { color: #00ffff; font-size: clamp(15px, 3.5vw, 22px); font-weight: 700; text-shadow: 2px 2px #000; }
.flames { font-size: 26px; margin-top: 6px; letter-spacing: 4px; }
.back-row { text-align: center; margin: 14px 0 0; }
.back-link {
  display: inline-block;
  padding: 6px 12px;
  background: #000;
  color: #00ffff;
  border: 2px outset #444;
  text-decoration: none;
  font-weight: 700;
}
.hint { color: #fff; text-shadow: 1px 1px #000; text-align: center; margin: 14px auto 22px; max-width: 760px; }

/* --- the lab grid -------------------------------------------------------- */
.lab {
  position: relative;
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "potato" "song" "a" "b";
}
.potato-panel { grid-area: potato; }
.song-panel { grid-area: song; }
.modules-a { grid-area: a; }
.modules-b { grid-area: b; }
@media (min-width: 760px) {
  .lab { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "potato potato" "song song" "a b"; }
}
@media (min-width: 1150px) {
  .lab {
    grid-template-columns: minmax(250px, 1fr) minmax(400px, 1.3fr) minmax(250px, 1fr);
    grid-template-areas: "a potato b" "a song b";
    grid-template-rows: auto 1fr;
    column-gap: 70px;                 /* room for the cables to swing in */
  }
}

/* Cables are drawn over everything but never catch taps. */
.cables {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 5;
}
.cables path { fill: none; stroke-linecap: round; }
.cables .jacket { stroke: #000; stroke-width: 9; }
.cables .wire { stroke-width: 5; }
.cables .live { stroke-dasharray: 2 10; }

/* --- panels ------------------------------------------------------------- */
.panel {
  position: relative;
  background: #fff;
  color: #000;
  border: 3px solid #000;
  box-shadow: 5px 5px 0 #000;
  padding: 14px;
  min-width: 0;
}
.panel-title { color: #ff0000; font-size: 20px; font-weight: 700; text-decoration: underline; margin-bottom: 8px; }
.panel-sub { display: inline-block; color: #444; font-size: 14px; font-weight: 400; text-decoration: none; }
.note { color: #444; font-size: 13px; margin: 8px 0 0; }

/* --- the potato ------------------------------------------------------- */
.potato { position: relative; max-width: 520px; margin: 0 auto; }
.potato-art { display: block; width: 100%; height: auto; }
.potato-art .spud { fill: var(--spud); stroke: var(--spud-dark); stroke-width: 5; }
.potato-art .spot { fill: #8a5a2b; }
.potato-art .eye { fill: #2a1a0a; transition: fill .15s; }
.potato.powered .eye { fill: #ffff00; filter: drop-shadow(0 0 6px #ffff00); }
.potato-art .mouth { fill: #5a1a00; }
.holes { position: absolute; inset: 0; }
.hole {
  position: absolute;
  width: 46px; height: 46px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid #000;
  background: radial-gradient(circle at 50% 40%, #1a0d03 0 45%, #3b2410 46%);
  color: #ffcc88;
  font: 700 14px var(--comic);
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 6;                        /* above the cables, so the plug ends sit on top */
}
.hole.used { background: var(--mc); color: #000; font-size: 20px; box-shadow: 0 0 0 3px #fff, 2px 2px 0 4px #000; }
.hole .num { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 12px; color: #000; background: #ffffcc; border: 1px solid #000; padding: 0 4px; line-height: 15px; }
.armed .hole { animation: hole-pulse .8s infinite alternate; }
@keyframes hole-pulse { from { box-shadow: 0 0 0 0 #ffff00; } to { box-shadow: 0 0 0 7px #ffff00; } }

.led-row { text-align: center; margin: 12px 0 6px; }
.led-label, .led {
  display: inline-block;
  padding: 6px 10px;
  background: #000;
  border: 2px solid #ff0000;
  font: 700 15px "Courier New", monospace;
}
.led-label { color: #ff0000; border-right: 0; }
.led { color: #00ff00; letter-spacing: 2px; min-width: 7.5em; }
.path { text-align: center; font-weight: 700; margin: 8px 0; min-height: 1.4em; }
.slider-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 6px 0 10px; }
.slider-row input { width: min(260px, 100%); }
input[type="range"] { accent-color: #ff0000; }
.presets { text-align: center; }
.presets-label { font-weight: 700; display: block; margin-bottom: 6px; }
.preset-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* Gray beveled 90s buttons */
.bevel {
  background: linear-gradient(to bottom, #e6e6e6, #b3b3b3);
  border: 2px outset #ddd;
  color: #000;
  padding: 6px 10px;
  font-size: 14px;
}
.bevel:active { border-style: inset; }
.bevel.on { background: linear-gradient(to bottom, #fff2a8, #ffd700); border-color: #ffd700; }

/* Big shiny 90s button */
.primary {
  background: linear-gradient(to bottom, #ffff66, #ff9900);
  color: #000;
  border: 3px outset #ffcc00;
  box-shadow: 4px 4px 0 #000;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 12px 22px;
  font-size: 18px;
}
.primary:active { border-style: inset; box-shadow: 1px 1px 0 #000; transform: translate(3px, 3px); }
.primary.on { background: linear-gradient(to bottom, #ff8080, #e00000); color: #fff; }

/* --- song --------------------------------------------------------------- */
.song-note { margin: 0 0 10px; font-size: 14px; color: #333; }
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.field { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.field input, .field select, .module select {
  background: #fff; color: #000; border: 2px inset #999; font-size: 15px; padding: 4px;
}
.field input { width: 4.5em; }
.song-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 12px; padding-top: 12px; border-top: 2px dashed #999; }
.song-tools .new-song { min-height: 44px; font-weight: 700; font-size: 15px; }
.chords { margin: 14px 0 6px; display: grid; gap: 8px; }
.chord-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chord-row .sec { font-weight: 700; font-size: 13px; color: #ff0000; min-width: 5.5em; }
.chord {
  min-width: 52px;
  padding: 8px 10px;
  background: #ffffcc;
  border: 2px outset #ccc;
  color: #000;
  font: 700 16px var(--comic);
}
.chord.on { background: #00ff00; border-style: inset; }
.keys-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; font-weight: 700; font-size: 14px; }
.octave { display: inline-flex; align-items: center; gap: 6px; }
.octave .bevel { padding: 2px 10px; }
.keys {
  position: relative;
  height: 130px;
  margin-top: 8px;
  border: 3px solid #000;
  background: #000;
  touch-action: none;                /* so sliding along the keys doesn't scroll the page */
  user-select: none;
  -webkit-user-select: none;
}
.key { position: absolute; top: 0; bottom: 0; border: 1px solid #000; }
.key.white { background: linear-gradient(to bottom, #fff 80%, #ddd); }
.key.black { background: linear-gradient(to bottom, #333, #000); height: 60%; bottom: auto; z-index: 1; border-radius: 0 0 3px 3px; }
.key.down.white { background: #ffff66; }
.key.down.black { background: #ff9900; }
.key .lbl { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 11px; color: #555; pointer-events: none; }

/* --- take it to GarageBand ------------------------------------------------- */
.export { margin-top: 16px; padding-top: 12px; border-top: 3px dashed #000; }
.export-title { font-weight: 700; font-size: 17px; color: #ff0000; margin-bottom: 8px; }
.export-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.export-buttons .bevel { min-height: 44px; font-weight: 700; flex: 1 1 150px; }
.export-buttons .bevel:disabled { opacity: .6; cursor: progress; }
#record.on { background: linear-gradient(to bottom, #ff8080, #e00000); color: #fff; border-color: #ff6666; }
.export-help { margin-top: 8px; font-size: 13px; color: #333; }
.export-help summary { cursor: pointer; font-weight: 700; color: #0055cc; }
.export-help ul { margin: 6px 0 0; padding-left: 18px; }
.export-help li { margin: 4px 0; }

/* --- modules ------------------------------------------------------------ */
.modules { display: grid; gap: 22px; align-content: start; min-width: 0; }
.group-title { color: #fff; text-shadow: 2px 2px #000; font-weight: 700; font-size: 17px; margin: 0 0 -10px; }
.module { border-left: 12px solid var(--mc); }
.module-head { display: flex; align-items: center; gap: 10px; }
.module-name { font-size: 18px; font-weight: 700; color: #000; line-height: 1.1; }
.module-name small { display: block; font-size: 12px; font-weight: 400; color: #555; }
.module-emoji { font-size: 26px; }
.blurb { font-size: 13px; color: #333; margin: 6px 0 8px; }
.plug {
  margin-left: auto;
  flex: none;
  min-height: 44px;
  padding: 6px 10px;
  background: #000;
  color: #ffff66;
  border: 3px outset #555;
  font-weight: 700;
  font-size: 14px;
  touch-action: none;                /* drag a cable from it without scrolling */
}
.plug .jack {
  display: inline-block;
  width: 14px; height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--mc);
}
.plug.in { background: var(--mc); color: #000; border-color: #000; border-style: inset; }
.plug.in .jack { border-color: #000; }
.plug.armed { outline: 4px dashed #ff00ff; outline-offset: 2px; }
.module.off .knobs { opacity: .55; }
.knobs { display: grid; gap: 6px; }
.knob-row { display: grid; grid-template-columns: 7.5em minmax(0, 1fr) 4.2em; align-items: center; gap: 8px; font-size: 13px; }
.knob-row span:first-child { font-weight: 700; }
.knob-row output { text-align: right; font-family: "Courier New", monospace; font-size: 12px; }
.knob-row input[type="range"], .knob-row select { width: 100%; min-width: 0; }

/* --- the rest ------------------------------------------------------------ */
.sound-asleep {
  position: fixed;
  left: 50%; bottom: 16px;
  transform: translateX(-50%);
  z-index: 20;
  padding: 12px 16px;
  background: #000;
  color: #ffff00;
  border: 3px outset #ff0000;
  font-weight: 700;
  max-width: calc(100% - 32px);
}
.hole-picker {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: #000;
  border-top: 4px solid #ffff00;
  color: #ffff00;
  font-weight: 700;
}
.hole-picker[hidden] { display: none; }
.hole-picker .bevel { min-width: 44px; min-height: 40px; font-weight: 700; }
body:has(.hole-picker:not([hidden])) { padding-bottom: 120px; }
.toast[hidden] { display: none; }
.toast {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%);
  z-index: 30; background: #ffffcc; color: #000; border: 3px solid #000; box-shadow: 4px 4px 0 #000;
  padding: 10px 14px; font-weight: 700; max-width: calc(100% - 32px); text-align: center;
}
footer { text-align: center; color: #fff; text-shadow: 1px 1px #000; margin-top: 34px; }
footer .small { font-size: 13px; color: #ccffff; }

@media (prefers-reduced-motion: reduce) {
  h1 { animation: none; }
  .armed .hole { animation: none; box-shadow: 0 0 0 5px #ffff00; }
  .potato-art .eye { transition: none; }
}
