/*
  Global stylesheet - single source of truth for the site.

  Structure:
    1) Reset and base
    2) Design tokens (:root) - palette and typography are owned by the
       `brand-guidelines` skill. Spacing, radii, shadows, motion, and layout
       tokens are owned here.
    3) Layout primitives
    4) Components (site-wide reusable primitives only - page-specific
       styles live with their page builds, not here)
    5) Utilities
*/

/* ===== 1) Reset and base ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: 1.2;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

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

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

/* ===== 2) Design tokens ===== */
/* Palette and typography are written by the `brand-guidelines` skill from
   `build-assets/0-the-brand/tokens.json`. Spacing, radii, shadows, and
   transitions are owned here. */
:root {
  /* Palette (brand-guidelines) */
  --color-bg: #FFFFFF;
  --color-surface: #FFFFFF;
  --color-surface-soft: #E8EEF7;
  --color-text: #001B3D;
  --color-text-soft: #36506E;
  --color-primary: #BF0A30;
  --color-primary-dark: #8F0824;
  --color-primary-light: #F7E5EA;
  --color-accent: #002868;
  --color-focus: #BF0A30;
  --color-patriot-blue: #002868;

  /* Typography (brand-guidelines) */
  --font-heading: Georgia, Cambria, "Times New Roman", Times, serif;
  --font-body: Inter, Aptos, "Segoe UI", Helvetica, Arial, sans-serif;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Radii */
  --radius-sm: 0.5rem;
  --radius-md: 0.875rem;
  --radius-lg: 1.25rem;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(60, 64, 67, 0.12);
  --shadow-md: 0 4px 14px rgba(17, 24, 39, 0.08);
  --shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.12);

  /* Motion */
  --transition-fast: 180ms ease;
  --transition-base: 260ms ease;

  /* Layout */
  --container-max: 72rem;

  /* Aesthetic dials - the `design-system` skill SETS these per brand to diverge
     the look (sharp vs soft, flat vs shadowed, square vs pill). Defaults below are
     a soft/rounded baseline; a brand's design stage should deliberately override
     them so two brands don't look like the same template reskinned. */
  --logo-height: 2.75rem;    /* prominent by default - the logo is a brand asset, not chrome */
  --logo-max-width: 22rem;   /* generous, so wide wordmarks stay tall (not width-starved) */
  --header-bg: var(--color-surface);        /* white header for supplied navy logo */
  --header-fg: var(--color-patriot-blue);   /* navy header text */
  --btn-radius: 0.25rem;
  --card-radius: 0.25rem;
  --card-shadow: none;
  --card-border: 1px solid color-mix(in srgb, var(--color-accent) 28%, transparent);
  --chip-radius: var(--radius-pill);
}

/* Logo grows on wider screens - override the dial at the breakpoint, never per-page. */
@media (min-width: 1024px) {
  :root { --logo-height: 3.5rem; }
}

/* ===== 3) Layout primitives ===== */
.container {
  width: min(100% - 2rem, var(--container-max));
  margin-inline: auto;
}

.section {
  padding: var(--space-10) 0;
}

.grid {
  display: grid;
  gap: var(--space-4);
}

.grid-2 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(1, minmax(0, 1fr)); }

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

@media (min-width: 768px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ===== 4) Components ===== */

