/* =====================================================
   YALLA VAMOS SPORTS TV — page-specific layout.

   Every colour, font, radius and easing below resolves to a
   token defined in ../../assets/css/brand.css, which this page
   loads first. Nothing here introduces a new brand value.
   ===================================================== */

/* Lucide swaps <i data-lucide> for an <svg> and copies the class across,
   so icon sizing lives on these three helpers. */
.ico    { width: 18px; height: 18px; flex: none; }
.ico-sm { width: 15px; height: 15px; flex: none; }
.ico-lg { width: 34px; height: 34px; flex: none; }

/* The player scripts toggle this class on a dozen elements. */
.hidden { display: none !important; }

/* =====================================================
   1. SHELL
   ===================================================== */
.tv {
    position: relative;
    z-index: 10;
    padding-bottom: clamp(2rem, 5vh, 3.5rem);
}

.tv__shell {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    align-items: start;
    gap: clamp(1.25rem, 2.5vw, 2rem);
}

/* Theater mode simply retires the rail and lets the stage span the shell. */
.tv__shell.is-theater { grid-template-columns: minmax(0, 1fr); }
.tv__shell.is-theater .tv-rail { display: none; }

.tv-credit {
    margin-top: 1.75rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}
.tv-credit a {
    color: var(--gold);
    text-decoration: none;
}
.tv-credit a:hover { color: var(--gold-light); text-decoration: underline; }

/* =====================================================
   2. CHANNEL RAIL
   ===================================================== */
.tv-rail {
    position: sticky;
    top: 90px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
    border-radius: 24px;
    overflow: hidden;
    animation: fadeUp 0.8s var(--ease-out) 0.1s both;
}

.tv-rail__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1.1rem 1.15rem;
    border-bottom: 1px solid var(--hairline);
    background: rgba(0, 0, 0, 0.2);
}
.tv-rail__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}
.tv-rail__mark {
    width: 40px;
    height: 40px;
    flex: none;
    object-fit: contain;
    padding: 5px;
    border-radius: 11px;
    background: radial-gradient(120% 120% at 30% 12%, #ffffff 0%, #f1e9d5 100%);
    box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.5);
}
.tv-rail__title {
    display: block;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold);
    line-height: 1.2;
}
.tv-rail__sub {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
/* Scoped so it outranks the generic .tv-icon-btn { display: grid } below.
   Only the drawer breakpoint brings this button back. */
.tv-rail__head .tv-rail__close { display: none; }

/* --- Search ------------------------------------------------- */
.tv-rail__search {
    position: relative;
    padding: 0.9rem 1.15rem;
    border-bottom: 1px solid var(--hairline);
}
.tv-search__icon {
    position: absolute;
    left: 1.9rem;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    color: var(--text-muted);
    pointer-events: none;
}
.tv-search__input {
    width: 100%;
    padding: 0.7rem 2.4rem 0.7rem 2.4rem;
    font-family: var(--font-main);
    font-size: 0.82rem;
    color: #fff;
    background: rgba(4, 7, 15, 0.62);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
}
.tv-search__input::placeholder { color: var(--text-muted); }
.tv-search__input:focus {
    border-color: rgba(212, 175, 55, 0.75);
    background: rgba(4, 7, 15, 0.9);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.15);
}
.tv-search__clear {
    position: absolute;
    right: 1.75rem;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    background: none;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: color 0.25s ease, background-color 0.25s ease;
}
.tv-search__clear:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

/* --- Channel list ------------------------------------------- */
.tv-rail__scroll {
    flex: 1;
    min-height: 220px;
    overflow-y: auto;
    padding: 0.75rem;
}
.tv-rail__list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.tv-rail__sentinel {
    display: flex;
    justify-content: center;
    padding: 1.1rem 0;
}

