/*
 * Meridian — Nocturne design system.
 *
 * Values come from the design handoff's token sheet, which is authoritative. Dark near-neutral
 * ground, one blurple accent used as line and outline rather than fill, 8px base radius,
 * headings at weight 500 and never bolder — hierarchy here is size and space.
 */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/inter-500.woff2') format('woff2');
}

:root {
  --color-bg: #161826;
  --color-surface: #232532;
  --color-text: #e9e9ed;
  --color-accent: #9184d9;
  --color-divider: color-mix(in srgb, #e9e9ed 16%, transparent);

  /* Ramps are generated in OKLCH on one shared lightness scale, so the same step of any role
     carries the same visual weight. */
  --color-neutral-100: #f3f5fe;
  --color-neutral-200: #e4e7f5;
  --color-neutral-300: #cfd3e5;
  --color-neutral-400: #b2b6ca;
  --color-neutral-500: #9397ab;
  --color-neutral-600: #75798c;
  --color-neutral-700: #595d6c;
  --color-neutral-800: #3f424d;
  --color-neutral-900: #292b31;

  --color-accent-100: #f5f4ff;
  --color-accent-200: #e7e5fe;
  --color-accent-300: #d2cefd;
  --color-accent-400: #b5abfc;
  --color-accent-500: #968ae0;
  --color-accent-600: #796cbf;
  --color-accent-700: #5d5294;
  --color-accent-800: #423a6a;
  --color-accent-900: #2b2741;

  --font-heading: "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: ui-monospace, monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  /* On a dark ground, elevation is a hairline edge plus ambient darkness. */
  --shadow-sm: 0 0 0 1px #3f424d;
  --shadow-md: 0 0 0 1px #595d6c, 0 6px 18px rgba(0,0,0,0.55);
  --shadow-lg: 0 0 0 1px #9397ab, 0 16px 40px rgba(0,0,0,0.65);
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

h1, h2 {
  font-family: var(--font-heading);
  font-weight: 500;
  margin: 0;
  text-wrap: pretty;
}

p { margin: 0; text-wrap: pretty; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

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

.eyebrow {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-neutral-600);
}
.eyebrow-accent { color: var(--color-accent-400); }

/* The fade-to-transparent accent rule is a Nocturne signature — never substitute a solid
   divider. */
.rule {
  height: 1px;
  border: 0;
  background: linear-gradient(90deg, var(--color-accent), transparent);
}

/* — buttons — outlined, never filled — */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 14px;
  line-height: 1.2;
  color: var(--color-text);
  background: transparent;
  border: 1px solid transparent;
  padding: 5.6px 10px;
  border-radius: var(--radius-md);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.btn-primary:active { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: 2.8px; }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.btn-block { width: 100%; }

.card {
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-md);
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--color-neutral-800);
  border-top-color: var(--color-accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Layout — mobile first (the handoff's 390x844 treatment), desktop from
   1024px up. The device frame and status bar in the mocks are scaffolding;
   the real browser supplies those.
   ═══════════════════════════════════════════════════════════════════════ */

#app { min-height: 100%; display: flex; flex-direction: column; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 24px 24px;
  width: 100%;
  max-width: 640px;
}
.screen-centered { justify-content: center; align-items: flex-start; padding-bottom: 80px; }
.spacer { flex: 1; }

.sitenav { padding-top: 44px; }
.wordmark {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-accent-400);
}

.welcome-main { display: flex; flex-direction: column; flex: 1; }
.rule-wordmark { width: 56px; margin-top: 14px; }
.welcome-heading { margin-top: 56px; font-size: 31px; line-height: 1.14; letter-spacing: -0.02em; }
.welcome-body { margin-top: 20px; font-size: 15px; line-height: 1.6; color: var(--color-neutral-400); }
.btn-verify { margin-top: auto; font-size: 15px; padding: 14px 16px; }

.state-heading { margin-top: 26px; font-size: 27px; line-height: 1.15; letter-spacing: -0.02em; }
.state-body { margin-top: 12px; font-size: 15px; line-height: 1.6; color: var(--color-neutral-400); }
.screen-centered .state-heading { margin-top: 30px; font-size: 24px; }
.screen-centered .state-body { font-size: 14px; color: var(--color-neutral-500); }

/* — the settings gear: chrome, not part of what the demo shows — */
.sitenav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gear {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; margin: -6px -6px -6px 0;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--color-neutral-600); cursor: pointer;
}
.gear:hover { color: var(--color-accent-400); background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.gear:active { background: color-mix(in srgb, var(--color-text) 12%, transparent); }

/* — footer: keeps the bottom rule and the attribution — */
.sitefooter {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--color-divider);
}
.attribution { font-size: 10px; letter-spacing: 0.04em; color: var(--color-neutral-700); }

