/* Cancer Protocol Machine — clinical login wall.
   External stylesheet (CSP style-src 'self'). No inline styles anywhere. */

:root {
  --primary: #0d5c63;
  --primary-lt: #1a7a8c;
  --accent: #0e7c86;
  --bg: #f4f7fa;
  --panel: #ffffff;
  --ink: #172a33;
  --muted: #5b6b73;
  --line: #d6dfe4;
  --danger: #c62828;
  --ok: #2e7d32;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── login view ── */
#login-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background:
    radial-gradient(1100px 620px at 50% -10%, #e3eef1 0%, var(--bg) 60%),
    linear-gradient(180deg, #eef4f6 0%, var(--bg) 40%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(13, 92, 99, 0.10), 0 2px 6px rgba(23, 42, 51, 0.06);
  padding: 30px 28px;
}

.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.brand-mark {
  width: 48px; height: 48px; flex: 0 0 48px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-lt) 100%);
  color: #fff; font-weight: 700; font-size: 22px; letter-spacing: 0;
  display: flex; align-items: center; justify-content: center;
}
.brand-text h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.2px; color: var(--ink); }
.brand-text p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input {
  width: 100%;
  padding: 11px 13px;
  font-size: 14px;
  color: var(--ink);
  background: #fbfdfe;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 134, 0.14);
  background: #fff;
}

.btn-primary {
  width: 100%;
  margin-top: 4px;
  padding: 12px 16px;
  font-size: 14.5px;
  font-weight: 650;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn-primary:hover { background: #0a4b51; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: #7fa6ab; cursor: default; }

.login-error {
  margin: 12px 0 0;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--danger);
  background: #fdecec;
  border: 1px solid #f4c9c9;
  border-radius: 8px;
}
.login-status { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); }

