/* ============================================================
   Login — "Ledger" light theme
   Scoped to this page: login.css is only linked from index.html.
   ============================================================ */

:root {
  --paper: #F6F7F3;
  --surface: #FFFFFF;
  --surface-2: #FBFBF8;
  --ink: #132420;
  --ink-soft: #4B5A54;
  --ink-faint: #8A968F;
  --line: #E2E6DD;
  --line-soft: #EBEDE6;

  --primary: #0B6E4F;
  --primary-dark: #084F39;
  --primary-tint: #E4F1EA;
  --gold: #B8862E;
  --gold-tint: #F5ECD9;
  --blue: #3B78C2;
  --blue-tint: #E7EEF7;
  --purple: #7C5CBF;
  --purple-tint: #EFEAF8;
  --negative: #A83A44;
  --negative-tint: #F5E6E5;

  --shadow-sm: 0 1px 2px rgba(19, 36, 32, 0.06);
  --shadow-md: 0 8px 24px -12px rgba(19, 36, 32, 0.18);
  --shadow-lg: 0 28px 64px -20px rgba(19, 36, 32, 0.28);

  --font-display: 'Fraunces', Georgia, serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --text-primary: var(--ink);
  --text-secondary: var(--ink-soft);
  --text-muted: var(--ink-faint);
  --error: var(--negative);
}

html { color-scheme: light; }

@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes shimmerSweep { 0% { transform: translateX(-120%); } 100% { transform: translateX(220%); } }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
@keyframes dotPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.6); opacity: 0.35; } }
@keyframes floatDrift1 { 0%, 100% { transform: translate(0, 0) rotate(-4deg); } 50% { transform: translate(6px, -10px) rotate(3deg); } }
@keyframes floatDrift2 { 0%, 100% { transform: translate(0, 0) rotate(5deg); } 50% { transform: translate(-8px, 8px) rotate(-3deg); } }

/* ----- Base ----- */
.login-page {
  display: block;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
}

/* ----- Ambient background ----- */
.auth-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-mesh {
  position: absolute;
  inset: -50%;
  background:
    radial-gradient(ellipse 70% 50% at 15% 30%, rgba(11, 110, 79, 0.10) 0%, transparent 55%),
    radial-gradient(ellipse 55% 45% at 82% 20%, rgba(184, 134, 46, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse 50% 40% at 60% 85%, rgba(59, 120, 194, 0.09) 0%, transparent 45%),
    linear-gradient(160deg, var(--paper) 0%, #F1F3EC 45%, var(--paper) 100%);
  animation: meshShift 20s ease-in-out infinite alternate;
}

@keyframes meshShift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-2%, 1%) scale(1.04); }
}

.auth-orbs { position: absolute; inset: 0; }

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.4;
  will-change: transform;
}

.auth-orb-1 {
  width: min(520px, 70vw); height: min(520px, 70vw);
  background: var(--primary); top: -14%; left: -8%;
  animation: orbDrift1 22s ease-in-out infinite;
}
.auth-orb-2 {
  width: min(420px, 55vw); height: min(420px, 55vw);
  background: var(--gold); bottom: -8%; right: -6%;
  animation: orbDrift2 26s ease-in-out infinite;
}
.auth-orb-3 {
  width: min(280px, 40vw); height: min(280px, 40vw);
  background: var(--blue); top: 42%; left: 40%;
  animation: orbDrift3 20s ease-in-out infinite;
}

@keyframes orbDrift1 { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(40px, 30px); } }
@keyframes orbDrift2 { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-35px, -25px); } }
@keyframes orbDrift3 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(25px, -35px) scale(1.1); } }

.auth-noise {
  position: absolute;
  inset: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ----- Shell / layout ----- */
.auth-shell {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 420px);
  align-items: center;
  gap: clamp(2rem, 5vw, 5rem);
  max-width: 1180px;
  width: 100%;
}

/* ----- Hero (left, decorative) ----- */
.auth-hero { position: relative; }
.auth-hero-inner { position: relative; max-width: 480px; }

.auth-hero-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--ink);
  margin-bottom: 2.25rem;
  opacity: 0;
  animation: riseIn 0.6s cubic-bezier(.16,1,.3,1) 0.05s both;
}

.auth-brand-icon {
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  box-shadow: 0 8px 22px rgba(11, 110, 79, 0.35);
}
.auth-brand-icon svg { width: 21px; height: 21px; color: #fff; }
.auth-brand-text { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; }

.auth-hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 3.6vw, 3.1rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 1rem;
  text-wrap: balance;
  opacity: 0;
  animation: riseIn 0.65s cubic-bezier(.16,1,.3,1) 0.14s both;
}
.auth-hero-title em { font-style: italic; color: var(--primary); }

.auth-hero-sub {
  font-size: 1.02rem;
  color: var(--ink-soft);
  line-height: 1.6;
  max-width: 40ch;
  margin-bottom: 2.25rem;
  opacity: 0;
  animation: riseIn 0.65s cubic-bezier(.16,1,.3,1) 0.22s both;
}

.auth-hero-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin-bottom: 2.25rem;
}

