/* ============================================================
   BUNII.NET STYLE TEMPLATE
   ============================================================
   HOW TO CUSTOMIZE:
   1. Edit the CSS variables in :root below
   2. Edit panel content in index.html
   3. Edit playlist in script.js
   ============================================================ */

/* ============================================================
   CSS VARIABLES - EDIT THESE TO CUSTOMIZE
   ============================================================ */
:root {
  /* Colors */
  --ink: #f2f2f2;
  --muted: #a6a6a6;
  --dark: #050505;
  --mint: #ffffff;

  /* Accent (faint pink) */
  --accent: #fcadff;
  --accent-glow: rgba(252, 173, 255, 0.14);
  --accent-line: rgba(252, 173, 255, 0.38);
  --accent-text: rgba(252, 173, 255, 0.85);

  /* Panel appearance */
  --card-opacity: 0.5;
  --card-hover-opacity: 0.8;
  --panel: rgba(10, 10, 10, var(--card-opacity));
  --line: rgba(255, 255, 255, 0.18);

  /* Layout */
  --radius: 8px;
  --wall-z: -900px;

  /* How far the backdrop is knocked back behind the panels. The no-WebGL
     fallback below reads this too, so the two stay in step; script.js writes it
     here from BACKDROP.dim. */
  --backdrop-dim: 0.62;

  /* Written every frame by script.js from the sphere's rotation, so the fallback
     backdrop moves with the panels instead of sitting still behind them. */
  --backdrop-shift-y: 0px;
  --backdrop-stars-opacity: 0.35;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--dark);
  color: var(--ink);
  font-family: "Archivo", system-ui, sans-serif;
  text-transform: lowercase;
}

body {
  cursor: auto;
  user-select: none;
}

body.dragging {
  cursor: grabbing;
}

button, a, input {
  font: inherit;
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   THREE.JS CANVAS
   ============================================================ */
#threeStage {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #050505;
  /* A canvas is a replaced element, so `inset: 0` alone does NOT stretch it: with
     width/height left auto it falls back to its intrinsic 300x150, and the
     gradient below then paints in the top-left corner. three.js sets inline
     sizes once it has a context, but on the no-WebGL path it never gets that
     far - so the size has to live here. */
  width: 100%;
  height: 100%;
  display: block;
}

/* Backdrop for machines with no usable WebGL context (script.js falls back to
   this): the same cloud sea under the same violet sky as the shader scene, built
   from gradients instead of pixels. Tune it here; .vignette overlays the top. */
#threeStage.backdrop-fallback {
  /* Taller than the viewport so the parallax can slide it without ever exposing
     an edge. Every gradient stop below is pre-shifted by that same 12%, so at
     rest the visible band (9.7%..90.3% of this taller box) is exactly the
     composition it would have been at 0%..100%. */
  top: -12%;
  bottom: auto;   /* explicit, so the box never depends on over-constraint rules */
  height: 124%;
  transform: translate3d(0, var(--backdrop-shift-y, 0px), 0);
  /* Un-dimmed on purpose: the same palette as BACKDROP in script.js, with the
     dimming left to the filter below so both paths are knocked back equally. */
  background:
    radial-gradient(120% 16% at 50% 58.9%, rgba(217, 127, 214, 0.3), transparent 74%),
    linear-gradient(
      to bottom,
      #150b26 9.7%,
      #1d1033 37.1%,
      #3b2159 50%,
      #6f4489 55.6%,
      #a86ab8 58.9%,
      #8a67c0 63.7%,
      #4a2f74 75.8%,
      #261640 90.3%);
  filter: brightness(var(--backdrop-dim, 0.62));
}

/* Star field for the no-webgl backdrop. The shader keeps its stars in the sky and
   lets the cloud deck hide the rest; this is the CSS equivalent - a tiled field
   masked off before the cloud line, riding the same parallax.
   Hidden unless the canvas above it has fallen back, which is what the
   adjacent-sibling rule at the bottom does. */
