/* ==========================================================================
   PAGE DE CONNEXION ÉLÈVE — EFFETS TECHNOLOGIQUES
   - Fond "circuit imprimé" animé (courant qui circule dans les pistes)
   - Carte métallique vissée (4 vis dans les coins) + engrenage autour de l'icône
   - Champ identifiant : étincelles + arcs électriques pendant la saisie
   - Mot de passe : chaque caractère devient un composant (lampe, pile, transistor,
     résistance, LED, condensateur) reliés par un fil où circule le courant
   - Jauge "tension du circuit" = force du mot de passe (0 V → 9 V)
   - Bouton "Se connecter" en forme d'écrou, case "Rester connecté" = interrupteur
   Tout est limité à .login-section.tech-login (n'affecte pas le reste du site)
   ========================================================================== */

/* ---------- 1. Fond circuit imprimé ---------- */
.login-section.tech-login {
    position: relative;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 40%, #12305a 0%, #0b1a33 55%, #060d1c 100%) !important;
}

.tech-circuit-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.login-section.tech-login .login-container {
    position: relative;
    z-index: 2;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 3px solid #94a3b8;
    box-shadow:
        0 0 0 1px #e2e8f0 inset,
        0 0 0 6px rgba(148, 163, 184, 0.25),
        0 25px 50px -12px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(56, 189, 248, 0.25);
}

/* Vis métalliques dans les 4 coins de la carte */
.tech-screw {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #f8fafc 0%, #cbd5e1 40%, #64748b 100%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 -1px 1px rgba(0, 0, 0, 0.25);
    z-index: 3;
    pointer-events: none;
}
.tech-screw::before {
    content: '';
    position: absolute;
    left: 3px;
    right: 3px;
    top: 50%;
    height: 2px;
    margin-top: -1px;
    background: #475569;
    border-radius: 1px;
    transform: rotate(var(--screw-rot, 35deg));
}
.tech-screw.tl { top: 10px; left: 10px; --screw-rot: 35deg; }
.tech-screw.tr { top: 10px; right: 10px; --screw-rot: -20deg; }
.tech-screw.bl { bottom: 10px; left: 10px; --screw-rot: 80deg; }
.tech-screw.br { bottom: 10px; right: 10px; --screw-rot: 10deg; }

/* ---------- 2. Icône entourée d'un engrenage qui tourne ---------- */
.login-section.tech-login .login-icon {
    position: relative;
    background: linear-gradient(135deg, #0ea5e9, #6366f1) !important;
    box-shadow: 0 0 0 4px #fff, 0 0 22px rgba(14, 165, 233, 0.55);
}
.tech-gear-ring {
    position: absolute;
    inset: -18px;
    pointer-events: none;
    animation: techGearSpin 14s linear infinite;
}
.tech-gear-ring svg { width: 100%; height: 100%; display: block; }
@keyframes techGearSpin { to { transform: rotate(360deg); } }

.login-section.tech-login .login-icon.tech-zap {
    animation: techIconZap 0.35s ease;
}
@keyframes techIconZap {
    0%, 100% { box-shadow: 0 0 0 4px #fff, 0 0 22px rgba(14, 165, 233, 0.55); }
    50%      { box-shadow: 0 0 0 4px #fef08a, 0 0 40px rgba(250, 204, 21, 0.95); }
}

/* ---------- 3. Champs de saisie "sous tension" ---------- */
.login-section.tech-login .login-form .form-group {
    position: relative;
}

.login-section.tech-login .login-form input:not([type="checkbox"]) {
    background: #ffffff;
    border-color: #cbd5e1;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.login-section.tech-login .login-form input:not([type="checkbox"]):focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
}

/* Champ "chargé" : bordure électrique qui crépite */
.login-section.tech-login .form-group.tech-charged input:not([type="checkbox"]) {
    border-color: #facc15 !important;
    box-shadow:
        0 0 0 3px rgba(250, 204, 21, 0.28),
        0 0 16px rgba(56, 189, 248, 0.55) !important;
}

/* Calque des étincelles et des arcs électriques */
.tech-spark-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 6;
}
.tech-spark {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #fef9c3;
    box-shadow: 0 0 6px 2px #facc15, 0 0 12px 3px #38bdf8;
    animation: techSparkFly 0.45s ease-out forwards;
}
@keyframes techSparkFly {
    from { transform: translate(0, 0) scale(1); opacity: 1; }
    to   { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}
.tech-bolt {
    position: absolute;
    left: 0;
    width: 100%;
    height: 22px;
    overflow: visible;
    animation: techBoltFlash 0.28s steps(3) forwards;
}
.tech-bolt path {
    fill: none;
    stroke: #e0f2fe;
    stroke-width: 2;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 3px #38bdf8) drop-shadow(0 0 6px #facc15);
}
@keyframes techBoltFlash {
    0%   { opacity: 1; }
    50%  { opacity: 0.3; }
    70%  { opacity: 1; }
    100% { opacity: 0; }
}

/* ---------- 4. Mot de passe : composants électroniques ---------- */
.login-section.tech-login .form-group.tech-pw-masked input#password {
    color: transparent !important;
    caret-color: transparent !important;
    -webkit-text-fill-color: transparent;
}
.login-section.tech-login .form-group.tech-pw-masked input#password::selection {
    background: transparent;
}

.tech-pw-components {
    position: absolute;
    left: 22px;
    right: 52px;
    top: 0;
    height: 54px;
    display: flex;
    align-items: center;
    gap: 3px;
    overflow: hidden;
    pointer-events: none;
    z-index: 4;
}
.form-group:not(.tech-pw-masked) .tech-pw-components { display: none; }

/* Fil électrique qui relie les composants */
.tech-pw-wire {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    margin-top: -1px;
    background: #94a3b8;
    border-radius: 1px;
    z-index: 0;
    transform-origin: left center;
    transform: scaleX(var(--wire, 0));
    transition: transform 0.2s ease;
}
.tech-pw-wire::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 0;
    width: 18px;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, #facc15, #fff, transparent);
    animation: techCurrent 1.1s linear infinite;
}
@keyframes techCurrent {
    from { left: -18px; }
    to   { left: 100%; }
}