.auth-hero-features li {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  opacity: 0;
  animation: riseIn 0.55s cubic-bezier(.16,1,.3,1) forwards;
}
.auth-hero-features li:nth-child(1) { animation-delay: 0.32s; }
.auth-hero-features li:nth-child(2) { animation-delay: 0.4s; }
.auth-hero-features li:nth-child(3) { animation-delay: 0.48s; }

.auth-hero-icon {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1);
}
.auth-hero-icon svg { width: 19px; height: 19px; }
.auth-hero-features li:hover .auth-hero-icon { transform: scale(1.1) rotate(-6deg); }
.auth-hero-icon.icon-primary { background: var(--primary-tint); color: var(--primary); }
.auth-hero-icon.icon-blue { background: var(--blue-tint); color: var(--blue); }
.auth-hero-icon.icon-gold { background: var(--gold-tint); color: var(--gold); }

.auth-hero-features strong { display: block; font-size: 0.95rem; font-weight: 600; color: var(--ink); margin-bottom: 0.15rem; }
.auth-hero-features span { display: block; font-size: 0.84rem; color: var(--ink-faint); line-height: 1.4; }

.auth-hero-chart {
  position: relative;
  padding: 1.1rem 1.2rem 0.9rem;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  animation: riseIn 0.6s cubic-bezier(.16,1,.3,1) 0.56s both;
}
.auth-hero-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.hero-chart-line {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: drawLine 1.6s cubic-bezier(.16,1,.3,1) 0.9s forwards;
}
.hero-chart-dot { fill: var(--primary); animation: dotPulse 2.2s ease-in-out 2.5s infinite; }
.auth-hero-chart-tag {
  display: block; margin-top: 0.35rem;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.02em; color: var(--ink-faint);
}

.auth-hero-float {
  position: absolute;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--ink-faint);
  opacity: 0;
  animation: riseIn 0.5s ease 0.9s both, floatDrift1 7s ease-in-out 1.4s infinite;
}
.auth-hero-float svg { width: 15px; height: 15px; }
.auth-hero-float-1 { top: -2.2rem; right: 2rem; color: var(--blue); }
.auth-hero-float-2 { bottom: 1.5rem; right: -1.6rem; color: var(--gold); animation-name: riseIn, floatDrift2; animation-delay: 1s, 1.6s; }

/* ----- Auth panel (right, functional) ----- */
.auth-panel { width: 100%; }

.auth-card {
  position: relative;
  width: 100%;
  padding: 2.25rem;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: cardIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
  overflow: hidden;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-card-shine {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--gold) 50%, var(--blue) 100%);
  opacity: 0.9;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--ink);
}
.auth-brand-mobile { display: none; margin-bottom: 1.5rem; }

.auth-eyebrow {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 0.35rem;
}

.auth-header { margin-bottom: 1.75rem; }

.auth-title {
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 600; letter-spacing: -0.01em;
  color: var(--ink); margin-bottom: 0.4rem;
}

.auth-subtitle {
  font-size: 0.92rem;
  color: var(--ink-soft);
  line-height: 1.5;
  transition: opacity 0.3s ease;
}
.auth-subtitle.is-switching { opacity: 0; }

/* Tabs */
.auth-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  padding: 0.3rem;
  margin-bottom: 1.75rem;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.auth-tab {
  position: relative; z-index: 1;
  padding: 0.65rem 1rem; border: none; border-radius: 11px;
  background: transparent; color: var(--ink-faint);
  font-family: inherit; font-size: 0.88rem; font-weight: 600; cursor: pointer;
  transition: color 0.25s ease;
}
.auth-tab.active { color: var(--primary-dark); }

.auth-tab-indicator {
  position: absolute; top: 0.3rem; left: 0.3rem;
  width: calc(50% - 0.425rem); height: calc(100% - 0.6rem);
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid rgba(11, 110, 79, 0.18);
  box-shadow: 0 3px 10px rgba(11, 110, 79, 0.14);
  transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
  pointer-events: none;
}
.auth-tabs.signup-mode .auth-tab-indicator { transform: translateX(calc(100% + 0.25rem)); }

/* Form */
.auth-form { display: flex; flex-direction: column; gap: 1.25rem; }

.auth-field label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 0.45rem; }

.auth-field-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.45rem; }
.auth-field-row label { margin-bottom: 0; }

.auth-input-wrap { position: relative; display: flex; align-items: center; }

.auth-input-icon {
  position: absolute; left: 1rem; width: 18px; height: 18px;
  color: var(--ink-faint); pointer-events: none;
  transition: color 0.2s ease;
}

.auth-input-wrap input {
  width: 100%;
  padding: 0.9rem 3rem 0.9rem 2.85rem;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.auth-input-wrap input::placeholder { color: var(--ink-faint); }
.auth-input-wrap input:hover { border-color: rgba(11, 110, 79, 0.3); }
.auth-input-wrap input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 110, 79, 0.14);
  background: var(--surface);
}
.auth-input-wrap:focus-within .auth-input-icon { color: var(--primary); }

