/* ==========================================================================
   base.css — Reset, base typography, buttons, forms, layout utilities
   Loaded after tokens.css. Mobile-first.
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* offset anchored scroll so the sticky header doesn't cover targets */
  scroll-padding-top: calc(var(--header-h) + 1rem);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--ink-700);
  background: var(--white);
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Media defaults */
img, picture, svg, video, canvas {
  display: block;
  max-width: 100%;
  height: auto;
}
img { font-style: italic; /* alt text styling if image fails */ }

/* Form elements inherit type */
input, button, textarea, select { font: inherit; color: inherit; }

/* Remove list styling where we opt out */
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

/* --- Typography ----------------------------------------------------------- */
h1, h2, h3, h4 {
  color: var(--ink-900);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  font-weight: 800;
  text-wrap: balance;
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-lg); font-weight: 700; }
h4 { font-size: var(--fs-md); font-weight: 700; }

@media (max-width: 639px) {
  h1 { font-size: 2.25rem; }
  h2 { font-size: 1.875rem; }
  h3 { font-size: 1.35rem; }
}

p { text-wrap: pretty; }
p + p { margin-top: var(--space-4); }

strong, b { font-weight: 700; color: var(--ink-800); }

small { font-size: var(--fs-sm); }

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
code:not(pre code) {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 0.1em 0.4em;
  border-radius: var(--r-sm);
  color: var(--ink-800);
}

.lead {
  font-size: var(--fs-md);
  color: var(--ink-600);
  line-height: 1.6;
}

/* --- Links ---------------------------------------------------------------- */
a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--brand-700); text-decoration: underline; }

/* --- Focus-visible (accessible, consistent ring) -------------------------- */
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
/* Drop the default outline only when our ring is shown */
:focus:not(:focus-visible) { outline: none; }

/* --- Selection ------------------------------------------------------------ */
::selection {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--ink-900);
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
  --btn-bg: var(--white);
  --btn-fg: var(--ink-800);
  --btn-bd: var(--line-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.72em 1.25em;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease),
              box-shadow var(--t) var(--ease),
              background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn .icon { width: 1.15em; height: 1.15em; }

.btn--primary {
  --btn-bg: var(--accent);
  --btn-fg: #fff;
  --btn-bd: var(--accent);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover {
  --btn-bg: var(--brand-700);
  --btn-bd: var(--brand-700);
  color: #fff;
  box-shadow: var(--shadow-accent);
}

.btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ink-800);
  --btn-bd: var(--line-2);
}
.btn--ghost:hover {
  --btn-bg: var(--surface-2);
  --btn-bd: var(--line-2);
  color: var(--ink-900);
}
/* Ghost button on dark sections */
.section--dark .btn--ghost,
.hero--dark .btn--ghost,
.site-footer .btn--ghost {
  --btn-fg: var(--dark-ink);
  --btn-bd: color-mix(in srgb, var(--dark-ink) 30%, transparent);
}
.section--dark .btn--ghost:hover,
.hero--dark .btn--ghost:hover,
.site-footer .btn--ghost:hover {
  --btn-bg: color-mix(in srgb, var(--white) 8%, transparent);
  color: #fff;
}

.btn--wa {
  --btn-bg: var(--wa-green);
  --btn-fg: #062e15;
  --btn-bd: var(--wa-green);
}
.btn--wa:hover {
  --btn-bg: var(--wa-green-700);
  --btn-bd: var(--wa-green-700);
  color: #fff;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--wa-green) 35%, transparent);
}

.btn--lg { padding: 0.9em 1.6em; font-size: var(--fs-base); }
.btn--block { display: flex; width: 100%; }

/* --- Forms ---------------------------------------------------------------- */
.field { display: grid; gap: var(--space-2); }
.field + .field { margin-top: var(--space-4); }

.label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-800);
}
.label .req { color: var(--danger); }

.input, .textarea, .select {
  width: 100%;
  padding: 0.7em 0.85em;
  font-size: var(--fs-base);
  color: var(--ink-900);
  background: var(--white);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.textarea { min-height: 8.5rem; resize: vertical; line-height: 1.55; }
.textarea--sm { min-height: 5.5rem; }

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85em center;
  padding-right: 2.5em;
  cursor: pointer;
}

.input::placeholder, .textarea::placeholder { color: var(--ink-400); }

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

.input:user-invalid, .textarea:user-invalid, .select:user-invalid {
  border-color: var(--danger);
}

.hint { font-size: var(--fs-xs); color: var(--ink-500); }

/* Honeypot anti-spam field — visually & semantically hidden */
.hp {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Form status message (filled by main.js, polite live region) */
.form-status {
  font-size: var(--fs-sm);
  margin-top: var(--space-3);
  min-height: 1.2em;
}
.form-status[data-state="error"] { color: var(--danger); }
.form-status[data-state="ok"]    { color: var(--success); }

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

/* --- Layout: section ------------------------------------------------------ */
.section { padding-block: var(--section-y); }
.section--tight { padding-block: clamp(2rem, 1.5rem + 2vw, 3.5rem); }

.section--surface { background: var(--surface); }
.section--surface-2 { background: var(--surface-2); }

/* Dark sections flip the local theme variables */
.section--dark {
  background: var(--dark-bg);
  color: var(--dark-ink-soft);
}
.section--dark h1, .section--dark h2,
.section--dark h3, .section--dark h4 { color: #fff; }
.section--dark a { color: var(--brand-400); }
.section--dark a:hover { color: #fff; }
.section--dark .lead { color: var(--dark-ink); }

/* Section heading block */
.section-head { max-width: 64ch; margin-bottom: var(--space-6); }
.section-head--center {
  margin-inline: auto;
  text-align: center;
}

/* --- Layout: grids -------------------------------------------------------- */
.grid { display: grid; gap: var(--space-5); }
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
.grid--4 { grid-template-columns: 1fr; }
.grid--auto {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}

@media (min-width: 640px) {
  .grid--2 { grid-template-columns: repeat(2, 1fr); }
  .grid--4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 880px) {
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--4 { grid-template-columns: repeat(4, 1fr); }
}

/* Two-column hero / content split */
.split {
  display: grid;
  gap: clamp(2rem, 1rem + 4vw, 4rem);
  align-items: center;
}
@media (min-width: 880px) {
  .split { grid-template-columns: 1.05fr 0.95fr; }
}

/* --- Helpers -------------------------------------------------------------- */
.mono { font-family: var(--font-mono); }
.text-center { text-align: center; }
.muted { color: var(--ink-500); }
.flow > * + * { margin-top: var(--space-4); }
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.text-link .icon { width: 1em; height: 1em; }
.cluster--center { justify-content: center; }

/* Visually hidden but accessible to screen readers */
.visually-hidden, .sr-only {
  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 */
.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -100%;
  z-index: 999;
  background: var(--ink-900);
  color: #fff;
  padding: 0.6em 1em;
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  transition: top var(--t) var(--ease);
}
.skip-link:focus { top: var(--space-3); color: #fff; }

/* Generic inline icon (used by .btn .icon and links) */
.icon {
  display: inline-block;
  width: 1.25em;
  height: 1.25em;
  fill: currentColor;
  flex: none;
  vertical-align: middle;
}

/* --- Reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .btn:hover { transform: none; }
}
