/* Site-wide glassmorphism — header, mega menus, blurred page backdrop */

/*
 * Global smooth scrolling
 */
html {
    scroll-behavior: smooth;
}

/*
 * Sections linked from in-page anchors (#contact on home / floating CTA sit under fixed header).
 * Also covers all services-* anchors added to services.html sections.
 */
#contact,
#services,
#services-remodeling,
#services-additions,
#services-new-construction,
#services-roofing,
#services-process {
    scroll-margin-top: clamp(8.75rem, 22vmin, 13rem);
}

/*
 * Floating “Get a Free Estimate” — same visual language as header CTAs (rounded-md, gradient, shadow-md, uppercase).
 */
.site-float-estimate-btn {
    position: fixed;
    z-index: 60;
    right: calc(1.25rem + env(safe-area-inset-right, 0px));
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    left: auto;
    box-sizing: border-box;
    display: inline-block;
    max-width: min(22rem, calc(100vw - 2.5rem - env(safe-area-inset-right, 0px) - env(safe-area-inset-left, 0px)));
    border-radius: 0.375rem;
    background: linear-gradient(75deg, #760480, #0b36b8);
    padding: 0.875rem 1.25rem;
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    line-height: 1.25;
    color: #fff;
    text-decoration: none;
    box-shadow:
        0 4px 6px -1px rgba(15, 23, 42, 0.1),
        0 2px 4px -2px rgba(15, 23, 42, 0.1);
    transition: opacity 0.2s ease;
}
.site-float-estimate-btn:hover {
    opacity: 0.9;
}

.site-float-estimate-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow:
        0 0 0 2px #760480,
        0 4px 6px -1px rgba(15, 23, 42, 0.12),
        0 2px 4px -2px rgba(15, 23, 42, 0.1);
}

@media (min-width: 640px) {
    .site-float-estimate-btn {
        right: calc(2rem + env(safe-area-inset-right, 0px));
        bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
        max-width: none;
        padding: 0.875rem 1.75rem;
        font-size: 0.875rem;
        letter-spacing: 0.16em;
        white-space: nowrap;
    }
}

#site-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 85;
    background: rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.32s ease, visibility 0.32s ease;
    pointer-events: none;
}

#site-menu-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.site-header-shell {
    overflow: visible;
    /* Let child rows carry glass / color so hero shows through between bars */
    background: transparent !important;
    transition:
        background-color 0.38s ease,
        box-shadow 0.38s ease,
        backdrop-filter 0.38s ease,
        -webkit-backdrop-filter 0.38s ease,
        border-color 0.38s ease;
}

/*
 * Main brand bar: frosted glass (~40% more transparent vs prior alphas; no container opacity).
 * Prior ~0.78/0.62 → multiply alpha ~0.6 for stronger glass read-through.
 */
.site-header-brand-row {
    border-bottom-color: rgba(255, 255, 255, 0.55) !important;
    background: linear-gradient(
        to bottom,
        rgba(207, 206, 204, 0.47),
        rgba(255, 255, 255, 0.37)
    ) !important;
    backdrop-filter: blur(12px) saturate(145%);
    -webkit-backdrop-filter: blur(12px) saturate(145%);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.05);
    transition:
        background 0.35s ease,
        backdrop-filter 0.35s ease,
        -webkit-backdrop-filter 0.35s ease,
        box-shadow 0.35s ease;
}

.site-header-shell.is-scrolled .site-header-brand-row {
    background: linear-gradient(
        to bottom,
        rgba(230, 229, 228, 0.55),
        rgba(255, 255, 255, 0.53)
    ) !important;
    backdrop-filter: blur(14px) saturate(155%);
    -webkit-backdrop-filter: blur(14px) saturate(155%);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06), 0 12px 40px -24px rgba(15, 23, 42, 0.1);
}

/* Scrolled: shell stays transparent; brand row gains opacity + blur (shrink via .site-header-brand-inner) */
.site-header-shell.is-scrolled {
    background: transparent !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
}

/* Interior pages: soft glass bar at rest; deepens on scroll */
.site-header-shell.site-header--interior:not(.is-scrolled) {
    background: transparent !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
}

