/* ==========================================================================
   Roslin Community Development Trust — style.css
   Design system: "Glen & Stone"
   - Palette drawn from Roslin Glen woodland and chapel sandstone
   - Display face: Bricolage Grotesque / Body face: Source Sans 3
   - Mobile-first, accessible, no framework
   ========================================================================== */

/* ---- 1. Design tokens ---------------------------------------------------- */
:root {
  /* Colour */
  --glen: #17493b;        /* deep woodland green — primary */
  --esk: #2e6e5e;         /* river teal — secondary / hover */
  --sandstone: #c9a86a;   /* chapel stone gold — accent */
  --ink: #1c2321;         /* near-black text */
  --paper: #fbfaf7;       /* warm off-white page background */
  --mist: #edefe9;        /* alternating section background */
  --line: #d8dcd3;        /* hairline borders */
  --white: #ffffff;

  /* Type */
  --font-display: "Bricolage Grotesque", "Arial Black", sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", Arial, sans-serif;

  /* Scale (fluid) */
  --text-sm: 0.875rem;
  --text-base: 1.0625rem;
  --text-lg: clamp(1.15rem, 1rem + 0.6vw, 1.35rem);
  --text-h3: clamp(1.25rem, 1.1rem + 0.8vw, 1.6rem);
  --text-h2: clamp(1.7rem, 1.3rem + 1.6vw, 2.4rem);
  --text-h1: clamp(2.3rem, 1.6rem + 3.4vw, 4.2rem);

  /* Spacing & shape */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;
  --space-6: 6rem;
  --radius: 10px;
  --measure: 65ch;        /* max comfortable line length */
  --container: 72rem;
}

/* ---- 2. Reset & base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0 0 var(--space-2);
  color: var(--glen);
  text-wrap: balance;
}
h1 { font-size: var(--text-h1); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: var(--text-h2); font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: var(--text-h3); font-weight: 600; }

p, ul, ol { margin: 0 0 var(--space-2); max-width: var(--measure); }

a { color: var(--esk); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--glen); }

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

/* ---- 3. Utilities -------------------------------------------------------- */
.container {
  width: min(100% - 2.5rem, var(--container));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--glen);
  color: var(--white);
  padding: var(--space-1) var(--space-2);
  z-index: 100;
}
.skip-link:focus { left: 0; }

.eyebrow {
  display: block;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--esk);
  margin-bottom: var(--space-1);
}

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

/* ---- 4. Header & navigation ---------------------------------------------- */
.site-header {
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Top row: brand + (mobile) hamburger */
.header-top {
  border-bottom: 1px solid var(--line);
}
.header-top .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-block: 0.7rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--glen);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.1;
  flex-shrink: 0;
}
.brand svg { flex-shrink: 0; }
.brand span small {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--esk);
  letter-spacing: 0.02em;
}

.brand img {
  display: block;
  height: 48px;
  width: auto;
}

/* ── Animated hamburger (mobile only) ───────────────────────────────────── */
.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.6rem;
  height: 2.6rem;
  background: var(--glen);
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--white);
  border-radius: 2px;
  transition: transform 250ms ease, opacity 200ms ease;
  transform-origin: center;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ══════════════════════════════════════════════════════════════════════════
   THE MENU BAR
   ══════════════════════════════════════════════════════════════════════════ */
.site-nav {
  background: var(--glen);
}

.site-nav > ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  width: min(100% - 2.5rem, var(--container));
  margin-inline: auto;
}

/* ── Each menu item (a "cell" in the bar) ────────────────────────────────── */
.nav-item {
  position: relative;
  display: flex;
}

/* Divider lines between cells */
.nav-item + .nav-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 25%;
  bottom: 25%;
  width: 1px;
  background: rgba(255,255,255,0.12);
}

.nav-item > a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem 1.35rem;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  position: relative;
  transition: background 180ms ease, color 180ms ease;
}

/* Down-caret only on items that have a submenu */
.nav-item.has-sub > a::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.65;
  transition: transform 200ms ease, opacity 200ms ease;
}
.nav-item:hover.has-sub > a::after,
.nav-item:focus-within.has-sub > a::after {
  transform: rotate(180deg);
  opacity: 1;
}

/* Hover / active cell */
.nav-item > a:hover,
.nav-item > a:focus-visible {
  background: var(--esk);
  color: var(--white);
}

/* Sandstone underline bar on the current page */
.nav-item > a[aria-current="page"] {
  color: var(--white);
  background: rgba(255,255,255,0.08);
}
.nav-item > a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--sandstone);
}

/* ══════════════════════════════════════════════════════════════════════════
   CASCADING DROPDOWN PANEL
   ══════════════════════════════════════════════════════════════════════════ */
.sub-menu {
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 15rem;
  background: var(--white);
  border-radius: 0 0 12px 12px;
  box-shadow:
    0 2px 4px rgb(23 73 59 / 0.06),
    0 16px 36px rgb(23 73 59 / 0.18);
  border-top: 3px solid var(--sandstone);

  /* hidden state */
  visibility: hidden;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease, visibility 0ms linear 200ms;
  z-index: 20;
}

