/* ═══════════════════════════════════════════════════════════════════════════
   NOVIRA — Authentication Shell (Login & OTP Verification)
   Neutral-black canvas (#0D0D0F), inset warm tonal Folded Portal brand panel,
   email-first 365px auth column, warm-sand primary action (#E7D5BA).
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --auth-canvas: #0D0D0F;
  --auth-brand-base: #171719;
  --auth-brand-mid: #1D1B19;
  --auth-brand-warm: #302920;
  --auth-brand-border: rgba(255, 255, 255, 0.07);
  --auth-ivory: #F3E8D6;
  --auth-sand: #E7D5BA;
  --auth-sand-hover: #EFE1CC;
  --auth-sand-ink: #191612;
  --auth-input-bg: #19191C;
  --auth-input-hover: #1E1E22;
  --auth-border: #38383D;
  --auth-border-hover: #4C4C54;
  --auth-sep: #303035;
  --auth-text: #F2F2F2;
  --auth-text-secondary: #A4A4A9;
  --auth-text-label: #D2D2D5;
  --auth-text-muted: #8E8E96;
  --auth-text-legal: #A09FA4;
  --auth-text-legal-link: #C8C8CD;
  --auth-error-fg: var(--novira-status-error-fg, #DDA393);
  --auth-error-bg: var(--novira-status-error-bg, #241D1A);
  --auth-error-border: var(--novira-status-error-border, #63453D);
  --auth-font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --auth-radius-panel: 16px;
  --auth-radius-control: 8px;
  --auth-control-h: 49px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--auth-canvas);
  color: var(--auth-text);
  color-scheme: dark;
  font-family: var(--auth-font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.auth-shell {
  display: grid;
  grid-template-columns: 53% 47%;
  min-height: 100svh;
  min-height: 100dvh;
  padding: 16px;
  background: var(--auth-canvas);
}

/* ── Left: Inset Folded Portal Brand Panel ─────────────────────────────── */
.auth-brand {
  position: relative;
  isolation: isolate;
  border: 1px solid var(--auth-brand-border);
  border-radius: var(--auth-radius-panel);
  overflow: hidden;
  min-height: 580px;
  background: radial-gradient(
    ellipse at 50% 50%,
    var(--auth-brand-warm) 0%,
    var(--auth-brand-mid) 50%,
    var(--auth-brand-base) 85%
  );
  display: grid;
  place-items: center;
}

.auth-brand-home {
  position: absolute;
  left: 38px;
  top: 35px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border-radius: 6px;
  z-index: 2;
}

.auth-brand-home:focus-visible {
  outline: 2px solid var(--auth-sand);
  outline-offset: 4px;
}

.auth-brand-lockup {
  display: block;
  width: 132px;
  height: auto;
}

.auth-brand-geometry {
  width: 82%;
  max-width: 640px;
  height: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: -1;
  opacity: 0.22;
  pointer-events: none;
}

.auth-brand-mark {
  width: clamp(160px, 18vw, 270px);
  margin: 0;
}

/* ── Right: Authentication Workspace ───────────────────────────────────── */
.auth-panel {
  display: grid;
  place-items: center;
  padding: 40px 32px;
  position: relative;
}

.auth-card {
  width: 100%;
  max-width: 365px;
}

.auth-mobile-home {
  display: none;
  margin-bottom: 36px;
  text-decoration: none;
  border-radius: 6px;
}

.auth-mobile-home:focus-visible {
  outline: 2px solid var(--auth-sand);
  outline-offset: 4px;
}

.auth-mobile-lockup {
  display: block;
  width: 120px;
  height: auto;
}

.auth-title {
  font-size: 32px;
  font-weight: 550;
  line-height: 1.15;
  letter-spacing: -1.2px;
  color: var(--auth-text);
  margin: 0 0 13px;
}

.auth-subtitle {
  font-size: 14px;
  line-height: 1.65;
  color: var(--auth-text-secondary);
  margin: 0 0 36px;
}

