/* ==========================================================
   Pages d'authentification Tek-Log (connexion / réinitialisation)
   ========================================================== */

:root {
  --blue: #005eb8;
  --blue-dark: #004a99;
  --navy: #071a33;
  --gold: #ffb500;
  --gold-dark: #e6a200;
  --ink: #0f172a;
  --text: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --field: #f8fafc;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--navy);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Arrière-plan plein écran ---------- */
.auth-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(800px 500px at 15% 10%, rgba(0, 94, 184, .55), transparent 60%),
    radial-gradient(700px 500px at 90% 90%, rgba(255, 181, 0, .18), transparent 60%),
    linear-gradient(rgba(7, 26, 51, .86), rgba(7, 26, 51, .94)),
    url('../img/background.jpg') center / cover no-repeat;
}

/* ---------- Conteneur centré ---------- */
.auth-wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 20px;
}

.auth-shell {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: #fff;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .06);
  animation: shell-in .6s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes shell-in {
  from { opacity: 0; transform: translateY(18px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Panneau illustration ---------- */
.auth-visual {
  position: relative;
  padding: 32px 32px 28px;
  color: #fff;
  background: linear-gradient(160deg, #0a3d7a 0%, var(--blue-dark) 45%, #06264d 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.auth-visual::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--gold), rgba(255, 181, 0, .35));
}

.auth-brand img { height: 30px; display: block; }

.auth-visual .reader-scene {
  width: 100%;
  max-width: 420px;
  margin: 18px auto 8px;
  display: block;
  flex: 1;
}

.auth-tagline h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
  color: #fff;
}
.auth-tagline h2 span { color: var(--gold); }
.auth-tagline p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: rgba(255, 255, 255, .78);
}

/* ---------- Panneau formulaire ---------- */
.auth-card {
  padding: 40px 40px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 560px;
}

.auth-head { margin-bottom: 22px; }
.auth-head h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.2px;
}
.auth-head p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
}

.auth-icon-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 24px;
  margin-bottom: 16px;
  color: var(--blue);
  background: rgba(0, 94, 184, .1);
}
.auth-icon-badge.is-success { color: var(--success); background: var(--success-bg); }
.auth-icon-badge.is-danger  { color: var(--danger);  background: var(--danger-bg); }

/* Sélecteur Église / Participant */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 24px;
  background: #f1f5f9;
  border-radius: 12px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 10px 8px;
  border-radius: 9px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: background .2s, color .2s, box-shadow .2s;
}
.segmented button i { margin-right: 6px; }
.segmented button[aria-selected="true"] {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}

/* Vues (connexion, oubli, participant…) */
.view[hidden],
.segmented[hidden],
.qr-placeholder[hidden] { display: none !important; }
.view { animation: view-in .35s ease both; }
@keyframes view-in {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: none; }
}

/* Champs */
.field { margin-bottom: 18px; }
.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.field-label a {
  font-size: 12.5px;
  font-weight: 600;
}

.input-wrap { position: relative; }
.input-wrap > .bi:first-child {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 16px;
  pointer-events: none;
  transition: color .2s;
}
.input-wrap input {
  width: 100%;
  height: 48px;
  padding: 0 46px 0 42px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.input-wrap input::placeholder { color: #a0aec0; }
.input-wrap input:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 94, 184, .12);
}
.input-wrap:focus-within > .bi:first-child { color: var(--blue); }
.input-wrap input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, .1);
}

