/* ==========================================================================
   Homerun Baseball Ottawa — design tokens and base layer
   Canonical palette from visual-identity.md. Do not alter the five brand
   hex values. Teaching-app field colours (ball / base / backup) stay out.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
  /* Canonical brand colours — do not change */
  --brand-navy: #062448;
  --brand-navy-2: #14294d;
  --brand-red: #a3301f;
  --brand-red-2: #8d2418;
  --brand-cream: #f6f3ec;

  /* Neutrals (allowed alongside the five brand hexes) */
  --white: #ffffff;
  --black: #000000;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-600: #4a5568; /* official muted ink from brand guidelines */
  --gray-700: #374151;

  /* RGB channels for overlays / shadows (same navy and red, not new hues) */
  --navy-rgb: 6, 36, 72;
  --red-rgb: 163, 48, 31;

  /* Derived surfaces and type colours
     White type on navy/red; navy type on cream/white. */
  --surface: var(--brand-cream);
  --surface-alt: var(--white);
  --surface-navy: var(--brand-navy);
  --surface-navy-2: var(--brand-navy-2);
  --surface-red: var(--brand-red);
  --ink: var(--brand-navy);
  --ink-muted: var(--gray-600);
  --ink-on-dark: var(--white);
  --ink-on-red: var(--white);
  --border: var(--gray-300);
  --border-strong: var(--brand-navy);
  --focus-ring: var(--brand-red);
  --focus-ring-on-dark: var(--white);

  /* Overlays — hero scrim must keep white type above 4.5:1 on photography */
  --scrim-navy: rgba(var(--navy-rgb), 0.78);
  --scrim-navy-strong: rgba(var(--navy-rgb), 0.88);
  --scrim-navy-soft: rgba(var(--navy-rgb), 0.55);

  /* Shadows (navy-tinted, not generic black) */
  --shadow-1: 0 1px 2px rgba(var(--navy-rgb), 0.08);
  --shadow-2: 0 4px 14px rgba(var(--navy-rgb), 0.12);
  --shadow-3: 0 12px 32px rgba(var(--navy-rgb), 0.18);

  /* Modular type scale — fluid between ~320px and ~1200px viewports */
  --step--1: clamp(0.8125rem, 0.78rem + 0.16vw, 0.875rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --step-1: clamp(1.125rem, 1.05rem + 0.38vw, 1.375rem);
  --step-2: clamp(1.375rem, 1.2rem + 0.88vw, 1.75rem);
  --step-3: clamp(1.75rem, 1.45rem + 1.5vw, 2.25rem);
  --step-4: clamp(2.125rem, 1.7rem + 2.13vw, 3rem);
  --step-5: clamp(2.5rem, 1.9rem + 3vw, 3.75rem);

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.6;
  --leading-loose: 1.75;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* System stack only — no hosted webfonts */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font-sans);

  /* Spacing scale (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;

  /* Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-pill: 999px;

  /* Layout */
  --container-max: 1200px;
  --container-gutter: var(--space-4);
  --header-height: 4.5rem;
  --measure: 40rem;

  /* Motion */
  --duration: 180ms;
  --duration-slow: 280ms;
  --ease: ease;

  /* Stacking */
  --z-base: 1;
  --z-header: 100;
  --z-nav: 110;
  --z-skip: 1000;
}

/* --------------------------------------------------------------------------
   2. Reset
   -------------------------------------------------------------------------- */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html:focus-within {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  line-height: var(--leading-normal);
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

ul,
ol {
  list-style: none;
  padding: 0;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* --------------------------------------------------------------------------
   3. Base elements
   -------------------------------------------------------------------------- */

body {
  font-family: var(--font-sans);
  font-size: var(--step-0);
  font-weight: var(--weight-regular);
  color: var(--ink);
  background-color: var(--surface);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--ink);
  text-wrap: balance;
}

h1 {
  font-size: var(--step-4);
}

h2 {
  font-size: var(--step-3);
}

h3 {
  font-size: var(--step-2);
}

h4,
h5,
h6 {
  font-size: var(--step-1);
}

p,
li {
  text-wrap: pretty;
}

p {
  max-width: var(--measure);
}

a {
  color: var(--brand-red);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--brand-red-2);
}

strong {
  font-weight: var(--weight-semibold);
}

small {
  font-size: var(--step--1);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
}

blockquote {
  font-size: var(--step-1);
  font-style: italic;
  line-height: var(--leading-snug);
  color: var(--ink);
}

code,
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

::selection {
  background-color: var(--brand-navy);
  color: var(--ink-on-dark);
}

/* --------------------------------------------------------------------------
   4. Focus
   Visible rings are required (WCAG 2.2 AA). Brand red on light surfaces;
   white on navy/red chrome so the ring still contrasts.
   -------------------------------------------------------------------------- */

:focus {
  outline: none;
}

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

.site-header :focus-visible,
.site-footer :focus-visible,
.hero :focus-visible,
.cta-band--navy :focus-visible,
.cta-band--red :focus-visible {
  outline-color: var(--focus-ring);
}

/* --------------------------------------------------------------------------
   5. Skip link
   First focusable control on every page. Hidden until focused.
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-skip);
  padding: var(--space-2) var(--space-4);
  background-color: var(--brand-navy);
  color: var(--ink-on-dark);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
  transition: transform var(--duration) var(--ease);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  color: var(--ink-on-dark);
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   6. Screen-reader-only text
   -------------------------------------------------------------------------- */

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

/* --------------------------------------------------------------------------
   7. Reduced motion
   Honour prefers-reduced-motion globally so later components inherit it.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html,
  html:focus-within {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
