/**
 * Vinathis CMS — Sticky Header Shared CSS
 * Works across all themes: newsportal, magazine, default
 * Strategy:
 *   - When user scrolls DOWN past header height → show compact sticky bar (logo + nav)
 *   - When user scrolls UP → keep showing sticky bar (accessibility)
 *   - Smooth slide-in/slide-out animation
 *   - Full responsive: mobile hamburger retained
 *
 * Usage (PHP): <?php echo sticky_header_js(); ?> in footer OR:
 *   <link rel="stylesheet" href="<?php echo url('themes/shared/sticky-header.css'); ?>">
 *   <script src="<?php echo url('themes/shared/sticky-header.js'); ?>"></script>
 */

/* ── Floating Sticky Bar ─────────────────────────────────────── */
.sticky-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9000;
    background: var(--dark, #111827);
    box-shadow: 0 2px 16px rgba(0,0,0,.25);

    /* Hidden state */
    transform: translateY(-110%);
    opacity: 0;
    transition: transform .28s cubic-bezier(.4,0,.2,1),
                opacity   .28s ease;
    will-change: transform;
}

.sticky-bar.is-visible {
    transform: translateY(0);
    opacity: 1;
}

/* Inner layout */
.sticky-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 20px;
    max-width: 1200px;
    margin: 0 auto;
    gap: 16px;
}

/* Logo in sticky bar */
.sticky-bar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    font-weight: 800;
    font-size: 18px;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
}

.sticky-bar-logo img {
    max-height: 34px;
    width: auto;
}

.sticky-bar-logo-text {
    font-size: 17px;
    letter-spacing: -.3px;
}

/* Nav links in sticky bar */
.sticky-bar-nav {
    display: flex;
    align-items: center;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.sticky-bar-nav li a {
    display: block;
    padding: 6px 14px;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-radius: 4px;
    transition: background .18s, color .18s;
    white-space: nowrap;
}

.sticky-bar-nav li a:hover,
.sticky-bar-nav li a.active {
    background: rgba(255,255,255,.12);
    color: #fff;
}

/* Search + Actions in sticky bar */
.sticky-bar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sticky-search-btn {
    background: none;
    border: 1px solid rgba(255,255,255,.3);
    color: rgba(255,255,255,.85);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background .18s, border-color .18s;
}

.sticky-search-btn:hover {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.6);
    color: #fff;
}

.sticky-back-top {
    background: var(--primary, #b91c1c);
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .18s, transform .18s;
    text-decoration: none;
}

.sticky-back-top:hover {
    background: rgba(255,255,255,.2);
    transform: translateY(-2px);
}

/* ── Scroll-to-top floating button ───────────────────────────── */
.scroll-top-btn {
    position: fixed;
    bottom: 28px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: var(--primary, #b91c1c);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    z-index: 8999;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .25s ease, transform .25s ease;
    pointer-events: none;
}

.scroll-top-btn.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.scroll-top-btn:hover {
    background: var(--primary-dark, #991b1b);
    transform: translateY(-3px);
}

/* ── Placeholder div to prevent layout jump ─────────────────── */
.sticky-placeholder {
    display: none;
}

/* ── Color variations per theme ─────────────────────────────── */
.theme-newsportal .sticky-bar { background: #111827; }
.theme-newsportal .sticky-bar-nav li a:hover,
.theme-newsportal .sticky-bar-nav li a.active { background: rgba(185,28,28,.6); }

.theme-magazine   .sticky-bar { background: #101010; }
.theme-magazine   .sticky-bar-nav li a:hover,
.theme-magazine   .sticky-bar-nav li a.active { background: var(--primary, #c92a2a); }

.theme-default    .sticky-bar { background: #1d2a3e; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sticky-bar-nav {
        display: none; /* hamburger shows on mobile via original nav */
    }

    .sticky-bar-inner {
        padding: 0 14px;
    }

    .sticky-bar-logo-text {
        font-size: 14px;
    }

    .scroll-top-btn {
        bottom: 18px;
        right: 14px;
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .sticky-bar-actions .sticky-search-btn {
        display: none;
    }
}

/* ── Progress indicator ──────────────────────────────────────── */
.read-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--primary, #b91c1c);
    z-index: 9001;
    width: 0%;
    transition: width .1s linear;
}
