/* ==========================================
   theme.css — Digital Seba TV visual theme overrides and home carousel styling
   ========================================== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.streamdeck-theme {
  --bg: #06070b;
  --bg-elevated: rgba(21, 24, 34, 0.82);
  --surface: rgba(24, 28, 38, 0.94);
  --surface2: rgba(35, 40, 52, 0.88);
  --surface3: rgba(73, 84, 104, 0.82);
  --border: rgba(247, 248, 251, 0.13);
  --border2: rgba(247, 248, 251, 0.24);
  --text: #f7f8fb;
  --text2: rgba(247, 248, 251, 0.72);
  --text3: rgba(247, 248, 251, 0.48);
  --red: #ff0000;
  --red-dim: #cc0000;
  --accent: #35d6a4;
  --accent-bg: rgba(53, 214, 164, 0.13);
  --accent-glow: rgba(53, 214, 164, 0.42);
  --blue: #58b7ff;
  --font-ui: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 78% 6%, rgba(88, 183, 255, 0.19), transparent 32rem),
    radial-gradient(circle at 4% 42%, rgba(53, 214, 164, 0.12), transparent 26rem),
    var(--bg);
}

.tv-topbar {
  height: 72px;
  padding: 0 clamp(14px, 3vw, 44px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(6, 7, 11, 0.76);
  backdrop-filter: blur(24px);
}

.tv-brand {
  padding: 8px 12px;
}

.tv-badge {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 900;
}

.tv-icon-btn,
.tv-search .search-input,
.tv-now-playing {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.07);
}

.tv-search .search-input {
  height: 44px;
  border-radius: 999px;
  padding-right: 48px;
}

.tv-search {
  position: relative;
}

.tv-search .search-clear,
.tv-search .search-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: var(--text2);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.tv-search .search-clear:hover,
.tv-search .search-clear:focus-visible,
.tv-search .search-clear-btn:hover,
.tv-search .search-clear-btn:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text);
  outline: none;
}

.tv-search .search-clear:focus-visible,
.tv-search .search-clear-btn:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

.tv-now-playing {
  min-height: 42px;
  padding-inline: 14px;
  backdrop-filter: blur(18px);
}

#btn-chat {
  display: none;
}

body.is-watching #btn-chat {
  display: inline-flex;
}

#ctrl-chat.on {
  background: rgba(53, 214, 164, 0.16);
  color: var(--accent);
}

.tv-app {
  background: transparent;
}

.tv-main {
  overflow-y: auto;
  background: transparent;
}

body.is-watching .tv-main {
  overflow: hidden;
  background: #000;
}

.tv-guide {
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(180deg, rgba(20, 24, 34, 0.96), rgba(8, 10, 15, 0.98)),
    var(--bg);
  backdrop-filter: blur(24px);
}

.cat-label {
  color: var(--accent);
  letter-spacing: 0;
}

.ch-item {
  margin: 4px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.ch-item:hover,
.ch-item.active {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.11);
}

.ch-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.tv-player-shell {
  margin: 0;
  border-radius: 0;
}

body:not(.is-watching) .tv-player-shell {
  margin: 0 clamp(14px, 3vw, 34px);
  overflow: hidden;
  border-radius: 8px;
}

body.is-watching .tv-player-shell {
  min-height: 0;
}

body:not(.is-watching) .stage {
  border-radius: 8px;
}

.tv-browse {
  padding: clamp(14px, 3vw, 34px) clamp(14px, 3vw, 34px) 56px;
  gap: 34px;
  overflow: visible;
  flex: 0 0 auto;
}

.home-section {
  gap: 14px;
  position: relative;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-header .section-title {
  margin-bottom: 0;
}

.section-title {
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  font-weight: 800;
}

.carousel-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(170px, 18vw, 250px);
  grid-template-columns: none;
  gap: 16px;
  overflow-x: auto;
  margin: -12px -16px -8px;
  padding: 18px 16px 28px;
  scroll-padding-inline: 16px;
  scrollbar-width: none;
  cursor: grab;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
  user-select: none;
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

.carousel-track.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
}

.carousel-controls {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  /* border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px; */
  background: rgba(8, 8, 10, 0.94);
  box-shadow: 0 12px 28px #0000005C;
}

