/* The Andover Association - site stylesheet.
   Palette, type and shell follow the andoverconcept resident-portal content pages:
   cream surfaces, forest green primary, Inter body, Fraunces for the brand and headings. */

/* ---------- Tokens ---------- */
:root {
  --bg: #f6f3ec;
  --surface: #fbf9f4;
  --surface-2: #ffffff;
  --surface-alt: #f9f7f2;
  --border: #ddd6c8;
  --border-strong: #cfc7b6;
  --text: #1f2a24;
  --text-muted: #5d665f;
  --text-faint: #959a91;
  --text-inverse: #f6f3ec;
  --primary: #2f5741;
  --primary-hover: #234433;
  --primary-tint: #dbe5dc;
  --band: #22402f;          /* dark green nav band */
  --band-ink: #f6f3ec;
  --brass: #8a5a2b;
  --brass-light: #e7c9a5;
  --gold: #b0832e;
  --error: #8a3b2a;
  --error-bg: #f2dfd7;
  --warning: #964219;
  --warning-bg: #efe2d0;
  --success: #2f5741;
  --success-bg: #dbe5dc;
  --line: rgba(31, 42, 36, .14);
  --shadow-sm: 0 1px 2px rgba(31, 42, 36, .06);
  --shadow-md: 0 6px 20px rgba(31, 42, 36, .08);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-pill: 999px;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Fraunces', ui-serif, Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --content: 1280px;
  --prose: 760px;
  color-scheme: light;
}
/* Dark palette: applies when the OS prefers dark, unless data-theme="light" is set,
   or whenever data-theme="dark" is set on <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141a17; --surface: #1a211d; --surface-2: #1f2722; --surface-alt: #232c27;
    --border: #2c3631; --border-strong: #3a4640;
    --text: #e6e3da; --text-muted: #a3a89f; --text-faint: #6c726b; --text-inverse: #141a17;
    --primary: #8fbc9d; --primary-hover: #a9cdb4; --primary-tint: #26372d;
    --band: #1d3327; --brass: #d3a372; --gold: #c9a25a;
    --error: #e59a86; --error-bg: #3d2721; --warning: #e0a77e; --warning-bg: #3a2e22;
    --success: #8fbc9d; --success-bg: #26372d;
    --line: rgba(230, 227, 218, .14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow-md: 0 6px 20px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141a17; --surface: #1a211d; --surface-2: #1f2722; --surface-alt: #232c27;
  --border: #2c3631; --border-strong: #3a4640;
  --text: #e6e3da; --text-muted: #a3a89f; --text-faint: #6c726b; --text-inverse: #141a17;
  --primary: #8fbc9d; --primary-hover: #a9cdb4; --primary-tint: #26372d;
  --band: #1d3327; --brass: #d3a372; --gold: #c9a25a;
  --error: #e59a86; --error-bg: #3d2721; --warning: #e0a77e; --warning-bg: #3a2e22;
  --success: #8fbc9d; --success-bg: #26372d;
  --line: rgba(230, 227, 218, .14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow-md: 0 6px 20px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--primary); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--primary-hover); }
p, li { text-wrap: pretty; }
h1, h2, h3, h4 { line-height: 1.2; text-wrap: balance; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: var(--radius-sm); }
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sr-only, .hp {
  position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip {
  position: absolute; left: 16px; top: -100px; z-index: 10000;
  background: var(--primary); color: var(--text-inverse);
  padding: 8px 16px; border-radius: var(--radius-sm);
}
.skip:focus { top: 16px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-row {
  display: flex; align-items: center; gap: 16px;
  max-width: 1600px; margin: 0 auto; padding: 12px 24px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand:hover { color: inherit; }
.brand-mark { height: 40px; width: auto; flex-shrink: 0; }
.brand-titles { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-display); font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--text-muted); letter-spacing: .08em; text-transform: uppercase; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill-link {
  display: inline-flex; align-items: center; height: 36px; padding: 0 12px;
  font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none;
  color: var(--text-muted); border: 1px solid var(--line); border-radius: var(--radius-pill);
}
.pill-link:hover { color: var(--text); background: var(--line); }

/* Dark green section band under the topbar */
.navband {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--band);
}
.navband-label {
  font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brass-light); margin-right: 4px;
}
.navband a {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
  font-size: 14px; font-weight: 600; white-space: nowrap; text-decoration: none;
  color: var(--band-ink); background: rgba(246, 243, 236, .08);
  border: 1px solid rgba(246, 243, 236, .2); border-radius: var(--radius-pill);
  transition: background .15s;
}
.navband a:hover { background: rgba(246, 243, 236, .18); color: #fff; }
.navband a[aria-current="page"] { background: var(--band-ink); color: #22402f; border-color: var(--band-ink); }
.navband svg { width: 16px; height: 16px; }

@media (max-width: 640px) {
  .topbar-row { padding: 10px 16px; gap: 10px; }
  .brand-sub, .navband-label { display: none; }
  .navband { padding: 8px 16px; gap: 6px; }
  .navband a { font-size: 13px; padding: 7px 12px; }
}

/* ---------- Page layout ---------- */
.app { flex: 1; width: 100%; max-width: var(--content); margin: 0 auto; padding: 32px 24px 48px; }
.app.narrow { max-width: 760px; }
@media (max-width: 640px) { .app { padding: 24px 16px 40px; } }

.masthead {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  padding-bottom: 24px; margin-bottom: 32px; border-bottom: 1px solid var(--border);
}
.masthead h1, h1.page-title {
  margin: 0; font-family: var(--font-display); font-size: clamp(26px, 22px + 1.2vw, 34px);
  font-weight: 600; letter-spacing: -.015em;
}
.masthead .lede, p.lead {
  margin: 8px 0 0; max-width: var(--prose); color: var(--text-muted); font-size: 16px;
}
.masthead .meta { text-align: right; font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.masthead .meta .strong { color: var(--text); font-weight: 500; }
@media (max-width: 640px) {
  .masthead { flex-direction: column; gap: 12px; margin-bottom: 24px; }
  .masthead .meta { text-align: left; }
}

h2.section-title { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 4px; }
p.section-lede { color: var(--text-muted); font-size: 14px; margin: 0 0 24px; max-width: var(--prose); }
.prose { max-width: var(--prose); }
.prose p { margin: 0 0 1em; }

/* ---------- Hero (home page) ---------- */
.hero { position: relative; min-height: clamp(320px, 52vh, 560px); display: grid; align-items: end; overflow: hidden; }
.hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(20, 30, 24, .78) 0%, rgba(20, 30, 24, .25) 55%, rgba(20, 30, 24, 0) 100%);
}
.hero-inner {
  position: relative; z-index: 1; width: 100%; max-width: var(--content);
  margin: 0 auto; padding: 48px 24px; color: #f6f3ec;
}
.hero-kicker { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--brass-light); margin: 0 0 8px; }
.hero h1 {
  margin: 0; font-family: var(--font-display); font-weight: 500;
  font-size: clamp(34px, 24px + 3vw, 60px); letter-spacing: -.02em; line-height: 1.05;
}
.hero p { margin: 12px 0 0; max-width: 620px; font-size: 17px; color: rgba(246, 243, 236, .9); }
.hero .btn { margin-top: 20px; }
@media (max-width: 640px) { .hero-inner { padding: 32px 16px; } }

