/*
Theme Name: Laboratory Clarity — Elementor Safe Child
Theme URI: https://allianceassays.com/
Template: laboratory-clarity
Author: Geeks of Cybernet
Description: Original Laboratory Clarity child theme with isolated Elementor layout CSS corrections. No migration, form, SEO, theme-template, or database changes.
Version: 2.3.0
Requires at least: 6.6
Requires PHP: 8.1
License: GPL-2.0-or-later
Text Domain: laboratory-clarity-elementor
*/

/*
 * ALLIANCE ASSAYS / ELEMENTOR LAYOUT CORRECTION — v2.3.0
 *
 * Only affects converted Alliance Elementor documents (.aaec-elementor).
 * The parent theme and AAEC migration plugin remain unchanged.
 *
 * The migration plugin's compat.css is loaded after this file; selectors here
 * are deliberately more specific. !important is confined to layout geometry
 * that was being overridden by the migration's legacy flex rules.
 *
 * All Elementor-native padding, margins on ordinary sections/cards, and gap
 * values are intentionally left alone. Do not use broad .e-con resets here.
 */

/* The original theme uses centered, max-1240px content. Elementor's default
 * --margin-left/--margin-right may resolve to zero, so the converted wrappers
 * need explicit automatic inline margins instead of inheriting those vars.
 * --width remains available for intentionally narrower Elementor content. */
body.aaec-elementor {
    --aaec-theme-gutter: 80px;
    --aaec-theme-content-max: 1240px;
}
body.aaec-elementor .site-content.entry-content,
body.aaec-elementor .site-content.entry-content > .elementor {
    width: 100%;
    max-width: none;
    margin-inline: 0;
}
body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted:is(.lwm-section-inner, .hero-grid) {
    box-sizing: border-box;
    width: min(var(--width, 100%), var(--aaec-theme-content-max), calc(100% - var(--aaec-theme-gutter))) !important;
    max-width: var(--aaec-theme-content-max) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    min-width: 0;
}

/* Narrow headings and FAQ panels retain their original dimensions without
 * making the surrounding section narrower. */
body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.section-heading {
    width: min(var(--width, 100%), 750px) !important;
    max-width: 750px !important;
    min-width: 0;
}
body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-faq {
    width: min(var(--width, 100%), 900px) !important;
    max-width: 900px !important;
    min-width: 0;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* A genuine grid avoids the flex item / default --width:100% conflict which
 * was turning desktop 3-card rows into 2 + 1 and 2-card rows into a stack.
 * The gaps are read from Elementor's own --gap variable by compat.css. */
body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    min-width: 0;
    width: min(var(--width, 100%), 100%) !important;
    max-width: 100% !important;
}
/* Original source has deliberate 2-column grids with 2 or 4 cards. */
body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-grid.aaec-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-grid > .e-con.lwm-card {
    box-sizing: border-box;
    width: min(var(--width, 100%), 100%) !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
}
/* These descendants are allowed to shrink inside their equal-width track. */
body.aaec-elementor .site-content.entry-content .elementor .e-con.lwm-card :is(.elementor-widget, .elementor-widget-container, .e-con.card-body) {
    min-width: 0;
    max-width: 100%;
}

/* The source has four process milestones, not three. Match original desktop
 * tracks exactly and let Elementor's gap control determine the separation. */
body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-steps {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
    min-width: 0;
    width: min(var(--width, 100%), 100%) !important;
    max-width: 100% !important;
}
body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-steps > .e-con.lwm-step {
    width: min(var(--width, 100%), 100%) !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
}

/* Split sections are two equal tracks. Elementor still controls padding and
 * the gap. Nested image widgets fill their track without forcing overflow. */
body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-split {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    min-width: 0;
    width: 100% !important;
}
body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-split > .elementor-element {
    width: min(var(--width, 100%), 100%) !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
}

/* Optional Elementor header and footer templates use the same centered
 * content width as the original WordPress header and footer. */
body.aaec-parts-active .elementor .e-con.aaec-converted:is(
    .aaec-utility-inner, .aaec-header-inner, .aaec-footer-top,
    .aaec-footer-bottom, .aaec-footer-disclaimer
) {
    box-sizing: border-box;
    width: min(var(--width, 100%), 1240px, calc(100% - 80px)) !important;
    max-width: 1240px !important;
    margin-inline: auto !important;
    min-width: 0;
}

/* Below 1150px, match original theme's 25px-side content gutters. */
@media (max-width: 1150px) {
    body.aaec-elementor { --aaec-theme-gutter: 50px; }
    body.aaec-parts-active .elementor .e-con.aaec-converted:is(
        .aaec-utility-inner, .aaec-header-inner, .aaec-footer-top,
        .aaec-footer-bottom, .aaec-footer-disclaimer
    ) { width: min(var(--width, 100%), 1240px, calc(100% - 50px)) !important; }
}

/* Tablet: two cards / two process steps / a single split column. */
@media (max-width: 900px) {
    body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-steps {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Phones: restore original 18px-side gutters and one-column service/splits. */
@media (max-width: 760px) {
    body.aaec-elementor { --aaec-theme-gutter: 36px; }
    body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-grid,
    body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-grid.aaec-grid-2,
    body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-split {
        grid-template-columns: minmax(0, 1fr);
    }
    body.aaec-parts-active .elementor .e-con.aaec-converted:is(
        .aaec-utility-inner, .aaec-header-inner, .aaec-footer-top,
        .aaec-footer-bottom, .aaec-footer-disclaimer
    ) { width: min(var(--width, 100%), 1240px, calc(100% - 36px)) !important; }
}

@media (max-width: 420px) {
    body.aaec-elementor .site-content.entry-content .elementor .e-con.aaec-converted.lwm-steps {
        grid-template-columns: minmax(0, 1fr);
    }
}
