/* ==============================================================================
   TASTEYBOX TV - 10-FOOT EXPERIENCE STYLESHEET (Cloudflare Pages TV Web App)
   Theme: Pitch Black (#000000) & Brand Orange (#FF7729)
   ============================================================================== */

:root {
  --brand-orange: #FF7729;
  --brand-orange-glow: rgba(255, 119, 41, 0.45);
  --brand-orange-light: rgba(255, 119, 41, 0.15);
  --color-black: #000000;
  --color-white: #FFFFFF;
  --bg-card-idle: #141414;
  --text-secondary: #E5E7EB;
  --text-muted: #9CA3AF;
  --status-live: #10B981;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

html, body {
  width: 100vw;
  height: 100vh;
  background-color: var(--color-black);
  color: var(--color-white);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  cursor: none; /* TV experience: hide mouse pointer */
}

/* Enable pointer cursor when mouse is actually used on desktop preview */
body.mouse-active {
  cursor: default;
}

/* ==============================================================================
   SCREEN VIEWS (TV GUIDE vs FULLSCREEN PLAYER)
   ============================================================================== */

.screen-view {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  background-color: var(--color-black);
}

.screen-view.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

/* ==============================================================================
   TV GUIDE / HOME SCREEN
   ============================================================================== */

#tvGuideScreen {
  display: flex;
  flex-direction: column;
  padding: 24px 48px;
  overflow: hidden;
}

/* 1. TOP CENTER HEADER */
.tv-header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 18px;
}

.brand-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.brand-logo {
  height: 48px;
  max-width: 260px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(255, 119, 41, 0.25));
}

.brand-subtitle-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}

.sub-line {
  width: 18px;
  height: 1.5px;
  background-color: rgba(255, 119, 41, 0.6);
  border-radius: 2px;
}

.brand-subtitle {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* 2. LEFT-ALIGNED CATEGORY CAPSULES */
.category-nav {
  width: 100%;
  margin-bottom: 20px;
}

.category-scroll-list {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px 2px;
}

.category-scroll-list::-webkit-scrollbar {
  display: none;
}

.category-capsule {
  flex-shrink: 0;
  padding: 8px 22px;
  border-radius: 24px;
  background-color: var(--bg-card-idle);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.category-capsule.active {
  background-color: var(--brand-orange);
  border-color: var(--brand-orange);
  color: var(--color-white);
  box-shadow: 0 4px 16px var(--brand-orange-glow);
}

.category-capsule:focus,
.category-capsule.focused {
  transform: scale(1.08);
  border-color: var(--color-white);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4), 0 4px 16px var(--brand-orange-glow);
  outline: none;
}

/* 3. 6-COLUMN CHANNEL GRID */
.grid-container {
  flex: 1;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  padding-bottom: 30px;
}

.grid-container::-webkit-scrollbar {
  display: none;
}

.channels-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 24px 20px;
  padding: 6px 4px 40px 4px;
}

/* BORDERLESS CHANNEL CARD */
.channel-card {
  display: flex;
  flex-direction: column;
  background: transparent; /* ZERO CARD BACKGROUND */
  border: none; /* ZERO CARD BORDER */
  border-radius: 14px;
  padding: 0;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  outline: none;
  position: relative;
}

/* D-PAD FOCUS HIGHLIGHT */
.channel-card:focus,
.channel-card.focused {
  transform: scale(1.08);
  z-index: 20;
}

.channel-card:focus .thumbnail-wrapper,
.channel-card.focused .thumbnail-wrapper {
  box-shadow: 0 0 0 3px var(--brand-orange), 0 10px 30px var(--brand-orange-glow);
}

/* 1:1 SQUARE THUMBNAIL WRAPPER */
.thumbnail-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1; /* 1:1 PURE SQUARE */
  border-radius: 12px;
  background-color: #0c0c0c;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: box-shadow 0.2s ease;
}

.channel-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
  display: block;
}

/* TOP-LEFT CH X BADGE (NO BRACKETS) */
.channel-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background-color: rgba(0, 0, 0, 0.85);
  color: var(--brand-orange);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  backdrop-filter: blur(4px);
}

/* METADATA BELOW THUMBNAIL (ZERO BACKGROUND & ZERO BORDER) */
.channel-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: 10px;
}