.tech-comp {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    width: 22px;
    height: 26px;
    animation: techCompPop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tech-comp svg { width: 100%; height: 100%; display: block; }
@keyframes techCompPop {
    0%   { transform: translateY(-14px) scale(0.3) rotate(-25deg); opacity: 0; }
    100% { transform: none; opacity: 1; }
}

/* Lampe et LED qui s'allument */
.tech-comp .glow {
    animation: techGlow 1.6s ease-in-out infinite alternate;
}
@keyframes techGlow {
    from { opacity: 0.55; }
    to   { opacity: 1; }
}

/* Curseur personnalisé (le curseur natif est masqué) */
.tech-pw-caret {
    flex: 0 0 auto;
    width: 2px;
    height: 22px;
    background: #0ea5e9;
    border-radius: 1px;
    z-index: 1;
    opacity: 0;
}
.form-group.tech-pw-focus .tech-pw-caret {
    animation: techCaretBlink 1s steps(1) infinite;
}
@keyframes techCaretBlink {
    0%, 49%  { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* Jauge "tension du circuit" (force du mot de passe) */
.tech-voltmeter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: -14px;
    margin-bottom: 20px;
    font-size: 0.74rem;
    font-weight: 600;
    color: #64748b;
}
.tech-voltmeter-bar {
    position: relative;
    flex: 1;
    height: 10px;
    border: 2px solid #475569;
    border-radius: 3px;
    background: #e2e8f0;
    overflow: hidden;
}
.tech-voltmeter-bar::after {
    /* borne + de la pile */
    content: '';
    position: absolute;
    right: -6px;
    top: 1px;
    width: 4px;
    height: 4px;
}
.tech-voltmeter-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e);
    background-size: 300px 100%;
    transition: width 0.3s ease;
}
.tech-voltmeter-val {
    min-width: 54px;
    text-align: right;
    font-family: 'Courier New', monospace;
    color: #0f172a;
}

