/* ==========================================================================
   Header, navigation, mega-dropdown, social rail, mobile drawer
   ========================================================================== */

header {
    background-color: rgba(255, 255, 255, 0.86);
    position: fixed;
    width: 100%;
    top: 0; left: 0;
    z-index: var(--z-header);
    box-shadow: none;
    border-bottom: 1px solid transparent;
    transition: transform var(--dur-2) var(--ease-out),
                box-shadow var(--dur-2) var(--ease-out),
                border-color var(--dur-2) var(--ease-out);
}

/* Glass where supported; the translucent white above is the fallback. */
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
    header {
        background-color: rgba(255, 255, 255, 0.72);
        -webkit-backdrop-filter: blur(14px) saturate(1.4);
        backdrop-filter: blur(14px) saturate(1.4);
    }
}

/* Hide-on-scroll-down, reveal-on-scroll-up. */
header.is-hidden { transform: translateY(-100%); }

/* The hairline and shadow only exist once there is content to float over. */
header.scrolled {
    border-color: var(--hair-1);
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
}

/* Scroll progress indicator */
.scroll-progress {
    position: absolute;
    left: 0; bottom: 0;
    height: 2px;
    width: 100%;
    transform-origin: 0 50%;
    transform: scaleX(0);
    background: var(--grad-brand);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--sp-4) var(--sp-5);
    gap: var(--sp-4);
}

.logo a { display: inline-flex; align-items: center; text-decoration: none; }
/* No transform here. There used to be a scale(2.9), which existed because the
   old logo.png was 1408x736 with the mark occupying a fraction of that — the
   scale was compensating for baked-in whitespace. assets/logo.png is now
   cropped to the mark itself, so the scale would blow it up to ~348x104 and
   paint it straight over the nav links. transform does not affect layout, so
   nothing would reflow to reveal the problem — it just overlaps. */
.logo img {
    height: 36px;
    width: auto;
    display: block;
}

.nav-links { display: flex; align-items: center; }
.nav-item { position: relative; margin: 0 var(--sp-4); }
.nav-item > a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: var(--fs-sm);
    padding: var(--sp-2) 0;
    transition: color var(--dur-2) var(--ease-out);
    display: inline-block;
}
.nav-item > a:hover,
.nav-item.is-active > a { color: var(--primary-color); }

/* Active-page underline */
.nav-item > a::after {
    content: '';
    display: block;
    height: 2px;
    width: 100%;
    background: var(--primary-color);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform var(--dur-2) var(--ease-out);
}
.nav-item.is-active > a::after,
.nav-item > a:hover::after { transform: scaleX(1); }

/* --- Services dropdown --- */
.dropdown {
    position: absolute;
    top: 100%; left: 0;
    background-color: var(--white);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-sm);
    min-width: 240px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), visibility var(--dur-2);
    padding: var(--sp-3) 0;
    z-index: var(--z-dropdown);
    pointer-events: none;
}
.nav-item:hover .dropdown,
.nav-item:focus-within .dropdown,
.nav-item.is-open .dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}
.dropdown li a {
    display: block;
    padding: var(--sp-3) var(--sp-5);
    text-decoration: none;
    color: var(--text-main);
    font-size: var(--fs-sm);
    font-weight: 500;
    transition: var(--transition);
}
.dropdown li a:hover { background-color: var(--slate-100); color: var(--primary-color); padding-left: 25px; }

/* --- Pricing mega-dropdown --- */
.mega-dropdown {
    position: fixed;
    top: var(--header-h);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background-color: var(--white);
    box-shadow: var(--shadow-xl);
    border-radius: 14px;
    width: min(920px, 92vw);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), visibility var(--dur-2);
    z-index: var(--z-dropdown);
    border: 1px solid var(--border-light);
}
.nav-item.pricing-item:hover .mega-dropdown,
.nav-item.pricing-item:focus-within .mega-dropdown,
.nav-item.pricing-item.is-open .mega-dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}
.mega-dropdown-inner { padding: var(--sp-6); }
.mega-dropdown-head { text-align: center; margin-bottom: 22px; }
/* Was an h4 — this is nav chrome, not a content heading, and sat before every
   page's own h1 in the DOM. Selector renamed to match; styling unchanged. */
.mega-dropdown-title { font-size: var(--fs-lg); color: var(--dark-bg); margin-bottom: 6px; }
.mega-dropdown-head p { font-size: var(--fs-xs); color: var(--slate-500); }
.mega-dropdown-foot { text-align: center; margin-top: 18px; font-size: var(--fs-xs); color: var(--slate-500); }

