/* ============================================================
   Middlebury Township — Heritage Warm design system
   ============================================================ */

:root {
  /* Palette */
  --color-primary: #2d4a3e;      /* forest green */
  --color-primary-hover: #1f3429;
  --color-secondary: #5a7a5c;    /* sage */
  --color-accent: #a8462b;       /* barn red */
  --color-accent-hover: #8a3922;
  --color-bg: #faf6ee;           /* cream */
  --color-surface: #ffffff;
  --color-surface-warm: #f5ede0;
  --color-text: #1f2a24;
  --color-text-muted: #5b6a62;
  --color-border: #e2dccb;
  --color-link: #2d4a3e;

  /* Typography */
  --font-serif: "Source Serif Pro", "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  /* Layout */
  --container-max: 1200px;
  --container-narrow: 760px;
  --radius: 6px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);

  /* Split tokens so dark mode can flip text without disturbing the green chrome */
  --color-heading: var(--color-primary);      /* heading / link text that must invert in dark */
  --color-on-dark: var(--color-surface-warm);  /* light text/borders on the always-green chrome */

  color-scheme: light;
}

/* ----- Reset ----- */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
img, picture { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; }

/* ----- Base ----- */
html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-heading);
}
h1 { font-size: clamp(1.75rem, 4vw, 2.75rem); margin-bottom: var(--space-4); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: var(--space-3); }
h3 { font-size: 1.25rem; margin-bottom: var(--space-3); }
h4 { font-size: 1rem; margin-bottom: var(--space-2); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-color: var(--color-secondary);
  text-underline-offset: 3px;
}
a:hover { color: var(--color-accent); }

/* ----- Layout ----- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-5);
}
.container-narrow {
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

/* ----- Header ----- */
.site-header {
  background: var(--color-primary);
  color: var(--color-on-dark);
  padding: var(--space-4) 0;
  border-bottom: 4px solid var(--color-accent);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
}
.site-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-on-dark);
  text-decoration: none;
}
.site-title:hover { color: white; }
.site-tagline {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-top: 2px;
}

/* ----- Nav ----- */
.site-nav ul {
  display: flex;
  gap: var(--space-5);
  list-style: none;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
}
.site-nav a {
  color: var(--color-on-dark);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: var(--space-2) 0;
  position: relative;
}
.site-nav a:hover { color: white; }
.site-nav .has-dropdown { position: relative; }
.site-nav .dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  padding: var(--space-2);
  z-index: 50;
  margin-top: var(--space-2);
}
/* Invisible bridge over the margin-top gap so moving the cursor from the menu
   item down into the dropdown doesn't pass through a dead zone and close it. */
.site-nav .dropdown::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--space-2));
  left: 0;
  right: 0;
  height: var(--space-2);
}
.site-nav .has-dropdown:hover .dropdown,
.site-nav .has-dropdown:focus-within .dropdown { display: block; }
.site-nav .dropdown a {
  display: block;
  padding: var(--space-2) var(--space-3);
  color: var(--color-heading);
  border-radius: var(--radius);
}
.site-nav .dropdown a:hover { background: var(--color-surface-warm); color: var(--color-accent); }

/* ----- Hero ----- */
.hero {
  background: linear-gradient(135deg, var(--color-secondary), var(--color-primary));
  color: var(--color-on-dark);
  padding: var(--space-9) 0 var(--space-8);
  text-align: center;
}
.hero h1 { color: white; margin-bottom: var(--space-3); }
.hero .lede {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.15rem;
  opacity: 0.95;
  max-width: 600px;
  margin: 0 auto var(--space-5);
}
.hero-actions { display: flex; gap: var(--space-3); justify-content: center; flex-wrap: wrap; }

