/* The website's secondary pages. Sign-in, account and replay load it after
   app.css (body.site-page): the site header, buttons and spacing scale of
   site.css, drawn with app.css tokens. The security page loads it after
   site.css (body.read-page) for its reading column only, so every rule
   below is scoped to one of those body classes. Contrast ratios are
   measured on --bg-raised. */

:root {
  --danger: #b3261e;            /* 6.4:1, white on it 6.4:1 */
  --danger-ink: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --danger: #ff8a80;          /* 7.9:1, dark ink on it 9.6:1 */
    --danger-ink: #2a0b08;
  }
}
:root[data-theme='dark'] {
  --danger: #ff8a80;
  --danger-ink: #2a0b08;
}

/* ---- the spacing scale of site.css, stepped down at the same widths -------- */

.site-page {
  --gutter: 32px;
  --card-pad: 28px;
  --sec-pad: 96px;
  --head-gap: 48px;
  --head-h: 62px;
  --dot: color-mix(in srgb, var(--text) 9%, transparent);
  background: var(--bg);
  font: 16px/1.6 var(--sans);
  overflow-x: clip;
}
@media (max-width: 1100px) {
  .site-page { --gutter: 24px; --sec-pad: 80px; --head-gap: 40px; }
}
@media (max-width: 720px) {
  .site-page { --gutter: 16px; --card-pad: 22px; --sec-pad: 56px; --head-gap: 32px; }
}
@media (max-width: 360px) {
  .site-page { --card-pad: 20px; }
}
.site-page h1, .site-page h2 { text-wrap: balance; }
.site-page .dotted {
  background-image: radial-gradient(circle, var(--dot) 1px, transparent 1.2px);
  background-size: 22px 22px; background-position: 11px 11px;
}
.site-page .eyebrow {
  margin: 0 0 12px; font: 600 12px/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent);
}

/* ---- buttons: site.css's, on top of app.css's .btn ------------------------- */

.site-page .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: auto; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--bg-raised); color: var(--text);
  font: 600 15px/1.2 var(--sans); text-align: center; text-decoration: none;
  transition: background var(--dur), filter var(--dur), border-color var(--dur);
}
.site-page .btn:hover { background: var(--bg-hover); }
.site-page :is(.btn.primary, .btn-primary) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.site-page :is(.btn.primary, .btn-primary):hover { background: var(--accent); filter: brightness(1.08); }
.site-page .btn.danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.site-page .btn.danger:hover { background: var(--danger); filter: brightness(1.06); }
/* Opens the delete form: the danger tone, without the fill the final step has. */
.site-page .btn.danger-quiet { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--line-strong)); }
.site-page .btn:disabled { opacity: .55; cursor: default; filter: none; }
.site-page .btn-sm { min-height: 32px; padding: 6px 12px; font-size: 13px; }

/* ---- the site header (index.html's markup) --------------------------------- */

.site-page .site-head {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-page .wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 var(--gutter); }
.site-page .head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: var(--head-h); }
.site-page .site-head .wordmark { display: inline-flex; align-items: center; min-height: 44px; font-size: 22px; color: var(--text); text-decoration: none; }
.site-page .head-nav { display: flex; align-items: center; gap: 4px; }
.site-page .btn-head { margin-left: 8px; white-space: nowrap; }

/* ---- fields and messages, shared by sign-in and account -------------------- */

.auth-form { display: grid; gap: 16px; text-align: left; }
.site-page .field { display: grid; gap: 6px; font: 500 13px/1.3 var(--sans); color: var(--text-dim); }
.site-page .field input {
  height: 44px; padding: 0 12px; border: 1px solid var(--line-input); border-radius: var(--r-md);
  background: var(--bg); color: var(--text); font: 400 16px/1.3 var(--sans);
}
.site-page .field input.auth-code { font: 500 20px/1 var(--mono); letter-spacing: .14em; text-align: center; }
.auth-hint { margin: -8px 0 0; font-size: 13px; line-height: 1.45; color: var(--text-faint); }
.auth-msg {
  margin: 0; padding: 10px 12px; border-radius: var(--r-md); font-size: 14px; line-height: 1.45;
  color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--bg-raised));
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}
.auth-msg:empty { display: none; }
.site-page .btn.auth-submit { width: 100%; min-height: 44px; margin-top: 4px; }
.acct .btn.auth-submit { width: auto; margin-top: 0; }
/* Cloudflare Turnstile draws its own box here (flexible width, 65px tall), only when the check is on. */
.auth-human { display: flex; justify-content: center; min-height: 65px; }
.auth-human[hidden] { display: none; }
.site-page .link-btn { font-size: 14px; }

/* ---- sign in: one card on the dotted paper --------------------------------- */

