/**
 * SO Contact Form — styles front.
 * Reprend la maquette « Formulaire de contact complet »
 * (crème #fffdf8 / terracotta #b4462c, Space Grotesk + Instrument Serif).
 * Tout est piloté par variables CSS, surchargables par le thème.
 */
.so-contactform {
    --so-cf-bg: #fffdf8;
    --so-cf-accent: #b4462c;
    --so-cf-accent-hover: #8f3520;
    --so-cf-accent-sending: #8f3a25;
    --so-cf-accent-glow: rgba(180, 70, 44, 0.12);
    --so-cf-text: #1c1a17;
    --so-cf-label: #3a352c;
    --so-cf-muted: #6d6555;
    --so-cf-hint: #8a8070;
    --so-cf-placeholder: #a89e8c;
    --so-cf-border: #d9d0be;
    --so-cf-underline: #ded6c6;
    --so-cf-card-border: #e4dccc;
    --so-cf-card-bg-sel: #fffaf7;
    --so-cf-radius: 3px;
    --so-cf-radius-lg: 8px;

    --so-cf-err: #c0442f;
    --so-cf-err-text: #a93a24;
    --so-cf-err-text-dark: #7d2d1c;
    --so-cf-err-bg: #fbeeea;
    --so-cf-err-border: #e8c7bd;

    --so-cf-ok: #4a6b39;
    --so-cf-ok-bg: #eef3ea;
    --so-cf-ok-border: #cfdcc4;

    position: relative;
    margin: 0;
    color: var(--so-cf-text);
    -webkit-font-smoothing: antialiased;
}

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

/* L'attribut hidden doit toujours l'emporter (sinon écrasé par display:flex). */
.so-contactform [hidden] {
    display: none !important;
}

/* --- Barre de chargement (haut du formulaire) --- */
.so-contactform__progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    overflow: hidden;
    border-radius: 4px 4px 0 0;
}

.so-contactform__progress span {
    display: block;
    width: 33%;
    height: 100%;
    background: var(--so-cf-accent);
    animation: so-cf-bar 1.1s ease-in-out infinite;
}

/* --- Titre --- */
.so-contactform__title {
    margin: 0 0 22px;
    font-family: "Instrument Serif", Georgia, serif;
    font-weight: 400;
    font-size: 30px;
    color: var(--so-cf-text);
}

/* --- Corps --- */
.so-contactform__body {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* --- Lignes / colonnes --- */
.so-contactform__row {
    display: grid;
    grid-template-columns: repeat(var(--so-cf-cols, 1), 1fr);
    gap: 22px 24px;
}

.so-contactform__col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

@media (max-width: 560px) {
    .so-contactform__row {
        grid-template-columns: 1fr;
    }
}

/* --- Champ --- */
.so-contactform__field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.so-contactform__label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.so-contactform__label {
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--so-cf-label);
}

.so-contactform__req {
    color: var(--so-cf-accent);
}

.so-contactform__count {
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    color: var(--so-cf-hint);
    transition: color 0.15s;
}

.so-contactform__count.is-warn {
    color: #a07a2c;
}

.so-contactform__count.is-over {
    color: var(--so-cf-err-text);
}

/* --- Contrôles --- */
.so-contactform__control {
    position: relative;
}

.so-contactform input[type="text"],
.so-contactform input[type="email"],
.so-contactform input[type="tel"],
.so-contactform input[type="number"],
.so-contactform input[type="date"],
.so-contactform textarea,
.so-contactform select {
    width: 100%;
    padding: 10px 2px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--so-cf-underline);
    border-radius: 0;
    color: var(--so-cf-text);
    font: inherit;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s;
}

.so-contactform textarea {
    line-height: 1.6;
    resize: vertical;
    min-height: 80px;
}

.so-contactform__field--email input {
    padding-right: 24px;
}

/* Liste déroulante : flèche native remplacée par un chevron. */
.so-contactform select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 26px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8070' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 2px center;
    background-size: 16px 16px;
}

.so-contactform select:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b4462c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* Les options du menu déroulant natif (couleurs normalisées). */
.so-contactform select option {
    color: var(--so-cf-text);
    background: var(--so-cf-bg);
}

.so-contactform input::placeholder,
.so-contactform textarea::placeholder {
    color: var(--so-cf-placeholder);
}

.so-contactform input:focus,
.so-contactform textarea:focus,
.so-contactform select:focus {
    border-bottom-color: var(--so-cf-accent);
}

/* Champ en erreur */
.so-contactform__field.is-invalid input,
.so-contactform__field.is-invalid textarea,
.so-contactform__field.is-invalid select {
    border-bottom-color: var(--so-cf-err);
    border-bottom-width: 1.5px;
    background: transparent;
}

/* Check « e-mail valide » */
.so-contactform__valid {
    position: absolute;
    right: 2px;
    top: 11px;
    pointer-events: none;
    animation: so-cf-rise 0.2s ease both;
}

/* --- Cartes de sélection (radio) --- */
.so-contactform__chips {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.so-contactform__chip {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 18px;
    border: 1.5px solid var(--so-cf-card-border);
    border-radius: var(--so-cf-radius-lg);
    background: transparent;
    color: var(--so-cf-text);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.so-contactform__chip input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
}

.so-contactform__chip:has(input:checked) {
    background: var(--so-cf-card-bg-sel);
    border-color: var(--so-cf-accent);
    box-shadow: 0 0 0 3px rgba(180, 70, 44, 0.10);
}

.so-contactform__chip:has(input:focus-visible) {
    border-color: var(--so-cf-accent);
}

.so-contactform__chip-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.so-contactform__chip-title {
    display: block;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--so-cf-text);
}

.so-contactform__chip-desc {
    display: block;
    margin-top: 3px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--so-cf-hint);
}

