/**
 * 2PX Elementor Suite - Hero Widget Styles
 * BEM Methodology Used
 */

/* =========================================================================
   Elementor Wrapper – Herencia de altura
   Elementor envuelve el widget en capas que por defecto no propagan la
   altura de la sección. Estas reglas permiten que el widget llene el
   100% del alto de su columna/sección cuando ésta tiene altura definida.
   ========================================================================= */
.elementor-widget-2px-hero,
.elementor-widget-2px-hero .elementor-widget-container {
    height: 100%;
}

/* =========================================================================
   Base Layout & Grid
   ========================================================================= */
.twopx-hero {
    position: relative;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap; /* Allows stacking mechanism */
}

/* Common resets inside the widget */
.twopx-hero * {
    box-sizing: border-box;
}

/* Row wrapping inside elementor handles */
.twopx-hero__media-col,
.twopx-hero__content-col {
    width: 100%; /* Default mobile behavior: Stacked vertically */
}

.twopx-hero__media-col {
    position: relative;
    display: flex;
}

/* =========================================================================
   Media Wrapper (Optimized for LCP to act as backgrounds)
   ========================================================================= */
.twopx-hero__media-wrapper {
    position: relative;
    width: 100%;
    min-height: 300px; /* Minimal height so it doesn't collapse if no content provides height */
    overflow: hidden;
}

/* Position image and video as background replacements */
.twopx-hero__image,
.twopx-hero__video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0; 
    border: none;
}

/* Media Overlay (Transparent layer) */
.twopx-hero__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1; /* Below content, above video/image */
    transition: background-color 0.3s ease;
}

/* =========================================================================
   Content Styles
   ========================================================================= */
.twopx-hero__content-col {
    display: flex;
    flex-direction: column;
    justify-content: center; /* Vertically center content */
    padding: 40px 20px; /* Native padding, user can overwrite in Advanced tab */
    z-index: 2; /* Content must be above everything */
}

.twopx-hero__content-wrapper {
    position: relative;
    max-width: 100%;
}

/* El tamaño del título se controla desde Elementor vía el control
   "Tipografía del Título" (apunta al H1). Las partes 1–3 son spans
   inline que HEREDAN del H1. Con :where() la especificidad es 0,
   así cualquier control de Elementor (especificidad ≥ 0,1,0) gana. */
:where(.twopx-hero__title) {
    line-height: 1.1;
}

/* Los spans fuerzan herencia del H1 (especificidad 0,2,0).
   Esto evita que el tema bloquee el font-size con reglas de span.
   Los controles de Elementor por parte (≥ 0,3,0) aún pueden sobrescribir. */
.elementor-widget-2px-hero .twopx-hero__title-part1,
.elementor-widget-2px-hero .twopx-hero__title-part2,
.elementor-widget-2px-hero .twopx-hero__title-part3 {
    display: inline;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
}

/* Typography base margins */
.twopx-hero__subtitle {
    margin: 0 0 10px 0;
    text-transform: uppercase;
}
.twopx-hero__title {
    margin: 0 0 20px 0;
}
.twopx-hero__description {
    margin: 0 0 30px 0;
    line-height: 1.6;
}

/* Actions block */
.twopx-hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 15px; /* Spacing between buttons */
}
.twopx-hero--layout-media_right .twopx-hero__actions,
.twopx-hero--layout-media_left .twopx-hero__actions {
    /* If content align changes based on parent CSS from Elementor Control we inherit */
    justify-content: inherit;
}

/* Buttons — solo estructura base, colores controlados desde Elementor */
.twopx-hero__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 15px 30px; /* Fallback; el control "Relleno" lo sobreescribe */
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    font-weight: 600;
}
.twopx-hero__btn--primary {
    background-color: #000; /* Fallback */
    color: #fff;             /* Fallback */
}
.twopx-hero__btn--secondary {
    background-color: transparent; /* Fallback */
    color: #000;                   /* Fallback */
    border: 1px solid #000;        /* Fallback */
}

/* =========================================================================
   Layout Variants (Desktop / Tablet)
   ========================================================================= */

/* Default Stacked for Mobile (Already defined above with width: 100%) */

/* Layout 1: Background Full (Global / Mobile & Desktop)
   Media-col es absolutamente posicionado (fondo).
   El hero es flex-column: el content-col crece con flex:1 para
   llenar toda la altura disponible, permitiendo que justify-content
   funcione correctamente para la alineación vertical. */