/* Site header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  color: var(--header-fg);
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
}

.site-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
}

.native-desktop-nav {
  display: none;
}

.native-nav-list,
.native-footer-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.native-nav-list {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.native-nav-list a:not(.btn) {
  color: var(--header-fg);
  font-weight: 700;
  font-size: 0.92rem;
}

.native-nav-list a:not(.btn):hover,
.native-nav-list a:not(.btn):focus-visible {
  color: var(--color-primary-light);
  text-decoration: underline;
  text-underline-offset: var(--space-2);
}

.mobile-menu {
  position: relative;
}

.mobile-menu summary {
  cursor: pointer;
  color: var(--header-fg);
  font-weight: 800;
  list-style: none;
  border: 1px solid color-mix(in srgb, var(--header-fg) 45%, transparent);
  border-radius: var(--btn-radius);
  padding: var(--space-2) var(--space-3);
}

.mobile-menu summary::-webkit-details-marker {
  display: none;
}

.mobile-menu-panel {
  position: absolute;
  top: calc(100% + var(--space-3));
  right: 0;
  z-index: 30;
  width: min(82vw, 20rem);
  padding: var(--space-5);
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--card-border);
  box-shadow: var(--shadow-lg);
}

.mobile-menu-panel .native-nav-list {
  align-items: stretch;
  flex-direction: column;
  gap: var(--space-3);
}

.mobile-menu-panel .native-nav-list a:not(.btn) {
  color: var(--color-text);
  display: block;
  padding: var(--space-2) 0;
}

@media (min-width: 900px) {
  .native-desktop-nav { display: block; }
  .mobile-menu { display: none; }
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* The header logo is an <img src="{{logo.src}}"> whose REAL file is injected by the CMS
   at upload - its aspect ratio is unknown at build time. HEIGHT is the primary driver
   (a generous --logo-height), so every logo renders at a consistent, prominent height
   regardless of ratio; --logo-max-width is a generous, viewport-relative safety cap that
   only clamps a very wide logo on small screens (it then scales down proportionally, never
   distorts). Never pin width AND height. Tune the dials per brand - never a per-page size. */
.site-logo img {
  height: auto;
  width: auto;
  max-height: var(--logo-height);
  max-width: min(var(--logo-max-width, 22rem), 55vw);
  object-fit: contain;
}

.site-nav {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
}

.site-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* CMS-rendered menus - `{{menu.navigation}}` and `{{menu.footer}}` expand to
   <ul class="canvas-navigation-menu"> / <ul class="canvas-footer-menu"> with
   <li><a> children. Style the generated classes directly. */

.canvas-navigation-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.canvas-navigation-menu > li {
  margin: 0;
}

.canvas-navigation-menu a {
  color: var(--header-fg);
  font-weight: 600;
  font-size: 0.95rem;
  padding: var(--space-2) 0;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.canvas-navigation-menu a:hover,
.canvas-navigation-menu a:focus-visible {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.canvas-footer-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-6);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}

/* Footers can carry many links. With 8+ items, flow them into responsive columns
   (auto-fill grid) instead of one long, sprawling wrapping row - multi-column on wide
   screens, collapsing toward a single column on mobile. Short footer menus keep the
   inline row above. Where :has() is unsupported it harmlessly stays the flex row. */
.canvas-footer-menu:has(> li:nth-child(8)) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr));
  align-items: start;
  gap: var(--space-2) var(--space-5);
}

.canvas-footer-menu > li {
  margin: 0;
}

.canvas-footer-menu a {
  color: var(--color-text-soft);
  font-size: 0.9rem;
  transition: color var(--transition-fast);
}

.canvas-footer-menu a:hover,
.canvas-footer-menu a:focus-visible {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  color: var(--color-text-soft);
  font-size: 0.9rem;
}

.breadcrumb a {
  color: var(--color-primary);
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-separator {
  color: var(--color-text-soft);
  opacity: 0.6;
}

.breadcrumb [aria-current="page"] {
  color: var(--color-text);
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 0;
  text-decoration: none;
  white-space: nowrap;
  border-radius: var(--btn-radius);
  min-height: 2.75rem;
  padding: 0.78rem 1.4rem;
  font-size: 0.98rem;
  line-height: 1;
  letter-spacing: 0.01em;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline-offset: 3px; }

.btn[disabled],
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
  pointer-events: none;
  box-shadow: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--color-primary) 28%, transparent);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--color-primary) 40%, transparent);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid color-mix(in srgb, var(--color-text) 16%, transparent);
}

