/**
 * base.css – design tokens, reset and shared primitives.
 *
 * Single source of truth for the visual system. Load this FIRST on every page,
 * then the page's own stylesheet, so page rules can still override primitives.
 *
 * Page stylesheets must not redeclare these tokens: the palette used to drift
 * per page (the application form rendered indigo, the thank-you page green)
 * which made the shared navbar change colour depending on where you were.
 */

:root {
  /* Brand — taken from the RHET logo */
  --primary:          #0A3A4A;
  --primary-dark:     #072A36;
  --primary-light:    #D6E9F0;
  --primary-tint:     #F1F8FB;

  /* Amber accent. `--secondary` is for fills and rules; it only reaches ~2:1 on
     white, so use `--secondary-text` whenever the accent carries actual words. */
  --secondary:        #F5A623;
  --secondary-text:   #B45309;
  --secondary-tint:   #FEF6E7;

  /* Neutrals */
  --text-primary:     #1e293b;
  /* slate-600, not slate-500: the lighter grey cleared 4.5:1 on white but fell
     to 3.8:1 on tinted rows such as the selected position. */
  --text-secondary:   #475569;
  /* Decorative only — 2.5:1 on white. Never use for text that must be read. */
  --text-muted:       #94a3b8;
  --bg-primary:       #ffffff;
  --bg-secondary:     #f8fafc;
  --bg-tertiary:      #f1f5f9;
  --border-color:     #e2e8f0;
  --border-strong:    #cbd5e1;

  /* Status */
  --error:            #dc2626;
  --error-tint:       #fef2f2;
  --success:          #059669;
  --success-tint:     #ecfdf5;

  /* Type scale */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;

  /* Space, shape, motion */
  --radius-sm:  0.375rem;
  --radius:     0.5rem;
  --radius-lg:  0.75rem;
  --radius-xl:  1rem;
  --shadow-sm:  0 1px 2px rgba(10, 58, 74, 0.06);
  --shadow-md:  0 4px 12px rgba(10, 58, 74, 0.08);
  --shadow-lg:  0 12px 28px rgba(10, 58, 74, 0.12);
  --transition: 0.2s ease;

  --container-width: 1200px;
  --navbar-height: 70px;

  /* Names apply.css already uses. Kept so it keeps working, but pointed at the
     brand palette — they used to carry the indigo/orange values that made the
     application form look like a different site. */
  --border-radius: var(--radius-lg);
  --card-shadow:   var(--shadow-lg);
  --focus-ring:    0 0 0 3px rgba(10, 58, 74, 0.25);
  --hover-bg:      var(--primary-tint);
  --input-bg:      #f9fafb;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  max-width: 100%;
}

h1, h2, h3, h4 {
  line-height: 1.25;
  text-wrap: balance;
}

/* Topbar is injected by load-topbar.js; reserve its height when present. */
body.has-topbar {
  padding-top: var(--navbar-height);
}

/* ── Focus ──────────────────────────────────────────────────────────────────── */

/* One visible focus style for every interactive element, so keyboard users can
   always see where they are. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@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;
  }
}

/* ── Layout ─────────────────────────────────────────────────────────────────── */

.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

@media (max-width: 480px) {
  .container {
    padding: 0 1rem;
  }
}

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

/* ── Page header ────────────────────────────────────────────────────────────── */

.page-header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 2.5rem 0 2rem;
}

.page-title {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-primary);
}

.page-description {
  max-width: 60ch;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .page-header {
    padding: 1.75rem 0 1.5rem;
  }

  .page-title {
    font-size: var(--text-2xl);
  }
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
}

.btn-secondary,
.btn-outline {
  background-color: var(--bg-primary);
  border-color: var(--border-strong);
  color: var(--primary);
}

.btn-secondary:hover,
.btn-outline:hover {
  background-color: var(--primary-tint);
  border-color: var(--primary);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-icon {
  flex-shrink: 0;
}

/* ── Touch ergonomics ───────────────────────────────────────────────────────── */

/* `!important` is deliberate here. base.css loads first so the page stylesheets
   win on order, and their component rules are class selectors (.form-control,
   .location-filter) that outrank these element selectors on specificity too.
   These two properties are ergonomic floors rather than design choices, so
   overriding them per component is never what we want. */
@media (pointer: coarse) {
  /* iOS Safari zooms the whole page when a focused field is under 16px, forcing
     the user to pinch back out after every tap. */
  input:not([type='checkbox']):not([type='radio']),
  select,
  textarea {
    font-size: 16px !important;
  }

  /* 44px minimum, per WCAG 2.5.5 and the Apple/Material guidance. */
  .btn,
  input:not([type='checkbox']):not([type='radio']),
  select,
  textarea {
    min-height: 44px !important;
  }

  /* Standalone links in dense lists (footer, nav) need vertical room so
     neighbouring targets are not easy to hit by mistake. Links inside running
     prose are left alone — WCAG 2.5.5 exempts them, and padding them would
     wreck line spacing. */
  .footer-links a,
  .footer-nav a,
  .footer-legal a,
  .nav-link,
  .logo {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
}