.backdrop-stars {
  display: none;
  position: fixed;
  inset: -12% 0;
  z-index: 1;
  pointer-events: none;
  background-repeat: repeat;
  background-size: 512px 512px;
  /* Elements of this box: stars full to 37%, gone by 55% - i.e. clear of the
     horizon, which sits at 58.9%. */
  mask-image: linear-gradient(to bottom, #000 0%, #000 37%, transparent 55%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 37%, transparent 55%);
  opacity: var(--backdrop-stars-opacity, 0.35);
  filter: brightness(var(--backdrop-dim, 0.62));
  transform: translate3d(0, var(--backdrop-shift-y, 0px), 0);
}

#threeStage.backdrop-fallback + .backdrop-stars {
  display: block;
}

/* ============================================================
   VIGNETTE OVERLAY
   ============================================================ */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  box-shadow:
    inset 0 0 160px rgba(0, 0, 0, 0.82),
    inset 0 0 240px rgba(252, 173, 255, 0.045);
}

/* ============================================================
   CUSTOM CURSOR
   ============================================================ */
.cursor {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 60;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(248, 243, 234, 0.78);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 22px rgba(255, 255, 255, 0.18);
  transition: width 0.16s ease, height 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

/* Crosshair lines */
.cursor::before,
.cursor::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(248, 243, 234, 0.78);
  transform: translate(-50%, -50%);
}

.cursor::before {
  width: 10px;
  height: 1px;
}

.cursor::after {
  width: 1px;
  height: 10px;
}

.cursor.locked {
  width: 38px;
  height: 38px;
  border-color: var(--accent);
  box-shadow: 0 0 34px rgba(252, 173, 255, 0.30);
}

body.custom-cursor-enabled {
  cursor: none;
}

body.custom-cursor-enabled .cursor {
  display: block;
}

body:not(.custom-cursor-enabled) .cursor {
  display: none;
}

/* ============================================================
   HUD - 3D PERSPECTIVE CONTAINER
   ============================================================ */
.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  perspective: 1120px;
  perspective-origin: 50% 50%;
}

/* ============================================================
   SPHERE - 3D ROTATING CONTAINER
   ============================================================ */
.sphere {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1px;
  height: 1px;
  transform-style: preserve-3d;
  transform: translateZ(var(--zoom-z, 0px)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, deg));
  transition: transform 0.08s linear;
}

/* ============================================================
   PANELS (CARDS) - BASE STYLES
   ============================================================ */
.panel {
  position: absolute;
  width: min(430px, 80vw);
  min-height: 210px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 26px 80px rgba(0,0,0,0.26);
  transform-style: preserve-3d;
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  pointer-events: auto;
  overflow: hidden;
  filter: blur(1.2px);
  transition: filter 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.panel > * {
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 10px rgba(0,0,0,0.38);
}

/* Focused/hovered panel */
.panel.is-near {
  border-color: var(--accent-line);
  box-shadow: 0 0 34px var(--accent-glow), 0 26px 80px rgba(0,0,0,0.42);
  filter: blur(0);
  background: rgba(10, 10, 10, var(--card-hover-opacity));
}

.panel-title {
  margin: 0 0 14px;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  color: var(--accent-text);
}

/* ============================================================
   CREDITS PANEL (inside music player)
   ============================================================ */
.credits-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  right: 0;
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 18px 40px rgba(0,0,0,0.32);
}

.credits-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.credit-item {
  white-space: nowrap;
}

.credit-item strong {
  color: var(--ink);
  font-weight: 600;
}

/* ============================================================
   IDENTITY PANEL (Home)
   ============================================================ */
.identity {
  width: min(560px, 86vw);
  height: auto;
  padding: 22px 28px 20px;
}

.identity h1 {
  margin: 0;
  font-size: clamp(32px, 13vw, 64px);
  line-height: 0.78;
  letter-spacing: 0;
  text-shadow: 0 0 28px rgba(252,173,255,0.20), 0 0 28px rgba(255,255,255,0.12);
}

.discord-shell {
  display: flex;
  align-items: center;
  gap: 14px;
}

