/*
 * SON TV Header — Phase 3A.0
 *
 * Two-row editorial header: date strip → logo/courts/utility → nav → ticker.
 * Scoped to .sontv-header and .sontv-* classes.
 */


/* ==========================================================================
   HIDE PARENT ELEMENTS
   Parent's header elements are no longer in our markup, but their CSS
   from style.php still loads. These overrides are a safety net in case
   any parent element leaks through (e.g. via a plugin or widget).
   ========================================================================== */

#topbar,
#authorityBar,
#mainMenu,
#breakingGroup,
#headerSocial,
.bannerAd {
    display: none !important;
}

/* #header-cont is reused as the mobile bar wrapper (for parent JS compat).
   Parent's style.php styles #header-cont with margin/position for the old layout.
   We reset everything and hide on desktop, show on mobile. */
#header-cont.sontv-mobile-bar {
    display: none;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    position: static;
    float: none;
    width: auto;
    height: auto;
}

/* Also hide the inner container div that parent expects */
#header-cont.sontv-mobile-bar .innerContainer {
    display: contents;
}


/* ==========================================================================
   HEADER CONTAINER
   ========================================================================== */

.sontv-header {
    background: var(--color-bg);
}


/* ==========================================================================
   DATE STRIP
   ========================================================================== */

.sontv-datestrip {
    text-align: center;
    font-family: var(--font-sans);
    font-size: 11px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: 8px 0 12px;
    border-bottom: 1px solid var(--color-hairline);
}

.sontv-datestrip__sep {
    margin: 0 8px;
    color: var(--color-border);
}


/* ==========================================================================
   ROW 1 — LOGO + COURTS + UTILITY
   ========================================================================== */

.sontv-header-row1 {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
    padding: 8px 24px;
    border-bottom: 1px solid var(--color-hairline);
    max-width: 1200px;
    margin: 0 auto;
}

/* Logo */
.sontv-header__logo {
    display: block;
    text-decoration: none;
}

.sontv-header__logo h1,
.sontv-header__logo span {
    margin: 0;
    padding: 0;
    line-height: 1;
}

.sontv-header__logo img {
    display: block;
    width: 72px;
    height: 72px;
    object-fit: contain;
}

/* Court logos */
.sontv-header__courts {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
}

.sontv-header__courts a {
    display: inline-flex;
    align-items: center;
}

.sontv-header__courts img {
    display: block;
    width: 40px;
    height: 40px;
    object-fit: contain;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

.sontv-header__courts a:hover img {
    opacity: 1;
}

/* Utility (social + search) */
.sontv-header__utility {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sontv-social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    transition: color 0.2s ease;
    text-decoration: none;
}

.sontv-social-icon:hover {
    color: var(--color-accent);
}

/* Expandable search form — :focus-within toggle, no JS, AMP-safe */
.sontv-search {
    display: inline-flex;
    align-items: center;
    padding-left: 14px;
    margin-left: 6px;
    border-left: 1px solid var(--color-border);
    position: relative;
}

.sontv-search__input {
    width: 0;
    padding: 0;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--color-text);
    opacity: 0;
    transition: width 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
}

.sontv-search:focus-within .sontv-search__input {
    width: 180px;
    padding: 6px 8px;
    opacity: 1;
    border-bottom: 1px solid var(--color-border);
}

.sontv-search__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    color: var(--color-text);
    transition: color 0.2s ease;
    line-height: 1;
}

.sontv-search__btn:hover {
    color: var(--color-accent);
}


/* ==========================================================================
   ROW 2 — MAIN NAVIGATION
   ========================================================================== */

.sontv-header-row2 {
    padding: 12px 24px;
    border-bottom: 1px solid var(--color-text);
}

.sontv-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 28px;
    justify-content: center;
    align-items: center;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sontv-nav a {
    color: var(--color-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.sontv-nav a:hover {
    color: var(--color-accent);
}

.sontv-nav__home {
    font-size: 17px;
    line-height: 1;
    vertical-align: middle;
    position: relative;
    top: -1px;
}

/* Diger dropdown */
.sontv-nav__diger {
    position: relative;
}

.sontv-nav__diger > a {
    color: var(--color-text-muted);
}

.sontv-nav__dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    list-style: none;
    margin: 12px 0 0;
    padding: 12px 0;
    min-width: 220px;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Invisible bridge covers the 12px margin gap so hover stays active */
.sontv-nav__diger::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 12px;
}

.sontv-nav__diger:hover .sontv-nav__dropdown,
.sontv-nav__diger:focus-within .sontv-nav__dropdown {
    display: block;
}

.sontv-nav__dropdown li {
    display: block;
    padding: 0;
}

.sontv-nav__dropdown a {
    display: block;
    padding: 8px 18px;
    font-size: 13px;
    letter-spacing: 0.3px;
    text-transform: none;
    font-weight: 400;
}

.sontv-nav__dropdown a:hover {
    background: var(--color-bg-subtle);
    color: var(--color-accent);
}


/* ==========================================================================
   MOBILE HEADER BAR
   ========================================================================== */

.sontv-mobile-bar {
    display: none;
}

/* Hamburger menu panel restyling */
#hamburgermenu {
    background: var(--color-bg);
}

