/* The hosted sign-in page (slice L2b). Graphite, light and dark, copied
   from ui/app/globals.css (the one place the app's hexes live); the page
   follows the device's light or dark setting because no account is known
   yet. signin/tests/tokens.test.ts pins these values equal to globals.css,
   so a change there fails here until it is copied. Type: Inter Tight for
   body and display, JetBrains Mono for codes and keys, both self-hosted
   (no third-party request before sign-in). Scales from globals.css:
   radius 6 controls / 8 cards; type 11-12-14-15-22; 4px grid; 150ms. */

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

:root {
  color-scheme: light dark;
  --paper: #fafafa;
  --surface: #ffffff;
  --page-tint: #f4f4f5;
  --ink: #09090b;
  --muted: #5e5e66;
  --rule: #e4e4e7;
  --brand: #0f766e;
  --accent: #0f766e;
  --on-accent: #ffffff;
  --fail: #b91c1c;
  --hl-fail: #fef2f2;
  --focus-ring: var(--accent);
  --panel: var(--ink);
  --on-panel: var(--paper);
  --on-panel-muted: color-mix(in srgb, var(--paper) 74%, var(--ink));
  --radius-control: 6px;
  --radius-sheet: 8px;
  --motion: 150ms;
  --font-sans: "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #09090b;
    --surface: #131316;
    --page-tint: #18181b;
    --ink: #fafafa;
    --muted: #a1a1aa;
    --rule: #27272a;
    --brand: #2dd4bf;
    --accent: #2dd4bf;
    --on-accent: #042f2e;
    --fail: #f87171;
    --hl-fail: #2d0f12;
    /* The panel stays dark in dark mode: one step above the paper. */
    --panel: #131316;
    --on-panel: #fafafa;
    --on-panel-muted: #a1a1aa;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
}

/* A thin accent bar while IAP's handshake runs. */
#progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent);
  transform-origin: left;
  animation: progress 1.2s ease-in-out infinite;
  z-index: 10;
}
#progress[hidden] {
  display: none;
}
@keyframes progress {
  0% { transform: scaleX(0.05); }
  50% { transform: scaleX(0.7); }
  100% { transform: scaleX(0.05); translate: 100% 0; }
}

#app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
}

.panel {
  background: var(--panel);
  color: var(--on-panel);
  display: flex;
  align-items: center;
  padding: 48px 56px;
}
.panel-inner {
  max-width: 420px;
}
.wordmark {
  margin: 0;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.02em;
}
.panel-title {
  margin: 40px 0 0;
  font-size: 36px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.panel-dest {
  margin: 16px 0 0;
  color: var(--on-panel-muted);
  font-size: 14px;
}
.panel-dest .mono {
  color: var(--on-panel);
  font-size: 13px;
}

.form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 40px;
}

.card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sheet);
  padding: 32px;
}
.card h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.stack {
  display: grid;
  gap: 16px;
}

.lede {
  margin: 8px 0 24px;
  color: var(--muted);
}

.form {
  margin-top: 24px;
  display: grid;
  gap: 16px;
}
.field {
  display: grid;
  gap: 6px;
}
.label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}
.hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
input {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-control);
  min-height: 44px;
  padding: 0 12px;
  width: 100%;
  transition: border-color var(--motion);
}
input:hover {
  border-color: var(--muted);
}
input[aria-invalid="true"] {
  border-color: var(--fail);
}
input.code {
  font-family: var(--font-mono);
  font-size: 22px;
  letter-spacing: 0.32em;
  text-align: center;
  min-height: 52px;
}
input:disabled {
  opacity: 0.6;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.primary {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 44px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--motion), transform var(--motion);
}
.primary:hover {
  opacity: 0.9;
}
.primary:active {
  transform: translateY(1px);
}
.primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* A quiet second action: outlined, never the accent fill. */
.secondary {
  display: block;
  margin: 10px 0 8px;
  min-height: 40px;
  line-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-control);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  transition: border-color var(--motion);
}
.secondary:hover {
  border-color: var(--muted);
}

.link {
  font: inherit;
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.refusal {
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--radius-control);
  background: var(--hl-fail);
  color: var(--ink);
  border-left: 3px solid var(--fail);
}

.foot {
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.who {
  margin: 8px 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  color: var(--muted);
  font-size: 12px;
}
.who .mono {
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* First sign-in: Password, then Authenticator app. */
.steps {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
}
.steps li {
  display: flex;
  align-items: center;
  gap: 6px;
}
.steps .disc {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 11px;
}
.steps .is-current {
  color: var(--ink);
  font-weight: 500;
}
.steps .is-current .disc {
  border-color: var(--accent);
  color: var(--accent);
}
.steps .is-done .disc {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.setup {
  margin: 0;
  padding: 0 0 0 20px;
  display: grid;
  gap: 20px;
}
.setup > li::marker {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.setup-lead {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 500;
}
/* The QR sits on white in both modes: scanners read dark on light. */
.qr {
  margin: 12px 0 8px;
  width: 168px;
  height: 168px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sheet);
}
.qr svg {
  display: block;
  width: 100%;
  height: 100%;
}
.key summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--accent);
  width: fit-content;
}
.key-value {
  margin: 8px 0 4px;
  padding: 8px 10px;
  background: var(--page-tint);
  border-radius: var(--radius-control);
  font-size: 13px;
  letter-spacing: 0.06em;
  overflow-wrap: anywhere;
  user-select: all;
}

noscript p {
  padding: 24px;
}

@media (max-width: 900px) {
  #app {
    display: flex;
    flex-direction: column;
  }
  .panel {
    padding: 20px 16px;
  }
  .panel-title {
    margin-top: 12px;
    font-size: 20px;
  }
  .panel-dest {
    margin-top: 6px;
    font-size: 12px;
  }
  .form-side {
    align-items: flex-start;
    padding: 20px 16px 32px;
  }
  .card {
    padding: 24px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
  #progress {
    animation: none;
    transform: scaleX(0.6);
  }
}