/* Open on hover, keyboard focus, or JS class (mobile) */
.nav-item:hover > .sub-menu,
.nav-item:focus-within > .sub-menu,
.sub-menu.is-open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity 200ms ease, transform 200ms ease, visibility 0ms linear 0ms;
}

.sub-menu li { margin: 0; }

.sub-menu a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  border-radius: 8px;
  transition: background 150ms ease, color 150ms ease, padding-left 150ms ease;
}

/* Leading marker that grows on hover — the cascade feel */
.sub-menu a::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sandstone);
  flex-shrink: 0;
  transition: transform 150ms ease;
}
.sub-menu a:hover,
.sub-menu a:focus-visible {
  background: var(--mist);
  color: var(--glen);
  padding-left: 1.1rem;
}
.sub-menu a:hover::before,
.sub-menu a:focus-visible::before {
  transform: scale(1.5);
}
.sub-menu a[aria-current="page"] {
  color: var(--glen);
  background: var(--mist);
}

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE  (< 60rem): bar collapses into a drawer
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 59.99rem) {
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    box-shadow: 0 16px 32px rgb(0 0 0 / 0.2);
    max-height: calc(100vh - 100%);
    overflow-y: auto;
  }
  .site-nav.is-open { display: block; }

  .site-nav > ul {
    flex-direction: column;
    width: 100%;
    padding: 0.5rem;
  }

  .nav-item { flex-direction: column; }
  .nav-item + .nav-item::before { display: none; }

  .nav-item > a {
    justify-content: space-between;
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
  }
  .nav-item > a[aria-current="page"]::before { display: none; }

  /* Mobile submenu = inline accordion, not a floating panel */
  .sub-menu {
    position: static;
    visibility: visible;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    box-shadow: none;
    border-top: none;
    border-radius: 0;
    background: transparent;
    min-width: 0;
    padding: 0 0 0.4rem 1rem;
    margin-left: 0.4rem;
    border-left: 2px solid rgba(201,168,106,0.5);
    transition: none;

    /* collapsed by default on mobile */
    display: none;
  }
  .sub-menu.is-open { display: block; }

  .sub-menu a {
    color: rgba(255,255,255,0.8);
  }
  .sub-menu a::before { background: var(--sandstone); }
  .sub-menu a:hover,
  .sub-menu a:focus-visible {
    background: rgba(255,255,255,0.1);
    color: var(--white);
    padding-left: 1.1rem;
  }
  .sub-menu a[aria-current="page"] {
    background: transparent;
    color: var(--sandstone);
  }
}

/* Desktop: hide the hamburger */
@media (min-width: 60rem) {
  .nav-toggle { display: none; }
}

/* ---- 5. Hero with glen-contour signature motif --------------------------- */
.hero {
  position: relative;
  background: var(--glen);
  color: var(--white);
  overflow: hidden;
}
.hero .container {
  position: relative;
  z-index: 1;
  padding-block: var(--space-5) var(--space-6);
}
.hero h1 { color: var(--white); max-width: 18ch; }
.hero .eyebrow { color: var(--sandstone); }
.hero p { font-size: var(--text-lg); max-width: 48ch; color: #dfe8e2; }

.hero-contours {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.35;
  pointer-events: none;
}

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

/* ---- 6. Buttons ----------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius);
  font-weight: 700;
  text-decoration: none;
  border: 2px solid transparent;
  transition: background-color 150ms ease, color 150ms ease;
}
.btn-primary { background: var(--sandstone); color: var(--ink); }
.btn-primary:hover { background: #d9bc84; color: var(--ink); }
.btn-secondary { background: transparent; color: var(--white); border-color: var(--white); }
.btn-secondary:hover { background: rgb(255 255 255 / 0.12); color: var(--white); }
.btn-quiet { background: var(--mist); color: var(--glen); }
.btn-quiet:hover { background: var(--line); }
.btn-join {
  background: var(--glen);
  color: var(--white);
}
.btn-join:hover {
  background: var(--esk);
  color: var(--white);
}

/* ---- 7. Sections & cards --------------------------------------------------*/
.section { padding-block: var(--space-5); }
.section-alt { background: var(--mist); }
.section-head { margin-bottom: var(--space-4); }

.card-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
}
@media (min-width: 40rem) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 62rem) { .card-grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
}
.card h3 { margin-top: 0; }
.card p { flex-grow: 1; }
.card .card-link { font-weight: 700; text-decoration: none; }
.card .card-link:hover { text-decoration: underline; }

.card-date {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--esk);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}

/* Align date / title / body across the homepage News & Events cards only */
#news-events .card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}
#news-events .card > * { margin: 0; }
#news-events .card > * + * { margin-top: var(--space-1); }

.section-cta {
  margin-top: var(--space-3);
  text-align: center;
}

.pull-quote {
  position: relative;
  max-width: 44rem;
  margin: var(--space-4) 0;
  padding: var(--space-2) 0 var(--space-2) var(--space-4);
  border-left: 4px solid var(--sandstone);
}