.auth-main {
  min-height: calc(100dvh - var(--head-h) - 1px - env(safe-area-inset-top));
  display: flex; flex-direction: column; align-items: center;
  /* Top-anchored, not centered: every step's card starts at the same height, so switching steps never jumps. */
  padding: calc(var(--sec-pad) - var(--head-gap) / 2) var(--gutter) calc(var(--sec-pad) + env(safe-area-inset-bottom));
}
.auth-card {
  width: min(400px, 100%); padding: var(--card-pad);
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
}
.auth-card h1 { margin: 0 0 8px; text-align: center; font: 700 26px/1.2 var(--sans); letter-spacing: -.025em; }
.auth-sub { margin: 0 0 24px; text-align: center; font-size: 15px; line-height: 1.5; color: var(--text-dim); text-wrap: pretty; }
.auth-sub:empty { display: none; }
.auth-sub + .auth-hint { margin: -12px 0 0; text-align: center; }

/* Sign in | Create account: Mokxi's segmented control, the chosen side filled. */
.auth-card .seg { display: flex; gap: 4px; margin: 0 0 20px; padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.auth-card .seg button {
  flex: 1 1 0; min-width: 0; height: 36px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 7px; background: none; box-shadow: none;
  color: var(--text-dim); font: 600 14px/1.2 var(--sans); white-space: nowrap;
  transition: background var(--dur), color var(--dur);
}
.auth-card .seg button:hover { color: var(--text); }
.auth-card .seg button[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: none; }

/* Continue with Google / GitHub: full-width secondary buttons, the mark in
   the text color so it holds in light and dark, and "or" on a hairline. */
.auth-oauth { display: grid; gap: 8px; margin: 0 0 20px; }
.site-page .btn.oauth-btn { width: 100%; min-height: 44px; gap: 10px; }
.oauth-btn svg, .provider-mark { flex: none; width: 18px; height: 18px; fill: currentColor; stroke: none; }
.auth-or { display: flex; align-items: center; gap: 12px; margin: 12px 0 0; font-size: 13px; line-height: 1; color: var(--text-faint); }
.auth-or::before, .auth-or::after { content: ''; flex: 1 1 0; height: 1px; background: var(--line); }
#oauthMsg { margin: 0 0 16px; }

/* The ways around the form: one centered row, a hairline between two links. */
.auth-alt { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0 12px; margin: 16px 0 0; }
.auth-alt .link-btn { min-height: 44px; }
.auth-sep { width: 1px; height: 16px; background: var(--line-strong); }
.auth-actions { display: grid; gap: 8px; margin: 0; }
.auth-actions .btn { width: 100%; min-height: 44px; }
.auth-foot { margin: 16px 0 0; text-align: center; font-size: 14px; }
.auth-foot a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; color: var(--text-dim); }
.auth-foot a:hover { color: var(--text); }

/* ---- account: one card per section ------------------------------------------ */