.site-header-shell.site-header--interior:not(.is-scrolled) .site-header-nav-row,
.site-header-shell.site-header--interior.is-scrolled .site-header-nav-row {
    background: transparent !important;
}

.site-header-shell.site-header--home:not(.is-scrolled) {
    background: transparent !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
}

/* Purple promo strip: match glass read-through with header */
.site-header-shell .site-top-strip {
    backdrop-filter: blur(10px) saturate(125%);
    -webkit-backdrop-filter: blur(10px) saturate(125%);
}

/* Top strip: avoid clipping ascenders/descenders (no fixed height + adequate line-height) */
.site-top-strip-inner {
    box-sizing: border-box;
    min-height: 2.25rem;
    height: auto;
    max-height: none;
}

.site-top-strip-inner > span {
    line-height: 1.25;
}

@media (min-width: 640px) {
    .site-top-strip-inner {
        min-height: 3rem;
    }

    .site-top-strip-inner > span {
        line-height: 1.3;
    }
}

/* Header phone + address: vertical room, no guillotine; flex centers icon + text boxes */
.site-header-meta {
    overflow: visible;
    align-items: center;
}

.site-header-meta .site-header-phone-row,
.site-header-meta .site-header-address-row {
    display: flex;
    align-items: center;
    overflow: visible;
    min-width: 0;
}

.site-header-phone-link,
.site-header-address-text {
    line-height: 1.35;
    padding-top: 0.125rem;
    padding-bottom: 0.125rem;
}

@media (min-width: 640px) {
    .site-header-phone-link {
        line-height: 1.25;
        padding-top: 0;
        padding-bottom: 0;
    }

    .site-header-address-text {
        line-height: 1.4;
        padding-top: 0;
        padding-bottom: 0;
    }
}

.site-header-meta svg {
    flex-shrink: 0;
}

/* Desktop primary nav pill — ~30% more transparent than rgba(54,67,85,0.55) */
.site-desktop-nav-pill {
    position: absolute;
    left: 1.5rem;
    right: 1.5rem;
    bottom: -20px;
    max-width: 80rem;
    margin: 0 auto;
    z-index: 2;
    height: 40px;
    border-radius: 8px;
    padding: 0 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(54, 67, 85, 0.38);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.2);
}

/* Mobile: header CTA is `hidden sm:inline-block` in HTML (avoids duplicate with floating CTA) */

/*
 * Main header inner: compact vertical rhythm on small screens (logo size unchanged in markup).
 * Tighter padding when scrolled (shrink header). Hero video is offset with --site-header-height.
 */
.site-header-brand-inner {
    transition: padding 0.28s ease, gap 0.28s ease;
}

@media (max-width: 639px) {
    .site-header-brand-inner {
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
        gap: 0.25rem !important;
    }

    .site-header-shell.is-scrolled .site-header-brand-inner {
        padding-top: 0.2rem !important;
        padding-bottom: 0.2rem !important;
        gap: 0.2rem !important;
    }
}

