/* ==========================================================================
   Site header — "Cinema" model
   Transparent at the top of the page, frosted glass once the page scrolls,
   nav links with a glowing active dot, Spotlight search and a phone tab bar.
   Markup: partials/header/main-header.php · JS: public/js/animetv-core.js
   ========================================================================== */

.atv-hdr,
.atv-spot,
.atv-tabbar {
    --h-text: #ffffff;
    --h-text-2: #d3d7df;
    --h-muted: #9aa1ae;
    --h-glass: rgba(15, 16, 21, 0.8);
    --h-line: rgba(255, 255, 255, 0.07);
    --h-chip: rgba(255, 255, 255, 0.07);
    --h-chip-border: rgba(255, 255, 255, 0.13);
    --h-panel: rgba(24, 26, 33, 0.97);
    --h-accent: #f5b942;
    --h-accent-ink: #1c1503;
    --h-shadow: 0 20px 40px -18px rgba(0, 0, 0, 0.85);
    --h-text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45);
}

#animetvApp.day .atv-hdr,
#animetvApp.day .atv-spot,
#animetvApp.day .atv-tabbar {
    --h-text: #0f172a;
    --h-text-2: #334155;
    --h-muted: #64748b;
    --h-glass: rgba(255, 255, 255, 0.84);
    --h-line: rgba(15, 23, 42, 0.08);
    --h-chip: rgba(15, 23, 42, 0.04);
    --h-chip-border: rgba(15, 23, 42, 0.12);
    --h-panel: rgba(255, 255, 255, 0.98);
    --h-shadow: 0 14px 34px -16px rgba(15, 23, 42, 0.28);
    --h-text-shadow: none;
}

/* ---------- Bar ----------
   Fixed (not sticky): the theme makes <body> its own scroll container, which breaks position:sticky.
   .atv-hdr-spacer reserves the header's height in the page flow. */
body.animetv-native-body header.atv-hdr {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 900;
    display: block;
    height: 84px;
    margin: 0;
    padding: 0;
    direction: rtl;
    font-family: "IRANYekanX", "Vazirmatn", system-ui, sans-serif;
    -webkit-app-region: no-drag;
    transition: height 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
body.animetv-native-body header.atv-hdr.is-scrolled {
    height: 66px;
}
.atv-hdr-spacer {
    height: 94px;
}
/* Lift the header (and the account sheet inside it) above the music player while the sheet is open. */
body.animetv-native-body.atv-acct-open header.atv-hdr {
    z-index: 10060;
}
/* The frosted layer is a separate element so fixed descendants (account sheet) keep the viewport as their box. */
.atv-hdr__bg {
    position: absolute;
    inset: 0;
    background: transparent;
    border-bottom: 1px solid transparent;
    transition: background-color 0.35s, border-color 0.35s, box-shadow 0.35s;
    pointer-events: none;
}
.atv-hdr.is-scrolled .atv-hdr__bg {
    background: var(--h-glass);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    backdrop-filter: blur(20px) saturate(1.3);
    border-bottom-color: var(--h-line);
    box-shadow: var(--h-shadow);
}
body.animetv-native-body header.atv-hdr > .atv-hdr__in {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 40px;
    width: auto;
    height: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 clamp(16px, 3vw, 40px);
    box-sizing: border-box;
    -webkit-app-region: no-drag;
}

/* Brand: the site wordmark + TV icon inside a glass capsule (header logo model 3). Markup: partials/header/brand-logo.php (.atv-brand-tv / .atv-brand-wm, also used by the footer).
   Shrinks with the bar on scroll; white capsule in day mode. */
.atv-hdr a.atv-hdr__brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 5px 6px 5px 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.03));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 14px 30px -16px rgba(0, 0, 0, 0.95);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    color: #ffffff;
    text-decoration: none;
    transition: transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1), padding 0.35s, gap 0.35s;
}
.atv-hdr a.atv-hdr__brand:hover {
    transform: translateY(-1px);
    color: #ffffff;
}
.atv-hdr a.atv-hdr__brand:focus-visible {
    outline: 2px solid var(--h-accent);
    outline-offset: 3px;
}
.atv-hdr .atv-brand-tv {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 40%, rgba(253, 143, 0, 0.45), rgba(253, 143, 0, 0.12) 70%);
    box-shadow: inset 0 0 0 1px rgba(253, 143, 0, 0.5), 0 0 22px -4px rgba(253, 143, 0, 0.7);
    transition: width 0.35s, height 0.35s;
}
.atv-hdr .atv-brand-tv svg {
    display: block;
    width: 24.1px;
    height: 28px;
    transition: width 0.35s, height 0.35s;
}
.atv-hdr .atv-brand-wm {
    display: block;
    flex-shrink: 0;
    width: 106.4px;
    height: 26px;
    transition: width 0.35s, height 0.35s;
}
.atv-hdr.is-scrolled a.atv-hdr__brand {
    gap: 9px;
    padding: 4px 5px 4px 16px;
}
.atv-hdr.is-scrolled .atv-brand-tv {
    width: 40px;
    height: 40px;
}
.atv-hdr.is-scrolled .atv-brand-tv svg {
    width: 20.7px;
    height: 24px;
}
.atv-hdr.is-scrolled .atv-brand-wm {
    width: 90px;
    height: 22px;
}
#animetvApp.day .atv-hdr a.atv-hdr__brand,
#animetvApp.day .atv-hdr a.atv-hdr__brand:hover {
    border-color: #dfe3eb;
    background: linear-gradient(180deg, #ffffff, #f1f3f8);
    box-shadow: inset 0 1px 0 #ffffff, 0 10px 24px -16px rgba(15, 23, 42, 0.4);
    color: #0f172a;
}
#animetvApp.day .atv-hdr .atv-brand-tv {
    background: radial-gradient(circle at 50% 40%, #ffb347, #fd8f00);
    box-shadow: 0 6px 16px -6px rgba(253, 143, 0, 0.9);
}

