/* =========================================================================
   ABP SSO — feuille de style autonome (thème Crucible : dark + orange).
   Aucune dépendance externe. Palette alignée sur design.md.
   ========================================================================= */

:root {
  --bg: #050505;
  --surface: #0c0c0c;
  --card: #141414;
  --border: #262626;
  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-soft: rgba(249, 115, 22, 0.15);
  --success: #22c55e;
  --error: #ef4444;
  --text: #fafafa;
  --muted: #a3a3a3;
  --dim: #525252;
  --discord: #5865f2;
  --radius-card: 32px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
}

/* ----------------------------- Arrière-plan ----------------------------- */

/* Aurore : grandes nappes radiales orange qui dérivent lentement. */
.sso-aurora {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 40% at 20% 25%, rgba(249, 115, 22, 0.22), transparent 70%),
    radial-gradient(35% 35% at 82% 20%, rgba(234, 88, 12, 0.16), transparent 70%),
    radial-gradient(45% 45% at 75% 85%, rgba(249, 115, 22, 0.14), transparent 72%),
    radial-gradient(40% 40% at 15% 80%, rgba(88, 101, 242, 0.08), transparent 72%);
  filter: blur(20px);
  animation: auroraDrift 26s ease-in-out infinite alternate;
}

@keyframes auroraDrift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(2%, -2%, 0) scale(1.08); }
  100% { transform: translate3d(-2%, 1%, 0) scale(1.04); }
}

/* Grille subtile en surimpression. */
.sso-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 75%);
}

/* Canvas de particules. */
#sso-particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Vignette. */
.sso-vignette {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, transparent 45%, rgba(0, 0, 0, 0.55) 100%);
}

/* ------------------------------- Shell ---------------------------------- */

.sso-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}

/* ------------------------------- En-tête -------------------------------- */

.sso-head {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: fadeInUp 0.9s var(--ease) both;
}

.sso-logo {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 34px;
  color: #fff;
  box-shadow: 0 10px 40px rgba(249, 115, 22, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  animation: logoFloat 5s ease-in-out infinite;
}

.sso-logo::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 26px;
  border: 1px solid rgba(249, 115, 22, 0.35);
  animation: ringPulse 3s ease-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}

@keyframes ringPulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(1.45); opacity: 0; }
}

.sso-title {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 0;
  background: linear-gradient(100deg, #ffffff 0%, #ffd9bd 35%, var(--accent) 60%, #ffffff 100%);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: shimmer 6s linear infinite;
}

@keyframes shimmer {
  to { background-position: 220% center; }
}

.sso-subtitle {
  font-size: 0.95rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin: 0;
}

.sso-subtitle b {
  color: var(--accent);
  font-weight: 600;
}

/* Pastille "vous vous connectez à <service>". */
.sso-service-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(20, 20, 20, 0.6);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  animation: fadeInUp 1s var(--ease) both;
  animation-delay: 0.1s;
}

.sso-service-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ------------------------------- Carte ---------------------------------- */

.sso-card {
  position: relative;
  width: 100%;
  border-radius: var(--radius-card);
  padding: 30px 28px 26px;
  background: linear-gradient(180deg, rgba(20, 20, 20, 0.92), rgba(12, 12, 12, 0.92));
  border: 1px solid var(--border);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
  animation: cardIn 1s var(--ease) both;
  animation-delay: 0.15s;
}

/* Liseré orange animé en haut de carte. */
.sso-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 200% 100%;
  animation: sweep 4s linear infinite;
}

@keyframes sweep {
  to { background-position: 200% 0; }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(22px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.sso-card h2 {
  font-family: "Syne", sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}

.sso-card .sso-lede {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ----------------------------- Formulaire ------------------------------- */

.sso-field {
  margin-bottom: 16px;
  animation: fadeInUp 0.8s var(--ease) both;
}

.sso-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 7px;
}

.sso-input-wrap { position: relative; }

.sso-input-wrap > svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--dim);
  pointer-events: none;
  transition: color 0.2s ease;
}

.sso-input {
  width: 100%;
  background: rgba(5, 5, 5, 0.7);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 14px 44px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.sso-input::placeholder { color: var(--dim); }

.sso-input:focus {
  border-color: var(--accent);
  background: rgba(5, 5, 5, 0.95);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.sso-input-wrap:focus-within > svg { color: var(--accent); }

/* Bouton afficher / masquer mot de passe. */
.sso-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--dim);
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}

.sso-eye:hover { color: var(--text); background: var(--border); }
.sso-eye svg { width: 18px; height: 18px; }

/* ----------------------------- Remember-me ------------------------------ */

.sso-remember {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin: 4px 0 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(5, 5, 5, 0.4);
  animation: fadeInUp 0.8s var(--ease) both;
}

.sso-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  color: var(--text);
}

.sso-check input { position: absolute; opacity: 0; width: 0; height: 0; }

