/*
 Theme Name: Thornhill
 Theme URI: https://www.elegantthemes.com/gallery/divi/
 Description: Divi Child Theme
 Author: Elegant Themes
 Author URI: https://www.elegantthemes.com
 Template: Divi
 Version: 1.0.0
*/
 
/* =Theme customization starts here
------------------------------------------------------- */

/* Fix: Replace non-composited Divi button animations with compositor-only equivalents.
 * Divi's default transitions animate color, border-*, font-size, padding, and margin-left
 * on buttons — all non-compositable properties that trigger paint on every frame, causing
 * jank and CLS. We override transitions to use only transform + opacity (GPU-composited).
 *
 * The arrow (::after) is re-anchored via a static margin-left and moved with translateX
 * instead of animating margin-left directly, eliminating the layout-shift trigger.
 */

/* Limit button transitions to compositable properties only */
.et_pb_button,
.et_pb_more_button {
    -webkit-transition: opacity 300ms ease 0ms !important;
    transition: opacity 300ms ease 0ms !important;
}

/* Arrow pseudo-element: static margin-left, slide via transform + fade via opacity */
.et_pb_button::after,
.et_pb_more_button::after {
    margin-left: -1em !important;         /* Fixed anchor — never transitions */
    -webkit-transform: translateX(0);
    transform: translateX(0);
    opacity: 0;
    will-change: transform, opacity;
    -webkit-transition: -webkit-transform 0.4s ease, opacity 0.4s ease !important;
    transition: transform 0.4s ease, opacity 0.4s ease !important;
}

/* On hover slide arrow to its visible position using transform (composited) */
.et_pb_button:hover::after,
.et_pb_more_button:hover::after {
    -webkit-transform: translateX(1.3em); /* net: -1em anchor + 1.3em = 0.3em right of text */
    transform: translateX(1.3em);
    opacity: 1;
}

/* Fix #62: Mobile navigation menu overflows viewport with no scroll.
 * Cap the menu height at 80% of the viewport and enable touch-friendly scrolling.
 */
@media only screen and (max-width: 980px) {
    .et_mobile_nav_menu {
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Fix #65: Collapse mobile sub-menus behind a tap-to-expand arrow.
 * Sub-menus are hidden by default and revealed when the parent <li>
 * receives the .thorn-open class injected by functions.php JavaScript.
 */
@media only screen and (max-width: 980px) {
    .et_mobile_menu .menu-item-has-children > .sub-menu {
        display: none !important;
        width: 100%;
    }

    .et_mobile_menu .menu-item-has-children.thorn-open > .sub-menu {
        display: block !important;
    }

    /* Flex on the <li> so the toggle button sits to the right of the link */
    .et_mobile_menu .menu-item-has-children {
        display: flex !important;
        align-items: center !important;
        flex-wrap: wrap !important;
    }

    .et_mobile_menu .menu-item-has-children > a {
        flex: 1;
    }

    /* Toggle is a sibling <button> after the <a>, not inside it */
    .et_mobile_menu .thorn-toggle {
        background: none;
        border: none;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        min-height: 40px;
        cursor: pointer;
        color: inherit;
        font-style: normal;
        -webkit-transition: -webkit-transform 0.2s ease;
        transition: transform 0.2s ease;
        flex-shrink: 0;
    }

    .et_mobile_menu .menu-item-has-children.thorn-open > .thorn-toggle {
        -webkit-transform: rotate(90deg);
        transform: rotate(90deg);
    }
}

/* Fix #63: Allow all testimonials to expand to their natural height on all screen sizes.
 * The original mobile-only fix was lost in subsequent merges; extended to all viewports. */
.et_pb_testimonials_slider {
    height: auto !important;
}

.et_pb_testimonials_slider .et_pb_slide {
    height: auto !important;
    position: relative !important;
}

.et_pb_testimonials_slider .et_pb_testimonial,
.et_pb_testimonials_slider .et_pb_testimonial_description,
.et_pb_testimonials_slider .et_pb_testimonial_description_content {
    height: auto !important;
    overflow: visible !important;
    white-space: normal !important;
}

/* Allow the testimonials section wrapper to expand with its content. */
.et_pb_code_0 {
    height: auto !important;
    max-height: none !important;
}

/* Fix #61: Disable all newsletter subscribe elements on all devices. */
.area-outer-wrap,
#subscribe_main,
.et_pb_newsletter,
.et_pb_newsletter_button,
.et_pb_newsletter_form {
    display: none !important;
}

/* Fix #61 (follow-up): the Popups for Divi plugin renders its dark backdrop
 * as a separate .da-overlay element outside the wrapper above, and toggles
 * body classes to lock scrolling. Hiding the wrapper alone left this overlay
 * blocking the page. */
.da-overlay {
    display: none !important;
}
body.da-popup-visible,
body.da-overlay-visible {
    overflow: auto !important;
}
