/* =====================================================================
   Page de connexion — direction artistique « Le Coude » (09/10/2026)
   ---------------------------------------------------------------------
   Deux volets sur grand écran : à gauche la marque (nuit cacao, la paille
   qui se dessine puis se plie avec un ressort), à droite le formulaire sur
   crème. Sur téléphone : une seule colonne, la marque en bandeau et le
   formulaire en « feuille » qui remonte dessus.
   Règles de mouvement : on n'anime que transform / opacity (60 i/s, aucun
   recalcul de mise en page) ; tout est visible SANS JavaScript ; la classe
   `anim` (posée dans <head> seulement si l'utilisateur n'a pas demandé de
   réduire les animations) active les entrées.
   ===================================================================== */

:root {
    color-scheme: light;
    --fraise: #E6123E;
    --cassis: #A30D2C; /* rouge Lemon assombri (ex-cassis), charte du 16/10/2026 */
    --creme: #FBF6EF;
    --cacao: #1C1215;
    --nuit: #150E10;

    --fond: var(--creme);
    --surface: #FFFFFF;
    --encre: #1C1215;
    --encre-2: #4D3F42;
    --encre-3: #6A5B5E;
    --trait: #E9DED2;
    --trait-fort: #D9CBBD;
    --accent: #E6123E;
    --sur-accent: #FFFFFF;
    --accent-texte: #C8102E;
    --anneau: rgba(230, 18, 62, 0.16);
    --erreur-fond: #FDECEF;
    --erreur-trait: #F5C2CC;

    --volet: #150E10;
    --volet-encre: #FAF1E8;
    --volet-encre-2: rgba(250, 241, 232, 0.62);
    --paille: #E6123E;

    --police: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --police-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    /* Courbe iOS-like de la charte : départ franc, arrivée très douce. */
    --courbe: cubic-bezier(0.32, 0.72, 0, 1);
    --courbe-sortie: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --fond: #150E10;
        --surface: #1F1719;
        --encre: #FAF1E8;
        --encre-2: #CDBFB5;
        --encre-3: #A39389;
        --trait: #3A2E30;
        --trait-fort: #4A3B3E;
        --accent: #ED3F54;
        --sur-accent: #150E10;
        --accent-texte: #FF7088;
        --anneau: rgba(237, 63, 84, 0.22);
        --erreur-fond: rgba(237, 63, 84, 0.10);
        --erreur-trait: rgba(237, 63, 84, 0.32);
        --volet: #1C1215;
    }
}

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

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

