/*
  foundation-base.css — Sovran Studios Foundation Layer
  Mobile-first responsive baseline. Applied to every client site.
  This file is a starting point — do not override here; extend in theme.css.
*/

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Root / Design Tokens ───────────────────────────────── */
:root {
  --font-body: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Courier New', monospace;

  --color-text:       #1a1a1a;
  --color-text-muted: #555;
  --color-bg:         #fff;
  --color-border:     #e0e0e0;
  --color-accent:     #0057ff; /* override per client brand */

  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  2rem;
  --space-xl:  4rem;

  --radius-sm: 4px;
  --radius-md: 8px;

  --container-max: 1200px;
  --container-padding: 1rem;
}

/* ── Base Typography ────────────────────────────────────── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100dvh;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-weight: 700;
}

/* H1: one per page, SEO-critical */
h1 { font-size: clamp(1.75rem, 5vw, 3rem); }
h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.5rem); }

p { max-width: 70ch; }

a {
  color: var(--color-accent);
  text-decoration: underline;
}

a:hover, a:focus-visible {
  text-decoration: none;
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

img, video {
  max-width: 100%;
  height: auto;
  display: block;
}

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

/* ── Breakpoints ────────────────────────────────────────── */
/* Mobile-first. Breakpoints:
   sm  ≥ 480px   (large phones)
   md  ≥ 768px   (tablets)
   lg  ≥ 1024px  (small desktop)
   xl  ≥ 1280px  (standard desktop)
*/

@media (min-width: 480px) {
  :root { --container-padding: 1.25rem; }
}

@media (min-width: 768px) {
  :root { --container-padding: 2rem; }
}

@media (min-width: 1024px) {
  :root { --container-padding: 2.5rem; }
}

/* ── Navigation ─────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--container-padding);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.nav__links {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
  flex-wrap: wrap;
}

/* ── Forms ───────────────────────────────────────────────── */
input, textarea, select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.2s;
}

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

label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 600;
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: var(--space-md);
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6em 1.4em;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s, transform 0.1s;
  min-height: 44px;  /* touch target minimum */
  min-width: 44px;
}

button:hover, .btn:hover { filter: brightness(1.1); }
button:active, .btn:active { transform: scale(0.98); }

/* ── Touch Targets ───────────────────────────────────────── */
/* All interactive elements: minimum 44×44px touch target */
a, button, input, select, textarea, [role="button"] {
  min-height: 44px;
}

nav a {
  padding-block: var(--space-sm);
}

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

/* Skip link — MUST be the first focusable element in <body>.
   Hidden until focused, then slides into view (WCAG 2.4.1). */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1000;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) 0;
  transform: translateY(-120%);
  transition: transform 0.15s;
}
.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Visually-hidden until focused — for skip links and reveal-on-focus text */
.sr-only-focusable:focus,
.sr-only-focusable:focus-within {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Global keyboard-focus ring for ALL interactive elements (WCAG 2.4.7).
   Extends the ring the site already gives <a> to buttons, inputs,
   custom controls, and anything with tabindex. */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
/* Skip-link target receives focus programmatically; no persistent ring */
[id="main-content"]:focus {
  outline: none;
}

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

@media (prefers-color-scheme: dark) {
  /* Tokens only — client theme overrides these */
  :root {
    --color-text:   #f0f0f0;
    --color-text-muted: #aaa;
    --color-bg:     #111;
    --color-border: #333;
  }
}