#hamburgermenu .logoBlock {
    border-bottom: 1px solid var(--color-hairline);
    background: var(--color-bg);
}

#hamburgermenu .logoBlock img {
    max-height: 40px;
    width: auto;
}

/* Hamburger social icons — use our clean SVG row */
.sontv-hamburger-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--color-hairline);
}

.sontv-hamburger-social a {
    display: inline-flex;
    align-items: center;
    color: var(--color-text);
    transition: color 0.2s ease;
}

.sontv-hamburger-social a:hover {
    color: var(--color-accent);
}

/* Hide parent's sprite-based social inside hamburger */
#mobileSocial .safirSocial {
    display: none;
}

/* Court logos in hamburger — smaller, restrained */
#mobileAuthority {
    padding: 10px 15px;
    border-bottom: 1px solid var(--color-hairline);
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--color-bg);
}

#mobileAuthority a {
    display: inline-flex;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

#mobileAuthority a:hover {
    opacity: 1;
}

#mobileAuthority img {
    height: 22px;
    width: auto;
}

/* Mobile menu nav items */
#mobilemenu a {
    font-family: var(--font-sans);
    font-size: 15px;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-hairline);
}

#mobilemenu a:hover {
    color: var(--color-accent);
}


/* ==========================================================================
   RESPONSIVE — TABLET (768px - 1024px)
   ========================================================================== */

@media all and (max-width: 1024px) {
    .sontv-header-row1 {
        gap: 16px;
        padding: 12px 16px;
    }

    .sontv-header__courts {
        gap: 12px;
    }

    .sontv-header__courts img {
        width: 34px;
        height: 34px;
    }

    .sontv-nav {
        gap: 20px;
        font-size: 13px;
    }
}


/* ==========================================================================
   RESPONSIVE — MOBILE (<768px)
   ========================================================================== */

@media all and (max-width: 768px) {

    /* The header element itself is sticky on mobile — sticking range is
       #safirPage (full page height) rather than .sontv-header's own 72px
       (which would trap a sticky bar nested inside it: containing block
       = sticky element height → no room to stick). Background already
       set globally on .sontv-header (header.css:50) so the sticky bar is
       opaque on scroll. z-index: 100 sits above #wrapper (30) and any
       in-content positioned elements; well below the search overlay
       (9999), hamburger drawer (999999), and its backdrop (999998). */
    .sontv-header {
        position: sticky;
        top: 0;
        z-index: 100;
    }

    /* Show mobile bar, hide desktop elements.
       Sticky lives on .sontv-header (rule above). The bar itself stays
       position: relative because it is the containing block for its
       absolutely-positioned children (back button, absolute-centered logo). */
    #header-cont.sontv-mobile-bar,
    .sontv-mobile-bar {
        display: flex;
        align-items: center;
        height: 72px;
        padding: 0 12px;
        border-bottom: 1px solid var(--color-text);
        background: var(--color-bg);
        position: relative;
    }

    .sontv-datestrip,
    .sontv-header-row1,
    .sontv-header-row2 {
        display: none;
    }

    /* Mobile bar layout: [hamburger] [logo absolute-centered] [search]
       Logo is removed from flex flow and centered on the viewport so its
       position is independent of hamburger/search widths and of the
       back button's presence. Combined translate handles both axes
       (align-items: center on the bar no longer applies to a non-flex
       child). */
    .sontv-mobile-bar__logo {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    .sontv-mobile-bar__logo h1,
    .sontv-mobile-bar__logo span {
        margin: 0;
        padding: 0;
        line-height: 1;
        display: inline-block;
    }

    .sontv-mobile-bar__logo img {
        max-height: 60px;
        width: auto;
    }

    .sontv-mobile-bar__search {
        display: flex;
        align-items: center;
        justify-content: center;
        padding-left: 0;
        margin-left: auto;
        border-left: none;
    }

    .sontv-mobile-bar__search:focus-within {
        position: absolute;
        right: 12px;
        left: 56px;
        top: 50%;
        transform: translateY(-50%);
        background: var(--color-bg);
        z-index: 10;
    }

    .sontv-mobile-bar__search .sontv-search__input {
        font-size: 16px;
    }

    .sontv-mobile-bar__search:focus-within .sontv-search__input {
        width: 100%;
        flex: 1;
        border-bottom: 1px solid var(--color-text);
    }

    /* Hamburger toggle — reuse parent's .toggleMenu + #header-cont for JS compat.
       Parent's style.php has:
         desktop: #header-cont .toggleMenu { display: none }
         mobile (≤1080px): #header-cont .toggleMenu { display: block; position: absolute; ... }
       We override both to use our flex layout + inline SVG icon. */
    #header-cont.sontv-mobile-bar .toggleMenu {
        position: static !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        cursor: pointer;
        background: none !important;
        border: none !important;
        color: var(--color-text);
        z-index: 10;
    }

    /* SVG inside toggle inherits pointer-events from parent */
    #header-cont.sontv-mobile-bar .toggleMenu svg {
        pointer-events: none;
    }

    /* Hide parent's sprite-based pseudo-element */
    #header-cont.sontv-mobile-bar .toggleMenu:before {
        display: none !important;
        content: none !important;
    }

}


