/* ════════════════════════════════════════════════════════════
   app/style.css  ·  Radio Frartma  ·  Grid 7×3 pantalla completa
   ════════════════════════════════════════════════════════════ */

:root {
  --accent: #0099ff;
  --bg: #07061a;
  --bg2: #0d0b28;
  --text: #ece9ff;
  --text-dim: rgba(236, 233, 255, .5);
  --border: rgba(0, 153, 255, .13);
  --hdr-h: 58px;
  --ftr-h: 36px;
  --np-h: 52px;
  /* barra now-playing */
  --nav-h: 34px;
  /* barra flechas / dots */
  --cols: 6;
  --rows: 3;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
}

img {
  display: block;
}

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 153, 255, .25);
  border-radius: 99px;
}

/* ── Fondos ── */
#blur-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 55% at 8% 12%, rgba(0, 80, 230, .22) 0%, transparent 65%),
    radial-gradient(ellipse 65% 80% at 90% 85%, rgba(0, 30, 180, .18) 0%, transparent 65%),
    radial-gradient(ellipse 50% 50% at 50% 50%, rgba(5, 3, 30, .85) 0%, transparent 80%);
}



/* ── HEADER ── */
#siteHeader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--hdr-h);
  z-index: 200;
  background: rgba(7, 6, 26, .92);
  backdrop-filter: blur(22px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.logo-area {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.logo-area img {
  max-height: 42px;
  max-width: 185px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: .92;
  transition: opacity .2s;
}

.logo-area img:hover {
  opacity: 1;
}

.logo-txt {
  font-family: 'Rubik', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  background: linear-gradient(120deg, #fff 20%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Search */
.hdr-search-wrap {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 30px;
  overflow: hidden;
  transition: width .3s ease;
  width: 38px;
  height: 38px;
}

.hdr-search-wrap.open {
  width: min(270px, 46vw);
  background: rgba(255, 255, 255, .1);
}

.hdr-search-btn {
  min-width: 38px;
  height: 38px;
  background: transparent;
  color: var(--text-dim);
  font-size: .9rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .2s;
}

.hdr-search-btn:hover {
  color: var(--text);
}

.hdr-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: .86rem;
  padding: 0 10px 0 0;
  width: 0;
}

.hdr-search-wrap.open .hdr-search-input {
  width: 100%;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .1);
  color: var(--text-dim);
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, .15);
  color: var(--text);
}

/* ── MAIN ── */
#mainGrid {
  position: fixed;
  top: var(--hdr-h);
  bottom: var(--ftr-h);
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── NOW PLAYING BAR ── */
.now-playing {
  height: var(--np-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* centrado horizontal */
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 6, 26, .6);
  backdrop-filter: blur(12px);
  gap: 16px;
  position: relative;
  /* para posicionar controles a la derecha */
}

.np-texts {
  text-align: center;
  /* texto centrado */
  min-width: 0;
}

.np-texts h2 {
  font-family: 'Rubik', sans-serif;
  font-size: clamp(.82rem, 1.6vw, 1.1rem);
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(120deg, #fff 20%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: opacity .35s;
}

.np-texts p {
  font-size: clamp(.6rem, 1vw, .75rem);
  color: var(--text-dim);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity .35s;
}

.np-controls {
  position: absolute;
  right: 20px;
  /* controles fijos a la derecha */
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.np-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 153, 255, .4);
  transition: background .2s, transform .15s;
}

.np-btn:hover {
  background: #007acc;
  transform: scale(1.07);
}

.np-dot-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.np-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background .3s;
}

.np-dot.playing {
  background: #00e676;
  animation: dotPulse .9s infinite;
}

.np-dot.buffering {
  background: #ffb300;
  animation: dotPulse .5s infinite;
}

.np-dot.error {
  background: #ff4466;
}

.np-dot.paused {
  background: var(--text-dim);
}

@keyframes dotPulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .3
  }
}

.np-status {
  font-size: .7rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ── GRID NAV (flechas + dots) ── */
.grid-nav {
  height: var(--nav-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 12px;
}

.nav-arrow {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  color: var(--text-dim);
  font-size: .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}

.nav-arrow:hover {
  background: rgba(0, 153, 255, .25);
  color: #fff;
  border-color: rgba(0, 153, 255, .5);
}

.nav-arrow:disabled {
  opacity: .25;
  cursor: default;
}

.page-dots {
  display: flex;
  gap: 7px;
  align-items: center;
}

.page-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  border: none;
  cursor: pointer;
  transition: all .2s;
  padding: 0;
}

.page-dot.active {
  background: var(--accent);
  width: 20px;
  border-radius: 4px;
}

/* ── GRID WRAPPER ── */
.radio-grid-wrap {
  flex: 1;
  overflow: hidden;
  /* nunca desborda */
  display: flex;
  align-items: center;
  /* centra verticalmente */
  justify-content: center;
  /* centra horizontalmente */
  padding: 6px 14px 8px;
  min-height: 0;
  max-width: 100%;
}

.radio-grid {
  display: grid;
  /* Columnas con ancho fijo calculado por JS → --cell-size */
  grid-template-columns: repeat(var(--cols), var(--cell-size, 1fr));
  grid-auto-rows: var(--cell-size, auto);
  /* filas = ancho → cuadrado */
  gap: var(--cell-gap, clamp(5px, .8vw, 12px));
  /* Sin width/height 100% — el grid toma exactamente el tamaño de sus celdas */
  overflow: visible;
}

/* ── TARJETA ── */
.r-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  cursor: pointer;
  transition: transform .22s;
  overflow: visible;
  /* glow visible */
  padding: 2px;
  /* El tamaño de la celda lo fija el grid (--cell-size) */
}

