/* MocoAuth design tokens, from the Design sketchbook (015 Latch, 016 Tune, 017 Tide).
   Black, white, one orange dot: the accent is used for one thing at a time (a loading
   line, an error, today's point on a chart). Shared by the sign-in pages and the admin console. */
:root {
  --bg: #09090a;
  --fg: #ececec;
  --muted: #6f6f74;
  --faint: rgba(255, 255, 255, .16);
  --line: rgba(255, 255, 255, .09);
  --accent: #ff5a36;
  --sans: "Outfit", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, "PingFang SC", "Microsoft YaHei", monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --gutter: clamp(20px, 4vw, 48px);
  color-scheme: dark;
}

/* MocoAuth first-party pages. Adapted from Design 015 · Latch. No inline styles anywhere
   (strict CSP), so animation delays are classes (.d0–.d9) instead of style attributes. */

@font-face {
  font-family: "Outfit";
  src: url(fonts/outfit-latin-wght-normal.woff2) format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url(fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2");
  font-weight: 400;
  font-display: swap;
}

/* Design tokens (:root variables) come from @mocoauth/ui-tokens and are prepended at load. */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--sans); font-weight: 300;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
  display: grid; grid-template-rows: auto 1fr auto; min-height: 100vh;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background: radial-gradient(60vmax 40vmax at 50% -8%, rgba(255, 255, 255, .055), transparent 70%);
}
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1; opacity: 0;
  background: radial-gradient(40vmax 26vmax at 50% 62%, rgba(255, 90, 54, .07), transparent 70%);
  transition: opacity 1s var(--ease);
}
body.busy::after { opacity: 1; }

a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
::selection { background: var(--fg); color: var(--bg); }
:focus-visible { outline: 1px solid var(--faint); outline-offset: 4px; }
.mono { font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: .14em; text-transform: uppercase; }
:lang(zh-CN) .mono { letter-spacing: .08em; }
.muted { color: var(--muted); }

.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; overflow: visible; display: block; flex: none; }
.ic * { stroke-dasharray: 1; stroke-dashoffset: 0; }
.draw * { animation: draw .9s var(--ease) both; }
.draw *:nth-child(2) { animation-delay: .25s; }
.draw *:nth-child(3) { animation-delay: .4s; }
@keyframes draw { from { stroke-dashoffset: 1; opacity: 0; } 8% { opacity: 1; } }

/* ---------- Top + bottom bars ---------- */
.bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: clamp(20px, 3vw, 32px) var(--gutter); }
.mark { font-size: 20px; font-weight: 300; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; text-decoration: none; }
.mark svg { width: 20px; height: 20px; }
.lang { display: flex; gap: 14px; }
.lang a { color: var(--muted); text-decoration: none; transition: color .2s; }
.lang a:hover, .lang a[aria-current="true"] { color: var(--fg); }
.foot { align-items: flex-end; flex-wrap: wrap; }

/* ---------- Intro: a latch line opens (sign-in page only) ---------- */
.latch {
  position: fixed; left: 0; right: 0; top: 50%; height: 1px; pointer-events: none; z-index: 5;
  background: linear-gradient(90deg, transparent, var(--fg) 30%, var(--fg) 70%, transparent);
  box-shadow: 0 0 18px rgba(255, 255, 255, .45);
  transform: scaleX(0); opacity: 0;
  animation: latch 1.5s var(--ease) .15s forwards;
}
@keyframes latch {
  0%   { transform: scaleX(0) translateY(0); opacity: 1; }
  45%  { transform: scaleX(1) translateY(0); opacity: 1; }
  100% { transform: scaleX(1) translateY(-46px); opacity: 0; }
}
.r { animation: rise .9s var(--ease) both; animation-delay: calc(var(--d, 0) * 70ms + var(--base, 0ms)); }
.intro main .r { --base: 1000ms; }
.intro .bar .r { --base: 900ms; }
.d0 { --d: 0; } .d1 { --d: 1; } .d2 { --d: 2; } .d3 { --d: 3; } .d4 { --d: 4; }
.d5 { --d: 5; } .d6 { --d: 6; } .d7 { --d: 7; } .d8 { --d: 8; } .d9 { --d: 9; }
@keyframes rise { from { opacity: 0; filter: blur(10px); transform: translateY(10px); } to { opacity: 1; filter: none; transform: none; } }

/* ---------- Card ---------- */
main { display: grid; place-items: center; padding: 24px var(--gutter) 40px; }
.card { width: min(360px, 100%); }
.card.wide { width: min(420px, 100%); }

.greet { font-weight: 200; font-size: clamp(40px, 6vw, 52px); line-height: 1.05; letter-spacing: -.025em; overflow-wrap: anywhere; }
:lang(zh-CN) .greet { letter-spacing: 0; font-weight: 300; }
.sub { color: var(--muted); font-size: 16px; margin: 14px 0 40px; }