/* ==========================================================================
   SON DAKIKA TICKER (site-wide, moved from home.css)
   ========================================================================== */

.sd-ticker {
    display: flex;
    align-items: center;
    border: none;
    height: 42px;
    overflow: hidden;
    background: var(--color-accent);
    padding-left: 24px;
}

.sd-label {
    flex-shrink: 0;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #fff;
    padding: 0 16px 0 4px;
    display: flex;
    align-items: center;
}

.sd-label::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    margin-right: 8px;
    animation: sd-blink 1.4s infinite;
    vertical-align: middle;
}

@keyframes sd-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.sd-track {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.sd-content {
    display: flex;
    white-space: nowrap;
    animation: sd-scroll 30s linear infinite;
}

.sd-content:hover {
    animation-play-state: paused;
}

@keyframes sd-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.sd-fade {
    position: absolute;
    top: 0;
    right: 0;
    width: 60px;
    height: 100%;
    background: linear-gradient(to right, transparent, var(--color-accent));
    pointer-events: none;
}

.sd-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
    transition: opacity 0.15s ease;
}

/* High-specificity + !important: parent style.php may reset anchor margins.
   margin-right on every item creates the inter-item spacing AND the gap
   between the two copies, making translateX(-50%) exact for seamless loop. */
.sd-ticker .sd-track .sd-content .sd-item {
    margin-right: 36px !important;
}

.sd-item:hover {
    opacity: 0.8;
    color: #fff;
}

.sd-dot {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1;
}

.sd-title {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
}

.sd-time {
    font-family: var(--font-sans);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

/* Ticker — mobile adjustments */
@media all and (max-width: 768px) {
    .sd-ticker {
        height: 38px;
        padding-left: 10px;
    }

    .sd-label {
        font-size: 10px;
        letter-spacing: 1px;
        padding: 0 10px 0 2px;
    }

    .sd-label::before {
        width: 6px;
        height: 6px;
        margin-right: 6px;
    }

    .sd-content {
        animation-duration: 8s;
    }

    .sd-ticker .sd-track .sd-content .sd-item {
        margin-right: 20px !important;
    }

    .sd-title {
        font-size: 13px;
    }

    .sd-time {
        font-size: 11px;
    }

    .sd-fade {
        width: 40px;
    }
}


/* ==========================================================================
   AMP SIDEBAR (replaces jQuery hamburger on AMP requests)
   ========================================================================== */

/* Toggle button — inherits .toggleMenu base styles, reset button defaults */
.sontv-amp-toggle {
    background: none;
    border: none;
    cursor: pointer;
}

/* Sidebar interior */
amp-sidebar .sontv-amp-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--color-hairline);
}

amp-sidebar .sontv-amp-sidebar__header img {
    max-height: 40px;
    width: auto;
}

amp-sidebar .sontv-amp-sidebar__close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--color-text);
}

amp-sidebar .sontv-amp-sidebar__nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

amp-sidebar .sontv-amp-sidebar__nav li {
    border-bottom: 1px solid var(--color-hairline);
}

amp-sidebar .sontv-amp-sidebar__nav a {
    display: block;
    padding: 14px 16px;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 500;
    color: var(--color-text);
    text-decoration: none;
}

amp-sidebar .sontv-amp-sidebar__nav a:hover {
    color: var(--color-accent);
}


/* ==========================================================================
   ZONE DIVIDERS — Item 5
   Subtle 1px vertical lines between header zones.
   Desktop Row 1: logo | courts | utility
   Mobile bar:    hamburger | logo | search
   ========================================================================== */

.sontv-header-row1 .sontv-header__courts {
    border-left: 1px solid var(--color-hairline);
    padding-left: 12px;
}

.sontv-header-row1 .sontv-header__utility {
    border-left: 1px solid var(--color-hairline);
    padding-left: 12px;
}