.carousel-controls.is-hidden {
  display: none;
}

.carousel-nav-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  background: #111;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.carousel-nav-btn:hover:not(:disabled),
.carousel-nav-btn:focus-visible {
  border-color: rgba(255, 255, 255, 0.32);
  background: #181818;
  color: #fff;
}

.carousel-nav-btn:disabled {
  cursor: default;
  opacity: 0.4;
}

.home-ch-card {
  min-width: 0;
  border-radius: 8px;
  position: relative;
  transform-origin: center;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.home-ch-card:hover {
  transform: translateY(-5px) scale(1.018);
}

.channel-card-thumb,
.wm-thumb {
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background:
    radial-gradient(circle at 76% 18%, rgba(88, 183, 255, 0.18), transparent 35%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.home-ch-card img,
.channel-card-thumb img,
.ch-logo-box--tile img {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

.ch-logo-box--tile {
  background: #ffffff;
}

.home-live-badge,
.channel-card-live {
  background: var(--red);
}

.home-ch-name,
.channel-card-title {
  font-weight: 800;
  letter-spacing: 0;
}

.channel-card-meta {
  color: var(--text2);
  font-weight: 700;
}

.watch-more {
  background: transparent;
}

.floating-search {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(86px, 14vh, 150px) 18px 24px;
  border: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(16px);
}

body.guide-searching .floating-search {
  display: flex;
}

.floating-search-shell {
  width: min(440px, 100%);
  display: grid;
  gap: 10px;
}

.floating-search-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.floating-search-head h2 {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0;
}

.floating-search-close {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(16, 18, 22, 0.94);
  color: var(--text2);
  cursor: pointer;
}

.floating-search-close:hover,
.floating-search-close:focus-visible {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  outline: 0;
}

.floating-search-input {
  border-radius: 12px;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.42);
}

.floating-search-input .search-input {
  height: 48px;
  border-radius: 12px;
  background: rgba(9, 11, 15, 0.96);
  border-color: rgba(255, 255, 255, 0.12);
  font-size: 1rem;
}

.floating-search-results {
  max-height: min(58vh, 520px);
  overflow-y: auto;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(5, 7, 10, 0.96);
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.46);
}

.floating-search-empty {
  padding: 20px 14px;
  color: var(--text3);
  font-size: 0.9rem;
  text-align: center;
}

.floating-search-result {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: 44px 1fr 18px;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 10px;
  padding: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.floating-search-result:hover,
.floating-search-result:focus-visible {
  outline: 0;
  background: rgba(255, 255, 255, 0.08);
}

.floating-search-result .ch-logo-box--guide {
  width: 44px;
  height: 44px;
}

.floating-search-result-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.floating-search-result-name {
  overflow: hidden;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.floating-search-result-meta {
  color: var(--text3);
  font-size: 0.76rem;
  font-weight: 700;
}

.floating-search-result-arrow {
  color: var(--text3);
}

.floating-search-result-arrow svg {
  width: 18px;
  height: 18px;
}

.wm-card {
  border-radius: 8px;
}

.focusable:focus-visible,
.channel-card:focus-visible,
.ch-item:focus-visible,
.wm-card:focus-visible,
.ctrl-btn:focus-visible,
.ctrl-qual-btn:focus-visible {
  outline: 0;
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.18),
    0 18px 44px rgba(0, 0, 0, 0.42);
}

/* Mobile and TV optimization layer */
@media (hover: none) and (pointer: coarse) {

  .app-nav-btn,
  .tv-brand,
  .carousel-nav-btn,
  .ctrl-btn,
  .ctrl-qual-btn,
  .toggle-offline-btn,
  .chat-close-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .home-ch-card,
  .ch-item,
  .wm-card {
    -webkit-tap-highlight-color: transparent;
  }
}

  @media (min-width: 1600px) and (min-height: 850px) and (hover: none),
  (min-width: 2200px) and (min-height: 1200px) {
    :root {
      --nav-h: 86px;
      --guide-w: 380px;
      --chat-w: 430px;
    }

    .tv-topbar {
      height: var(--nav-h);
      padding-inline: clamp(32px, 4vw, 76px);
    }

    .app-nav-btn,
    .tv-icon-btn {
      width: 58px;
      height: 58px;
    }

    .tv-brand .brand-logo {
      width: 42px;
      height: 42px;
      max-width: 42px;
      max-height: 42px;
      flex-basis: 42px;
    }

    .tv-search .search-input {
      height: 56px;
      font-size: 1.08rem;
    }

    .tv-now-playing {
      min-height: 52px;
      font-size: 1rem;
    }

    .tv-browse {
      padding: 44px clamp(42px, 5vw, 90px) 80px;
      gap: 46px;
    }

    .section-title {
      font-size: clamp(1.7rem, 2.1vw, 2.35rem);
    }

    .carousel-track {
      grid-auto-columns: clamp(250px, 15vw, 340px);
      gap: 24px;
      padding-bottom: 28px;
    }

    .home-ch-name,
    .channel-card-title {
      font-size: 1.08rem;
    }

    .channel-card-meta {
      font-size: 0.9rem;
    }

    .home-live-badge,
    .channel-card-live {
      font-size: 0.78rem;
      padding: 5px 11px;
    }

    .ch-item {
      min-height: 72px;
      padding: 14px 22px;
    }

    .ch-logo-box--guide {
      width: 54px;
      height: 54px;
    }

    .ch-name {
      font-size: 1rem;
    }
  }

  .remote-nav-active .home-ch-card:focus,
  .remote-nav-active .ch-item:focus,
  .remote-nav-active .wm-card:focus,
  .remote-nav-active .carousel-nav-btn:focus,
  .remote-nav-active .app-nav-btn:focus,
  .remote-nav-active .tv-brand:focus,
  .remote-nav-active .ctrl-btn:focus,
  .remote-nav-active .ctrl-live-btn:focus,
  .remote-nav-active .ctrl-qual-btn:focus,
  .remote-nav-active .qual-item:focus,
  .home-ch-card:focus-visible,
  .ch-item:focus-visible,
  .wm-card:focus-visible,
  .ctrl-live-btn:focus-visible {
    outline: 0;
    transform: translateY(-5px) scale(1.025);
    box-shadow:
      0 0 0 3px rgba(53, 214, 164, 0.78),
      0 0 0 7px rgba(53, 214, 164, 0.18),
      0 24px 70px rgba(0, 0, 0, 0.55);
  }

  .remote-nav-active .home-ch-card:focus,
  .remote-nav-active .wm-card:focus,
  .home-ch-card:focus-visible,
  .wm-card:focus-visible {
    z-index: 8;
    padding: 10px;
    background: #fff;
    color: #080808;
    border-radius: 14px;
    transform: translateY(-8px) scale(1.08);
    box-shadow:
      0 18px 44px rgba(0, 0, 0, 0.55),
      0 0 0 2px rgba(255, 255, 255, 0.95),
      0 0 0 6px rgba(53, 214, 164, 0.42);
  }

  .remote-nav-active .home-ch-card:focus .channel-card-thumb,
  .remote-nav-active .wm-card:focus .wm-thumb,
  .home-ch-card:focus-visible .channel-card-thumb,
  .wm-card:focus-visible .wm-thumb {
    border-color: transparent;
    border-radius: 10px;
    box-shadow: none;
  }

  .remote-nav-active .home-ch-card:focus .home-ch-name,
  .remote-nav-active .home-ch-card:focus .channel-card-title,
  .remote-nav-active .wm-card:focus .wm-name,
  .home-ch-card:focus-visible .home-ch-name,
  .home-ch-card:focus-visible .channel-card-title,
  .wm-card:focus-visible .wm-name {
    color: #080808;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.25;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .remote-nav-active .home-ch-card:focus .channel-card-meta,
  .remote-nav-active .wm-card:focus .wm-meta,
  .home-ch-card:focus-visible .channel-card-meta,
  .wm-card:focus-visible .wm-meta {
    color: #4a4a4a;
  }

  .remote-nav-active .ch-item:focus,
  .ch-item:focus-visible {
    z-index: 6;
    background: #fff;
    color: #080808;
    border-color: transparent;
    border-left-color: transparent;
    border-radius: 12px;
    transform: translateX(0) scale(1.02);
    box-shadow:
      0 14px 36px rgba(0, 0, 0, 0.52),
      0 0 0 2px rgba(255, 255, 255, 0.95),
      0 0 0 6px rgba(53, 214, 164, 0.42);
  }

  .remote-nav-active .ch-item:focus .ch-name,
  .ch-item:focus-visible .ch-name {
    color: #080808;
    font-weight: 800;
  }

  .remote-nav-active .ch-item:focus .ch-live-dot,
  .ch-item:focus-visible .ch-live-dot {
    background: var(--red);
  }

  body.remote-nav-active .guide-shell.closed .guide-rail-btn:not(.guide-rail-menu):focus,
  body.remote-nav-active .guide-shell:not(.closed) .guide-rail-btn:not(.guide-rail-menu):focus {
    background: #fff;
    color: #080808;
    outline: 0;
    transform: scale(1.01);
    box-shadow:
      0 14px 34px rgba(0, 0, 0, 0.48),
      0 0 0 2px rgba(255, 255, 255, 0.95),
      0 0 0 5px rgba(53, 214, 164, 0.38);
  }

  body.remote-nav-active .guide-shell:not(.closed) .guide-rail-btn:not(.guide-rail-menu):focus .guide-rail-label,
  body.remote-nav-active .guide-shell:not(.closed) .guide-rail-btn:not(.guide-rail-menu):focus .guide-rail-count,
  body.remote-nav-active .guide-shell:not(.closed) .guide-rail-btn:not(.guide-rail-menu):focus .guide-rail-arrow {
    color: #080808 !important;
    opacity: 1;
  }

  body.remote-nav-active .guide-search-wrap .search-input:focus {
    background: #fff;
    border-color: transparent;
    color: #080808;
    box-shadow:
      0 14px 34px rgba(0, 0, 0, 0.48),
      0 0 0 2px rgba(255, 255, 255, 0.95),
      0 0 0 5px rgba(53, 214, 164, 0.38);
  }

  body.remote-nav-active .guide-search-wrap .search-input:focus::placeholder {
    color: rgba(8, 8, 8, 0.72);
  }

  body.remote-nav-active .guide-search-wrap:focus-within .search-icon {
    color: #080808;
  }

  body.remote-nav-active .ctrl-bar .ctrl-btn:focus,
  body.remote-nav-active .ctrl-bar .ctrl-live-btn:focus,
  body.remote-nav-active .ctrl-bar .ctrl-qual-btn:focus,
  body.remote-nav-active .ctrl-bar .qual-item:focus {
    background: #fff;
    border-color: transparent;
    color: #080808;
    outline: 0;
    transform: translateY(-3px) scale(1.06);
    box-shadow:
      0 14px 34px rgba(0, 0, 0, 0.52),
      0 0 0 2px rgba(255, 255, 255, 0.95),
      0 0 0 5px rgba(53, 214, 164, 0.38);
  }

  body.remote-nav-active .ctrl-bar .ctrl-live-btn:focus .ctrl-live-dot {
    background: var(--red);
  }

  /* ── Quality & Buffer Indicator in Control Bar ── */
  .ctrl-quality-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
  }

  .ctrl-quality-indicator .quality-badge {
    background: var(--accent-bg);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.6rem;
    letter-spacing: 0.04em;
  }

  .ctrl-quality-indicator .buffer-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  .ctrl-quality-indicator .buffer-bar {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    overflow: hidden;
  }

  .ctrl-quality-indicator .buffer-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
  }

/* Rail-first TV shell: the left rail replaces the old top navigation bar. */
:root {
  --nav-h: 0px;
}

.tv-topbar {
  display: none !important;
}