.tv-channel {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border-radius: 14px;
    text-align: left;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--hairline);
    cursor: pointer;
    font-family: var(--font-main);
    transition: transform 0.28s var(--ease-out),
                background-color 0.28s ease, border-color 0.28s ease;
}
.tv-channel:hover {
    transform: translateX(3px);
    background: rgba(212, 175, 55, 0.09);
    border-color: rgba(212, 175, 55, 0.32);
}
.tv-channel.is-playing {
    background: rgba(212, 175, 55, 0.14);
    border-color: rgba(212, 175, 55, 0.5);
}
.tv-channel__logo {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    padding: 5px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--hairline);
}
.tv-channel__logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.tv-channel__text {
    flex: 1;
    min-width: 0;
}
.tv-channel__name {
    font-size: 0.79rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.25s ease;
}
.tv-channel:hover .tv-channel__name { color: #fff; }
.tv-channel__tags {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.3rem;
}
.tv-channel__tag {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    padding: 0.15rem 0.45rem;
    border-radius: 5px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    max-width: 96px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tv-channel__tag--gold {
    color: var(--gold);
    background: rgba(212, 175, 55, 0.1);
}
/* Small bar on the right that lights up on hover, echoing the brand flags */
.tv-channel__pip {
    width: 3px;
    height: 20px;
    flex: none;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    transition: background-color 0.28s ease, box-shadow 0.28s ease;
}
.tv-channel:hover .tv-channel__pip,
.tv-channel.is-playing .tv-channel__pip {
    background: var(--gold);
    box-shadow: 0 0 12px 1px rgba(212, 175, 55, 0.65);
}

.tv-rail__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
}
.tv-rail__empty strong {
    font-size: 0.82rem;
    color: var(--text-soft);
}
.tv-rail__empty span { font-size: 0.72rem; }

/* --- Rail footer -------------------------------------------- */
.tv-rail__foot {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.15rem;
    border-top: 1px solid var(--hairline);
    background: rgba(0, 0, 0, 0.28);
}
.tv-rail__foot .tv-ghost-btn { flex: 1; justify-content: center; }

/* =====================================================
   3. BUTTONS & CHIPS
   ===================================================== */
.tv-ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    border-radius: 100px;
    font-family: var(--font-main);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-soft);
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--hairline);
    cursor: pointer;
    transition: color 0.3s ease, background-color 0.3s ease,
                border-color 0.3s ease, transform 0.3s var(--ease-out);
}
.tv-ghost-btn:hover {
    color: #fff;
    background: rgba(212, 175, 55, 0.14);
    border-color: rgba(212, 175, 55, 0.45);
    transform: translateY(-2px);
}
.tv-ghost-btn--danger {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
}
.tv-ghost-btn--danger:hover {
    color: #fff;
    background: rgba(239, 68, 68, 0.24);
    border-color: rgba(239, 68, 68, 0.5);
}

.tv-icon-btn {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 11px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--hairline);
    cursor: pointer;
    transition: color 0.25s ease, background-color 0.25s ease,
                border-color 0.25s ease, transform 0.25s var(--ease-out);
}
.tv-icon-btn:hover {
    color: #fff;
    background: rgba(212, 175, 55, 0.14);
    border-color: rgba(212, 175, 55, 0.4);
    transform: translateY(-2px);
}
.tv-icon-btn--danger:hover {
    background: rgba(227, 6, 19, 0.22);
    border-color: rgba(227, 6, 19, 0.45);
}
/* Set by player.js when the stream is muted */
.tv-icon-btn.is-muted { color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); }

.tv-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 100px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-soft);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--hairline);
    white-space: nowrap;
}
.tv-chip--gold {
    color: var(--gold);
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.28);
    text-transform: uppercase;
}

/* =====================================================
   4. STAGE
   ===================================================== */
.tv-stage {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
    animation: fadeUp 0.8s var(--ease-out) 0.22s both;
}

.tv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
/* The rail is permanently visible on desktop, so its opener stays hidden
   unless theater mode or a narrow viewport retires the rail. */
.tv-toolbar .tv-toolbar__menu { display: none; }
.tv__shell.is-theater .tv-toolbar .tv-toolbar__menu { display: inline-flex; }
.tv-toolbar__status { padding: 0.4rem 0.9rem 0.4rem 0.7rem; }

/* --- Player -------------------------------------------------- */
.tv-player {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 1.1rem;
    border-radius: 24px;
}
.tv-player__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--hairline);
}
.tv-player__head-left,
.tv-player__head-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.tv-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: 100px;
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(227, 6, 19, 0.85);
    box-shadow: 0 8px 20px -8px rgba(227, 6, 19, 0.8);
}
.tv-live-badge i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    animation: beamFlicker 1.6s ease-in-out infinite;
}

.tv-screen {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: calc(100vh - 280px);
    border-radius: 18px;
    overflow: hidden;
    background: #000;
    border: 1px solid var(--hairline);
    box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.9);
}
.tv-screen video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.tv-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    padding: 1.5rem;
    text-align: center;
    background: rgba(4, 7, 15, 0.9);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.tv-overlay--error { background: rgba(4, 7, 15, 0.96); }
.tv-overlay__icon { color: var(--flag-red); }
.tv-overlay__title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: #fff;
}
.tv-overlay__text {
    max-width: 42ch;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.tv-overlay__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 0.25rem;
}

/* Gold ring spinner, matching the emblem accent */
.tv-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(212, 175, 55, 0.18);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
    flex: none;
}
.tv-spinner--sm { width: 20px; height: 20px; border-width: 2px; }
.tv-spinner--lg { width: 58px; height: 58px; border-width: 4px; }

/* --- Now playing --------------------------------------------- */
.tv-player__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.tv-nowplaying {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}
.tv-nowplaying__logo {
    width: 50px;
    height: 50px;
    flex: none;
    padding: 6px;
    object-fit: contain;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--hairline);
}
.tv-nowplaying__name {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}
.tv-nowplaying__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.45rem;
}

