/**
 * Marilamp Contact Page - front office styles.
 *
 * Three independent groups, in this order:
 *   1. the page layout (intro column beside the native form, stores below);
 *   2. the module's own sections, fully namespaced under .mlc-* (BEM);
 *   3. the restyling of the *native* PrestaShop contact form, scoped so that it
 *      can only ever apply to a content wrapper that holds our intro column.
 *
 * Nothing here targets a bare theme selector: every rule outside .mlc-* is
 * anchored on `:has(.mlc-intro...)`, so the shop looks untouched wherever the
 * module is not displayed, and the switches in the back office simply add or
 * remove a class on the intro element.
 *
 * @author    Trigénius
 * @copyright Trigénius
 */

:root {
    /* Overwritten by the inline <style> the module prints from its settings. */
    --mlc-accent: #e00b17;
    --mlc-card-bg: #1a1a1a;
    --mlc-heading: #1a1a1a;

    --mlc-muted: #6f6f6f;
    --mlc-field-bg: #f1f1f1;
    --mlc-field-text: #3d3d3d;
    --mlc-placeholder: #b4b4b4;
    --mlc-radius: 6px;
    --mlc-gap: clamp(24px, 4vw, 64px);
}

/* =====================================================================
 * 1. Page layout
 *
 * The three blocks (our intro, the theme's #main with the form, our stores
 * grid) are siblings of #content-wrapper, so a grid on the wrapper is enough
 * to compose the reference layout without moving a single node.
 * ================================================================== */

@media (min-width: 992px) {
    #content-wrapper:has(> .mlc-intro) {
        display: grid;
        grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
        column-gap: var(--mlc-gap);
        row-gap: clamp(48px, 7vw, 104px);
        align-items: start;
    }

    #content-wrapper:has(> .mlc-intro) > .mlc-intro {
        grid-column: 1;
        padding-top: clamp(8px, 1.5vw, 24px);
    }

    #content-wrapper:has(> .mlc-intro) > #main {
        grid-column: 2;
    }

    /* The stores grid - and anything else hooked into the wrapper - keeps the
       full width instead of being pulled into one of the two columns. */
    #content-wrapper:has(> .mlc-intro) > *:not(.mlc-intro):not(#main) {
        grid-column: 1 / -1;
    }
}

@media (max-width: 991px) {
    #content-wrapper:has(> .mlc-intro) > .mlc-intro {
        margin-bottom: clamp(24px, 5vw, 40px);
    }
}

/* Optional: drop the description and the map the theme prints above the form. */
body:has(.mlc-intro--hide-theme) .section:has(> .desc_contact),
body:has(.mlc-intro--hide-theme) .desc_contact,
body:has(.mlc-intro--hide-theme) .section > iframe {
    display: none !important;
}

/* =====================================================================
 * 2a. Intro column
 * ================================================================== */

.mlc-intro,
.mlc-stores {
    box-sizing: border-box;
}

.mlc-intro *,
.mlc-intro *::before,
.mlc-intro *::after,
.mlc-stores *,
.mlc-stores *::before,
.mlc-stores *::after {
    box-sizing: border-box;
}

.mlc-intro {
    color: var(--mlc-muted);
}

.mlc-intro__title {
    margin: 0 0 14px;
    font-size: clamp(26px, 2.6vw, 36px);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--mlc-heading);
}

.mlc-intro__title-line {
    display: block;
}

.mlc-intro__subtitle {
    margin: 0 0 clamp(20px, 2.5vw, 30px);
    font-size: 14px;
    line-height: 1.5;
    color: var(--mlc-muted);
}

/* Information blocks: a <dl> where every <dt> is the bold line. */
.mlc-intro__blocks {
    margin: 0 0 clamp(20px, 2.5vw, 30px);
}

.mlc-block__label {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.45;
    color: var(--mlc-heading);
}

.mlc-block__lines {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--mlc-muted);
}

.mlc-block__lines:last-child {
    margin-bottom: 0;
}

.mlc-block__line {
    display: block;
}

/* Socials */

.mlc-intro__social-label {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.45;
    color: var(--mlc-heading);
}