/* ----- Buttons ----- */
.btn {
  display: inline-block;
  padding: var(--space-3) var(--space-5);
  background: var(--color-accent);
  color: white;
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 150ms;
}
.btn:hover { background: var(--color-accent-hover); color: white; }
.btn-secondary {
  background: transparent;
  border: 2px solid var(--color-on-dark);
  color: var(--color-on-dark);
}
.btn-secondary:hover { background: var(--color-surface-warm); color: var(--color-heading); }

/* ----- Cards & content blocks ----- */
.section { padding: var(--space-8) 0; }
.section-title {
  text-align: center;
  margin-bottom: var(--space-6);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-5);
}
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.card-body { padding: var(--space-5); flex: 1; }
.card .tag {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-accent);
  font-weight: 700;
  margin-bottom: var(--space-2);
}
.card h3 { margin-bottom: var(--space-2); font-size: 1.15rem; }
.card .meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

/* ----- Article (long-form content pages) ----- */
.article {
  background: var(--color-surface);
  padding: var(--space-7) 0;
}
.article-header { margin-bottom: var(--space-6); }
.article-header .kicker {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--color-accent);
  font-weight: 700;
  margin-bottom: var(--space-2);
}
.article-body ul, .article-body ol { margin: 0 0 var(--space-4) var(--space-5); }
.article-body li { margin-bottom: var(--space-2); }
.article-body img { border-radius: var(--radius); margin: var(--space-5) 0; }
.article-body blockquote {
  border-left: 4px solid var(--color-accent);
  padding-left: var(--space-4);
  font-style: italic;
  color: var(--color-text-muted);
  margin: var(--space-5) 0;
}

/* ----- Lists (minutes, agendas, news index) ----- */
.entry-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.entry-list > li {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) 0;
}
.entry-list > li:last-child { border-bottom: none; }
.entry-list .entry-date {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-right: var(--space-3);
}
.entry-list .entry-title {
  font-weight: 600;
  color: var(--color-heading);
  text-decoration: none;
}
.entry-list .entry-title:hover { color: var(--color-accent); }

/* ----- Footer ----- */
.site-footer {
  background: var(--color-primary);
  color: var(--color-on-dark);
  padding: var(--space-7) 0 var(--space-5);
  margin-top: var(--space-9);
}
.site-footer a { color: var(--color-on-dark); }
.site-footer a:hover { color: white; }
.site-footer .footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}
.site-footer h4 {
  color: var(--color-on-dark);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.site-footer ul { list-style: none; padding: 0; }
.site-footer li { margin-bottom: var(--space-2); font-size: 0.9rem; }
.site-footer .legal {
  border-top: 1px solid rgba(245, 237, 224, 0.2);
  padding-top: var(--space-4);
  font-size: 0.8rem;
  opacity: 0.85;
  text-align: center;
}

/* ----- Forms & documents lists ----- */
.doc-list { list-style: none; padding: 0; margin: var(--space-3) 0 var(--space-6); }
.doc-list li { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.doc-size { color: var(--color-text-muted); font-size: 0.8rem; white-space: nowrap; }
.doc-size-large { color: #9a4b00; font-weight: 600; }

/* ----- Responsive ----- */
@media (max-width: 720px) {
  .site-header .container { flex-direction: column; align-items: flex-start; }
  .site-nav ul { gap: var(--space-4); }
  .hero { padding: var(--space-7) 0 var(--space-6); }
}

/* ============================================================
   Dark theme — activates on the visitor's OS/browser preference.
   Cool-dark palette. The green chrome (header/hero/footer/buttons)
   keeps --color-primary; only text/surface tokens flip.
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #17191a;
    --color-surface: #202325;
    --color-surface-warm: #262a2c;
    --color-text: #e6e8ea;
    --color-text-muted: #9aa0a4;
    --color-border: #33383b;
    --color-link: #86c08a;
    --color-accent: #d4673f;
    --color-accent-hover: #e07a4f;
    --color-heading: #eef1ee;
    --color-on-dark: #e6e8ea;
    color-scheme: dark;
  }
  .doc-size-large { color: #d6a04a; }
}