/* ==========================================================================
   Milkdrop Visualizer — Styles
   Fullscreen dark theme matching GLSL Playground conventions.
   All classes namespaced with md__ to avoid collisions.
   ========================================================================== */

/* ==========================================================================
   Canvas & Layout
   ========================================================================== */

.md__canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  background: #000;
}

.md__back {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: rgba(10, 10, 10, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.2s, border-color 0.2s, background 0.2s, opacity 0.4s;
}

.md__back:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(10, 10, 10, 0.8);
}

.md__back svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* ==========================================================================
   Utility Bar (top-right) — matches GLSL Playground
   ========================================================================== */

.md__utility {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
}

.md__utility-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(10, 10, 10, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.md__utility-btn:hover {
  color: #fff;
  background: rgba(10, 10, 10, 0.8);
  border-color: rgba(255, 255, 255, 0.4);
}

.md__utility-btn--active {
  color: #5ac8fa;
  border-color: rgba(90, 200, 250, 0.4);
  background: rgba(90, 200, 250, 0.1);
}

.md__utility-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* ==========================================================================
   Preset Navigation (top center)
   ========================================================================== */

.md__preset-nav {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: rgba(10, 10, 10, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  max-width: calc(100vw - 300px);
}

.md__preset-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.md__preset-nav-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.md__preset-nav-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.md__preset-name {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ==========================================================================
   Preset Panel (overlay)
   ========================================================================== */

.md__presets-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(0, 0, 0, 0.5);
  transition: opacity 0.2s;
}

.md__presets-overlay--hidden {
  opacity: 0;
  pointer-events: none;
}

.md__presets-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 150;
  width: 600px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.2s, transform 0.2s;
}

.md__panel--hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -48%);
}

.md__panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.md__panel-title {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.md__panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: color 0.2s;
}

.md__panel-close:hover {
  color: #fff;
}

.md__panel-close svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.md__presets-search {
  width: calc(100% - 32px);
  margin: 12px 16px 0;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 12px;
  color: #fff;
  outline: none;
}

.md__presets-search:focus {
  border-color: rgba(90, 200, 250, 0.5);
}

.md__presets-search::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.md__presets-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.md__presets-section-header {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
  padding: 10px 12px 4px;
  pointer-events: none;
  user-select: none;
}

.md__presets-item {
  padding: 8px 12px;
  border-radius: 6px;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.md__presets-item--featured {
  border-left: 2px solid rgba(90, 200, 250, 0.3);
}

.md__presets-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
}

.md__presets-credits {
  flex-shrink: 0;
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 10px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.3);
}

.md__presets-credits a {
  color: rgba(90, 200, 250, 0.6);
  text-decoration: none;
}

.md__presets-credits a:hover {
  color: #5ac8fa;
  text-decoration: underline;
}

/* ==========================================================================
   Player Bar (bottom) — matches GLSL Playground
   ========================================================================== */

.md__player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 120;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  transition: height 0.3s ease;
  overflow: hidden;
}

.md__player--collapsed {
  height: 48px;
}

.md__player--expanded {
  height: 400px;
}

.md__player-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 16px;
}

.md__player-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.md__player-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.md__player-btn--play {
  width: 36px;
  height: 36px;
  border-color: #5ac8fa;
  color: #5ac8fa;
}

.md__player-btn--play:hover {
  background: rgba(90, 200, 250, 0.1);
}

.md__player-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: currentColor;
  stroke-width: 0;
}

.md__player-track {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.md__player-track-name {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.md__player-time {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.3);
  min-width: 70px;
  text-align: right;
  flex-shrink: 0;
}

.md__player-volume {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.md__player-volume svg {
  width: 14px;
  height: 14px;
  stroke: rgba(255, 255, 255, 0.5);
  fill: rgba(255, 255, 255, 0.5);
  stroke-width: 0;
}

.md__player-volume-slider {
  width: 70px;
  height: 3px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
}

.md__player-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.md__player-volume-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
}

.md__player-expand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: color 0.2s, transform 0.3s;
  flex-shrink: 0;
}

.md__player-expand:hover {
  color: #fff;
}

.md__player-expand svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* Progress bar */
.md__player-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: height 0.15s;
}

.md__player-progress:hover {
  height: 4px;
}

.md__player-progress-fill {
  height: 100%;
  background: #5ac8fa;
  width: 0;
  transition: width 0.1s linear;
}

.md__player-progress:hover .md__player-progress-fill {
  background: #ff3cac;
}

/* Expanded body */
.md__player-body {
  display: flex;
  flex-direction: column;
  height: calc(100% - 48px);
  padding: 12px 16px;
  gap: 8px;
}

.md__player-spectrum {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 60px;
  flex-shrink: 0;
}

