/* =====================================================================
   FungFung :: demo.css :: DEMOSCENE ZONE
   ---------------------------------------------------------------------
   Ко́ппер-бары, плазма, растр-полосы, sine-scroller, спектр трекер-модуля
   и низкополигональный PS1-вайб. Только CSS + чуть-чуть ванильного JS.
   Подключается ТОЛЬКО со страницы demo.html.
   ===================================================================== */

/* ---------- Палитры (переключаются кнопками, body.pal-*) ---------- */
body.demo {
  --c1: #00ff41;  --c2: #ff00aa;  --c3: #00e5ff;  --c4: #ffcc00;  --glow: #00ff41;
  background: #000;
  font-family: "Courier New", Courier, monospace;
}
body.demo.pal-c64     { --c1:#8f6fdd; --c2:#63c9c3; --c3:#c9c963; --c4:#aa9f9f; --glow:#8f6fdd; }
body.demo.pal-amiga   { --c1:#ee2233; --c2:#55bbff; --c3:#ffee55; --c4:#ffffff; --glow:#55bbff; }
body.demo.pal-psx     { --c1:#b0b0ff; --c2:#ff9f4a; --c3:#59d3ff; --c4:#e0e0e0; --glow:#b0b0ff; }
body.demo.pal-jungle  { --c1:#39ff14; --c2:#ff2bd6; --c3:#00f0ff; --c4:#ffe600; --glow:#39ff14; }

/* ---------- Сканлайны поверх всего (CRT) ---------- */
.crt::after {
  content:""; position:fixed; inset:0; pointer-events:none; z-index:9999;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.28) 0 1px, rgba(0,0,0,0) 1px 3px);
  mix-blend-mode: multiply;
}

/* ---------- ПЛАЗМА (фон страницы демо) ---------- */
.plasma-bg {
  position: fixed; inset: -20%; z-index: -1;
  background:
    radial-gradient(circle at 20% 30%, var(--c2), transparent 45%),
    radial-gradient(circle at 80% 20%, var(--c3), transparent 45%),
    radial-gradient(circle at 30% 80%, var(--c1), transparent 45%),
    radial-gradient(circle at 70% 70%, var(--c4), transparent 40%),
    #000;
  filter: blur(40px) saturate(1.6);
  opacity: .30;
  animation: plasma-move 24s linear infinite;
}
@keyframes plasma-move {
  0%   { transform: translate(0,0) rotate(0deg) scale(1.1); }
  50%  { transform: translate(-6%,4%) rotate(180deg) scale(1.25); }
  100% { transform: translate(0,0) rotate(360deg) scale(1.1); }
}

/* ---------- КО́ППЕР-БАРЫ ---------- */
.copper { margin: 6px 0; }
.copper .bar {
  height: 10px; margin-bottom: 3px;
  background: linear-gradient(90deg, transparent, var(--c1), transparent);
  background-size: 50% 100%; background-repeat: repeat-x;
}
.copper .bar:nth-child(1) { animation: copper-slide 3.2s linear infinite 0s; }
.copper .bar:nth-child(2) { animation: copper-slide 3.2s linear infinite .10s; }
.copper .bar:nth-child(3) { animation: copper-slide 3.2s linear infinite .20s; }
.copper .bar:nth-child(4) { animation: copper-slide 3.2s linear infinite .30s; }
.copper .bar:nth-child(5) { animation: copper-slide 3.2s linear infinite .40s; }
.copper .bar:nth-child(6) { animation: copper-slide 3.2s linear infinite .50s; }
@keyframes copper-slide { from { background-position: -100% 0; } to { background-position: 200% 0; } }

/* ---------- РАСТР-ПОЛОСЫ (шахматка, движется) ---------- */
.raster {
  height: 40px; border-top: 1px solid #000; border-bottom: 1px solid #000;
  background: repeating-linear-gradient(90deg, var(--c2) 0 8px, var(--c1) 8px 16px);
  background-size: 200% 100%;
  animation: raster-move 1.2s linear infinite;
  image-rendering: pixelated;
  box-shadow: 0 0 14px var(--glow);
}
@keyframes raster-move { to { background-position: 32px 0; } }

/* ---------- ПИКСЕЛЬНЫЙ ЛОГОТИП / "DEMO TITLE" ---------- */
.demotitle {
  text-align: center;
  font-family: "Courier New", monospace;
  font-weight: bold;
  font-size: 40px;
  letter-spacing: 6px;
  line-height: 1.1;
  color: var(--c4);
  text-shadow: 0 0 6px var(--glow), 0 0 18px var(--glow), 3px 3px 0 #000;
  animation: titleshade 6s linear infinite;
}
@keyframes titleshade { 50% { color: var(--c1); text-shadow: 0 0 6px var(--c1), 0 0 20px var(--c1), 3px 3px 0 #000; } }

/* ---------- SINE-SCROLLER (JS ведёт по синусоиде) ---------- */
.scroller {
  overflow: hidden; white-space: nowrap; height: 60px; position: relative;
  border-top: 2px solid var(--c3); border-bottom: 2px solid var(--c3);
  background: #000; margin: 14px 0;
}
.scroller .row { position: absolute; top: 0; left: 0; will-change: transform; }
.scroller .ch {
  display: inline-block; font-family: "Courier New", monospace; font-weight: bold;
  font-size: 26px; color: var(--c1); text-shadow: 0 0 8px var(--glow); will-change: transform;
}

/* ---------- СПЕКТР ТРЕКЕР-МОДУЛЯ ---------- */
.spectrum {
  display: flex; align-items: flex-end; justify-content: center; gap: 3px;
  height: 90px; padding: 8px; background: #050505; border: 2px inset var(--c1);
}
.spectrum i {
  display: block; width: 8px; background: linear-gradient(0deg, var(--c1), var(--c4), var(--c2));
  box-shadow: 0 0 8px var(--glow);
  animation: bar-bounce .42s steps(6, end) infinite alternate;
}
.spectrum i:nth-child(2n) { animation-duration: .33s; }
.spectrum i:nth-child(3n) { animation-duration: .51s; }
.spectrum i:nth-child(5n) { animation-duration: .27s; }
.spectrum i:nth-child(7n) { animation-duration: .6s; }
@keyframes bar-bounce { from { height: 12%; } to { height: 92%; } }

/* ---------- GREETZ ---------- */
.greetz { font-family: "Courier New", monospace; font-size: 15px; line-height: 1.9; }

/* ---------- .NFO в ASCII-рамке ---------- */
.nfo {
  font-family: "Courier New", monospace; font-size: 12px; line-height: 1.35;
  color: #9fffa8; background: #001a00; border: 2px solid var(--c1);
  padding: 12px 16px; white-space: pre; overflow-x: auto; box-shadow: 0 0 12px var(--glow);
}
.nfo b { color: var(--c4); }

/* ---------- PS1 LOW-POLY + ДИЗЕРИНГ ---------- */
.psxbox { position: relative; border: 3px ridge #888; background: #000; overflow: hidden; }
.psxbox img, .psxbox svg { display: block; width: 100%; image-rendering: pixelated; }
.psxbox .dither {              /* пиксельный дизеринг и "мыло" PS1 */
  position: absolute; inset: 0; pointer-events: none;
  background-image: repeating-conic-gradient(#000 0% 25%, transparent 0% 50%);
  background-size: 3px 3px; opacity: .35; mix-blend-mode: overlay;
}
.psx-flat { filter: saturate(1.2) contrast(1.1); }
/* лёгкий "vertex shimmer" — дрожание, как на PS1 */
@keyframes vjitter { 0%,100%{transform:translate(0,0)} 25%{transform:translate(0.6px,-0.4px)} 50%{transform:translate(-0.5px,0.5px)} 75%{transform:translate(0.3px,0.2px)} }
.polymush { animation: vjitter .35s steps(2,end) infinite; }

/* ---------- КНОПКИ ПАЛИТР ---------- */
.palbar { text-align: center; margin: 10px 0; }
.palbar button {
  font-family: "Courier New", monospace; font-weight: bold; cursor: pointer;
  background: #000; color: var(--c4); border: 2px outset var(--c1); padding: 4px 10px; margin: 2px;
}
.palbar button:hover { border-style: inset; color: #000; background: var(--c1); }

/* ---------- BOOT-ПАНЕЛЬ (PS1-подобный старт) ---------- */
.boot {
  background: #000; border: 3px double var(--c3); padding: 16px; text-align: center;
  box-shadow: 0 0 16px var(--c3);
}
.boot .sys { color: var(--c3); font-size: 13px; letter-spacing: 3px; }
.boot .big { color: #fff; font-size: 22px; letter-spacing: 6px; margin: 8px 0; text-shadow: 0 0 8px #fff; }
.bootbar { height: 16px; border: 2px inset #666; background: #111; margin: 12px auto; width: 70%; overflow: hidden; }
.bootbar span { display: block; height: 100%; width: 0;
  background: repeating-linear-gradient(90deg, var(--c1) 0 10px, #024 10px 12px);
  animation: bootfill 6s linear forwards; }
@keyframes bootfill { to { width: 100%; } }

/* =====================================================================
   17) ПЛЕЕР FUNGFUNG TRACKER JUKEBOX
   ===================================================================== */
.jukebox { border: 2px inset var(--c1); background: #000; padding: 8px; }
#viz { width: 100%; height: 120px; display: block; background: #000;
       border: 1px solid #111; image-rendering: pixelated; }
.nowplaying { margin-top: 8px; font-family: "Courier New", monospace; font-size: 14px; }
.np-label { color: var(--c4); font-weight: bold; }
.np-title { color: var(--c1); font-weight: bold; }

.playlist { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto;
            border: 2px inset #333; background: #030303; }
.playlist li { padding: 4px 8px; cursor: pointer; font-family: "Courier New", monospace;
               font-size: 13px; border-bottom: 1px dotted #1c1c1c; color: #b8b8b8; }
.playlist li:hover { background: #001a00; color: #fff; }
.playlist li.playing { background: var(--c1); color: #000; }
.playlist li .idx { display: inline-block; width: 22px; color: var(--c2); }
.playlist li.playing .idx { color: #003; }
.playlist li .src { font-size: 10px; color: #5f5f5f; }
.playlist li.playing .src { color: #024; }

.controls { font-family: "Courier New", monospace; }
.controls button {
  font-family: "Courier New", monospace; font-weight: bold; cursor: pointer;
  background: #000; color: var(--c1); border: 2px outset var(--c1);
  padding: 5px 9px; margin: 2px; font-size: 13px;
}
.controls button:hover { background: var(--c1); color: #000; border-style: inset; }
.controls button.on { background: var(--c4); color: #000; }
.controls label { display: block; color: var(--c3); font-size: 12px; margin: 8px 0 2px; }
.controls input[type=range] { width: 100%; accent-color: var(--c1); }
.time { color: var(--c3); font-size: 12px; margin: 6px 0; }

/* =====================================================================
   18) ЖИВОЙ ПАТТЕРН (трекерная сетка)
   ===================================================================== */
.trackerbox { border: 2px inset var(--c1); background: #000; }
.trackerhead { padding: 4px 8px; background: #001a00; color: var(--c1);
  font-family: "Courier New", monospace; font-size: 12px; border-bottom: 1px solid #063; }
.patternview { height: 300px; overflow: auto; background: #000; }
.ptable { border-collapse: collapse; font-family: "Courier New", monospace;
  font-size: 11px; white-space: pre; width: 100%; }
.ptable th { position: sticky; top: 0; background: #0a0a0a; color: var(--c3);
  border: 1px solid #123; padding: 1px 6px; font-weight: normal; z-index: 2; }
.ptable td { border: 1px solid #0d0d0d; padding: 0 6px; color: #9fb8a2; }
.ptable td.rownum, .ptable th.rownum { color: #4a6; background: #050505; text-align: right; }
.ptable tr.beat td { color: #d7ffd7; }
.ptable tr.cur td { background: var(--c1); color: #000; font-weight: bold; }
.ptable tr.cur td.rownum { background: var(--c4); color: #000; }
.ptable td:empty::after { content: "···"; color: #243; }

/* =====================================================================
   19) 3D: КРУТИЛКА КОНТЕЙНЕР + ТЕМПЕ-БЛОК + ГРИБ
   ===================================================================== */
.stage { perspective: 800px; height: 240px; display: flex; align-items: center;
  justify-content: center; position: relative; overflow: hidden; cursor: grab;
  background: radial-gradient(circle at 50% 55%, rgba(255,255,255,.13), transparent 62%); }
.stage:active { cursor: grabbing; }
.stage.drag { cursor: grabbing; }
.hint { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center;
  font-family: "Courier New", monospace; font-size: 10px; color: #666; }

/* --- 3D ТЕМПЕ-БЛОК (CSS-3D призма, тач/мышь для вращения) --- */
.tempe3d { position: relative; width: 160px; height: 110px;
  transform-style: preserve-3d; will-change: transform; }
.tempe3d .face { position: absolute; left: 50%; top: 50%;
  background-color: #d9d3c8; image-rendering: pixelated;
  /* Овальчики мицелия: все помещены ВНУТРЬ плитки 90x90 и не касаются
     краёв — поэтому не бывает полу-овалов и наложений, только ровные
     пятна на расстоянии друг от друга. Меняй позиции/размеры тут. */
  background-image:
    radial-gradient(10px 7px at 20% 24%, #8f887b 0 99%, transparent 100%),
    radial-gradient(9px 6px at 62% 18%, #9a9284 0 99%, transparent 100%),
    radial-gradient(11px 8px at 44% 58%, #857e72 0 99%, transparent 100%),
    radial-gradient(8px 6px at 80% 66%, #948c7f 0 99%, transparent 100%),
    radial-gradient(6px 5px at 30% 82%, rgba(255,255,255,.95) 0 99%, transparent 100%),
    radial-gradient(5px 4px at 72% 86%, rgba(255,255,255,.85) 0 99%, transparent 100%);
  background-size: 90px 90px;
  background-repeat: repeat;
  border: 1px solid #111; box-shadow: inset 0 0 34px rgba(0,0,0,.45); }
.tempe3d .f-front  { width:160px; height:110px; transform: translate(-50%,-50%) translateZ(60px); filter: brightness(1.05); }
.tempe3d .f-back   { width:160px; height:110px; transform: translate(-50%,-50%) rotateY(180deg) translateZ(60px); filter: brightness(.7); }
.tempe3d .f-right  { width:120px; height:110px; transform: translate(-50%,-50%) rotateY(90deg) translateZ(80px); filter: brightness(.85); }
.tempe3d .f-left   { width:120px; height:110px; transform: translate(-50%,-50%) rotateY(-90deg) translateZ(80px); filter: brightness(.62); }
.tempe3d .f-top    { width:160px; height:120px; transform: translate(-50%,-50%) rotateX(90deg) translateZ(55px); filter: brightness(1.2); }
.tempe3d .f-bottom { width:160px; height:120px; transform: translate(-50%,-50%) rotateX(-90deg) translateZ(55px); filter: brightness(.5); }

/* --- ГРИБ (вращение) + свечение, чтобы не сливался с фоном --- */
.mush3d { transform-style: preserve-3d; will-change: transform;
  filter: drop-shadow(0 0 6px #fff) drop-shadow(0 0 18px rgba(255,255,255,.5)); }
