/* ==========================================================================
   DreamFundSL — Front page & sign-in
   Loaded after app.css and reuses its design tokens (--ink-*, --teal,
   --green, --gold, --parchment, --font-*). Nothing here changes the app
   shell; every rule is scoped to .auth-screen or the boot splash.

   Direction: the same digital-passbook idea as the rest of the app. The one
   memorable element is the sample "Financial health" passbook page: dotted
   leaders between label and value, and a total with a double rule under it,
   like the closing line of a ledger. Everything else stays quiet.
   ========================================================================== */

.auth-screen {
  --auth-gutter: clamp(20px, 4vw, 48px);
  --teal-ink: #0b7c77;          /* teal dark enough for text on parchment (4.7:1) */
  --mint: #6ee7b0;              /* leaf green lifted for use on navy */
  --hero-bg: linear-gradient(155deg, #0d7a74 0%, #0f2c53 48%, #0a1f3d 100%);
  background: var(--parchment);
  color: var(--text-primary);
}

/* ---------- Utilities ---------- */

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.auth-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
.auth-screen [id] { scroll-margin-top: 16px; }

/* ---------- Boot splash (shown while the session check runs) ---------- */

.boot-splash {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: linear-gradient(155deg, #0d7a74 0%, #0f2c53 48%, #0a1f3d 100%);
  /* Failsafe: if login.js ever fails to load, the splash still clears itself. */
  animation: boot-failsafe 0s linear 7s forwards;
}
.boot-splash img {
  width: 72px; height: 72px; border-radius: 18px;
  box-shadow: 0 10px 30px rgba(4, 14, 30, 0.4);
  animation: boot-pulse 1.6s ease-in-out infinite;
}
@keyframes boot-pulse { 0%, 100% { transform: scale(1); opacity: 0.92; } 50% { transform: scale(1.05); opacity: 1; } }
@keyframes boot-failsafe { to { visibility: hidden; opacity: 0; } }

/* ---------- Hero ---------- */

.auth-hero {
  position: relative;
  background: var(--hero-bg);
  color: #e9f1f4;
  overflow: hidden;
}
/* Faint passbook ruling behind the hero, fading out toward the bottom. */
.auth-hero::before {
  content: "";
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0, transparent 39px,
    rgba(255, 255, 255, 0.05) 39px, rgba(255, 255, 255, 0.05) 40px
  );
  -webkit-mask-image: linear-gradient(to bottom, #000 25%, transparent 95%);
          mask-image: linear-gradient(to bottom, #000 25%, transparent 95%);
  pointer-events: none;
}
.auth-simple .auth-hero { min-height: 100vh; min-height: 100svh; }

.auth-topbar {
  position: relative;
  max-width: 1240px; margin: 0 auto;
  padding: 20px var(--auth-gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand img { width: 40px; height: 40px; border-radius: 10px; box-shadow: 0 4px 12px rgba(4, 14, 30, 0.35); }
.auth-wordmark {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 600; letter-spacing: -0.01em;
  color: #fff;
}
.auth-wordmark span { color: var(--mint); }

.auth-topnav { display: flex; gap: 4px; }
.auth-topnav a {
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 8px 12px; border-radius: 8px;
}
.auth-topnav a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.auth-hero :focus-visible, .front-security :focus-visible, .front-footer :focus-visible {
  outline-color: var(--mint);
}

.auth-hero-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 430px);
  grid-template-areas: "copy card" "book card";
  column-gap: clamp(32px, 6vw, 96px);
  row-gap: 32px;
  align-items: start;
  max-width: 1240px; margin: 0 auto;
  padding: clamp(16px, 2vw, 24px) var(--auth-gutter) clamp(48px, 7vw, 96px);
}
.auth-hero-two { grid-template-columns: minmax(0, 1fr) minmax(340px, 460px); grid-template-areas: "copy card"; align-items: center; }
.auth-hero-single { grid-template-columns: minmax(0, 440px); grid-template-areas: "card"; justify-content: center; }

.auth-copy { grid-area: copy; }
.auth-copy h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 4.4vw, 56px);
  font-weight: 600; line-height: 1.08; letter-spacing: -0.02em;
  color: #fff; text-wrap: balance; max-width: 18ch;
}
.auth-lede {
  margin: 20px 0 0; max-width: 54ch;
  font-size: 17px; line-height: 1.65;
  color: rgba(233, 241, 244, 0.86); text-wrap: pretty;
}

.auth-points {
  list-style: none; margin: 30px 0 0; padding: 0;
  display: grid; gap: 14px; max-width: 46ch;
}
.auth-points li {
  position: relative; padding-left: 32px;
  color: rgba(233, 241, 244, 0.92); line-height: 1.55;
}
.auth-points li::before {
  content: ""; position: absolute; left: 0; top: 1px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(110, 231, 176, 0.16);
}
.auth-points li::after {
  content: ""; position: absolute; left: 8px; top: 5px;
  width: 6px; height: 11px;
  border: solid var(--mint); border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0.8);
}