.auth-input-wrap.has-error input {
  border-color: rgba(168, 58, 68, 0.55);
  box-shadow: 0 0 0 3px rgba(168, 58, 68, 0.1);
}

.auth-toggle-pw {
  position: absolute; right: 0.65rem;
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: none; border-radius: 10px;
  background: transparent; color: var(--ink-faint); cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}
.auth-toggle-pw:hover { color: var(--primary); background: var(--primary-tint); }
.auth-toggle-pw svg { width: 18px; height: 18px; }
.auth-toggle-pw .eye-closed { display: none; }
.auth-toggle-pw.is-visible .eye-open { display: none; }
.auth-toggle-pw.is-visible .eye-closed { display: block; }

.auth-error { display: block; min-height: 1.15em; margin-top: 0.35rem; font-size: 0.78rem; color: var(--negative); }

.auth-strength { margin-top: 0.5rem; }
.auth-strength-bar { height: 4px; border-radius: 4px; background: var(--line-soft); overflow: hidden; margin-bottom: 0.35rem; }
.auth-strength-bar span { display: block; height: 100%; width: 0; border-radius: 4px; transition: width 0.35s ease, background 0.35s ease; }
.auth-strength-label { font-size: 0.72rem; color: var(--ink-faint); }

.auth-forgot {
  border: none; background: none; padding: 0; font-family: inherit;
  font-size: 0.78rem; font-weight: 600; color: var(--gold); cursor: pointer;
  transition: color 0.2s ease;
}
.auth-forgot:hover { color: var(--primary); }

.auth-remember {
  display: flex; align-items: center; gap: 0.65rem;
  font-size: 0.85rem; color: var(--ink-soft); cursor: pointer; user-select: none;
}
.auth-remember input { position: absolute; opacity: 0; width: 0; height: 0; }

.auth-check {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 6px;
  border: 2px solid var(--line);
  transition: all 0.2s ease;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.auth-check svg { width: 12px; height: 12px; opacity: 0; transform: scale(0.6); transition: opacity 0.15s ease, transform 0.15s cubic-bezier(.34,1.56,.64,1); }
.auth-remember input:checked + .auth-check { background: var(--primary); border-color: var(--primary); }
.auth-remember input:checked + .auth-check svg { opacity: 1; transform: scale(1); }

/* Submit button */
.auth-submit {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  width: 100%; margin-top: 0.25rem; padding: 1rem 1.5rem;
  border: none; border-radius: 14px;
  font-family: inherit; font-size: 1rem; font-weight: 600; color: #fff; cursor: pointer;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 10px 28px rgba(11, 110, 79, 0.3);
}

.auth-submit-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  transition: opacity 0.3s ease;
}
.auth-submit-bg::after {
  content: ''; position: absolute; inset: 0; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.28), transparent);
  animation: shimmerSweep 3s ease-in-out infinite;
}

.auth-submit:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(11, 110, 79, 0.4); }
.auth-submit:active:not(:disabled) { transform: translateY(0); }
.auth-submit:disabled { cursor: not-allowed; opacity: 0.85; }

.auth-submit-text, .auth-submit-arrow { position: relative; z-index: 1; transition: opacity 0.2s ease, transform 0.25s ease; }
.auth-submit-arrow { width: 18px; height: 18px; }
.auth-submit:hover:not(:disabled) .auth-submit-arrow { transform: translateX(3px); }

.auth-submit-loader {
  display: none; position: absolute; z-index: 2;
  width: 22px; height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%;
  animation: authSpin 0.7s linear infinite;
}
.auth-submit.loading .auth-submit-text, .auth-submit.loading .auth-submit-arrow { opacity: 0; }
.auth-submit.loading .auth-submit-loader { display: block; }
@keyframes authSpin { to { transform: rotate(360deg); } }

.auth-footer-note { margin-top: 1.5rem; text-align: center; font-size: 0.75rem; line-height: 1.5; color: var(--ink-faint); }

/* Card tilt on mouse (applied via JS) */
.auth-card.tilt-active { transition: transform 0.1s ease-out; }

/* Toast on login page */
.login-page .toast {
  top: auto;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  right: max(1.5rem, env(safe-area-inset-right));
  left: max(1.5rem, env(safe-area-inset-left));
  transform: translateY(120%);
}
.login-page .toast.show { transform: translateY(0); }

/* ----- Responsive ----- */
@media (max-width: 960px) {
  .auth-hero { display: none; }
  .auth-layout { grid-template-columns: 1fr; max-width: 440px; }
  .auth-brand-mobile { display: flex; }
}

@media (max-width: 480px) {
  .auth-card { padding: 1.5rem; border-radius: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-mesh, .auth-orb, .auth-submit-bg, .auth-submit-bg::after, .auth-card,
  .auth-hero-brand, .auth-hero-title, .auth-hero-sub, .auth-hero-features li,
  .auth-hero-chart, .hero-chart-line, .hero-chart-dot, .auth-hero-float {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .hero-chart-line { stroke-dashoffset: 0 !important; }
  .auth-tab-indicator { transition-duration: 0.01ms !important; }
}