.btn-secondary:hover {
  background: color-mix(in srgb, var(--color-surface-soft) 75%, #fff);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text);
  border: 1px solid color-mix(in srgb, var(--color-text) 20%, transparent);
}

.btn-ghost:hover {
  background: color-mix(in srgb, var(--color-surface-soft) 65%, transparent);
}

/* Header CTAs follow the header foreground so they stay legible on a coloured band
   (no-op on the neutral default where --header-fg == --color-text). */
.site-header .btn-ghost {
  color: var(--header-fg);
  border-color: color-mix(in srgb, var(--header-fg) 20%, transparent);
}

.btn-sm {
  min-height: 2.2rem;
  padding: 0.55rem 1rem;
  font-size: 0.87rem;
}

.btn-lg {
  min-height: 3rem;
  padding: 0.9rem 1.7rem;
  font-size: 1.04rem;
}

.btn-block { width: 100%; }

.btn-icon {
  width: 2.75rem;
  min-width: 2.75rem;
  padding: 0;
  border-radius: 50%;
}

/* Card */
.card {
  background: var(--color-surface);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: var(--card-border);
  padding: var(--space-5);
}

.card-title {
  margin: 0 0 var(--space-2);
  font-size: 1.08rem;
}

.card-text {
  margin: 0;
  color: var(--color-text-soft);
}

/* Chip - pill-shaped tag */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.95rem;
  border-radius: var(--chip-radius);
  background: var(--color-surface);
  color: var(--color-primary);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
}

.chip-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Site footer */
.site-footer {
  padding: var(--space-10) 0;
  color: var(--color-text-soft);
  font-size: 0.9rem;
  border-top: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
}

.native-footer-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: var(--space-3) var(--space-6);
  margin-bottom: var(--space-5);
}

.native-footer-list a,
.footer-legal a {
  color: var(--color-text-soft);
}

.native-footer-list a:hover,
.footer-legal a:hover {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: var(--space-1);
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid color-mix(in srgb, var(--color-text) 10%, transparent);
}

.illustrative-disclosure {
  margin: var(--space-5) 0 0;
  color: var(--color-text-soft);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* Homepage */
.homepage-hero {
  background: var(--color-patriot-blue);
  color: var(--color-surface);
  border-bottom: 0.4rem solid var(--color-primary);
}

.homepage-hero-media {
  overflow: hidden;
  background: var(--color-patriot-blue);
}

.homepage-hero-media img {
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center top;
}

.homepage-hero-copy {
  padding: var(--space-8) var(--space-4) var(--space-10);
}

.homepage-hero-panel {
  max-width: 34rem;
}

.homepage-hero h1 {
  max-width: 16ch;
  margin: 0 0 var(--space-4);
  font-size: clamp(2.25rem, 1.9rem + 2.2vw, 4rem);
  line-height: 1.05;
}

.homepage-hero-lede {
  max-width: 45ch;
  margin: 0 0 var(--space-6);
  font-size: 1.12rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.homepage-hero .btn-secondary {
  color: var(--color-patriot-blue);
}

.section-heading {
  max-width: 18ch;
  margin: 0 0 var(--space-4);
  font-size: clamp(2rem, 1.6rem + 2vw, 3.2rem);
}

.section-intro {
  max-width: 65ch;
  color: var(--color-text-soft);
  font-size: 1.08rem;
}

.patriot-rule {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-primary);
  font-weight: 900;
}

.patriot-rule::before,
.patriot-rule::after {
  content: "";
  flex: 1;
  height: 0.18rem;
  background: linear-gradient(90deg, var(--color-primary) 0 33%, var(--color-surface) 33% 66%, var(--color-accent) 66% 100%);
  border: 1px solid var(--color-surface-soft);
}

.audience-card,
.step-card,
.link-card {
  height: 100%;
}

.audience-card h3,
.step-card h3,
.link-card h3 {
  margin-top: 0;
}

.section-blue {
  background: var(--color-surface-soft);
}

.section-navy {
  background: var(--color-patriot-blue);
  color: var(--color-surface);
}

.section-navy .section-intro {
  color: color-mix(in srgb, var(--color-surface) 82%, transparent);
}

/* Core content pages */
.content-hero {
  padding: var(--space-8) 0;
  background: var(--color-patriot-blue);
  color: var(--color-surface);
  border-bottom: 0.35rem solid var(--color-primary);
}

.content-hero-grid {
  display: grid;
  gap: var(--space-6);
  align-items: center;
}

.content-hero-copy h1 {
  margin: 0 0 var(--space-4);
  font-size: clamp(2.35rem, 1.8rem + 2.8vw, 4.5rem);
}

.content-hero-copy p {
  max-width: 58ch;
  font-size: 1.08rem;
}

.content-hero-media {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--color-surface-soft);
  border: 0.25rem solid var(--color-surface);
}

.content-hero-media.portrait {
  aspect-ratio: 3 / 4;
  max-width: 30rem;
  justify-self: center;
}

