/* ==========================================================================
   VYV Domicile — feuille de style
   --------------------------------------------------------------------------
   Sommaire :
     1. Polices
     2. Variables (couleurs, tailles)
     3. Base
     4. Composants communs (container, boutons, footer)
     5. Landing : haut de page (hero)
     6. Landing : formulaire
     7. Popup de remerciement
     8. Pages légales
     9. Responsive (tablette, mobile)

   TAILLES PROPORTIONNELLES (desktop) :
   la maquette est dessinée pour un écran de 1920 px de large.
   La variable --px vaut 1px sur un écran de 1920 px, et diminue
   quand l'écran est plus petit (jusqu'à 0.75px, atteint à 1440 px).

     calc(54 * var(--px))  →  54px à 1920, 40px à 1440…

   Pour les textes, on garde un minimum lisible avec max() :
     max(16px, calc(18 * var(--px)))  →  18px à 1920, jamais moins de 16px.
   ========================================================================== */


/* 1. Polices ============================================================== */

@font-face {
    font-family: "Wigrum";
    src: url("../fonts/wigrum-regular.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: "Wigrum";
    src: url("../fonts/wigrum-medium.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}
@font-face {
    font-family: "Wigrum";
    src: url("../fonts/wigrum-bold.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}
@font-face {
    font-family: "Wigrum";
    src: url("../fonts/wigrum-black.woff2") format("woff2");
    font-weight: 900;
    font-display: swap;
}


/* 2. Variables ============================================================ */

:root {
    --purple: #482683;
    --purple-dark: #351c62;
    --text: #484c64;
    --grey: #9396ab;
    --grey-light: #f6f6f6;
    --field: #f5f5f5;
    --yellow: #ffbd4a;
    --error: #c8102e;
    --error-bg: #fdecee;
    --white: #fff;

    /* 1 « pixel de maquette » : 1px à 1920 px de large, 0.75px minimum (voir en haut du fichier) */
    --px: clamp(0.75px, calc(100vw / 1920), 1px);

    --container: calc(1354 * var(--px));
    --gutter: 24px;

    /* Hauteur de la zone violette, mesurée depuis le bas de la page */
    --purple-height: calc(600 * var(--px));
}


/* 3. Base ================================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: "Wigrum", Arial, Helvetica, sans-serif;
    font-size: max(16px, calc(18 * var(--px)));
    line-height: 1.3;
    color: var(--text);
    background: var(--white);
    -webkit-font-smoothing: antialiased;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: var(--purple);
}

h1,
h2 {
    margin: 0;
    font-weight: 900;
    color: var(--purple);
}

/* Contour visible lors de la navigation au clavier (accessibilité) */
:focus-visible {
    outline: 3px solid var(--purple);
    outline-offset: 3px;
}


/* 4. Composants communs =================================================== */

.container {
    width: min(100% - 2 * var(--gutter), var(--container));
    margin-inline: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: calc(220 * var(--px));
    height: max(46px, calc(56 * var(--px)));
    padding: 0 calc(32 * var(--px));
    border: 0;
    background: var(--purple);
    color: var(--white);
    font: 700 max(17px, calc(22 * var(--px)))/1 "Wigrum", Arial, sans-serif;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn:hover {
    background: var(--purple-dark);
}

.btn[disabled] {
    opacity: 0.7;
    cursor: wait;
}

.btn--small {
    min-width: calc(260 * var(--px));
    height: max(44px, calc(52 * var(--px)));
    font-size: max(15px, calc(17 * var(--px)));
}

.site-footer {
    position: relative;
    padding: calc(90 * var(--px)) 0 calc(18 * var(--px));
}

.site-footer ul {
    display: flex;
    justify-content: flex-end;
    gap: 16px calc(88 * var(--px));
    margin: 0;
    padding: 0 calc(119 * var(--px)) 0 0;
    list-style: none;
}

.site-footer a {
    color: var(--white);
    font-size: max(15px, calc(16 * var(--px)));
    font-weight: 700;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}

.site-footer a:focus-visible {
    outline-color: var(--white);
}


/* 5. Landing : haut de page =============================================== */

/* Vague grise en fond, derrière le haut de page et le haut du formulaire */
.page {
    background: url("../img/forme-grise.png") no-repeat center calc(50 * var(--px)) / 100% auto;
}

.hero__inner {
    position: relative;
    padding: calc(20 * var(--px)) 0 calc(32 * var(--px));
}

.hero__logo {
    display: inline-block;
    width: calc(108 * var(--px));
    margin-left: calc(39 * var(--px));
}

.hero__media {
    position: absolute;
    top: calc(30 * var(--px));
    right: 0;
    width: calc(470 * var(--px));
}

.hero__text {
    position: relative; /* passe au-dessus de la photo si elles se chevauchent */
    max-width: calc(860 * var(--px));
    margin-left: calc(39 * var(--px));
    padding-top: calc(44 * var(--px));
}

.hero__text h1 {
    margin-bottom: calc(16 * var(--px));
    font-size: max(28px, calc(36 * var(--px)));
    line-height: 1.12;
}

.hero__text p {
    margin: 0 0 calc(14 * var(--px));
}

.hero__text p:last-child {
    margin-bottom: 0;
}

/* Retours à la ligne de la maquette : seulement quand le texte a sa taille « maquette » */
@media (max-width: 1700px) {
    .br-desktop,
    .contact__intro br {
        display: none;
    }
}


/* 6. Landing : formulaire ================================================= */

/* Zone du bas : contient le formulaire et le footer, sur fond violet arrondi */
.bottom {
    position: relative;
    overflow: hidden;
    isolation: isolate; /* le fond violet (z-index: -1) reste dans cette zone */
}

/* Le fond violet en forme de dôme */
.bottom::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: calc(100% - var(--purple-height));
    left: -30%;
    right: -30%;
    bottom: -100vw;
    background: var(--purple);
    border-radius: 50% 50% 0 0 / 60vw 60vw 0 0;
}

.contact {
    position: relative;
    max-width: calc(800 * var(--px));
}

/* Forme jaune décorative, derrière le formulaire */
.contact__shape {
    position: absolute;
    left: 80.5%;
    bottom: calc(-70 * var(--px));
    width: calc(290 * var(--px));
    pointer-events: none;
}

.contact__card {
    position: relative;
    padding: calc(38 * var(--px)) calc(40 * var(--px)) calc(40 * var(--px));
    background: var(--white);
    box-shadow: 0 0 0 1px #e9e9ee, 0 10px 30px rgba(72, 38, 131, 0.08);
}

.contact__card h2 {
    margin-bottom: calc(10 * var(--px));
    font-size: max(24px, calc(34 * var(--px)));
    line-height: 1.12;
}

.contact__intro {
    margin: 0 0 calc(22 * var(--px));
}

.field {
    margin-bottom: calc(14 * var(--px));
}

.field__label {
    display: block;
    margin-bottom: 6px;
    color: var(--purple);
    font-size: max(16px, calc(18 * var(--px)));
    font-weight: 700;
}

.field__input {
    display: block;
    width: 100%;
    height: max(44px, calc(52 * var(--px)));
    padding: 0 calc(20 * var(--px));
    border: 0;
    border-radius: 0;
    background: var(--field);
    color: var(--text);
    font: 500 max(16px, calc(18 * var(--px))) "Wigrum", Arial, sans-serif;
}

.field__input::placeholder {
    color: var(--grey);
    opacity: 1;
}

.field__input:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--purple);
}

/* Menu déroulant : on remplace la flèche du navigateur par celle de la maquette */
.field__select {
    padding-right: calc(56 * var(--px));
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 35'%3E%3Cpath fill='%239396ab' d='M16 0 32 16H0zM0 19h32L16 35z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right calc(14 * var(--px)) center;
    background-size: calc(24 * var(--px)) calc(26 * var(--px));
    cursor: pointer;
}

/* Tant qu'aucun secteur n'est choisi, le texte est gris comme un placeholder */
.field__select:invalid {
    color: var(--grey);
}

.field__select option {
    color: var(--text);
}

/* Case à cocher personnalisée : la vraie case est cachée, on dessine un carré à la place */
.field--checkbox {
    position: relative;
    margin-top: calc(26 * var(--px));
}

.checkbox__input {
    position: absolute;
    opacity: 0;
    width: max(44px, calc(52 * var(--px)));
    height: max(44px, calc(52 * var(--px)));
    margin: 0;
    cursor: pointer;
}

.checkbox__label {
    display: flex;
    align-items: center;
    gap: calc(18 * var(--px));
    color: var(--purple);
    font-size: max(15px, calc(17 * var(--px)));
    font-weight: 700;
    line-height: 1.25;
    cursor: pointer;
}

.checkbox__box {
    flex: 0 0 max(44px, calc(52 * var(--px)));
    height: max(44px, calc(52 * var(--px)));
    background: var(--field) no-repeat center / 60%;
}

.checkbox__input:checked + .checkbox__label .checkbox__box {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23482683' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round' d='M4 12.5l5 5L20 6.5'/%3E%3C/svg%3E");
}

.checkbox__input:focus-visible + .checkbox__label .checkbox__box {
    outline: 3px solid var(--purple);
    outline-offset: 3px;
}

/* Erreurs */
.field__error {
    margin: 6px 0 0;
    color: var(--error);
    font-size: max(14px, calc(15 * var(--px)));
    font-weight: 500;
}

.field__error:empty {
    display: none;
}

.has-error .field__input,
.has-error .checkbox__box {
    background-color: var(--error-bg);
    box-shadow: inset 0 0 0 2px var(--error);
}

.form__alert {
    margin-bottom: 20px;
    padding: 14px 18px;
    background: var(--error-bg);
    color: var(--error);
    font-size: max(15px, calc(16 * var(--px)));
    font-weight: 500;
}

.form__alert:empty {
    display: none;
}

/* Champ piège anti-robot : sorti de l'écran */
.form__trap {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* « * Champ obligatoire » à gauche, bouton Envoyer à droite, sur la même ligne */
.form__footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-top: calc(22 * var(--px));
}

.form__required {
    margin: 0;
    color: var(--grey);
    font-size: max(14px, calc(15 * var(--px)));
    font-weight: 500;
}

.form__legal {
    margin: calc(18 * var(--px)) 0 0;
    color: var(--grey);
    font-size: max(13px, calc(13 * var(--px)));
    line-height: 1.4;
}

.form__legal a {
    color: inherit;
}


/* 7. Popup de remerciement ================================================ */

.popup {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(72, 38, 131, 0.55);
    animation: popup-fade 0.25s ease-out;
}

/* Sans cette règle, display: flex l'emporterait sur l'attribut hidden */
.popup[hidden] {
    display: none;
}

.popup__box {
    position: relative;
    width: min(calc(860 * var(--px)), 100%);
    max-height: 100%;
    overflow-y: auto;
    padding: calc(110 * var(--px)) calc(40 * var(--px)) calc(100 * var(--px));
    background: var(--white);
    text-align: center;
}

.popup__box:focus {
    outline: none;
}

.popup__close {
    position: absolute;
    top: 11px;
    right: 14px;
    display: flex;
    padding: 4px;
    color: var(--grey);
}

.popup__close:hover {
    color: var(--purple);
}

.popup__text {
    margin: 0 0 calc(34 * var(--px));
    color: var(--purple);
    font-size: max(18px, calc(28 * var(--px)));
    line-height: 1.2;
}

.popup__text strong {
    display: block;
    font-size: max(20px, calc(31 * var(--px)));
}

@keyframes popup-fade {
    from {
        opacity: 0;
    }
}


/* 8. Pages légales ======================================================== */

.legal-header {
    padding: 20px 0;
    border-bottom: 1px solid #ececf1;
}

.legal-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.legal-header__logo {
    width: 72px;
}

.legal-header__back {
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
}

.legal-header__back:hover {
    text-decoration: underline;
}

.legal {
    max-width: 920px;
    padding: 56px 0 80px;
    font-size: 17px;
    line-height: 1.6;
}

.legal h1 {
    margin-bottom: 8px;
    font-size: 36px;
    line-height: 1.15;
}

.legal__subtitle {
    margin: 0 0 40px;
    color: var(--grey);
    font-weight: 700;
}

.legal h2 {
    margin: 44px 0 14px;
    font-size: 23px;
    font-weight: 700;
    line-height: 1.25;
}

.legal h3 {
    margin: 28px 0 8px;
    color: var(--purple);
    font-size: 19px;
}

.legal p,
.legal ul {
    margin: 0 0 14px;
}

.legal li {
    margin-bottom: 6px;
}

.legal a {
    overflow-wrap: anywhere; /* les longues URL ne débordent pas sur mobile */
}

.legal__date {
    margin-top: 48px !important;
    color: var(--grey);
    font-size: 15px;
}

/* Tableaux : défilement horizontal sur petit écran plutôt que de casser la mise en page */
.table-wrap {
    margin: 20px 0 28px;
    overflow-x: auto;
}

.legal table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 16px;
    line-height: 1.45;
}

.legal th,
.legal td {
    padding: 12px 16px;
    border: 1px solid #e3e3ea;
    text-align: left;
    vertical-align: top;
}

.legal th {
    background: var(--purple);
    color: var(--white);
    font-weight: 700;
}

.legal tbody tr:nth-child(even) {
    background: var(--grey-light);
}

.legal td ul {
    margin: 4px 0 0;
    padding-left: 18px;
}

/* Bloc dépliable « Vos droits en détail » */
.legal details {
    margin: 20px 0;
    padding: 0 24px;
    background: var(--grey-light);
}

.legal summary {
    padding: 16px 0;
    color: var(--purple);
    font-weight: 700;
    cursor: pointer;
}

.legal details[open] {
    padding-bottom: 12px;
}

/* Valeur pas encore renseignée (config/site.php) */
.todo {
    padding: 0 4px;
    background: #fff3cd;
    color: #7a5d00;
    font-weight: 700;
}

.page-legal .site-footer {
    padding: 32px 0;
    background: var(--purple);
}


/* 9. Responsive =========================================================== */

/* Tablette : la photo passe à côté du logo, le texte en dessous */
@media (max-width: 1024px) {
    :root {
        --container: 900px;
        --purple-height: 480px;
    }

    .hero__inner {
        display: grid;
        grid-template-columns: auto minmax(0, 300px);
        justify-content: space-between;
        align-items: start;
        gap: 0 24px;
        padding-top: 20px;
    }

    .hero__logo {
        width: 100px;
        margin-left: 0;
    }

    .hero__media {
        position: static;
        width: auto;
    }

    .hero__text {
        grid-column: 1 / -1;
        max-width: none;
        margin-left: 0;
        padding-top: 20px;
    }

    .contact {
        max-width: 760px;
        margin-inline: auto;
    }

    .contact__intro br,
    .contact__card h2 br {
        display: none;
    }

    .contact__shape {
        left: auto;
        right: -70px;
        bottom: -70px;
        width: 220px;
    }

    .site-footer {
        padding-top: 90px;
    }

    .site-footer ul {
        justify-content: center;
        gap: 12px 48px;
        padding-right: 0;
    }

    .popup__box {
        padding: 90px 32px 70px;
    }
}

/* Mobile */
@media (max-width: 640px) {
    :root {
        --gutter: 16px;
        --purple-height: 400px;
    }

    .page {
        background-size: 400% auto;
        background-position: 30% 60px;
    }

    .hero__inner {
        grid-template-columns: 84px minmax(0, 1fr);
        padding-bottom: 28px;
    }

    .hero__logo {
        width: 84px;
    }

    .hero__media {
        max-width: 240px;
        justify-self: end;
    }

    .hero__text h1 br {
        display: none;
    }

    .hero__text h1 {
        font-size: 26px;
    }

    .contact__card {
        padding: 28px 18px 32px;
    }

    .field__input {
        padding: 0 16px;
    }

    .field__select {
        padding-right: 48px;
        background-size: 22px 24px;
    }

    .form__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .contact__shape {
        right: -50px;
        bottom: -55px;
        width: 150px;
    }

    .site-footer {
        padding: 80px 0 28px;
    }

    .site-footer ul {
        flex-direction: column;
        align-items: center;
    }

    .popup__box {
        padding: 64px 20px 40px;
    }

    .popup__text br {
        display: none;
    }

    .btn--small {
        width: 100%;
    }

    .legal {
        padding: 36px 0 56px;
        font-size: 16px;
    }

    .legal h1 {
        font-size: 28px;
    }

    .legal h2 {
        font-size: 20px;
    }

    .legal details {
        padding: 0 16px;
    }
}

/* Visiteurs ayant demandé à limiter les animations */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