/* — settings dialog — */
.sheet-settings { display: flex; flex-direction: column; gap: 14px; }
.settings-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.btn-close-settings { font-size: 12px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.setting-stacked { flex-direction: column; align-items: stretch; gap: 8px; }
.setting-label { font-size: 12px; color: var(--color-neutral-400); letter-spacing: 0.02em; }
.setting-disabled { opacity: 0.45; }
.setting-input {
  width: 100%; padding: 7px 10px; font-size: 12.5px;
  color: var(--color-text); background: var(--color-bg);
  border: 1px solid var(--color-neutral-800); border-radius: var(--radius-sm);
  caret-color: var(--color-accent);
}
.setting-input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }
.setting-input:disabled { cursor: not-allowed; }
.settings-note {
  margin-top: 2px; padding-top: 12px;
  border-top: 1px solid var(--color-divider);
  font-size: 11px; line-height: 1.55; color: var(--color-neutral-600);
}

.toggle {
  width: 34px; height: 19px; border-radius: 10px; padding: 2px; flex: none;
  display: flex; align-items: center; justify-content: flex-start;
  border: 1px solid var(--color-neutral-800); background: transparent; cursor: pointer;
}
.toggle::after {
  content: ''; width: 13px; height: 13px; border-radius: 50%;
  background: var(--color-neutral-700);
}
.toggle.on {
  border-color: var(--color-accent-600);
  background: var(--color-accent-900);
  justify-content: flex-end;
}
.toggle.on::after { background: var(--color-accent-400); }

.seg {
  display: flex; flex: none; overflow: hidden;
  border: 1px solid var(--color-neutral-800); border-radius: var(--radius-sm);
}
.seg-opt {
  font-size: 10px; padding: 4px 9px; border: 0; cursor: pointer;
  background: transparent; color: var(--color-neutral-600);
}
.seg-opt:hover:not(:disabled) { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.seg-opt.selected { background: var(--color-accent-900); color: var(--color-accent-300); }
.seg-opt:disabled { cursor: not-allowed; }

/* — consent overlay — */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(9,10,18,0.72);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px;
}
.sheet {
  width: 100%; max-width: 560px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px;
}
.consent-body { font-size: 14.5px; line-height: 1.6; color: var(--color-neutral-300); }
.consent-body-first { margin-top: 14px; }
.consent-body + .consent-body { margin-top: 12px; }
.consent-actions { margin-top: 20px; display: flex; flex-direction: column; gap: 8px; }
.btn-continue { font-size: 15px; padding: 13px 16px; }
.btn-cancel { font-size: 13px; color: var(--color-neutral-500); }

/* — marks — */
.mark {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.mark-success {
  border: 1px solid var(--color-accent-600);
  background: var(--color-accent-900);
  color: var(--color-accent-300);
  font-size: 16px;
}
.mark-neutral { border: 1px solid var(--color-neutral-700); color: var(--color-neutral-400); font-size: 15px; }

/* — result — */
.screen-result, .screen-error { padding-top: 44px; }
.result-cards { margin-top: 26px; display: flex; flex-direction: column; gap: 12px; }
.card-receipt { padding: 16px; }
.receipt-rows { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; font-size: 12.5px; }
.receipt-row { display: flex; justify-content: space-between; gap: 10px; }
.receipt-key { color: var(--color-neutral-500); }
.receipt-value-true { color: var(--color-accent-300); }

.card-pseudonym {
  padding: 16px;
  border: 1px solid var(--color-accent-800);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--color-accent-900) 60%, transparent);
}
.pseudonym-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.btn-copy { font-size: 11px; padding: 3px 8px; }
.pseudonym-value {
  margin-top: 10px; font-size: 12px; line-height: 1.6;
  word-break: break-all; color: var(--color-accent-200);
}
.pseudonym-note { margin-top: 10px; font-size: 11.5px; line-height: 1.55; color: var(--color-neutral-500); }

/* On mobile the handoff pushes "Start over" to the bottom of the screen, below the cards.
   `display: contents` on the wrapper lets the screen order all of them directly; the desktop
   block below restores the wrapper so the two-column grid sees two children again. */
.result-main { display: contents; }
.screen-result .mark { order: 1; }
.screen-result .state-heading { order: 2; }
.screen-result .state-body { order: 3; }
.screen-result .result-cards { order: 4; }
.screen-result .btn-reset {
  order: 5; margin-top: auto; padding-top: 18px;
  width: 100%; font-size: 12px; color: var(--color-neutral-600);
}

