/*
 * meditest — estilos
 *
 * Arcade cósmico: fondo negro + texturas geométricas visibles,
 * bordes muy gruesos negros, bloques de color sólido,
 * mix-blend-mode: difference en texturas,
 * fuentes: Cormorant Garamond (títulos), MedievalSharp (cuerpo), Space Mono (UI)
 */

/* ── reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #050505;
  --surface: #111;
  --border: #000;
  --text: #fff;
  --text-dim: #666;
}

body {
  font-family: 'Space Mono', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
  user-select: none;
}

/* ── TEXTURAS DE FONDO (radiales + pattern con opacidades) ── */

/* capa 1: dots pattern con variación radial de opacidad */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.04;
  background: radial-gradient(ellipse at 50% 50%, #444 0%, transparent 65%);
}

/* capa 2: zigzag pattern con variación radial opuesta */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  mix-blend-mode: difference;
  opacity: 0.07;
  background-image:
    linear-gradient(135deg, #888 25%, transparent 25%),
    linear-gradient(225deg, #888 25%, transparent 25%),
    linear-gradient(45deg, #888 25%, transparent 25%),
    linear-gradient(315deg, #888 25%, transparent 25%);
  background-position: 8px 0, 8px 0, 0 0, 0 0;
  background-size: 16px 16px;
  /* radial mask opuesta: visible en bordes, desvanece en centro */
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, transparent 15%, #000 70%);
  mask-image: radial-gradient(ellipse at 50% 50%, transparent 15%, #000 70%);
}

/* ── escritorio ── */
#escritorio {
  width: 100vw;
  height: 100vh;
  position: relative;
  z-index: 1;
}

#iconos {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 9999;
}

/* ── icono de escritorio ── */
.icono {
  width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.15s;
}

.icono:hover { transform: translateY(-2px); }
.icono:active { transform: translateY(1px); }

.icono-img {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
}

.icono-img svg {
  width: 32px;
  height: 32px;
}

.icono-label {
  font-size: 0.4rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.icono:hover .icono-label { color: var(--text); }

/* ── ventana genérica ── */
.ventana {
  position: absolute;
  background: var(--surface);
  border: 6px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  animation: pop-in 0.2s ease-out;
  min-width: 280px;
  overflow: hidden;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.4);
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes pop-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.96) translateY(6px); }
}

.ventana.closing {
  animation: pop-out 0.15s ease-in forwards;
  pointer-events: none;
}

/* titlebar: thick top bar with close button */
.ventana-titlebar {
  display: flex;
  align-items: center;
  padding: 0 10px;
  height: 32px;
  background: #000;
  border-bottom: 5px solid #000;
  flex-shrink: 0;
  cursor: grab;
}

.ventana-titlebar:active { cursor: grabbing; }

.ventana-cerrar {
  width: 14px;
  height: 14px;
  background: #ff5f57;
  border: 2px solid #333;
  cursor: pointer;
  font-size: 0;
  transition: transform 0.1s;
  flex-shrink: 0;
}

.ventana-cerrar:hover { transform: scale(1.2); }
.ventana-cerrar:active { transform: scale(0.9); }

