/**
 * frontend/css/login.css — KIDAB Login Page Styles
 * Version: 1.0.1 | Updated: 2026-05-18 | Author: Sentinel Mesh
 * © 2026 Sentinel Mesh
 *
 * Inherits from tokens.css exclusively — no page-local :root overrides (M-S41-02).
 * File-scoped opacity constants below are derived from tokens.css brand palette only.

 */

/* ─────────────────────────────────────────────
   §0 — SKIP NAV (WCAG 2.2 §2.4.1)
   ───────────────────────────────────────────── */
.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;
}
.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto; height: auto;
  padding: var(--space-2) var(--space-4);
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 2px solid var(--color-brand-gold);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  z-index: var(--z-toast, 500);
  text-decoration: none;
}

/* ─────────────────────────────────────────────
   §1 — PAGE SHELL
   ───────────────────────────────────────────── */
.page-login {
  min-height: 100vh;
  background: var(--surface-primary);
  color: var(--text-primary);
}

.login-shell {
  display: grid;
  grid-template-columns: 2fr 3fr;
  min-height: 100vh;
}

/* ─────────────────────────────────────────────
   §2 — BRAND PANEL (left column — always dark)
   ───────────────────────────────────────────── */
.login-brand {
  position: relative;
  /* Brand panel is always dark regardless of theme.
     --surface-tertiary fallback #0d0b08 applied if token absent in tokens.css. */
  background: var(--surface-tertiary, #0d0b08);
  padding: var(--space-12) var(--space-10);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  isolation: isolate;
}

/* Geometric grid overlay */
.login-brand::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(198, 156, 62, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(198, 156, 62, 0.07) 1px, transparent 1px);
  background-size: 40px 40px;
  z-index: 0;
  pointer-events: none;
}

/* Radial brand glow */
.login-brand::after {
  content: '';
  position: absolute;
  top: 25%;
  left: -30%;
  width: 160%;
  height: 70%;
  background: radial-gradient(
    ellipse at 30% 50%,
    rgba(198, 156, 62, 0.1) 0%,
    transparent 60%
  );
  z-index: 0;
  pointer-events: none;
}

.login-brand__inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.login-brand__logo {
  display: inline-flex;
  flex-direction: column;
  gap: var(--space-1);
}

.login-brand__logo-text {
  font-family: var(--font-brand, 'Georgia', serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-brand-gold);
  letter-spacing: -0.02em;
  line-height: 1;
}

.login-brand__logo-ar {
  font-family: var(--font-brand, 'Georgia', serif);
  font-size: 1.125rem;
  color: rgba(198, 156, 62, 0.6);
  letter-spacing: 0.05em;
  line-height: 1;
}

.login-brand__copy {
  margin-top: auto;
  padding-top: var(--space-12);
}

.login-brand__tagline {
  font-family: var(--font-brand, 'Georgia', serif);
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1.35;
  color: #e8e2d6;
  margin-bottom: var(--space-3);
  letter-spacing: -0.01em;
}

.login-brand__sub {
  font-size: 0.9375rem;
  color: rgba(232, 226, 214, 0.5);
  line-height: 1.6;
  max-width: 26ch;
}

/* Decorative concentric arc — bottom-right of brand panel */
.login-brand__pattern {
  position: absolute;
  bottom: -80px;
  right: -80px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  border: 1px solid rgba(198, 156, 62, 0.1);
  z-index: 0;
  pointer-events: none;
}
.login-brand__pattern::before {
  content: '';
  position: absolute;
  inset: 48px;
  border-radius: 50%;
  border: 1px solid rgba(198, 156, 62, 0.07);
}
.login-brand__pattern::after {
  content: '';
  position: absolute;
  inset: 96px;
  border-radius: 50%;
  border: 1px solid rgba(198, 156, 62, 0.04);
}

/* ─────────────────────────────────────────────
   §3 — FORM PANEL (right column)
   ───────────────────────────────────────────── */
.login-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-10) var(--space-6);
  background: var(--surface-primary);
}

.login-form-wrap {
  width: 100%;
  max-width: 440px;
}

/* ─────────────────────────────────────────────
   §4 — PAGE HEADER
   ───────────────────────────────────────────── */
.login-header {
  margin-bottom: var(--space-8);
}

.login-title {
  font-family: var(--font-brand, 'Georgia', serif);
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin-bottom: var(--space-1);
}

.login-subtitle {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ─────────────────────────────────────────────
   §5 — VERIFIED BANNER
   ───────────────────────────────────────────── */
.login-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: var(--space-6);
  border: 1px solid transparent;
  line-height: 1.4;
}

.login-banner--success {
  background: rgba(34, 197, 94, 0.08);
  color: #15803d;
  border-color: rgba(34, 197, 94, 0.2);
}

[data-theme='dark'] .login-banner--success {
  background: rgba(34, 197, 94, 0.06);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.15);
}

.login-banner__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────
   §6 — TAB SWITCHER
   ───────────────────────────────────────────── */