.auth-subtitle strong {
  color: var(--auth-text);
  font-weight: 550;
  word-break: break-word;
}

.auth-inline-link {
  color: var(--auth-sand);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
  white-space: nowrap;
}

.auth-inline-link:hover {
  color: var(--auth-ivory);
}

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

/* ── Submission-Level Bordered Alert (Terracotta Semantic Tokens) ─────── */
.auth-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin: 0 0 24px;
  border-radius: var(--auth-radius-control);
  border: 1px solid var(--auth-error-border);
  background: var(--auth-error-bg);
  color: var(--auth-error-fg);
  font-size: 13px;
  line-height: 1.5;
}

.auth-error svg {
  flex: none;
  margin-top: 2px;
  color: var(--auth-error-fg);
}

/* ── Understated Inline Field-Level Validation ────────────────────────── */
.auth-field-error {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 8px 0 0;
  color: var(--auth-error-fg);
  font-size: 12.5px;
  line-height: 1.45;
}

.auth-field-error[hidden] {
  display: none;
}

.auth-field-error svg {
  flex: none;
  margin-top: 2px;
  color: var(--auth-error-fg);
}

.auth-field-error--otp {
  margin: -12px 0 18px;
}

/* ── Form Controls ─────────────────────────────────────────────────────── */
.auth-label {
  display: block;
  font-size: 13px;
  font-weight: 450;
  color: var(--auth-text-label);
}

.auth-field {
  width: 100%;
  height: var(--auth-control-h);
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius-control);
  background: var(--auth-input-bg);
  color: var(--auth-text);
  font: inherit;
  font-size: 14px;
  padding: 0 14px;
  margin-top: 9px;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.auth-field::placeholder {
  color: var(--auth-text-muted);
}

.auth-field:hover {
  border-color: var(--auth-border-hover);
}

.auth-field:focus {
  outline: none;
  border-color: var(--auth-sand);
  box-shadow: 0 0 0 1px rgba(231, 213, 186, 0.35);
}

.auth-field:focus-visible {
  outline: 2px solid var(--auth-sand);
  outline-offset: 2px;
  border-color: var(--auth-border-hover);
  box-shadow: none;
}

.auth-field.is-error,
.auth-field[aria-invalid="true"] {
  border-color: var(--auth-error-border);
  background: var(--auth-error-bg);
}

.auth-field.is-error:focus,
.auth-field[aria-invalid="true"]:focus {
  border-color: var(--auth-error-fg);
  box-shadow: 0 0 0 1px rgba(221, 163, 147, 0.32);
}

.auth-field.is-error:focus-visible,
.auth-field[aria-invalid="true"]:focus-visible {
  outline: 2px solid var(--auth-error-fg);
  outline-offset: 2px;
  border-color: var(--auth-error-border);
  box-shadow: none;
}

.auth-remember {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 21px 0 19px;
  font-size: 13px;
  color: #B7B7BD;
  cursor: pointer;
  user-select: none;
}

.auth-remember input[type="checkbox"] {
  accent-color: var(--auth-sand);
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

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

/* ── Primary & Secondary Action Buttons ────────────────────────────────── */
.auth-btn {
  height: var(--auth-control-h);
  width: 100%;
  border-radius: var(--auth-radius-control);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.auth-btn:focus-visible {
  outline: 2px solid var(--auth-sand);
  outline-offset: 3px;
}

.auth-btn--primary {
  background: var(--auth-sand);
  color: var(--auth-sand-ink);
  border: 1px solid transparent;
}

.auth-btn--primary:hover:not(:disabled) {
  background: var(--auth-sand-hover);
}

.auth-btn--primary:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.auth-btn-arrow {
  position: absolute;
  right: 16px;
  font-size: 19px;
  line-height: 1;
}

.auth-btn--secondary {
  background: transparent;
  border: 1px solid var(--auth-border);
  color: var(--auth-text);
}

.auth-btn--secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--auth-border-hover);
}

