/* renderer/login.css — ForgeWeb
   Page de compte. AUTONOME : n'emprunte rien aux feuilles de l'application
   (styles.css n'est pas chargé ici), d'où ses propres variables.

   REGISTRE : celui de l'application — thème « Livre » (papier / encre / serif).
   ⚠ MIROIRS : les jetons ci-dessous reprennent, sous le même nom, les valeurs
   de styles.css (couleurs, Lune et Éclipse), marge.css (rayons, transitions)
   et elements.css (ombre de modale, champ, bouton primaire). Une valeur
   retouchée là-bas se reporte ici à la main.

   THÈME : html[data-theme] = dernier thème utilisé sur ce navigateur
   (login.js, forge.bootTheme). « eclipse » (ou « dark ») → Éclipse ; toute
   autre valeur → Lune ; AUCUN attribut → le système décide. */

/* === Lune (défaut) ========================================================== */
:root {
  color-scheme: light;
  --paper:            #f6f0e2;
  --paper-raised-min: #faf7eb;
  --paper-raised:     #fffdf6;
  --paper-sunken:     #ece4d3;
  --ink:              #2a2620;
  --ink-body:         #443e35;
  --ink-soft:         #6f665a;
  --rule:             #ddd3c1;
  --rule-strong:      #c8bba2;
  --accent:           #3f6b4f;
  --accent-hover:     #5c7a49;   /* = --book-moss */
  --positive:         #3f6b4f;
  --negative:         #9b3b34;
  --shadow-rgb:       42, 38, 32;

  --book-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Times New Roman", serif;
  --font-body:  system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition-fast: 0.1s ease;
  --transition-base: 0.2s ease;

  /* Retrait intérieur du panneau : le bandeau de titre s'y cale (marges
     négatives), le bloc mobile le resserre en un point. */
  --lg-pad: 24px;
}

/* === Éclipse ================================================================
   Deux blocs IDENTIQUES (le CSS ne sait pas factoriser une media query et un
   sélecteur d'attribut) : les retoucher ensemble. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --paper:            #1d1b18;
    --paper-raised-min: #221f1b;
    --paper-raised:     #27241f;
    --paper-sunken:     #151311;
    --ink:              #ece4d3;
    --ink-body:         #d2c9b6;
    --ink-soft:         #b5aa96;
    --rule:             #37322b;
    --rule-strong:      #4d463c;
    --accent:           #86b394;
    --accent-hover:     #a3c7ab;
    --positive:         #86b394;
    --negative:         #e0877c;
    --shadow-rgb:       0, 0, 0;
  }
}
:root[data-theme="eclipse"],
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:            #1d1b18;
  --paper-raised-min: #221f1b;
  --paper-raised:     #27241f;
  --paper-sunken:     #151311;
  --ink:              #ece4d3;
  --ink-body:         #d2c9b6;
  --ink-soft:         #b5aa96;
  --rule:             #37322b;
  --rule-strong:      #4d463c;
  --accent:           #86b394;
  --accent-hover:     #a3c7ab;
  --positive:         #86b394;
  --negative:         #e0877c;
  --shadow-rgb:       0, 0, 0;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--paper);
  color: var(--ink-body);
  font: 16px/1.5 var(--font-body);
}

::selection { background-color: color-mix(in srgb, var(--ink) 14%, transparent); }

[hidden] { display: none !important; }

.login-shell { width: 100%; max-width: 400px; }

/* Marque : titre serif de l'application, encre pleine. */
.login-brand {
  margin: 0 0 20px;
  text-align: center;
  font: 600 2rem/1.2 var(--book-serif);
  letter-spacing: 0.01em;
  color: var(--ink);
}

/* ── Panneau : surface de modale (elements.css §4.b) ── */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: var(--lg-pad);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(var(--shadow-rgb), 0.18);
}

