/* Page de connexion maison d'Otoko (auth.otoko.co), 15/11/2026.
   Authelia reste le moteur ; cette page parle à son API, même origine.
   Source : ~/otoko-tools/hub_connexion/  ·  Page : Tech-RD/hub-authentification.md
   Jetons du Lab (otoko-design-system) : papier, encre, repère violet-encre, violet charte. */

@font-face {
  font-family: "Gabarito";
  src: url("/connexion/gabarito.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("/connexion/hanken.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --papier: #fcfaf6;
  --surface: #f5f1eb;
  --champ: #ffffff;
  --trait: #e2ddd5;
  --trait-fort: #b9b1ba;
  --encre: #1f1820;
  --encre-2: #524a54;
  --encre-3: #6e6570;
  --repere: #6f007f;
  --repere-fort: #5a0068;
  --sur-repere: #ffffff;
  --alerte: #a00059;
  --alerte-fond: #fff0f6;
  --anneau: rgba(111, 0, 127, 0.2);
  --selection: #f5c3fd;

  --halo-1: rgba(224, 73, 251, 0.46);
  --halo-2: rgba(194, 184, 254, 0.34);
  --halo-3: rgba(250, 60, 164, 0.2);

  --titre: "Gabarito", "Avenir Next", system-ui, sans-serif;
  --corps: "Hanken Grotesk", "Avenir Next", system-ui, sans-serif;

  --sortie: cubic-bezier(0.16, 1, 0.3, 1);
  --doux: cubic-bezier(0.45, 0, 0.25, 1);
  --rayon-champ: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --papier: #1f1820;
    --surface: #2a212c;
    --champ: #2a212c;
    --trait: #3b3140;
    --trait-fort: #5a4f5e;
    --encre: #f4f0f5;
    --encre-2: #c9c0ca;
    --encre-3: #a59ba7;
    --repere: #e9a3fb;
    --repere-fort: #f2c4fd;
    --sur-repere: #1f1820;
    --alerte: #ff9ccb;
    --alerte-fond: #3a1a2b;
    --anneau: rgba(233, 163, 251, 0.28);
    --selection: #6f007f;

    --halo-1: rgba(224, 73, 251, 0.5);
    --halo-2: rgba(140, 120, 240, 0.32);
    --halo-3: rgba(250, 60, 164, 0.26);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--papier);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--papier);
  color: var(--encre);
  font-family: var(--corps);
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  caret-color: var(--repere);
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--selection); color: var(--encre); }

[hidden] { display: none !important; }

/* ── L'astre : une forme lumineuse qui respire derrière la page ─────────── */