.content-hero-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
}

.prose {
  max-width: 72ch;
}

.prose h2 {
  margin-top: var(--space-10);
  font-size: clamp(1.65rem, 1.35rem + 1.4vw, 2.5rem);
}

.prose h3 {
  margin-top: var(--space-6);
}

.prose p,
.prose li {
  color: var(--color-text-soft);
  line-height: 1.75;
}

.prose a {
  color: var(--color-primary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: var(--space-1);
}

.directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--space-4);
}

.directory-card {
  height: 100%;
}

.directory-card h3 {
  margin-top: 0;
}

.state-list {
  columns: 2;
  column-gap: var(--space-8);
  padding-left: var(--space-5);
}

.state-list li {
  break-inside: avoid;
  margin-bottom: var(--space-2);
}

.contact-panel {
  padding: var(--space-8);
  background: var(--color-surface-soft);
  border-left: 0.35rem solid var(--color-primary);
}

.contact-panel p:last-child {
  margin-bottom: 0;
}

@media (min-width: 760px) {
  .content-hero-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
  }

  .state-list { columns: 3; }
}

@media (min-width: 1100px) {
  .state-list { columns: 4; }
}

.link-card {
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.link-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.link-card a {
  color: var(--color-primary);
  font-weight: 800;
}

.safety-panel,
.final-cta {
  display: grid;
  gap: var(--space-6);
  align-items: center;
}

.safety-panel ul {
  margin: 0;
  padding-left: var(--space-6);
}

.final-cta {
  text-align: center;
  justify-items: center;
  padding: var(--space-10);
  background: var(--color-patriot-blue);
  color: var(--color-surface);
  border-top: 0.35rem solid var(--color-primary);
}

.final-cta h2 {
  max-width: 18ch;
  margin: 0;
  font-size: clamp(2rem, 1.6rem + 2vw, 3.2rem);
}

.final-cta p {
  max-width: 55ch;
  margin: 0;
}

@media (min-width: 900px) {
  .homepage-hero {
    position: relative;
    display: block;
    min-height: clamp(42rem, 76vh, 54rem);
    overflow: hidden;
  }

  .homepage-hero-media {
    position: absolute;
    inset: 0;
    background: var(--color-patriot-blue);
  }

  .homepage-hero-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 20%;
  }

  .homepage-hero-copy {
    position: absolute;
    left: clamp(var(--space-4), 3vw, var(--space-12));
    bottom: clamp(var(--space-4), 4vh, var(--space-10));
    z-index: 1;
    width: min(29vw, 32rem);
    padding: 0;
  }

  .homepage-hero-panel {
    width: 100%;
    max-width: none;
    padding: clamp(var(--space-5), 2.2vw, var(--space-8));
    background: color-mix(in srgb, var(--color-patriot-blue) 95%, transparent);
    border-left: 0.35rem solid var(--color-primary);
    box-shadow: var(--shadow-lg);
  }

  .homepage-hero-panel .chip {
    display: none;
  }

  .homepage-hero h1 {
    margin: 0 0 var(--space-4);
    max-width: none;
    font-size: clamp(1.65rem, 2.2vw, 3.15rem);
  }

  .homepage-hero-lede {
    margin: 0 0 var(--space-5);
    font-size: clamp(0.9rem, 1vw, 1rem);
  }

  .homepage-hero .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .safety-panel,
  .final-cta {
    grid-template-columns: 1.3fr 1fr;
    text-align: left;
    justify-items: stretch;
  }

  .final-cta .btn {
    justify-self: end;
  }
}


/* Member profile */
.profile-head {
  display: flex;
  gap: var(--space-5);
  align-items: center;
  margin-bottom: var(--space-6);
}
.profile-avatar {
  width: 7.5rem;
  height: 7.5rem;
  border-radius: var(--radius-pill);
  object-fit: cover;
}
.profile-id {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.profile-headline {
  font-size: 1.15rem;
  font-weight: 600;
}
.profile-bio {
  color: var(--color-text-soft);
  max-width: 60ch;
}
.profile-interests {
  margin-top: var(--space-3);
}

/* ===== 5) Utilities ===== */
.text-center { text-align: center; }
.muted { color: var(--color-text-soft); }

.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

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