.r-card:hover {
  transform: translateY(-3px);
}

.r-img-wrap {
  /* Cuadrado garantizado: width = 100% de la celda, aspect-ratio lo hace cuadrado */
  width: calc(100% - 4px);
  /* descontar el padding del r-card */
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  border-radius: clamp(7px, 1vw, 13px);
  overflow: hidden;
  border: 2.5px solid transparent;
  background: var(--bg2);
  position: relative;
  transition: border-color .3s, box-shadow .3s, border-radius .35s, transform .3s cubic-bezier(.34, 1.56, .64, 1);
}

.r-img-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(40%) brightness(.87);
  transition: filter .25s;
  user-select: none;
  -webkit-user-drag: none;
}

.r-card:hover .r-img-wrap {
  border-color: rgba(0, 153, 255, .45);
  box-shadow: 0 6px 22px rgba(0, 153, 255, .22);
}

.r-card:hover .r-img-wrap img {
  filter: grayscale(0%) brightness(1.08);
}

/* Estados */
.r-card.selected .r-img-wrap {
  border-color: #f5c518;
  border-radius: 50%;
  /* El glow en el wrapper — r-card ya no tiene overflow:hidden */
  box-shadow: 0 0 0 3px rgba(245, 197, 24, .25), 0 0 22px rgba(245, 197, 24, .6);
  transform: scale(0.75);
  animation: glowCard 2s ease-in-out infinite;
}

.r-card.selected .r-img-wrap img {
  filter: grayscale(0%) brightness(1.12);
}

.r-card.playing .r-img-wrap {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 153, 255, .2), 0 0 18px rgba(0, 153, 255, .5);
}

.r-card.buffering .r-img-wrap {
  border-color: #00e676;
  animation: bufPulse .7s infinite;
}

.r-card.error .r-img-wrap {
  border-color: #ff4466;
}

@keyframes glowCard {

  0%,
  100% {
    box-shadow: 0 0 0 2px rgba(245, 197, 24, .3), 0 0 14px rgba(245, 197, 24, .45);
  }

  50% {
    box-shadow: 0 0 0 4px rgba(245, 197, 24, .5), 0 0 30px rgba(245, 197, 24, .8);
  }
}

@keyframes bufPulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .55
  }
}


.r-name {
  font-size: clamp(.48rem, .75vw, .7rem);
  font-weight: 500;
  text-align: center;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  padding: 0 2px;
  transition: color .2s;
  flex-shrink: 0;
  line-height: 1.2;
}

.r-card:hover .r-name {
  color: var(--text);
}

/* Skeletons */
.skel-img {
  width: calc(100% - 4px);
  aspect-ratio: 1/1;
  flex-shrink: 0;
  border-radius: clamp(7px, 1vw, 13px);
  animation: skelP 1.5s ease-in-out infinite;
}

.skel-name {
  display: block;
  height: .6em;
  width: 65%;
  background: rgba(255, 255, 255, .07);
  border-radius: 4px;
  animation: skelP 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes skelP {

  0%,
  100% {
    background: rgba(255, 255, 255, .07)
  }

  50% {
    background: rgba(255, 255, 255, .14)
  }
}

/* ── FOOTER ── */
#siteFooter {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--ftr-h);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 3, 22, .8);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  font-size: clamp(.65rem, 1vw, .8rem);
  color: var(--text-dim);
  text-align: center;
}

#siteFooter a {
  color: var(--accent);
}

/* ── SHARE MODAL ── */
.share-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-modal.hidden {
  display: none;
}

.share-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 20, .82);
  backdrop-filter: blur(7px);
  cursor: pointer;
}

.share-card {
  position: relative;
  z-index: 1;
  background: rgba(9, 6, 84, .97);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  width: min(380px, 92vw);
  box-shadow: 0 20px 60px rgba(0, 0, 200, .3);
  animation: popIn .3s ease;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(.93) translateY(14px)
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0)
  }
}

.share-card h3 {
  font-family: 'Rubik', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  color: #f5c518;
  margin-bottom: 6px;
}

.share-card>p {
  font-size: .83rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.share-url-box {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.share-url-box input {
  flex: 1;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .8rem;
  outline: none;
}

#btnCopyUrl {
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: .9rem;
  transition: background .2s;
}

#btnCopyUrl:hover {
  background: #007acc;
}

.share-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  font-size: .84rem;
  font-weight: 500;
  color: #fff;
  transition: opacity .2s, transform .2s;
}

