/*
 * YamiNeko SSO — Custom login styles
 * Design spec: /root/auth-login-design/DESIGN-SPEC.md
 * Visual basis: /root/auth-login-design/clean-mock.html
 *
 * NO external resources. NO inline styles in HTML (CSP-compatible).
 *
 * ── FONT NOTE ──────────────────────────────────────────────────────────────
 * Geist is not self-hosted here. To enable it, uncomment and populate the
 * @font-face blocks below, pointing at your own woff2 files served from
 * the same origin (auth.ocleiria.fr). The fallback stack is used until then.
 *
 * @font-face {
 *   font-family: 'Geist';
 *   font-style:  normal;
 *   font-weight: 400;
 *   font-display: swap;
 *   src: url('/fonts/geist-regular.woff2') format('woff2');
 * }
 * @font-face {
 *   font-family: 'Geist';
 *   font-style:  normal;
 *   font-weight: 500;
 *   font-display: swap;
 *   src: url('/fonts/geist-medium.woff2') format('woff2');
 * }
 * @font-face {
 *   font-family: 'Geist';
 *   font-style:  normal;
 *   font-weight: 600;
 *   font-display: swap;
 *   src: url('/fonts/geist-semibold.woff2') format('woff2');
 * }
 * @font-face {
 *   font-family: 'Geist';
 *   font-style:  normal;
 *   font-weight: 700;
 *   font-display: swap;
 *   src: url('/fonts/geist-bold.woff2') format('woff2');
 * }
 * ───────────────────────────────────────────────────────────────────────────
 */

/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
  --accent:           #6d5dfc;
  --accent-hover:     #5b4ce0;
  --accent-ring:      rgba(109, 93, 252, 0.14);
  --accent-ring-soft: rgba(109, 93, 252, 0.40);
  --accent-ring-mid:  rgba(109, 93, 252, 0.55);
  --ink:              #18181b;
  --text-strong:      #3f3f46;
  --text-medium:      #52525b;
  --muted:            #71717a;
  --muted-light:      #a1a1aa;
  --faint:            #c4c4c9;
  --border:           #e4e4e7;
  --border-hover:     #d4d4d8;
  --divider:          #ececec;
  --hover-surface:    #f5f5f5;
  --wa-icon-bg:       #f4f2ff;
  --page-bg:          #fafaf9;
  --card-bg:          #ffffff;
  --panel-gradient:   radial-gradient(ellipse at 30% 65%, #1c1630 0%, #0d0c12 100%);
  --btn-shadow:       0 1px 2px rgba(16, 24, 40, 0.10), 0 6px 18px -8px rgba(109, 93, 252, 0.55);
  --font:             'Geist', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-mono:        'Geist', ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, monospace;
}

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

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

body {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--page-bg);
}

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes ynPulse {
  0%   { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1.7); opacity: 0;   }
}

@keyframes ynSpin {
  to { transform: rotate(360deg); }
}

/* ── Tabular numbers (financial/code figures) ──────────────────────────── */
.tabular {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* ── Page layout ────────────────────────────────────────────────────────── */
.yn-page {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background: var(--page-bg);
}

/* ── Left brand panel ───────────────────────────────────────────────────── */
#yn-panel {
  width: 42%;
  flex: none;
  background: var(--panel-gradient);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 52px;
  position: relative;
  overflow: hidden;
}

.yn-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.yn-brand .mark {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.10);
  display: flex;
  align-items: center;
  justify-content: center;
}

.yn-brand .wordmark {
  color: #ffffff;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.yn-hero {
  position: relative;
  margin-top: -60px;
}

.yn-hero h1 {
  margin: 0;
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: #ffffff;
}

.yn-brand-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.28);
  position: relative;
}

.yn-brand-foot span {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ── Right form column ──────────────────────────────────────────────────── */
#yn-form-col {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
}

.yn-content {
  width: 100%;
  max-width: 384px;
}