.sso-check .box {
  width: 20px;
  height: 20px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(5, 5, 5, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s var(--ease);
  flex-shrink: 0;
}

.sso-check .box svg {
  width: 13px; height: 13px;
  color: #fff;
  opacity: 0;
  transform: scale(0.4);
  transition: all 0.18s var(--ease);
}

.sso-check input:checked + .box {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(249, 115, 22, 0.5);
}

.sso-check input:checked + .box svg { opacity: 1; transform: scale(1); }

.sso-duration {
  position: relative;
}

.sso-duration select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(5, 5, 5, 0.85);
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 32px 8px 12px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.sso-duration select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sso-duration select:disabled { opacity: 0.4; cursor: not-allowed; }

.sso-duration::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

/* ------------------------------- Boutons -------------------------------- */

.sso-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.12s var(--ease), background 0.18s ease, box-shadow 0.2s ease, border-color 0.18s ease;
  position: relative;
  overflow: hidden;
}

.sso-btn:active { transform: scale(0.98); }
.sso-btn svg { width: 19px; height: 19px; }

.sso-btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  box-shadow: 0 10px 30px rgba(249, 115, 22, 0.35);
}

.sso-btn-primary:hover { box-shadow: 0 14px 38px rgba(249, 115, 22, 0.5); }

/* Brillance qui traverse le bouton primaire. */
.sso-btn-primary::after {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s var(--ease);
}

.sso-btn-primary:hover::after { left: 130%; }

.sso-btn-discord {
  background: rgba(88, 101, 242, 0.12);
  border: 1px solid rgba(88, 101, 242, 0.4);
  color: var(--text);
}

.sso-btn-discord:hover {
  background: rgba(88, 101, 242, 0.22);
  border-color: var(--discord);
  box-shadow: 0 10px 28px rgba(88, 101, 242, 0.28);
}

.sso-btn-discord svg { width: 21px; height: 21px; color: #fff; }

.sso-btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 500;
}

.sso-btn-ghost:hover {
  border-color: rgba(249, 115, 22, 0.5);
  color: var(--text);
  background: rgba(20, 20, 20, 0.6);
}

.sso-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }

/* ------------------------------ Séparateur ------------------------------ */

.sso-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0;
  color: var(--dim);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.sso-divider::before,
.sso-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

/* -------------------------------- Erreur -------------------------------- */

.sso-error {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: 13px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 0.86rem;
  animation: shake 0.4s var(--ease) both;
}

.sso-error svg { width: 18px; height: 18px; flex-shrink: 0; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ------------------------- Pied du shell -------------------------------- */

.sso-foot {
  text-align: center;
  font-size: 0.74rem;
  color: var(--dim);
  line-height: 1.6;
  animation: fadeInUp 1.1s var(--ease) both;
  animation-delay: 0.3s;
}

.sso-foot a { color: var(--muted); text-decoration: none; }
.sso-foot a:hover { color: var(--accent); }

/* ====================================================================== */
/*  Scène « Connexion approuvée »                                          */
/* ====================================================================== */

.sso-approved {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  padding: 40px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  animation: cardIn 0.7s var(--ease) both;
}

.sso-check-badge {
  position: relative;
  width: 116px;
  height: 116px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sso-check-badge .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(34, 197, 94, 0.5);
  animation: ringExpand 2s ease-out infinite;
}
.sso-check-badge .ring:nth-child(2) { animation-delay: 0.6s; }
.sso-check-badge .ring:nth-child(3) { animation-delay: 1.2s; }

@keyframes ringExpand {
  0%   { transform: scale(0.6); opacity: 0.8; }
  100% { transform: scale(1.5); opacity: 0; }
}

.sso-check-disc {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(34, 197, 94, 0.35), rgba(34, 197, 94, 0.12));
  border: 1.5px solid rgba(34, 197, 94, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 50px rgba(34, 197, 94, 0.4);
  animation: pop 0.6s var(--ease) both;
}

@keyframes pop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.sso-check-disc svg {
  width: 46px;
  height: 46px;
  color: var(--success);
}

.sso-check-disc svg path {
  stroke-dasharray: 48;
  stroke-dashoffset: 48;
  animation: drawCheck 0.5s var(--ease) 0.35s forwards;
}

@keyframes drawCheck {
  to { stroke-dashoffset: 0; }
}

.sso-approved h2 {
  font-family: "Syne", sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0;
  color: var(--text);
}

.sso-approved p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.sso-approved .target {
  color: var(--accent);
  font-weight: 600;
}

/* Barre de progression de redirection. */
.sso-progress {
  width: 220px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.sso-progress > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--success));
  animation: fill var(--redirect-delay, 1400ms) linear forwards;
}

@keyframes fill {
  to { width: 100%; }
}

.sso-secure-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--dim);
}
.sso-secure-note svg { width: 14px; height: 14px; }

/* ------------------------------ Génériques ------------------------------ */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

.spin { animation: spin360 0.8s linear infinite; }
@keyframes spin360 { to { transform: rotate(360deg); } }

a { -webkit-tap-highlight-color: transparent; }

/* Délais échelonnés pour les champs. */
.stagger-1 { animation-delay: 0.25s; }
.stagger-2 { animation-delay: 0.32s; }
.stagger-3 { animation-delay: 0.39s; }
.stagger-4 { animation-delay: 0.46s; }
.stagger-5 { animation-delay: 0.53s; }

/* Préférence "réduire les animations". */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 480px) {
  .sso-card { padding: 24px 20px; border-radius: 24px; }
  .sso-remember { flex-direction: column; align-items: stretch; }
  .sso-duration select { width: 100%; }
}
