/* =========================================================================
   SOCIETY SKELETON — DESIGN SYSTEM
   Three layers:
     1. PRIMITIVES  — scales (type, space, radius, motion). Rarely touched.
     2. THEME       — the per-society customisation surface. Restyle a whole
                      site by editing this block (and DIRECTIONS.md presets).
     3. COMPONENTS  — read only from the two layers above.
   Rules for restyles live in DESIGN.md. CSP: fonts must be self-hosted from
   /static/fonts (tools/get_fonts.py) — no external CDNs, no inline styles.
   ========================================================================= */

/* ====================== 1. PRIMITIVES ==================================== */
:root {
  /* Fluid type scale (minor third-ish, clamps between 360px and 1280px) */
  --text-xs:      0.78rem;
  --text-sm:      0.9rem;
  --text-base:    1rem;
  --text-md:      clamp(1.05rem, 0.95rem + 0.4vw, 1.2rem);
  --text-lg:      clamp(1.2rem, 1.05rem + 0.6vw, 1.5rem);
  --text-xl:      clamp(1.5rem, 1.25rem + 1.2vw, 2.1rem);
  --text-2xl:     clamp(1.9rem, 1.5rem + 2vw, 2.9rem);
  --text-display: clamp(2.3rem, 1.7rem + 3.2vw, 4rem);

  /* Space scale (4px rhythm) */
  --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-section: clamp(3.5rem, 2.5rem + 5vw, 6.5rem);

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --speed-fast: 150ms;
  --speed-base: 250ms;

  /* Layers */
  --z-nav: 20;
  --z-overlay: 40;
}

/* ====================== 2. THEME (per-society surface) ===================
   Pick a direction from DIRECTIONS.md, then adjust from the client's photos
   and brand. Keep contrast: ink on bg/surface >= 4.5:1, accent-ink on
   accent >= 4.5:1. Check both light and dark blocks before shipping.
   ========================================================================= */
:root {
  color-scheme: light dark;

  /* Colour — light. Accent is AeroSoc's logo navy, sampled from the mark. */
  --color-bg: #eef1f7;
  --color-surface: #ffffff;
  --color-ink: #171a21;
  --color-ink-muted: #4d5566;
  --color-accent: #172a55;          /* main brand colour */
  --color-brand-navy: #172a55;      /* exact logo navy — fixed in both themes */
  --color-accent-ink: #ffffff;      /* text ON the accent */
  --color-accent-soft: color-mix(in srgb, var(--color-accent) 8%, var(--color-bg));
  --color-accent-hover: color-mix(in srgb, var(--color-accent) 86%, #ffffff);
  --color-line: #e2e5ec;
  --color-focus: var(--color-accent);
  --shadow-tint: color-mix(in srgb, var(--color-accent) 22%, #71717a);

  /* Type — self-hosted via tools/get_fonts.py; system stacks as fallback */
  --font-display: "Space Grotesk", "Segoe UI", Arial, sans-serif;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --weight-display: 700;

  /* Shape — one radius system per site (see DESIGN.md: shape lock).
     Sharp: 0 / 0 / 0 · Soft: 14px / 10px / 8px · Pill: 8px / 999px / 8px */
  --radius-card: 10px;
  --radius-btn: 8px;
  --radius-input: 6px;

  --container: 1120px;
}

/* Dark theme. Night-sky navy from the brand; accent is a lighter tonal
   variant of the logo blue, not an inversion. Contrast checked separately. */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #11151f;
    --color-surface: #1a2130;
    --color-ink: #e9ecf3;
    --color-ink-muted: #a6adbd;
    --color-accent: #9fbdf2;        /* lighter tonal variant, not inverted */
    --color-accent-ink: #0e1b38;
    --color-accent-soft: color-mix(in srgb, var(--color-accent) 13%, var(--color-bg));
    --color-accent-hover: color-mix(in srgb, var(--color-accent) 85%, #ffffff);
    --color-line: #303a4e;
    --shadow-tint: #000000;
  }
}

/* ====================== reset & base ==================================== */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-ink);
  background: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  line-height: 1.12;
  margin: 0 0 0.55em;
  text-wrap: balance;
}
h1 { font-size: var(--text-display); letter-spacing: -0.015em; }
h2 { font-size: var(--text-2xl); letter-spacing: -0.01em; margin-top: 0; }
h3 { font-size: var(--text-lg); }
p { margin: 0 0 1em; }
a { color: var(--color-accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
::selection { background: var(--color-accent); color: var(--color-accent-ink); }

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

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--color-accent); color: var(--color-accent-ink);
  padding: var(--space-2) var(--space-4); z-index: var(--z-overlay);
  border-radius: 0 0 var(--radius-btn) 0; text-decoration: none;
}
.skip-link:focus-visible { left: 0; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--space-5); }
.container.narrow { max-width: 780px; }
.center { text-align: center; }
.muted { color: var(--color-ink-muted); }

