/* ============================================================
   Popup d'authentification — Pilote Militaire (ADR 0045, lot A)
   ------------------------------------------------------------
   Remplace la page login.html. Connexion, inscription et demande
   de réinitialisation dans une seule surface, ouverte par-dessus
   le tableau de bord.

   THEMING — rien de codé en dur ici, tout passe par --accent* :
   ces variables valent l'identité de la FILIÈRE quand body porte
   data-space (css/pm-tokens.css), et retombent sur le neutre encre
   du thème général quand il n'en porte pas. La règle « une surface
   porte l'identité de l'espace dans lequel elle s'ouvre, et le
   thème général hors de tout espace » (CONTEXT.md § Charte
   Briefing) est donc tenue par HÉRITAGE, sans une ligne de
   JavaScript de plus : la popup d'un invité qui n'a pas encore
   choisi son espace est acier, celle ouverte dans l'espace EOPAN
   est bleu marine.
   ============================================================ */

.pm-auth-dialog {
    /* `position: fixed` explicite : la feuille UA de `dialog:modal` pose déjà fixed,
       mais `position: relative` ici l'écrasait — la boîte se rendait en haut du
       document et défilait avec la page derrière le backdrop (bug mobile). `inset: 0`
       + `margin: auto` la recentre sans dépendre de la feuille UA. */
    position: fixed;
    inset: 0;
    margin: auto;
    overscroll-behavior: contain;
    border: none;
    border-radius: var(--radius-lg);
    padding: 0;
    width: 100%;
    max-width: min(440px, calc(100vw - 24px));
    background: var(--surface-card);
    color: var(--text-primary);
    box-shadow: 0 24px 60px rgba(16, 18, 22, 0.35);
    font-family: var(--font-sans);
}

/* Verrou de scroll de page pendant l'ouverture — posé dans les trois feuilles de
   dialog (règle identique, idempotente) : c'est la plus sûre, elle ne dépend pas de
   savoir laquelle des trois pages charge quoi. */
html.pm-modal-open {
    overflow: hidden;
}

.pm-auth-dialog::backdrop {
    background: rgba(20, 22, 26, 0.55);
}

.pm-auth-dialog__inner {
    padding: 26px 24px 24px;
}

.pm-auth-dialog__close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.pm-auth-dialog__close:hover {
    color: var(--text-primary);
}

.pm-auth-dialog__close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.pm-auth-dialog__kicker {
    margin: 0 0 4px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    /* Seul endroit où la filière se voit d'un coup d'œil : le candidat sait dans
       quel espace il s'apprête à entrer. */
    color: var(--accent-strong);
}

.pm-auth-dialog__title {
    margin: 0 0 6px;
    font-size: 1.25rem;
    font-weight: 650;
    line-height: 1.25;
}

.pm-auth-dialog__hint {
    margin: 0 0 18px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* ---- Onglets Connexion / Inscription ---- */

.pm-auth-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 18px;
    background: var(--surface-inset);
    border-radius: var(--radius-md);
}

.pm-auth-tab {
    flex: 1;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    padding: 9px 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 550;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.pm-auth-tab:hover {
    color: var(--text-primary);
}

.pm-auth-tab--active {
    background: var(--surface-card);
    color: var(--accent-strong);
    box-shadow: var(--shadow-sm);
}

.pm-auth-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* ---- Panneaux ---- */

.pm-auth-panel {
    display: none;
}

.pm-auth-panel--active {
    display: block;
}

.pm-auth-field {
    margin-bottom: 14px;
}

.pm-auth-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.pm-auth-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface-inset);
    color: var(--text-primary);
    font-family: inherit;
    /* 16px minimum : en dessous, iOS zoome la page au focus du champ. */
    font-size: 16px;
}

.pm-auth-field input:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.pm-auth-submit {
    width: 100%;
    min-height: 46px;
    margin-top: 4px;
    padding: 12px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent-strong);
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s;
}

.pm-auth-submit:hover:not(:disabled) {
    filter: brightness(1.08);
}

.pm-auth-submit:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.pm-auth-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

.pm-auth-submit--ghost {
    margin-top: 10px;
    background: var(--surface-card);
    border: 1px solid var(--border-strong);
    color: var(--accent-strong);
}

.pm-auth-linkbtn {
    border: none;
    background: transparent;
    padding: 0;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--accent-strong);
    text-decoration: underline;
    cursor: pointer;
}

.pm-auth-forgot {
    margin: 0 0 16px;
}

/* Mention d'acceptation des CGU et de la confidentialité, sous le bouton d'inscription
   (lot B3). Discrète mais LISIBLE : c'est le support de l'acceptation, elle ne descend
   pas sous la taille des mentions du dialog d'achat. */
.pm-auth-legal {
    margin: 12px 0 0;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-muted);
    text-align: center;
}

.pm-auth-legal a {
    color: var(--accent-strong);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ---- Messages ---- */

.pm-auth-msg {
    margin-top: 14px;
    padding: 11px 13px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    line-height: 1.5;
}

.pm-auth-msg--error {
    color: var(--status-danger);
    background: var(--status-danger-bg);
}

.pm-auth-msg--success {
    color: var(--status-success);
    background: var(--status-success-bg);
}

.pm-auth-recaptcha {
    margin: 4px 0 12px;
}

/* Le widget reCAPTCHA fait 304 px de large et ne se redimensionne pas : sur un
   écran étroit il déborderait de la popup. */
@media (max-width: 380px) {
    .pm-auth-recaptcha {
        transform: scale(0.85);
        transform-origin: 0 0;
        height: 65px;
    }
}
