/* ==========================================================================
   ZimVID Prep — design tokens, reset, typography, buttons and forms
   ========================================================================== */

:root {
  color-scheme: light;

  /* Traffic Safety Council of Zimbabwe palette:
     green #006e36 · yellow #f9ff00 · red #d40000 · white / black */
  --bg: #f7faf8;
  --bg-glow: #e8f3ec;
  --surface: #ffffff;
  --surface-2: #eef5f0;
  --surface-3: #e1ede6;
  --ink: #0c1a12;
  --ink-soft: #1c3527;
  --muted: #55705f;
  --muted-2: #77907f;

  --line: #d9e6dd;
  --line-strong: #c4d6ca;

  --brand: #006e36;
  --brand-strong: #005227;
  --brand-bright: #0b8a46;
  --brand-soft: #e4f3ea;
  --brand-ink: #00301a;

  --gold: #f0b429;
  --gold-strong: #b97e06;
  --gold-soft: #fdf4da;

  --red: #ff0000;
  --brand-red: #a61b1b;
  --red-soft: #ffecec;
  --green: #006e36;
  --green-soft: #e4f5ec;
  --blue: #175cd3;
  --blue-soft: #eaf1fe;

  --shadow-xs: 0 1px 2px rgba(10, 27, 20, 0.05);
  --shadow-sm: 0 1px 3px rgba(10, 27, 20, 0.06), 0 4px 12px rgba(10, 27, 20, 0.04);
  --shadow-md: 0 2px 6px rgba(10, 27, 20, 0.05), 0 16px 36px rgba(10, 27, 20, 0.08);
  --shadow-lg: 0 30px 70px rgba(6, 40, 27, 0.16);

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-xl: 30px;
  --pill: 999px;

  --container: 1180px;
  --header-h: 72px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #06110b;
  --bg-glow: #0b2015;
  --surface: #0b1a12;
  --surface-2: #10261a;
  --surface-3: #163322;
  --ink: #ecf7f0;
  --ink-soft: #cfe6d8;
  --muted: #9bb5a5;
  --muted-2: #7e9988;

  --line: #1e3626;
  --line-strong: #2c4a35;

  --brand: #2fbf74;
  --brand-strong: #1fa964;
  --brand-bright: #55dd95;
  --brand-soft: #0c2a1a;
  --brand-ink: #d6ffe8;

  --gold: #f5c33b;
  --gold-strong: #f5c33b;
  --gold-soft: #2a2411;

  --red: #ff5a5a;
  --brand-red: #e57373;
  --red-soft: #2c1111;
  --green: #3ccf91;
  --green-soft: #0c2a20;
  --blue: #84adff;
  --blue-soft: #101d33;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 14px 40px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 30px 70px rgba(0, 0, 0, 0.55);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 12% -10%, var(--bg-glow), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(240, 180, 41, 0.06), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

img {
  background-color: var(--surface-2);
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color 0.18s var(--ease);
}

a:hover {
  color: var(--brand-strong);
}

p {
  margin: 0 0 1rem;
}

ul,
ol {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

li {
  margin-bottom: 0.35rem;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}

strong,
b {
  font-weight: 700;
}

small {
  font-size: 0.85em;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0 0 0.6rem;
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: -0.022em;
  color: var(--ink);
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.8rem, 3.4vw, 2.7rem);
}

h2 {
  font-size: clamp(1.45rem, 2.2vw, 1.9rem);
}

h3 {
  font-size: clamp(1.05rem, 1.4vw, 1.25rem);
  letter-spacing: -0.015em;
}

h4 {
  font-size: 1.05rem;
}

::selection {
  background: var(--brand);
  color: #fff;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* -- Layout utilities ----------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 20px;
}

.container-narrow {
  max-width: 820px;
}

.section {
  padding: clamp(1.5rem, 3vw, 2.25rem) 0;
}

.section-tight {
  padding: clamp(1rem, 2vw, 1.5rem) 0;
}

.stack > * + * {
  margin-top: var(--stack-gap, 1rem);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.grid {
  display: grid;
  gap: 1.25rem;
}

.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: 1.25rem;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.small {
  font-size: 0.875rem;
}

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

.text-center {
  text-align: center;
}

.nowrap {
  white-space: nowrap;
}

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mt-4 { margin-top: 2rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.w-full { width: 100% !important; }

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -80px;
  z-index: 200;
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm);
  transition: top 0.2s var(--ease);
}

.skip-link:focus {
  top: 12px;
  color: #fff;
}

/* -- Icons ---------------------------------------------------------------- */
.icon {
  display: inline-block;
  flex: none;
  vertical-align: -0.15em;
}

.icon.is-filled {
  color: var(--gold);
}

/* -- Buttons -------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink);
  --btn-border: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.72rem 1.15rem;
  border-radius: var(--pill);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease),
    background 0.16s var(--ease), border-color 0.16s var(--ease), color 0.16s var(--ease);
  box-shadow: var(--shadow-xs);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  color: var(--btn-ink);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled,
.btn[disabled],
.btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn .icon {
  margin-top: -1px;
}

.btn-primary {
  --btn-bg: linear-gradient(135deg, var(--brand-bright), var(--brand-strong));
  --btn-ink: #fff;
  --btn-border: transparent;
  box-shadow: 0 10px 24px rgba(10, 122, 85, 0.28);
}

.btn-primary:hover {
  --btn-bg: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
}

.btn-gold {
  --btn-bg: var(--gold);
  --btn-ink: #2a1d00;
  --btn-border: transparent;
  box-shadow: 0 10px 24px rgba(196, 201, 0, 0.30);
}

.btn-gold:hover {
  --btn-bg: #e6a916;
  color: #2a1d00;
}

.btn-secondary {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink);
  --btn-border: var(--line-strong);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-ink: var(--ink-soft);
  --btn-border: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  --btn-bg: var(--surface-2);
  box-shadow: none;
}

.btn-danger {
  --btn-bg: var(--red);
  --btn-ink: #fff;
  --btn-border: transparent;
}

.btn-lg {
  padding: 0.95rem 1.55rem;
  font-size: 1.02rem;
}

.btn-sm {
  padding: 0.48rem 0.85rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn-link {
  border: 0;
  background: none;
  box-shadow: none;
  padding: 0;
  color: var(--brand);
  font-weight: 650;
  cursor: pointer;
}

.btn-link:hover {
  color: var(--brand-strong);
  text-decoration: underline;
  box-shadow: none;
  transform: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* -- Badges / pills ------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.24rem 0.62rem;
  border-radius: var(--pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.5;
  white-space: nowrap;
}

.badge .icon {
  width: 13px;
  height: 13px;
}

.badge-free,
.badge-success {
  background: var(--green-soft);
  border-color: color-mix(in srgb, var(--green) 25%, transparent);
  color: var(--green);
}

.badge-premium,
.badge-gold {
  background: var(--gold-soft);
  border-color: color-mix(in srgb, var(--gold) 40%, transparent);
  color: var(--gold-strong);
}

.badge-brand {
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 22%, transparent);
  color: var(--brand);
}

.badge-danger {
  background: var(--red-soft);
  border-color: color-mix(in srgb, var(--red) 25%, transparent);
  color: var(--red);
}

.badge-muted {
  background: var(--surface-2);
  color: var(--muted);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
  padding: 0.35rem 0.8rem 0.35rem 0.45rem;
  border-radius: var(--pill);
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.eyebrow .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #009739 0 25%, #ffd200 0 50%, #ef3340 0 75%, #111 0);
}

/* -- Cards ---------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: clamp(1.2rem, 2.4vw, 1.9rem);
}

.card-hover {
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), border-color 0.22s var(--ease);
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--brand) 28%, var(--line));
}

/* -- Forms ---------------------------------------------------------------- */
.field {
  margin-bottom: 1.05rem;
}

.label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.input,
.select,
.textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease), background 0.16s var(--ease);
  appearance: none;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 13px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line-strong));
}