.notice, .alert { margin: -16px 0 32px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); line-height: 1.6; }
.notice { color: var(--fg); }
.alert { color: var(--accent); }

/* field: label above, hairline below that draws in from the left on focus */
.field { position: relative; margin-bottom: 38px; }
.field .head { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); transition: color .3s; }
.field:focus-within .head label { color: var(--fg); }
.field .head a, .link { color: var(--muted); text-decoration: none; cursor: pointer; transition: color .2s; }
.field .head a:hover, .link:hover { color: var(--fg); }
.box { position: relative; }
.box input {
  width: 100%; height: 44px; background: transparent; border: 0; outline: 0; padding: 0;
  font: 300 18px/1 var(--sans); color: var(--fg); caret-color: var(--accent);
}
.box input::placeholder { color: rgba(255, 255, 255, .18); }
.box input:-webkit-autofill { -webkit-text-fill-color: var(--fg); transition: background-color 99999s; }
.box.pw input { padding-right: 36px; }
.box::before, .box::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; }
.box::before { background: var(--line); }
.box::after { background: var(--fg); transform: scaleX(0); transform-origin: left; transition: transform .6s var(--ease), background .3s; }
.field:focus-within .box::after { transform: scaleX(1); }
.field.bad .box::after { background: var(--accent); transform: scaleX(1); }
.eye { position: absolute; right: 0; top: 0; height: 44px; width: 32px; display: grid; place-items: center end; color: var(--muted); transition: color .2s; }
.eye[hidden] { display: none; }
.eye:hover { color: var(--fg); }
.msg { position: absolute; left: 0; top: calc(100% + 10px); color: var(--muted); opacity: 0; transform: translateY(-3px); transition: opacity .3s, transform .3s var(--ease); white-space: nowrap; }
.msg.on { opacity: 1; transform: none; }
.field.bad .msg { color: var(--accent); }

.row { display: flex; justify-content: space-between; align-items: center; margin: 0 0 32px; }
.tick { display: flex; align-items: center; gap: 10px; color: var(--muted); cursor: pointer; user-select: none; transition: color .2s; }
.tick:hover, .tick:has(input:checked) { color: var(--fg); }
.tick input { position: absolute; opacity: 0; pointer-events: none; }
.tick .sq { width: 14px; height: 14px; border: 1px solid var(--faint); border-radius: 3px; display: grid; place-items: center; transition: border-color .2s; }
.tick .sq svg { width: 10px; height: 10px; stroke-width: 2; }
.tick .sq path { stroke-dashoffset: 1; transition: stroke-dashoffset .35s var(--ease); }
.tick input:checked + .sq { border-color: var(--fg); }
.tick input:checked + .sq path { stroke-dashoffset: 0; }
.tick input:focus-visible + .sq { outline: 1px solid var(--faint); outline-offset: 3px; }

/* primary button: filled, becomes a loading line while the form submits */
.go {
  position: relative; width: 100%; height: 52px; border-radius: 26px; overflow: hidden;
  background: var(--fg); color: var(--bg); font-size: 16px; font-weight: 400;
  transition: background .4s var(--ease), color .4s var(--ease), box-shadow .4s var(--ease);
}
.go:not(:disabled):hover { box-shadow: 0 0 32px rgba(255, 255, 255, .16); }
.go .lbl, .go .load { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; transition: opacity .3s, filter .3s; }
.go:not(:disabled):hover .lbl .ic { animation: nudge .5s var(--ease); }
@keyframes nudge { 50% { transform: translateX(4px); } }
.go .load { opacity: 0; justify-content: space-between; padding: 0 24px; color: var(--fg); }
.go .ln { position: absolute; left: 26px; bottom: 0; height: 1px; width: calc(var(--p, 0) * (100% - 52px)); background: var(--accent); box-shadow: 0 0 10px var(--accent), 0 0 2px var(--accent); opacity: 0; }
.go.busy { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.go.busy .lbl { opacity: 0; filter: blur(6px); }
.go.busy .load, .go.busy .ln { opacity: 1; }
.shake { animation: shake .45s var(--ease); }
@keyframes shake { 20% { transform: translateX(-6px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } 100% { transform: none; } }

.ghost {
  width: 100%; height: 52px; border-radius: 26px; box-shadow: inset 0 0 0 1px var(--line);
  display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 16px; font-weight: 300;
  transition: box-shadow .3s; text-decoration: none;
}
.ghost:hover { box-shadow: inset 0 0 0 1px var(--faint); }
.stack { display: grid; gap: 12px; }

.alt { margin-top: 28px; display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); }
.alt a { color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--line); transition: border-color .2s; }
.alt a:hover { border-color: var(--fg); }
.back { display: inline-flex; align-items: center; gap: 8px; margin-top: 28px; }
.back .ic { width: 14px; height: 14px; }
.inline-form { display: inline; }
.linkish { color: var(--fg); border-bottom: 1px solid var(--line); text-transform: inherit; letter-spacing: inherit; font: inherit; }
.linkish:hover { border-color: var(--fg); }

