/* =========================================================
   HEADER — App-Style Sticky Header + Drawer + Bottom Nav
   Fully responsive.
   ========================================================= */

/* =========================================================
   1. GLOBAL HEADER SHELL
   ========================================================= */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    transition: box-shadow .25s ease, background .25s ease;
}
.site-header.scrolled {
    box-shadow: 0 4px 20px rgba(8, 24, 58, 0.06);
    background: rgba(255, 255, 255, 0.95);
}

/* =========================================================
   2. HEADER CONTAINER (allows wrapping on mobile)
   ========================================================= */
.header-main { padding: 10px 0; }
.header-main .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

/* =========================================================
   3. SITE BRANDING
   ========================================================= */
.site-branding {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    order: 1;
}
.site-branding .site-title {
    font-family: 'Poppins', sans-serif;
    font-size: 22px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -.5px;
    line-height: 1;
}
.site-branding .site-title a {
    color: var(--navy-dark);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.site-branding .site-title a span { color: var(--primary); }
.site-branding img.custom-logo {
    max-height: 38px;
    width: auto;
}
.site-branding .site-description { display: none; }

.tso-logo-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: linear-gradient(135deg, #0066ff 0%, #0052cc 100%);
    color: #fff;
    font-size: 17px;
    box-shadow: 0 6px 14px rgba(0, 102, 255, 0.28);
    flex-shrink: 0;
}

.tso-logo-link {
    text-decoration: none !important;
    display: inline-block;
}
.tso-text-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.tso-logo-text-group {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.tso-logo-brand {
    font-family: 'Poppins', sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: #08183a;
    letter-spacing: -.3px;
}
.tso-logo-tagline {
    font-size: 10px;
    color: #64748b;
    font-weight: 600;
    letter-spacing: .2px;
    margin-top: 2px;
}

/* =========================================================
   4. SEARCH BARS
   ========================================================= */
.tso-header-search-pill {
    position: relative;
    flex: 1 1 auto;
    max-width: 480px;
    margin: 0 auto;
    order: 2;
}
.tso-header-search-pill .tso-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 14px;
    pointer-events: none;
    transition: color .2s ease;
    z-index: 2;
}
.tso-header-search-pill input[type="search"] {
    width: 100%;
    padding: 11px 18px 11px 42px;
    background: #f1f5f9;
    border: 1.5px solid transparent;
    border-radius: 999px;
    font-size: 14px;
    font-family: inherit;
    color: #0f172a;
    outline: none;
    transition: all .22s ease;
    -webkit-appearance: none;
    appearance: none;
}
.tso-header-search-pill input[type="search"]::placeholder {
    color: #94a3b8;
    font-weight: 500;
}
.tso-header-search-pill input[type="search"]:focus {
    background: #ffffff;
    border-color: #0066ff;
    box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.12);
}

.header-search {
    position: relative;
    max-width: 320px;
    flex: 1 1 auto;
    order: 2;
}
.header-search input[type="search"] {
    width: 100%;
    padding: 10px 42px 10px 16px;
    background: #f1f5f9;
    border: 1.5px solid transparent;
    border-radius: 999px;
    font-size: 13px;
    outline: none;
    transition: all .22s ease;
    -webkit-appearance: none;
    appearance: none;
}
.header-search input[type="search"]:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.12);
}
.header-search button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: transform .2s ease, background .2s ease;
}
.header-search button:hover {
    background: var(--primary-dark);
    transform: translateY(-50%) scale(1.06);
}

/* =========================================================
   5. DESKTOP NAVIGATION
   ========================================================= */