.tv-player__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.9rem;
    margin-left: auto;
}
.tv-facts {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    padding: 0.7rem 1.2rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--hairline);
}
.tv-facts dt {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.tv-facts dd {
    margin-top: 0.25rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-soft);
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tv-facts a { color: var(--gold); text-decoration: none; }
.tv-facts a:hover { text-decoration: underline; }
/* player.js applies this when a channel has no website on file */
.tv-facts a.is-muted {
    color: var(--text-muted);
    pointer-events: none;
}
.tv-player__buttons {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

/* =====================================================
   5. LOADING / IDLE STATES
   ===================================================== */
.tv-content { display: flex; }
.tv-state {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    width: 100%;
    min-height: clamp(320px, 46vh, 460px);
    padding: 2.5rem 1.75rem;
    text-align: center;
    border-radius: 24px;
    overflow: hidden;
}
.tv-state--idle { border-style: dashed; }
.tv-state__glow {
    position: absolute;
    right: -18%;
    bottom: -30%;
    width: 60%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.14), transparent 65%);
    pointer-events: none;
}
.tv-state__badge {
    position: relative;
    display: grid;
    place-items: center;
    width: 82px;
    height: 82px;
    border-radius: 50%;
    color: var(--gold);
    background: rgba(212, 175, 55, 0.07);
    border: 1px solid rgba(212, 175, 55, 0.28);
    box-shadow: 0 0 40px -6px rgba(212, 175, 55, 0.4);
    animation: emblemFloat 7s ease-in-out infinite;
}
.tv-state__title {
    position: relative;
    font-family: var(--font-heading);
    font-size: clamp(1.4rem, 3vw, 1.9rem);
    font-weight: 700;
    color: #fff;
}
.tv-state__text {
    position: relative;
    max-width: 46ch;
    font-size: 0.88rem;
    color: var(--text-soft);
}
.tv-state__actions {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.6rem;
}
.tv-state .tv-state__browse { display: none; }
.tv-state .btn--primary { padding: 0.9rem 1.9rem; font-size: 0.78rem; }

/* =====================================================
   6. SETTINGS PANEL
   ===================================================== */
.tv-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1rem 0;
    border-top: 1px solid var(--hairline);
}
.tv-setting--stack {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
}
.tv-setting__name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #fff;
}
.tv-setting__hint {
    margin-top: 0.2rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.tv-setting__reset { justify-content: center; }

.tv-switch {
    position: relative;
    flex: none;
    cursor: pointer;
}
.tv-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}
.tv-switch__track {
    display: block;
    width: 46px;
    height: 26px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid var(--hairline);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
.tv-switch__track::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.3s var(--ease-spring), background-color 0.3s ease;
}
.tv-switch input:checked + .tv-switch__track {
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    border-color: var(--gold);
}
.tv-switch input:checked + .tv-switch__track::after {
    transform: translateX(20px);
    background: #04070f;
}
.tv-switch input:focus-visible + .tv-switch__track {
    outline: 2px solid var(--gold-light);
    outline-offset: 3px;
}

/* =====================================================
   7. TOASTS
   ===================================================== */
.tv-toasts {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}
.tv-toast {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    max-width: 340px;
    padding: 0.85rem 1.15rem;
    border-radius: 14px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-soft);
    background: rgba(11, 20, 40, 0.96);
    border: 1px solid var(--hairline);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 24px 48px -18px rgba(0, 0, 0, 0.9);
    pointer-events: auto;
}
.tv-toast--success { color: var(--gold-light); border-color: rgba(212, 175, 55, 0.4); }
.tv-toast--error   { color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }

.tv-toast.is-in  { animation: toastIn 0.35s var(--ease-out) both; }
.tv-toast.is-out { animation: toastOut 0.25s ease both; }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(16px) scale(0.94); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
    to { opacity: 0; transform: translateY(8px) scale(0.96); }
}

/* =====================================================
   8. RESPONSIVE — rail collapses into a drawer
   ===================================================== */
@media (max-width: 1000px) {
    .tv__shell { grid-template-columns: minmax(0, 1fr); }

    .tv-rail {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 900;
        width: min(340px, 88vw);
        max-height: none;
        border-radius: 0 24px 24px 0;
        background: rgba(7, 13, 28, 0.98);
        transform: translateX(-102%);
        transition: transform 0.4s var(--ease-out);
        animation: none;
    }
    .tv-rail.is-open { transform: translateX(0); }
    .tv-rail__head .tv-rail__close { display: grid; }

    .tv-backdrop {
        position: fixed;
        inset: 0;
        z-index: 890;
        background: rgba(3, 6, 14, 0.7);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }

    .tv-toolbar .tv-toolbar__menu,
    .tv-state .tv-state__browse { display: inline-flex; }

    .tv-screen { max-height: none; }
}

@media (max-width: 720px) {
    .tv-player__foot { flex-direction: column; align-items: stretch; }
    .tv-player__controls { margin-left: 0; flex-direction: column; align-items: stretch; }
    .tv-facts { justify-content: space-between; gap: 0.75rem; padding: 0.7rem 0.9rem; }
    .tv-facts dd { max-width: 90px; }
    .tv-player__buttons { margin-left: 0; justify-content: space-between; }
    .tv-player__buttons .tv-ghost-btn { flex: 1; justify-content: center; }
    .tv-toasts { right: 0.75rem; left: 0.75rem; bottom: 0.75rem; }
    .tv-toast { max-width: none; }
}
