/* Page de connexion — template_connection.html intégré (scopé sous #authModal) */
#authModal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
  color: rgba(245, 250, 255, 0.92);
  font-family: Inter, system-ui, sans-serif;
  display: grid;
  place-items: center;
  isolation: isolate;
}

#authModal.hidden {
  display: none !important;
}

#authModal .bg-layer {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(4, 6, 10, 0.5), rgba(4, 6, 10, 0.9)),
    url("/background.svg") center/cover no-repeat;
  transform: scale(1.03);
  animation: auth-bg-breathe 10s ease-in-out infinite;
  z-index: -3;
}

#authModal .bg-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(0deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px) 0 0 / 36px 36px;
  opacity: 0.18;
  z-index: -2;
  animation: auth-drift 18s linear infinite;
}

#authModal .vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 45%, rgba(0, 0, 0, 0.72) 100%);
  z-index: -1;
  pointer-events: none;
}

#authModal .boot-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

#authModal .boot-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#authModal .boot-inner {
  display: grid;
  gap: 18px;
  place-items: center;
  text-align: center;
  padding: 20px;
}

#authModal .logo-gif {
  width: min(300px, 62vw);
  max-height: min(300px, 62vw);
  object-fit: contain;
  filter: drop-shadow(0 0 24px rgba(45, 167, 255, 0.25));
}

#authModal .logo-name {
  margin: 0;
  font-family: Orbitron, sans-serif;
  font-size: clamp(28px, 5.5vw, 54px);
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(237, 245, 255, 0.95);
  text-shadow: 0 0 24px rgba(45, 167, 255, 0.32);
  animation: auth-pulse 1.2s ease-in-out infinite;
}

#authModal .boot-status {
  margin: 0;
  font-family: Orbitron, sans-serif;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(220, 233, 246, 0.6);
}

#authModal .console-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: opacity 0.45s ease, visibility 0.45s ease;
  opacity: 1;
  visibility: visible;
}

#authModal .console-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#authModal .console-screen.out-glitch .console-shell {
  animation: auth-terminal-out 0.42s steps(2) forwards;
}

#authModal .console-shell {
  width: min(760px, calc(100vw - 32px));
  height: min(320px, 56vh);
  background: rgba(2, 6, 10, 0.84);
  border: 1px solid rgba(45, 167, 255, 0.22);
  box-shadow: 0 0 28px rgba(45, 167, 255, 0.12);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

#authModal .console-shell.glitch-mode {
  border-color: rgba(255, 85, 104, 0.72);
  box-shadow: 0 0 34px rgba(255, 59, 82, 0.26);
  animation: auth-term-fragment 0.22s steps(4) infinite, auth-term-flicker 0.11s linear infinite;
}

#authModal .console-head {
  border-bottom: 1px solid rgba(45, 167, 255, 0.18);
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: Orbitron, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  color: rgba(218, 235, 251, 0.8);
}

#authModal .console-state { color: #7ce7ff; }

#authModal .console-body {
  margin: 0;
  padding: 12px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  color: #9ff5c0;
  white-space: pre-wrap;
}

#authModal .console-body.crash {
  color: #ff6275;
  text-shadow: 0 0 8px rgba(255, 77, 104, 0.45);
}

#authModal .console-line {
  opacity: 0;
  transform: translateY(4px);
  animation: auth-line-in 0.22s ease forwards;
}

#authModal .console-line.crash-line {
  color: #ff7084;
  animation: auth-line-in 0.07s linear forwards;
  letter-spacing: 0.02em;
}

#authModal .console-line.ascii-line {
  color: #ff445d;
  font-weight: 700;
  letter-spacing: 0;
  animation: auth-line-in 0.12s linear forwards;
}

#authModal .console-cursor {
  display: inline-block;
  margin-left: 4px;
  color: #9ff5c0;
  animation: auth-cursor 0.8s step-end infinite;
}

#authModal .hud-window {
  width: min(620px, calc(100vw - 36px));
  min-height: 250px;
  opacity: 1;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(0) scale(1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(2px);
}

#authModal .hud-window.assembling {
  visibility: visible;
  pointer-events: none;
  animation: auth-assemble-slices 0.72s steps(6) forwards;
}

#authModal .hud-window.visible {
  visibility: visible;
  pointer-events: auto;
}