.ciel {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.astre {
  position: absolute;
  left: 50%;
  top: 0;
  width: min(128vw, 720px);
  aspect-ratio: 1;
  transform: translate(-50%, calc(44svh - 50%));
  transition: transform 1800ms var(--sortie), opacity 1800ms var(--sortie);
  will-change: transform;
}

body.posee .astre {
  transform: translate(-50%, calc(17svh - 50%)) scale(0.82);
}

.halo, .coeur {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.halo {
  background:
    radial-gradient(closest-side, var(--halo-1), rgba(224, 73, 251, 0.12) 58%, transparent 100%);
  animation: respire 9s var(--doux) infinite alternate;
}

.coeur {
  inset: 14%;
  background:
    radial-gradient(closest-side at 38% 42%, var(--halo-3), transparent 70%),
    radial-gradient(closest-side at 64% 60%, var(--halo-2), transparent 72%);
  animation: tourne 48s linear infinite, respire-coeur 9s var(--doux) infinite alternate;
}

@keyframes respire {
  from { transform: scale(0.9); opacity: 0.72; }
  to   { transform: scale(1.05); opacity: 1; }
}
@keyframes respire-coeur {
  from { opacity: 0.7; }
  to   { opacity: 1; }
}
@keyframes tourne {
  to { rotate: 360deg; }
}

/* ── La page ────────────────────────────────────────────────────────────── */

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding:
    calc(18px + env(safe-area-inset-top, 0px))
    calc(24px + env(safe-area-inset-right, 0px))
    calc(16px + env(safe-area-inset-bottom, 0px))
    calc(24px + env(safe-area-inset-left, 0px));
}

.haut {
  display: flex;
  justify-content: center;
  padding-top: 6px;
}

.logo {
  display: block;
  width: 88px;
  height: 28px;
  background-color: var(--encre);
  -webkit-mask: url("/connexion/logo.svg") center / contain no-repeat;
  mask: url("/connexion/logo.svg") center / contain no-repeat;
}

.scene {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  display: grid;
  align-items: end;
  padding-block: 32px 12px;
}

@media (min-height: 760px) and (min-width: 600px) {
  .scene { align-items: center; }
}

.ecran {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.ecran-attente {
  align-self: center;
  min-height: 40svh;
  justify-content: flex-end;
}

/* Fondu d'entrée : lent, amorti, sans spinner. Chaque enfant arrive un peu
   après le précédent. La sortie est plus rapide que l'entrée. */
.ecran > * {
  opacity: 0;
  transform: translateY(10px);
  filter: blur(5px);
  transition:
    opacity 760ms var(--sortie),
    transform 760ms var(--sortie),
    filter 760ms var(--sortie);
}
.ecran.visible > * { opacity: 1; transform: none; filter: none; }
.ecran.visible > :nth-child(2) { transition-delay: 70ms; }
.ecran.visible > :nth-child(3) { transition-delay: 140ms; }
.ecran.visible > :nth-child(4) { transition-delay: 210ms; }
.ecran.visible > :nth-child(5) { transition-delay: 260ms; }
.ecran.visible > :nth-child(n + 6) { transition-delay: 300ms; }

.ecran.sortant > * {
  opacity: 0;
  transform: translateY(-6px);
  filter: blur(4px);
  transition-duration: 260ms;
  transition-delay: 0ms;
}

h1 {
  margin: 0;
  font-family: var(--titre);
  font-weight: 700;
  font-size: clamp(2rem, 8.6vw, 2.5rem);
  line-height: 1.06;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

.sous {
  margin: 0 auto;
  max-width: 32ch;
  color: var(--encre-2);
  text-wrap: pretty;
}

.aide {
  margin: 0 auto;
  max-width: 36ch;
  color: var(--encre-3);
  font-size: 0.9375rem;
  text-wrap: pretty;
}

.note {
  margin: 0 auto;
  color: var(--encre-2);
  font-size: 0.9375rem;
}

.lent {
  margin: 0;
  color: var(--encre-2);
  font-family: var(--titre);
  font-weight: 500;
  font-size: 1.0625rem;
  letter-spacing: 0.01em;
}
.ecran-attente.visible > .lent { animation: battement 3.2s var(--doux) 900ms infinite alternate; }
@keyframes battement {
  from { opacity: 1; }
  to   { opacity: 0.45; }
}

/* ── Formulaires ────────────────────────────────────────────────────────── */

.formulaire, .bloc-cle {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
  text-align: left;
}
.bloc-cle { text-align: center; }
.bloc-cle + .formulaire { margin-top: 0; }

.champ {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.champ > span:first-child {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--encre-2);
  padding-left: 4px;
}

input[type="email"], input[type="password"], input[type="text"] {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  font: inherit;
  font-size: 1.0625rem;
  color: var(--encre);
  background: var(--champ);
  border: 1px solid var(--trait);
  border-radius: var(--rayon-champ);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
input:focus-visible, input:focus {
  border-color: var(--repere);
  box-shadow: 0 0 0 3px var(--anneau);
}
input[readonly] {
  background: var(--surface);
  color: var(--encre-2);
  border-color: transparent;
}
input[readonly]:focus { box-shadow: none; border-color: var(--trait); }
input::placeholder { color: var(--encre-3); }

input.code {
  text-align: center;
  font-family: var(--titre);
  font-weight: 600;
  font-size: 1.375rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.avec-bouton { position: relative; display: block; }
.avec-bouton input { padding-right: 104px; }
.voir {
  position: absolute;
  top: 6px;
  right: 6px;
  height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--repere);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.coche {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  cursor: pointer;
  color: var(--encre);
  user-select: none;
  -webkit-user-select: none;
}
.coche input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 1.5px solid var(--trait-fort);
  border-radius: 7px;
  background: var(--champ);
  display: grid;
  place-items: center;
  transition: background-color 160ms ease, border-color 160ms ease;
  cursor: pointer;
}
.coche input::after {
  content: "";
  width: 6px;
  height: 11px;
  border: solid var(--sur-repere);
  border-width: 0 2.2px 2.2px 0;
  transform: translateY(-1px) rotate(45deg) scale(0.6);
  opacity: 0;
  transition: opacity 160ms ease, transform 200ms var(--sortie);
}
.coche input:checked { background: var(--repere); border-color: var(--repere); }
.coche input:checked::after { opacity: 1; transform: translateY(-1px) rotate(45deg) scale(1); }

/* ── Boutons et liens ───────────────────────────────────────────────────── */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 0 24px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: var(--titre);
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: 0.005em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease-out, background-color 200ms ease, opacity 200ms ease;
}
.btn:active { transform: scale(0.97); }
.btn-1 { background: var(--repere); color: var(--sur-repere); }
.btn-2 { background: transparent; color: var(--encre); border-color: var(--trait-fort); }
@media (hover: hover) and (pointer: fine) {
  .btn-1:hover { background: var(--repere-fort); }
  .btn-2:hover { border-color: var(--encre-3); }
  .lien:hover { text-decoration-thickness: 2px; }
}
.btn:disabled { cursor: default; }
.btn[aria-busy="true"] { animation: patience 1.6s var(--doux) infinite alternate; }
@keyframes patience {
  from { opacity: 1; }
  to   { opacity: 0.55; }
}

.liens {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 22px;
}
.lien {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--repere);
  font: inherit;
  font-size: 0.96875rem;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  cursor: pointer;
}
.bloc-cle .lien { align-self: center; }

:focus-visible {
  outline: 2px solid var(--repere);
  outline-offset: 3px;
}
input:focus-visible { outline: none; }
h1:focus, h1:focus-visible { outline: none; }

.erreur {
  margin: 0;
  padding: 11px 14px;
  border-radius: 14px;
  background: var(--alerte-fond);
  color: var(--alerte);
  font-size: 0.96875rem;
  font-weight: 500;
  text-align: left;
  text-wrap: pretty;
  animation: apparait 320ms var(--sortie);
}
.erreur .lien { min-height: 0; padding: 0; color: inherit; font-size: inherit; }
/* La sortie de secours de tout refus : deux gestes à la ligne, assez grands pour le pouce. */
.erreur .secours {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 8px;
}
.erreur .secours .lien { min-height: 36px; font-weight: 600; }
@keyframes apparait {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.bas {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--encre-3);
}
.bas p { margin: 0; }
.bas p + p { margin-top: 6px; }
.bas a { color: var(--encre-2); text-underline-offset: 3px; }

.sans-js {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 2;
  margin: 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--encre);
  text-align: center;
}

/* ── Mouvement réduit : l'astre ne respire plus, les écrans se fondent ──── */

@media (prefers-reduced-motion: reduce) {
  .halo, .coeur, .ecran-attente.visible > .lent, .btn[aria-busy="true"] { animation: none; }
  .astre { transition: opacity 400ms ease; }
  body.posee .astre { transform: translate(-50%, calc(17svh - 50%)) scale(0.82); }
  .ecran > * { transform: none; filter: none; transition: opacity 240ms ease; }
  .ecran.visible > * { transition-delay: 0ms !important; }
  .ecran.sortant > * { transform: none; filter: none; }
  .erreur { animation: none; }
  .btn:active { transform: none; }
}