.mlc-social {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mlc-social__item {
    margin: 0;
}

.mlc-social__link {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid #d9d9d9;
    border-radius: 50%;
    color: var(--mlc-heading);
    text-decoration: none;
    transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.mlc-social__link:hover,
.mlc-social__link:focus {
    border-color: var(--mlc-accent);
    color: var(--mlc-accent);
    text-decoration: none;
    transform: translateY(-1px);
}

.mlc-social__link:focus-visible {
    outline: 2px solid var(--mlc-accent);
    outline-offset: 2px;
}

.mlc-social__link .mlc-icon {
    width: 16px;
    height: 16px;
}

/* Accessible names that must not be painted. */
.mlc-social__name,
.mlc-stores .sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* =====================================================================
 * 2b. "Visite-nos" stores grid
 * ================================================================== */

.mlc-stores {
    padding: clamp(36px, 5vw, 72px) 0 0;
    color: var(--mlc-muted);
}

.mlc-stores__header {
    margin: 0 0 clamp(22px, 3vw, 38px);
    text-align: center;
}

.mlc-stores__title {
    margin: 0 0 8px;
    font-size: clamp(22px, 2.2vw, 30px);
    font-weight: 800;
    line-height: 1.2;
    color: var(--mlc-heading);
}

.mlc-stores__subtitle {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--mlc-muted);
}

.mlc-stores__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: clamp(16px, 1.8vw, 24px);
    margin: 0;
    padding: 0;
    list-style: none;
}

.mlc-stores__cell {
    display: flex;
    margin: 0;
}

.mlc-store {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    padding: clamp(18px, 1.6vw, 24px);
    border-radius: 10px;
    background-color: var(--mlc-card-bg);
    color: #cfcfcf;
}

.mlc-store__name {
    margin: 0;
    font-size: clamp(16px, 1.3vw, 19px);
    font-weight: 800;
    line-height: 1.2;
    color: #fff;
}

.mlc-store__badge {
    font-size: 0.8em;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #ffffff;
    opacity: 0.85;
}

.mlc-store__address {
    margin: 0;
    font-size: 13px;
    font-style: normal;
    line-height: 1.5;
    color: #b6b6b6;
}

.mlc-store__address-line {
    display: block;
}

.mlc-store__contacts {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mlc-store__contact {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
}

.mlc-store__contact .mlc-icon {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    color: #ffffff;
}

.mlc-store__contact a {
    color: #e4e4e4;
    text-decoration: none;
    word-break: break-word;
}

.mlc-store__contact a:hover,
.mlc-store__contact a:focus {
    color: #fff;
    text-decoration: underline;
}

/* Map button: light pill by default, accent on hover, as in the reference. */
.mlc-store__map {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-end;
    margin-top: auto;
    padding: 5px 6px 5px 16px;
    border-radius: 999px;
    background-color: #fff;
    color: #1a1a1a;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.mlc-store__map:hover,
.mlc-store__map:focus {
    background-color: var(--mlc-accent);
    color: #fff;
    text-decoration: none;
}

.mlc-store__map:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.mlc-store__map-icon {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: #1a1a1a;
    color: #fff;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.mlc-store__map:hover .mlc-store__map-icon,
.mlc-store__map:focus .mlc-store__map-icon {
    background-color: #fff;
    color: var(--mlc-accent);
}

.mlc-store__map-icon .mlc-icon {
    width: 13px;
    height: 13px;
}

/* =====================================================================
 * 3. Native contact form, restyled
 *
 * Scoped to a wrapper that carries our intro column with the "form" switch on:
 * the markup, the fields and the validation remain the ones of PrestaShop.
 * ================================================================== */

#content-wrapper:has(.mlc-intro--form) #content.page-content {
    padding: clamp(22px, 2.4vw, 40px);
    border: 1px solid #ececec;
    border-radius: 14px;
    background-color: #fff;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.05);
}

#content-wrapper:has(.mlc-intro--form) .contact-form {
    color: var(--mlc-field-text);
}

/* The heading lives in the intro column, so the one inside the card is dropped. */
#content-wrapper:has(.mlc-intro--form) .contact-form .form-group.row:has(.form-title-contact) {
    display: none;
}

#content-wrapper:has(.mlc-intro--form) .contact-form .form-group.row {
    align-items: center;
    margin-bottom: 12px;
}

#content-wrapper:has(.mlc-intro--form) .contact-form .form-control-label {
    margin-bottom: 0;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.3;
    text-align: right;
    color: #9a9a9a;
}

#content-wrapper:has(.mlc-intro--form) .contact-form .form-control,
#content-wrapper:has(.mlc-intro--form) .contact-form .bootstrap-filestyle .form-control {
    height: auto;
    min-height: 40px;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: var(--mlc-radius);
    background-color: var(--mlc-field-bg);
    box-shadow: none;
    color: var(--mlc-field-text);
    font-size: 13px;
    line-height: 1.4;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

#content-wrapper:has(.mlc-intro--form) .contact-form .form-control::placeholder {
    color: var(--mlc-placeholder);
    opacity: 1;
}

#content-wrapper:has(.mlc-intro--form) .contact-form .form-control:focus {
    border-color: var(--mlc-accent);
    background-color: #fff;
    outline: 0;
}

