/* Cross-device + Smart TV optimizations */

:root {
    --focus-ring: 0 0 0 3px rgba(0, 201, 122, 0.45);
    --touch-min: 44px;
    --tv-safe-x: clamp(24px, 4vw, 72px);
    --tv-safe-y: clamp(20px, 3vh, 56px);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
.channel-item:focus-visible,
.home-btn:focus-visible,
.home-channel-card:focus-visible,
.home-featured-card:focus-visible,
.home-fifa-watch:focus-visible,
.mobile-nav-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.channel-item:focus-visible {
    border-color: rgba(0, 201, 122, 0.65);
    background: rgba(0, 201, 122, 0.12);
}

/* Touch phones & tablets */
body.device-touch.device-phone .icon-btn,
body.device-touch.device-phone .chip-btn,
body.device-touch.device-phone .favorite-btn,
body.device-touch.device-phone .mobile-nav-btn {
    min-width: var(--touch-min);
    min-height: var(--touch-min);
}

body.device-touch.device-tablet .channel-item {
    min-height: 68px;
    padding: 12px 14px;
}

body.device-tablet.device-touch .home-channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

body.device-touch.device-phone .home-menu-btn,
body.device-touch.device-phone .home-pill,
body.device-touch.device-phone .home-search-clear {
    min-width: var(--touch-min);
    min-height: var(--touch-min);
}

body.device-touch.device-phone .home-header-actions .home-btn-sm {
    min-height: var(--touch-min);
}

body.device-touch.device-phone .home-channel-card,
body.device-touch.device-phone .home-featured-card {
    min-height: var(--touch-min);
}

body.device-touch.device-phone.home-page .home-main {
    padding-bottom: calc(108px + env(safe-area-inset-bottom));
}

body.device-touch.device-phone.home-page .site-footer-home {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
}

/* Smart TV & large screen lean-back */
body.device-tv {
    font-size: 18px;
}

body.device-tv .app {
    min-height: 100vh;
    min-height: 100dvh;
}

body.device-tv .sidebar {
    width: var(--sidebar-width);
}

body.device-tv .sidebar-header,
body.device-tv .sidebar-tools,
body.device-tv .sidebar-footer {
    padding: 18px;
}

body.device-tv .channel-item {
    min-height: 76px;
    padding: 14px 16px;
    margin-bottom: 10px;
    border-radius: 18px;
}

body.device-tv .channel-logo,
body.device-tv .now-playing-logo {
    width: 58px;
    height: 58px;
}

body.device-tv .channel-meta strong {
    font-size: 1.02rem;
}

body.device-tv .search-box input,
body.device-tv .filter-row select,
body.device-tv .chip-btn {
    min-height: 52px;
    font-size: 1rem;
}

body.device-tv .topbar {
    padding: 20px var(--tv-safe-x);
}

body.device-tv .topbar-title h2 {
    font-size: 1.35rem;
}

body.device-tv .fifa-hero,
body.device-tv .player-section,
body.device-tv .fifa-matches-section,
body.device-tv .info-grid {
    margin-left: var(--tv-safe-x);
    margin-right: var(--tv-safe-x);
}

body.device-tv .player-section {
    padding-left: var(--tv-safe-x);
    padding-right: var(--tv-safe-x);
}

body.device-tv #livePlayer {
    max-height: min(78vh, 920px);
}

body.device-tv .fifa-chip {
    min-height: 52px;
    padding: 12px 18px;
    font-size: 1rem;
}

body.device-tv .unmute-btn,
body.device-tv .play-btn,
body.device-tv .retry-btn {
    min-height: 52px;
    padding: 14px 22px;
    font-size: 1rem;
}

body.device-tv .mobile-nav {
    display: none !important;
}

body.device-tv.mobile-view-channels .main {
    visibility: visible !important;
    height: auto !important;
    overflow: visible !important;
    pointer-events: auto !important;
}

body.device-tv.mobile-view-channels .sidebar {
    position: sticky !important;
    transform: none !important;
    width: var(--sidebar-width) !important;
    max-width: none !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 20 !important;
    box-shadow: none !important;
    padding-bottom: 0 !important;
}

body.device-tv .now-watching-pill {
    font-size: 0.88rem;
    padding: 8px 14px;
}

body.device-tv .now-watching-pill strong {
    font-size: 1rem;
}

/* Home on TV */
body.device-tv.home-page .home-main {
    max-width: 1600px;
    padding: var(--tv-safe-y) var(--tv-safe-x) 80px;
}

body.device-tv.home-page .home-header {
    padding-top: var(--tv-safe-y);
}

body.device-tv.home-page .home-hero-title {
    font-size: clamp(2.2rem, 4vw, 3.4rem);
}

body.device-tv.home-page .home-btn {
    min-height: 52px;
    font-size: 1.05rem;
}

body.device-tv.home-page .home-channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px;
}

body.device-tv.home-page .home-fifa-watch {
    max-width: 520px;
    min-height: 88px;
    padding: 18px 20px;
}

body.device-tv.home-page .home-fab {
    display: none !important;
}

/* Ultra-wide TV */
@media (min-width: 1920px) {
    body.device-tv {
        --sidebar-width: 400px;
    }

    body.device-tv .main {
        max-width: 1800px;
        margin-inline: auto;
    }
}

/* Phone landscape */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 960px) {
    body.device-phone .topbar {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    body.device-phone #livePlayer {
        max-height: 72vh;
        max-height: 72dvh;
    }

    body.device-phone .fifa-hero {
        margin-top: 8px;
        padding: 12px 14px;
    }

    body.device-phone .sidebar {
        width: min(320px, 42vw);
    }
}

/* Prevent iOS input zoom */
@media (max-width: 900px) {
    .search-box input,
    .filter-row select,
    .home-search {
        font-size: 16px;
    }
}
