/* ========================================
   Parallax Section Styles
   Homepage parallax flow sections
   ======================================== */

/* ===== Base Parallax Styles ===== */
/* Works with both Elementor Containers (.e-con) and Sections (.elementor-section) */
.pgs-parallax-section {
    position: relative;
    /* Force full viewport height - override Elementor inline styles */
    height: 100vh !important;
    height: 100dvh !important; /* Modern browsers with dynamic viewport */
    min-height: 100vh !important;
    min-height: 100dvh !important;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* Offset content for fixed header - pushes visual center up */
    padding-bottom: var(--header-height, 80px) !important;

    /* Parallax effect - applied directly to element background */
    background-attachment: fixed !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

/* ===== Progressive Background Image (replaces CSS background-image) ===== */
.pgs-parallax-bg {
    position: absolute;
    left: 0;
    right: 0;
    /* Oversized for parallax shift buffer.
       Uses explicit height (not opposing insets) so Chrome iOS can resolve
       background-position: center. Uses <div> + background-size instead of
       <img> + object-fit because iOS WebKit fails to size absolute <img>
       in flex/dvh containers. */
    top: -15vh;
    height: calc(100% + 30vh);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
    pointer-events: none;
}

/* LQIP blur state (PHP templates with tiny placeholder) */
.pgs-parallax-bg.lqip {
    filter: blur(20px);
    transition: filter 0.6s ease;
}

/* Elementor sections — fade in from transparent */
.pgs-parallax-bg.pgs-parallax-bg--loading {
    opacity: 0;
    transition: opacity 0.6s ease;
}

/* Loaded state — shared by both approaches */
.pgs-parallax-bg.loaded {
    filter: none;
    opacity: 1;
}

/* ===== Elementor Container Support ===== */
.e-con.pgs-parallax-section,
.elementor-element.e-con.pgs-parallax-section {
    /* Force full viewport height with higher specificity */
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    padding-bottom: var(--header-height, 80px) !important;
    background-attachment: fixed !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

/* Elementor Section Support (legacy) */
.elementor-section.pgs-parallax-section {
    padding: 0;
    padding-bottom: var(--header-height, 80px) !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    background-attachment: fixed !important;
}

/* Remove any default Elementor overlays */
.pgs-parallax-section > .elementor-background-overlay,
.pgs-parallax-section > .e-con-inner > .elementor-background-overlay {
    display: none;
}

/* Ensure inner content is above background */
.pgs-parallax-section > .elementor-container,
.pgs-parallax-section > .e-con-inner {
    position: relative;
    z-index: 10;
}

/* ===== Content-Fit Height Modifier ===== */
/* Use when section should collapse to content size instead of full viewport */
.pgs-parallax-section.pgs-parallax-section--content-fit,
.e-con.pgs-parallax-section.pgs-parallax-section--content-fit,
.elementor-section.pgs-parallax-section.pgs-parallax-section--content-fit {
    height: auto !important;
    min-height: auto !important;
    padding-top: var(--spacing-xxl, 4rem) !important;
    padding-bottom: var(--spacing-xxl, 4rem) !important;
}

/* ===== Content Container ===== */
.pgs-parallax-content {
    position: relative;
    z-index: 10;
    text-align: center;
    max-width: 720px;
    margin: 0 auto;
    padding: var(--spacing-xxl, 4rem) var(--spacing-md, 1.5rem);
    color: #ffffff;
}

/* Elementor widget wrappers */
.pgs-parallax-section .elementor-widget-wrap,
.pgs-parallax-section .e-con-inner {
    position: relative;
    z-index: 10;
}

/* ===== Typography ===== */
.pgs-parallax-title,
.pgs-parallax-section h1,
.pgs-parallax-section h2,
.pgs-parallax-section .elementor-heading-title {
    font-family: var(--font-heading, '29LTAzer', sans-serif);
    font-size: clamp(1.875rem, 5vw, 2.75rem);
    font-weight: 700;
    line-height: 1.2;
    color: #ffffff;
    margin-bottom: var(--spacing-md, 1.5rem);
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: currentColor;
    background-clip: unset;
    /* Text shadow for readability on images */
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.pgs-parallax-text,
.pgs-parallax-section p,
.pgs-parallax-section .elementor-widget-text-editor {
    font-family: var(--font-body, '29LTAzer', sans-serif);
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: var(--spacing-lg, 2rem);
    max-width: 600px;
    margin-inline: auto;
    /* Text shadow for readability */
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* ===== CTA Button ===== */
.pgs-parallax-cta,
.pgs-parallax-section .elementor-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    font-family: var(--font-primary, '29LTAzer', sans-serif);
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary, #3a3a3a);
    background-color: #ffffff;
    border: none;
    border-radius: var(--border-radius-md, 0.5rem);
    text-decoration: none;
    cursor: pointer;
    transition:
        transform 0.25s var(--ease-smooth, ease),
        box-shadow 0.25s var(--ease-smooth, ease),
        background-color 0.25s var(--ease-smooth, ease);
    box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
}

.pgs-parallax-cta:hover,
.pgs-parallax-cta:focus,
.pgs-parallax-section .elementor-button:hover,
.pgs-parallax-section .elementor-button:focus {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
    background-color: var(--color-accent, #e4cd9a);
    color: var(--color-text-primary, #3a3a3a);
}

.pgs-parallax-cta:focus,
.pgs-parallax-section .elementor-button:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.pgs-parallax-cta:active,
.pgs-parallax-section .elementor-button:active {
    transform: translateY(0);
}

/* ===== Optional Overlay (add class if needed) ===== */
.pgs-parallax-section--with-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

/* ===== Scroll Reveal Animation ===== */
.pgs-parallax-content {
    opacity: 0;
    transform: translateY(24px);
    animation: parallaxReveal 0.5s var(--ease-smooth, ease) forwards;
    animation-delay: 0.1s;
}

@keyframes parallaxReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered animation for Elementor widgets */
.pgs-parallax-section .elementor-widget {
    opacity: 0;
    transform: translateY(16px);
    animation: parallaxReveal 0.4s var(--ease-smooth, ease) forwards;
}

.pgs-parallax-section .elementor-widget:nth-child(1) { animation-delay: 0.1s; }
.pgs-parallax-section .elementor-widget:nth-child(2) { animation-delay: 0.2s; }
.pgs-parallax-section .elementor-widget:nth-child(3) { animation-delay: 0.3s; }

/* ===== Tablet Styles ===== */
@media (max-width: 1024px) {
    .pgs-parallax-section,
    .e-con.pgs-parallax-section,
    .elementor-section.pgs-parallax-section {
        height: 100vh !important;
        height: 100dvh !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        /* Slightly smaller header on tablet */
        padding-bottom: var(--header-height, 75px) !important;
    }

    /* Content-fit modifier - tablet */
    .pgs-parallax-section.pgs-parallax-section--content-fit,
    .e-con.pgs-parallax-section.pgs-parallax-section--content-fit,
    .elementor-section.pgs-parallax-section.pgs-parallax-section--content-fit {
        padding-top: var(--spacing-xl, 3rem) !important;
        padding-bottom: var(--spacing-xl, 3rem) !important;
    }

    .pgs-parallax-content {
        padding: var(--spacing-xl, 3rem) var(--spacing-md, 1.5rem);
    }
}

/* ===== Mobile Styles ===== */
@media (max-width: 768px) {
    .pgs-parallax-section,
    .e-con.pgs-parallax-section,
    .elementor-section.pgs-parallax-section {
        /* Force full viewport height on mobile */
        height: 100vh !important;
        height: 100dvh !important; /* Accounts for mobile browser chrome */
        min-height: 100vh !important;
        min-height: 100dvh !important;
        /* Smaller header on mobile */
        padding-bottom: var(--header-height-mobile, 70px) !important;
        /* Disable fixed attachment on mobile (iOS limitation) */
        background-attachment: scroll !important;
    }

    /* Content-fit modifier - mobile */
    .pgs-parallax-section.pgs-parallax-section--content-fit,
    .e-con.pgs-parallax-section.pgs-parallax-section--content-fit,
    .elementor-section.pgs-parallax-section.pgs-parallax-section--content-fit {
        padding-top: var(--spacing-lg, 2rem) !important;
        padding-bottom: var(--spacing-lg, 2rem) !important;
    }

    .pgs-parallax-content {
        padding: var(--spacing-lg, 2rem) var(--spacing-sm, 1rem);
        max-width: 100%;
    }

    .pgs-parallax-title,
    .pgs-parallax-section h1,
    .pgs-parallax-section h2,
    .pgs-parallax-section .elementor-heading-title {
        font-size: clamp(1.5rem, 6vw, 2rem);
        margin-bottom: var(--spacing-sm, 1rem);
    }

    .pgs-parallax-text,
    .pgs-parallax-section p {
        font-size: 1rem;
        margin-bottom: var(--spacing-md, 1.5rem);
    }

    .pgs-parallax-cta,
    .pgs-parallax-section .elementor-button {
        padding: 0.75rem 1.5rem;
        font-size: 0.9375rem;
        width: 100%;
        max-width: 280px;
    }

    /* Simplify animations on mobile */
    .pgs-parallax-content,
    .pgs-parallax-section .elementor-widget {
        animation-duration: 0.3s;
    }
}

/* ===== Small Mobile ===== */
@media (max-width: 480px) {
    .pgs-parallax-section,
    .e-con.pgs-parallax-section,
    .elementor-section.pgs-parallax-section {
        height: 100vh !important;
        height: 100dvh !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        padding-bottom: var(--header-height-mobile, 70px) !important;
    }

    /* Content-fit modifier - small mobile */
    .pgs-parallax-section.pgs-parallax-section--content-fit,
    .e-con.pgs-parallax-section.pgs-parallax-section--content-fit,
    .elementor-section.pgs-parallax-section.pgs-parallax-section--content-fit {
        padding-top: var(--spacing-md, 1.5rem) !important;
        padding-bottom: var(--spacing-md, 1.5rem) !important;
    }

    .pgs-parallax-content {
        padding: var(--spacing-md, 1.5rem) var(--spacing-sm, 1rem);
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .pgs-parallax-section,
    .e-con.pgs-parallax-section {
        background-attachment: scroll !important;
    }

    .pgs-parallax-content,
    .pgs-parallax-section .elementor-widget {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .pgs-parallax-cta,
    .pgs-parallax-section .elementor-button {
        transition: none;
    }
}

/* ===== High Contrast Mode ===== */
@media (prefers-contrast: high) {
    .pgs-parallax-title,
    .pgs-parallax-section h1,
    .pgs-parallax-section h2,
    .pgs-parallax-text,
    .pgs-parallax-section p {
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    }

    .pgs-parallax-cta,
    .pgs-parallax-section .elementor-button {
        border: 2px solid #ffffff;
    }
}

/* ===== Print Styles ===== */
@media print {
    .pgs-parallax-section {
        min-height: auto;
        page-break-inside: avoid;
        background: none !important;
    }

    .pgs-parallax-content {
        color: #000000;
    }

    .pgs-parallax-title,
    .pgs-parallax-section h1,
    .pgs-parallax-section h2 {
        color: #000000;
        text-shadow: none;
    }
}

/* ========================================
   Transparent Header on Parallax Pages
   Only applies when first section has parallax class
   ======================================== */

/* Base transparent state - header overlays first parallax section */
.site-header.header-transparent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    backdrop-filter: blur(16px) saturate(120%);
    box-shadow: none;
    transition:
        background-color 0.3s ease,
        backdrop-filter 0.3s ease,
        -webkit-backdrop-filter 0.3s ease,
        box-shadow 0.3s ease;
}

/* Make header content white for visibility on parallax backgrounds */
.site-header.header-transparent .site-title a,
.site-header.header-transparent .site-tagline,
.site-header.header-transparent .primary-menu > li > a {
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.site-header.header-transparent .primary-menu > li.menu-item-icon > a::before {
    background-color: #ffffff;
}

/* Menu link hover state */
.site-header.header-transparent .primary-menu > li > a:hover,
.site-header.header-transparent .primary-menu > li > a:focus {
    color: var(--color-accent, #e4cd9a);
}

.site-header.header-transparent .primary-menu > li.menu-item-icon > a:hover::before {
    background-color: var(--color-accent, #e4cd9a);
}

/* Current page indicator */
.site-header.header-transparent .primary-menu > li.current-menu-item > a,
.site-header.header-transparent .primary-menu > li.current_page_item > a {
    color: var(--color-accent, #e4cd9a);
}

/* Mobile menu toggle - white lines */
.site-header.header-transparent .mobile-menu-toggle .menu-icon span {
    background-color: #ffffff;
}

/* Logo filter for dark backgrounds (invert if needed) */
.site-header.header-transparent .site-logo img {
    /* Add filter if logo needs to be lighter on dark bg */
    /* filter: brightness(0) invert(1); */
    transition: transform 0.4s var(--ease-organic), filter 0.3s ease;
}

/* Scrolled state - blur effect kicks in */
.site-header.header-transparent.header-scrolled {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Scrolled state - revert to dark text */
.site-header.header-transparent.header-scrolled .site-title a,
.site-header.header-transparent.header-scrolled .site-tagline {
    color: var(--color-text-primary, #3a3a3a);
    text-shadow: none;
}

.site-header.header-transparent.header-scrolled .primary-menu > li > a {
    color: var(--color-text-primary, #3a3a3a);
    text-shadow: none;
}

.site-header.header-transparent.header-scrolled .primary-menu > li > a:hover,
.site-header.header-transparent.header-scrolled .primary-menu > li > a:focus {
    color: var(--color-primary, #c06240);
}

.site-header.header-transparent.header-scrolled .primary-menu > li.current-menu-item > a,
.site-header.header-transparent.header-scrolled .primary-menu > li.current_page_item > a {
    color: var(--color-primary, #c06240);
}

/* Mobile menu toggle - dark lines when scrolled */
.site-header.header-transparent.header-scrolled .mobile-menu-toggle .menu-icon span {
    background-color: var(--color-text-primary, #3a3a3a);
}

/* Logo back to normal when scrolled */
.site-header.header-transparent.header-scrolled .site-logo img {
    filter: none;
}

/* Sticky + transparent header combo */
.sticky-header-enabled .site-header.header-transparent.is-sticky {
    position: fixed;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* Sticky state uses same dark colors as scrolled */
.sticky-header-enabled .site-header.header-transparent.is-sticky .site-title a,
.sticky-header-enabled .site-header.header-transparent.is-sticky .site-tagline,
.sticky-header-enabled .site-header.header-transparent.is-sticky .primary-menu > li > a {
    color: var(--color-text-primary, #3a3a3a);
    text-shadow: none;
}

.sticky-header-enabled .site-header.header-transparent.is-sticky .primary-menu > li > a:hover,
.sticky-header-enabled .site-header.header-transparent.is-sticky .primary-menu > li > a:focus {
    color: var(--color-primary, #c06240);
}

.sticky-header-enabled .site-header.header-transparent.is-sticky .primary-menu > li.menu-item-icon > a::before {
    background-color: var(--color-text-primary, #3a3a3a);
}

.sticky-header-enabled .site-header.header-transparent.is-sticky .primary-menu > li.menu-item-icon > a:hover::before,
.sticky-header-enabled .site-header.header-transparent.is-sticky .primary-menu > li.menu-item-icon > a:focus::before {
    background-color: var(--color-primary, #c06240);
}

.sticky-header-enabled .site-header.header-transparent.is-sticky .mobile-menu-toggle .menu-icon span {
    background-color: var(--color-text-primary, #3a3a3a);
}

.sticky-header-enabled .site-header.header-transparent.is-sticky .mobile-menu-toggle.is-active .menu-icon span {
    background-color: #ffffff;
}

/* ===== Mobile Transparent Header ===== */
@media (max-width: 768px) {
    .site-header.header-transparent {
        /* Slightly stronger blur on mobile for readability */
        background: rgba(0, 0, 0, 0.1);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .site-header.header-transparent.header-scrolled {
        background: rgba(255, 255, 255, 0.3);
        backdrop-filter: blur(20px) saturate(120%);
        -webkit-backdrop-filter: blur(20px) saturate(120%);
    }

    /* Hamburger lines white on transparent header */
    .site-header.header-transparent .menu-icon span {
        background: #ffffff;
    }

    /* Navigation matches header background (prevents white flash on dismiss) */
    .site-header.header-transparent .primary-navigation {
        background: rgba(0, 0, 0, 0.1);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        box-shadow: none;
    }

    /* Sticky navigation matches sticky header */
    .site-header.header-transparent.is-sticky .primary-navigation {
        background: rgba(255, 255, 255, 0.5);
        backdrop-filter: blur(20px) saturate(120%);
        -webkit-backdrop-filter: blur(20px) saturate(120%);
    }

    .site-header.header-transparent .primary-navigation.is-open .primary-menu > li > a {
        color: var(--color-cream, #3a3a3a);
        text-shadow: none;
    }

    /* Subtle borders on transparent menu */
    .site-header.header-transparent:not(.is-sticky) .primary-navigation.is-open .primary-menu > li > a {
        border-bottom-color: rgba(255, 255, 255, 0.15);
    }

    .site-header.header-transparent.is-sticky .primary-navigation.is-open .primary-menu > li > a {
        color: var(--color-text-primary, #3a3a3a);
    }

    .site-header.header-transparent .primary-navigation.is-open .primary-menu > li.menu-item-icon > a::before {
        background-color: var(--color-cream, #3a3a3a);
    }

    .site-header.header-transparent.is-sticky .primary-navigation.is-open .primary-menu > li.menu-item-icon > a::before {
        background-color: var(--color-text-primary, #3a3a3a);
    }
}

/* ===== Reduced Motion for Header Transitions ===== */
@media (prefers-reduced-motion: reduce) {
    .site-header.header-transparent {
        transition: none;
    }
}

/* ========================================
   Footer Margin Fix for Parallax Sections
   Removes gap when parallax is last section
   ======================================== */

/* Remove footer margin when last section is parallax */
/* Class-based fallback for Safari 14-15 (no :has() support) */
.site-main.has-parallax-last + .site-footer {
    margin-top: 0;
}

.site-main:has(.pgs-parallax-section:last-child) + .site-footer,
.site-main:has([data-elementor-type] .pgs-parallax-section:last-child) + .site-footer {
    margin-top: 0;
}