/* Subject: native arrow replaced by an inline caret, drawn in currentColor. */
#content-wrapper:has(.mlc-intro--form) .contact-form select.form-control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='%233d3d3d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px 14px;
}

#content-wrapper:has(.mlc-intro--form) .contact-form textarea.form-control {
    min-height: 108px;
    resize: vertical;
}

/* Attachment: the grey field keeps the file name, the dark button opens it. */
#content-wrapper:has(.mlc-intro--form) .contact-form .bootstrap-filestyle.input-group {
    width: 100%;
}

#content-wrapper:has(.mlc-intro--form) .contact-form .bootstrap-filestyle .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

#content-wrapper:has(.mlc-intro--form) .contact-form .group-span-filestyle .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 0 var(--mlc-radius) var(--mlc-radius) 0;
    background-color: #6e6e6e;
    background-image: none;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-shadow: none;
    box-shadow: none;
    transition: background-color 0.2s ease;
}

#content-wrapper:has(.mlc-intro--form) .contact-form .group-span-filestyle .btn:hover,
#content-wrapper:has(.mlc-intro--form) .contact-form .group-span-filestyle .btn:focus {
    background-color: var(--mlc-accent);
    color: #fff;
}

/* The glyphicon of the file button is redundant next to its label. */
#content-wrapper:has(.mlc-intro--form) .contact-form .icon-span-filestyle {
    display: none;
}

/* GDPR consent line and any other checkbox of the form. */
#content-wrapper:has(.mlc-intro--form) .contact-form .custom-checkbox span,
#content-wrapper:has(.mlc-intro--form) .contact-form [type="checkbox"] + label,
#content-wrapper:has(.mlc-intro--form) .contact-form label em,
#content-wrapper:has(.mlc-intro--form) .contact-form .form-group.row label:not(.form-control-label):not(.btn) {
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.45;
    color: #8a8a8a;
}

/* Submit: pill button aligned with the fields column. */
#content-wrapper:has(.mlc-intro--form) .contact-form .form-footer {
    display: flex;
    justify-content: flex-start;
    margin-top: 6px;
    padding-left: calc(25% + 15px);
    text-align: left;
}

#content-wrapper:has(.mlc-intro--form) .contact-form .form-footer [type="submit"] {
    min-width: 120px;
    padding: 12px 30px;
    border: 0;
    border-radius: 999px;
    background-color: var(--mlc-accent);
    background-image: none;
    box-shadow: none;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-transform: none;
    text-shadow: none;
    transition: filter 0.2s ease, transform 0.2s ease;
}

#content-wrapper:has(.mlc-intro--form) .contact-form .form-footer [type="submit"]:hover,
#content-wrapper:has(.mlc-intro--form) .contact-form .form-footer [type="submit"]:focus {
    filter: brightness(0.92);
    transform: translateY(-1px);
}

#content-wrapper:has(.mlc-intro--form) .contact-form .form-footer [type="submit"]:focus-visible {
    outline: 2px solid var(--mlc-accent);
    outline-offset: 3px;
}

/* Small screens: labels above the fields, button full width. */
@media (max-width: 767px) {
    #content-wrapper:has(.mlc-intro--form) .contact-form .form-control-label {
        margin-bottom: 4px;
        text-align: left;
    }

    #content-wrapper:has(.mlc-intro--form) .contact-form .form-footer {
        padding-left: 0;
    }

    #content-wrapper:has(.mlc-intro--form) .contact-form .form-footer [type="submit"] {
        width: 100%;
    }
}

/* =====================================================================
 * Motion and print
 * ================================================================== */

@media (prefers-reduced-motion: reduce) {
    .mlc-social__link,
    .mlc-store__map,
    .mlc-store__map-icon,
    #content-wrapper:has(.mlc-intro--form) .contact-form .form-footer [type="submit"] {
        transition: none;
    }

    .mlc-social__link:hover,
    .mlc-store__map:hover,
    #content-wrapper:has(.mlc-intro--form) .contact-form .form-footer [type="submit"]:hover {
        transform: none;
    }
}

@media (prefers-reduced-motion: no-preference) {
    @supports (animation-timeline: view()) {
        .mlc-stores__header,
        .mlc-stores__cell {
            animation: mlc-fade-in linear both;
            animation-timeline: view();
            animation-range: entry 5% cover 20%;
        }
    }
}

@keyframes mlc-fade-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media print {
    #content-wrapper:has(> .mlc-intro) {
        display: block;
    }

    .mlc-store {
        color: #000;
        background: none;
        border: 1px solid #999;
    }

    .mlc-store__name,
    .mlc-store__badge,
    .mlc-store__address,
    .mlc-store__contact a,
    .mlc-store__contact .mlc-icon {
        color: #000;
    }

    .mlc-store__map,
    .mlc-social {
        display: none;
    }
}