.identity .discord-shell {
  margin-top: 18px;
}

.avatar-wrap {
  position: relative;
  flex: 0 0 auto;
}

.discord-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #eeeeee;
}

.status-dot {
  position: absolute;
  right: 1px;
  bottom: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #8e8e93;
  border: 3px solid #090b12;
}

.discord-name {
  font-size: 1.35rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.discord-status,
.discord-activity {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.92rem;
}

.status-emoji {
  height: 1.05em;
  width: auto;
  margin-right: 4px;
  vertical-align: -0.18em;
}

/* ============================================================
   LINKS PANEL (Socials)
   ============================================================ */
.link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.portal-link {
  min-height: 54px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.portal-link:hover {
  transform: translateY(-2px);
  border-color: var(--accent-line);
  background: rgba(252, 173, 255, 0.06);
}

/* ============================================================
   MUSIC PLAYER PANEL
   ============================================================ */
.player-panel {
  position: relative;
  width: min(390px, 82vw);
  min-height: 520px;
  background: var(--panel);
  overflow: visible;
}

.player-panel.is-near {
  background: rgba(10, 10, 10, var(--card-hover-opacity));
}

/* "Now playing" bars, top-right of the panel. Only animating while audio is
   actually running, so they double as proof the element is producing sound. */
.player-panel .equalizer {
  position: absolute;
  top: 24px;
  right: 22px;
  height: 13px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.player-panel .equalizer.active {
  opacity: 1;
}

.equalizer i {
  width: 3px;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transform-origin: 50% 100%;
  transform: scaleY(0.22);
}

.equalizer.active i {
  animation: eq-bars 900ms ease-in-out infinite;
}

.equalizer.active i:nth-child(2) {
  animation-delay: 150ms;
}

.equalizer.active i:nth-child(3) {
  animation-delay: 320ms;
}

@keyframes eq-bars {
  0%, 100% { transform: scaleY(0.22); }
  50%      { transform: scaleY(1); }
}

/* Album cover */
.cover-frame {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 18px 40px rgba(0,0,0,0.48);
}

.cover-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 58%, rgba(0,0,0,0.76));
}

/* Track info */
.track-meta {
  margin-top: 16px;
}

.music-title {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.15;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
  max-width: 100%;
}

.music-title span {
  display: inline-block;
  min-width: 100%;
}

.music-artist {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Transient player feedback: "no audio source yet", "skipping"... */
.player-note {
  margin: 8px 0 0;
  color: var(--accent-text);
  font-size: 0.76rem;
  line-height: 1.35;
}

.player-note:empty {
  display: none;
}

/* Time display */
.time-row,
.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 7px;
}

/* Range sliders (seek + volume) */
.range {
  width: 100%;
  height: 4px;
  margin: 14px 0 0;
  appearance: none;
  border-radius: 999px;
  /* --fill is set from script.js so both sliders show how far along they are */
  background-image: linear-gradient(
    90deg,
    var(--accent) 0,
    var(--accent) var(--fill, 0%),
    rgba(255,255,255,0.2) var(--fill, 0%),
    rgba(255,255,255,0.2) 100%
  );
  cursor: pointer;
}

.range::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(252, 173, 255, 0.16);
}

.range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
}

/* Transport controls */
.controls {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  gap: 10px;
  margin-top: 16px;
}

.control-btn {
  min-height: 46px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.06);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}

.control-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.06);
  transform: translateY(-1px);
}

.control-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.control-btn.primary {
  background: var(--ink);
  color: #05060b;
  font-weight: 800;
}

.control-btn.primary:hover {
  background: #fff;
  box-shadow: 0 0 24px var(--accent-glow);
}

.control-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.control-btn.icon {
  display: grid;
  place-items: center;
}

/* Shuffle / Loop mode buttons */
.mode-btn {
  gap: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.58;
}

.mode-btn.active {
  opacity: 1;
  color: #050505;
  background: #f2f2f2;
  border-color: #f2f2f2;
  box-shadow: 0 0 18px var(--accent-glow);
}