.acct { max-width: calc(680px + 2 * var(--gutter)); margin: 0 auto; padding: var(--head-gap) var(--gutter) calc(var(--sec-pad) + env(safe-area-inset-bottom)); }
.acct[aria-busy='true'] .acct-card { visibility: hidden; }
.acct-title { margin: 0 0 var(--card-pad); font: 700 36px/1.15 var(--sans); letter-spacing: -.025em; }
.acct-notice { margin: 0 0 20px; padding: 12px 16px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--text); font-size: 15px; }
.acct-card {
  margin: 0 0 20px; padding: var(--card-pad);
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.card-head { margin: 0 0 20px; }
.card-head h2 { margin: 0; font: 650 19px/1.3 var(--sans); letter-spacing: -.01em; }
.card-head p { margin: 4px 0 0; font-size: 15px; line-height: 1.5; color: var(--text-dim); text-wrap: pretty; }
.acct-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.acct-value { margin: 0; overflow-wrap: anywhere; }
.acct-value strong { font-weight: 650; }
.acct-meta { margin-left: 6px; font-size: 14px; color: var(--text-dim); }
.acct-help { margin: 12px 0 0; font-size: 14px; line-height: 1.5; color: var(--text-dim); }
.acct-help:first-child { margin-top: 0; }
.acct-help:empty { display: none; }
.acct-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.auth-form .acct-actions { margin-top: 4px; }
.acct-sub { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.acct .auth-form > :is(.field, .auth-msg, .auth-hint) { max-width: 400px; }

/* Pills: mono, uppercase, the accent when the news is good. */
.badge-pill {
  display: inline-block; margin-left: 6px; padding: 4px 8px; border-radius: 999px; vertical-align: 2px;
  background: var(--bg-hover); color: var(--text-dim);
  font: 600 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
}
.badge-pill:empty { display: none; }
.badge-pill.ok { background: var(--accent-soft); color: var(--accent); }
.acct-value > .badge-pill:first-child { margin: 0 8px 0 0; }

/* Plan: what Pro adds, as a quiet checked list. */
.plan-list { margin: 8px 0 0; padding: 0; list-style: none; font-size: 15px; }
.plan-list li { position: relative; padding: 4px 0 4px 26px; }
.plan-list li::before {
  content: ''; position: absolute; left: 3px; top: .78em; width: 11px; height: 6px;
  border: solid var(--accent); border-width: 0 0 2px 2px; transform: rotate(-45deg);
}
#planMsg { margin-top: 16px; }

/* Two-factor setup: numbered steps, the code to scan in its own frame. */
.acct-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.acct-steps > li { position: relative; margin: 0 0 24px; padding-left: 36px; counter-increment: step; }
.acct-steps > li:last-child { margin-bottom: 0; }
.acct-steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font: 600 12px/1 var(--mono);
}
.acct-steps .auth-form { margin-top: 12px; }
.tfa-scan {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 20px;
  margin-top: 12px; padding: 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-tint);
}
/* Scanners need dark on light, so the code keeps a white tile in dark mode too. */
.qr { width: 168px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-card); }
.qr:empty { display: none; }
.qr svg { display: block; width: 100%; height: auto; stroke: none; }
.qr svg rect { fill: #fff; }
.qr svg path { fill: #000; }
.tfa-key .acct-help { margin: 0; }
.setup-key {
  margin: 8px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-raised);
  font: 15px/1.5 var(--mono); letter-spacing: .06em; word-spacing: .35em; overflow-wrap: anywhere; user-select: all;
}

/* Recovery codes: a framed sheet of numbered mono codes, two to a row. */
.codes {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  margin: 16px 0 0; padding: 16px; list-style: none; counter-reset: code;
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-tint);
  user-select: all;
}
.codes li {
  display: flex; align-items: baseline; gap: 10px; padding: 8px 12px; counter-increment: code;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-raised);
  font: 500 16px/1.4 var(--mono); letter-spacing: .06em; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.codes li::before { content: counter(code, decimal-leading-zero); font-size: 11px; letter-spacing: .04em; color: var(--text-faint); }
.codes:empty { display: none; }

.devices { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.device { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.device p { margin: 0; }
.device-name { font-weight: 600; }
.device .device-when { margin-top: 2px; font-size: 13px; color: var(--text-faint); }
#devicesMsg { margin-top: 16px; }

/* Sign-in methods: the device rows, each led by the provider's mark. */
.provider { display: flex; align-items: center; gap: 12px; min-width: 0; }
.provider > div { min-width: 0; }
.provider .device-when { overflow-wrap: anywhere; }
#providersMsg { margin-top: 16px; }

/* ---- the security page: a reading column on site.css ----------------------- */

.read-page .read { max-width: 68ch; }
.read-page .read h1 { font-size: 36px; line-height: 1.15; letter-spacing: -.025em; }
.read-page .read .lead { margin-top: 20px; }
.read-page .read h2 { margin-top: 40px; font: 650 20px/1.35 var(--sans); letter-spacing: -.01em; }
.read-page .read h2 + p { margin-top: 8px; }
.read-page .read p + p { margin-top: 16px; }
.read-page .read .small { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
@media (max-width: 1100px) { .read-page .read h1 { font-size: 32px; } }
@media (max-width: 720px) {
  .read-page .read h1 { font-size: 28px; }
  .read-page .read h2 { margin-top: 32px; font-size: 18px; }
}

/* ---- phones: 44px targets, the header steps down as site.css's does -------- */

@media (max-width: 720px), (pointer: coarse) {
  .site-page .btn, .site-page .btn-sm, .site-page .link-btn { min-height: 44px; }
  .site-page .btn-sm { padding: 8px 14px; }
  .auth-card .seg button { height: 44px; }
}
@media (max-width: 1100px) {
  .acct-title { font-size: 32px; }
}
@media (max-width: 720px) {
  .site-page .site-head .wordmark { font-size: 20px; }
  .site-page .btn-head { margin-left: 4px; padding: 8px 14px; }
  .acct-title { font-size: 28px; }
  .acct-actions .btn { flex: 1 1 auto; }
  .tfa-scan { grid-template-columns: 1fr; justify-items: center; padding: 16px; text-align: center; }
  .tfa-key { width: 100%; }
  .codes { padding: 12px; }
  .codes li { padding: 8px 10px; font-size: 15px; }
}
@media (max-width: 420px) {
  .site-page .btn-head { padding: 8px 12px; font-size: 14px; }
}
@media (max-width: 359px) {
  .auth-sep { display: none; }
  .auth-alt { flex-direction: column; }
  .codes { grid-template-columns: 1fr; }
}
@media (max-width: 340px) {
  .site-page .site-head .wordmark { font-size: 18px; }
}