/* --- Case à cocher --- */
.so-contactform__checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}

.so-contactform__checkbox input {
    width: 16px;
    height: 16px;
    margin: 1px 0 0;
    accent-color: var(--so-cf-accent);
    flex: none;
    cursor: pointer;
}

.so-contactform__label-text {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--so-cf-muted);
}

.so-contactform a {
    color: var(--so-cf-accent);
}

.so-contactform a:hover {
    color: var(--so-cf-accent-hover);
}

/* --- Messages d'erreur par champ --- */
.so-contactform__error {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--so-cf-err-text);
}

.so-contactform__error:empty {
    display: none;
}

.so-contactform__error .so-contactform__ico {
    flex: none;
}

.so-contactform__error > span {
    animation: so-cf-rise 0.2s ease both;
}

/* --- Encadrés de statut (récap + erreur serveur) --- */
.so-contactform__status:empty {
    display: none;
}

.so-contactform__summary,
.so-contactform__server {
    display: flex;
    gap: 11px;
    padding: 13px 15px;
    background: var(--so-cf-err-bg);
    border: 1px solid var(--so-cf-err-border);
    border-radius: var(--so-cf-radius);
    margin-bottom: 15px;
}

.so-contactform__summary {
    
    animation: so-cf-shake 0.35s ease both;
}

.so-contactform__summary svg,
.so-contactform__server svg {
    flex: none;
    margin-top: 1px;
    color: var(--so-cf-err-text);
}

.so-contactform__summary span {
    font-size: 13px;
    line-height: 1.55;
    color: var(--so-cf-err-text-dark);
}

.so-contactform__server {
    align-items: flex-start;
    animation: so-cf-rise 0.25s ease both;
}

.so-contactform__server-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.so-contactform__server-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--so-cf-err-text-dark);
}

.so-contactform__server-text {
    font-size: 13px;
    line-height: 1.55;
    color: #8d4231;
}

.so-contactform__server-retry {
    align-self: flex-start;
    padding: 7px 13px;
    background: transparent;
    border: 1px solid #d9a898;
    border-radius: var(--so-cf-radius);
    color: #8d3524;
    font: inherit;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.so-contactform__server-retry:hover {
    background: #f6e0d9;
}

/* --- CAPTCHA --- */
.so-contactform__captcha {
    margin: 4px 0;
}

.so-contactform__captcha-note {
    margin: 0;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--so-cf-hint);
}

.so-contactform__captcha-note a {
    color: var(--so-cf-hint);
    text-decoration: underline;
}

/* --- Actions --- */
.so-contactform__actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-top: 6px;
}

.so-contactform__submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    padding: 15px 22px;
    border: none;
    border-radius: var(--so-cf-radius-lg);
    background: var(--so-cf-accent);
    color: var(--so-cf-bg);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: background 0.15s;
}

.so-contactform__submit:hover {
    background: var(--so-cf-accent-hover);
}

.so-contactform.is-sending .so-contactform__submit {
    background: var(--so-cf-accent-sending);
    cursor: progress;
}

.so-contactform__spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: so-cf-spin 0.7s linear infinite;
}

.so-contactform.is-sending .so-contactform__spinner {
    display: inline-block;
}

.so-contactform__hint {
    font-size: 12px;
    color: var(--so-cf-hint);
}

/* Désactivation pendant l'envoi */
.so-contactform.is-sending input,
.so-contactform.is-sending textarea,
.so-contactform.is-sending select,
.so-contactform.is-sending .so-contactform__chip {
    opacity: 0.6;
    pointer-events: none;
}

/* --- Écran de succès --- */
.so-contactform__success:focus {
    outline: none;
}

.so-contactform__success-inner {
    padding: 40px 0;
    text-align: center;
    animation: so-cf-rise 0.4s ease both;
}

.so-contactform__success-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 22px;
    border-radius: 50%;
    background: var(--so-cf-ok-bg);
    border: 1px solid var(--so-cf-ok-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.so-contactform__success-title {
    margin: 0 0 10px;
    font-family: "Instrument Serif", Georgia, serif;
    font-weight: 400;
    font-size: 27px;
    color: var(--so-cf-text);
}

.so-contactform__success-text {
    max-width: 40ch;
    margin: 0 auto 26px;
    font-size: 14.5px;
    line-height: 1.65;
    color: var(--so-cf-muted);
}

.so-contactform__success-text strong {
    color: var(--so-cf-text);
    font-weight: 500;
}

.so-contactform__reset {
    display: inline-block;
    padding: 11px 20px;
    background: transparent;
    border: 1px solid #cfc6b4;
    border-radius: var(--so-cf-radius);
    color: #3a352c;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.so-contactform__reset:hover {
    background: #f6f1e6;
    border-color: #b7ac96;
    color: #3a352c;
}

/* --- Éléments de mise en page --- */
.so-contactform__heading {
    margin: 0.5rem 0 0;
    font-family: "Instrument Serif", Georgia, serif;
    font-weight: 400;
    font-size: 22px;
    color: var(--so-cf-text);
}

.so-contactform__paragraph {
    margin: 0;
    color: var(--so-cf-muted);
}

/* --- Honeypot --- */
.so-contactform__hp {
    position: absolute !important;
    left: -9999px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* --- Animations --- */
@keyframes so-cf-spin { to { transform: rotate(360deg); } }
@keyframes so-cf-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes so-cf-shake {
    0%, 100% { transform: none; }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}
@keyframes so-cf-bar { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

@media (prefers-reduced-motion: reduce) {
    .so-contactform *,
    .so-contactform *::before,
    .so-contactform *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
    .so-contactform__progress span { animation: none; }
    .so-contactform__spinner { animation-duration: 0.7s !important; animation-iteration-count: infinite !important; }
}