/* Oversized opening quote mark in sandstone */
.pull-quote::before {
  content: "\201C";               /* left double quotation mark */
  position: absolute;
  top: -0.4rem;
  left: 1.4rem;
  font-family: var(--font-display);
  font-size: 5rem;
  line-height: 1;
  color: var(--sandstone);
  opacity: 0.35;
  pointer-events: none;
}

.pull-quote p {
  position: relative;            /* sits above the quote mark */
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-h3);
  font-weight: 600;
  line-height: 1.4;
  color: var(--glen);
  text-wrap: balance;
}

.pull-quote cite {
  display: block;
  margin-top: var(--space-2);
  font-family: var(--font-body);
  font-style: normal;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--esk);
}

/* Vision — mirror of the mission pull quote, bracketing it as a pair */
/* Vision — same left-aligned quote treatment as the mission, one step quieter */
.pull-quote.vision p {
  font-size: var(--text-lg);
  color: var(--esk);
}



/* ---- 8. Page banner (inner pages) -----------------------------------------*/
.page-banner {
  background: var(--glen);
  color: var(--white);
  position: relative;
  overflow: hidden;
}
.page-banner .container { position: relative; z-index: 1; padding-block: var(--space-4); }
.page-banner h1 { color: var(--white); }
.page-banner p { color: #dfe8e2; max-width: 55ch; }
.page-banner .hero-contours { opacity: 0.25; }

/* ---- 9. Prose & two-column layouts ----------------------------------------*/
.prose h2 { margin-top: var(--space-4); }
.prose h2:first-child { margin-top: 0; }

.split {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
  align-items: start;
}
@media (min-width: 52rem) { .split { grid-template-columns: 3fr 2fr; } }

.aside-box {
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 5px solid var(--sandstone);
  border-radius: var(--radius);
  padding: var(--space-3);
}
.aside-box h2, .aside-box h3 { margin-top: 0; }

/* ---- 10. Contact & forms ---------------------------------------------------*/
.contact-list { list-style: none; padding: 0; }
.contact-list li { margin-bottom: var(--space-2); }
.contact-list strong { display: block; color: var(--glen); }

.form-field { margin-bottom: var(--space-2); }
.form-field label { display: block; font-weight: 700; margin-bottom: 0.3rem; color: var(--glen); }
.form-field input,
.form-field textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}
.form-field input:focus,
.form-field textarea:focus { border-color: var(--esk); }
.form-note { font-size: var(--text-sm); color: #4a544f; }

/* ---- 11. Footer ------------------------------------------------------------*/
.site-footer {
  background: var(--glen);
  color: #cfe0d7;
  margin-top: var(--space-5);
  position: relative;
  overflow: hidden;
}
.site-footer .container {
  position: relative;
  z-index: 1;
  padding-block: var(--space-4);
  display: grid;
  gap: var(--space-3);
}
@media (min-width: 52rem) {
  .site-footer .container { grid-template-columns: 2fr 1fr 1fr; }
}
.site-footer h2 {
  color: var(--white);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.site-footer a { color: var(--white); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 0.4rem; }
.footer-legal {
  border-top: 1px solid rgb(255 255 255 / 0.15);
  position: relative;
  z-index: 1;
}
.footer-legal .container {
  display: block;
  padding-block: var(--space-2);
  font-size: var(--text-sm);
}

/* ---- 12. Tables (events listings etc.) -------------------------------------*/
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); }
th { font-family: var(--font-display); color: var(--glen); }

/* ---- 13. Map page ---------------------------------------------------------*/
#map {
  height: clamp(340px, 60vh, 560px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--mist);
}

/* Leaflet sets its own z-index stack; keep it below the sticky header. */
.leaflet-pane, .leaflet-top, .leaflet-bottom { z-index: 5 !important; }

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

.map-filter {
  font: inherit;
  font-weight: 600;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--glen);
  cursor: pointer;
}
.map-filter:hover { background: var(--mist); }
.map-filter[aria-pressed="true"] {
  background: var(--glen);
  border-color: var(--glen);
  color: var(--white);
}

.map-list { margin-top: var(--space-4); }
.map-list ul { list-style: none; padding: 0; max-width: none; }
.map-list li {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
}
.map-list li p { margin: 0.25rem 0 0; }

.map-list-link {
  font: inherit;
  font-family: var(--font-display);
  font-size: var(--text-h3);
  font-weight: 600;
  color: var(--esk);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.map-list-link:hover { color: var(--glen); text-decoration: underline; }

.map-tag {
  display: inline-block;
  margin-left: 0.6rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--white);
  vertical-align: 0.2em;
}

.leaflet-popup-content { font-family: var(--font-body); }
.leaflet-popup-content strong { font-family: var(--font-display); color: var(--glen); font-size: 1.05rem; }
.leaflet-popup-content p { margin: 0.35rem 0; max-width: none; }
.popup-category {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--esk);
}