/* Titre : bandeau d'en-tête de modale (§4.d / 4.e) — fond papier, filet bas,
   coins hauts de la surface. Tiré jusqu'aux bords par des marges négatives. */
.login-form h2 {
  margin: calc(-1 * var(--lg-pad)) calc(-1 * var(--lg-pad)) 4px;
  padding: 14px var(--lg-pad);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0;
  font: 600 1.25rem/1.3 var(--book-serif);
  color: var(--ink);
}

/* ── Champs (elements.css §1 + jetons --field-*) ── */
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--ink);
}
.login-form label > span { font-weight: 500; }
.login-form small, .login-help { color: var(--ink-soft); }
.login-form small { font-size: 0.8125rem; }
.login-help { margin: 0; font-size: 0.875rem; }

/* Fond papier, filet fin, arête basse ferme et NEUTRE au repos. Corps à 16 px :
   pas de zoom iOS au focus. */
.login-form input:not([type="checkbox"]) {
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background-color: var(--paper-raised-min);
  border: 1px solid var(--rule);
  border-bottom-color: var(--rule-strong);
  border-radius: var(--radius-xs);
}
.login-form input:not([type="checkbox"]):hover { border-bottom-color: var(--ink-soft); }

/* Champ ACTIF : arête basse à l'accent, plein en haut, fondu vers le bas sur
   3 px (liseré de la navbar couché sous le champ) — sans halo ni anneau. */
.login-form input:not([type="checkbox"]):focus {
  outline: none;
  background-color: var(--paper-raised);
  border-bottom-color: transparent;
  background-image: linear-gradient(to bottom, var(--accent), transparent);
  background-size: 100% 3px;
  background-position: left bottom;
  background-repeat: no-repeat;
  background-origin: border-box;
}

/* Champ en erreur : cadre et arête au rouge d'erreur, focus compris. */
.login-form input:not([type="checkbox"])[aria-invalid="true"] { border-color: var(--negative); }
.login-form input:not([type="checkbox"])[aria-invalid="true"]:focus {
  border-bottom-color: transparent;
  background-image: linear-gradient(to bottom, var(--negative), transparent);
}

/* Anneau de focus clavier commun (--focus-ring) : bouton, liens, case. */
.login-submit:focus-visible,
.login-links a:focus-visible,
.login-terms a:focus-visible,
.login-terms input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Bouton primaire (elements.css §6 quater) ── */
.login-submit {
  margin-top: 4px;
  padding: 10px 20px;
  font: 400 1rem/1.4 var(--book-serif);
  color: var(--paper-raised);
  background-color: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.login-submit:hover:not(:disabled) { background-color: var(--accent-hover); }
.login-submit:disabled { opacity: 0.45; cursor: progress; }

/* ── Messages ── */
.login-error { margin: 0; color: var(--negative); font-size: 0.875rem; }

/* Bandeau d'information : papier surélevé, filet fin ; teinte d'état à 12 %
   (--positive-tint / --negative-tint de l'application). */
.login-notice {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--paper-raised);
  color: var(--ink);
  font-size: 0.875rem;
}
.login-notice[data-kind="ok"] {
  border-color: var(--positive);
  background: color-mix(in srgb, var(--positive) 12%, var(--paper-raised));
}
.login-notice[data-kind="error"] {
  border-color: var(--negative);
  background: color-mix(in srgb, var(--negative) 12%, var(--paper-raised));
}

/* ── Liens : encre douce, accent au survol (doctrine : accent = interaction) ── */
.login-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 0;
  font-family: var(--book-serif);
  font-size: 0.875rem;
}
.login-links a,
.login-terms a,
.legal-doc a {
  color: var(--ink-soft);
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 3px;
  border-radius: var(--radius-xs);   /* arrondit l'anneau de focus */
}
.login-links a:hover,
.login-terms a:hover,
.legal-doc a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