#authModal .hud-window .build-item {
  opacity: 0;
  transform: translateY(6px);
  filter: blur(6px);
  transition: opacity 0.14s linear, transform 0.18s ease, filter 0.18s ease;
}

#authModal .hud-window.assembling .build-item.built,
#authModal .hud-window.visible .build-item {
  opacity: 1;
  transform: none;
  filter: none;
}

#authModal .hud-window.glitching {
  animation: auth-window-fragment 0.2s steps(4) infinite, auth-window-flicker 0.09s linear infinite;
  filter: saturate(1.5) contrast(1.25);
}

#authModal .hud-window::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(0deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px) 0 0 / 24px 24px;
  opacity: 0.16;
  pointer-events: none;
}

#authModal .scanline {
  position: absolute;
  inset: -120% 0 auto 0;
  height: 180px;
  background: linear-gradient(180deg, transparent, rgba(45, 167, 255, 0.08), transparent);
  animation: auth-scan 3s linear infinite;
  pointer-events: none;
}

#authModal .hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  position: relative;
  z-index: 1;
}

#authModal .hud-brand {
  margin: 0;
  font-family: Orbitron, sans-serif;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(245, 250, 255, 0.92);
}

#authModal .hud-state {
  font-family: Orbitron, sans-serif;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #2da7ff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#authModal .hud-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2da7ff;
  box-shadow: 0 0 10px #2da7ff;
  animation: auth-blink 1.1s linear infinite;
}

#authModal .hud-content {
  padding: 26px 18px 20px;
  display: grid;
  gap: 14px;
  text-align: center;
  position: relative;
  z-index: 1;
}

#authModal .hud-title {
  margin: 0;
  font-family: Orbitron, sans-serif;
  font-size: clamp(34px, 8vw, 72px);
  font-weight: 800;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: rgba(242, 248, 255, 0.98);
  text-shadow: 0 0 26px rgba(45, 167, 255, 0.34);
  animation: auth-title-jitter 4s steps(2) infinite;
}

#authModal .hud-subtitle {
  margin: 0;
  font-family: Orbitron, sans-serif;
  font-size: clamp(10px, 1.6vw, 12px);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(220, 233, 246, 0.6);
}

#authModal .hud-footer {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  padding-top: 4px;
}

#authModal .auth-panel {
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
  display: grid;
  gap: 8px;
  max-width: 380px;
  width: 100%;
  justify-self: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

#authModal .auth-panel.visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

#authModal .auth-row {
  display: grid;
  gap: 5px;
  text-align: left;
}

#authModal .auth-row label {
  font-family: Orbitron, sans-serif;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(220, 233, 246, 0.6);
}

#authModal .auth-row input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(4, 9, 14, 0.7);
  color: rgba(245, 250, 255, 0.92);
  font-family: Inter, system-ui, sans-serif;
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#authModal .auth-row input:focus {
  border-color: #2da7ff;
  box-shadow: 0 0 0 2px rgba(45, 167, 255, 0.18);
}

#authModal .auth-submit {
  margin-top: 4px;
  border: 1px solid #2da7ff;
  background: rgba(45, 167, 255, 0.12);
  color: #eaf5ff;
  font-family: Orbitron, sans-serif;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 9px 12px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

#authModal .auth-submit:hover {
  background: rgba(45, 167, 255, 0.24);
  box-shadow: 0 0 16px rgba(45, 167, 255, 0.22);
}

#authModal .hud-tag {
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(228, 239, 250, 0.78);
  background: rgba(255, 255, 255, 0.02);
  font-family: Orbitron, sans-serif;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 10px;
}

#authModal .hud-corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: #2da7ff;
  border-style: solid;
  border-width: 0;
  opacity: 0.9;
  z-index: 2;
}

#authModal .hud-corner.tl { top: 7px; left: 7px; border-top-width: 1px; border-left-width: 1px; }
#authModal .hud-corner.tr { top: 7px; right: 7px; border-top-width: 1px; border-right-width: 1px; }
#authModal .hud-corner.bl { bottom: 7px; left: 7px; border-bottom-width: 1px; border-left-width: 1px; }
#authModal .hud-corner.br { bottom: 7px; right: 7px; border-bottom-width: 1px; border-right-width: 1px; }