/* ---------- Sign-in card ---------- */

.auth-card {
  grid-area: card;
  width: 100%; max-width: 560px;
  background: var(--parchment);
  color: var(--text-primary);
  border-radius: 16px;
  padding: 32px 30px 26px;
  box-shadow: 0 24px 60px rgba(4, 14, 30, 0.45), 0 2px 6px rgba(4, 14, 30, 0.3);
}
.auth-card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--ink-900);
}
.auth-card-sub { margin: 6px 0 22px; color: var(--text-muted); font-size: 14.5px; line-height: 1.5; }

.auth-card [role="alert"]:empty { display: none; }
.auth-card .alert { margin-bottom: 16px; align-items: flex-start; line-height: 1.45; }
.auth-card .alert-error { color: #a63f1d; }
.auth-card .alert-success { color: #086a66; }

.auth-form { display: grid; gap: 16px; }
.auth-screen .field { gap: 6px; }
.auth-screen .field label {
  font-size: 13.5px; font-weight: 600; letter-spacing: 0;
  text-transform: none; color: var(--text-primary);
}
.field-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.field-link {
  color: var(--teal-ink); font-size: 13.5px; font-weight: 600; text-decoration: none;
}
.field-link:hover, .auth-back a:hover { text-decoration: underline; }

.auth-screen .field input {
  width: 100%; height: 46px; padding: 0 14px;
  font-size: 16px; /* 16px stops iOS zooming into the field */
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fff; color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-screen .field input:hover { border-color: #a9bfc1; }
.auth-screen .field input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15, 154, 148, 0.16); }

.pw-field { position: relative; }
.pw-field input { padding-right: 72px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 34px; padding: 0 10px;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--teal-ink); font-size: 13.5px; font-weight: 600;
}
.pw-toggle:hover { background: var(--teal-dim); }
.pw-hint { margin: 0; font-size: 12.5px; font-weight: 500; color: #8a5f10; }

.auth-submit {
  width: 100%; min-height: 46px; padding: 0 18px;
  font-size: 15px; border-radius: 8px; text-decoration: none;
}
.btn-secondary.auth-submit { background: #fff; }

.auth-alt {
  margin-top: 22px; padding-top: 20px;
  border-top: 1px solid var(--line);
  display: grid; gap: 10px; text-align: center;
  color: var(--text-muted); font-size: 13.5px;
}
.auth-trust {
  margin: 20px 0 0; display: flex; align-items: flex-start; gap: 10px;
  font-size: 12.5px; line-height: 1.5; color: var(--text-muted);
}
.auth-trust .icon { width: 18px; height: 18px; margin-top: 1px; color: var(--teal); }
.auth-back { margin: 18px 0 0; text-align: center; font-size: 13.5px; }
.auth-back a { color: var(--teal-ink); font-weight: 600; text-decoration: none; }
.auth-noscript { margin: 12px 0 0; font-size: 13px; color: #a63f1d; }

/* Live password checklist (sign-up and reset) */
.pw-rules { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 5px; font-size: 12.5px; color: var(--text-muted); }
.pw-rules li { position: relative; padding-left: 22px; line-height: 1.4; }
.pw-rules li::before {
  content: ""; position: absolute; left: 0; top: 1px;
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); background: #fff;
}
.pw-rules li::after {
  content: ""; position: absolute; left: 5px; top: 3.5px;
  width: 4px; height: 7px;
  border: solid #fff; border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg); opacity: 0;
}
.pw-rules li[data-met="true"] { color: #0a6b40; }
.pw-rules li[data-met="true"]::before { background: var(--green); border-color: var(--green); }
.pw-rules li[data-met="true"]::after { opacity: 1; }

/* ---------- Passbook (sample financial health) ---------- */

.passbook {
  grid-area: book;
  position: relative;
  width: 100%; max-width: 560px; margin: 0;
  background: var(--parchment);
  color: var(--text-primary);
  border-radius: 14px;
  padding: 22px 26px 22px 36px;
  box-shadow: 0 18px 44px rgba(4, 14, 30, 0.35);
}
/* Stitched binding down the left edge. */
.passbook::before {
  content: ""; position: absolute; left: 15px; top: 14px; bottom: 14px;
  border-left: 2px dashed var(--line-strong);
}
.passbook-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.passbook-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--ink-900); }
.passbook-tag {
  padding: 3px 10px; border-radius: 999px;
  background: var(--gold-dim); color: #8a5f10;
  font-size: 12px; font-weight: 600;
}

.ledger { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 14px; }
.ledger-line { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }
.ledger-leader { flex: 1; min-width: 12px; border-bottom: 2px dotted #9fb0b4; transform: translateY(-3px); }
.ledger-val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.ledger-val b { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.ledger-bar { display: block; height: 6px; margin-top: 7px; border-radius: 4px; background: var(--parchment-dim); overflow: hidden; }
.ledger-bar i {
  display: block; height: 100%; width: var(--fill);
  background: var(--gold); border-radius: 4px; transform-origin: left center;
}
.ledger-item.is-strong .ledger-bar i { background: var(--green); }

.ledger-total {
  margin-top: 20px; padding-top: 14px;
  border-top: 1px solid var(--line-strong);
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
}
.ledger-total-text { display: grid; gap: 6px; justify-items: start; }
.ledger-total-label { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.status-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--green-dim); color: #0a6b40;
  font-size: 12.5px; font-weight: 600;
}
.ledger-total-num > span[aria-hidden] {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 0 2px 3px;
  border-bottom: 4px double var(--ink-900);   /* the ledger rule under a closing total */
}
.ledger-total-num b {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 40px; font-weight: 600; line-height: 1; letter-spacing: -0.02em;
  color: var(--ink-900);
}
.ledger-total-num small { font-family: var(--font-mono); font-size: 14px; color: var(--text-muted); }
.passbook-note { margin: 16px 0 0; font-size: 13px; line-height: 1.55; color: var(--text-muted); }

/* One orchestrated moment: bars fill in order, then the score counts up.
   login.js adds .is-armed immediately and .is-live once the page is in view. */
.passbook.is-armed .ledger-bar i { transform: scaleX(0); }
.passbook.is-live .ledger-bar i {
  animation: ledger-fill 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i) * 120ms + 200ms);
}
@keyframes ledger-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- Front page sections ---------- */

.front-section { background: var(--parchment); padding: clamp(48px, 7vw, 96px) var(--auth-gutter); }
.front-wrap { max-width: 1240px; margin: 0 auto; }
.front-head h2 {
  margin: 0; max-width: 26ch;
  font-family: var(--font-display);
  font-size: clamp(26px, 3vw, 38px); font-weight: 600; line-height: 1.15; letter-spacing: -0.015em;
  color: var(--ink-900); text-wrap: balance;
}
.front-head p { margin: 12px 0 0; max-width: 60ch; color: var(--text-muted); font-size: 16px; line-height: 1.6; }

.feature-groups {
  margin-top: 44px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 48px clamp(32px, 6vw, 88px);
}
.feature-group h3 {
  margin: 0; padding-bottom: 10px;
  font-family: var(--font-display); font-size: 21px; font-weight: 600;
  color: var(--ink-900); border-bottom: 2px solid var(--ink-900);
}
.feature-list { list-style: none; margin: 0; padding: 0; }
.feature { border-bottom: 1px solid var(--line); }
.feature summary {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 20px;
  column-gap: 14px; align-items: start;
  padding: 14px 6px; cursor: pointer; list-style: none;
  border-radius: 8px;
}
.feature summary::-webkit-details-marker { display: none; }
.feature summary:hover { background: rgba(15, 154, 148, 0.06); }
.feature-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--teal-dim); color: var(--teal-ink);
}
.feature-text { display: block; min-width: 0; }
.feature-name { display: block; font-size: 15.5px; font-weight: 600; color: var(--ink-900); line-height: 1.35; }
.feature-line { display: block; margin-top: 2px; font-size: 14px; line-height: 1.5; color: var(--text-muted); }
.feature-chevron { margin-top: 10px; width: 18px; height: 18px; color: var(--text-faint); transition: transform 0.2s; }
.feature[open] .feature-chevron { transform: rotate(180deg); }
.feature-more { padding: 0 34px 18px 60px; }
.feature-more p { margin: 0; max-width: 62ch; font-size: 14.5px; line-height: 1.65; color: var(--text-primary); }

