/*
 * Kulturna — mobile refinements (additive override layer)
 * ---------------------------------------------------------
 * Loaded AFTER css/styles.min.css (see functions.php). Contains ONLY
 * small-screen overrides; desktop layout is left untouched.
 *
 * Authored by hand and kept OUT of the SCSS/gulp bundle on purpose: the
 * theme's src/sass is currently older than the deployed styles.min.css
 * (it is missing live checkout styling), so recompiling the bundle would
 * regress the site. This file lets us ship mobile fixes with zero risk to
 * the existing compiled CSS. When the current SCSS source is recovered,
 * these rules can be folded into the partials and this file retired.
 *
 * Breakpoints follow the theme's Bootstrap config (lg = 992px, where the
 * nav collapses; sm = 576px).
 */

@media (max-width: 991.98px) {

    /* Belt-and-braces: never allow sideways scrolling on phones. */
    html,
    body {
        overflow-x: hidden;
    }

    /* --- Content media: keep every image/iframe inside the viewport.
       Several editor images carry a hard-coded inline width (e.g. the home
       "trima" graphic at 540px) which overflows a phone screen. --- */
    #content img,
    #content figure,
    #content iframe,
    #content .wp-block-image img {
        max-width: 100%;
        height: auto;
    }

    /* --- Typography: the custom display headings use large px sizes and
       very wide letter-spacing that overflow (and get clipped) on phones.
       Scale them down and tighten tracking below the lg breakpoint. --- */
    .page-template-home h1 {
        font-size: 28px;
        letter-spacing: 6px;
        line-height: 1.15;
        margin-top: 16px;
    }

    .page-template-home h4 {
        font-size: 15px;
        letter-spacing: 3px;
    }

    .entry-header h1.entry-title,
    .single-product .entry-header h1.entry-title {
        font-size: 34px;
        letter-spacing: 3px;
        line-height: 1.15;
    }

    .page-template-history h1 {
        font-size: 30px;
        letter-spacing: 5px;
        line-height: 1.2;
        padding-top: 10px;
    }

    .page-template-contacts h1 {
        font-size: 32px;
        letter-spacing: 3px;
    }

    .page-template-contacts .site-content h4 {
        font-size: 19px;
    }

    .single-recipes .recipe-title {
        font-size: 34px;
        letter-spacing: 4px;
    }

    .page-template-age h4 {
        font-size: 20px;
        letter-spacing: 1px;
        line-height: 1.3;
    }

    /* --- Home: the bottle graphic is absolutely positioned and pulled up to
       sit beside the copy on desktop; on mobile it overlaps the heading.
       Let it flow normally, centred, below the text. --- */
    .page-template-home .bottle img,
    .bottle img {
        position: static;
        left: auto;
        right: auto;
        transform: none;
        margin: 16px auto 0px 26px;
        display: block;
        max-width: 55%;
    }

    /* --- Product loop (shop + related): the thumbnail is intentionally blown
       up (154% wide, shifted -40%) for desktop art-direction, which crowds the
       text column on phones. Rein it in and let titles use the full width. --- */
    ul.products > li.product .woocommerce-LoopProduct-link img.attachment-woocommerce_thumbnail {
        left: 0;
        width: 100%;
        max-width: 100%;
    }

    ul.products > li.product .woocommerce-loop-product__title {
        max-width: none;
        font-size: 24px;
    }

    /* Keep the nested product-loop grid inside the viewport. The item markup is
       li > a.woocommerce-LoopProduct-link > .row > .col-8, and that inner .row's
       negative margins stretch it to the full viewport width, pushing the text
       column flush against #page's overflow:hidden edge (clipping line ends).
       Zeroing the row margins pulls the column back inside its item. */
    ul.products .woocommerce-LoopProduct-link .row {
        margin-left: 0;
        margin-right: 0;
    }

    ul.products .woocommerce-LoopProduct-link .row > [class*="col-"] {
        padding-left: 8px;
        padding-right: 16px;
    }

    ul.products .description,
    ul.products .description p,
    ul.products .woocommerce-loop-product__title {
        overflow-wrap: break-word;
    }

    ul.products .woocommerce-LoopProduct-link .col-8 {
        padding-right: 18px;
    }

    /* --- Age gate: the two consent buttons are 40% wide and side-by-side,
       so their Bulgarian labels run off-screen. Stack them full-width. --- */
    .button-age {
        display: block;
        width: 100%;
        margin: 12px 0;
        height: auto;
        min-height: 52px;
        line-height: 1.3;
        padding: 12px 16px;
    }

    /* --- Footer: fixed 175px height + forced-horizontal nav clips content
       on mobile. Let it grow and wrap. --- */
    footer.site-footer {
        height: auto;
        background-size: cover;
        padding-bottom: 22px;
    }

    footer.site-footer #footer-nav ul {
        flex-wrap: wrap;
    }

    footer.site-footer #footer-nav ul .nav-item .nav-link {
        padding-bottom: 4px;
    }

    footer.site-footer .site-info img {
        max-width: 100%;
    }

    /* --- Single product: the quantity box + "Add to cart" button overflow
       the row and the button label gets clipped. Let them wrap and let the
       button take the remaining width. --- */
    .single-product form.cart {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        align-items: stretch;
    }

    .single-product form.cart .quantity {
        flex: 0 0 auto;
    }

    .single-product form.cart .single_add_to_cart_button {
        flex: 1 1 auto;
        width: auto;
        white-space: normal;
    }

    /* --- Checkout: keep wide WooCommerce tables from forcing horizontal
       overflow; allow them to scroll within their own container. (The cart
       table stacks into cards on phones instead, see _woocommerce.scss.) --- */
    .woocommerce-checkout .shop_table_responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- My-account: the login/register block (#customer_login) is a flex row
       whose two columns only get a width at >=lg (via a col-lg-6 @extend), so
       below lg they collapse to content width (~38px / ~77px) and the two forms
       pile on top of each other. Stack them full-width. The same applies to the
       logged-in dashboard's navigation + content columns. --- */
    .woocommerce-account #customer_login.u-columns,
    .woocommerce-account .u-columns.col2-set {
        display: block;
    }

    .woocommerce-account #customer_login .col-1,
    .woocommerce-account #customer_login .col-2,
    .woocommerce-account .u-columns .u-column1,
    .woocommerce-account .u-columns .u-column2,
    .woocommerce-account .col2-set .col-1,
    .woocommerce-account .col2-set .col-2 {
        width: 100%;
        max-width: 100%;
        float: none;
        margin: 0 0 32px;
    }

    /* Logged-in dashboard: sidebar nav above the content, both full width. */
    .woocommerce-account .woocommerce-MyAccount-navigation,
    .woocommerce-account .woocommerce-MyAccount-content {
        width: 100%;
        max-width: 100%;
        float: none;
    }

    .woocommerce-account .woocommerce-MyAccount-navigation {
        margin-bottom: 24px;
    }

    /* Account form fields (edit-account, addresses) that pair up via col-md-6
       extends can also squeeze on small screens — let them span full width. */
    .woocommerce-account .woocommerce-MyAccount-content form .form-row {
        width: 100%;
    }
}

@media (max-width: 575.98px) {

    .entry-header h1.entry-title,
    .single-product .entry-header h1.entry-title {
        font-size: 28px;
        letter-spacing: 2px;
    }

    .page-template-home h1 {
        font-size: 24px;
        letter-spacing: 4px;
    }

    .page-template-contacts h1 {
        font-size: 26px;
        letter-spacing: 2px;
    }

    /* On the narrowest phones stack the qty box above a full-width button. */
    .single-product form.cart .single_add_to_cart_button {
        flex-basis: 100%;
    }
}