/* ---------- Nav ---------- */
.atv-hdr__nav {
    display: flex;
    align-items: center;
    gap: 30px;
    padding-top: 8px;
}
.atv-hdr a.atv-hdr__link {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 15px;
    font-weight: 600;
    color: var(--h-text-2);
    text-decoration: none;
    white-space: nowrap;
    text-shadow: var(--h-text-shadow);
    transition: color 0.2s, text-shadow 0.2s;
}
.atv-hdr a.atv-hdr__link:hover {
    color: var(--h-text);
    text-shadow: 0 0 18px rgba(245, 185, 66, 0.45);
}
.atv-hdr__dot {
    display: block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: transparent;
    transition: background-color 0.2s, box-shadow 0.2s;
}
.atv-hdr__link:hover .atv-hdr__dot {
    background: rgba(245, 185, 66, 0.6);
}
.atv-hdr a.atv-hdr__link.is-active {
    color: var(--h-text);
}
.atv-hdr__link.is-active .atv-hdr__dot {
    background: var(--h-accent);
    box-shadow: 0 0 10px rgba(245, 185, 66, 0.95);
}

/* ---------- Tools ---------- */
.atv-hdr__tools {
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.atv-hdr .atv-hdr__search {
    width: 250px;
    height: 44px;
    margin: 0;
    padding: 0 14px 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    border: 1px solid var(--h-chip-border);
    background: var(--h-chip);
    color: var(--h-text-2);
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: border-color 0.25s, box-shadow 0.25s, background-color 0.25s;
}
.atv-hdr .atv-hdr__search:hover {
    border-color: rgba(245, 185, 66, 0.5);
    box-shadow: 0 0 24px rgba(245, 185, 66, 0.2);
}
.atv-hdr__search > i {
    width: 28px;
    font-size: 15px;
}
.atv-hdr__search-txt {
    flex: 1;
    text-align: right;
    white-space: nowrap;
}
.atv-hdr kbd,
.atv-spot kbd {
    font-family: inherit;
    font-size: 10.5px;
    line-height: 20px;
    padding: 0 6px;
    border-radius: 6px;
    border: 1px solid var(--h-chip-border);
    border-bottom-width: 2px;
    background: var(--h-chip);
    color: var(--h-muted);
}
.atv-hdr .atv-hdr__icon {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--h-chip-border);
    background: var(--h-chip);
    color: var(--h-text);
    font-size: 16px;
    text-decoration: none;
    cursor: pointer;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: background-color 0.2s, box-shadow 0.2s;
}
.atv-hdr .atv-hdr__icon:hover {
    box-shadow: 0 0 20px rgba(245, 185, 66, 0.3);
}
.atv-hdr .atv-hdr__theme {
    color: var(--h-accent);
}
.atv-hdr__ping {
    position: absolute;
    top: 10px;
    left: 11px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--h-accent);
    box-shadow: 0 0 10px rgba(245, 185, 66, 0.9);
}
.atv-hdr .atv-hdr__avatar {
    display: block;
    width: 46px;
    height: 46px;
    margin: 0;
    padding: 2px;
    border: 0;
    border-radius: 50%;
    background: conic-gradient(from 210deg, #f5b942, #8b5cf6, #f5b942);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
    cursor: pointer;
    transition: box-shadow 0.2s;
}
.atv-hdr .atv-hdr__avatar[aria-expanded="true"] {
    box-shadow: 0 0 0 3px rgba(245, 185, 66, 0.25), 0 0 26px rgba(139, 92, 246, 0.55);
}
.atv-hdr__avatar img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #14151b;
}
#animetvApp.day .atv-hdr__avatar img {
    border-color: #ffffff;
}
.atv-hdr .atv-hdr__login {
    height: 44px;
    margin: 0;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffc964, #f0ab22);
    color: var(--h-accent-ink);
    font: inherit;
    font-size: 13.5px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 26px -10px rgba(245, 185, 66, 0.7);
}
.atv-hdr a:focus-visible,
.atv-hdr button:focus-visible,
.atv-spot a:focus-visible,
.atv-spot button:focus-visible,
.atv-tabbar a:focus-visible {
    outline: 2px solid var(--h-accent);
    outline-offset: 2px;
}

