/* Sign in / create account (login.html, login.js). Apple-style: a frosted card over a soft-focus flight past the Matterhorn.
   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 video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  animation: sky-in 1.6s var(--ease-out) both;
}
@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). Only on the plans page's
   still sky: over the film they veiled the mountains in milk and drifted against its camera. */
.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 {
  /* The card is 84% white over the moving clip, so behind its text it can be as dark as #d6d6d6 (a black frame):
     the page's grey (#5b6b7c, 3.8:1 there) fell under 4.5:1 for the 12-15 px hints. This grey is 5.0:1 at worst
     (SEC-20 §10, Accessibility Inspector audit). */
  --muted: #4a5868;
  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; }
/* The whole logo in navy, as it's drawn: the three peaks over ALPINE in spaced serif capitals (Alpine, 2026-10-27;
   the peaks alone and 116 px wide until the owner asked for a bigger logo the same day) */
.brand-mark { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; color: var(--navy); }
.brand-mark svg { display: block; width: 168px; height: auto; }
.brand-name {
  font-family: var(--font-brand); font-weight: 600; font-size: 24px; line-height: 1;
  letter-spacing: .3em; margin-right: -.3em;   /* no tracking after the last letter */
  text-transform: uppercase;
}
@media (max-width: 480px) {
  .brand-mark svg { width: 140px; }
  .brand-name { font-size: 21px; }
}
.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 rgb(var(--navy-rgb) / .5); border-radius: 12px;   /* 3:1 or more on the card (WCAG 1.4.11) */
  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); }
.check input[aria-invalid="true"] { box-shadow: 0 0 0 2px var(--destructive); }
.field-hint { margin: -6px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
#title:focus { outline: none; }   /* the heading takes the focus when the step changes (login.js), not a control */
.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); }
/* Tap areas of about 44 px (D-8) without moving anything: the tick boxes' labels reach 5 px further up and down
   (behind their text, so the privacy link stays a link), and "Forgot password?" 12 px */
.check { position: relative; isolation: isolate; }
.check::before { content: ""; position: absolute; inset: -5px 0; z-index: -1; }
.link { position: relative; }
.link::after { content: ""; position: absolute; inset: calc(50% - 22px) -8px; }   /* 44 px tall whatever the line (-12 px made 43.5) */
.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; }
/* The sign-in message stays in the page as a live region (login.js show()): empty, it takes no room and isn't seen, but
   stays in the accessibility tree, so the text set later is read (A10 SEC-20) */
#msg:empty, #link-msg:empty { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.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[aria-disabled="true"] { opacity: .6; cursor: progress; transform: none; }   /* busy, kept focusable (login.js busy()) */
.link[aria-disabled="true"] { opacity: .6; cursor: progress; }
.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; }

/* An email link asking first (login.js linkGate) */
.link-text { margin: 0 0 14px; font-size: 15px; line-height: 1.45; color: var(--text); overflow-wrap: anywhere; }
#link-confirm .form-msg:not(:empty) { margin-bottom: 12px; }
#link-confirm .btn + .btn { margin-top: 10px; }

/* One row where it fits; on a phone the sentence takes its own row, centred, with the links under it */
.under { margin: 18px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; text-align: center; font-size: 13px; font-weight: 600; color: var(--navy); animation: pane-in .7s var(--ease-out) both; animation-delay: .5s; }
.under a { align-self: center; flex: none; 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); }
/* Fingers get 44 px (Apple's minimum): the sign-in / create-account switch and the links under the card */
@media (pointer: coarse) {
  .segmented button { height: 38px; }
  .segmented button::after { content: ""; position: absolute; inset: -3px 0; }   /* the control's rim counts too */
  .under a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; }
  .home-pill { min-height: 44px; }   /* "Home" while signed in was 36 px (iOS Safari 2026-11-08) */
}
.under span { align-self: center; padding: 6px 10px; border-radius: 14px; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--glass-border); }   /* on glass like the link: plain text over the moving sky fell to about 3.6:1 */

/* ---------- 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 its still poster (login.js) ---------- */
@media (prefers-reduced-motion: reduce) {
  .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; }
}