/* Eyebrow: small uppercase label above a headline. Rationed — at most one
   per three sections on a page (DESIGN.md). The hero's counts as one. */
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-ink-muted);
  margin-bottom: 0.5em;
}
.role { /* committee roles, sponsor tiers: label style without the ration */
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent);
  margin: 0 0 0.5em;
}
.lead { font-size: var(--text-md); max-width: 44rem; text-wrap: pretty; }
.prose { max-width: 46rem; }
.prose p, .lead p { margin-bottom: 1em; }

/* ====================== header / nav =====================================
   AeroSoc variant: the header is brand navy in both themes so the site is
   bookended in the logo colour (navy header + hero at the top, navy footer
   at the bottom, white content between). All overrides scoped to
   .site-header / .hero — the admin panel pins its own colours in admin.css. */
.site-header {
  background: var(--color-brand-navy);
  border-bottom: 1px solid #223763;
  position: sticky; top: 0; z-index: var(--z-nav);
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); min-height: 68px;
}
.nav-brand {
  display: inline-flex; align-items: center; gap: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-lg); font-weight: var(--weight-display);
  color: var(--color-ink); text-decoration: none;
}
.nav-brand img { width: 38px; height: 38px; border-radius: 8px; }
.site-header .nav-brand { color: #ffffff; }
.nav-links { display: flex; align-items: center; gap: var(--space-5); }
.nav-links a:not(.btn) {
  color: var(--color-ink); text-decoration: none; font-size: var(--text-sm);
  padding: var(--space-2) 0;
}
.site-header .nav-links a:not(.btn) { color: #ccd5e8; }
.site-header .nav-links a:not(.btn):hover { color: #ffffff; }
.site-header .nav-links a:not(.btn)[aria-current="page"] {
  color: #ffffff;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}
.site-header .btn-primary { background: #ffffff; color: var(--color-brand-navy); }
.site-header .btn-primary:hover { background: #dde4f2; }
.nav-cta { margin-left: var(--space-2); flex-shrink: 0; }
.nav-toggle { display: none; }

@media (max-width: 800px) {
  .nav-toggle {
    display: inline-flex; flex-direction: column; gap: 5px;
    background: none; border: 0; padding: 12px; cursor: pointer;
    min-width: 44px; min-height: 44px; justify-content: center;
  }
  .nav-toggle span {
    width: 22px; height: 2px; background: var(--color-ink);
    transition: transform var(--speed-fast) var(--ease-out);
  }
  .site-header .nav-toggle span { background: #ffffff; }
  .nav-links {
    display: none;
    position: absolute; left: 0; right: 0; top: 68px;
    flex-direction: column; align-items: flex-start; gap: var(--space-3);
    background: var(--color-brand-navy);
    border-bottom: 1px solid #223763;
    padding: var(--space-4) var(--space-5) var(--space-6);
    box-shadow: 0 16px 32px -20px var(--shadow-tint);
  }
  .nav-links.open { display: flex; }
  .nav-links a { min-height: 44px; display: flex; align-items: center; width: 100%; }
  .nav-cta { margin-left: 0; }
}

/* ====================== buttons ========================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0.6em 1.5em;
  border-radius: var(--radius-btn); border: 1.5px solid transparent;
  font: inherit; font-size: var(--text-sm); font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background var(--speed-fast) var(--ease-out),
              border-color var(--speed-fast) var(--ease-out),
              color var(--speed-fast) var(--ease-out),
              transform var(--speed-fast) var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-accent); color: var(--color-accent-ink); }
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-ghost { border-color: var(--color-line); color: var(--color-ink); background: transparent; }
.btn-ghost:hover { border-color: var(--color-accent); color: var(--color-accent); }
.btn-small { min-height: 36px; padding: 0.3em 1em; font-size: var(--text-xs); }

/* ====================== sections & layout families =======================
   Vary the family per section — a page should not repeat one layout over
   and over (DESIGN.md: section variety). Available families:
     .hero        — top-of-page statement
     .section     — plain flow content
     .section-alt — tinted background variant
     .band        — full-width accent statement block
     .split       — two-column text + media (add .reverse to flip)
     .grid-feature— asymmetric card grid (first item featured)
   ========================================================================= */
/* AeroSoc hero: brand navy continuing from the header, with the logo mark
   as a large faint watermark (alpha baked into mark-watermark.png). Same in
   light and dark — the brand colour does not flip with the theme. */
.hero {
  padding: calc(var(--space-section) * 1.1) 0 var(--space-section);
  background:
    url("../img/mark-watermark.png") no-repeat right -120px center / 520px auto,
    linear-gradient(160deg, #101f42 0%, var(--color-brand-navy) 60%, #1d3468 100%);
  color: #eef1f8;
}
.hero .eyebrow { color: #9db1d8; }
.hero h1 { max-width: 20ch; color: #ffffff; }
.hero .lead { max-width: 38rem; color: #d9e0ef; }
.hero .btn-primary { background: #ffffff; color: var(--color-brand-navy); }
.hero .btn-primary:hover { background: #dde4f2; }
.hero .btn-ghost { border-color: #51648f; color: #ffffff; }
.hero .btn-ghost:hover { border-color: #ffffff; color: #ffffff; }
.hero-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-6); }

/* Hero "Find us" panel (pattern from the econ site, adapted for the navy
   hero). Translucent card so the watermark reads through faintly. */
.hero-grid {
  display: grid; grid-template-columns: 1.2fr 0.8fr;
  gap: clamp(var(--space-6), 6vw, var(--space-8));
  align-items: center;
}
/* grid/flex min-width:auto would let the nowrap handles force the page
   wider than small viewports — allow the panel and rows to shrink */
.hero-grid > *, .social-link { min-width: 0; }
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; gap: var(--space-6); }
}
.hero-panel {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-card);
  padding: var(--space-4) var(--space-5);
}
.hero-panel-title {
  text-transform: uppercase; letter-spacing: 0.09em;
  font-size: var(--text-xs); font-weight: 600;
  color: #9db1d8;
  margin: var(--space-1) 0 var(--space-1);
}
.social-list { display: flex; flex-direction: column; }
.social-link {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 48px; padding: var(--space-2) 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #eef1f8; text-decoration: none;
}
.social-link:first-child { border-top: 0; }
.social-link svg { flex-shrink: 0; color: #9fbdf2; }
.social-name { font-weight: 600; font-size: var(--text-sm); }
.social-handle {
  margin-left: auto; color: #9db1d8;
  font-size: var(--text-xs);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 55%;
}
.social-link:hover .social-name { color: #ffffff; text-decoration: underline; text-underline-offset: 3px; }

.section { padding: var(--space-section) 0; }
.section-alt { background: var(--color-accent-soft); }
.page-head { padding-top: var(--space-7); }

.band {
  background: var(--color-accent);
  color: var(--color-accent-ink);
  padding: var(--space-section) 0;
}
/* AeroSoc: lift the band a step above the brand navy so it reads as its
   own layer against the footer (both would otherwise be #172a55). Light
   mode only - the dark theme's band is already the light tonal accent. */
@media (prefers-color-scheme: light) {
  .band { background: linear-gradient(160deg, #1d3468 0%, #24407c 100%); }
}
.band h2, .band h3 { color: inherit; }
.band a:not(.btn) { color: inherit; }
.band .muted { color: color-mix(in srgb, var(--color-accent-ink) 78%, var(--color-accent)); }
.band .btn-primary { background: var(--color-accent-ink); color: var(--color-accent); }
.band .btn-primary:hover { background: color-mix(in srgb, var(--color-accent-ink) 88%, var(--color-accent)); }

.split {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--space-7); align-items: center;
}
.split.reverse > :first-child { order: 2; }
.split-media img { border-radius: var(--radius-card); width: 100%; object-fit: cover; }
@media (max-width: 800px) {
  .split { grid-template-columns: 1fr; gap: var(--space-5); }
  .split.reverse > :first-child { order: 0; }
}

/* ====================== cards & grids ==================================== */
.grid { display: grid; gap: var(--space-5); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-3 { grid-template-columns: 1fr; } }

/* Featured grid: first card spans the full first column height. Use when
   one item deserves the spotlight (next event, headline story). */
.grid-feature { grid-template-columns: 1.2fr 1fr; grid-auto-rows: auto; }
.grid-feature > :first-child { grid-row: span 2; }
.grid-feature > :first-child .card-img { aspect-ratio: 4 / 3; }
@media (max-width: 800px) {
  .grid-feature { grid-template-columns: 1fr; }
  .grid-feature > :first-child { grid-row: auto; }
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color var(--speed-base) var(--ease-out),
              box-shadow var(--speed-base) var(--ease-out),
              transform var(--speed-base) var(--ease-out);
}
.card:has(a):hover {
  border-color: color-mix(in srgb, var(--color-accent) 40%, var(--color-line));
  box-shadow: 0 14px 34px -18px var(--shadow-tint);
  transform: translateY(-2px);
}
.card-img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.card-body { padding: var(--space-4) var(--space-5) var(--space-5); }
.card-body h3 { margin-bottom: 0.35em; }
.card-body h3 a { color: var(--color-ink); text-decoration: none; }
.card-body h3 a:hover { color: var(--color-accent); }
.card-body .eyebrow { margin-bottom: 0.6em; }
.card-body p:last-child { margin-bottom: 0; }

.person-img { aspect-ratio: 1; object-fit: cover; }
.person-placeholder {
  aspect-ratio: 1; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--color-accent-soft),
    color-mix(in srgb, var(--color-accent) 20%, var(--color-surface)));
  font-family: var(--font-display); font-size: var(--text-display);
  color: var(--color-accent);
}
.person-links { display: flex; gap: var(--space-3); font-size: var(--text-sm); }

.detail-img { border-radius: var(--radius-card); margin: var(--space-5) 0; }

/* gallery */
.gallery-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.gallery-item { margin: 0; }
.gallery-item img {
  border-radius: var(--radius-card); aspect-ratio: 4 / 3;
  object-fit: cover; width: 100%;
}
.gallery-item figcaption { font-size: var(--text-xs); margin-top: var(--space-2); }

/* sponsors */
.sponsor-strip {
  display: flex; gap: var(--space-7); align-items: center;
  flex-wrap: wrap;
}
.sponsor-logo { max-height: 56px; width: auto; }
.sponsor-row {
  display: flex; gap: var(--space-5); align-items: flex-start;
  padding: var(--space-5) 0; border-top: 1px solid var(--color-line);
}
.sponsor-row:first-of-type { border-top: 0; }
.sponsor-row .sponsor-logo { max-height: 72px; max-width: 140px; }

/* ====================== forms ============================================ */
.form { max-width: 560px; }
.form-row { margin-bottom: var(--space-4); display: flex; flex-direction: column; gap: var(--space-1); }
.form-row label { font-size: var(--text-sm); font-weight: 600; }
.form-row input:not([type="checkbox"]), .form-row textarea, .form-row select {
  font: inherit; padding: 0.6em 0.8em; min-height: 44px;
  border: 1.5px solid var(--color-line); border-radius: var(--radius-input);
  background: var(--color-surface); color: var(--color-ink);
}
.form-row textarea { min-height: auto; }
.form-row input:focus-visible, .form-row textarea:focus-visible {
  outline: 2px solid var(--color-focus); outline-offset: 1px;
  border-color: var(--color-accent);
}
.checkbox-label { display: flex; gap: var(--space-2); align-items: center; font-weight: 400; }

/* honeypot: visually removed, still in the DOM for bots */
.hp-field { position: absolute; left: -9999px; top: -9999px; }

/* flash messages */
.flashes { padding-top: var(--space-4); }
.flash {
  padding: 0.8em 1.1em; border-radius: var(--radius-input);
  margin-bottom: var(--space-2);
  border: 1px solid var(--color-line); background: var(--color-surface);
}
.flash-success {
  border-color: color-mix(in srgb, #15803d 40%, var(--color-line));
  background: color-mix(in srgb, #15803d 8%, var(--color-surface));
}
.flash-error {
  border-color: color-mix(in srgb, #b91c1c 40%, var(--color-line));
  background: color-mix(in srgb, #b91c1c 8%, var(--color-surface));
}

/* ====================== footer ===========================================
   Brand-navy footer, same colour in light and dark: the exact navy from the
   AeroSoc logo. The wordmark PNG is black, so it is inverted to white. */
.site-footer {
  margin-top: var(--space-section);
  background: var(--color-brand-navy);
  color: #e9ecf3;
  padding: var(--space-7) 0;
  font-size: var(--text-sm);
}
/* When a page ends on a .band, the footer gap would show as a stray light
   strip between two solid blocks — close it. */
main:has(> .band:last-child) + .site-footer { margin-top: 0; }
.site-footer .muted { color: #aab4cc; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--space-6); }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-brand {
  font-family: var(--font-display); font-weight: var(--weight-display);
  font-size: var(--text-md); margin-bottom: 0.3em;
}
.footer-wordmark { height: 44px; width: auto; filter: invert(1); margin-bottom: var(--space-3); }
.footer-links { display: flex; flex-direction: column; gap: var(--space-2); }
.footer-links a { color: #c4cde0; text-decoration: none; }
.footer-links a:hover { color: #ffffff; }

/* ====================== motion guard ===================================== */
@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;
  }
  .card:has(a):hover { transform: none; }
  .btn:active { transform: none; }
}