/* ---------- Spotlight search ---------- */
.atv-spot {
    position: fixed;
    inset: 0;
    z-index: 10040;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 12vh 16px 16px;
    direction: rtl;
    font-family: "IRANYekanX", "Vazirmatn", system-ui, sans-serif;
}
.atv-spot[hidden] {
    display: none;
}
.atv-spot__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(6, 7, 10, 0.6);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    animation: atvSpotFade 0.2s ease;
}
.atv-spot__panel {
    position: relative;
    width: 100%;
    max-width: 680px;
    max-height: 76vh;
    display: flex;
    flex-direction: column;
    border-radius: 22px;
    overflow: hidden;
    background: var(--h-panel);
    border: 1px solid var(--h-chip-border);
    box-shadow: 0 40px 90px -20px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(245, 185, 66, 0.14), 0 0 70px -10px rgba(245, 185, 66, 0.28);
    color: var(--h-text);
    animation: atvSpotPop 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes atvSpotFade {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes atvSpotPop {
    from { opacity: 0; transform: translateY(-12px) scale(0.98); }
    to { opacity: 1; transform: none; }
}
.atv-spot .atv-spot__form {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin: 0;
}
.atv-spot__row {
    height: 64px;
    flex-shrink: 0;
    padding: 0 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--h-line);
}
.atv-spot__ico {
    color: var(--h-accent);
    font-size: 18px;
}
.atv-spot .atv-spot__input {
    flex: 1;
    min-width: 0;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    box-shadow: none;
    color: var(--h-text);
    font: inherit;
    font-size: 17px;
}
.atv-spot .atv-spot__input::placeholder {
    color: var(--h-muted);
}
.atv-spot .atv-spot__input::-webkit-search-cancel-button {
    display: none;
}
.atv-spot .atv-spot__clear,
.atv-spot .atv-spot__esc {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--h-muted);
    cursor: pointer;
}
.atv-spot .atv-spot__clear {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}
.atv-spot__filters {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 18px 6px;
}
.atv-spot__chip {
    position: relative;
    margin: 0;
    cursor: pointer;
}
.atv-spot__chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.atv-spot__chip span {
    height: 32px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid var(--h-chip-border);
    color: var(--h-text-2);
    font-size: 12.5px;
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s;
}
.atv-spot__chip input:checked + span {
    background: var(--h-text);
    border-color: var(--h-text);
    color: var(--h-glass);
    font-weight: 800;
}
#animetvApp.day .atv-spot__chip input:checked + span {
    color: #ffffff;
}
.atv-spot__chip input:focus-visible + span {
    outline: 2px solid var(--h-accent);
    outline-offset: 2px;
}

