/* ============ auth-v2.css — agent portal (login / signup / reset), letterpress desk ============
   Shares the landing-v2 design language: Fraunces display serif, Creato body, JetBrains
   mono labels, brand deep/pale tokens, and the wax-seal + ink motif. Self-contained on
   purpose — the landing sheet is page-scoped and carries ~900 lines this page never uses. */

@font-face { font-family: 'Creato Display'; src: url('/static/fonts/CreatoDisplay-Regular.otf') format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Creato Display'; src: url('/static/fonts/CreatoDisplay-Medium.otf') format('opentype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Creato Display'; src: url('/static/fonts/CreatoDisplay-Bold.otf') format('opentype'); font-weight: 700; font-display: swap; }

/* ---- Brand tokens (mirror landing-v2.css) ---- */
body[data-brand="bq"] {
  --deep: #0a2a1a; --deep2: #071f13; --pale: #e3f1e8; --pale2: #d5e9dd;
  --ink-deep: #eaf6ef; --ink-pale: #143524; --brand: #3a8a5c;
  --accent-deep: #6fc492; --cta-pale: #2e7a4f; --sand: #cfc0a0;
}
body[data-brand="closio"] {
  --deep: #0c2236; --deep2: #081a2b; --pale: #e8f1f8; --pale2: #d9e8f4;
  --ink-deep: #eaf3fb; --ink-pale: #16314a; --brand: #5b9bd5;
  --accent-deep: #8ec3ee; --cta-pale: #3f7fb8; --sand: #c9c3b4;
}
body[data-brand="tpi"] {
  --deep: #101d3f; --deep2: #0a1530; --pale: #e9eefb; --pale2: #dbe4f7;
  --ink-deep: #ecf0fc; --ink-pale: #16234a; --brand: #1e40af;
  --accent-deep: #8da6f2; --cta-pale: #1e40af; --sand: #c9c0ab;
}

:root {
  --ease: cubic-bezier(0.33, 0, 0.11, 1);
  --dur: 0.8s; --dur-fast: 0.5s; --stagger-sm: 0.12s;
  --paper: #ffffff; --paper-line: #e5e7eb; --paper-ink: #111827;
  --paper-mute: #6b7280; --paper-faint: #9ca3af;
  --ink-red: #b91c1c; --approve: #047857; --approve-bg: rgba(5, 150, 105, 0.10);
}

/* ---- Base ---- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  font-family: 'Creato Display', 'Inter', -apple-system, sans-serif;
  background: var(--deep); color: var(--ink-deep);
  font-size: 17px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
.mono { font-family: 'JetBrains Mono', monospace; }
.hand { font-family: 'Caveat', cursive; }
.display { font-family: 'Fraunces', Georgia, serif; font-optical-sizing: auto;
  font-weight: 480; line-height: 1.08; letter-spacing: -0.005em; }
.hidden { display: none !important; }

/* ---- Atmosphere: desk-lamp glow + corner vignettes, CSS only ---- */
.auth-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(110vmax 80vmax at 78% -12%, rgba(255,255,255,0.07), transparent 58%),
    radial-gradient(90vmax 70vmax at -8% 108%, rgba(0,0,0,0.42), transparent 55%),
    radial-gradient(56vmax 44vmax at 64% 50%, rgba(255,255,255,0.035), transparent 62%);
}
.auth-bg::after { /* faint paper-grain so the deep isn't a dead flat */
  content: ''; position: absolute; inset: 0; opacity: 0.5;
  background-image: radial-gradient(rgba(255,255,255,0.022) 1px, transparent 1.2px);
  background-size: 26px 26px;
}

/* ---- Shell: rail + stage ---- */
.auth-shell { position: relative; z-index: 1; min-height: 100vh;
  width: min(1240px, calc(100% - 48px)); margin-inline: auto;
  display: grid; grid-template-columns: 1.04fr 1fr; align-items: center;
  gap: clamp(40px, 6vw, 96px); padding: 48px 0; }

/* ---- Left rail ---- */
.rail { display: flex; flex-direction: column; gap: 0; max-width: 520px; }
.rail__logo { display: inline-block; width: fit-content; }
.rail__logo img { height: 54px; width: auto; }
.rail__kicker { margin-top: 46px; font-size: 12px; letter-spacing: 2.2px;
  text-transform: uppercase; opacity: 0.62; font-weight: 500; }
