/* Sign in / create account (login.html, login.js). Apple-style: a frosted card over a flight across snowy mountains.
   Colours, type, radii and motion come from design/tokens.css. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body.login-page {
  margin: 0; min-height: 100dvh;
  font-family: var(--font); font-size: var(--text-base); line-height: 1.5;
  color: var(--text); background: var(--sky);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ---------- Background: the flight ---------- */
.sky { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: linear-gradient(var(--sky), var(--sky-horizon) 45%, var(--snow)); }
.sky canvas, .sky video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  animation: sky-in 1.6s var(--ease-out) both;
}
.sky canvas { filter: blur(1.5px) saturate(1.08); transform: scale(1.01); }   /* softens the renderer's depth slices into a painted look */
.sky video { opacity: 0; transition: opacity 1.2s var(--ease); }
.sky video.ready { opacity: 1; }
@keyframes sky-in { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: none; } }

/* Thin clouds drifting across the view, two layers at different speeds (D2 motion: slow and soft) */
.clouds {
  position: absolute; inset: -20% -50%; pointer-events: none;
  background-repeat: no-repeat;
  filter: blur(18px);
  will-change: transform;
}
.clouds-far {
  opacity: .55;
  background-image:
    radial-gradient(ellipse 28% 9% at 22% 28%, rgba(255,255,255,.95), transparent 70%),
    radial-gradient(ellipse 36% 10% at 62% 20%, rgba(255,255,255,.85), transparent 70%),
    radial-gradient(ellipse 24% 7% at 86% 34%, rgba(255,255,255,.8), transparent 70%);
  animation: drift 90s linear infinite;
}
.clouds-near {
  opacity: .5;
  background-image:
    radial-gradient(ellipse 32% 12% at 40% 60%, rgba(255,255,255,.9), transparent 70%),
    radial-gradient(ellipse 22% 8% at 78% 72%, rgba(255,255,255,.8), transparent 70%);
  animation: drift 55s linear infinite reverse;
}
@keyframes drift { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgb(var(--navy-rgb) / .18) 100%),
    linear-gradient(rgba(255,255,255,.08), transparent 30%, transparent 70%, rgb(var(--navy-rgb) / .14));
}

/* ---------- Layout ---------- */
.stage {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(72px, env(safe-area-inset-top) + 64px) var(--gutter) max(28px, env(safe-area-inset-bottom) + 20px);
}
.home-pill {
  position: fixed; z-index: 2; top: max(16px, env(safe-area-inset-top) + 8px); left: var(--gutter);
  display: inline-flex; align-items: center; gap: 4px;
  height: 36px; padding: 0 14px 0 8px; border-radius: 999px;
  background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border); box-shadow: 0 1px 3px rgb(var(--navy-rgb) / .1);
  color: var(--navy); font-size: 14px; font-weight: 600; text-decoration: none;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-out);
}
.home-pill:hover { background: var(--glass-solid); }
.home-pill:active { transform: scale(.97); }
.home-pill svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- The card (frosted glass) ---------- */
.card {
  width: min(100%, 420px);
  padding: 28px 28px 24px;
  border-radius: var(--radius-lg);
  background: var(--glass-thick);
  -webkit-backdrop-filter: var(--blur-thick); backdrop-filter: var(--blur-thick);
  border: 1px solid var(--glass-border);
  box-shadow: 0 24px 60px rgb(var(--navy-rgb) / .22), 0 2px 6px rgb(var(--navy-rgb) / .08), inset 0 1px 0 rgba(255,255,255,.7);
  animation: card-in .7s var(--ease-sheet) both; animation-delay: .15s;
}
@keyframes card-in { from { opacity: 0; transform: translateY(28px) scale(.98); } to { opacity: 1; transform: none; } }
.brand { text-align: center; margin-bottom: 20px; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--navy); color: #fff;
  box-shadow: 0 8px 20px rgb(var(--navy-rgb) / .3), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-mark svg { width: 34px; height: 34px; }
.card h1 {
  margin: 14px 0 6px;
  font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1.15;
  letter-spacing: var(--tracking-title); color: var(--navy);
}
.lead { margin: 0; font-size: 15px; color: var(--muted); }

/* Switching between the auth pane and the welcome pane crossfades (D2) */
.pane { animation: pane-in var(--dur) var(--ease-out) both; }
@keyframes pane-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Segmented control with a sliding thumb */
.segmented {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  padding: 3px; border-radius: 12px; background: var(--fill-2);
  margin-bottom: 16px;
}
.segmented-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px);
  border-radius: 9px; background: #fff; box-shadow: 0 1px 3px var(--stroke), 0 3px 8px rgb(var(--navy-rgb) / .08);
  transition: transform var(--dur) var(--ease-sheet);
}
.segmented.signup .segmented-thumb { transform: translateX(100%); }
.segmented button {
  position: relative; z-index: 1;
  height: 34px; border: 0; background: none; border-radius: 9px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
  transition: color var(--dur-fast) var(--ease);
}
.segmented button[aria-selected="true"] { color: var(--text); }