.twopx-hero.twopx-hero--layout-background {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 380px; /* Fallback cuando la sección no tiene altura definida */
    height: 100%;      /* Llena la sección cuando sí tiene altura definida */
}
.twopx-hero.twopx-hero--layout-background .twopx-hero__media-col {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}
.twopx-hero.twopx-hero--layout-background .twopx-hero__content-col {
    position: relative;
    width: 100%;
    z-index: 2;
    flex: 1; /* Crece para llenar toda la altura del hero */
}
.twopx-hero.twopx-hero--layout-background .twopx-hero__media-wrapper {
    position: relative;
    height: 100%;
    min-height: 0;
}
.twopx-hero.twopx-hero--layout-background .twopx-hero__image,
.twopx-hero.twopx-hero--layout-background .twopx-hero__video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Layout 4: Background Editorial
   Fotografía a ancho completo (idéntico al background) pero el contenido
   se distribuye en una rejilla editorial:
   - Subtitle: arriba-izquierda
   - Meta: arriba-derecha
   - Title: centro (puede expandirse)
   - Description: abajo-izquierda
   - Actions (CTAs): abajo-derecha */
.twopx-hero.twopx-hero--layout-background_editorial {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 380px;
    height: 100%;
}
.twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__media-col {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}
.twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__content-col {
    position: relative;
    width: 100%;
    z-index: 2;
    flex: 1;
}
.twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__media-wrapper {
    position: relative;
    height: 100%;
    min-height: 0;
}
.twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__image,
.twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Mobile: una sola columna apilada — el grid pasa a flujo vertical */
.twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__content-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    gap: 16px;
}

.twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__meta {
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Tablet+: rejilla editorial 2 columnas × 3 filas */
@media (min-width: 768px) {
    .twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__content-wrapper {
        display: grid;
        grid-template-areas:
            "subtitle meta"
            "title    title"
            "description actions";
        grid-template-columns: 1fr auto;
        grid-template-rows: auto 1fr auto;
        column-gap: 24px;
        row-gap: 16px;
    }
    .twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__subtitle {
        grid-area: subtitle;
        align-self: start;
        justify-self: start;
        margin: 0;
    }
    .twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__meta {
        grid-area: meta;
        align-self: start;
        justify-self: end;
    }
    .twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__title {
        grid-area: title;
        align-self: start;
        margin: 0;
    }
    .twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__description {
        grid-area: description;
        align-self: end;
        justify-self: start;
        margin: 0;
        max-width: 60ch;
    }
    .twopx-hero.twopx-hero--layout-background_editorial .twopx-hero__actions {
        grid-area: actions;
        align-self: end;
        justify-self: end;
    }
}

/* Tablet (768px – 1024px): lado a lado con padding reducido */
@media (min-width: 768px) {

    /* Layout 2: Media Right, Text Left */
    /* By default the media col is first in DOM, so we must reorder */
    .twopx-hero.twopx-hero--layout-media_right .twopx-hero__media-col {
        order: 2;
        width: 70%;
    }
    .twopx-hero.twopx-hero--layout-media_right .twopx-hero__content-col {
        order: 1;
        width: 30%;
        padding: 40px 24px; /* Más compacto en tablet */
    }

    /* Layout 3: Media Left, Text Right */
    .twopx-hero.twopx-hero--layout-media_left .twopx-hero__media-col {
        order: 1;
        width: 70%;
    }
    .twopx-hero.twopx-hero--layout-media_left .twopx-hero__content-col {
        order: 2;
        width: 30%;
        padding: 40px 24px; /* Más compacto en tablet */
    }

    /* Layouts lado a lado: el media-wrapper debe llenar el 100%
       de la altura de su columna para que la imagen/video no quede corta */
    .twopx-hero.twopx-hero--layout-media_left .twopx-hero__media-wrapper,
    .twopx-hero.twopx-hero--layout-media_right .twopx-hero__media-wrapper {
        height: 100%;
        min-height: 0;
        align-self: stretch;
        flex: 1;
    }

}

/* Desktop (1025px+): padding generoso en la columna de texto */
@media (min-width: 1025px) {

    .twopx-hero.twopx-hero--layout-media_right .twopx-hero__content-col,
    .twopx-hero.twopx-hero--layout-media_left .twopx-hero__content-col {
        padding: 60px 40px;
    }

}

/* =========================================================================
   Effects & Animations
   ========================================================================= */

@keyframes twopxKenBurns {
    0% { transform: scale(1); }
    100% { transform: scale(1.15); }
}

.twopx-hero--ken-burns .twopx-hero__image {
    animation: twopxKenBurns 12s ease-out alternate infinite;
}