.input:focus,
.select:focus,
.textarea:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent);
}

.input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
  opacity: 1;
}

.help {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.errorlist {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 600;
}

.errorlist li {
  margin: 0;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0.9rem 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.checkbox-row input[type="checkbox"],
.checkbox {
  width: 18px;
  height: 18px;
  margin-top: 0.15rem;
  accent-color: var(--brand);
  flex: none;
}

.form-note {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.85rem;
}

.code-input {
  font-family: var(--font-mono);
  font-size: 1.15rem !important;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  text-align: center;
}

/* -- Flash messages ------------------------------------------------------- */
.flashes {
  position: fixed;
  z-index: 120;
  top: calc(var(--header-h) + 14px);
  right: 16px;
  display: grid;
  gap: 0.6rem;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.flash {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--ink-soft);
  font-size: 0.9rem;
  pointer-events: auto;
  animation: flash-in 0.32s var(--ease) both;
}

.flash .icon {
  margin-top: 2px;
  color: var(--brand);
}

.flash-success { border-left: 4px solid var(--green); }
.flash-success .icon { color: var(--green); }
.flash-error { border-left: 4px solid var(--red); }
.flash-error .icon { color: var(--red); }
.flash-warning { border-left: 4px solid var(--gold); }
.flash-warning .icon { color: var(--gold-strong); }
.flash-info { border-left: 4px solid var(--blue); }
.flash-info .icon { color: var(--blue); }

.flash-close {
  margin-left: auto;
  background: none;
  border: 0;
  padding: 2px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* -- Dialog --------------------------------------------------------------- */
dialog.modal {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  padding: 1.6rem;
  box-shadow: var(--shadow-lg);
}

dialog.modal::backdrop {
  background: rgba(4, 16, 11, 0.55);
  backdrop-filter: blur(3px);
}

.dialog-title {
  margin-bottom: 0.4rem;
}

.dialog-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1.4rem;
}

/* -- Spinner -------------------------------------------------------------- */
.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 42px;
  height: 42px;
  border-width: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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