/**
 * Newsletter GRIM — formulaires d'inscription et page de désinscription.
 *
 * La couleur d'accent vient de la marque active via --grim-nl-accent,
 * posée en style inline sur le conteneur.
 */

/* Les jetons reprennent ceux du thème : rayon de 0.375rem et graisse 500, comme
   le bloc « bouton personnalisé ». Les couleurs de titre et de texte sont
   injectées par PHP depuis Paramètres du thème, l'accent depuis la marque.
   Déclarés aussi sur .grim-nl-overlay : les éléments automatiques vivent hors
   du conteneur .grim-nl, et sans cela leur bouton n'aurait aucun fond. */
.grim-nl,
.grim-nl-overlay {
    --grim-nl-accent: #6646ff;
    --grim-nl-radius: 0.375rem;
    --grim-nl-border: #e2e4e9;
    --grim-nl-text: #1a202c;
    --grim-nl-muted: #6b7280;
    font-family: inherit;
}

.grim-nl { width: 100%; }

.grim-nl__title {
    margin: 0 0 8px;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--grim-nl-title, var(--grim-nl-text));
}

.grim-nl__desc {
    margin: 0 0 16px;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--grim-nl-body, var(--grim-nl-muted));
}

/* ─── Champs ─────────────────────────────────────────────────────────────── */

.grim-nl__fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* Les champs se placent côte à côte tant qu'il reste de la place, puis
   passent à la ligne — plutôt qu'un champ par ligne, qui étirait le
   formulaire du pied de page sur trois rangées. */
.grim-nl__field {
    flex: 1 1 180px;
    min-width: 0;
}

.grim-nl__field--small {
    flex: 0 1 140px;
}

.grim-nl__input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: inherit;   /* sinon le navigateur impose sa police système */
    font-size: 0.9375rem;
    line-height: 1.4;
    color: var(--grim-nl-text);
    background: #fff;
    border: 1px solid var(--grim-nl-border);
    border-radius: var(--grim-nl-radius);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
}

.grim-nl__input::placeholder {
    color: #9ca3af;
}

.grim-nl__input:focus {
    outline: none;
    border-color: var(--grim-nl-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--grim-nl-accent) 18%, transparent);
}

/* ─── Bouton ─────────────────────────────────────────────────────────────── */

/* Reprend la géométrie du bloc « bouton personnalisé » du thème :
   0.75rem 1.5rem, graisse 500, rayon 0.375rem, bordure de 2px transparente. */
.grim-nl__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.75rem 1.5rem;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--grim-nl-on-accent, #fff);
    background: var(--grim-nl-accent);
    border: 2px solid transparent;
    border-radius: var(--grim-nl-radius);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.grim-nl__submit:hover:not(:disabled) {
    filter: brightness(1.12);
}

.grim-nl__submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.grim-nl.is-loading .grim-nl__spinner,
.is-loading > .grim-nl__spinner,
.grim-nl__form.is-loading .grim-nl__spinner,
.grim-nl-unsub.is-loading .grim-nl__spinner {
    display: inline-block;
}

@keyframes grim-nl-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .grim-nl__spinner {
        animation: none;
    }
}

/* ─── Consentements ──────────────────────────────────────────────────────── */

.grim-nl__consents {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.grim-nl__consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--grim-nl-muted);
    cursor: pointer;
}

.grim-nl__consent input[type="checkbox"] {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    margin-top: 2px;
    accent-color: var(--grim-nl-accent);
    cursor: pointer;
}

.grim-nl__privacy {
    font-size: 0.75rem;
    color: var(--grim-nl-accent);
    text-decoration: underline;
}

/* ─── Messages ───────────────────────────────────────────────────────────── */

.grim-nl__message {
    margin: 10px 0 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    min-height: 1em;
}

.grim-nl__message.is-success {
    color: #15803d;
}

.grim-nl__message.is-error {
    color: #b91c1c;
}