/* ---------- Security band ---------- */

.front-security {
  background: linear-gradient(170deg, var(--ink-800) 0%, var(--ink-900) 100%);
  color: #e9f1f4;
  padding: clamp(48px, 7vw, 96px) var(--auth-gutter) clamp(24px, 4vw, 48px);
}
.front-security h2 { color: #fff; }
.front-security .front-head p { color: rgba(233, 241, 244, 0.78); }
.security-list {
  list-style: none; margin: 40px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 clamp(28px, 4vw, 56px);
}
.security-list li { border-top: 1px solid rgba(255, 255, 255, 0.18); padding: 18px 0 30px; }
.security-list h3 { margin: 0; font-size: 16px; font-weight: 600; color: #fff; line-height: 1.35; }
.security-list p { margin: 8px 0 0; font-size: 14.5px; line-height: 1.65; color: rgba(233, 241, 244, 0.78); }

/* ---------- Footer ---------- */

.front-footer {
  background: var(--ink-900);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 32px var(--auth-gutter);
  color: #e9f1f4;
}
.front-footer-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.front-footer-brand { display: flex; align-items: center; gap: 12px; }
.front-footer-brand img { width: 36px; height: 36px; border-radius: 9px; }
.front-footer-tag { margin-top: 2px; font-size: 13px; color: rgba(233, 241, 244, 0.7); }
.front-footer-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.front-footer-credit { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: 12.5px; color: rgba(233, 241, 244, 0.5); text-align: center; }
.btn-light, .btn-ghost { min-height: 44px; padding: 0 20px; font-size: 14.5px; border-radius: 8px; text-decoration: none; }
.btn-light { background: #fff; color: var(--ink-900); }
.btn-light:hover { background: var(--parchment-dim); }
.btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, 0.4); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .auth-hero-grid,
  .auth-hero-two {
    grid-template-columns: minmax(0, 560px);
    grid-template-areas: "copy" "card" "book";
    justify-content: center;
    align-items: start;
  }
  .auth-hero-single { grid-template-columns: minmax(0, 480px); grid-template-areas: "card"; }
  .auth-copy, .auth-card, .passbook { max-width: 560px; }
  .feature-groups { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .security-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .auth-topbar { padding-top: 16px; padding-bottom: 12px; }
  .auth-wordmark { font-size: 20px; }
  .auth-topnav a { padding: 8px; }
  .auth-hero-grid { row-gap: 24px; }
  .auth-copy h1 { font-size: 32px; }
  .auth-lede { margin-top: 14px; font-size: 15.5px; line-height: 1.55; }
  .auth-lede-extra { display: none; }   /* keep the sign-in form near the top on small phones */
  .auth-card { padding: 26px 20px 22px; border-radius: 14px; }
  .auth-card-title { font-size: 25px; }
  .passbook { padding: 20px 18px 20px 30px; }
  .passbook::before { left: 12px; }
  .ledger-total-num b { font-size: 34px; }
  .security-list { grid-template-columns: minmax(0, 1fr); }
  .feature-more { padding-right: 6px; }
  .front-footer-row { align-items: flex-start; }
  .front-footer-actions { width: 100%; }
  .front-footer-actions .btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .boot-splash img { animation: none; }
  .feature-chevron { transition: none; }
  .passbook.is-armed .ledger-bar i,
  .passbook.is-live .ledger-bar i { animation: none; transform: none; }
}
