/* Sign-in page — standalone stylesheet for /login.
 *
 * This page loads neither style.css nor app.js, so the handful of tokens it
 * needs are redeclared here under the same names and the same three-block
 * theming shape the app uses (light default, prefers-color-scheme dark, then
 * [data-theme="dark"] so an explicit choice wins in both directions). Keeping
 * the names identical means the login card and the app agree on the teal, the
 * radii and the shadows without either file importing the other.
 *
 * --err-ink is the one token that has no counterpart in style.css: --st-critical
 * (#d03b3b) is a fill colour there, always paired with a label, and it is too
 * light to set small error text in on white and too dark to set it in on the
 * dark page. So each theme gets a text-weight red of its own.
 */

:root {
  color-scheme: light;
  --surface-1:      #ffffff;
  --page:           #f4f6f6;
  --raised:         #ffffff;
  --sunken:         #eef1f1;
  --text-primary:   #0b0f0f;
  --text-secondary: #4d5658;
  --text-muted:     #869092;
  --baseline:       #c2cbcb;
  --border:         rgba(11, 15, 15, 0.09);

  --accent:         #00857C;
  --accent-hover:   #006D64;
  --accent-ink:     #00655e;
  --accent-wash:    #eaf5f4;
  --on-accent:      #ffffff;

  --st-critical: #d03b3b;
  --err-ink:     #a52a2a;   /* 5.6:1 on --surface-1 */

  --wash: rgba(11, 15, 15, 0.045);
  --shadow-sm: 0 1px 2px rgba(11, 15, 15, 0.05), 0 1px 3px rgba(11, 15, 15, 0.04);
  --shadow-md: 0 2px 6px rgba(11, 15, 15, 0.07), 0 6px 16px rgba(11, 15, 15, 0.06);
  --shadow-lg: 0 10px 40px rgba(11, 15, 15, 0.14);

  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page:           #0d0f0f;
    --raised:         #232625;
    --sunken:         #141616;
    --text-primary:   #ffffff;
    --text-secondary: #c3c8c7;
    --text-muted:     #8a9291;
    --baseline:       #3c4140;
    --border:         rgba(255, 255, 255, 0.10);

    --accent:         #00A99D;
    --accent-hover:   #1FB8AB;
    --accent-ink:     #4ad4c6;
    --accent-wash:    #122b29;
    --on-accent:      #04211f;

    --err-ink:        #ff9b95;   /* 6.9:1 on --surface-1 */

    --wash: rgba(255, 255, 255, 0.055);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.45), 0 8px 24px rgba(0,0,0,0.35);
    --shadow-lg: 0 12px 44px rgba(0,0,0,0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page:           #0d0f0f;
  --raised:         #232625;
  --sunken:         #141616;
  --text-primary:   #ffffff;
  --text-secondary: #c3c8c7;
  --text-muted:     #8a9291;
  --baseline:       #3c4140;
  --border:         rgba(255, 255, 255, 0.10);

  --accent:         #00A99D;
  --accent-hover:   #1FB8AB;
  --accent-ink:     #4ad4c6;
  --accent-wash:    #122b29;
  --on-accent:      #04211f;

  --err-ink:        #ff9b95;

  --wash: rgba(255, 255, 255, 0.055);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.45), 0 8px 24px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 44px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--page);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  accent-color: var(--accent);
  /* svh, not vh: on iOS Safari 100vh is the *expanded* viewport, so a centred
     card measured against it sits a toolbar's height too low. */
  min-height: 100vh;
  min-height: 100svh;
  /* Flex rather than `grid; place-items:center`: the shell is a single child
     that wants to fill the width up to its own cap, and a flex line gives it
     that against the viewport directly, with no auto-sized track in between to
     reason about. */
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(20px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

/* The same whisper of brand colour the app puts behind its page plane, so the
   two do not look like different products across a sign-in. */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1100px 460px at 12% -8%,
      color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    radial-gradient(760px 380px at 100% 0%,
      color-mix(in srgb, var(--accent) 5%, transparent), transparent 68%);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- shell ---------------------------------------------------------------- */

.shell { width: 100%; max-width: 396px; }

.wordmark { text-align: center; margin-bottom: 18px; }
/* The product has no logo, so the name in text *is* the mark. */
.wordmark h1 {
  margin: 0; font-size: 21px; font-weight: 660; letter-spacing: -0.028em;
  color: var(--text-primary);
}
.wordmark .env {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
  font-size: 11px; font-weight: 660; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent-ink); background: var(--accent-wash);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 999px; padding: 3px 10px;
}
.wordmark .env i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none;
}

