/*
 * base.css — design tokens, reset, typography, and shared chrome
 * (header, nav, footer, buttons, form fields) used on every page.
 *
 * Theming: light tokens on :root by default. Dark tokens apply when
 * either the OS prefers dark (prefers-color-scheme) AND the user has
 * not explicitly chosen light, OR the user has explicitly chosen dark
 * via the theme toggle (data-theme="dark" set by js/common.js).
 */

:root {
  --bg: #ffffff;
  --bg-elevated: #f9f9f9;
  --bg-inset: #f1f1f1;
  --text-primary: #0f0f0f;
  --text-secondary: #606060;
  --border: #e2e2e2;
  --accent: #4f46e5;
  --accent-contrast: #ffffff;
  --accent-soft: #eef0fd;
  --warning-fg: #8a5a00;
  --warning-bg: #fff6e5;
  --danger-fg: #b3261e;
  --danger-bg: #fdecea;
  --focus-ring: #4f46e5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 6px rgba(0, 0, 0, 0.05);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0f;
    --bg-elevated: #181818;
    --bg-inset: #272727;
    --text-primary: #f1f1f1;
    --text-secondary: #aaaaaa;
    --border: #303030;
    --accent: #9b8cfb;
    --accent-contrast: #14123a;
    --accent-soft: #232052;
    --warning-fg: #ffcc80;
    --warning-bg: #3a2c00;
    --danger-fg: #ff8a80;
    --danger-bg: #3a1210;
    --focus-ring: #9b8cfb;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 8px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-elevated: #181818;
  --bg-inset: #272727;
  --text-primary: #f1f1f1;
  --text-secondary: #aaaaaa;
  --border: #303030;
  --accent: #9b8cfb;
  --accent-contrast: #14123a;
  --accent-soft: #232052;
  --warning-fg: #ffcc80;
  --warning-bg: #3a2c00;
  --danger-fg: #ff8a80;
  --danger-bg: #3a1210;
  --focus-ring: #9b8cfb;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 8px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--accent);
}

a:hover {
  text-decoration-thickness: 2px;
}

h1,
h2,
h3 {
  line-height: 1.25;
  font-weight: 700;
}

p {
  margin: 0 0 1em;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header / nav ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 800;
  flex: 0 0 auto;
}

.site-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.site-nav a {
  display: inline-block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 600;
}

.site-nav a:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Page hero / headings ---------- */

.page-hero {
  padding: 36px 0 8px;
}

.page-hero h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem);
  margin: 0 0 10px;
}

.page-hero p {
  color: var(--text-secondary);
  font-size: 1.0625rem;
  max-width: 68ch;
}

.section-copy {
  padding: 8px 0 48px;
}

.section-copy h2 {
  font-size: 1.375rem;
  margin: 2em 0 0.6em;
}

.section-copy h2:first-child {
  margin-top: 0;
}

.section-copy h3 {
  font-size: 1.0625rem;
  margin: 1.4em 0 0.5em;
}

.section-copy p,
.section-copy li {
  color: var(--text-primary);
  max-width: 74ch;
}

.section-copy ul,
.section-copy ol {
  padding-left: 1.25em;
}

.section-copy li {
  margin-bottom: 0.4em;
}

.section-copy table {
  border-collapse: collapse;
  width: 100%;
  max-width: 74ch;
  margin: 1em 0 1.6em;
  font-size: 0.9375rem;
}

.section-copy caption {
  text-align: left;
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.section-copy th,
.section-copy td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.section-copy th {
  background: var(--bg-elevated);
}

.faq {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

.faq-item h3 {
  margin: 0 0 8px;
  font-size: 1.0625rem;
}

.faq-item p {
  margin: 0;
  color: var(--text-secondary);
}

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

.btn {
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1.2;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-inset);
}

.btn-secondary[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8125rem;
}

/* ---------- Form fields ---------- */

.field-group {
  margin-bottom: 16px;
}

.field-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.field-group input[type="text"],
.field-group input[type="search"],
.field-group textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.9375rem;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-primary);
  resize: vertical;
}

.field-group input[type="file"] {
  width: 100%;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.field-group input:focus-visible,
.field-group textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.field-hint--warning {
  color: var(--warning-fg);
  font-weight: 600;
}

.field-hint--danger {
  color: var(--danger-fg);
  font-weight: 700;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.callout {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.callout strong {
  color: var(--text-primary);
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 28px 0 40px;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.site-footer .wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-secondary);
}

.footer-disclaimer {
  max-width: 76ch;
}

/* ---------- Misc utility ---------- */

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .page-hero {
    padding-top: 24px;
  }
}
