/* ==================================================
   ECOMNIGHTHQ — SHARED NAVBAR STYLESHEET
   Single source of truth for all pages
   ================================================== */

/* ==================================================
   TEXT SELECTION / COPY (works alongside the custom cursor)
   The custom cursor sets `cursor:none`, which hid the native I-beam and
   made selecting/copying text feel broken. Restore the I-beam over real
   text + give selection a visible highlight — only on fine-pointer devices.
   ================================================== */
::selection { background: rgba(77, 124, 255, 0.35); }
::-moz-selection { background: rgba(77, 124, 255, 0.35); }
@media (hover: hover) and (pointer: fine) {
    p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th, dd, dt,
    figcaption, .pol-body, .pol-body *, .course-gate .gate-terms,
    .course-item-title, .testimonial-text, .hero-desc, .section-desc {
        cursor: text;
    }
}

/* ==================================================
   SAFARI-SAFE BUTTON ICON ALIGNMENT
   Force icon + text to stay centered inside buttons (matches Chrome).
   Safari can drop flex-gap / mis-size inline SVGs, so pin the essentials.
   ================================================== */
.btn, .card-link, .svc-card-cta, .sc-plan-btn, .cd-buy-btn,
.section-btn, .course-item-btn, .form-submit-btn, .gs-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn > svg, .btn .icon-sm, .btn .icon-xs, .btn-arrow, .btn-play-icon,
.card-link svg, .svc-card-cta svg, .sc-plan-btn svg, .cd-buy-btn svg,
.section-btn svg, .course-item-btn svg {
    flex: 0 0 auto;
}
.btn-arrow > svg, .btn-play-icon > svg { width: 16px; height: 16px; display: block; }

/* Utility */
.desktop-only { display: flex; }
.mobile-only  { display: none !important; }

/* ==================================================
   NAV ICONS
   ================================================== */
.nav-icon {
    width: 15px;
    height: 15px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
    opacity: 0.7;
    transition: opacity 0.3s;
}
.nav-link:hover .nav-icon { opacity: 1; }
.nav-link.active .nav-icon { opacity: 1; color: var(--accent); }

.mobile-nav-icon {
    width: 22px;
    height: 22px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 12px;
    opacity: 0.6;
    flex-shrink: 0;
}

/* ==================================================
   THEME TOGGLE
   ================================================== */
.theme-toggle {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--btn-ghost-bg);
    border: 1px solid var(--border-glass);
    transition: all 0.3s var(--ease-out-expo);
    cursor: pointer;
    flex-shrink: 0;
}
.theme-toggle:hover {
    background: var(--btn-ghost-hover-bg);
    border-color: var(--border-hover);
    transform: scale(1.05);
}
.theme-toggle:active { transform: scale(0.95); }

.theme-icon {
    width: 18px;
    height: 18px;
    position: absolute;
    transition: all 0.4s var(--ease-out-expo);
    color: var(--text-primary);
}
[data-theme="dark"]  .sun-icon  { opacity: 1; transform: rotate(0deg) scale(1); }
[data-theme="dark"]  .moon-icon { opacity: 0; transform: rotate(-90deg) scale(0.5); }
[data-theme="light"] .sun-icon  { opacity: 0; transform: rotate(90deg) scale(0.5); }
[data-theme="light"] .moon-icon { opacity: 1; transform: rotate(0deg) scale(1); }

.theme-toggle-mobile { width: 36px; height: 36px; }
.theme-toggle-mobile .theme-icon { width: 16px; height: 16px; }

/* ==================================================
   NAVBAR
   ================================================== */
.navbar {
    position: fixed;
    top: var(--ticker-height);
    left: 0;
    width: 100%;
    height: var(--nav-height);
    z-index: 100;
    transition: all 0.7s var(--ease-out-expo);
    border-bottom: 1px solid transparent;
}
.navbar.scrolled {
    height: 64px;
    background: var(--nav-scrolled-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-glass);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 48px;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Logo */
.nav-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.3px;
    color: var(--text-primary);
}
.logo-mark {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--btn-ghost-bg);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    transition: all 0.3s;
    color: var(--logo-svg-color);
}
.nav-logo:hover .logo-mark {
    border-color: var(--border-hover);
    box-shadow: 0 0 20px var(--accent-dim);
}
.logo-text { opacity: 0.95; }

/* Nav Links */
.nav-links { display: flex; gap: 24px; }
.nav-link {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    position: relative;
    padding: 4px 0;
    transition: color 0.3s var(--ease-out-expo);
    display: inline-flex;
    align-items: center;
}
.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0%;
    height: 1px;
    background: var(--accent);
    transition: width 0.4s var(--ease-out-expo);
}
.nav-link:hover { color: var(--text-primary); }
.nav-link:hover::after { width: 100%; }
.nav-link.active { color: var(--text-primary); }
.nav-link.active::after { width: 100%; background: var(--text-primary); }