body {
    margin: 0;
    min-height: 100%;
    min-height: 100dvh;
    font-family: var(--police);
    font-size: 16px;
    line-height: 1.5;
    color: var(--encre);
    background: var(--fond);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.mono {
    font-family: var(--police-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------------------------------------------------------------------
   Structure : deux volets ≥ 960 px, une colonne en dessous
   --------------------------------------------------------------------- */
.connexion {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 960px) {
    .connexion { grid-template-columns: minmax(440px, 0.9fr) minmax(0, 1fr); }
}

/* ---------------------------------------------------------------------
   Volet de marque
   --------------------------------------------------------------------- */
.volet {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    color: var(--volet-encre);
    background: var(--volet);
    display: flex;
    flex-direction: column;
    padding: 20px 22px 44px;
    min-height: 236px;
}

@media (min-width: 960px) and (prefers-color-scheme: dark) {
    /* En sombre, les deux volets sont proches : un filet les sépare. */
    .volet { box-shadow: inset -1px 0 0 var(--trait); }
}

@media (min-width: 960px) {
    .volet {
        padding: 40px 48px;
        min-height: 100vh;
        min-height: 100dvh;
        position: sticky;
        top: 0;
    }
}

/* Deux halos (fraise, cassis) qui dérivent très lentement : le volet « respire ».
   Dégradés radiaux statiques déplacés en transform → coût quasi nul. */
.halo {
    position: absolute;
    z-index: -1;
    border-radius: 50%;
    pointer-events: none;
    will-change: transform;
}

.halo-fraise {
    width: 120%;
    aspect-ratio: 1;
    right: -55%;
    bottom: -60%;
    background: radial-gradient(closest-side, rgba(230, 18, 62, 0.42), rgba(230, 18, 62, 0.10) 55%, transparent);
}

.halo-cassis {
    width: 90%;
    aspect-ratio: 1;
    left: -40%;
    top: -45%;
    background: radial-gradient(closest-side, rgba(123, 30, 58, 0.55), rgba(123, 30, 58, 0.12) 60%, transparent);
}

.anim .halo-fraise { animation: derive-a 22s ease-in-out infinite alternate; }
.anim .halo-cassis { animation: derive-b 26s ease-in-out infinite alternate; }

@keyframes derive-a {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(-8%, -6%, 0) scale(1.08); }
}

@keyframes derive-b {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(10%, 8%, 0) scale(0.94); }
}

/* Largeurs recalculées le 14/10/2026 quand la pastille « web » est partie :
   les lettres gardent exactement la même taille qu'avant (116 et 138 px pour
   l'ancien logo de 407,77 unités de large → 79 et 94 px pour 279,05). */
.volet-logo {
    display: block;
    width: 79px;
    height: auto;
    position: relative;
    z-index: 1;
}

@media (min-width: 960px) {
    .volet-logo { width: 94px; }
}

.devise {
    position: relative;
    z-index: 1;
    margin: auto 0 0;
    max-width: 58%;
    font-weight: 800;
    font-size: 26px;
    line-height: 0.98;
    letter-spacing: -0.045em;
    color: var(--volet-encre);
    text-wrap: balance;
}

@media (min-width: 960px) {
    .devise {
        margin: clamp(56px, 13vh, 140px) 0 0;
        max-width: 11ch;
        font-size: clamp(44px, 4.3vw, 68px);
    }
}

.devise em {
    font-style: normal;
    color: var(--paille);
}

.volet-pied {
    display: none;
}

@media (min-width: 960px) {
    .volet-pied {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-top: auto;
        position: relative;
        z-index: 1;
        color: var(--volet-encre-2);
    }
    .volet-pied {
        align-self: flex-start;
        text-decoration: none;
        border-radius: var(--radius-md, 8px);
        transition: color 220ms cubic-bezier(0.32, 0.72, 0, 1);
    }
    .volet-pied:hover { color: var(--volet-encre, #FAF1E8); }
    .volet-pied:focus-visible { outline: 2px solid var(--paille); outline-offset: 4px; }
    /* Le logo LSB est sombre : on le passe en blanc pour qu'il se lise sur le volet nuit */
    .volet-pied .lsb {
        width: 28px; height: 28px;
        filter: brightness(0) invert(1);
        opacity: .85;
        transition: transform 420ms cubic-bezier(0.32, 0.72, 0, 1), opacity 220ms;
    }
    .volet-pied:hover .lsb { opacity: 1; transform: rotate(-8deg) scale(1.08); }
}

/* La paille : sort du bas du volet, monte, puis se plie au coude. */
.paille {
    position: absolute;
    z-index: 0;
    bottom: -1px;
    right: 6px;
    width: 172px;
    height: 172px;
    overflow: visible;
    pointer-events: none;
}

@media (min-width: 960px) {
    .paille {
        right: auto;
        left: 60%;
        width: clamp(280px, 30vw, 440px);
        height: clamp(280px, 30vw, 440px);
        transform: translateX(-38.5%);
    }
}

.paille-trait {
    fill: none;
    stroke: var(--paille);
    stroke-width: 14.5;
    stroke-linejoin: round;
}

/* Le trait est tracé du bas vers le haut (pathLength="1" : 0 → 1, cf login.js). */
/* Masquée dès le premier rendu (pas d'éclair de la paille finale avant que le
   script ne la redresse). `pret` = login.js a pris la main. Si le script ne
   charge pas, la paille se trace seule, déjà pliée, au bout de 2,5 s. */
.anim .paille-trait {
    stroke-dasharray: 1 1;
    stroke-dashoffset: 1;
}

.anim .paille:not(.pret) .paille-trait {
    animation: paille-secours 1100ms var(--courbe) 2.5s forwards;
}

@keyframes paille-secours { to { stroke-dashoffset: 0; } }

/* ---------------------------------------------------------------------
   Côté formulaire
   --------------------------------------------------------------------- */
.cote {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    background: var(--fond);
    /* Sur téléphone : la feuille remonte sur le bandeau, coins arrondis. */
    margin-top: -24px;
    border-radius: 28px 28px 0 0;
    padding: 34px 22px 22px;
}

@media (min-width: 960px) {
    .cote {
        margin-top: 0;
        border-radius: 0;
        padding: 40px 48px 32px;
    }
}

.carte {
    width: 100%;
    max-width: 392px;
    margin: 0 auto;
}

@media (min-width: 960px) {
    .carte { margin: auto; }
}

.surtitre {
    margin: 0 0 14px;
    color: var(--accent-texte);
}

h1 {
    margin: 0;
    font-size: 40px;
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.045em;
    color: var(--encre);
}

@media (min-width: 960px) {
    h1 { font-size: 52px; }
}

.chapo {
    margin: 12px 0 30px;
    font-size: 15.5px;
    line-height: 1.5;
    color: var(--encre-3);
}

/* Entrées échelonnées : chaque bloc arrive en fondu + léger glissé. */
.anim .entree {
    animation: entree 720ms var(--courbe) both;
    animation-delay: calc(var(--i, 0) * 60ms + 120ms);
}

@keyframes entree {
    from { opacity: 0; transform: translate3d(0, 14px, 0); }
    to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------------
   Erreur serveur (« Identifiants incorrects. »)
   --------------------------------------------------------------------- */
.erreur {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 22px;
    padding: 12px 14px;
    border-radius: var(--radius-carte, 12px);
    border: 1px solid var(--erreur-trait);
    background: var(--erreur-fond);
    color: var(--accent-texte);
    font-size: 14.5px;
    font-weight: 500;
    line-height: 1.4;
}

.erreur svg { flex: none; margin-top: 1px; }

.anim .erreur { animation: erreur-entree 520ms var(--courbe) both; }

@keyframes erreur-entree {
    from { opacity: 0; transform: translate3d(0, -6px, 0) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

/* Secousse amortie : trois allers-retours de plus en plus courts, comme un
   ressort qui se calme — un « non » poli, pas une alarme. */
.secousse { animation: secousse 560ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }

@keyframes secousse {
    0%   { transform: translate3d(0, 0, 0); }
    14%  { transform: translate3d(-9px, 0, 0); }
    30%  { transform: translate3d(7px, 0, 0); }
    46%  { transform: translate3d(-4.5px, 0, 0); }
    62%  { transform: translate3d(2.5px, 0, 0); }
    78%  { transform: translate3d(-1px, 0, 0); }
    100% { transform: translate3d(0, 0, 0); }
}

/* ---------------------------------------------------------------------
   Champs
   --------------------------------------------------------------------- */
.champ {
    position: relative;
    margin-bottom: 30px;
}

.champ label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--encre-2);
}

.saisie { position: relative; }

.saisie input {
    display: block;
    width: 100%;
    height: 54px;
    padding: 0 16px;
    font: inherit;
    font-size: 16px; /* ≥ 16 px : iOS ne zoome pas à la saisie */
    color: var(--encre);
    background: var(--surface);
    border: 1px solid var(--trait-fort);
    border-radius: var(--radius-carte, 12px);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 0 0 0 transparent, 0 1px 2px rgba(28, 18, 21, 0.04);
    transition:
        border-color 180ms var(--courbe),
        box-shadow 260ms var(--courbe),
        background-color 180ms var(--courbe);
}

.saisie input::placeholder { color: var(--encre-3); opacity: 0.7; }

.saisie input:hover { border-color: var(--encre-3); }

.saisie input:focus-visible,
.saisie input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--anneau), 0 1px 2px rgba(28, 18, 21, 0.04);
}

.saisie input[aria-invalid="true"] { border-color: var(--accent); }

.saisie-mdp input { padding-right: 56px; }

/* Remplissage automatique du navigateur : on garde nos couleurs. */
.saisie input:-webkit-autofill,
.saisie input:-webkit-autofill:hover,
.saisie input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--encre);
    caret-color: var(--encre);
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
    transition: background-color 9999s;
}