.card {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 24px 22px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: cardIn .3s var(--ease) backwards;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* The brand hairline from header.top, moved to the top edge of the card — the
   one piece of chrome that carries over when there is no header on the page. */
.card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%,
    color-mix(in srgb, var(--accent) 65%, transparent) 26%, transparent 64%);
}

.card h2 {
  margin: 0 0 3px; font-size: 15.5px; font-weight: 640; letter-spacing: -0.02em;
}
.card .lede { margin: 0 0 18px; font-size: 12.5px; color: var(--text-secondary); }

/* --- fields --------------------------------------------------------------- */

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label {
  font-size: 11.5px; color: var(--text-secondary); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.field input {
  font: inherit; font-size: 15px;   /* >=16px avoids the iOS zoom-on-focus; 15px
                                       is the compromise the app's forms use */
  width: 100%; min-height: 48px; padding: 10px 13px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--raised); color: var(--text-primary);
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
.field input::placeholder { color: var(--text-muted); }
.field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
/* Only mark a field red once it has actually been submitted wrong — :invalid on
   its own paints every empty required field on first paint. */
.card.was-invalid .field input:invalid { border-color: color-mix(in srgb, var(--st-critical) 55%, transparent); }

/* The toggle sits inside the field, so the input reserves room for it rather
   than letting the button cover typed characters. */
.pw { position: relative; display: flex; }
.pw input { padding-right: 76px; }
.pw-toggle {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  height: 42px; min-width: 64px; padding: 0 12px;
  font: inherit; font-size: 12.5px; font-weight: 620;
  border: 0; border-radius: 7px; background: transparent; color: var(--text-secondary);
  cursor: pointer; transition: background .14s var(--ease), color .14s var(--ease);
}
.pw-toggle:hover { background: var(--wash); color: var(--text-primary); }
.pw-toggle:focus-visible {
  outline: none; color: var(--accent-ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* --- error ---------------------------------------------------------------- */

.form-error {
  margin: 0 0 14px;
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px; font-weight: 540; line-height: 1.45;
  color: var(--err-ink);
  background: color-mix(in srgb, var(--st-critical) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--st-critical) 26%, transparent);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.form-error::before { content: "!"; font-weight: 800; line-height: 1.45; flex: none; }
/* The region stays in the DOM so it is a live region from first paint; it is
   only *drawn* once it holds a message. Generated content does not count
   towards :empty, so the "!" mark does not defeat this. */
.form-error:empty { display: none; }

/* --- submit --------------------------------------------------------------- */

.submit {
  width: 100%; min-height: 48px;
  font: inherit; font-size: 14px; font-weight: 620;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent);
  cursor: pointer; box-shadow: var(--shadow-sm);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .12s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
.submit:hover:not(:disabled) { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.submit:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.submit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--page), 0 0 0 6px color-mix(in srgb, var(--accent) 45%, transparent);
}
/* Not 0.45 like the app's disabled buttons: this one is disabled *while working*
   and still has to read as the thing you are waiting on. */
.submit:disabled { cursor: progress; opacity: 0.72; box-shadow: none; }

.spinner {
  width: 15px; height: 15px; flex: none; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--on-accent) 35%, transparent);
  border-top-color: var(--on-accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- footer --------------------------------------------------------------- */

.foot {
  margin-top: 16px; text-align: center;
  font-size: 11.5px; color: var(--text-muted); line-height: 1.55;
}

.theme-toggle {
  display: block; margin: 10px auto 0;
  font: inherit; font-size: 11.5px; font-weight: 560;
  min-height: 44px; padding: 0 14px;
  background: none; border: 0; border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.theme-toggle:hover { background: var(--wash); color: var(--text-primary); }
.theme-toggle:focus-visible {
  outline: none; color: var(--text-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Visually hidden but still announced — used for the live status text that
   tells a screen reader the form is working. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* At 360px the card's own padding is most of the width, so trim it and let the
   fields keep their size — a cramped tap target costs more than a cramped
   margin does. */
@media (max-width: 400px) {
  .card { padding: 20px 16px 18px; border-radius: 14px; }
  .wordmark h1 { font-size: 19px; }
}