.md__player-spectrum-bar {
  flex: 1;
  background: linear-gradient(to top, #5ac8fa, #ff3cac);
  border-radius: 1px 1px 0 0;
  min-height: 2px;
  transition: height 0.08s ease-out;
}

.md__playlist-header {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 0;
}

.md__playlist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.md__playlist-item {
  padding: 8px 10px;
  border-radius: 4px;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.md__playlist-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
}

.md__playlist-item--active {
  background: rgba(90, 200, 250, 0.08);
  color: #5ac8fa;
}

.md__playlist-item--active::before {
  content: "\25B8 ";
}

/* ==========================================================================
   Drop Zone Overlay
   ========================================================================== */

.md__dropzone {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.md__dropzone--active {
  opacity: 1;
  pointer-events: all;
}

.md__dropzone-icon {
  width: 64px;
  height: 64px;
  stroke: #5ac8fa;
  fill: none;
  stroke-width: 1.5;
}

.md__dropzone-text {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
}

.md__dropzone-hint {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   Toast Messages
   ========================================================================== */

.md__toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 400;
  padding: 10px 20px;
  background: rgba(10, 10, 10, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.md__toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: all;
}

.md__toast--error {
  border-color: rgba(255, 60, 60, 0.4);
  color: #ff6b6b;
}

/* ==========================================================================
   Loading / WebGL Missing States
   ========================================================================== */

.md__loading {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  transition: opacity 0.5s;
}

.md__loading--hidden {
  opacity: 0;
  pointer-events: none;
}

.md__loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: #5ac8fa;
  border-radius: 50%;
  animation: md-spin 0.8s linear infinite;
}

@keyframes md-spin {
  to { transform: rotate(360deg); }
}

.md__loading-text {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
}

.md__no-webgl {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 32px;
  text-align: center;
}

.md__no-webgl-title {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.md__no-webgl-msg {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  max-width: 40ch;
  line-height: 1.6;
}

.md__no-webgl-link {
  color: #5ac8fa;
  text-decoration: none;
}

.md__no-webgl-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Keyboard Hints
   ========================================================================== */

.md__hints {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  gap: 12px;
  opacity: 0.4;
  transition: opacity 0.3s;
  pointer-events: none;
}

.md__hints:hover {
  opacity: 0.8;
}

.md__hint {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  gap: 4px;
}

.md__hint kbd {
  display: inline-block;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  font-size: 10px;
  line-height: 1;
  font-family: inherit;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .md__hints {
    display: none;
  }

  .md__preset-nav {
    max-width: calc(100vw - 200px);
  }

  .md__presets-panel {
    width: calc(100vw - 16px);
    max-height: 70vh;
    top: auto;
    bottom: 56px;
    left: 8px;
    transform: none;
    border-radius: 12px 12px 0 0;
  }

  .md__panel--hidden.md__presets-panel {
    transform: translateY(10px);
  }
}

@media (max-width: 480px) {
  .md__utility {
    top: 10px;
    right: 10px;
    gap: 4px;
  }

  .md__back {
    top: 10px;
    left: 10px;
    font-size: 0;
    padding: 8px;
  }

  .md__back svg {
    width: 16px;
    height: 16px;
  }

  .md__preset-nav {
    top: 10px;
    max-width: calc(100vw - 160px);
  }

  .md__player-volume {
    display: none;
  }

  .md__player-time {
    display: none;
  }
}

/* ==========================================================================
   Fun Hub Card Preview — Pulsing concentric rings
   ========================================================================== */

.preview-milkdrop {
  background: #050508;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Radial gradient core glow */
.preview-milkdrop__core {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 60, 172, 0.8), rgba(90, 200, 250, 0.4), transparent);
  filter: blur(30px);
  animation: mdCoreGlow 4s ease-in-out infinite;
}

@keyframes mdCoreGlow {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
}

/* Concentric rings */
.preview-milkdrop__ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid;
  animation: mdRingPulse 3s ease-out infinite;
}

.preview-milkdrop__ring--1 {
  width: 60px;
  height: 60px;
  border-color: rgba(255, 60, 172, 0.6);
  animation-delay: 0s;
}

.preview-milkdrop__ring--2 {
  width: 120px;
  height: 120px;
  border-color: rgba(90, 200, 250, 0.4);
  animation-delay: 0.5s;
}

.preview-milkdrop__ring--3 {
  width: 180px;
  height: 180px;
  border-color: rgba(48, 209, 88, 0.3);
  animation-delay: 1.0s;
}

.preview-milkdrop__ring--4 {
  width: 240px;
  height: 240px;
  border-color: rgba(255, 149, 0, 0.2);
  animation-delay: 1.5s;
}

.preview-milkdrop__ring--5 {
  width: 300px;
  height: 300px;
  border-color: rgba(255, 60, 172, 0.15);
  animation-delay: 2.0s;
}

@keyframes mdRingPulse {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Floating particle dots */
.preview-milkdrop__particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #5ac8fa;
  opacity: 0;
  animation: mdParticleFloat 6s ease-in-out infinite;
}

.preview-milkdrop__particle--1 {
  top: 30%;
  left: 20%;
  animation-delay: 0s;
  background: #ff3cac;
}

.preview-milkdrop__particle--2 {
  top: 60%;
  right: 25%;
  animation-delay: 1.5s;
  background: #5ac8fa;
}

.preview-milkdrop__particle--3 {
  bottom: 25%;
  left: 40%;
  animation-delay: 3s;
  background: #30d158;
}

.preview-milkdrop__particle--4 {
  top: 25%;
  right: 30%;
  animation-delay: 4.5s;
  background: #ff9500;
}

@keyframes mdParticleFloat {
  0%, 100% { opacity: 0; transform: translateY(0) scale(0.5); }
  20% { opacity: 0.8; transform: translateY(-10px) scale(1); }
  80% { opacity: 0.6; transform: translateY(-25px) scale(0.8); }
}

/* Vignette */
.preview-milkdrop__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, 0.6) 100%);
  pointer-events: none;
  z-index: 4;
}

/* Milkdrop logo text overlay */
.preview-milkdrop__label {
  position: relative;
  z-index: 3;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 0 20px rgba(90, 200, 250, 0.4), 0 0 40px rgba(255, 60, 172, 0.2);
}