.bundle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.bundle-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
.bundle-card:hover { border-color: var(--primary-color); box-shadow: 0 10px 25px rgba(13, 71, 161, 0.08); transform: translateY(-3px); }
.bundle-card.featured { border-color: var(--primary-color); background-color: #f8fbff; position: relative; }
.bundle-tag {
    position: absolute;
    top: -11px; right: var(--sp-4);
    background: var(--primary-color);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 4px var(--sp-3);
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
/* Was an h5, same reason as .mega-dropdown-title above. */
.bundle-card .bundle-name { font-size: var(--fs-base); color: var(--dark-bg); margin-bottom: 4px; }
.bundle-card .bundle-sub { font-size: var(--fs-xs); color: var(--slate-500); margin-bottom: 6px; }
.bundle-card .bundle-price { font-size: var(--fs-sm); font-weight: 700; color: var(--primary-color); margin-bottom: 14px; }
.bundle-card ul { margin-bottom: 18px; flex-grow: 1; }
.bundle-card ul li {
    font-size: var(--fs-xs);
    color: var(--text-main);
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    margin-bottom: var(--sp-2);
    line-height: 1.4;
}
.bundle-card ul li .icon { color: var(--primary-color); width: var(--icon-sm); height: var(--icon-sm); margin-top: 1px; }

/* --- Floating social rail --- */
.social-sidebar {
    position: fixed;
    left: 0; top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sidebar);
}
.sidebar-icon {
    width: 45px; height: 45px;
    display: flex; align-items: center; justify-content: center;
    color: var(--white);
    text-decoration: none;
    font-size: 18px;
    transition: var(--transition);
    border-radius: 0 4px 4px 0;
    margin-bottom: 2px;
}
.sidebar-icon:hover { width: 55px; padding-left: var(--sp-3); }
.s-linkedin  { background-color: #0077b5; }
.s-instagram { background-color: #e1306c; }
.s-facebook  { background-color: #1877f2; }
.s-whatsapp  { background-color: var(--whatsapp); position: relative; }
.s-youtube   { background-color: #ff0000; }

.s-whatsapp::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 0 4px 4px 0;
    background-color: var(--whatsapp);
    opacity: 0.55;
    animation: pulseRing 2.2s ease-out infinite;
    z-index: -1;
}

@media (max-width: 900px) {
    /* The rail overlaps content on small screens; it lives in the mobile
       drawer instead. Hidden at 900px, not 768px, to match the point at which
       the nav becomes the drawer — between the two you got a hamburger AND a
       floating social rail sitting over the content. */
    .social-sidebar { display: none; }
}

/* ==========================================================================
   Mobile navigation
   Previously the nav was simply `display: none` under 900px with no
   replacement, leaving phone visitors with no way to navigate the site.
   ========================================================================== */

.nav-toggle {
    display: none;
    width: 44px; height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--dark-bg);
    flex-direction: column;
    gap: 5px;
}
.nav-toggle-bar {
    display: block;
    width: 22px; height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform var(--dur-2) var(--ease-out), opacity var(--dur-1) linear;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-drawer {
    position: fixed;
    inset: 0;
    background: var(--dark-bg);
    color: var(--white);
    z-index: calc(var(--z-header) - 1);
    padding: calc(var(--header-h) + var(--sp-6)) var(--sp-5) var(--sp-6);
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), visibility var(--dur-2);
}
.mobile-drawer.is-open { opacity: 1; visibility: visible; transform: translateY(0); }
body.nav-open { overflow: hidden; }

.mobile-nav-list { display: flex; flex-direction: column; }
.mobile-nav-list > li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    opacity: 0;
    transform: translateY(12px);
}
.mobile-drawer.is-open .mobile-nav-list > li {
    animation: drawerItemIn var(--dur-3) var(--ease-out) forwards;
    animation-delay: calc(var(--i, 0) * 55ms);
}
.mobile-nav-list > li > a,
.mobile-acc-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--sp-4) 0;
    color: var(--white);
    text-decoration: none;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: var(--fs-lg);
    text-align: left;
}
.mobile-acc-trigger .icon { transition: transform var(--dur-2) var(--ease-out); }
.mobile-acc-trigger[aria-expanded="true"] .icon { transform: rotate(180deg); }