/* Loop cycled to "this track only" - badge tells it apart from looping all */
.mode-btn.mode-one {
  position: relative;
}

.mode-btn.mode-one::after {
  content: "1";
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 0.6rem;
  font-weight: 800;
  line-height: 1;
}

/* ============================================================
   BOTTOM DOCK NAVIGATION
   ============================================================ */
.dock {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(252, 173, 255, 0.18);
  border-radius: 999px;
  background: rgba(10, 7, 10, 0.72);
  backdrop-filter: blur(16px);
  box-shadow: 0 0 30px rgba(252, 173, 255, 0.10), inset 0 0 20px rgba(252, 173, 255, 0.04);
}

.dock button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.dock svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dock button:hover,
.dock button.active {
  color: #05060b;
  background: var(--mint);
  box-shadow: 0 0 22px rgba(252, 173, 255, 0.30);
}

/* ============================================================
   PRELOAD / ENTER SCREEN
   ============================================================ */
.preload {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 50%, rgba(252, 173, 255, 0.09), transparent 28%),
    #050505;
  transition: opacity 0.6s ease, transform 0.6s ease;
  overflow: hidden;
}

.preload.hidden {
  opacity: 0;
  transform: scale(1.03);
  pointer-events: none;
}

.enter-card {
  position: relative;
  width: min(520px, calc(100vw - 34px));
  min-height: 320px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 30px;
  background: rgba(255,255,255,0.035);
  box-shadow: 0 30px 90px rgba(0,0,0,0.62), 0 0 90px rgba(252, 173, 255, 0.06);
  backdrop-filter: blur(22px);
  text-align: center;
  display: grid;
  align-content: center;
  overflow: hidden;
  perspective: 620px;
  perspective-origin: 50% 50%;
}

/* Glass floor effect */
.enter-card::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  transform: perspective(520px) rotateX(58deg) scaleY(1.55);
  transform-origin: 50% 100%;
  pointer-events: none;
}

.enter-card h2 {
  position: relative;
  margin: 0 0 12px;
  font-size: 2.6rem;
  letter-spacing: 0;
  z-index: 2;
}

.preload-disclaimer {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 42;
  width: min(520px, calc(100vw - 34px));
  margin: 0;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  text-align: center;
}

/* Floating 3D decoration shapes */
.enter-mark {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  transform-style: preserve-3d;
  transform: rotateX(var(--enter-rx, 0deg)) rotateY(var(--enter-ry, 0deg));
  transition: transform 0.12s ease-out;
}

.enter-mark span {
  position: absolute;
  width: 104px;
  height: 72px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.035);
  box-shadow: 0 18px 40px rgba(0,0,0,0.32);
  pointer-events: none;
}

.enter-mark span:nth-child(1) {
  left: 32px;
  top: 54px;
  transform: translateZ(-70px) rotateY(28deg) rotateZ(-8deg);
}

.enter-mark span:nth-child(2) {
  right: 34px;
  top: 62px;
  transform: translateZ(-95px) rotateY(-28deg) rotateZ(7deg);
}

.enter-mark span:nth-child(3) {
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%) translateZ(-60px) rotateX(18deg);
  width: 132px;
  height: 58px;
}

.enter-btn {
  position: relative;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius);
  background: #f2f2f2;
  color: #05060b;
  cursor: pointer;
  font-weight: 800;
  text-transform: lowercase;
  letter-spacing: 0.12em;
  transition: background 0.18s ease;
}

.enter-btn:hover {
  background: #fff;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 740px) {
  .hud {
    perspective: 760px;
  }

  .panel {
    width: min(330px, 84vw);
    padding: 18px;
  }

  .identity {
    width: min(360px, 86vw);
    min-height: 250px;
  }

  .link-grid,
  .controls {
    grid-template-columns: 1fr;
  }

  .player-panel {
    min-height: 470px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sphere {
    transition: none;
  }

  .portal-link,
  .control-btn {
    transition: none;
  }

  /* Still visible feedback, just calmer */
  .equalizer.active i {
    animation-duration: 2.4s;
  }
}
