/* ============================================================
   Clon de watch.mattarmoa.com con embeds de Twitch
   Valores tomados (medidos) de la página original:
     - fondo:        #0b0b0e   (rgb 11,11,14)
     - texto:        #ecedf0   (rgb 236,237,240)
     - toolbar:      #121217   (rgb 18,18,23)
     - chat default: 340px     - toolbar: 40px
   Acento: morado Twitch (#9146ff) en lugar del verde Kick.
   ============================================================ */

:root {
  --bg: #0b0b0e;
  --text: #ecedf0;
  --toolbar-bg: #121217;
  --panel-bg: #18181b;          /* Twitch dark */
  --accent: #9146ff;            /* morado Twitch */
  --accent-hover: #a970ff;
  --border: rgba(255, 255, 255, 0.08);
  --muted: #adadb8;

  --chat-width: 25vw;           /* ≈ 3/12 de la pantalla (lo ajusta el handle) */
  --chat-min: 260px;
  --chat-max: 520px;
  --toolbar-h: 40px;
  --handle-w: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

/* ---------- Layout principal (mismo grid que la original) ---------- */
.app {
  display: grid;
  grid-template-columns: 1fr var(--chat-width);
  grid-template-rows: 1fr var(--toolbar-h);
  grid-template-areas:
    "player chat"
    "toolbar toolbar";
  height: 100vh;
  width: 100vw;
}

/* cuando el chat está oculto, el player ocupa todo */
.app.chat-hidden {
  grid-template-columns: 1fr 0;
}
.app.chat-hidden .chat-area { display: none; }

/* ---------- Reproductor ---------- */
.player-area {
  grid-area: player;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* VIDEO PRINCIPAL (Vidstack + hls.js): de fondo, ocupa toda el área */
.main-video {
  position: absolute;
  inset: 0;
}
.main-video media-player {
  width: 100%;
  height: 100%;
}
.main-video media-player video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* PLAYER DE TWITCH chico arriba-izquierda (≈1/12 del ancho): mantiene la view */
.twitch-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  width: calc(100vw / 12 * 3); /* triple: ≈3/12 (1/4) del ancho */
  min-width: 330px;
  aspect-ratio: 16 / 9;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
  background: #000;
}
.twitch-overlay iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---------- Chat ---------- */
.chat-area {
  grid-area: chat;
  position: relative;
  display: flex;
  flex-direction: row;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  min-width: 0;
}
.chat-frame {
  flex: 1;
  min-width: 0;
}
.chat-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* separador arrastrable */
.resize-handle {
  width: var(--handle-w);
  flex: 0 0 var(--handle-w);
  margin-left: calc(var(--handle-w) / -2);
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 5;
}
.resize-handle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background: transparent;
  transition: background 0.15s;
}
.resize-handle:hover::before,
.resize-handle:focus-visible::before,
.resize-handle.dragging::before {
  background: var(--accent);
}
.resize-handle:focus-visible { outline: none; }

/* ---------- Barra inferior ---------- */
.toolbar {
  grid-area: toolbar;
  height: var(--toolbar-h);
  background: var(--toolbar-bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  user-select: none;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toolbar-center { flex: 1; justify-content: center; }
.toolbar-label { font-size: 13px; color: var(--muted); }

.icon-btn {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: inline-flex;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }

/* botón Subscribe (morado Twitch) */
.subscribe-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.15s;
}
.subscribe-btn:hover { background: var(--accent-hover); }
.twitch-glitch { color: #fff; }

/* ---------- Switch tipo toggle ---------- */
.switch { position: relative; display: inline-flex; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 38px;
  height: 20px;
  border-radius: 999px;
  background: #3a3a44;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  padding: 2px;
}
.switch-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 2px rgba(145,70,255,0.5); }

/* ---------- Responsive: en pantallas angostas el chat va abajo ---------- */
@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 300px var(--toolbar-h);
    grid-template-areas:
      "player"
      "chat"
      "toolbar";
  }
  .app.chat-hidden {
    grid-template-rows: 1fr 0 var(--toolbar-h);
  }
  .chat-area { border-left: 0; border-top: 1px solid var(--border); }
  .resize-handle { display: none; }
}
