/**
 * Design tokens and primitives shared by every page.
 *
 * Colors are defined once on :root and redefined for dark mode, so a component
 * never needs to know which theme is active.
 */

:root {
  /* Neutrals: warm grey, so large light surfaces do not read as clinical. */
  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e6e6ec;
  --border-strong: #d4d4dd;
  --text: #16161c;
  --text-muted: #5f5f6d;
  --text-subtle: #8a8a99;

  /* Brand: deep indigo reads as trustworthy next to payment details. */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-contrast: #ffffff;

  --success: #0f9d58;
  --success-soft: #e6f6ed;
  --danger: #d33a3a;
  --danger-soft: #fdeceb;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgb(16 16 28 / 0.06), 0 1px 3px rgb(16 16 28 / 0.04);
  --shadow: 0 2px 4px rgb(16 16 28 / 0.04), 0 8px 24px rgb(16 16 28 / 0.08);
  --shadow-lg: 0 4px 8px rgb(16 16 28 / 0.04), 0 16px 48px rgb(16 16 28 / 0.12);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;

  --shell-width: 1120px;
  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b0b0f;
    --surface: #141419;
    --surface-raised: #1b1b22;
    --border: #26262f;
    --border-strong: #35353f;
    --text: #f2f2f5;
    --text-muted: #a3a3b2;
    --text-subtle: #75758a;

    --accent: #7c74f0;
    --accent-hover: #918bf4;
    --accent-soft: #1e1b3d;
    --accent-contrast: #0b0b0f;

    --success: #3ecf8e;
    --success-soft: #10291f;
    --danger: #f07171;
    --danger-soft: #2c1618;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 2px 4px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 4px 8px rgb(0 0 0 / 0.3), 0 16px 48px rgb(0 0 0 / 0.5);
  }
}

:root[data-theme='dark'] {
  --bg: #0b0b0f;
  --surface: #141419;
  --surface-raised: #1b1b22;
  --border: #26262f;
  --border-strong: #35353f;
  --text: #f2f2f5;
  --text-muted: #a3a3b2;
  --text-subtle: #75758a;
  --accent: #7c74f0;
  --accent-hover: #918bf4;
  --accent-soft: #1e1b3d;
  --accent-contrast: #0b0b0f;
  --success: #3ecf8e;
  --success-soft: #10291f;
  --danger: #f07171;
  --danger-soft: #2c1618;
}

/* ------------------------------------------------------------------ */
/* Reset                                                               */
/* ------------------------------------------------------------------ */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 650;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------ */
/* Layout primitives                                                   */
/* ------------------------------------------------------------------ */

.shell {
  width: 100%;
  max-width: var(--shell-width);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

@media (min-width: 640px) {
  .shell {
    padding-inline: var(--space-6);
  }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.button {
  --button-bg: var(--surface);
  --button-fg: var(--text);
  --button-border: var(--border-strong);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 18px;
  min-height: 42px;
  border: 1px solid var(--button-border);
  border-radius: var(--radius-full);
  background: var(--button-bg);
  color: var(--button-fg);
  font-weight: 560;
  font-size: 15px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  user-select: none;
}

.button:hover {
  border-color: var(--text-subtle);
}

.button:active {
  transform: translateY(1px);
}

.button--primary {
  --button-bg: var(--accent);
  --button-fg: var(--accent-contrast);
  --button-border: transparent;
  box-shadow: var(--shadow-sm);
}

.button--primary:hover {
  --button-bg: var(--accent-hover);
  border-color: transparent;
  box-shadow: var(--shadow);
}

.button--ghost {
  --button-bg: transparent;
}

.button--danger {
  --button-fg: var(--danger);
  --button-border: var(--border);
}

.button--danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.button--large {
  padding: 14px 26px;
  min-height: 52px;
  font-size: 16.5px;
}

.button--small {
  padding: 7px 14px;
  min-height: 36px;
  font-size: 14px;
}

.button--block {
  width: 100%;
}

.button[disabled],
.button[aria-busy='true'] {
  opacity: 0.6;
  pointer-events: none;
}

/* ------------------------------------------------------------------ */
/* Brand                                                               */
/* ------------------------------------------------------------------ */

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 660;
  letter-spacing: -0.02em;
  font-size: 17px;
}

.brand--centered {
  justify-content: center;
  margin-bottom: var(--space-5);
}

.logo {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  /* The mark is a real QR code for the site, drawn with currentColor. */
  color: var(--accent);
  border-radius: 3px;
}

/* ------------------------------------------------------------------ */
/* Forms                                                               */
/* ------------------------------------------------------------------ */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__label {
  font-size: 14px;
  font-weight: 560;
  color: var(--text-muted);
}

.field__input,
.field__textarea,
.field__select {
  width: 100%;
  padding: 11px 14px;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* 16px avoids the iOS zoom-on-focus behaviour. */
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field__input::placeholder,
.field__textarea::placeholder {
  color: var(--text-subtle);
}

.field__input:focus,
.field__textarea:focus,
.field__select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.field__textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

.field__help {
  font-size: 13px;
  color: var(--text-subtle);
}

.field__error {
  font-size: 14px;
  color: var(--danger);
  margin-top: calc(var(--space-2) * -1);
}

/* ------------------------------------------------------------------ */
/* Status pages                                                        */
/* ------------------------------------------------------------------ */

.page--status {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-4);
}

.status {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  max-width: 420px;
}

.status__title {
  font-size: 24px;
}

.status__body {
  color: var(--text-muted);
}

.loading {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-subtle);
}

.icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Large enough that the mark is a working code, not just a glyph. */
.logo--large {
  width: 44px;
  height: 44px;
}