/* big icon + facts (sent, account, consent, error) */
.big-ic { width: 44px; height: 44px; stroke-width: 1.25; margin: 0 0 28px -4px; }
.big-ic.warn { color: var(--accent); }
.facts { border-top: 1px solid var(--line); margin: 0 0 32px; }
.facts > div { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.facts dd { color: var(--fg); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; letter-spacing: .02em; }
.facts dt { color: var(--muted); flex: none; }
.facts.wrap dd { white-space: normal; overflow-wrap: anywhere; }

/* consent scopes */
.scopes { list-style: none; border-top: 1px solid var(--line); margin: 12px 0 32px; }
.scopes li { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
.scopes .ic { width: 16px; height: 16px; color: var(--muted); }
.label { color: var(--muted); }
.footnote { margin-top: 24px; color: var(--muted); }

/* passkeys */
.passkey { margin-top: 12px; }
.passkey[hidden] { display: none; }
.passkey .ghost .ic, .passkey .go .ic { width: 18px; height: 18px; }
a.go { display: block; text-decoration: none; }
.status { text-align: center; color: var(--muted); min-height: 14px; margin-top: 14px; text-indent: .14em; }
.status.pulse { animation: pulse 1.4s ease-in-out infinite; }
.status.bad { color: var(--accent); }
@keyframes pulse { 50% { opacity: .35; } }

/* security settings */
.rows { list-style: none; border-top: 1px solid var(--line); margin: 0 0 32px; }
.rows li { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.rows li > span:last-child { display: flex; align-items: center; gap: 12px; text-transform: none; letter-spacing: .02em; color: var(--fg); }
.rows .sub-row { padding-left: 16px; }
.rows .sub-row > span:first-child { text-transform: none; letter-spacing: .02em; }
.mini { padding: 6px 12px; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); color: var(--fg); text-decoration: none; transition: box-shadow .2s; font-size: 10px; }
.mini:hover { box-shadow: inset 0 0 0 1px var(--faint); }
.notice a, .notice .linkish { color: var(--fg); }

/* authenticator setup: dark modules on a light tile scan most reliably */
.qr { width: 184px; padding: 12px; background: var(--fg); border-radius: 12px; margin: 0 0 24px; }
.qr svg { display: block; width: 100%; height: auto; }
.secret { font-size: 13px; color: var(--fg); letter-spacing: .12em; word-spacing: .2em; overflow-wrap: anywhere; margin: 8px 0 36px; }

/* recovery codes */
.codes { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 0 32px; }
.codes li { font-size: 14px; color: var(--fg); text-transform: none; letter-spacing: .08em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

/* ---------- Account settings (Tune) ---------- */
.card.settings { width: min(600px, 100%); }
.subnav { display: flex; gap: 22px; flex-wrap: wrap; margin: 0 0 48px; }
.subnav a { color: var(--muted); text-decoration: none; position: relative; transition: color .2s; }
.subnav a:hover, .subnav a[aria-current="page"] { color: var(--fg); }
.subnav a[aria-current="page"]::after { content: ""; position: absolute; left: 0; right: .14em; bottom: -8px; height: 1px; background: var(--fg); box-shadow: 0 0 8px rgba(255, 255, 255, .6); }
.setting-list { list-style: none; border-top: 1px solid var(--line); margin: 0 0 32px; }
.setting-list li { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.setting-list .t { font-size: 17px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.setting-list .d { color: var(--muted); margin-top: 6px; line-height: 1.6; overflow-wrap: anywhere; }
.setting-list .d.mono { text-transform: none; letter-spacing: .04em; }
.badge { padding: 4px 9px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--faint); color: var(--fg); font-size: 10px; }
.choice { border: 0; display: flex; gap: 20px; flex-wrap: wrap; margin: -6px 0 36px; }
.choice legend { margin-bottom: 14px; }
.tick .sq.round { border-radius: 50%; }
.spaced { margin-top: 16px; }
.rename { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; min-width: 0; }
.rename input { background: transparent; border: 0; border-bottom: 1px solid var(--line); color: var(--fg); font: 300 15px/1.6 var(--sans); padding: 2px 0; min-width: 0; width: 14ch; text-transform: none; letter-spacing: 0; }
.rename input:focus { outline: none; border-color: var(--fg); }
/* Settings pages sit at the top so the sub-navigation doesn't jump between tabs. */
.card.settings { align-self: start; margin-top: clamp(16px, 5vh, 56px); }