.rail__head { margin-top: 14px; font-size: clamp(40px, 4.6vw, 62px); }
.rail__head em { font-style: normal; color: var(--accent-deep); }
.rail__sub { margin-top: 18px; font-size: 17.5px; line-height: 1.6; opacity: 0.78; max-width: 42ch; }
.rail__stats { margin-top: 38px; display: flex; gap: 34px; }
.rail__stats > div { display: flex; flex-direction: column; gap: 3px; }
.rail__stats .num { font-size: 21px; color: var(--accent-deep); }
.rail__stats label { font-size: 11.5px; letter-spacing: 1.6px; text-transform: uppercase; opacity: 0.55; }
.rail__note { margin-top: 40px; font-size: 23px; rotate: -2deg; width: fit-content;
  color: var(--sand); opacity: 0.92; }
.rail__foot { margin-top: 56px; font-size: 12px; opacity: 0.5; letter-spacing: 0.4px; }
.rail__foot a:hover { text-decoration: underline; }

/* staggered rail entrance (one-shot) */
.rail > * { opacity: 0; transform: translateY(22px);
  animation: rail-in var(--dur) var(--ease) forwards;
  animation-delay: calc(var(--ri, 0) * var(--stagger-sm)); }
@keyframes rail-in { to { opacity: 1; transform: none; } }
.rail__logo { animation-name: rail-in-logo; }
@keyframes rail-in-logo { to { opacity: 1; transform: none; } }

/* ---- Stage + paper sheet ---- */
.stage { position: relative; display: flex; justify-content: center; }
.sheet { position: relative; width: min(460px, 100%);
  background: var(--paper); color: var(--paper-ink);
  border: 1px solid var(--paper-line); border-radius: 16px;
  padding: 44px 42px 38px;
  box-shadow: 0 32px 64px rgba(0,0,0,0.4), 0 6px 18px rgba(0,0,0,0.22);
  opacity: 0; transform: translateY(26px);
  animation: sheet-in var(--dur) var(--ease) 0.12s forwards; }
@keyframes sheet-in { to { opacity: 1; transform: none; } }
/* ruled left margin, like a ledger page */
.sheet::before { content: ''; position: absolute; left: 26px; top: 18px; bottom: 18px;
  width: 1px; background: linear-gradient(to bottom, transparent, #f3d3d3 12%, #f3d3d3 88%, transparent); opacity: 0.7; }

/* ---- Wax seal (slams once, then still) ---- */
.sheet__seal { position: absolute; top: -36px; right: -34px; width: 118px; height: 116px;
  rotate: 11deg; z-index: 3; pointer-events: none;
  opacity: 0; transform: scale(2.4);
  animation: seal-slam 0.42s cubic-bezier(0.6, 0, 0.9, 0.6) 0.66s forwards; }
.sheet__seal svg { display: block; width: 100%; height: 100%; }
@keyframes seal-slam {
  0% { opacity: 0; transform: scale(2.4); }
  62% { opacity: 1; transform: scale(0.96); }
  82% { transform: scale(1.035); }
  100% { opacity: 1; transform: scale(1); }
}
/* the sheet takes the thud */
.sheet { animation-name: sheet-in-thud; }
@keyframes sheet-in-thud {
  0% { opacity: 0; transform: translateY(26px); }
  55% { opacity: 1; transform: none; }
  72% { transform: none; }
  76.5% { transform: translateY(2px) scale(0.992); }
  84% { transform: none; }
  100% { opacity: 1; transform: none; }
}
/* ink flecks that arrive with the seal */
.sheet__flecks { position: absolute; top: -64px; right: -66px; width: 200px; height: 190px;
  z-index: 2; pointer-events: none; }
.sheet__flecks i { position: absolute; border-radius: 50%;
  background: var(--ink-red); opacity: 0;
  width: calc(var(--s, 4) * 1px); height: calc(var(--s, 4) * 1px);
  left: calc(var(--x, 50) * 1%); top: calc(var(--y, 50) * 1%);
  transform: scale(0.3);
  animation: fleck-pop 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) calc(0.92s + var(--fd, 0s)) forwards; }
@keyframes fleck-pop { to { opacity: var(--o, 0.8); transform: scale(1); } }

/* ---- Section swap (toggleAuth flips .hidden) ---- */
.auth-sec:not(.hidden) { animation: sec-in 0.45s var(--ease); }
@keyframes sec-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---- Section header ---- */
.sec-kicker { display: block; font-size: 10.5px; letter-spacing: 2.4px;
  text-transform: uppercase; color: var(--cta-pale); font-weight: 500; }
.sec-head h2 { font-family: 'Fraunces', Georgia, serif; font-optical-sizing: auto;
  font-weight: 520; font-size: 34px; line-height: 1.06; letter-spacing: -0.005em;
  margin-top: 10px; color: var(--paper-ink); }
.sec-sub { margin-top: 10px; font-size: 14.5px; line-height: 1.55; color: var(--paper-mute); }
.sec-sub strong { color: var(--paper-ink); font-weight: 600; }
.sec-hint { margin-top: 6px; font-size: 12.5px; color: var(--paper-faint); }
.sec-head { margin-bottom: 26px; }
/* short engraved rule under the header, like the card divider on the landing */
.sec-head::after { content: ''; display: block; width: 44px; height: 3px; margin-top: 18px;
  background: var(--cta-pale); opacity: 0.18; border-radius: 2px; }

/* ---- Fields ---- */
.field { margin-bottom: 16px; }
.field__row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 7px; }
.field__label { display: block; font-size: 10px; letter-spacing: 1.8px;
  text-transform: uppercase; color: var(--paper-mute); font-weight: 500; }
