/*
 * Kit stylesheet. Uses only the tokens in brand.css, so a business restyles by editing that file.
 * No external fonts or scripts (the CSP allows 'self' only). Mobile first; tap targets >= 44px.
 */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
main:focus { outline: none; }
img, svg { max-width: 100%; height: auto; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 0.6em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.75rem, 1.4rem + 1.6vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 1.15rem + 0.7vw, 1.65rem); }
h3 { font-size: 1.15rem; }
p, ul, ol, dl, table { margin: 0 0 1rem; }
a { color: var(--brand); text-underline-offset: 0.15em; }
a:hover { color: var(--brand-strong); }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-alt); padding: 0.1em 0.35em; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

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

.visually-hidden {
  position: absolute !important; 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: 1rem; top: -4rem; z-index: 100;
  background: var(--brand); color: var(--brand-contrast); padding: 0.6rem 1rem; border-radius: var(--radius-small);
}
.skip-link:focus { top: 1rem; color: var(--brand-contrast); }

.muted { color: var(--ink-muted); }
.small { font-size: 0.875rem; }
.lead { font-size: 1.15rem; color: var(--ink-muted); max-width: 42rem; }
.eyebrow { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.5rem; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 1rem; }
@media (min-width: 48rem) { .container { padding: 0 1.5rem; } }
.page { padding-top: 2rem; padding-bottom: 3rem; }
.page-narrow { max-width: 30rem; }
.section { padding-top: 3rem; padding-bottom: 3rem; }
.stack > * + * { margin-top: 1rem; }
.cluster { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }

/* ---------- Banner, header, footer ---------- */
.mode-banner {
  background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--border);
  text-align: center; font-size: 0.875rem; font-weight: 600; padding: 0.4rem 1rem;
}
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; min-height: 4rem; padding-top: 0.5rem; padding-bottom: 0.5rem; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 1.1rem; color: var(--ink); text-decoration: none; min-height: 44px; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 1.6rem; height: 1.6rem; border-radius: 0.45rem; background: var(--brand); box-shadow: inset 0 0 0 0.4rem var(--brand), inset 0 0 0 0.65rem var(--brand-contrast); }
.site-nav ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; list-style: none; margin: 0; padding: 0; align-items: center; }
.site-nav a, .nav-button {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.25rem;
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.95rem;
}
.site-nav a:hover, .nav-button:hover { color: var(--brand); }
.site-nav a[aria-current="page"] { color: var(--brand); text-decoration: underline; text-decoration-thickness: 2px; }
.nav-button { background: none; border: 0; cursor: pointer; font-family: inherit; }
.inline-form { display: inline; margin: 0; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface-alt); margin-top: 2rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; align-items: center; justify-content: space-between; padding-top: 1.5rem; padding-bottom: 1.5rem; font-size: 0.9rem; color: var(--ink-muted); }
.footer-inner p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; list-style: none; margin: 0; padding: 0; }
.footer-links a, .footer-support a { color: var(--ink-muted); display: inline-block; padding: 0.6rem 0; }
.footer-links a:hover, .footer-support a:hover { color: var(--brand); }

/* ---------- Hero and marketing ---------- */
.hero { background: linear-gradient(180deg, var(--brand-soft), var(--surface)); padding: 3.5rem 0 3rem; }
.hero-title { font-size: clamp(2rem, 1.5rem + 2.5vw, 3.25rem); max-width: 18em; }
.steps { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); list-style: none; padding: 0; }
.section-callout { background: var(--surface-alt); border-radius: var(--radius); padding: 2rem 1.5rem; margin-bottom: 2rem; }