/* ---------- 5. Bouton "Se connecter" en forme d'écrou ---------- */
.login-section.tech-login .login-form button[type="submit"].tech-nut-btn {
    position: relative;
    border: none;
    border-radius: 0 !important;
    min-height: 56px;
    clip-path: polygon(22px 0, calc(100% - 22px) 0, 100% 50%, calc(100% - 22px) 100%, 22px 100%, 0 50%);
    background: linear-gradient(180deg, #f1f5f9 0%, #cbd5e1 35%, #94a3b8 52%, #cbd5e1 70%, #e2e8f0 100%) !important;
    color: #0f172a !important;
    font-weight: 700;
    letter-spacing: 0.4px;
    box-shadow: none !important;
    gap: 12px;
    justify-content: center;
    transition: filter 0.2s ease, transform 0.15s ease;
}
.login-section.tech-login .login-form button[type="submit"].tech-nut-btn::before {
    /* biseau intérieur de l'écrou */
    content: '';
    position: absolute;
    inset: 5px;
    clip-path: polygon(19px 0, calc(100% - 19px) 0, 100% 50%, calc(100% - 19px) 100%, 19px 100%, 0 50%);
    border: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 45%, rgba(15, 23, 42, 0.12));
    pointer-events: none;
}
.login-section.tech-login .login-form button[type="submit"].tech-nut-btn:hover {
    filter: brightness(1.06) drop-shadow(0 0 6px rgba(56, 189, 248, 0.7));
    transform: translateY(-2px);
}
.login-section.tech-login .login-form button[type="submit"].tech-nut-btn:active {
    transform: translateY(0) scale(0.98);
}
.login-section.tech-login .login-form button[type="submit"].tech-nut-btn > i:not(.fa-spinner) {
    display: none; /* remplacé par l'icône écrou, sauf le spinner de chargement */
}
.tech-nut-icon {
    position: relative;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tech-nut-icon svg { width: 100%; height: 100%; display: block; }
.tech-nut-btn:hover .tech-nut-icon { transform: rotate(60deg); }
.tech-nut-btn.tech-screwing .tech-nut-icon { animation: techNutScrew 0.6s linear infinite; }
@keyframes techNutScrew { to { transform: rotate(360deg); } }
.tech-nut-label { position: relative; }

/* Petits écrous décoratifs (lien "Créer un compte" / "Cliquez ici") */
.login-section.tech-login .login-footer a[href="inscription-eleve.html"],
.login-section.tech-login .login-footer a[href="espace-eleve.html"] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 16px;
    margin-left: 4px;
    clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 10px 100%, 0 50%);
    background: linear-gradient(180deg, #e2e8f0, #94a3b8 55%, #cbd5e1);
    color: #0f172a !important;
    font-weight: 700;
    text-decoration: none !important;
}
.login-section.tech-login .login-footer a[href="inscription-eleve.html"]:hover,
.login-section.tech-login .login-footer a[href="espace-eleve.html"]:hover {
    filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.8));
}

/* ---------- 6. "Rester connecté" = interrupteur électrique avec LED ---------- */
.login-section.tech-login .remember-me-checkmark {
    width: 42px;
    height: 22px;
    border-radius: 12px;
    border: 2px solid #475569;
    background: #334155;
    justify-content: flex-start;
}
.login-section.tech-login .remember-me-checkmark::after {
    content: '';
    width: 14px;
    height: 14px;
    margin: 0 0 0 2px;
    border: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #f8fafc, #94a3b8);
    transform: translateX(0);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.login-section.tech-login .remember-me-label input[type="checkbox"]:checked ~ .remember-me-checkmark {
    background: #14532d;
    border-color: #22c55e;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.6);
}
.login-section.tech-login .remember-me-label input[type="checkbox"]:checked ~ .remember-me-checkmark::after {
    transform: translateX(20px);
    background: radial-gradient(circle at 35% 30%, #dcfce7, #22c55e);
    box-shadow: 0 0 8px #4ade80;
}

/* ---------- 7. Flash électrique à la connexion ---------- */
.tech-flash {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    border-radius: inherit;
    background: radial-gradient(circle at 50% 80%, rgba(254, 249, 195, 0.9), rgba(56, 189, 248, 0.25) 45%, transparent 70%);
    animation: techFlash 0.5s ease-out forwards;
}
@keyframes techFlash {
    0%   { opacity: 0; }
    20%  { opacity: 1; }
    100% { opacity: 0; }
}

@media (max-width: 480px) {
    .login-section.tech-login .login-container { padding: 44px 24px; }
    .tech-gear-ring { inset: -14px; }
}

@media (prefers-reduced-motion: reduce) {
    .tech-gear-ring,
    .tech-pw-wire::after,
    .tech-comp,
    .tech-comp .glow,
    .tech-spark,
    .tech-bolt { animation: none !important; }
}