.demo-note {
  margin: 0 0 14px; padding: 9px 12px; border-radius: var(--radius-sm);
  background: rgb(var(--accent-rgb) / .1); color: #0b4f99; font-size: 13px; line-height: 1.4;
}

/* Form */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field.show { animation: pane-in var(--dur) var(--ease-out) both; }
.field input {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--stroke); border-radius: 12px;
  background: rgba(255,255,255,.82); color: var(--text);
  font: inherit; font-size: 16px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.field input::placeholder { color: rgb(var(--navy-rgb) / .35); }
.field input:focus { outline: none; background: #fff; border-color: var(--accent); box-shadow: 0 0 0 4px rgb(var(--accent-rgb) / .22); }
.field input[aria-invalid="true"] { border-color: var(--destructive); }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 46px; }
.pw-toggle {
  position: absolute; top: 0; right: 0; width: 46px; height: 46px;
  border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 12px;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle[aria-pressed="true"] { color: var(--accent); }
.pw-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.form-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-top: -2px; }
.form-row .link { flex: none; margin-top: 2px; }
.check.remember { font-weight: 600; font-size: 13px; line-height: 1.35; }
.check.remember input { margin-top: 1px; }
.check small { display: block; margin-top: 1px; font-size: 12px; font-weight: 400; color: var(--muted); }
.link { border: 0; background: none; padding: 0; font: inherit; font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; color: var(--text); cursor: pointer; }
.check input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.check a { color: var(--accent); }
.form-msg {
  margin: 0; padding: 9px 12px; border-radius: var(--radius-sm);
  background: rgba(198, 40, 40, .1); color: var(--destructive); font-size: 13px; line-height: 1.4;
  animation: pane-in var(--dur-fast) var(--ease-out) both;
}
.form-msg.info { background: rgb(var(--accent-rgb) / .1); color: #0b4f99; }
.form-msg.ok { background: rgba(31, 157, 85, .12); color: #14683a; }
.form.shake { animation: shake .4s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 46px; padding: 0 18px;
  border: 0; border-radius: 12px;
  background: var(--fill-2); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--fill-hover); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px rgb(var(--accent-rgb) / .3); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
.btn:not(.primary).busy::after { border-color: rgb(var(--navy-rgb) / .2); border-top-color: var(--navy); }
@keyframes spin { to { transform: rotate(360deg); } }
.btn:focus-visible, .link:focus-visible, .segmented button:focus-visible, .pw-toggle:focus-visible, .home-pill:focus-visible, .under a:focus-visible, .check input:focus-visible {
  outline: 3px solid var(--focus-ring); outline-offset: 2px;
}

.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--separator); }
.providers { display: flex; flex-direction: column; gap: 10px; }
.btn.provider { background: #fff; border: 1px solid var(--stroke); }
.btn.provider:hover { background: var(--snow-light); }
.btn.provider svg { width: 18px; height: 18px; flex: none; }
.btn.provider.apple { background: #000; color: #fff; border-color: #000; }
.btn.provider.apple:hover { background: #1d1d1f; }

/* Welcome pane */
.me { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; padding: 14px; border-radius: var(--radius); background: rgba(255,255,255,.6); }
.avatar {
  display: grid; place-items: center; flex: none;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--navy); color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .02em;
}
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.me-text strong { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#welcome .btn + .btn { margin-top: 10px; }
#welcome .form-msg { margin-bottom: 12px; }

.under { margin: 18px 0 0; display: flex; gap: 10px; font-size: 13px; font-weight: 600; color: var(--navy); animation: pane-in .7s var(--ease-out) both; animation-delay: .5s; }
.under a { color: inherit; text-decoration: none; padding: 6px 10px; border-radius: 999px; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--glass-border); }
.under a:hover { background: var(--glass-solid); }
.under span { align-self: center; opacity: .6; }

/* ---------- Phones ---------- */
@media (max-width: 480px) {
  .card { padding: 24px 20px 20px; border-radius: 24px; }
  .card h1 { font-size: 24px; }
  .home-pill { position: absolute; }   /* scrolls away with the page instead of sitting over the card */
}

/* ---------- Reduce motion: nothing slides, drifts or flies; the flight is a still frame (login.js) ---------- */
@media (prefers-reduced-motion: reduce) {
  .sky canvas, .sky video, .card, .pane, .field.show, .form-msg, .under { animation: none; }
  .clouds { animation: none; }
  .segmented-thumb, .btn, .home-pill { transition: none; }
  .form.shake { animation: none; }
}