.toggle-visibility {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 17px;
}
.toggle-visibility:hover { background: #eef2f7; color: var(--ink); }

.field-hint {
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--warning);
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-hint[hidden] { display: none; }

/* Boutons */
.btn-primary {
  position: relative;
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  background: linear-gradient(180deg, #ffc22e, var(--gold));
  box-shadow: 0 8px 20px rgba(255, 181, 0, .28), inset 0 -2px 0 rgba(0, 0, 0, .08);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.btn-primary:hover { filter: brightness(1.03); box-shadow: 0 10px 24px rgba(255, 181, 0, .38); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:focus-visible { outline: 3px solid rgba(0, 94, 184, .4); outline-offset: 2px; }
.btn-primary:disabled { cursor: not-allowed; filter: saturate(.6); opacity: .8; }

.btn-secondary {
  width: 100%;
  height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background .2s, border-color .2s;
}
.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; color: var(--ink); text-decoration: none; }
.btn-secondary:disabled { opacity: .6; cursor: not-allowed; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(15, 23, 42, .25);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.is-loading .btn-label,
.is-loading .btn-icon { display: none; }

/* Liens */
.auth-card a,
.link-btn {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}
.auth-card a:hover,
.link-btn:hover { text-decoration: underline; }
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  font-size: 13.5px;
}

/* Alertes intégrées */
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  border: 1px solid transparent;
  animation: alert-in .3s ease both;
}
.alert[hidden] { display: none; }
.alert .bi { font-size: 16px; margin-top: 1px; }
.alert-error   { color: #991b1b; background: var(--danger-bg);  border-color: #fecaca; }
.alert-success { color: #166534; background: var(--success-bg); border-color: #bbf7d0; }
.alert-info    { color: #1e3a8a; background: #eff6ff;           border-color: #bfdbfe; }
@keyframes alert-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.shake { animation: shake .4s ease; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* QR participant */
.qr-box {
  position: relative;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  margin: 0 auto 18px;
  border-radius: 18px;
  overflow: hidden;
  background: #0f172a;
  display: grid;
  place-items: center;
}
.qr-box #qr-reader { width: 100%; }
.qr-box #qr-reader video { object-fit: cover; }
.qr-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: #cbd5e1;
  font-size: 13px;
  padding: 20px;
}
.qr-placeholder .bi { font-size: 40px; display: block; margin-bottom: 8px; color: var(--gold); }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 18px;
  font-size: 12px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.divider::before,
.divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Jauge de robustesse */
.strength { margin-top: 10px; }
.strength-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.strength-bar span {
  height: 5px;
  border-radius: 5px;
  background: var(--line);
  transition: background .25s;
}
.strength-text { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }

.rules {
  list-style: none;
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  font-size: 12.5px;
}
.rules li { display: flex; align-items: center; gap: 8px; padding: 3px 0; color: var(--muted); transition: color .2s; }
.rules li .bi { font-size: 14px; }
.rules li.ok { color: var(--success); }

.auth-footer {
  text-align: center;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .7);
  line-height: 1.7;
}
.auth-footer a { color: #fff; font-weight: 700; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

.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;
}

/* ==========================================================
   Animation de l'illustration « enfant qui lit »
   ========================================================== */
.reader-scene * { transform-box: view-box; }

.rs-child { animation: rs-breathe 4.5s ease-in-out infinite; transform-origin: 200px 330px; }
@keyframes rs-breathe {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}

.rs-head { animation: rs-nod 6s ease-in-out infinite; transform-origin: 200px 205px; }
@keyframes rs-nod {
  0%, 100% { transform: rotate(-3deg); }
  50%      { transform: rotate(3deg); }
}

.rs-eyes { animation: rs-blink 5s infinite; transform-origin: 200px 157px; }
@keyframes rs-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95%           { transform: scaleY(.1); }
}

.rs-flip {
  transform-origin: 200px 260px;
  animation: rs-page 4s cubic-bezier(.45, .05, .35, 1) infinite;
}
.rs-flip-2 { animation-delay: 2s; }
@keyframes rs-page {
  0%, 15%  { transform: scaleX(1);  opacity: 1; }
  45%      { transform: scaleX(0);  opacity: 1; }
  75%      { transform: scaleX(-1); opacity: 1; }
  85%      { transform: scaleX(-1); opacity: 0; }
  100%     { transform: scaleX(1);  opacity: 0; }
}

.rs-halo { animation: rs-glow 4s ease-in-out infinite; transform-origin: 200px 215px; }
@keyframes rs-glow {
  0%, 100% { opacity: .75; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.05); }
}

.rs-twinkle circle { animation: rs-twinkle 2.4s ease-in-out infinite; }
@keyframes rs-twinkle {
  0%, 100% { opacity: .2; }
  50%      { opacity: 1; }
}

.rs-float { opacity: 0; animation: rs-float-a 6s ease-out infinite; }
.rs-f1 { animation-name: rs-float-a; animation-delay: 0s; }
.rs-f2 { animation-name: rs-float-b; animation-delay: 1s; }
.rs-f3 { animation-name: rs-float-c; animation-delay: 2s; }
.rs-f4 { animation-name: rs-float-b; animation-delay: 3s; }
.rs-f5 { animation-name: rs-float-a; animation-delay: 4s; }
.rs-f6 { animation-name: rs-float-c; animation-delay: 5s; }

@keyframes rs-float-a {
  0%   { opacity: 0; transform: translate(0, 0) scale(.6) rotate(0); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-70px, -190px) scale(1.25) rotate(-25deg); }
}
@keyframes rs-float-b {
  0%   { opacity: 0; transform: translate(0, 0) scale(.6) rotate(0); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translate(75px, -185px) scale(1.2) rotate(25deg); }
}
@keyframes rs-float-c {
  0%   { opacity: 0; transform: translate(0, 0) scale(.6); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translate(8px, -205px) scale(1.3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .rs-float { opacity: 0; }
}

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 880px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 480px; }
  .auth-visual { padding: 20px 20px 16px; align-items: center; text-align: center; }
  .auth-visual .reader-scene { max-width: 230px; margin: 8px auto 4px; }
  .auth-tagline p { display: none; }
  .auth-tagline h2 { font-size: 17px; margin: 0; }
  .auth-card { padding: 28px 22px 24px; min-height: 0; }
  .auth-head h1 { font-size: 21px; }
}

@media (max-width: 380px) {
  .auth-wrap { padding: 16px 12px; }
  .auth-visual .reader-scene { max-width: 180px; }
}