/* Image beside text */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: center; }
.split-media img { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow-md); }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }

/* ---------- Cards and grids ---------- */
.card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-sm); margin-bottom: 20px;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card h3 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.card .card-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
@media (max-width: 640px) { .card { padding: 20px; } }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 8px; }
.kpi .value { font-family: var(--font-mono); font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.brief-hero {
  background: linear-gradient(135deg, var(--primary-tint) 0%, var(--surface) 100%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 28px; margin-bottom: 20px;
}
.brief-hero .meta { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; }
.brief-hero h3 { margin: 0 0 8px; font-size: 18px; }
.brief-hero p { margin: 0; color: var(--text-muted); font-size: 14px; line-height: 1.6; max-width: var(--prose); }

/* ---------- Callouts, pills ---------- */
.callout {
  border-left: 3px solid var(--primary); border-radius: var(--radius);
  background: var(--surface-alt); padding: 14px 18px; margin: 12px 0 20px;
  font-size: 14px; line-height: 1.55;
}
.callout strong:first-child { display: block; margin-bottom: 4px; }
.callout-warn { border-color: var(--warning); background: var(--warning-bg); }
.callout-err  { border-color: var(--error); background: var(--error-bg); }
.callout-ok   { border-color: var(--success); background: var(--success-bg); }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 500;
  background: var(--primary-tint); color: var(--primary);
}
.pill.warn { background: var(--warning-bg); color: var(--warning); }
.pill.err { background: var(--error-bg); color: var(--error); }
.pill.neutral { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th {
  font-weight: 500; color: var(--text-muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; background: var(--surface-alt);
}
table.data td.num, table.data th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-alt); }

/* ---------- Buttons ---------- */
.btn, button[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-size: 15px; font-weight: 600; line-height: 1.2; text-decoration: none;
  padding: 12px 22px; border-radius: var(--radius-pill); cursor: pointer;
  background: var(--primary); color: var(--text-inverse); border: 1px solid var(--primary);
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover, button[type="submit"]:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--text-inverse); }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); color: var(--primary); border-color: var(--primary); }
.hero .btn { background: #f6f3ec; color: #22402f; border-color: #f6f3ec; }
.hero .btn:hover { background: #fff; border-color: #fff; color: #22402f; }

/* ---------- Forms ---------- */
fieldset { border: 0; padding: 0; margin: 0 0 24px; min-width: 0; }
legend {
  padding: 0; margin-bottom: 4px; font-size: 11px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted);
}
legend .optional { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-faint); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row.addr { grid-template-columns: 1fr 2fr; }
@media (max-width: 480px) { .row, .row.addr { grid-template-columns: 1fr; } }
label { display: block; margin: 12px 0 4px; font-size: 13px; font-weight: 500; color: var(--text); }
input, select, textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--text);
  padding: 10px 12px; background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: 6px;
  transition: border-color .15s, box-shadow .15s;
}
input, select { min-height: 46px; }
textarea { min-height: 96px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint);
}
select option { color: var(--text); background: var(--surface-2); }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--error); font-size: 13px; }
.form-error {
  margin-bottom: 20px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--error-bg); color: var(--error); border-left: 3px solid var(--error);
}
.form-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.note { font-size: 13px; color: var(--text-muted); margin-top: 16px; }
.footnote {
  font-size: 11px; color: var(--text-faint); margin-top: 24px; padding-top: 16px;
  border-top: 1px solid var(--border); line-height: 1.55;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line); background: var(--surface);
  color: var(--text-muted); font-size: 13px;
}
.site-footer-inner {
  max-width: var(--content); margin: 0 auto; padding: 28px 24px 32px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.site-footer .foot-logo { width: 84px; height: 84px; border-radius: var(--radius); flex-shrink: 0; }
.site-footer .foot-name { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--text); }
.site-footer p { margin: 2px 0 0; }
.site-footer .foot-links { margin-left: auto; display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer .foot-links a { color: var(--text-muted); text-decoration: none; }
.site-footer .foot-links a:hover { color: var(--primary); }
@media (max-width: 640px) {
  .site-footer-inner { padding: 24px 16px; }
  .site-footer .foot-links { margin-left: 0; width: 100%; }
}

/* ---------- Utilities ---------- */
.text-muted { color: var(--text-muted); }
.text-small { font-size: 12px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.right { text-align: right; }
.strong { font-weight: 600; }

@media print {
  body { background: #fff; color: #000; font-size: 10pt; }
  .topbar, .navband, .site-footer, .btn, button { display: none !important; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}

/* Checkbox with its wording, e.g. consent boxes */
label.check {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start;
  margin: 12px 0 0; padding: 14px 16px; font-weight: 400; font-size: 14px; line-height: 1.5;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer;
}
label.check:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); }
label.check input[type="checkbox"] {
  width: 20px; height: 20px; min-height: 0; margin: 1px 0 0; padding: 0;
  accent-color: var(--primary); cursor: pointer;
}
label.check input[type="checkbox"]:focus { box-shadow: none; }
label.check input[type="checkbox"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
label.check .req { color: var(--text-muted); font-size: 13px; }
.prose h2.section-title { margin: 36px 0 8px; }
.prose h2.section-title:first-of-type { margin-top: 20px; }