.field__aside { font-size: 12px; color: var(--cta-pale); cursor: pointer; font-weight: 500; }
.field__aside:hover { text-decoration: underline; }
.field__box { position: relative; }
.form-control { display: block; width: 100%; appearance: none;
  font: inherit; font-size: 15.5px; color: var(--paper-ink);
  background: #fcfcfb; border: 1px solid var(--paper-line); border-radius: 10px;
  padding: 12px 14px; transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s var(--ease); }
.form-control::placeholder { color: #b6bcc6; }
.form-control:hover { border-color: #d2d6dd; }
.form-control:focus { outline: none; background: #fff; border-color: var(--cta-pale);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--cta-pale) 14%, transparent); }
.form-control:-webkit-autofill { -webkit-box-shadow: 0 0 0 100px #fcfcfb inset; -webkit-text-fill-color: var(--paper-ink); }
.field-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* password reveal */
.pw-toggle { position: absolute; right: 7px; top: 50%; translate: 0 -50%;
  display: grid; place-items: center; width: 32px; height: 32px;
  background: none; border: 0; border-radius: 8px; cursor: pointer; color: var(--paper-faint); }
.pw-toggle:hover { color: var(--paper-mute); background: #f3f4f6; }
.pw-toggle svg { width: 17px; height: 17px; }
.pw-toggle .eye-off { display: none; }
.pw-toggle.is-off .eye { display: none; }
.pw-toggle.is-off .eye-off { display: block; }
.field__box:has(.pw-toggle) .form-control { padding-right: 44px; }

/* ---- Primary button: the landing pill, in brand ink ---- */
.btn-primary { display: block; width: 100%; margin-top: 22px;
  font: inherit; font-size: 15.5px; font-weight: 500; letter-spacing: 0.1px;
  color: var(--pale); background: var(--cta-pale);
  border: 0; border-radius: 999px; padding: 14px 24px; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), filter 0.3s var(--ease); }
.btn-primary:hover { transform: translateY(-2px);
  box-shadow: 0 12px 26px color-mix(in srgb, var(--cta-pale) 32%, transparent); filter: brightness(1.06); }
.btn-primary:active { transform: none; box-shadow: none; }
.btn-primary:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }
.btn-primary:focus-visible { outline: 2.5px solid var(--cta-pale); outline-offset: 3px; }

/* ---- Messages: red-ink margin note / approve chip ---- */
.error-msg { display: none; margin: 0 0 16px; padding: 10px 13px;
  font-size: 13.5px; line-height: 1.45; color: var(--ink-red);
  background: rgba(185, 28, 28, 0.06); border-left: 3px solid var(--ink-red);
  border-radius: 0 8px 8px 0; }
.success-msg { display: none; margin: 0 0 16px; padding: 10px 13px;
  font-size: 13.5px; line-height: 1.45; color: var(--approve); font-weight: 500;
  background: var(--approve-bg); border-radius: 8px; }

/* ---- 6-digit code: letterpress tiles ---- */
.code-inputs { display: flex; gap: 9px; justify-content: center; margin: 4px 0 6px; }
.code-inputs input { width: 50px; height: 60px; text-align: center;
  font-family: 'JetBrains Mono', monospace; font-size: 24px; color: var(--paper-ink);
  background: #fcfcfb; border: 1px solid var(--paper-line); border-radius: 10px;
  caret-color: var(--cta-pale);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.12s var(--ease), background 0.2s var(--ease); }
.code-inputs input:focus { outline: none; background: #fff; border-color: var(--cta-pale);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--cta-pale) 14%, transparent); }
.code-inputs input.filled { background: var(--pale); border-color: var(--cta-pale);
  box-shadow: inset 0 2px 5px color-mix(in srgb, var(--cta-pale) 16%, transparent); /* pressed into the paper */ }

/* ---- Small print under forms ---- */
.auth-toggle { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--paper-line);
  text-align: center; font-size: 13.5px; color: var(--paper-mute); }
.auth-toggle a { color: var(--cta-pale); font-weight: 600; cursor: pointer; }
.auth-toggle a:hover { text-decoration: underline; }
.resend-row { text-align: center; margin-top: 14px; }
.resend-link { font-size: 13px; color: var(--cta-pale); font-weight: 500; cursor: pointer; }
.resend-link:hover { text-decoration: underline; }
.back-row { text-align: center; margin-top: 16px; }
.back-link { font-size: 12px; letter-spacing: 0.6px; color: var(--paper-faint); }
.back-link:hover { color: var(--paper-mute); }
.verify-info { margin-top: 10px; font-size: 14.5px; line-height: 1.55; color: var(--paper-mute); }
.verify-info strong { color: var(--paper-ink); font-weight: 600; word-break: break-all; }
.legal-note { margin-top: 6px; font-size: 11.5px; color: var(--paper-faint); }

/* ---- Responsive ---- */
@media (max-width: 1020px) {
  .auth-shell { grid-template-columns: 1fr; gap: 34px; align-items: start;
    width: min(560px, calc(100% - 40px)); padding: 40px 0 56px; }
  .rail { max-width: none; }
  .rail__logo img { height: 44px; }
  .rail__kicker { margin-top: 26px; }
  .rail__head { font-size: clamp(34px, 7.5vw, 46px); }
  .rail__stats { margin-top: 26px; gap: 26px; }
  .rail__note, .rail__foot { display: none; }
  .sheet__seal { top: -30px; right: -12px; width: 96px; height: 94px; }
  .sheet__flecks { right: -28px; }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .auth-shell { width: calc(100% - 32px); padding: 28px 0 44px; }
  .sheet { padding: 34px 24px 30px; }
  .sheet::before { left: 14px; }
  .sec-head h2 { font-size: 29px; }
  .field-duo { grid-template-columns: 1fr; gap: 0; }
  .code-inputs { gap: 7px; }
  .code-inputs input { width: 44px; height: 54px; font-size: 21px; }
  .sheet__seal { top: -26px; right: -8px; width: 84px; height: 82px; }
}
@media (max-width: 375px) {
  .code-inputs input { width: 40px; height: 50px; font-size: 19px; }
}
@media (max-width: 340px) {
  .code-inputs { gap: 5px; }
  .code-inputs input { width: 36px; height: 46px; font-size: 17px; }
}

/* ---- Reduced motion: everything rests at its final state ---- */
@media (prefers-reduced-motion: reduce) {
  .rail > *, .sheet, .auth-sec:not(.hidden) { animation: none !important; opacity: 1 !important; transform: none !important; }
  .sheet__seal { animation: none !important; opacity: 1; transform: scale(1); }
  .sheet__flecks i { animation: none !important; opacity: var(--o, 0.8); transform: scale(1); }
  .btn-primary, .form-control, .code-inputs input { transition: none !important; }
}