@media (min-width: 640px) {
    .site-header-brand-inner {
        padding-top: 0.625rem !important;
        padding-bottom: 0.625rem !important;
    }

    .site-header-shell.is-scrolled .site-header-brand-inner {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
}

.site-header-shell.site-header--home:not(.is-scrolled) .site-glass-btn {
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.35) !important;
    color: #fff !important;
    box-shadow: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.site-header-shell.site-header--home:not(.is-scrolled) .site-glass-btn:hover {
    background: rgba(255, 255, 255, 0.22) !important;
}

/* Mobile mega dropdown */
.site-glass-dropdown {
    background: rgba(255, 255, 255, 0.88) !important;
    backdrop-filter: blur(22px) saturate(150%);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    border-color: rgba(255, 255, 255, 0.65) !important;
    box-shadow: 0 25px 80px -20px rgba(15, 23, 42, 0.35);
}

/* Desktop hover mega curtain — ~30% more transparent than prior 0.60 white */
.site-glass-mega-curtain {
    background: rgba(255, 255, 255, 0.42) !important;
    backdrop-filter: blur(28px) saturate(180%) brightness(1.04);
    -webkit-backdrop-filter: blur(28px) saturate(180%) brightness(1.04);
    border-top: 1px solid rgba(255, 255, 255, 0.55);
    border-bottom: 1px solid rgba(255, 255, 255, 0.32);
    box-shadow: 0 8px 32px -8px rgba(15, 23, 42, 0.16), 0 32px 64px -32px rgba(15, 23, 42, 0.12);
}

.site-header-shell.is-scrolled .site-glass-mega-curtain {
    background: rgba(255, 255, 255, 0.44) !important;
}

/* Primary nav: show which top-level page is active (desktop bar + mobile overlay). */
.site-header-nav-row nav[aria-label="Primary links"] a.js-nav-mega-trigger[aria-current="page"] {
    color: #fff;
    font-weight: 600;
    border-bottom-color: rgba(255, 255, 255, 0.95);
}
.site-header-nav-row nav[aria-label="Primary links"] a.js-nav-mega-trigger[aria-current="page"]:hover {
    color: #fff;
    border-bottom-color: #fff;
}

#megaMenuPanel nav[aria-label="Site navigation"] a[aria-current="page"] {
    color: #5a0661;
    font-weight: 700;
    background: linear-gradient(90deg, rgba(118, 4, 128, 0.12), rgba(11, 54, 184, 0.06));
    box-shadow: inset 4px 0 0 #760480;
}
#megaMenuPanel nav[aria-label="Site navigation"] a[aria-current="page"]:hover {
    color: #5a0661;
}

/* Frosted cards sitewide — optional subtle lift for common panels */
.site-glass-panel {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: 0 18px 60px -36px rgba(15, 23, 42, 0.35);
}

@media (prefers-reduced-motion: reduce) {
    #site-menu-backdrop,
    .site-header-shell,
    .site-glass-dropdown,
    .site-glass-mega-curtain,
    .site-float-estimate-btn {
        transition-duration: 0.01ms !important;
    }

    .site-float-estimate-btn:hover {
        opacity: 1;
    }
}

/*
 * Full-viewport hero video: first-frame poster strip + fade to video when decoded (poster `img`; native `poster` stays hidden until video fades in otherwise).
 */
.site-hero-viewport {
    min-height: 100svh;
}

/* Video + poster sit in the viewport band below the fixed header (measured in JS) */
.site-hero-viewport .site-hero-media-offset {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: var(--site-header-height, 0px);
}

/* Home: focal area slightly lower so subject clears fixed header band */
.hero-video-stage .hero-video-poster-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 44%;
    z-index: 0;
    opacity: 1;
    transition: opacity 1.05s ease-out;
    pointer-events: none;
}
.hero-video-stage.is-ready .hero-video-poster-layer {
    opacity: 0;
}
.hero-video-stage video.hero-cover {
    object-fit: cover;
    object-position: 50% 44%;
    opacity: 0;
    transition: opacity 1.05s ease-out;
    z-index: 1;
}
.hero-video-stage.is-ready video.hero-cover {
    opacity: 1;
}
.hero-video-stage .hero-video-overlay.site-hero-overlay {
    opacity: 0;
    transition: opacity 1.05s ease-out;
    z-index: 2;
    background: linear-gradient(
        to bottom,
        rgba(15, 23, 42, 0.22) 0%,
        rgba(15, 23, 42, 0.06) 42%,
        rgba(15, 23, 42, 0.32) 100%
    );
}
.hero-video-stage.is-ready .hero-video-overlay.site-hero-overlay {
    opacity: 1;
}

@media (max-width: 768px) and (orientation: portrait) {
    .hero-video-stage video.hero-cover,
    .hero-video-stage .hero-video-poster-layer {
        object-position: 54% 40%;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .hero-video-stage video.hero-cover,
    .hero-video-stage .hero-video-poster-layer {
        object-position: 50% 42%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hero-video-stage video.hero-cover {
        opacity: 1;
        transition: none;
    }
    .hero-video-stage .hero-video-poster-layer {
        opacity: 1;
        transition: none;
    }
    .hero-video-stage.is-ready .hero-video-poster-layer {
        opacity: 1;
    }
    .hero-video-stage .hero-video-overlay.site-hero-overlay {
        opacity: 0;
        visibility: hidden;
        transition: none;
    }
    .hero-video-stage.is-ready video.hero-cover {
        opacity: 1;
    }
}