/* Nav Actions */
.nav-actions { display: flex; align-items: center; gap: 20px; }
.lang-switch {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-glass);
    background: var(--btn-ghost-bg);
    transition: all 0.3s;
}
.lang-switch:hover {
    background: var(--btn-ghost-hover-bg);
    border-color: var(--border-hover);
}
.lang-active  { color: var(--text-primary); }
.lang-divider { color: var(--border-subtle); }
.lang-dim     { color: var(--text-muted); transition: color 0.3s; }
.lang-switch:hover .lang-dim { color: var(--text-secondary); }
.login-link   { font-size: 0.82rem; font-weight: 500; color: var(--text-secondary) !important; }
.login-link:hover { color: var(--text-primary) !important; }

/* ==================================================
   MOBILE HAMBURGER & NAV RIGHT
   ================================================== */
.nav-right-mobile {
    display: none !important;
    align-items: center;
    gap: 10px;
}
/* Compact language toggle in the mobile top bar (next to the theme toggle) */
.lang-switch-topbar {
    font-size: 0.72rem;
    padding: 0 10px;
    height: 36px;
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
}
.mobile-menu-toggle {
    z-index: 1001;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hamburger {
    width: 22px;
    height: 16px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.hamburger span {
    display: block;
    width: 100%;
    height: 1.5px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.4s var(--ease-out-expo);
    transform-origin: center;
}
.mobile-menu-toggle.active .hamburger span:nth-child(1) { transform: translateY(7.25px)  rotate(45deg);  }
.mobile-menu-toggle.active .hamburger span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.mobile-menu-toggle.active .hamburger span:nth-child(3) { transform: translateY(-7.25px) rotate(-45deg); }
/* Hamburger button carries .active directly (id="hamburgerBtn") */
.hamburger.active span:nth-child(1) { transform: translateY(7.25px)  rotate(45deg);  }
.hamburger.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.active span:nth-child(3) { transform: translateY(-7.25px) rotate(-45deg); }

/* ==================================================
   FULLSCREEN MOBILE MENU
   ================================================== */
.mobile-menu {
    position: fixed;
    inset: 0;
    z-index: 999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    /* No transition here on purpose. This panel's background
       (.mobile-menu-bg) uses a full-viewport backdrop-filter blur, and
       animating THIS element's opacity forced the browser to re-composite
       that blur on every single frame of the fade — one of the most
       expensive things a browser can do, and the actual cause of the
       visible delay/hitch ("hanging") when tapping the hamburger, in both
       Chrome and Safari (it isn't a Safari-only quirk). Showing/hiding
       instantly removes that cost entirely; the menu still reads as a
       smooth reveal because the nav links inside it keep their own
       slide-up transition (see .mobile-menu.active .mobile-link below). */
}
.mobile-menu-bg {
    position: absolute;
    inset: 0;
    background: var(--mobile-menu-bg);
    /* --mobile-menu-bg is already 0.95–0.98 alpha (near-solid), so the
       blur was mostly a cosmetic touch, not something legibility actually
       depends on. Removing the transition (above) didn't fully fix the
       reported hamburger jank, which means a full-viewport blur is
       expensive even rendered just once, not only while animating — on a
       page already juggling videos/carousels/GSAP it can still blow the
       frame budget. Cut drastically instead of removing outright, to keep
       a little of the frosted look while removing most of the cost. */
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}
@media (max-width: 768px) {
    /* Confirmed via testing on an actual phone that the delay is real
       (under ~0.5s) on mobile specifically, not desktop. Removing
       backdrop-filter entirely on mobile is a clean, decisive test: the
       background is already 0.95+ opacity, so the visual difference is
       minor, and this eliminates 100% of the blur-compositing cost on
       the exact device where it was reported — no blur at all left to
       cost anything. */
    .mobile-menu-bg {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}
.mobile-menu.active {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
}
.mobile-menu-content {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0 24px;
    overflow-y: auto;
    min-height: 0;
}
.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    height: 64px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-subtle);
}
.mobile-menu-close {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--btn-ghost-bg);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    transition: all 0.3s ease;
    cursor: pointer;
}
.mobile-menu-close:hover {
    background: var(--btn-ghost-hover-bg);
    border-color: var(--border-hover);
}
.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    justify-content: center;
    padding: 30px 0;
}
.mobile-link-wrap { overflow: hidden; }
.mobile-link {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 4vw, 2.5rem);
    font-weight: 500;
    color: var(--text-primary);
    transform: translateY(110%);
    transition: color 0.3s, transform 0.5s var(--ease-out-expo);
    padding: 8px 0;
    line-height: 1.2;
}
/* Reveal links when the menu opens — works with or without GSAP */
.mobile-menu.active .mobile-link { transform: translateY(0); }
.mobile-link::before {
    content: attr(data-index);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.5;
    min-width: 20px;
}
.mobile-link:hover  { color: var(--accent); }
.mobile-link.active { color: var(--accent); }
.mobile-link .mobile-nav-icon       { color: var(--text-secondary); }
.mobile-link:hover .mobile-nav-icon { color: var(--accent); }