#authModal .auth-panel .hidden { display: none !important; }
#authModal .auth-panel #loginError {
  font-size: 12px;
  color: #ff6f6f;
  text-align: center;
  min-height: 1.2em;
}

#authModal.page-glitch .bg-layer {
  animation: auth-bg-breathe 10s ease-in-out infinite, auth-page-fragment 0.17s steps(3) infinite;
  filter: hue-rotate(-18deg) saturate(1.45);
}

#authModal.page-glitch .bg-grid {
  opacity: 0.32;
  animation: auth-drift 18s linear infinite, auth-page-flicker 0.09s linear infinite;
}

@keyframes auth-bg-breathe {
  0%, 100% { transform: scale(1.03); }
  50% { transform: scale(1.06); }
}

@keyframes auth-drift {
  from { transform: translateY(0); }
  to { transform: translateY(36px); }
}

@keyframes auth-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.78; }
}

@keyframes auth-scan {
  0% { transform: translateY(0); }
  100% { transform: translateY(360%); }
}

@keyframes auth-blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0.2; }
}

@keyframes auth-title-jitter {
  0%, 95%, 100% { transform: translate(0, 0); }
  96% { transform: translate(-1px, 1px); }
  97% { transform: translate(1px, 0); }
  98% { transform: translate(0, -1px); }
}

@keyframes auth-line-in {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes auth-cursor {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes auth-term-fragment {
  0%, 100% { clip-path: inset(0 0 0 0); }
  20% { clip-path: inset(2% 0 51% 0); }
  40% { clip-path: inset(42% 0 23% 0); }
  60% { clip-path: inset(14% 0 34% 0); }
  80% { clip-path: inset(58% 0 6% 0); }
}

@keyframes auth-term-flicker {
  0%, 70%, 100% { opacity: 1; }
  71% { opacity: 0.72; }
  74% { opacity: 1; }
  83% { opacity: 0.58; }
  85% { opacity: 1; }
}

@keyframes auth-page-fragment {
  0%, 100% { clip-path: inset(0 0 0 0); }
  25% { clip-path: inset(0 0 63% 0); }
  50% { clip-path: inset(24% 0 21% 0); }
  75% { clip-path: inset(47% 0 0 0); }
}

@keyframes auth-page-flicker {
  0%, 82%, 100% { opacity: 0.32; }
  83% { opacity: 0.15; }
  84% { opacity: 0.34; }
  92% { opacity: 0.08; }
  93% { opacity: 0.32; }
}

@keyframes auth-window-fragment {
  0%, 100% { clip-path: inset(0 0 0 0); }
  18% { clip-path: inset(3% 0 49% 0); }
  38% { clip-path: inset(45% 0 24% 0); }
  58% { clip-path: inset(16% 0 35% 0); }
  78% { clip-path: inset(63% 0 4% 0); }
}

@keyframes auth-window-flicker {
  0%, 82%, 100% { opacity: 1; }
  83% { opacity: 0.5; }
  84% { opacity: 1; }
  92% { opacity: 0.35; }
  93% { opacity: 1; }
}

@keyframes auth-assemble-slices {
  0% {
    clip-path: polygon(0 0, 100% 0, 100% 9%, 0 14%);
    opacity: 0.2;
    filter: hue-rotate(-40deg) saturate(1.8);
  }
  16% { clip-path: polygon(0 18%, 100% 10%, 100% 34%, 0 40%); opacity: 0.6; }
  33% { clip-path: polygon(0 42%, 100% 36%, 100% 58%, 0 66%); opacity: 0.75; }
  50% { clip-path: polygon(0 61%, 100% 56%, 100% 77%, 0 86%); opacity: 0.85; }
  72% { clip-path: polygon(0 81%, 100% 74%, 100% 96%, 0 100%); opacity: 0.95; }
  100% {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    opacity: 1;
    filter: none;
  }
}

@keyframes auth-terminal-out {
  0% { opacity: 1; clip-path: inset(0 0 0 0); filter: hue-rotate(0deg); }
  25% { opacity: 0.95; clip-path: inset(0 0 42% 0); filter: hue-rotate(-35deg) saturate(1.5); }
  55% { opacity: 0.72; clip-path: inset(28% 0 0 0); }
  100% { opacity: 0; clip-path: inset(100% 0 0 0); }
}