/* Piège à robots : hors écran, jamais masqué par display:none (certains bots le détectent). */
.grim-nl__trap {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.grim-nl__admin-notice {
    padding: 12px 16px;
    font-size: 0.8125rem;
    color: #92400e;
    background: #fef3c7;
    border: 1px dashed #f59e0b;
    border-radius: 6px;
}

/* ─── Variante « en ligne » ──────────────────────────────────────────────── */

.grim-nl--inline .grim-nl__field--email {
    flex: 1 1 200px;
}

.grim-nl--inline .grim-nl__submit {
    flex: 0 0 auto;
}

/* ─── Variante « empilée » ───────────────────────────────────────────────── */

.grim-nl--stacked .grim-nl__fields {
    flex-direction: column;
    align-items: stretch;
}

.grim-nl--stacked .grim-nl__field,
.grim-nl--stacked .grim-nl__field--small {
    flex: 1 1 auto;
}

.grim-nl--stacked .grim-nl__submit {
    width: 100%;
}

/* ─── Variante « carte » ─────────────────────────────────────────────────── */

.grim-nl--card {
    padding: 28px;
    background: #fff;
    border: 1px solid var(--grim-nl-border);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.grim-nl--card .grim-nl__fields {
    flex-direction: column;
    align-items: stretch;
}

.grim-nl--card .grim-nl__submit {
    width: 100%;
    margin-top: 4px;
}

/* ─── Pied de page ───────────────────────────────────────────────────────── */
/* Ici et non dans newsletter-overlay.css : cette feuille-là n'est chargée que
   si un élément interruptif est actif, et le formulaire du pied de page
   s'étirait alors sur toute la largeur sur les sites sans overlay. */

.grim-nl-footer {
    padding-bottom: 26px;
    margin-bottom: 26px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.22);
}

.grim-nl-footer .grim-nl {
    max-width: 640px;
}

@media (max-width: 640px) {
    .grim-nl__fields {
        flex-direction: column;
        align-items: stretch;
    }

    .grim-nl__field--small {
        flex: 1 1 auto;
    }

    .grim-nl__submit {
        width: 100%;
    }
}

/* ─── Page de désinscription ─────────────────────────────────────────────── */

.grim-nl-page {
    padding: 64px 20px;
}

.grim-nl-page__inner {
    max-width: 620px;
    margin: 0 auto;
}

.grim-nl-page__title {
    margin: 0 0 12px;
    font-size: 1.875rem;
    font-weight: 700;
}

.grim-nl-page__intro {
    margin: 0 0 28px;
    color: #4b5563;
    line-height: 1.6;
}

.grim-nl-unsub__field {
    margin-bottom: 20px;
}

.grim-nl-unsub__field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 600;
}

.grim-nl-unsub__field input {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.9375rem;
    border: 1px solid #e2e4e9;
    border-radius: 8px;
}

.grim-nl-unsub__field input[readonly] {
    background: #f3f4f6;
    color: #4b5563;
}

.grim-nl-unsub__channels {
    margin: 0 0 24px;
    padding: 16px 18px;
    border: 1px solid #e2e4e9;
    border-radius: 10px;
}

.grim-nl-unsub__channels legend {
    padding: 0 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #4b5563;
}

.grim-nl-unsub__channel {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 0.9375rem;
    cursor: pointer;
}

.grim-nl-unsub__partial {
    margin-top: 8px;
    padding-left: 26px;
    border-left: 2px solid #e2e4e9;
}

.grim-nl-unsub__submit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 28px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #fff;
    background: #1a202c;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.grim-nl-unsub__submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.grim-nl-erase {
    margin-top: 48px;
    padding-top: 28px;
    border-top: 1px solid #e2e4e9;
}

.grim-nl-erase__title {
    margin: 0 0 10px;
    font-size: 1.0625rem;
    font-weight: 700;
}

.grim-nl-erase__text {
    margin: 0 0 16px;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #6b7280;
}

.grim-nl-erase__confirm {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 0.8125rem;
    color: #4b5563;
    cursor: pointer;
}

.grim-nl-erase__submit {
    padding: 11px 22px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #b91c1c;
    background: #fff;
    border: 1px solid #b91c1c;
    border-radius: 8px;
    cursor: pointer;
}

.grim-nl-erase__submit:hover {
    color: #fff;
    background: #b91c1c;
}

.grim-nl-page__privacy {
    margin-top: 32px;
    font-size: 0.8125rem;
}