/* ── Remplissage automatique ──
   Le navigateur peint son propre fond (jaune pâle sous Firefox, bleuté sous
   Chromium) qui casse le thème : recouvert par une ombre interne au fond du
   champ. Cette ombre masque aussi le dégradé du focus : l'arête active est
   alors redessinée par une seconde ombre, posée dessus. */
.login-form input:autofill {
  box-shadow: 0 0 0 100px var(--paper-raised-min) inset;
  -webkit-text-fill-color: var(--ink);
}
.login-form input:-webkit-autofill {
  box-shadow: 0 0 0 100px var(--paper-raised-min) inset;
  -webkit-text-fill-color: var(--ink);
}
.login-form input:autofill:focus {
  box-shadow: 0 -2px 0 var(--accent) inset, 0 0 0 100px var(--paper-raised) inset;
}
.login-form input:-webkit-autofill:focus {
  box-shadow: 0 -2px 0 var(--accent) inset, 0 0 0 100px var(--paper-raised) inset;
}
/* Firefox ajoute son propre halo rouge aux champs :invalid. */
.login-form input:-moz-ui-invalid { box-shadow: none; }

/* Transitions ÉNUMÉRÉES, tempos de l'application ; aucune en mouvement réduit. */
@media (prefers-reduced-motion: no-preference) {
  .login-submit {
    transition: background-color var(--transition-fast), opacity var(--transition-fast);
  }
  .login-form input:not([type="checkbox"]) {
    transition: border-color var(--transition-base), background-color var(--transition-base);
  }
  .login-links a, .login-terms a, .legal-doc a {
    transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
  }
}

/* ── Inscription : acceptation des conditions d'utilisation ── */
.login-form label.login-terms {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink-body);
}
.login-form label.login-terms > span { font-weight: 400; }
.login-terms input { margin: 3px 0 0; flex: 0 0 auto; width: 16px; height: 16px; accent-color: var(--accent); }
.login-terms input[aria-invalid="true"] { outline: 2px solid var(--negative); outline-offset: 2px; }

/* ── Page des conditions d'utilisation (cgu.html) ── */
body.legal-body { display: block; height: auto; }
.legal-shell { width: 100%; max-width: 720px; margin: 0 auto; }
.legal-doc {
  padding: 28px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(var(--shadow-rgb), 0.18);
}
.legal-doc h2 { margin: 0 0 4px; font: 600 1.5rem/1.25 var(--book-serif); color: var(--ink); }
.legal-doc h3 { margin: 26px 0 6px; font: 600 1.1rem/1.3 var(--book-serif); color: var(--ink); }
.legal-doc p { margin: 0 0 10px; }
.legal-meta { color: var(--ink-soft); font-size: 0.8125rem; }

/* ── FORGEWEB — MOBILE ──
   Écran bas ou étroit (téléphone, clavier virtuel ouvert) : body ne force
   plus sa hauteur — un formulaire plus haut que l'écran (inscription) était
   centré, son haut rogné et INATTEIGNABLE. Il part du haut et la page défile.
   dvh : hauteur réelle, barre d'adresse mobile déduite. Encoches : marges
   de sécurité. Les champs sont déjà à 16 px (pas de zoom iOS au focus). */
@media (max-width: 480px), (max-height: 640px) {
  html { height: auto; min-height: 100%; }
  body {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 16px max(12px, env(safe-area-inset-right, 0px))
             max(16px, env(safe-area-inset-bottom, 0px))
             max(12px, env(safe-area-inset-left, 0px));
  }
  :root { --lg-pad: 18px; }
  .login-form h2 { padding-block: 12px; }
  .legal-doc { padding: 18px; }
}
/* Tactile : la case des conditions et les liens offrent une cible suffisante. */
@media (pointer: coarse) {
  .login-terms input { width: 20px; height: 20px; margin-top: 1px; }
  .login-links { gap: 12px 16px; }
  .login-links a { padding: 4px 0; }
  .login-submit { padding-block: 12px; }
}