/* Connexion (M005) : carte vitrée NEX6, saisie TOTP en six cases, chorégraphie de vérification inspirée de la référence « Glassy OTP ».
   Fond opaque de secours via les variables --glass-* (app.css). */
.lg { position: relative; width: min(440px, 100%); padding: 36px 34px 30px; border-radius: 24px; text-align: center; isolation: isolate;
  --w: clamp(38px, 11.5vw, 48px); --gap: 9px; --pitch: calc(var(--w) + var(--gap)); --R: calc(var(--w) * 1.3);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.1); }
/* Bord lumineux fin : dégradé cyan → violet, visible seulement sur le contour. */
.lg::before { content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.6), rgba(255, 255, 255, 0) 38%, rgba(123, 97, 255, 0.6));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; }
/* Plaques vitrées qui dépassent aux coins opposés de la carte (décor, derrière la carte). */
.lg-shard { position: absolute; z-index: -1; width: 62px; height: 62px; border-radius: 16px; pointer-events: none;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); }
.lg-shard.tl { top: -14px; left: -14px; } .lg-shard.br { bottom: -14px; right: -14px; }
.lg-step { animation: lg-in 0.28s var(--ease) both; }
.lg-logo { height: 52px; margin-bottom: 16px; filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.3)); }
.lg-logo.sm { height: 30px; margin-bottom: 14px; }
.lg h1 { font-size: clamp(1.3rem, 4.5vw, 1.65rem); }
.acc { color: var(--neon-cyan); } .acc-ok { color: var(--st-ok); }
.lg-lead { color: var(--text-secondary); font-size: 0.92rem; line-height: 1.5; margin: 10px 0 4px; }
.lg label { text-align: left; margin-top: 18px; }
.lg input:not([type=checkbox]) { margin-bottom: 4px; }
.lg .btn-primary { width: 100%; justify-content: center; margin-top: 18px; transition: background 0.3s var(--ease), opacity 0.2s; }
.lg .alert { margin: 14px 0 0; text-align: left; }
.lg-extra { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Badge : la clé devient un bouclier vert quand l'accès est vérifié. */
.lg-badge { width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 14px; display: grid; place-items: center; color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.07); border: 1px solid rgba(0, 240, 255, 0.35); transition: color 0.3s var(--ease), background 0.3s var(--ease), border-color 0.3s var(--ease); }
.lg-badge svg, .b-ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lg-badge .i-ok { display: none; }
.lg[data-state=ok] .lg-badge { color: var(--st-ok); background: rgba(74, 222, 128, 0.08); border-color: rgba(74, 222, 128, 0.45); }
.lg[data-state=ok] .lg-badge .i-key { display: none; } .lg[data-state=ok] .lg-badge .i-ok { display: block; }

/* Six cases visuelles ; le champ réel les recouvre (transparent) : clavier, collage et gestionnaires de codes fonctionnent. */
.otp { position: relative; display: flex; justify-content: center; align-items: center; height: 58px; margin: 22px 0 6px; transition: height 0.4s var(--ease); }
.otp-cells { position: relative; display: flex; gap: var(--gap); }
.otp-cell { width: var(--w); height: 58px; flex: none; display: grid; place-items: center; border-radius: 12px; background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border); font: 600 1.5rem var(--font-mono); color: var(--text-primary);
  transition: transform 0.5s var(--ease), opacity 0.35s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease); }
.otp-cell.full { border-color: rgba(0, 240, 255, 0.35); background: rgba(0, 240, 255, 0.05); }
.otp[data-focus] .otp-cell.on { border-color: var(--neon-cyan); box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.18), 0 0 18px rgba(0, 240, 255, 0.25); }
.lg input.otp-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; background: transparent; opacity: 0; font-size: 16px; cursor: text; }
/* Mode « code de secours » : un champ texte ordinaire à la place des cases. */
.lg[data-mode=recovery] .otp-cell { display: none; }
.lg[data-mode=recovery] input.otp-input { position: static; opacity: 1; height: auto; padding: 13px 14px; background: var(--bg-1); border: 1px solid var(--border-soft);
  text-align: center; letter-spacing: 0.14em; font-family: var(--font-mono); }
.lg[data-mode=recovery] input.otp-input:focus { border-color: var(--neon-cyan); box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.15); }