@media all and (max-width: 768px) {
    #header-cont.sontv-mobile-bar .sontv-mobile-bar__search {
        border-left: 1px solid var(--color-hairline);
        padding-left: 10px;
    }
}


/* ==========================================================================
   SEARCH OVERLAY — Item 6a
   Single shared overlay opened by .js-sontv-search-open, closed by
   .js-sontv-search-close, Escape key, or backdrop click.
   Body-scroll lock uses html.sontv-search-open (not body inline style)
   so it does NOT conflict with parent's hamburger overlay handler
   which manipulates body.style.overflow directly.
   ========================================================================== */

.sontv-search-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: none;
    border: none;
    color: var(--color-text);
    cursor: pointer;
    transition: color 0.15s ease;
}

.sontv-search-trigger:hover,
.sontv-search-trigger:focus-visible {
    color: var(--color-accent);
    outline: none;
}

html.sontv-search-open {
    overflow: hidden;
}

.sontv-search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 26, 0.78);
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 18vh 16px 0;
    opacity: 1;
    transition: opacity 0.18s ease;
}

.sontv-search-overlay[hidden] {
    display: none;
}

.sontv-search-overlay__inner {
    position: relative;
    width: 100%;
    max-width: 720px;
}

.sontv-search-overlay__form {
    display: flex;
    align-items: center;
    background: var(--color-bg);
    border-radius: 4px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
    padding: 4px 4px 4px 18px;
}

.sontv-search-overlay__label {
    position: absolute;
    left: -9999px;
}

.sontv-search-overlay__input {
    flex: 1;
    min-width: 0;
    min-height: 56px;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 20px;
    color: var(--color-text);
    padding: 8px 12px 8px 0;
}

.sontv-search-overlay__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Item 6a-fix: hide redundant submit button inside overlay.
   Form still submits on Enter; input type=search shows a native "Ara" key
   on mobile soft keyboards. */
.sontv-search-overlay__submit {
    display: none;
}

.sontv-search-overlay__close {
    position: absolute;
    top: -52px;
    right: 0;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media all and (max-width: 768px) {
    .sontv-search-overlay {
        padding: 12vh 12px 0;
    }
    .sontv-search-overlay__input {
        font-size: 18px;
        min-height: 48px;
    }
    .sontv-search-overlay__submit {
        width: 48px;
        height: 48px;
    }
}

/* Item 6a-fix2: the legacy .sontv-mobile-bar__search:focus-within rule
   (header.css:471) was written for the old expandable form input — it
   repositions the form to span the mobile bar when its input is focused.
   The new trigger button keeps .sontv-mobile-bar__search for the Item 5
   divider, but should NOT inherit that reposition. The user saw the
   trigger jump next to the hamburger (red, due to focus-visible) and
   read it as a duplicate button. This neutralizes the inherited focus
   reposition; the focus-visible color remains for keyboard a11y. */
@media all and (max-width: 768px) {
    #header-cont.sontv-mobile-bar .sontv-search-trigger:focus,
    #header-cont.sontv-mobile-bar .sontv-search-trigger:focus-within {
        position: static;
        right: auto;
        left: auto;
        top: auto;
        transform: none;
        background: none;
        z-index: auto;
    }
}


/* ==========================================================================
   GERİ BACK BUTTON — Item 2 (NYT-minimal restyle, v3)
   Visible on all non-home pages (PHP-guarded via is_front_page()).
   Inline Lucide arrow-left SVG, stroke-width 2.5 (a touch bolder than the
   stroke-2 hamburger/search icons for visibility). Transparent button,
   color inherits via currentColor.
   Mobile: 24px icon, button ≥44x44 tap target.
   Desktop: absolute at far-left of the date strip, 18px icon — does NOT
   alter the bar height (centered date text stays put).
   ========================================================================== */

.sontv-back-btn {
    background: transparent;
    border: 0;
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    cursor: pointer;
    line-height: 1;
    font-family: var(--font-sans);
    font-weight: 400;
}

.sontv-back-btn:hover,
.sontv-back-btn:focus {
    opacity: 0.6;
    outline: none;
}

/* Desktop variant: absolute far-left, no min size — fits inside the
   existing date strip height without disrupting the centered text. */
.sontv-datestrip {
    position: relative;
}

.sontv-back-btn--desktop {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    min-width: auto;
    min-height: auto;
    padding: 4px 6px;
}

.sontv-back-btn--desktop svg {
    width: 18px;
    height: 18px;
}

/* Mobile variant: pull out of the flex flow so the logo cell ignores
   the back button entirely. Parity with homepage: flex children become
   [hamburger][logo flex:1][search], exactly as on is_front_page().
   left: 52px = 12px bar padding + 40px hamburger width. */
@media all and (max-width: 768px) {
    .sontv-mobile-bar .sontv-back-btn {
        position: absolute;
        left: 52px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1;
    }
}