.share-btn:hover {
  opacity: .9;
  transform: scale(1.03);
}

.share-btn.wa {
  background: #25D366;
}

.share-btn.fb {
  background: #1877F2;
}

.share-btn.tw {
  background: #000;
  border: 1px solid #333;
}

.share-btn.tg {
  background: #0088cc;
}

.share-close {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  color: var(--text-dim);
  font-size: .9rem;
  transition: all .2s;
}

.share-close:hover {
  background: rgba(255, 255, 255, .16);
  color: #fff;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 50px;
  right: 18px;
  z-index: 700;
  background: var(--bg2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: .84rem;
  box-shadow: 0 8px 24px rgba(0, 0, 200, .3);
  transition: all .3s;
  pointer-events: none;
}

.toast.hidden {
  opacity: 0;
  transform: translateY(8px);
}

.toast.ok {
  border-color: #00e676;
}

.toast.err {
  border-color: #ff4466;
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE — breakpoints combinando ancho + orientación
   Las tarjetas siempre son cuadradas gracias a aspect-ratio:1/1
   ════════════════════════════════════════════════════════════ */

/* Desktop grande ≥1400px — 6×3 */
@media (min-width: 1400px) {
  :root {
    --cols: 6;
    --rows: 3;
  }
}

/* Desktop normal 1101–1399px — 7×3 (por defecto en :root) */

/* Desktop mediano 769–1100px — 5×4 */
@media (max-width: 1100px) and (min-width: 769px) {
  :root {
    --cols: 5;
    --rows: 4;
    --hdr-h: 56px;
  }
}

/* ── Tablet & móvil portrait ── */

/* Tablet portrait 601–768px — 4×4 */
@media (max-width: 768px) and (orientation: portrait) {
  :root {
    --cols: 4;
    --rows: 4;
    --hdr-h: 52px;
    --np-h: 48px;
  }

  .header-inner {
    padding: 0 14px;
  }

  .logo-area img {
    max-height: 32px;
    max-width: 120px;
  }

  .np-controls {
    right: 14px;
  }
}

/* Móvil portrait grande 421–600px — 4 cols scroll */
@media (max-width: 600px) and (orientation: portrait) {
  :root {
    --cols: 4;
    --rows: 3;
    --hdr-h: 52px;
    --np-h: 44px;
    --nav-h: 30px;
    --ftr-h: 32px;
  }

  .now-playing {
    padding: 0 10px;
  }

  .np-controls {
    right: 10px;
  }

  .r-name {
    font-size: clamp(.44rem, 2.4vw, .65rem);
  }
}

/* ── Móvil ≤900px: scroll vertical nativo (portrait y landscape) ── */
@media (max-width: 900px) {
  .radio-grid-wrap {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    align-items: flex-start !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 16px;
  }

  .radio-grid {
    height: auto !important;
    overflow: visible !important;
    padding-bottom: 8px;
  }

  .grid-nav {
    display: none !important;
  }
}

/* Restaurar modo paginado en desktop */
@media (min-width: 901px) {
  .radio-grid-wrap {
    overflow-y: hidden !important;
    align-items: center !important;
  }

  .radio-grid {
    height: auto !important;
  }

  /* celdas cuadradas fijas, no fill */
  .grid-nav {
    display: flex !important;
  }
}

/* Móvil portrait pequeño ≤420px — 3×4 */
@media (max-width: 420px) and (orientation: portrait) {
  :root {
    --cols: 3;
    --rows: 4;
  }
}

/* ── Landscape: previene el desborde horizontal ── */

/* Tablet landscape 769–1100px — 5×3 */
@media (max-width: 1100px) and (min-width: 601px) and (orientation: landscape) {
  :root {
    --cols: 5;
    --rows: 3;
    --hdr-h: 52px;
    --np-h: 44px;
  }

  .header-inner {
    padding: 0 16px;
  }

  .logo-area img {
    max-height: 30px;
  }
}

/* Móvil landscape 361–600px — 5×2 sin desborde */
@media (max-width: 600px) and (orientation: landscape) {
  :root {
    --cols: 5;
    --rows: 2;
    --hdr-h: 44px;
    --ftr-h: 26px;
    --np-h: 36px;
    --nav-h: 26px;
  }

  html,
  body {
    overflow: hidden;
  }

  .header-inner {
    padding: 0 10px;
  }

  .logo-area img {
    max-height: 26px;
    max-width: 100px;
  }

  .np-controls {
    right: 8px;
  }

  .np-status {
    display: none;
  }

  .r-name {
    font-size: clamp(.4rem, 1.8vw, .56rem);
  }

  .radio-grid-wrap {
    padding: 4px 8px;
    overflow: hidden;
    /* el grid no desborda el wrapper */
    align-items: center;
  }

  /* El JS recalcula --cell-size desde el ancho real — siempre cuadrado */
}

/* Móvil landscape muy pequeño ≤360px — 4×2 */
@media (max-width: 360px) and (orientation: landscape) {
  :root {
    --cols: 4;
    --rows: 2;
  }
}