.channel-name {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  font-weight: 800;
  color: var(--color-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  letter-spacing: 0.2px;
}

.channel-category {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-orange);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* ==============================================================================
   STATE PLACEHOLDERS (LOADING / ERROR / EMPTY)
   ============================================================================== */

.state-placeholder {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.state-placeholder.hidden {
  display: none !important;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 119, 41, 0.2);
  border-top-color: var(--brand-orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.state-text {
  font-size: 16px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}

.error-icon, .empty-icon {
  font-size: 56px;
  color: var(--brand-orange);
  margin-bottom: 14px;
}

.retry-btn {
  margin-top: 18px;
  padding: 10px 24px;
  border-radius: 8px;
  background-color: var(--brand-orange);
  color: var(--color-white);
  border: none;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.retry-btn:focus,
.retry-btn.focused {
  transform: scale(1.08);
  box-shadow: 0 0 20px var(--brand-orange-glow);
}

/* ==============================================================================
   FULLSCREEN TV VIDEO PLAYER VIEW
   ============================================================================== */

#tvPlayerScreen {
  background-color: #000000;
  z-index: 100;
}

#tvVideoPlayer {
  width: 100vw;
  height: 100vh;
  object-fit: contain;
  background-color: #000000;
}

/* PLAYER LOADER & ERROR */
.player-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 110;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 24px 36px;
  border-radius: 16px;
  backdrop-filter: blur(8px);
}

.player-loader.hidden {
  display: none !important;
}

.player-loader-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-white);
}

.player-error-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  z-index: 120;
  padding: 40px;
}

.player-error-overlay.hidden {
  display: none !important;
}

.error-large-icon {
  font-size: 64px;
  color: var(--brand-orange);
  margin-bottom: 16px;
}

.player-error-overlay h2 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}

.player-error-overlay p {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 500px;
  margin-bottom: 24px;
}

.player-error-actions {
  display: flex;
  gap: 16px;
}

.player-btn {
  padding: 12px 28px;
  border-radius: 10px;
  background-color: var(--brand-orange);
  color: var(--color-white);
  border: none;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.player-btn.secondary {
  background-color: rgba(255, 255, 255, 0.15);
}

.player-btn:focus,
.player-btn.focused {
  transform: scale(1.08);
  box-shadow: 0 0 20px var(--brand-orange-glow);
}

/* ==============================================================================
   ON-SCREEN DISPLAY (OSD) OVERLAY
   ============================================================================== */

.player-osd {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 56px;
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, transparent 25%, transparent 70%, rgba(0,0,0,0.92) 100%);
  z-index: 105;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.player-osd.visible {
  opacity: 1;
  pointer-events: auto;
}

/* TOP OSD BAR */
.osd-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.osd-back-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--color-white);
  font-size: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.osd-back-btn:focus,
.osd-back-btn.focused {
  background-color: var(--brand-orange);
  border-color: var(--brand-orange);
  transform: scale(1.1);
  box-shadow: 0 0 20px var(--brand-orange-glow);
}

.osd-channel-num {
  background-color: var(--brand-orange);
  color: var(--color-white);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  font-weight: 900;
  padding: 6px 16px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}

.osd-zap-hint {
  background-color: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 18px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  gap: 6px;
}

.key-pill {
  color: var(--brand-orange);
  font-weight: 800;
}

/* BOTTOM OSD CARD */
.osd-bottom-card {
  background-color: rgba(18, 18, 18, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  gap: 22px;
  backdrop-filter: blur(16px);
}

.osd-channel-logo-box {
  width: 68px;
  height: 68px;
  border-radius: 14px;
  background-color: #000000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.osd-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
}

.osd-channel-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.osd-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.osd-channel-name {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 22px;
  font-weight: 900;
  color: var(--color-white);
}

.osd-category-badge {
  background-color: var(--brand-orange-light);
  color: var(--brand-orange);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
}

.osd-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
}

.live-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--status-live);
  box-shadow: 0 0 10px var(--status-live);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.live-badge-text {
  color: var(--status-live);
  letter-spacing: 0.5px;
}

.osd-divider {
  color: rgba(255, 255, 255, 0.3);
}

.osd-quality-badge {
  color: rgba(255, 255, 255, 0.7);
}
