/* Hero Block Frontend Styles - WordPress Native Approach */

/* Touch-friendly global improvements */
html {
    /* Smooth scrolling for all browsers */
    scroll-behavior: smooth;
}

/* Base Hero Container */
.wpm-hero {
    position: relative;
    display: flex;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;

    /* Use CSS custom properties set by PHP */
    min-height: var(--hero-min-height, 600px);
    text-align: var(--hero-text-align, left);
    align-items: var(--hero-vertical-align, flex-end);
    justify-content: var(--hero-text-align, flex-start);

    /* Improve performance on touch devices */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.wpm-hero *,
.wpm-hero *::before,
.wpm-hero *::after {
    box-sizing: border-box;
}

/* Vertical alignment mapping */
.wpm-hero[style*="--hero-vertical-align: top"] {
    align-items: flex-start;
}

.wpm-hero[style*="--hero-vertical-align: center"] {
    align-items: center;
}

.wpm-hero[style*="--hero-vertical-align: bottom"] {
    align-items: flex-end;
}

/* Horizontal alignment mapping */
.wpm-hero[style*="--hero-text-align: left"] {
    justify-content: flex-start;
}

.wpm-hero[style*="--hero-text-align: center"] {
    justify-content: center;
}

.wpm-hero[style*="--hero-text-align: right"] {
    justify-content: flex-end;
}

/* Background Image */
.wpm-hero__background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--hero-bg-image, none);
    background-size: cover;
    background-position: var(--hero-bg-position, center);
    background-repeat: no-repeat;
}

/* Overlay */
.wpm-hero__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #000;
    opacity: var(--hero-overlay-opacity, 0.5);
    z-index: 1;
}

/* Content Container - Intrinsic Design */
.wpm-hero__content {
    position: relative;
    z-index: 2;

    /* Fluid width with max-width constraint */
    width: min(var(--hero-content-max-width, 800px), 100%);
    max-width: var(--hero-content-max-width, 800px);

    /* Left margin support */
    margin-left: var(--hero-left-margin, 0px);

    /* Responsive padding using clamp() */
    padding: clamp(2rem, 5vw, 3.75rem) clamp(1.25rem, 3vw, 2.5rem);
}