.tso-nav-links {
    display: flex;
    align-items: center;
    order: 4;
}
.tso-nav-links ul,
.main-nav > .container > ul {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.tso-nav-links li,
.main-nav > .container > ul > li { position: relative; }

.tso-nav-links a,
.main-nav > .container > ul > li > a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 600;
    color: #08183a;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 10px;
    position: relative;
    transition: all .2s ease;
    letter-spacing: .1px;
}
.tso-nav-links a:hover,
.main-nav > .container > ul > li > a:hover {
    color: var(--primary);
    background: rgba(0, 102, 255, 0.06);
}
.tso-nav-links .current-menu-item > a,
.main-nav .current-menu-item > a {
    color: var(--primary);
    background: rgba(0, 102, 255, 0.08);
}

.tso-nav-links ul ul,
.main-nav ul ul {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 8px;
    box-shadow: 0 12px 32px rgba(8, 24, 58, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all .22s ease;
    flex-direction: column;
    align-items: stretch;
    z-index: 100;
    list-style: none;
}
.tso-nav-links li:hover > ul,
.main-nav li:hover > ul {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.tso-nav-links ul ul a,
.main-nav ul ul a {
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    border-radius: 8px;
    text-transform: none;
    letter-spacing: 0;
}
.tso-nav-links ul ul a:hover,
.main-nav ul ul a:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #f1f5f9;
    color: #08183a;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
    transition: all .2s ease;
    -webkit-tap-highlight-color: transparent;
    order: 3;
}
.menu-toggle:hover,
.menu-toggle:active {
    background: #e2e8f0;
    color: var(--primary);
    transform: scale(0.95);
}

/* =========================================================
   6. BREAKING NEWS TICKER
   ========================================================= */
.breaking-news {
    background: linear-gradient(90deg, #08183a 0%, #0f2350 100%);
    color: #fff;
    padding: 7px 0;
    overflow: hidden;
    font-size: 12.5px;
}
.breaking-news .container {
    display: flex;
    align-items: center;
    gap: 12px;
}
.breaking-label {
    background: linear-gradient(135deg, #ff3b30 0%, #e63946 100%);
    color: #fff;
    padding: 4px 11px;
    font-weight: 800;
    font-size: 10px;
    text-transform: uppercase;
    border-radius: 6px;
    letter-spacing: .5px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    animation: tso-pulse 1.6s ease-in-out infinite;
}
.breaking-label::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    animation: tso-dot 1.6s ease-in-out infinite;
}
@keyframes tso-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .75; }
}
@keyframes tso-dot {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.4); opacity: .6; }
}
.ticker-wrap { overflow: hidden; flex: 1; position: relative; }
.ticker {
    display: flex;
    gap: 36px;
    white-space: nowrap;
    animation: ticker 32s linear infinite;
}
.ticker:hover { animation-play-state: paused; }
.ticker a {
    color: #e2e8f0;
    font-size: 12.5px;
    font-weight: 500;
    transition: color .2s ease;
}
.ticker a:hover { color: #f59e0b; }
@keyframes ticker {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* =========================================================
   7. TSO SCREENSHOT HEADER VARIANT
   ========================================================= */
.tso-screenshot-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    padding: 10px 0;
}
.tso-screenshot-header .header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

/* =========================================================
   8. MOBILE BOTTOM NAV
   ========================================================= */
.tso-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(8, 24, 58, 0.06);
}
.tso-bottom-nav ul {
    display: flex;
    align-items: center;
    justify-content: space-around;
    list-style: none;
    margin: 0;
    padding: 0;
}
.tso-bottom-nav li { flex: 1; }
.tso-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 4px;
    font-size: 10.5px;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
    border-radius: 12px;
    transition: color .2s ease, background .2s ease;
    -webkit-tap-highlight-color: transparent;
}
.tso-bottom-nav a i { font-size: 18px; line-height: 1; }
.tso-bottom-nav a:active { background: rgba(0, 102, 255, 0.08); }
.tso-bottom-nav .current-menu-item > a,
.tso-bottom-nav a.active { color: var(--primary); }

/* =========================================================
   9. RESPONSIVE — Tablet (≤ 1024px)
   ========================================================= */