/* Live results reuse the existing AJAX markup, shown inline in the panel */
.atv-spot .cmd-live-search-panel {
    position: relative;
    inset: auto;
    display: none;
    min-width: 0;
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    border: 0;
    border-radius: 0;
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
}
.atv-spot .cmd-live-search-panel.is-open {
    display: block;
}
.atv-spot .cmd-live-list {
    max-height: none;
}
.atv-spot__panel:has(.cmd-live-search-panel.is-open) .atv-spot__quick {
    display: none;
}
.atv-spot__quick {
    flex-shrink: 0;
    padding: 10px 18px 16px;
}
.atv-spot__quick-title {
    display: block;
    margin-bottom: 8px;
    font-size: 11.5px;
    color: var(--h-muted);
}
.atv-spot__links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.atv-spot .atv-spot__links a {
    height: 36px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-radius: 999px;
    border: 1px solid var(--h-chip-border);
    color: var(--h-text-2);
    font-size: 12.5px;
    text-decoration: none;
    transition: border-color 0.2s, color 0.2s;
}
.atv-spot .atv-spot__links a:hover {
    border-color: rgba(245, 185, 66, 0.5);
    color: var(--h-text);
}
.atv-spot__foot {
    flex-shrink: 0;
    height: 44px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-top: 1px solid var(--h-line);
    font-size: 12px;
    color: var(--h-muted);
}
.atv-spot__foot span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
body.animetv-native-body.atv-spot-open {
    overflow: hidden !important;
}

