/* ---------- TV Guide (multi-channel grid, iptvnator-style) ---------- */
#guide { display: flex; flex-direction: column; }
#guide[hidden] { display: none; }
.guide-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0.8rem 3rem;
  padding: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
}
.guide-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  padding: 0 1.1rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  flex: 0 0 auto;
}
.guide-pills {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  align-items: center;
  justify-content: flex-start;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scroll-padding-inline: 1rem;
  mask-image: linear-gradient(to right, transparent, black 12px, black calc(100% - 12px), transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 12px, black calc(100% - 12px), transparent);
}
.guide-pills::-webkit-scrollbar { display: none; }
/* pills vides (provider down / pas de catégories) : 0px au lieu de
   bouffer la moitié de l'espace libre via flex:1 */
.guide-pills:empty { display: none; }
.guide-pills .pill {
  white-space: nowrap;
  font-size: 0.8rem;
  padding: 0.62rem 1.05rem;
  min-height: 44px;
  box-sizing: border-box;
  border-radius: 9999px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  flex: 0 0 auto;
  scroll-snap-align: center;
}
.guide-pills .pill:hover { color: var(--text-bright); }
.guide-pills .pill.active {
  color: #000;
  background: var(--accent);
  box-shadow: var(--shadow-glow);
}
.guide-head > .close,
.guide-head .g-nav-btn,
.guide-head #guide-view-toggle {
  position: static;
  top: auto;
  right: auto;
  margin: 0; /* tue la marge héritée de .overlay .close qui décalait ✕ de 16px */
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.05rem;
}
.guide-head > .close:hover,
.guide-head .g-nav-btn:hover,
.guide-head #guide-view-toggle:hover {
  color: var(--text-bright);
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
}
.guide-time-nav {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}
#guide-close {
  flex: 0 0 auto;
  position: relative;
  right: auto;
  top: auto;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--muted);
}
#guide-close:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--text-bright);
  transform: none;
}

.guide-body {
  overflow-x: auto;
  overflow-y: auto;
  padding: 0 0 2rem;
  flex: 1;
}
/* fixed channel column left, scrollable time track right */
.g-head, .g-row {
  display: flex;
  align-items: center;
  min-width: max-content;
}
.g-corn { flex: 0 0 200px; position: sticky; left: 0; z-index: 2; background: var(--bg); }
.g-head { position: sticky; top: 0; z-index: 4; background: var(--bg); height: 22px; margin-bottom: 10px; }
.g-track {
  position: relative;
  width: 1080px; /* 6 columns of 30 min = 3h window */
  flex: 0 0 1080px;
  height: 56px;
}
.g-head .g-track { height: 22px; }
.g-hour {
  position: absolute;
  top: 0;
  height: 22px;
  line-height: 14px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11.5px;
  color: #b0abba;
  white-space: nowrap;
}
.g-row { margin-bottom: 10px; }
.g-row:hover { background: rgba(255, 255, 255, 0.03); }
.g-ch {
  flex: 0 0 200px;
  position: sticky;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  background: var(--bg);
  min-width: 0;
}
.g-ch .ib {
  width: 44px;
  height: 44px;
  font-size: 12px;
  color: #cbbcff;
}
.g-ch span:last-child {
  font-size: 14px;
  font-weight: 600;
  line-height: 18px;
  color: #f2f0ec;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.g-track { height: 56px; }
.g-prog {
  position: absolute;
  top: 0;
  bottom: 0;
  margin-right: 6px;
  box-sizing: border-box;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 12px;
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  opacity: 0.5;
}
.g-prog.past { opacity: 0.5; }
.g-prog.cur {
  background: rgba(167, 139, 250, 0.2);
  border-color: rgba(167, 139, 250, 0.6);
  box-shadow: 0 0 24px -6px rgba(167, 139, 250, 0.55);
  opacity: 1;
}
.g-prog:hover {
  background: rgba(122, 92, 224, 0.45);
  border-color: var(--accent);
  opacity: 1;
}
.g-prog-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, rgba(167, 139, 250, 0), #a78bfa);
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.8);
}
.g-prog-t {
  font-size: 13.5px;
  line-height: 18px;
  font-weight: 600;
  color: #f2f0ec;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  white-space: nowrap;
}
.g-prog-h {
  display: block;
  font-size: 11px;
  line-height: 14px;
  color: #b0abba;
}
.g-now {
  position: absolute;
  top: -30px;
  left: 406px;
  padding: 3px 9px;
  border-radius: 9999px;
  background: #ff6b5e;
  color: #1b0a08;
  font-size: 11.5px;
  font-weight: 500;
  z-index: 3;
}
.g-nowline {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  opacity: 0.85;
  z-index: 3;
  pointer-events: none;
}

@media (max-width: 640px) {
  /* Mobile: 2 lignes — ligne 1: titre + toggle + ‹ › + croix (ordres
     explicites, sinon le titre order:1 chevauche la croix) ;
     ligne 2: pills pleine largeur */
  .guide-head {
    flex-wrap: wrap;
    border-radius: var(--radius-lg);
    row-gap: 0.15rem;
    margin: 0.5rem 0.6rem;
    padding: 0.25rem;
    gap: 0.15rem;
  }
  .guide-title { order: 1; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 0.82rem; padding: 0 0.7rem; min-height: 40px; }
  #guide-view-toggle, .guide-time-nav, #guide-close { order: 2; }
  .guide-pills { order: 3; flex: 1 1 100%; min-width: 0; }
} /* fin @media 640 */