/* R66 — self-service "Forgot password?" link-style button. */
.btn-link {
  display: inline-block;
  margin: 12px 0 0;
  padding: 4px 2px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-link:hover { color: #0a4b51; }
.btn-link:disabled { color: #7fa6ab; cursor: default; }

.login-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.login-foot p { margin: 0 0 6px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.login-foot strong { color: var(--ink); }

.page-foot { font-size: 11px; color: #8a9aa1; text-align: center; }

/* ── app view ── */
#app-view { position: fixed; inset: 0; background: var(--bg); }
/* R83 — ZOOM MUST WORK. Clinicians zoom; a canvas app that swallows the
   gesture is unusable for anyone who needs larger text.

   eframe sets `touch-action: none` on its canvas so it can own every touch,
   which also cancels the browser's pinch-zoom on phones and tablets. Granting
   `pinch-zoom` back hands the two-finger gesture to the browser while egui
   keeps single-finger drags, taps and scrolls — the app loses nothing it uses.

   `-webkit-text-size-adjust` stops iOS Safari re-flowing text at odd sizes
   during the zoom, which otherwise makes the canvas jump. */
#cpm_canvas {
  position: absolute; inset: 0; width: 100vw; height: 100vh; display: block;
  touch-action: pan-x pan-y pinch-zoom;
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.boot-note {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--muted);
  z-index: 1; pointer-events: none;
}

[hidden] { display: none !important; }

/* ── R67 "stay signed in" opt-in ──────────────────────────────────────────
   Deliberately styled DOWN, not up: this is a security-relevant choice on a
   shared clinical workstation, so it reads as a quiet option rather than a
   call to action. Unchecked is the default and the safe path (tokens die with
   the tab, exactly as today). The hint line states the real bound — remember-me
   is restart tolerance INSIDE the server's 12h session cap, it does not extend
   it — because a control that overstates what it does is worse than none. */
.remember {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 2px 0 16px;
  cursor: pointer;
  user-select: none;
}
.remember input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fbfdfe;
  cursor: pointer;
  position: relative;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.remember input[type="checkbox"]:hover { border-color: var(--accent); }
.remember input[type="checkbox"]:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 134, 0.14);
}
.remember input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}
/* Tick drawn with borders — no background-image, so it cannot trip the strict
   CSP (img-src is locked down and there are no inline styles anywhere). */
.remember input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 4px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.remember-text { font-size: 12.5px; color: var(--ink); font-weight: 600; }

/* R72 — the hint line, restored. The comment above has described this element
   since R67; r681 removed the markup and this rule but left the prose, so the
   stylesheet documented a disclosure the page no longer made. Styled quieter
   than the label: it qualifies the control, it does not compete with it. */
.remember-hint {
  margin: -2px 0 0 27px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted, #5b6f79);
}

/* R68d — post-reset confirmation shown on the sign-in card. Deliberately calm:
   this is a success acknowledgement, not an alert, so it reads as part of the
   form rather than shouting over it. */
.login-notice{
  margin:0 0 4px;
  padding:10px 12px;
  border:1px solid #bcdfd2;
  border-left:3px solid #17795e;
  border-radius:6px;
  background:#f0f9f5;
  color:#14543f;
  font-size:13.5px;
  line-height:1.45;
}


/* ── R148 AUTH TABS (sign-in / sign-up toggle) ─────────────────────── */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--line);
}
.auth-tab {
  flex: 1;
  padding: 10px 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.auth-tab:hover { color: var(--ink); }
.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── R74 SPLASH ──────────────────────────────────────────────────────────
   The default paint, and the ONLY thing on screen until auth resolves. Styled
   to match the login card's own background and brand mark so the transition to
   either destination is a swap of content, not of scenery — the three-screen
   stagger the account holder reported was as much a change of background as a
   change of view. Deliberately understated: this is a wait, not an event. */
#boot-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.boot-card { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.boot-msg {
  margin: 0;
  font-size: 13px;
  color: var(--muted, #5b6f79);
  letter-spacing: 0.01em;
}
/* One slow pulse. No spinner: a spinner implies progress we cannot measure, and
   on a fast reload it appears for a single frame, which reads as a flicker. */
#boot-view .brand-mark { animation: boot-breathe 1.6s ease-in-out infinite; }
@keyframes boot-breathe { 0%,100% { opacity: 1 } 50% { opacity: 0.55 } }
@media (prefers-reduced-motion: reduce) {
  #boot-view .brand-mark { animation: none; }
}

/* ── R126 — a DETERMINATE first-load progress bar ────────────────────────
   The engine wasm compiles for several seconds on a cold first visit. R125d
   showed an indeterminate bar that only slid back and forth; it never FILLED,
   so it did not read as progress. This bar fills.

   It is time-paced, not byte-paced: WebAssembly compilation exposes no progress
   event, so no honest byte-accurate number exists. The fill is tuned to the
   real cold-start compile (~10s) and eases so it keeps advancing the whole way
   and holds near the end if a slow machine runs long — it never sits still and
   never claims 100% before the app is actually up (the splash is replaced whole
   the instant the engine is ready). It fades in after a beat so a fast, cached
   reload that finishes first never flashes a bar. */
.boot-bar {
  width: 210px; height: 4px; border-radius: 999px;
  background: rgba(91, 107, 115, 0.18);
  overflow: hidden;
  opacity: 0;
  animation: boot-bar-in 0.35s ease 0.35s forwards;
}
.boot-bar > i {
  display: block; width: 8%; height: 100%; border-radius: 999px;
  background: var(--accent, #0e7c86);
  animation: boot-fill 11s cubic-bezier(0.15, 0.72, 0.2, 1) forwards;
}
@keyframes boot-fill {
  0%   { width: 8%; }
  45%  { width: 60%; }
  75%  { width: 83%; }
  100% { width: 96%; }
}
@keyframes boot-bar-in { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .boot-bar > i { animation: none; width: 66%; }
}

/* ── R127 — the "Hades Engine" wordmark, script-set ──────────────────────
   Rendered with locally-installed script faces per OS (Segoe Script on Windows,
   Snell Roundhand / Apple Chancery on macOS, URW Chancery on Linux), falling
   back to the generic `cursive`. No @font-face, so nothing is fetched and it
   stays inside `font-src 'self'`. "Engine" stays in the sans as a tracked
   descriptor so the name reads as a product wordmark, not a signature. Used on
   the login card (<h1>) and the boot splash (<p>). */
.wordmark { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; margin: 0; }
.wordmark .wm-name {
  font-family: 'Segoe Script','Bradley Hand','Snell Roundhand','Apple Chancery','URW Chancery L',cursive;
  font-weight: 500; font-size: 22px; line-height: 1.05; color: var(--ink);
}
.wordmark .wm-kind {
  font-size: 11px; font-weight: 600; letter-spacing: 0.26em;
  text-transform: uppercase; color: var(--muted);
  position: relative; top: -1px;
}
/* Boot splash: same wordmark, centred, a touch smaller. */
.boot-wordmark { justify-content: center; }
.boot-wordmark .wm-name { font-size: 19px; }
.boot-wordmark .wm-kind { font-size: 10px; letter-spacing: 0.28em; }