.auth-btn--secondary svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.auth-sep {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--auth-text-secondary);
  font-size: 12px;
  margin: 23px 0;
}

.auth-sep::before,
.auth-sep::after {
  content: '';
  height: 1px;
  background: var(--auth-sep);
  flex: 1;
}

.auth-legal {
  font-size: 12px;
  line-height: 1.65;
  margin: 25px 0 0;
  color: var(--auth-text-legal);
}

.auth-legal a {
  color: var(--auth-text-legal-link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-legal a:hover {
  color: var(--auth-text);
}

.auth-legal a:focus-visible {
  outline: 2px solid var(--auth-sand);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ── OTP Verification Inputs & Resend Controls ─────────────────────────── */
.auth-otp-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 22px;
}

.auth-otp-box {
  width: 100%;
  height: 54px;
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius-control);
  background: var(--auth-input-bg);
  color: var(--auth-text);
  font-family: var(--auth-font-sans);
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  caret-color: var(--auth-sand);
  transition: border-color 160ms ease, background-color 160ms ease;
}

.auth-otp-box:hover {
  border-color: var(--auth-border-hover);
}

.auth-otp-box.is-filled {
  border-color: rgba(231, 213, 186, 0.52);
  background: var(--auth-input-hover);
}

.auth-otp-box:focus {
  outline: none;
  border-color: var(--auth-sand);
  box-shadow: 0 0 0 1px rgba(231, 213, 186, 0.4);
}

.auth-otp-box:focus-visible {
  outline: 2px solid var(--auth-sand);
  outline-offset: 2px;
  border-color: var(--auth-border-hover);
  box-shadow: none;
}

.auth-otp-box.is-error,
.auth-otp-box[aria-invalid="true"] {
  border-color: var(--auth-error-border);
  background: var(--auth-error-bg);
}

.auth-otp-box.is-error:focus,
.auth-otp-box[aria-invalid="true"]:focus {
  border-color: var(--auth-error-fg);
  box-shadow: 0 0 0 1px rgba(221, 163, 147, 0.35);
}

.auth-otp-box.is-error:focus-visible,
.auth-otp-box[aria-invalid="true"]:focus-visible {
  outline: 2px solid var(--auth-error-fg);
  outline-offset: 2px;
  border-color: var(--auth-error-border);
  box-shadow: none;
}

.auth-resend-wrap {
  margin-top: 20px;
}

.auth-timer {
  font-size: 13px;
  line-height: 1.5;
  color: var(--auth-text-secondary);
  text-align: center;
  margin: 0;
}

.auth-timer strong {
  color: var(--auth-text);
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}

.auth-back-row {
  margin-top: 24px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--auth-text-legal);
}

.auth-back-row a {
  color: var(--auth-text-legal-link);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-back-row a:hover {
  color: var(--auth-text);
}

/* ── Short Desktop Viewports (1280x720, 1366x768) ──────────────────────── */
@media (max-height: 760px) and (min-width: 861px) {
  .auth-brand {
    min-height: 520px;
  }

  .auth-panel {
    padding: 24px 32px;
  }
}

/* ── Tablet & Mobile: Prioritise Authentication Interface ──────────────── */
@media (max-width: 860px) {
  .auth-shell {
    display: block;
    padding: 0;
  }

  .auth-brand {
    display: none;
  }

  .auth-panel {
    min-height: 100svh;
    min-height: 100dvh;
    padding: 40px 24px;
  }

  .auth-mobile-home {
    display: inline-flex;
    align-items: center;
  }

  .auth-title {
    font-size: 29px;
  }
}

@media (max-width: 420px) {
  .auth-panel {
    align-content: start;
    padding: 44px 20px 36px;
  }

  .auth-otp-row {
    gap: 8px;
  }

  .auth-otp-box {
    height: 50px;
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-field,
  .auth-btn,
  .auth-otp-box {
    transition: none;
  }
}
