/* Albert Sans (fuente variable, 400–700), alojada en la propia web. Licencia: assets/fonts/OFL.txt */
@font-face {
  font-family: "Albert Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("assets/fonts/albert-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Albert Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("assets/fonts/albert-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --bg: #000000;
  --ink: #340856; /* texto y detalles sobre blanco: hover, selección y avisos */
  --fg: #fff;
  --live: #e91916;
  --radius: 16px;
}

* { box-sizing: border-box; }

/* Evita que la página se desplace lateralmente. Scroll vertical libre desde cualquier parte. */
html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-x: none;
}

body {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: visible;
  overscroll-behavior-x: none;
  background: var(--bg);
  color: var(--fg);
  font-family: "Albert Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Fondo fijo detrás de todo. Va en una capa aparte porque `background-attachment:
   fixed` se ignora en iOS y allí la imagen se estiraría a lo alto de la página. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg) url("assets/fondo-web.webp") center / cover no-repeat;
}

.page {
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
  padding: 48px 16px calc(32px + env(safe-area-inset-bottom, 0px));
}

/* En pantallas táctiles se bloquea el zoom y el desplazamiento lateral.
   El scroll vertical tiene que funcionar desde cualquier parte de la página. */
@media (pointer: coarse) {
  html {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-x: none;
    touch-action: pan-y pinch-zoom;
  }
  body {
    overflow-x: hidden;
    overflow-y: visible;
    overscroll-behavior-x: none;
    touch-action: pan-y;
  }
}

.profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 32px;
}

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 16px;
}

.name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.5;
}

.verified { flex: none; }

.bio {
  margin: 4px 0 0;
  font-size: 1rem;
  line-height: 1.5;
}

/* ---------- Columnas (REDES / CONTENIDO) ---------- */

/* Dos paneles que se deslizan en horizontal. El margen negativo devuelve al
   carril el ancho de la página: así el recorte del scroll no corta el hover
   (scale) ni el anillo de foco de los enlaces. */
.switcher {
  display: flex;
  gap: 24px;
  margin-top: 12px;
}

.switcher-tab {
  position: relative;
  padding: 4px 2px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .5;
  cursor: pointer;
  transition: opacity .15s ease;
}

.switcher-tab:hover { opacity: .8; }

.switcher-tab[aria-selected="true"],
.switcher-tab[aria-selected="true"]:hover { opacity: 1; }

/* Subrayado de la columna activa: no depende solo del color */
.switcher-tab::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transition: transform .2s ease;
}

.switcher-tab[aria-selected="true"]::after { transform: scaleX(1); }

.switcher-tab:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.columns {
  display: flex;
  margin-inline: -16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: none;
  touch-action: pan-x pan-y;
}

.columns::-webkit-scrollbar { display: none; }

.column {
  flex: 0 0 100%;
  min-width: 0;
  padding-inline: 16px;
  scroll-snap-align: start;
}

/* Al arrastrar con el ratón el imán estorba; al soltar se vuelve a activar */
.columns.is-dragging {
  scroll-snap-type: none;
  cursor: grabbing;
  user-select: none;
}

/* En pantallas táctiles se permite deslizar horizontalmente para cambiar entre columnas,
   pero el carril se mantiene siempre centrado. El scroll vertical sigue libre desde cualquier parte. */
@media (hover: none), (pointer: coarse) {
  .columns {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: none;
    touch-action: pan-x pan-y;
    scrollbar-width: none;
  }
  .columns::-webkit-scrollbar { display: none; }
}

.column > .group:last-child { margin-bottom: 0; }

.group { margin-bottom: 24px; }

.links {
  margin: 0;
  padding: 0;
  list-style: none;
}

.group h2 {
  margin: 0 0 16px;
  text-transform: uppercase;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: .01em;
}

.link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  margin-bottom: 16px;
  padding: 8px 64px;
  border: 2px solid var(--fg);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  transition: transform .15s ease, background-color .15s ease, color .15s ease;
}

.link:hover {
  background: var(--fg);
  color: var(--ink);
  transform: scale(1.02);
}

.link:active { transform: scale(.98); }

.link:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.link img {
  position: absolute;
  left: 8px;
  top: 50%;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  transform: translateY(-50%);
}

/* Icono dibujado en SVG (sigue el color del texto, también en hover) */
.link .link-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  padding: 6px;
  transform: translateY(-50%);
  transition: transform .2s ease;
}

.link:hover .link-icon { transform: translateY(-50%) rotate(-8deg) scale(1.1); }

.link-sub {
  font-size: 0.8125rem;
  font-weight: 400;
  opacity: .75;
}

.share {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 32px auto 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .5);
  background: rgba(255, 255, 255, .15);
  color: var(--fg);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background-color .15s ease;
}

.share:hover { background: rgba(255, 255, 255, .25); }

.share:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
}

.toast[hidden] { display: none; }

.group[hidden] { display: none; }

.video-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 8px;
  border: 2px solid var(--fg);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  transition: transform .15s ease, background-color .15s ease, color .15s ease;
}

/* Un fondo oscuro y translúcido por canal: se reconoce sin gritar */
.video-card[data-channel="main"] { background: rgba(255, 255, 255, .12); }

.video-card[data-channel="live"] { background: rgba(58, 16, 92, .85); }

.video-card[data-channel="raw"] { background: rgba(84, 84, 0, .9); }

.video-card:hover {
  background: var(--fg);
  color: var(--ink);
  transform: scale(1.02);
}

.video-card:active { transform: scale(.98); }

.video-card:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.video-thumb {
  position: relative;
  flex: none;
  width: 136px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 8px;
  background: #111;
}

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

.video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: .9;
  transition: opacity .15s ease;
}

.video-card:hover .video-play { opacity: 1; }

.video-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-right: 4px;
}

.video-channel {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  opacity: .7;
}

.video-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
}

.video-date {
  font-size: 0.8125rem;
  opacity: .7;
}

@media (max-width: 380px) {
  .video-thumb { width: 112px; }
  .video-title { font-size: 0.875rem; }
}

/* ---------- Página de error (404.html) ---------- */

.error-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.error-code {
  margin: 0 0 4px;
  font-size: 4.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.03em;
}

.error-page .bio { max-width: 32ch; }

/* ---------- Animaciones ---------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes pop {
  0% { opacity: 0; transform: scale(.6); }
  70% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

.avatar,
.error-code,
.name,
.bio,
.switcher,
.group > h2,
.link,
.video-card {
  /* backwards: oculto hasta que empieza; al acabar no bloquea el transform del hover */
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) backwards;
  animation-delay: calc(var(--i, 0) * 50ms);
}

.avatar { animation-name: pop; animation-duration: .6s; }

.avatar { transition: transform .3s ease; }
.avatar:hover { transform: rotate(-6deg) scale(1.05); }

.link img { transition: transform .2s ease; }
.link:hover img { transform: translateY(-50%) rotate(-8deg) scale(1.1); }

.video-thumb img { transition: transform .3s ease; }
.video-card:hover .video-thumb img { transform: scale(1.08); }
.video-card:hover .video-play { transform: translate(-50%, -50%) scale(1.15); }
.video-play { transition: opacity .15s ease, transform .2s ease; }

/* El botón ya está en el flujo de la página: no necesita transform propio. */
.share { animation: rise .5s .2s backwards; }

.toast:not([hidden]) { animation: toast-in .25s ease both; }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Los iconos blancos se invierten a negro cuando el botón se rellena de blanco */
.link .icon-mono { transition: transform .2s ease, filter .15s ease; }
.link:hover .icon-mono { filter: invert(1); }

/* Los iconos con fondo claro llevan un borde para no fundirse con el botón en hover */
.link .icon-framed { transition: transform .2s ease, box-shadow .15s ease; }
.link:hover .icon-framed { box-shadow: 0 0 0 2px var(--ink); }

/* ---------- Accesibilidad ---------- */

/* Texto solo para lectores de pantalla */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Con teclado, el foco se ve igual de claro que el hover */
.link:focus-visible,
.video-card:focus-visible {
  outline-width: 3px;
}

/* Quien pide más contraste ve el texto secundario sin atenuar */
@media (prefers-contrast: more) {
  .video-channel,
  .video-date { opacity: 1; }
  .switcher-tab[aria-selected="false"] { opacity: .8; }
  .share { background: var(--bg); border-color: var(--fg); }
}

/* Modo de alto contraste de Windows: usar los colores del sistema */
@media (forced-colors: active) {
  .link,
  .video-card,
  .share { border-color: ButtonText; }
  .link:hover,
  .video-card:hover {
    background: Highlight;
    color: HighlightText;
  }
  .link .icon-mono,
  .link:hover .icon-mono { filter: none; }
  .video-channel,
  .video-date { opacity: 1; }
  .verified path:first-child { fill: CanvasText; }
  /* El subrayado va como texto: el color de fondo se fuerza en este modo */
  .switcher-tab[aria-selected="true"] { text-decoration: underline; }
}

/* ---------- En directo ---------- */

.link-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--live);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.5;
  text-transform: uppercase;
}

.live-badge[hidden] { display: none; }

/* Vista previa del directo (columna CONTENIDO) */
.live-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 2px solid var(--fg);
  border-radius: var(--radius);
  background: #111;
}

.live-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  transition: transform .3s ease;
}

.live-frame:hover iframe { transform: scale(1.02); }

/* El enlace cubre el reproductor: cualquier clic lleva al canal */
.live-frame-link {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--radius) - 2px);
}

.live-frame-link:focus-visible {
  outline: 3px solid var(--fg);
  outline-offset: -5px;
}

/* Punto blanco que parpadea delante del texto */
.live-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: live-dot 1.2s ease-in-out infinite;
}

.live-viewers {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

/* Categoría (juego) y título del directo, bajo la etiqueta */
.live-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  margin-top: 2px;
}

.live-info[hidden] { display: none; }

.live-category {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.live-category:empty { display: none; }

.live-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.35;
  opacity: .8;
  overflow-wrap: anywhere;
}

@media (prefers-contrast: more) {
  .live-title { opacity: 1; }
}

.link.is-live {
  border-color: var(--live);
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) backwards, live-glow 2s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 50ms), 0s;
}

.link.is-live:hover { border-color: var(--live); }

@keyframes live-dot {
  50% { opacity: .3; }
}

@keyframes live-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(233, 25, 22, .55); }
  50% { box-shadow: 0 0 0 6px rgba(233, 25, 22, 0); }
}

@media (forced-colors: active) {
  .live-badge { border: 1px solid CanvasText; }
  .link.is-live { border-color: Highlight; border-width: 3px; }
  .live-frame { border-color: ButtonText; }
}

/* ---------- Selección de texto ---------- */

/* Blanco sobre negro, como el resto de la web, en lugar del azul del navegador */
::selection {
  background: var(--fg);
  color: var(--ink);
}

/* Dentro de un botón rellenado de blanco (hover), la selección se invierte */
.link:hover ::selection,
.video-card:hover ::selection {
  background: var(--ink);
  color: var(--fg);
}

/* En móvil, quitar el destello azul al tocar un enlace */
a,
button { -webkit-tap-highlight-color: transparent; }