.disclosure { font-size: 11.5px; color: var(--color-neutral-600); }
.disclosure > summary { cursor: pointer; padding: 6px 0; }
.disclosure-body { display: flex; flex-direction: column; gap: 8px; padding: 8px 0 0; }
.disclosure-row { display: flex; flex-direction: column; gap: 2px; }
.disclosure-key { color: var(--color-neutral-500); }
.disclosure-value { word-break: break-all; color: var(--color-neutral-400); }

/* — errors — */
.error-detail {
  margin-top: 18px; font-size: 11px; line-height: 1.6;
  color: var(--color-neutral-600); word-break: break-word;
}
.card-checks { margin-top: 22px; padding: 16px; }
.check-rows { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; font-size: 12.5px; }
.check-row { display: grid; grid-template-columns: 16px 1fr; gap: 4px 8px; align-items: baseline; }
.check-symbol { text-align: center; }
.check-pass .check-symbol { color: var(--color-accent-300); }
.check-warn .check-symbol { color: var(--color-neutral-400); }
.check-fail .check-symbol { color: var(--color-neutral-100); }
.check-detail { grid-column: 2; font-size: 11.5px; line-height: 1.5; color: var(--color-neutral-600); }
.error-actions { display: flex; flex-direction: column; gap: 8px; }
.btn-retry { font-size: 15px; padding: 14px 16px; }
.btn-back { font-size: 12px; color: var(--color-neutral-600); }

/* ═══════════════════════════════════════════════════════════════════════════
   Desktop — asymmetric, left-aligned, right column intentionally empty.
   ═══════════════════════════════════════════════════════════════════════ */

@media (min-width: 1024px) {
  .screen { max-width: none; padding: 0 56px 0; }

  .sitenav { padding: 22px 0; border-bottom: 1px solid var(--color-divider); flex: none; }
  .sitenav .wordmark { font-size: 12px; }
  .sheet-settings { width: 460px; max-width: 460px; }

  /* The content occupies a 600px column; the rest of the row is intentionally empty
     whitespace -- the asymmetry is part of the system's direction. On desktop the wordmark
     moves into the nav, so the accent rule sits below the heading rather than above it. */
  .welcome-main { justify-content: center; max-width: 600px; }
  .welcome-heading { order: 1; margin-top: 0; font-size: 52px; line-height: 1.08; letter-spacing: -0.03em; }
  .rule-wordmark { order: 2; width: 88px; margin-top: 26px; }
  .welcome-body { order: 3; margin-top: 26px; font-size: 17px; max-width: 44ch; }
  .btn-verify {
    order: 4; width: auto; align-self: flex-start;
    margin-top: 34px; padding: 13px 26px;
  }

  .sitefooter { padding: 16px 0; margin-top: 0; }

  .screen-centered { padding-bottom: 0; }
  .screen-centered .state-heading { font-size: 34px; }
  .screen-centered .state-body { font-size: 15px; max-width: 52ch; }
  .spinner { width: 38px; height: 38px; }
  .mark { width: 38px; height: 38px; }

  .screen-result {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 64px;
    align-items: center;
    align-content: center;
    padding-top: 0;
  }
  .screen-result .state-heading { font-size: 44px; margin-top: 28px; line-height: 1.1; letter-spacing: -0.03em; }
  .screen-result .state-body { font-size: 17px; max-width: 44ch; margin-top: 18px; }
  .result-main { display: flex; flex-direction: column; }
  .screen-result .mark,
  .screen-result .state-heading,
  .screen-result .state-body,
  .screen-result .result-cards { order: 0; }
  .screen-result .btn-reset {
    order: 0; margin-top: 28px; padding: 6px 0;
    width: auto; align-self: flex-start; font-size: 12.5px;
  }
  .result-cards { margin-top: 0; }
  .card-receipt, .card-pseudonym { padding: 20px; }
  .receipt-rows { font-size: 13px; gap: 11px; }
  .pseudonym-value { font-size: 12.5px; }
  .pseudonym-note { font-size: 12px; }

  .screen-error { justify-content: center; padding-top: 0; }
  .screen-error .state-heading { font-size: 40px; line-height: 1.1; letter-spacing: -0.03em; }
  .screen-error .state-body { font-size: 16px; max-width: 56ch; }
  .screen-error .spacer { display: none; }
  .card-checks { max-width: 56ch; }
  .error-actions { flex-direction: row; gap: 10px; margin-top: 32px; }
  .error-actions .btn { width: auto; }
  .btn-retry { padding: 11px 24px; font-size: 14px; }

  .backdrop { align-items: center; }
  .sheet { width: 520px; max-width: 520px; padding: 30px; }
  .consent-body { font-size: 15px; line-height: 1.65; }
  .consent-actions { flex-direction: row-reverse; justify-content: flex-start; gap: 10px; margin-top: 26px; }
  .consent-actions .btn { width: auto; }
  .btn-continue { padding: 11px 24px; font-size: 14px; }
}