/* Nested accordion replaces the hover mega-dropdown, which is unusable on touch. */
.mobile-acc-panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows var(--dur-2) var(--ease-out);
}
.mobile-acc-trigger[aria-expanded="true"] + .mobile-acc-panel { grid-template-rows: 1fr; }
.mobile-acc-panel > div { overflow: hidden; }
.mobile-acc-panel a {
    display: block;
    padding: var(--sp-3) 0 var(--sp-3) var(--sp-4);
    color: var(--slate-300);
    text-decoration: none;
    font-size: var(--fs-sm);
    border-left: 2px solid rgba(255, 255, 255, 0.15);
    margin-bottom: var(--sp-1);
}
.mobile-acc-panel a:hover { color: var(--sky); border-left-color: var(--sky); }

.mobile-drawer-cta { margin-top: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); }
.mobile-drawer-social { display: flex; gap: var(--sp-3); margin-top: var(--sp-6); }
.mobile-drawer-social a {
    width: 42px; height: 42px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    color: var(--white);
}

@media (max-width: 900px) {
    .nav-links { display: none; }
    .nav-toggle { display: flex; }
    .btn-consultation.is-desktop-only { display: none; }
}

@media (min-width: 901px) {
    .mobile-drawer { display: none; }
}

@media (max-width: 900px) {
    /* The mega-dropdown is a fixed 920px panel opened on hover — unusable and
       potentially overflowing on tablets. Its content lives in the mobile
       drawer accordion instead. Hidden at 900px, not 992px: between the two the
       desktop nav is still showing, so "Pricing" advertised aria-haspopup and
       then opened nothing at all. */
    .mega-dropdown { display: none; }
    .bundle-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Sticky mobile CTA bar — see partials/tail.php for why. Desktop-only bits
   (header CTA, social rail) are both absent below 900px, so this covers the
   gap with a persistent conversion + WhatsApp affordance.
   ========================================================================== */

.mobile-sticky-cta {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: var(--z-sidebar);
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border-top: 1px solid var(--hair-1);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
}
.mobile-sticky-cta .btn-primary {
    flex: 1;
    text-align: center;
    justify-content: center;
}
.mobile-sticky-whatsapp {
    flex: none;
    width: 46px; height: 46px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--whatsapp);
    color: #fff;
}
.mobile-sticky-whatsapp:hover { background: var(--whatsapp-dark); }

/* Suppressed while the drawer or a modal is open — both already toggle these
   body classes (app.js) — so the bar never competes with an overlay. */
body.nav-open .mobile-sticky-cta,
body.modal-open .mobile-sticky-cta { display: none !important; }

@media (max-width: 900px) {
    .mobile-sticky-cta { display: flex; }

    /* .to-top's phone geometry deliberately lives in 07-utilities.css next to
       its base rule, NOT here: that file loads after this one, so a rule here
       would lose the cascade to the unmediaed base and the button would stay
       bottom-right on top of .bot-trigger. */

    .bot-trigger {
        right: var(--sp-4);
        bottom: calc(var(--cta-bar-h) + var(--safe-b) + var(--fab-gap));
        width: var(--fab-size);
        height: var(--fab-size);
    }

    /* A bottom sheet rather than a 350px card that does not fit a 360px
       screen. Also removes the 481-900px dead zone where the fixed 350px was
       never overridden at all. */
    .bot-window {
        left: var(--sp-4);
        right: var(--sp-4);
        width: auto;
        height: min(66vh, 460px);
        bottom: calc(var(--cta-bar-h) + var(--safe-b) + var(--fab-gap) * 2 + var(--fab-size));
    }

    /* Toasts have to clear the bar too, or a success message renders behind it. */
    .toast-stack { bottom: calc(var(--cta-bar-h) + var(--safe-b) + var(--fab-gap)); }
}

@media (max-width: 400px) {
    :root { --fab-size: 48px; --fab-gap: 10px; }

    .bot-trigger { right: var(--sp-3); font-size: 20px; }
    .bot-window  { left: var(--sp-3); right: var(--sp-3); }

    /* At 320px "Get a Free Consultation" wrapped to two lines and took the bar
       from 81px to 106px — which silently invalidated --cta-bar-h and dropped
       .bot-trigger on top of the bar. Tightened so it stays on one line, and
       nowrap so no future label change can quietly bring the bug back. */
    .mobile-sticky-cta { padding-left: var(--sp-3); padding-right: var(--sp-3); }
    .mobile-sticky-cta .btn-primary {
        padding: 14px var(--sp-4);
        font-size: var(--fs-sm);
        white-space: nowrap;
    }
}
