/* Cartoon French Notes — Auth UI (polished + motion) */

:root {
  --accent: #e85d04;
  --accent-2: #f48c06;
  --purple: #9d4edd;
  --mint: #2a9d8f;
  --text: #1f1a17;
  --muted: #8a7568;
  --border: #ead9cb;
  --bg: #fff8f1;
  --card: #ffffff;
  --font: "Nunito", system-ui, sans-serif;
  --display: "Fredoka", "Nunito", sans-serif;
  --radius-modal: 24px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
}

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

html, body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.login-page {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  position: relative;
}

body.is-authing .btn-google,
body.is-authing .btn-primary {
  opacity: 0.72;
  pointer-events: none;
}

/* ── Ambient background ─────────────────────── */
.login-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  overflow: hidden;
  pointer-events: none;
}
.login-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(22px) saturate(1.08);
  transform: scale(1.14);
  animation: bgDrift 22s ease-in-out infinite alternate;
}
.login-bg img:nth-child(2) { animation-delay: -6s; }
.login-bg img:nth-child(3) { animation-delay: -12s; }
.login-bg img:nth-child(4) { animation-delay: -18s; }

@keyframes bgDrift {
  from { transform: scale(1.14) translate(0, 0); }
  to { transform: scale(1.2) translate(-1.5%, 1%); }
}

.login-bg-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(145deg, rgba(255, 248, 241, 0.82), rgba(255, 243, 232, 0.74)),
    radial-gradient(720px 440px at 12% 18%, rgba(244, 140, 6, 0.26), transparent 58%),
    radial-gradient(680px 420px at 92% 82%, rgba(157, 78, 221, 0.2), transparent 55%),
    radial-gradient(500px 320px at 50% 100%, rgba(42, 157, 143, 0.1), transparent 50%);
}

.float-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
  animation: orbFloat 16s ease-in-out infinite;
}
.float-orb.a {
  width: 220px; height: 220px;
  background: rgba(232, 93, 4, 0.38);
  top: 8%; left: -40px;
}
.float-orb.b {
  width: 260px; height: 260px;
  background: rgba(157, 78, 221, 0.28);
  bottom: 6%; right: -60px;
  animation-delay: -7s;
}
.float-orb.c {
  width: 160px; height: 160px;
  background: rgba(42, 157, 143, 0.22);
  top: 55%; left: 42%;
  animation-delay: -11s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(18px, -22px) scale(1.08); }
}

/* ── Stage + modal ──────────────────────────── */
.login-stage {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.auth-modal {
  width: min(1000px, 100%);
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  background: var(--card);
  border-radius: var(--radius-modal);
  border: 1px solid rgba(43, 33, 24, 0.1);
  box-shadow:
    0 40px 80px rgba(43, 33, 24, 0.16),
    0 12px 28px rgba(232, 93, 4, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.7) inset;
  overflow: hidden;
  animation: modalIn 780ms var(--ease-out) both;
  position: relative;
}

.auth-modal::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  z-index: 5;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(28px) scale(0.97); filter: blur(4px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

/* ── LEFT visual ────────────────────────────── */
.auth-visual {
  position: relative;
  min-height: 640px;
  background: #2b2118;
  overflow: hidden;
}

.visual-slides { position: absolute; inset: 0; }

.visual-slide {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  z-index: 0;
  transition: opacity 900ms ease;
}
.visual-slide.is-active {
  opacity: 1;
  z-index: 1;
}
.visual-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.08);
  transition: transform 6.5s ease-out;
}
.visual-slide.is-active img {
  transform: scale(1);
  animation: kenBurns 7s ease-out both;
}

@keyframes kenBurns {
  from { transform: scale(1.1) translate(1%, 0); }
  to { transform: scale(1) translate(0, 0); }
}