/* Heading - Intrinsic Typography - Mobile First */
.wpm-hero .wpm-hero__content h1.wpm-hero__heading {
    /* Start with mobile, then override at larger breakpoints */
    font-size: var(--hero-heading-font-size-mobile, clamp(2rem, 5vw + 1rem, 4.5rem));
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 clamp(1rem, 2vw, 1.5rem) 0;
    color: var(--hero-heading-color, #ffffff);
    text-align: var(--hero-content-text-align, left);
    text-shadow: var(--hero-heading-text-shadow, none);
}

.wpm-hero .wpm-hero__content h1.wpm-hero__heading strong {
    font-weight: 900;
}

/* Subheading - Intrinsic Typography - Mobile First */
.wpm-hero .wpm-hero__content p.wpm-hero__subheading {
    /* Start with mobile, then override at larger breakpoints */
    font-size: var(--hero-subheading-font-size-mobile, clamp(1rem, 2vw + 0.5rem, 1.5rem));
    line-height: 1.6;
    margin: 0 0 clamp(1.25rem, 2.5vw, 2rem) 0;
    opacity: 0.95;
    color: var(--hero-subheading-color, #ffffff);
    text-align: var(--hero-content-text-align, left);
    text-shadow: var(--hero-subheading-text-shadow, none);
}

.wpm-hero .wpm-hero__content p.wpm-hero__subheading strong {
    font-weight: 600;
}

/* Button Wrapper - Text Flow Layout */
.wpm-hero__button-wrapper {
    display: block;
    text-align: left;
}

/* Button Alignment */
.wpm-hero__button-wrapper--left {
    text-align: left;
    justify-content: flex-start;
}

.wpm-hero__button-wrapper--center {
    text-align: center;
    justify-content: center;
}

.wpm-hero__button-wrapper--right {
    text-align: right;
    justify-content: flex-end;
}

/* Adjust button margins for alignment */
.wpm-hero__button-wrapper--right .wpm-hero__button {
    margin-right: 0;
}

.wpm-hero__button-wrapper--left .wpm-hero__button:first-child {
    margin-left: 0;
}

/* Text Background */
.wpm-hero__text-background {
    position: relative;
    padding: clamp(1rem, 2vw, 1.5rem);
    display: inline-block;
    max-width: 100%;
}

.wpm-hero__text-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--hero-text-bg-color, #000000);
    opacity: var(--hero-text-bg-opacity, 0.8);
    z-index: -1;
}

/* Buttons - Base Styles */
.wpm-hero__button {
    display: inline-block;
    padding: clamp(0.875rem, 2vw, 1rem) clamp(1.5rem, 3vw, 2rem);
    text-decoration: none;
    border-radius: 0;
    font-weight: 600;
    font-size: clamp(0.9rem, 1.5vw, 1rem);
    transition: all 0.3s ease;
    text-align: center;
    margin: 0 clamp(0.5rem, 1vw, 0.75rem);
    /* Touch-friendly minimum tap target */
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Improve hit area for touch devices */
    touch-action: manipulation;
}

/* Button 1 - Specific Colors */
.wpm-hero__button-wrapper .wpm-hero__button:first-child {
    background-color: var(--hero-button1-bg-color, #ffffff);
    color: var(--hero-button1-text-color, #000000);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.wpm-hero__button-wrapper .wpm-hero__button:first-child:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    filter: brightness(0.9);
}

/* Button 2 - Specific Colors */
.wpm-hero__button-wrapper .wpm-hero__button:nth-child(2) {
    background-color: var(--hero-button2-bg-color, #ffffff);
    color: var(--hero-button2-text-color, #000000);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.wpm-hero__button-wrapper .wpm-hero__button:nth-child(2):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    filter: brightness(0.9);
}

.wpm-hero__button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 115, 170, 0.3);
}

/* Container Queries - Modern Responsive Approach */
@container (max-width: 768px) {
    .wpm-hero__content {
        width: 100%;
    }

    .wpm-hero__button-wrapper {
        max-width: 100%;
    }
}

/* Media Queries - Mobile First Approach */

/* Mobile: 600px and below */
@media (max-width: 600px) {
    .wpm-hero {
        min-height: clamp(20rem, 40vw, 25rem);
    }

    .wpm-hero__content {
        width: 100%;
        max-width: 100%;
        padding: max(4rem, env(safe-area-inset-top, 0px)) 1rem 1.5rem 1rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
        margin-left: auto;
        margin-right: auto;
    }

    .wpm-hero .wpm-hero__content h1.wpm-hero__heading {
        font-size: var(--hero-heading-font-size-mobile, clamp(2rem, 5vw + 1rem, 4.5rem));
        line-height: 1.2;
        word-break: break-word;
        hyphens: auto;
        text-align: center;
    }

    .wpm-hero .wpm-hero__content p.wpm-hero__subheading {
        font-size: var(--hero-subheading-font-size-mobile, clamp(1rem, 2vw + 0.5rem, 1.5rem));
        line-height: 1.5;
        text-align: center;
    }

    .wpm-hero__button-wrapper {
        display: flex;
        flex-direction: column;
        gap: clamp(0.75rem, 2vw, 1rem);
        text-align: center;
    }

    .wpm-hero__button {
        width: 100%;
        margin: 0;
        text-align: center;
        font-size: clamp(0.85rem, 2vw, 0.95rem);
        padding: clamp(0.75rem, 2vw, 0.875rem) clamp(1rem, 2.5vw, 1.5rem);
    }
}

/* Tablet: 601px to 1024px */
@media (min-width: 601px) and (max-width: 1024px) {
    .wpm-hero {
        min-height: clamp(25rem, 50vw, 31.25rem);
        align-items: flex-end;
        justify-content: flex-start;
    }

    .wpm-hero__content {
        width: 100%;
        max-width: 100%;
        padding: 1.875rem 1.25rem;
        text-align: left;
    }

    .wpm-hero .wpm-hero__content h1.wpm-hero__heading {
        font-size: var(--hero-heading-font-size-tablet, var(--hero-heading-font-size-mobile));
    }

    .wpm-hero .wpm-hero__content p.wpm-hero__subheading {
        font-size: var(--hero-subheading-font-size-tablet, var(--hero-subheading-font-size-mobile, clamp(1rem, 2vw + 0.5rem, 1.5rem)));
    }

    .wpm-hero__button-wrapper {
        display: flex;
        flex-wrap: wrap;
        gap: clamp(0.5rem, 1vw, 0.75rem);
    }

    .wpm-hero__button {
        text-align: center;
    }
}

/* Desktop: 1025px and above */
@media (min-width: 1025px) {
    .wpm-hero .wpm-hero__content h1.wpm-hero__heading {
        font-size: var(--hero-heading-font-size-desktop, var(--hero-heading-font-size-mobile));
    }

    .wpm-hero .wpm-hero__content p.wpm-hero__subheading {
        font-size: var(--hero-subheading-font-size-desktop, var(--hero-subheading-font-size-mobile, clamp(1rem, 2vw + 0.5rem, 1.5rem)));
    }
}

/* Medium screens: 769px to 1024px */
@media (min-width: 769px) and (max-width: 1024px) {
    .wpm-hero__content {
        max-width: 90%;
        padding: 3.125rem 1.875rem;
    }

    .wpm-hero__button-wrapper {
        display: flex;
        gap: clamp(0.75rem, 2vw, 1rem);
    }
}

/* Large screens: 1025px and up */
@media (min-width: 1025px) {
    .wpm-hero__content {
        padding: 3.4375rem 2.5rem;
    }

    .wpm-hero__button-wrapper {
        display: flex;
        gap: clamp(0.75rem, 2vw, 1rem);
    }
}

/* Full Width Alignment Support - Stackable-inspired Method */
.wpm-hero.alignfull {
    width: 100vw !important;
    position: relative !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    max-width: 100vw !important;
}

/* Additional override for nested containers */
.entry-content .wpm-hero.alignfull,
.site-content .wpm-hero.alignfull,
article .wpm-hero.alignfull,
main .wpm-hero.alignfull,
.wp-site-blocks .wpm-hero.alignfull {
    width: 100vw !important;
    position: relative !important;
    left: 50% !important;
    right: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    max-width: 100vw !important;
}

/* Wide Alignment Support */
.wpm-hero.alignwide {
    max-width: var(--wp--style--global--wide-size, 1280px);
    width: 100%;
}

/* Blocksy Theme Fix: Override is-layout-constrained for hero blocks */
.is-layout-constrained > .wpm-hero.alignfull,
.entry-content.is-layout-constrained > .wpm-hero.alignfull {
    width: 100vw !important;
    position: relative !important;
    left: 50% !important;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
    max-width: 100vw !important;
}