/* Vérification : les cases quittent la rangée, se rassemblent en hexagone (petits losanges) et tournent pendant la requête. */
.lg[data-state=busy] .otp, .lg[data-state=ok] .otp { height: 150px; }
.lg[data-state=busy] input.otp-input, .lg[data-state=ok] input.otp-input { pointer-events: none; }
.lg[data-state=busy] .otp-cell, .lg[data-state=ok] .otp-cell {
  --ang: calc(var(--i) * 60deg - 90deg); border-color: var(--neon-cyan); background: rgba(0, 240, 255, 0.07);
  transform: translate(calc(cos(var(--ang)) * var(--R) - (var(--i) - 2.5) * var(--pitch)), calc(sin(var(--ang)) * var(--R))) rotate(45deg) scale(0.78); }
.lg[data-state=busy] .otp-cells, .lg[data-state=ok] .otp-cells { animation: lg-orbit 1.3s cubic-bezier(0.55, 0, 0.35, 1) infinite; }
.lg[data-state=ok] .otp-cells { animation-play-state: paused; }
/* Succès : les cases fusionnent au centre (et s'effacent) ; un carré vert apparaît et la coche se trace. */
.lg[data-state=ok] .otp-cell { transform: translate(calc((2.5 - var(--i)) * var(--pitch)), 0) rotate(135deg) scale(0.15); opacity: 0; transition-duration: 0.45s; }
.ok-box { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 16px; display: grid; place-items: center; pointer-events: none;
  border: 2px solid var(--st-ok); background: rgba(74, 222, 128, 0.08); opacity: 0; transform: scale(0.4); }
.lg[data-state=ok] .ok-box { opacity: 1; transform: none; transition: opacity 0.3s 0.3s var(--ease), transform 0.45s 0.3s cubic-bezier(0.2, 1.4, 0.4, 1); animation: lg-glow 0.9s 0.5s ease-out both; }
.ok-svg { width: 34px; height: 34px; }
.ok-check { fill: none; stroke: var(--st-ok); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; }
.lg[data-state=ok] .ok-check { animation: lg-draw 0.35s 0.65s var(--ease) forwards; }

/* Bouton : « Vérifier le code » → indicateur « Vérification en cours » → vert « Accès vérifié ». */
.btn-primary .b-busy, .btn-primary .b-ok { display: none; }
.lg[data-state=busy] .b-idle, .lg[data-state=ok] .b-idle { display: none; }
.lg[data-state=busy] .b-busy, .lg[data-state=ok] .b-ok { display: inline-flex; align-items: center; gap: 8px; }
.lg[data-state=busy] .btn-primary { opacity: 0.85; cursor: progress; }
.lg[data-state=ok] .btn-primary { opacity: 1; background: linear-gradient(135deg, #34d399, #22c55e); color: #04140c; box-shadow: 0 0 24px rgba(74, 222, 128, 0.3); }
.b-ico { width: 18px; height: 18px; }
.spin { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: lg-spin 0.8s linear infinite; }

@keyframes lg-orbit { to { transform: rotate(360deg); } }
@keyframes lg-spin { to { transform: rotate(360deg); } }
@keyframes lg-draw { to { stroke-dashoffset: 0; } }
@keyframes lg-glow { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); } 100% { box-shadow: 0 0 0 30px rgba(74, 222, 128, 0); } }
@keyframes lg-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }

/* Codes de secours. */
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 18px 0 14px; padding: 14px; list-style: none; border-radius: 12px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--glass-border); font: 600 0.98rem var(--font-mono); letter-spacing: 0.04em; user-select: all; }
.lg-check { display: flex; gap: 8px; align-items: center; font-weight: 500; margin-top: 16px; cursor: pointer; }
.lg-check input { width: auto; margin: 0; }

@media (max-width: 480px) { .lg { padding: 28px 20px 24px; --gap: 7px; } .lg-shard { width: 46px; height: 46px; } }
/* Animations réduites : changements d'état instantanés (ni rotation, ni fusion, ni impulsion, ni tracé animé, ni indicateur tournant). */
@media (prefers-reduced-motion: reduce) {
  .lg-step, .lg[data-state=busy] .otp-cells, .lg[data-state=ok] .otp-cells, .lg[data-state=ok] .ok-box, .spin { animation: none; }
  .lg[data-state=ok] .ok-check { animation: none; stroke-dashoffset: 0; }
  .otp, .otp-cell, .lg[data-state=ok] .ok-box, .lg .btn-primary, .lg-badge { transition: none; }
}