/* ── Mobile logo (visible below 720px) ─────────────────────────────────── */
#yn-mobile-logo {
  display: none;
  align-items: center;
  gap: 10px;
  margin-bottom: 36px;
}

#yn-mobile-logo .mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

#yn-mobile-logo span {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}

/* ── Screen container ───────────────────────────────────────────────────── */
.yn-screen {
  display: none;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.yn-screen.is-active {
  display: block;
  opacity: 1;
  transform: translateX(0);
}

/* Prevent transition flash on initial render */
.yn-screen.is-init {
  transition: none;
}

/* ── Headings ───────────────────────────────────────────────────────────── */
.yn-head {
  margin-bottom: 30px;
}

.yn-head--totp {
  margin-bottom: 28px;
}

.yn-head h2 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.yn-head p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Forms / fields ─────────────────────────────────────────────────────── */
.yn-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.yn-form--totp {
  gap: 20px;
}

.yn-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.yn-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.yn-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-strong);
}

.yn-input {
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: var(--card-bg);
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  /* Prevent browser autocomplete styles from overriding design */
  appearance: none;
  -webkit-appearance: none;
}

.yn-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.yn-input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Override browser autofill yellow tint */
.yn-input:-webkit-autofill,
.yn-input:-webkit-autofill:hover,
.yn-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--card-bg) inset;
  -webkit-text-fill-color: var(--ink);
  transition: background-color 5000s ease-in-out 0s;
}

/* ── TOTP digit inputs ──────────────────────────────────────────────────── */
#yn-totp-inputs {
  display: flex;
  gap: 10px;
}

.yn-digit {
  flex: 1;
  min-width: 0;
  height: 58px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  background: var(--card-bg);
  outline: none;
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  /* Disable spinners on number inputs if type ever changes */
  -moz-appearance: textfield;
}

.yn-digit:focus,
.yn-digit:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.yn-digit.is-filled {
  border-color: var(--accent);
}

/* ── Primary button ─────────────────────────────────────────────────────── */
.yn-btn-primary {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 11px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: var(--btn-shadow);
  transition: background 0.18s ease, transform 0.06s ease, opacity 0.18s ease;
  /* Prevent double-submit while loading */
  position: relative;
}

.yn-btn-primary--login {
  margin-top: 4px;
}

.yn-btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.yn-btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.yn-btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.yn-btn-primary:focus-visible {
  outline: none;
  box-shadow: var(--btn-shadow), 0 0 0 3px var(--accent-ring);
}

/* Loading spinner inside button */
.yn-btn-primary .yn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: ynSpin 0.65s linear infinite;
  flex: none;
}

.yn-btn-primary.is-loading .yn-spinner {
  display: block;
}

.yn-btn-primary.is-loading .yn-btn-label {
  opacity: 0.8;
}

/* ── Secondary button (security key) ───────────────────────────────────── */
.yn-btn-secondary {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--card-bg);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 11px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.yn-btn-secondary:hover {
  background: var(--hover-surface);
  border-color: var(--border-hover);
}

.yn-btn-secondary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
  border-color: var(--accent);
}

/* ── Back button ────────────────────────────────────────────────────────── */
.yn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 28px;
  font-family: inherit;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease;
}

.yn-back--webauthn {
  margin-bottom: 36px;
}

.yn-back:hover {
  color: var(--ink);
}

.yn-back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Ghost button ───────────────────────────────────────────────────────── */
.yn-ghost {
  margin-top: 12px;
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  color: var(--muted);
  border: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease;
}

.yn-ghost:hover {
  color: var(--ink);
}

.yn-ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Links ──────────────────────────────────────────────────────────────── */
.yn-link {
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
  white-space: nowrap;
}

.yn-link:hover {
  color: var(--accent);
}

.yn-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.yn-admin-help {
  margin: 24px 0 0;
  font-size: 13px;
  color: var(--muted-light);
  text-align: center;
}