.login-tabs {
  display: flex;
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.login-tab {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s ease;
  text-align: center;
}

.login-tab:hover {
  color: var(--text-primary);
}

.login-tab[aria-selected='true'] {
  color: var(--color-brand-gold);
  border-bottom-color: var(--color-brand-gold);
  font-weight: 600;
}

.login-tab:focus-visible {
  outline: 2px solid var(--color-brand-gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

/* ─────────────────────────────────────────────
   §7 — FORM LAYOUT
   ───────────────────────────────────────────── */
.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.login-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.login-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ─────────────────────────────────────────────
   §8 — INPUTS
   ───────────────────────────────────────────── */
.login-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
  box-sizing: border-box;
}

.login-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.45;
}

.login-input:hover {
  border-color: var(--border-strong);
}

.login-input:focus {
  outline: none;
  border-color: var(--color-brand-gold);
  box-shadow: 0 0 0 3px rgba(198, 156, 62, 0.12);
}

/* Monospace input — recovery codes */
.login-input--mono {
  font-family: var(--font-mono, 'Courier New', monospace);
  letter-spacing: 0.08em;
  font-size: 0.875rem;
}

/* Password input container — provides space for the reveal button */
.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.login-input-wrap .login-input {
  padding-right: var(--space-10);
}

/* ─────────────────────────────────────────────
   §9 — PASSWORD REVEAL TOGGLE
   ───────────────────────────────────────────── */
.login-reveal {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.1s ease;
  padding: 0;
}

.login-reveal:hover {
  color: var(--text-primary);
}

.login-reveal:focus-visible {
  outline: 2px solid var(--color-brand-gold);
  outline-offset: 1px;
}

/* Icon visibility hooks — toggled via HTML hidden attribute by login.js wireReveal().
   These rules anchor the classes so they are not flagged as dead code. */
.login-reveal__icon--show,
.login-reveal__icon--hide {
  display: block;
  width: 18px;
  height: 18px;
}

/* ─────────────────────────────────────────────
   §10 — TURNSTILE
   ───────────────────────────────────────────── */
.login-turnstile {
  margin-top: calc(-1 * var(--space-1));
}

/* ─────────────────────────────────────────────
   §11 — INLINE ERROR
   ───────────────────────────────────────────── */
.login-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: 0.875rem;
  color: #dc2626;
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.15);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  line-height: 1.5;
  margin-top: calc(-1 * var(--space-1));
}

[data-theme='dark'] .login-error {
  color: #f87171;
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.18);
}

/* ─────────────────────────────────────────────
   §12 — SUBMIT BUTTONS
   ───────────────────────────────────────────── */
.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-6);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--surface-primary);
  background: var(--color-brand-gold);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  letter-spacing: 0.01em;
}

.login-btn:hover:not(:disabled) {
  opacity: 0.9;
  box-shadow: 0 4px 16px rgba(198, 156, 62, 0.28);
}

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

.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.login-btn:focus-visible {
  outline: 2px solid var(--color-brand-gold);
  outline-offset: 3px;
}

/* Passkey button variant — outlined, neutral */
.login-btn--passkey {
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.login-btn--passkey:hover:not(:disabled) {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.login-btn--passkey:hover:not(:disabled),
.login-btn--passkey:active:not(:disabled) {
  opacity: 1;
}

.login-btn__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ─────────────────────────────────────────────
   §13 — TEXT LINKS
   ───────────────────────────────────────────── */
.login-link {
  font-size: 0.875rem;
  color: var(--color-brand-gold);
  text-decoration: none;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.login-link:hover {
  text-decoration: underline;
}

.login-link:focus-visible {
  outline: 2px solid var(--color-brand-gold);
  outline-offset: 2px;
  border-radius: 2px;
}

.login-link--sm {
  font-size: 0.8125rem;
}

.login-link--center {
  text-align: center;
  width: 100%;
  display: block;
  padding: var(--space-1) 0;
}

.login-link--muted {
  color: var(--text-secondary);
  font-weight: 400;
}

.login-link--muted:hover {
  color: var(--text-primary);
  text-decoration: none;
}

/* ─────────────────────────────────────────────
   §14 — RECOVERY FORM
   ───────────────────────────────────────────── */
.login-recovery-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* ─────────────────────────────────────────────
   §15 — FOOTER
   ───────────────────────────────────────────── */
.login-footer {
  margin-top: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
  text-align: center;
}

.login-footer__text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.login-footer__links {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.login-footer__sep {
  color: var(--border-strong);
  font-size: 0.75rem;
  line-height: 1;
  user-select: none;
}

/* ─────────────────────────────────────────────
   §16 — RESPONSIVE
   ───────────────────────────────────────────── */
@media (max-width: 960px) {
  .login-shell {
    grid-template-columns: 1fr 1.5fr;
  }

  .login-brand__tagline {
    font-size: 1.5rem;
  }
}

@media (max-width: 768px) {
  .login-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .login-brand {
    padding: var(--space-5) var(--space-5);
    min-height: 0;
  }

  .login-brand::before,
  .login-brand::after {
    display: none;
  }

  .login-brand__pattern {
    display: none;
  }

  .login-brand__inner {
    flex-direction: row;
    align-items: center;
    height: auto;
  }

  .login-brand__copy {
    display: none;
  }

  .login-brand__logo {
    flex-direction: row;
    align-items: baseline;
    gap: var(--space-3);
  }

  .login-brand__logo-text {
    font-size: 1.375rem;
  }

  .login-brand__logo-ar {
    font-size: 0.875rem;
  }

  .login-form-panel {
    padding: var(--space-8) var(--space-5);
    align-items: flex-start;
  }

  .login-title {
    font-size: 1.625rem;
  }
}

@media (max-width: 480px) {
  .login-form-panel {
    padding: var(--space-6) var(--space-4);
  }

  .login-form-wrap {
    max-width: 100%;
  }

  .login-brand {
    padding: var(--space-4) var(--space-4);
  }
}