@media (max-width: 1024px) {
    .tso-header-search-pill { max-width: 360px; }
}

/* =========================================================
   10. RESPONSIVE — MOBILE DRAWER MODE (≤ 900px)
   ========================================================= */
@media (max-width: 900px) {

    .site-header,
    .tso-screenshot-header {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: #ffffff;
    }

    .header-main .container,
    .tso-screenshot-header .header-container {
        flex-wrap: wrap;
        row-gap: 10px;
    }

    .site-branding {
        order: 1;
        flex: 1 1 auto;
    }

    .menu-toggle {
        display: inline-flex;
        order: 2;
        flex: 0 0 auto;
    }

    .header-search,
    .tso-header-search-pill {
        order: 3;
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
        margin: 0;
    }

    .tso-nav-links,
    .main-nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: min(340px, 88vw);
        height: 100vh;
        height: 100dvh;
        background: #ffffff;
        box-shadow: -8px 0 40px rgba(8, 24, 58, 0.15);
        transform: translateX(105%);
        transition: transform .32s cubic-bezier(.4, 0, .2, 1);
        padding: 78px 20px 40px;
        padding-top: calc(78px + env(safe-area-inset-top));
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        z-index: 1001;
        display: block;
        border-top: none;
        list-style: none;
        visibility: hidden;
    }
    .tso-nav-links.open,
    .main-nav.open {
        transform: translateX(0);
        visibility: visible;
    }

    .tso-nav-links ul,
    .main-nav > .container > ul,
    .tso-nav-links > ul,
    .main-nav > ul {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 0;
        margin: 0;
        list-style: none;
    }
    .tso-nav-links a,
    .main-nav > .container > ul > li > a,
    .main-nav a {
        padding: 13px 16px;
        font-size: 15px;
        border-radius: 12px;
        text-transform: none;
        letter-spacing: 0;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .tso-nav-links a::after,
    .main-nav a::after { display: none !important; }

    .tso-nav-links ul ul,
    .main-nav ul ul {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        padding: 4px 0 4px 16px;
        display: none;
        background: transparent;
        border-radius: 0;
        min-width: 0;
        top: auto;
        left: auto;
    }
    .tso-nav-links li.open > ul,
    .main-nav li.open > ul {
        display: block;
    }

    body.tso-drawer-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(8, 24, 58, 0.55);
        z-index: 1000;
        animation: tso-fadeIn .25s ease;
    }
    @keyframes tso-fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    .tso-nav-links::before,
    .main-nav::before {
        content: '\00d7';
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
        position: absolute;
        top: calc(20px + env(safe-area-inset-top));
        right: 20px;
        width: 40px;
        height: 40px;
        border-radius: 12px;
        background: #f1f5f9;
        color: #08183a;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 26px;
        font-weight: 300;
        line-height: 1;
        cursor: pointer;
        transition: background .2s ease;
        z-index: 2;
    }
    .tso-nav-links::before:active,
    .main-nav::before:active {
        background: #e2e8f0;
    }

    .tso-bottom-nav { display: block; }
    body { padding-bottom: 74px; }
}

/* =========================================================
   11. RESPONSIVE — Small Tablet (≤ 768px)
   ========================================================= */
@media (max-width: 768px) {
    .site-header { padding: 8px 0; }
    .header-main { padding: 6px 0; }

    .menu-toggle {
        width: 40px;
        height: 40px;
        font-size: 16px;
        border-radius: 11px;
    }
}

/* =========================================================
   12. RESPONSIVE — Small Phones (≤ 640px)
   ========================================================= */