.visual-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 30px 28px 26px;
  background:
    linear-gradient(180deg, rgba(31, 26, 23, 0.5) 0%, rgba(31, 26, 23, 0.12) 38%, rgba(31, 26, 23, 0.68) 100%),
    linear-gradient(125deg, rgba(232, 93, 4, 0.22), rgba(157, 78, 221, 0.16));
  color: #fff8f1;
}

.visual-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeUp 700ms var(--ease-out) 120ms both;
}
.visual-brand img {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
  background: #fff8f1;
  object-fit: cover;
  animation: softPulse 3.8s ease-in-out infinite;
}
.visual-brand strong {
  display: block;
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: -0.02em;
}
.visual-brand span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.84;
}

@keyframes softPulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.visual-copy {
  animation: fadeUp 700ms var(--ease-out) 220ms both;
}
.visual-copy h2 {
  font-family: var(--display);
  font-size: clamp(28px, 3.5vw, 38px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 12px;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.visual-copy h2 em {
  font-style: normal;
  background: linear-gradient(110deg, #ffd6a8 10%, #fff 45%, #e0aaff 90%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #ffd6a8;
  animation: shimmerText 5s ease-in-out infinite;
}
@keyframes shimmerText {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.visual-copy p {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.55;
  max-width: 34ch;
  opacity: 0.94;
}

.visual-perks {
  list-style: none;
  display: grid;
  gap: 9px;
  margin: 18px 0 16px;
}
.visual-perks li {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(255, 248, 241, 0.16);
  border: 1px solid rgba(255, 248, 241, 0.2);
  backdrop-filter: blur(10px);
  width: fit-content;
  max-width: 100%;
  opacity: 0;
  transform: translateX(-12px);
  animation: perkIn 560ms var(--ease-out) both;
  transition: transform 200ms ease, background 200ms ease;
}
.visual-perks li:nth-child(1) { animation-delay: 320ms; }
.visual-perks li:nth-child(2) { animation-delay: 400ms; }
.visual-perks li:nth-child(3) { animation-delay: 480ms; }
.visual-perks li:nth-child(4) { animation-delay: 560ms; }
.visual-perks li:hover {
  transform: translateX(4px);
  background: rgba(255, 248, 241, 0.24);
}
@keyframes perkIn {
  to { opacity: 1; transform: translateX(0); }
}

.perk-ico {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  font-size: 11px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(232, 93, 4, 0.35);
}

.visual-dots {
  display: flex;
  gap: 8px;
  animation: fadeUp 700ms var(--ease-out) 500ms both;
}
.visual-dots button {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 0;
  padding: 0;
  background: rgba(255, 248, 241, 0.35);
  cursor: pointer;
  transition: width 280ms var(--ease-out), background 200ms ease, transform 200ms ease;
}
.visual-dots button:hover { transform: scale(1.15); }
.visual-dots button.is-active {
  width: 24px;
  background: #fff8f1;
  box-shadow: 0 0 0 3px rgba(255, 248, 241, 0.18);
}

/* ── RIGHT auth panel ───────────────────────── */
.auth-panel {
  background:
    radial-gradient(420px 220px at 100% 0%, rgba(157, 78, 221, 0.06), transparent 60%),
    radial-gradient(380px 200px at 0% 100%, rgba(232, 93, 4, 0.07), transparent 55%),
    #fff;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 30px 32px 26px;
  max-height: min(94vh, 860px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #e8d5c4 transparent;
}

.auth-panel-inner {
  width: 100%;
  max-width: 360px;
  text-align: center;
  margin: auto 0;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: fadeUp 620ms var(--ease-out) both;
}
.reveal-1 { animation-delay: 140ms; }
.reveal-2 { animation-delay: 200ms; }
.reveal-3 { animation-delay: 260ms; }
.reveal-4 { animation-delay: 320ms; }
.reveal-5 { animation-delay: 380ms; }
.reveal-6 { animation-delay: 440ms; }
.reveal-7 { animation-delay: 500ms; }
.reveal-8 { animation-delay: 560ms; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: #fff8f1;
  border: 1px solid var(--border);
  box-shadow:
    0 14px 30px rgba(232, 93, 4, 0.18),
    0 0 0 6px rgba(232, 93, 4, 0.06);
  overflow: hidden;
  animation: logoPop 900ms var(--ease-spring) both;
  position: relative;
}
.auth-logo::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(120deg, transparent 35%, rgba(255,255,255,0.55) 50%, transparent 65%);
  animation: logoShine 4.5s ease-in-out 1.2s infinite;
  pointer-events: none;
}
.auth-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  position: relative;
  z-index: 1;
}

@keyframes logoPop {
  from { opacity: 0; transform: scale(0.55) rotate(-10deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes logoShine {
  0%, 70%, 100% { transform: translateX(-60%) rotate(18deg); opacity: 0; }
  80% { opacity: 1; }
  100% { transform: translateX(60%) rotate(18deg); opacity: 0; }
}

.auth-mode-tabs {
  position: relative;
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff7ef, #fff3e8);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  gap: 2px;
  box-shadow: inset 0 1px 2px rgba(43, 33, 24, 0.04);
}
.mode-tab {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 200ms ease;
}
.mode-tab.is-active { color: var(--text); }
.mode-tab-pill {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(43, 33, 24, 0.1);
  transition: transform 280ms var(--ease-out), width 280ms var(--ease-out);
  z-index: 0;
  pointer-events: none;
}

.auth-title {
  font-family: var(--display);
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 6px;
  transition: opacity 200ms ease, transform 200ms ease;
}
.auth-title.is-swapping {
  opacity: 0;
  transform: translateY(6px);
}

.auth-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 18px;
  transition: opacity 200ms ease;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 11px 16px;
  border-radius: 14px;
  border: 1px solid #e2cbb8;
  background: #fff;
  color: #3c4043;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(43, 33, 24, 0.06);
  transition: transform 180ms var(--ease-out), box-shadow 200ms ease, border-color 180ms ease;
  position: relative;
  overflow: hidden;
}
.btn-google::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 20%, rgba(255,255,255,0.7) 50%, transparent 80%);
  transform: translateX(-120%);
  transition: transform 0.6s ease;
}
.btn-google:hover {
  transform: translateY(-2px);
  border-color: #d4b59e;
  box-shadow: 0 12px 26px rgba(232, 93, 4, 0.14);
}
.btn-google:hover::before { transform: translateX(120%); }
.btn-google .g-icon { width: 20px; height: 20px; flex-shrink: 0; }
.btn-google.is-disabled { opacity: 0.55; pointer-events: none; }

.auth-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.auth-or::before,
.auth-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

/* Form fields */
.auth-form {
  text-align: left;
  display: grid;
  gap: 12px;
  margin-bottom: 4px;
}
.field {
  max-height: 120px;
  overflow: hidden;
  transition: opacity 220ms ease, transform 220ms ease, max-height 280ms ease, margin 220ms ease, padding 220ms ease;
}
.field.is-hiding {
  opacity: 0;
  transform: translateY(-8px);
  max-height: 0;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: #6b5848;
  margin-bottom: 6px;
}
.field-control {
  position: relative;
  display: flex;
  align-items: center;
}
.field-control > i {
  position: absolute;
  left: 14px;
  color: #b9a294;
  font-size: 13px;
  pointer-events: none;
  transition: color 180ms ease, transform 180ms ease;
}
.field-control input {
  width: 100%;
  min-height: 48px;
  padding: 10px 42px 10px 40px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fffaf5;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease, transform 180ms ease;
}
.field-control input::placeholder {
  color: #c4b0a0;
  font-weight: 600;
}
.field-control input:hover { border-color: #e2cbb8; }
.field-control input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(232, 93, 4, 0.14);
  transform: translateY(-1px);
}
.field-control:focus-within > i {
  color: var(--accent);
  transform: scale(1.08);
}
.toggle-pass {
  position: absolute;
  right: 8px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #b9a294;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}
.toggle-pass:hover {
  color: var(--accent);
  background: rgba(232, 93, 4, 0.08);
  transform: scale(1.05);
}
.field-hint {
  margin-top: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff1f0;
  border: 1px solid #ffc9c0;
  color: #c0392b;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
  animation: shakeIn 420ms var(--ease-out) both;
}
@keyframes shakeIn {
  0% { opacity: 0; transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  70% { transform: translateX(-3px); }
  100% { opacity: 1; transform: translateX(0); }
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  margin-top: 4px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 0;
  background: linear-gradient(120deg, var(--accent) 0%, #dc2f02 42%, var(--purple) 100%);
  background-size: 180% 100%;
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  box-shadow:
    0 14px 30px rgba(232, 93, 4, 0.3),
    0 0 0 0 rgba(232, 93, 4, 0.25);
  transition: transform 180ms var(--ease-out), box-shadow 220ms ease, filter 160ms ease, background-position 450ms ease;
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.28) 50%, transparent 70%);
  transform: translateX(-130%);
  transition: transform 0.65s ease;
}
.btn-primary:hover {
  transform: translateY(-2px);
  background-position: 100% 0;
  box-shadow: 0 18px 36px rgba(157, 78, 221, 0.28);
  filter: brightness(1.04);
}
.btn-primary:hover::after { transform: translateX(130%); }
.btn-primary:active { transform: translateY(0); }
.btn-primary i {
  font-size: 13px;
  transition: transform 200ms ease;
}
.btn-primary:hover i { transform: translateX(3px); }

.auth-switch {
  margin-top: 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.linkish {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 800;
  color: var(--purple);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 160ms ease;
}
.linkish:hover { color: var(--accent); }

.auth-trust {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 12px;
  color: #b9a294;
}
.auth-trust span {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: #fffaf5;
  font-size: 14px;
  transition: color 160ms ease, border-color 160ms ease, transform 220ms var(--ease-spring), box-shadow 200ms ease;
}
.auth-trust span:hover {
  color: var(--accent);
  border-color: #e2cbb8;
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 8px 16px rgba(232, 93, 4, 0.14);
}
.auth-foot-note {
  margin-top: 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.4;
}

/* Toast */
.toast-login {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  max-width: min(420px, calc(100vw - 32px));
  background: #2b2118;
  color: #fff8f1;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 16px 40px rgba(43, 33, 24, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 50;
  text-align: center;
}
.toast-login.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 900px) {
  .auth-modal {
    grid-template-columns: 1fr;
    max-width: 440px;
  }
  .auth-visual { min-height: 250px; }
  .visual-perks { display: none; }
  .visual-copy h2 { font-size: 24px; }
  .visual-copy p { font-size: 13px; max-width: none; }
  .auth-panel {
    padding: 24px 20px 20px;
    max-height: none;
  }
  .auth-or { margin: 14px 0 10px; }
  .float-orb.c { display: none; }
}

@media (max-width: 480px) {
  .login-stage { padding: 12px; }
  .auth-modal { border-radius: 18px; }
  .auth-visual { min-height: 200px; }
  .visual-overlay { padding: 16px 14px 14px; }
  .auth-logo { width: 64px; height: 64px; margin-bottom: 10px; border-radius: 18px; }
  .btn-primary, .btn-google { border-radius: 12px; }
  .field-control input { border-radius: 12px; min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-modal, .auth-logo, .visual-slide, .visual-slide img,
  .visual-brand, .visual-copy, .visual-perks li, .visual-dots,
  .reveal, .float-orb, .login-bg img, .auth-logo::after,
  .visual-copy h2 em, .form-error {
    animation: none !important;
    transition: none !important;
  }
  .reveal, .visual-perks li, .visual-brand, .visual-copy, .visual-dots {
    opacity: 1 !important;
    transform: none !important;
  }
  .visual-slide { opacity: 0; }
  .visual-slide.is-active { opacity: 1; }
  .visual-slide.is-active img { transform: none; }
}