/* yellow = snap-to-grid toggle (middle button) */
.ventana-snap {
  width: 14px;
  height: 14px;
  background: #ffd700;
  border: 2px solid #333;
  cursor: pointer;
  font-size: 0;
  transition: transform 0.1s, background 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

.ventana-snap:hover { transform: scale(1.2); }
.ventana-snap:active { transform: scale(0.9); }
.ventana-snap.is-on { background: #fff; }
.ventana-snap.disabled { opacity: 0.3; cursor: default; }
.ventana-snap.disabled:hover { transform: none; }

/* green = fullscreen toggle (right button) */
.ventana-fullscreen {
  width: 14px;
  height: 14px;
  background: #00c853;
  border: 2px solid #333;
  cursor: pointer;
  font-size: 0;
  transition: transform 0.1s, background 0.15s;
  flex-shrink: 0;
}

.ventana-fullscreen:hover { transform: scale(1.2); }
.ventana-fullscreen:active { transform: scale(0.9); }
.ventana-fullscreen.is-on { background: #fff; }

/* animated transitions for fullscreen and snap */
.ventana.is-fullscreen,
.ventana.is-snapped {
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}

.ventana.is-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 99990 !important;
}


/* body */
.ventana-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* ══════════════════════════════════
   VENTANA CHAKRA
   ══════════════════════════════════ */

.ventana-chakra {
  width: clamp(360px, 55vw, 560px);
  height: clamp(360px, 50vh, 460px);
}

/* franja genérica */
.franja {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.franja + .franja {
  border-top: 5px solid var(--border);
}

/* franja 1: chakras — bloques de color */
.franja-chakras {
  padding: 0;
  overflow: visible;
}

.chakra-row {
  display: flex;
  width: 100%;
  height: 100%;
}

.chakra-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  border: none;
  border-right: 4px solid var(--border);
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: filter 0.15s;
  font-family: inherit;
  position: relative;
}

.chakra-btn { background: var(--ch-bg, #333); }
.chakra-btn:last-child { border-right: none; }
.chakra-btn:hover { filter: brightness(1.15); }

.chakra-btn.selected {
  background: #fff;
}

.chakra-btn svg {
  width: 70%;
  height: 70%;
  max-width: 48px;
  max-height: 48px;
}

/* franja 2: color */
.franja-color {
  transition: background 0.35s ease;
  position: relative;
}

.color-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  z-index: 1;
}

.color-nombre {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(1.2rem, 3.5vw, 1.8rem);
  font-weight: 700;
  text-transform: uppercase;
  color: #000;
  letter-spacing: 4px;
}

.color-freq {
  font-family: 'MedievalSharp', serif;
  font-size: clamp(0.65rem, 1.8vw, 0.85rem);
  color: rgba(0, 0, 0, 0.4);
}

/* franja 3: controles — 3 columnas */
.franja-controles {
  background: var(--surface);
  padding: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.ctrl-col {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  border-right: 4px solid var(--border);
}

.ctrl-col:last-child { border-right: none; }

.ctrl-btn {
  width: 100%;
  height: 100%;
  border: none;
  background: #1a1a1a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  font-family: 'Space Mono', monospace;
  color: var(--text);
}

.ctrl-btn:hover { background: #222; }

.ctrl-btn.active {
  background: #fff;
  color: #000;
}

.modo-btn {
  flex-direction: column;
  gap: 0;
}

.modo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modo-icon svg {
  width: 28px;
  height: 28px;
}

.modo-label:empty {
  display: none;
}

.play-btn { color: #fff; }
.play-btn svg { width: 22px; height: 22px; }

/* volumen */
.vol-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-dim);
}

.vol-slider {
  -webkit-appearance: none;
  appearance: none;
  width: clamp(50px, 10vw, 80px);
  height: 8px;
  background: #000;
  border: 2px solid #333;
  outline: none;
}

.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 3px solid #000;
  cursor: pointer;
}

.vol-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #fff;
  border: 3px solid #000;
  cursor: pointer;
  border-radius: 0;
}


/* no corner decorations */

/* ══════════════════════════════════
   VENTANA MEDITACIONES
   ══════════════════════════════════ */

.ventana-medi {
  width: clamp(260px, 36vw, 360px);
  height: clamp(280px, 42vh, 380px);
}

.ventana-medi .ventana-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* progress bar */
.medi-progress {
  height: 6px;
  background: #000;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  border-bottom: 2px solid var(--border);
}

.medi-progress-fill {
  height: 100%;
  background: #fff;
  width: 0%;
  transition: width 0.1s linear;
  pointer-events: none;
}

.medi-lista {
  list-style: none;
  flex: 2;
  overflow-y: auto;
  padding: 0;
  min-height: 0;
}

.medi-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 3px solid var(--border);
  gap: 8px;
}

.medi-item:hover {
  background: #1a1a1a;
}

.medi-item.active {
  color: #aaa;
  background: #0a1a1a;
  border-left: 5px solid #aaa;
}

.medi-name {
  font-family: 'MedievalSharp', serif;
  font-size: 0.8rem;
}

.medi-dur {
  font-family: 'Space Mono', monospace;
  font-size: 0.55rem;
  color: #fff;
  flex-shrink: 0;
}

.medi-controles {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  border-top: 5px solid var(--border);
  background: var(--surface);
  flex: 1;
}

.medi-controles .ctrl-col {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  border-right: 4px solid var(--border);
}

.medi-controles .ctrl-col:last-child { border-right: none; }

.medi-now {
  display: none;
}

.medi-play {
  width: 100%;
  height: 100%;
  border: none;
}

/* XY filter pads */
.filter-pad {
  width: 100%;
  height: 100%;
  position: relative;
  background: #0a0a0a;
  cursor: crosshair;
  overflow: hidden;
  touch-action: none;
}

/* subtle grid lines inside pad */
.filter-pad::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image:
    linear-gradient(rgba(255,255,255,0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.3) 1px, transparent 1px);
  background-size: 25% 25%;
}

.pad-cursor {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  /* default: LPF top-right (max freq, min Q) */
  left: 90%;
  top: 90%;
  box-shadow: 0 0 6px #fff;
}

.hpf-pad .pad-cursor {
  left: 10%;
  top: 90%;
}

.pad-label {
  position: absolute;
  bottom: 3px;
  right: 4px;
  font-size: 0.4rem;
  color: rgba(255,255,255,0.15);
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: none;
}

.hpf-pad .pad-label {
  right: auto;
  left: 4px;
}

/* no corner decorations for medi */


/* ══════════════════════════════════
   VENTANA VISUALIZER
   ══════════════════════════════════ */

.ventana-viz {
  width: clamp(320px, 45vw, 500px);
  height: clamp(280px, 40vh, 400px);
}

.viz-body {
  flex: 1;
  position: relative;
  background: #000;
  min-height: 0;
}

.viz-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.viz-overlay {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.viz-preset-name {
  font-size: 0.45rem;
  color: rgba(255, 255, 255, 0.3);
  text-transform: lowercase;
  letter-spacing: 0.5px;
}

.viz-no-audio {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'MedievalSharp', serif;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* ── scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #000; }
::-webkit-scrollbar-thumb { background: #333; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ── responsive ── */
@media (max-width: 600px) {
  body {
    overflow: auto;
    overflow-x: hidden;
  }

  #iconos {
    flex-direction: row;
    flex-wrap: wrap;
    top: 10px;
    left: 10px;
    gap: 10px;
  }

  /* only constrain non-fullscreen, non-snapped windows */
  .ventana:not(.is-fullscreen):not(.is-snapped) {
    min-width: 0;
    width: calc(100vw - 16px) !important;
    left: 8px !important;
  }

  /* bigger touch targets */
  .ventana-titlebar {
    height: 44px;
    padding: 0 12px;
    gap: 10px;
  }

  .ventana-cerrar,
  .ventana-snap,
  .ventana-fullscreen {
    width: 28px;
    height: 28px;
  }

  /* disable snap on mobile */
  .ventana-snap {
    opacity: 0.3;
    pointer-events: none;
  }

  .chakra-btn svg {
    width: 32px;
    height: 32px;
  }

  /* taller progress bar for touch */
  .medi-progress {
    height: 20px;
  }

  /* scroll inside fullscreen windows */
  .ventana.is-fullscreen .ventana-body {
    overflow-y: auto;
  }
}