.yn-admin-help a {
  color: var(--text-medium);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

.yn-admin-help a:hover {
  color: var(--accent);
}

/* ── Divider ────────────────────────────────────────────────────────────── */
.yn-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted-light);
}

.yn-divider .line {
  flex: 1;
  height: 1px;
  background: var(--divider);
}

.yn-divider .txt {
  font-size: 12px;
  font-weight: 500;
}

/* ── Error / status messages ────────────────────────────────────────────── */
.yn-error {
  display: none;
  padding: 11px 14px;
  background: #fff1f1;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 13.5px;
  color: #b91c1c;
  line-height: 1.45;
}

.yn-error.is-visible {
  display: block;
}

/* Failed-attempt hint (brute-force warning) */
.yn-error--warn {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

/* ── WebAuthn screen ────────────────────────────────────────────────────── */
.yn-webauthn {
  text-align: center;
}

.yn-wa-icon {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 28px;
  overflow: visible;
}

.yn-wa-icon .ring {
  position: absolute;
  border-radius: 50%;
}

.yn-wa-icon .ring-outer {
  inset: -20px;
  border: 2px solid var(--accent-ring-soft);
  animation: ynPulse 2.4s ease-out infinite 0.6s;
}

.yn-wa-icon .ring-inner {
  inset: -8px;
  border: 2px solid var(--accent-ring-mid);
  animation: ynPulse 2.4s ease-out infinite;
}

.yn-wa-icon .disc {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--wa-icon-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.yn-webauthn h2 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.yn-webauthn > p {
  margin: 0 auto 28px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
  max-width: 300px;
}

/* WebAuthn status variant – waiting for key */
.yn-wa-status {
  display: none;
  margin: 0 auto 20px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 280px;
}

.yn-wa-status.is-visible {
  display: block;
}

/* ── "Keep me logged in" checkbox row ───────────────────────────────────── */
.yn-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-strong);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.yn-remember input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.yn-remember input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Copyright footer ───────────────────────────────────────────────────── */
.yn-copyright {
  margin: 36px 0 0;
  font-size: 11.5px;
  color: var(--faint);
  text-align: center;
  letter-spacing: 0.015em;
}

/* ── ARIA / focus management helpers ────────────────────────────────────── */
[aria-hidden="true"] {
  pointer-events: none;
}

/* Visually hidden but accessible to screen readers */
.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;
}

/* ── Reduced-motion support ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .yn-wa-icon .ring-outer,
  .yn-wa-icon .ring-inner {
    animation: none;
  }

  .yn-screen {
    transition: none;
  }

  .yn-btn-primary,
  .yn-btn-secondary,
  .yn-back,
  .yn-ghost,
  .yn-link,
  .yn-input,
  .yn-digit {
    transition: none;
  }
}

/* ── Logos réels (mono noir/blanc, jamais coloré) ──────────────────────── */
.yn-brand .yn-logo { height: 30px; width: auto; display: block; }
#yn-mobile-logo .mark .yn-logo-sm { height: 18px; width: auto; display: block; }
.yn-watermark {
  position: absolute;
  width: 360px;
  height: auto;
  opacity: 0.05;
  right: -70px;
  bottom: 40px;
  pointer-events: none;
  user-select: none;
}

/* ── Footer (corrige le copyright blanc-sur-blanc) ─────────────────────── */
.yn-footer { margin: 36px 0 0; text-align: center; }
.yn-footer .yn-copyright { margin: 0; color: var(--muted); }
.yn-powered { margin: 4px 0 0; font-size: 11px; color: var(--muted); letter-spacing: 0.015em; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  #yn-panel {
    display: none !important;
  }

  #yn-form-col {
    justify-content: flex-start !important;
    padding: 40px 24px !important;
  }

  #yn-mobile-logo {
    display: flex !important;
  }

  /* Sur téléphone : logo + « YamiNeko SSO » + formulaire seulement. */
  .yn-footer { display: none !important; }
}
