/* Base styles shared by every Site Factory build.
   Uses the tokens from tokens.css. Do not hard-code colors here. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
img, video, svg { display: block; max-width: 100%; height: auto; }
img { object-fit: cover; }
h1, h2, h3, h4 { font-family: var(--font-heading); line-height: 1.1; margin: 0 0 var(--space-3); text-wrap: balance; }
h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-xl); }
p { margin: 0 0 var(--space-3); text-wrap: pretty; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Layout */
.container { width: min(100% - 2 * var(--gutter), var(--max-width)); margin-inline: auto; }
.section { padding-block: var(--space-section); }
/* Narrower text stays on the container's left edge. Never center a left-aligned column. */
.measure { max-width: 65ch; }
.measure-tight { max-width: 48ch; }
/* Anchored sections clear the sticky header (one-page sites and in-page links) */
[id] { scroll-margin-top: calc(var(--header-height, 72px) + 16px); }

/* Cards: equal height, actions pinned to the bottom so buttons line up across a row */
.card { display: flex; flex-direction: column; height: 100%; }
.card__action { margin-top: auto; padding-top: var(--space-3); }
.grid { display: grid; gap: var(--space-4); }
@media (min-width: 700px) { .grid--2 { grid-template-columns: repeat(2, 1fr); } .grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .grid--3 { grid-template-columns: repeat(3, 1fr); } }

/* Standalone text links get a full-size tap target */
.text-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }

/* Accessibility */
.skip-link { position: absolute; left: var(--space-2); top: -100px; z-index: 100; padding: var(--space-2) var(--space-3); background: var(--color-text); color: var(--color-bg); }
.skip-link:focus { top: var(--space-2); }
:focus-visible { outline: 3px solid var(--color-focus, var(--color-accent)); outline-offset: 3px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 48px; padding: 0.75em 1.5em;
  border: 2px solid transparent; border-radius: var(--radius-button);
  font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.btn--primary { background: var(--color-accent); color: var(--color-on-accent); }
.btn--secondary { border-color: currentColor; background: transparent; }
.btn:hover { transform: translateY(-1px); }

/* Sticky action bar on phones (house rule 4) */
.sticky-cta { display: none; }
@media (max-width: 767px) {
  .sticky-cta {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 50;
    padding: var(--space-2) var(--gutter) calc(var(--space-2) + env(safe-area-inset-bottom));
    background: var(--color-bg); box-shadow: 0 -4px 16px rgb(0 0 0 / 0.08);
    transform: translateY(100%); transition: transform 0.25s ease;
  }
  .sticky-cta.is-visible { transform: none; }
  .sticky-cta .btn { flex: 1; }
  body { padding-bottom: 80px; }
}

/* Forms */
label { display: block; font-weight: 600; margin-bottom: var(--space-1); }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 0.75em 1em;
  border: 1px solid var(--color-border); border-radius: var(--radius-input);
  background: var(--color-surface);
}
textarea { min-height: 140px; resize: vertical; }
.field { margin-bottom: var(--space-3); }

/* Reveal on scroll (motion level M1 and M2). site.js adds .is-in */
@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
  .reveal.is-in { opacity: 1; transform: none; }
}