/* Bouton œil : zone de 44 px pour le doigt, icône 20 px. */
.oeil {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: var(--radius-champ, 10px);
    background: transparent;
    color: var(--encre-3);
    cursor: pointer;
    transition: color 160ms var(--courbe), background-color 160ms var(--courbe), transform 160ms var(--courbe);
}

.oeil:hover { color: var(--encre); background: color-mix(in srgb, var(--encre) 6%, transparent); }
.oeil:active { transform: scale(0.92); }

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

/* La barre de l'œil barré se trace / s'efface au lieu de clignoter. */
.oeil .barre {
    stroke-dasharray: 1 1;
    stroke-dashoffset: 1;
    transition: stroke-dashoffset 280ms var(--courbe);
}

.oeil[aria-pressed="true"] .barre { stroke-dashoffset: 0; }

/* Aide sous le champ (majuscules activées, champ vide) : posée dans la marge
   du champ, en absolu → son apparition ne pousse jamais le reste. */
.aide {
    position: absolute;
    left: 2px;
    top: calc(100% + 6px);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 16px;
    color: var(--encre-3);
    opacity: 0;
    transform: translate3d(0, -3px, 0);
    transition: opacity 200ms var(--courbe), transform 260ms var(--courbe);
    pointer-events: none;
}

.aide.visible { opacity: 1; transform: none; }
.aide.alerte { color: var(--accent-texte); }