.mobile-nav-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-subtle);
    padding: 24px 0;
    opacity: 0;
    transform: translateY(20px);
}
.mobile-footer-left   { display: flex; align-items: center; gap: 24px; }
.mobile-link-small    { font-size: 0.9rem; font-weight: 500; color: var(--text-secondary); }
.lang-switch-mobile   { font-size: 0.9rem; font-weight: 500; color: var(--text-primary); cursor: pointer; user-select: none; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border-glass); background: var(--btn-ghost-bg); transition: all 0.3s; }
.lang-switch-mobile .lang-dim { color: var(--text-muted); }

/* ==================================================
   MOBILE MENU FOOTER (My Courses / Theme / Language / Login / Logout)
   These classes previously had ZERO matching CSS anywhere (only the
   differently-named, unused .mobile-nav-footer block above existed),
   so this whole section rendered with no spacing/order control and the
   Logout link — being the very last element in the DOM — could end up
   pushed low enough to be clipped on shorter phones. flex-shrink:0 here
   plus overflow-y:auto on .mobile-menu-content (above) is the safety
   net; the explicit `order` values below is what actually raises
   Logout so it's always one of the first things visible.
   ================================================== */
.mobile-menu-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
    padding: 18px 0 28px;
    border-top: 1px solid var(--border-subtle);
}
.mobile-menu-footer .mobile-link-mycourses { order: 1; }
.mobile-menu-footer .mobile-btn-logout     { order: 2; }
.mobile-menu-footer .mobile-theme-row      { order: 3; }
.mobile-menu-footer .mobile-lang-switch    { order: 4; }
.mobile-menu-footer .mobile-btn-login      { order: 5; }

.mobile-cta-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s;
}
.mobile-btn-login  { background: var(--accent); color: #fff; }
.mobile-btn-login:hover { opacity: 0.9; }
.mobile-btn-logout { background: var(--btn-ghost-bg); border: 1px solid var(--border-glass); color: var(--text-secondary); }
.mobile-btn-logout:hover { color: var(--text-primary); border-color: var(--border-hover, var(--border-glass)); }

.mobile-lang-switch { display: flex; gap: 8px; }
.mobile-lang-btn {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--border-glass);
    background: var(--btn-ghost-bg);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}
.mobile-lang-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.mobile-theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid var(--border-glass);
    background: var(--btn-ghost-bg);
}
.mobile-theme-row span { font-family: var(--font-body); font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }

/* ==================================================
   RESPONSIVE
   ================================================== */
@media (max-width: 1200px) {
    .nav-container { padding: 0 32px; }
    .nav-links     { gap: 16px; }
    .nav-link      { font-size: 0.75rem; }
    .nav-icon      { width: 13px; height: 13px; }
}

@media (max-width: 1024px) {
    .desktop-only    { display: none !important; }
    .mobile-only     { display: flex !important; }
    .nav-right-mobile { display: flex !important; }
}

@media (max-width: 768px) {
    /* Every page reserves top-padding for the ticker via --ticker-height,
       but the ticker itself is hidden on mobile — zero the variable here
       (loaded after each page's own stylesheet) so no page is left with an
       empty gap under the navbar where the ticker used to be. */
    :root { --ticker-height: 0px !important; }

    .desktop-only    { display: none !important; }
    .mobile-only     { display: flex !important; }
    .nav-right-mobile { display: flex !important; }

    /* Hide the ticker on mobile (matches the home page) so it never overlaps
       the navbar/hamburger on pages that load their own stylesheet. */
    .top-ticker { display: none !important; }

    .navbar {
        top: 0;
        height: 64px;
        background: var(--nav-scrolled-bg);
        /* Lighter blur + forced GPU layer on mobile: full-width backdrop-filter
           is a known Safari/iOS perf hit and was making the navbar feel slow
           to paint on first load. */
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--border-subtle);
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
    .navbar.scrolled { top: 0; height: 58px; }
    .nav-container   { padding: 0 16px; display: flex; justify-content: space-between; align-items: center; height: 100%; }
    .nav-logo { gap: 8px; }
    .logo-text { display: none; }
    .nav-right-mobile { gap: 8px !important; }
    .lang-switch-topbar { padding: 0 8px; font-size: 0.65rem; }
    .theme-toggle-mobile { width: 32px; height: 32px; }
    .theme-toggle-mobile .theme-icon { width: 14px; height: 14px; }
}

@media (max-width: 480px) {
    .nav-container { padding: 0 16px; }
}