/* ---------- Buttons ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 44px; padding: 0.55rem 1.1rem; border-radius: var(--radius-small);
  border: 2px solid transparent; font: inherit; font-weight: 700; line-height: 1.2;
  text-decoration: none; cursor: pointer; transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.button-primary { background: var(--brand); color: var(--brand-contrast); }
.button-primary:hover { background: var(--brand-strong); color: var(--brand-contrast); }
.button-secondary { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.button-secondary:hover { background: var(--brand-soft); color: var(--brand-strong); }
.button-danger { background: var(--bad); color: #fff; }
.button-danger:hover { background: #7f1414; color: #fff; }
.button-link { background: none; border-color: transparent; color: var(--brand); padding-left: 0; padding-right: 0; text-decoration: underline; }
.button-large { font-size: 1.05rem; padding: 0.75rem 1.4rem; }
.button[disabled], .button[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

/* ---------- Forms ---------- */
form { margin: 0 0 1rem; }
.field { margin-bottom: 1.25rem; }
.field label { display: block; font-weight: 700; margin-bottom: 0.3rem; }
.optional { font-weight: 400; color: var(--ink-muted); }
.hint { color: var(--ink-muted); font-size: 0.9rem; margin: -0.1rem 0 0.4rem; }
.field-error { color: var(--bad); font-weight: 700; font-size: 0.9rem; margin: 0 0 0.4rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"],
input[type="tel"], input[type="search"], input[type="date"], select, textarea {
  display: block; width: 100%; min-height: 44px; padding: 0.55rem 0.7rem;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-small);
}
textarea { min-height: 7rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.field-invalid input, .field-invalid select, .field-invalid textarea { border: 2px solid var(--bad); }
.field-check { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.6rem; align-items: start; }
.field-check input { width: 1.35rem; height: 1.35rem; margin: 0.15rem 0 0; accent-color: var(--brand); }
.field-check label { font-weight: 400; margin: 0; }
.field-check .hint, .field-check .field-error { grid-column: 2; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-small); padding: 1rem; margin: 0 0 1.25rem; }
legend { font-weight: 700; padding: 0 0.25rem; }
.form-errors-title { font-size: 1rem; margin-bottom: 0.4rem; }
.form-errors ul { margin: 0; padding-left: 1.2rem; }
.form-errors a { color: var(--bad); font-weight: 600; }

/* ---------- Cards, alerts, badges ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card > :last-child { margin-bottom: 0; }
.card-title { font-size: 1.1rem; }
.card-form { padding: 1.5rem; }
@media (min-width: 30rem) { .card-form { padding: 2rem; } }

.flashes { margin-bottom: 1.5rem; }
.alert { border-radius: var(--radius-small); padding: 0.8rem 1rem; margin-bottom: 0.75rem; border-left: 4px solid; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: var(--info); }
.alert-success { background: var(--good-bg); color: var(--good); border-color: var(--good); }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.alert-error { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }

.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.badge-neutral { background: var(--surface-alt); color: var(--ink-muted); border: 1px solid var(--border); }
.badge-good { background: var(--good-bg); color: var(--good); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }

.empty-state { text-align: center; border: 2px dashed var(--border); border-radius: var(--radius); padding: 2.5rem 1.25rem; color: var(--ink-muted); }
.empty-title { font-size: 1.15rem; color: var(--ink); }

.error-page { max-width: 40rem; padding: 2rem 0; }

/* ---------- Tables and detail lists ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-alt); font-weight: 700; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.numeric, th.numeric { text-align: right; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-weight: 700; padding: 0.6rem 0.8rem; }

.detail-list { margin: 0; }
.detail-list > div { display: grid; grid-template-columns: minmax(8rem, 35%) 1fr; gap: 0.75rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--ink-muted); font-weight: 600; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }

.pagination { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1rem 0; }
.pagination a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 0.5rem; }
.pagination-current { color: var(--ink-muted); }

/* ---------- Stat cards ---------- */
.stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); margin-bottom: 2rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--border-strong); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat p { margin: 0; }
.stat-title { color: var(--ink-muted); font-weight: 600; font-size: 0.9rem; }
.stat-value { font-size: 1.75rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stat-detail { color: var(--ink-muted); font-size: 0.875rem; }
.stat-link { margin-top: 0.4rem !important; font-size: 0.9rem; }
.stat-good { border-top-color: var(--good); }
.stat-warn { border-top-color: #b7791f; }
.stat-bad { border-top-color: var(--bad); }

/* ---------- Admin shell ---------- */
.admin-shell { display: grid; gap: 1.5rem; padding-top: 1.5rem; padding-bottom: 3rem; }
@media (min-width: 56rem) { .admin-shell { grid-template-columns: 14rem 1fr; align-items: start; } }
.admin-nav { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; }
.admin-nav-title { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); margin: 0.25rem 0.5rem 0.5rem; }
.admin-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
@media (min-width: 56rem) { .admin-nav ul { flex-direction: column; } }
.admin-nav a { display: flex; align-items: center; min-height: 44px; padding: 0 0.75rem; border-radius: var(--radius-small); color: var(--ink); text-decoration: none; font-weight: 600; }
.admin-nav a:hover { background: var(--surface); color: var(--brand); }
.admin-nav a[aria-current="page"] { background: var(--brand); color: var(--brand-contrast); }
.admin-content { min-width: 0; }

/* ---------- Motion and print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .site-footer, .mode-banner, .admin-nav, .skip-link { display: none; }
  a { color: inherit; }
}