@media (max-width: 640px) {
    .tso-logo-brand { font-size: 17px; }
    .tso-logo-tagline { font-size: 9.5px; }
    .tso-logo-icon {
        width: 34px;
        height: 34px;
        font-size: 15px;
        border-radius: 10px;
    }
    .site-branding .site-title { font-size: 19px; }
    .site-branding img.custom-logo { max-height: 32px; }
    .menu-toggle { width: 40px; height: 40px; font-size: 16px; }
    .tso-header-search-pill input[type="search"] {
        padding: 10px 16px 10px 40px;
        font-size: 13.5px;
    }
    .breaking-label { font-size: 9px; padding: 3px 9px; }
    .ticker a { font-size: 12px; }
    .ticker { gap: 28px; }

    body.has-bottom-nav { padding-bottom: 74px; }
    body.has-bottom-nav .back-to-top {
        bottom: calc(74px + env(safe-area-inset-bottom) + 16px);
    }
    body.has-bottom-nav .share-bottom {
        bottom: calc(70px + env(safe-area-inset-bottom));
    }
}

/* =========================================================
   13. RESPONSIVE — Small Phones (≤ 480px)
   ========================================================= */
@media (max-width: 480px) {
    .site-header { padding: 6px 0; }
    .container { padding: 0 14px; }

    .tso-logo-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
        border-radius: 9px;
    }
    .tso-logo-brand { font-size: 16px; }
    .tso-logo-tagline { font-size: 9px; letter-spacing: 0; }

    .site-branding .site-title { font-size: 17px; }
    .site-branding img.custom-logo { max-height: 30px; }

    .tso-header-search-pill input[type="search"] {
        padding: 10px 14px 10px 38px;
        font-size: 14px;
        border-radius: 12px;
    }
    .tso-header-search-pill .tso-search-icon {
        left: 14px;
        font-size: 13px;
    }

    .breaking-news { padding: 6px 0; font-size: 11.5px; }
    .breaking-label {
        font-size: 9px;
        padding: 3px 8px;
        border-radius: 5px;
    }
    .breaking-label::before { width: 5px; height: 5px; }
    .ticker { gap: 22px; }
    .ticker a { font-size: 11.5px; }

    .tso-nav-links,
    .main-nav {
        width: 100vw;
        max-width: 100vw;
        padding: 70px 16px 40px;
        padding-top: calc(70px + env(safe-area-inset-top));
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
    }

    .tso-bottom-nav a { font-size: 10px; padding: 5px 2px; }
    .tso-bottom-nav a i { font-size: 17px; }

    body.has-bottom-nav .back-to-top {
        bottom: calc(70px + env(safe-area-inset-bottom) + 12px);
        right: 16px;
        width: 42px;
        height: 42px;
        font-size: 16px;
    }
}

/* =========================================================
   14. RESPONSIVE — Ultra Small (≤ 360px)
   ========================================================= */
@media (max-width: 360px) {
    .tso-logo-tagline { display: none; }
    .tso-logo-brand { font-size: 15px; }
}

/* =========================================================
   15. LANDSCAPE PHONES
   ========================================================= */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    .tso-nav-links,
    .main-nav {
        padding-top: calc(60px + env(safe-area-inset-top));
    }
    .tso-nav-links a,
    .main-nav a {
        padding: 10px 14px;
        font-size: 14px;
    }
}

/* =========================================================
   16. BODY SCROLL LOCK WHEN DRAWER OPEN
   ========================================================= */
body.tso-drawer-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* =========================================================
   17. TOUCH DEVICE ENHANCEMENTS
   ========================================================= */
@media (hover: none) and (pointer: coarse) {
    .tso-nav-links a:hover,
    .main-nav a:hover {
        background: transparent;
        color: #08183a;
    }
    .menu-toggle,
    .tso-header-search-pill input,
    .tso-bottom-nav a {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    .tso-nav-links a:active,
    .main-nav a:active {
        background: rgba(0, 102, 255, 0.1);
        color: var(--primary);
    }
    .menu-toggle:active { transform: scale(0.92); }
}

/* =========================================================
   18. MOMENTUM SCROLL FOR DRAWER
   ========================================================= */
.tso-nav-links,
.main-nav {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}