/* ---------- Phone tab bar ---------- */
.atv-tabbar {
    display: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    body.animetv-native-body header.atv-hdr > .atv-hdr__in {
        gap: 24px;
    }
    .atv-hdr__nav {
        gap: 20px;
    }
    .atv-hdr .atv-hdr__search {
        width: 200px;
    }
}
@media (max-width: 980px) {
    .atv-hdr__nav {
        display: none;
    }
    .atv-hdr .atv-hdr__search {
        width: 44px;
        padding: 0;
        justify-content: center;
    }
    .atv-hdr__search > i {
        width: auto;
    }
    .atv-hdr__search-txt,
    .atv-hdr__search kbd {
        display: none;
    }
}
@media (max-width: 820px) {
    body.animetv-native-body header.atv-hdr {
        height: 62px;
    }
    .atv-hdr-spacer {
        height: 68px;
    }
    body.animetv-native-body header.atv-hdr.is-scrolled {
        height: 58px;
    }
    .atv-hdr a.atv-hdr__brand,
    .atv-hdr.is-scrolled a.atv-hdr__brand {
        gap: 8px;
        padding: 4px 5px 4px 14px;
    }
    .atv-hdr .atv-brand-tv,
    .atv-hdr.is-scrolled .atv-brand-tv {
        width: 34px;
        height: 34px;
    }
    .atv-hdr .atv-brand-tv svg,
    .atv-hdr.is-scrolled .atv-brand-tv svg {
        width: 18.1px;
        height: 21px;
    }
    .atv-hdr .atv-brand-wm,
    .atv-hdr.is-scrolled .atv-brand-wm {
        width: 73.6px;
        height: 18px;
    }
    .atv-hdr__tools {
        gap: 8px;
    }
    .atv-hdr .atv-hdr__icon,
    .atv-hdr .atv-hdr__search,
    .atv-hdr .atv-hdr__avatar {
        width: 40px;
        height: 40px;
    }
    .atv-hdr .atv-hdr__login {
        width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
    }
    .atv-hdr__login span {
        display: none;
    }

    .atv-tabbar {
        position: fixed;
        right: 12px;
        left: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        z-index: 890;
        height: 64px;
        display: flex;
        align-items: center;
        padding: 0 6px;
        border-radius: 22px;
        background: rgba(22, 23, 30, 0.84);
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.8);
        direction: rtl;
        font-family: "IRANYekanX", "Vazirmatn", system-ui, sans-serif;
    }
    #animetvApp.day .atv-tabbar {
        background: rgba(255, 255, 255, 0.92);
        border-color: rgba(15, 23, 42, 0.08);
        box-shadow: 0 14px 34px -12px rgba(15, 23, 42, 0.25);
    }
    .atv-tabbar a {
        flex: 1;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: var(--h-muted);
        font-size: 10.5px;
        text-decoration: none;
    }
    .atv-tabbar a i.fa-regular {
        font-size: 17px;
    }
    .atv-tabbar__dot {
        width: 5px;
        height: 5px;
        border-radius: 50%;
    }
    .atv-tabbar a.is-active {
        color: var(--h-text);
        font-weight: 700;
    }
    .atv-tabbar a.is-active i.fa-regular {
        font-weight: 900;
    }
    .atv-tabbar a.is-active .atv-tabbar__dot {
        background: var(--h-accent);
        box-shadow: 0 0 8px rgba(245, 185, 66, 0.95);
    }
    .atv-tabbar a.is-vip {
        color: var(--h-accent);
    }
    #animetvApp.day .atv-tabbar a.is-vip {
        color: #9a6200;
    }
    #animetvApp .main-content {
        padding-bottom: 104px;
    }
    body.has-music-player .atv-tabbar {
        bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    }
    body.has-music-player #animetvApp .main-content {
        padding-bottom: 180px;
    }
}
@media (max-width: 640px) {
    .atv-spot {
        padding: 0;
    }
    .atv-spot__panel {
        max-width: none;
        max-height: none;
        height: 100%;
        border-radius: 0;
        border-width: 0;
    }
    .atv-spot__foot {
        display: none;
    }
}
/* Narrow phones: the logo capsule steps down so the header row (logo + four round buttons) still fits. */
@media (max-width: 400px) {
    .atv-hdr a.atv-hdr__brand,
    .atv-hdr.is-scrolled a.atv-hdr__brand {
        gap: 7px;
        padding: 4px 4px 4px 12px;
    }
    .atv-hdr .atv-brand-tv,
    .atv-hdr.is-scrolled .atv-brand-tv {
        width: 32px;
        height: 32px;
    }
    .atv-hdr .atv-brand-wm,
    .atv-hdr.is-scrolled .atv-brand-wm {
        width: 65.5px;
        height: 16px;
    }
}
@media (max-width: 380px) {
    .atv-hdr a.atv-hdr__brand,
    .atv-hdr.is-scrolled a.atv-hdr__brand {
        gap: 6px;
        padding: 3px 3px 3px 10px;
    }
    .atv-hdr .atv-brand-tv,
    .atv-hdr.is-scrolled .atv-brand-tv {
        width: 30px;
        height: 30px;
    }
    .atv-hdr .atv-brand-tv svg,
    .atv-hdr.is-scrolled .atv-brand-tv svg {
        width: 16.4px;
        height: 19px;
    }
    .atv-hdr .atv-brand-wm,
    .atv-hdr.is-scrolled .atv-brand-wm {
        width: 57.3px;
        height: 14px;
    }
}
@media (max-width: 340px) {
    .atv-hdr .atv-brand-wm,
    .atv-hdr.is-scrolled .atv-brand-wm {
        display: none;
    }
    .atv-hdr a.atv-hdr__brand,
    .atv-hdr.is-scrolled a.atv-hdr__brand {
        padding: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .atv-hdr,
    .atv-hdr *,
    .atv-spot__panel,
    .atv-spot__backdrop {
        transition: none !important;
        animation: none !important;
    }
}