/* ---------------------------------------------------------------------
   « Rester connecté »
   --------------------------------------------------------------------- */
.rester {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: -4px 0 26px;
    min-height: 32px;
    font-size: 14.5px;
    color: var(--encre-2);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.rester input {
    flex: none;
    position: relative;
    width: 20px;
    height: 20px;
    margin: 0;
    border: 1.5px solid var(--trait-fort);
    border-radius: var(--radius-md, 8px);
    background: var(--surface);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: background-color 180ms var(--courbe), border-color 180ms var(--courbe), transform 160ms var(--courbe);
}

.rester input:active { transform: scale(0.9); }

.rester input::after {
    content: '';
    position: absolute;
    left: 5.5px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid var(--sur-accent);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0.4);
    opacity: 0;
    transition: transform 280ms var(--courbe), opacity 160ms var(--courbe);
}

.rester input:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.rester input:checked::after { opacity: 1; transform: rotate(45deg) scale(1); }

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

/* ---------------------------------------------------------------------
   Bouton pilule fraise
   --------------------------------------------------------------------- */
.bouton {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 54px;
    padding: 0 24px;
    overflow: hidden;
    border: 0;
    border-radius: var(--radius-full, 9999px);
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.005em;
    color: var(--sur-accent);
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 10px 24px -12px rgba(230, 18, 62, 0.7);
    transition: transform 260ms var(--courbe), box-shadow 260ms var(--courbe), filter 200ms var(--courbe);
    -webkit-tap-highlight-color: transparent;
}

.bouton:hover {
    transform: translate3d(0, -1px, 0);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 16px 30px -14px rgba(230, 18, 62, 0.8);
    filter: saturate(1.08);
}

.bouton:active { transform: scale(0.985); transition-duration: 90ms; }

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

.bouton-contenu,
.bouton-charge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: transform 420ms var(--courbe), opacity 240ms var(--courbe);
}

.bouton-contenu svg { transition: transform 320ms var(--courbe); }
.bouton:hover .bouton-contenu svg { transform: translate3d(3px, 0, 0); }

.bouton-charge {
    position: absolute;
    inset: 0;
    justify-content: center;
    opacity: 0;
    transform: translate3d(0, 110%, 0);
}

.bouton-charge svg { overflow: visible; }

.bouton-charge path {
    fill: none;
    stroke: currentColor;
    stroke-width: 16;
    stroke-linejoin: round;
}

.bouton.charge { cursor: progress; }
.bouton.charge .bouton-contenu { opacity: 0; transform: translate3d(0, -110%, 0); }
.bouton.charge .bouton-charge  { opacity: 1; transform: none; }

/* ---------------------------------------------------------------------
   Lien discret vers l'autre accès (connexion ↔ démo libre)
   --------------------------------------------------------------------- */
.autre-acces {
    margin: 22px 0 0;
    text-align: center;
    font-size: 14px;
    color: var(--encre-3);
}

.autre-acces a {
    color: var(--accent-texte);
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--radius-md, 8px);
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 0% 1.5px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 320ms var(--courbe);
}

.autre-acces a:hover { background-size: 100% 1.5px; }
.autre-acces a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------------------------------------------------------------------
   Pied de page
   --------------------------------------------------------------------- */
.pied {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    max-width: 392px;
    width: 100%;
    margin: 36px auto 0;
    padding-top: 18px;
    border-top: 1px solid var(--trait);
    color: var(--encre-3);
}

@media (min-width: 960px) {
    .pied { max-width: none; margin: 0; border-top: 0; padding-top: 0; }
}

/* ---------------------------------------------------------------------
   Réduction des animations : tout est posé, rien ne bouge.
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
    }
}

/* La secousse attend que les champs soient arrivés (entrées échelonnées). */
.anim .secousse { animation-delay: 420ms; }
