/* ==========================================================================
   Trabuco Creek Restoration Map — styles.css

   Look & feel: a digital field notebook / herbarium sheet that holds a live
   map. Plant data is set in a monospace "specimen label" style. Colors are
   drawn from the creek itself — willow green, iron-oxide red for invasives,
   and a steel-teal for water and accents.

   Built mobile-first (most viewing happens on phones), then adjusted upward
   for larger screens via the media query near the bottom.
   ========================================================================== */

/* ---- 1. Design tokens (change colors/fonts in one place) ----------------- */
:root {
  /* Paper & ink */
  --paper:      #E9E3D5;   /* main background — aged field paper */
  --paper-2:    #E2DBCA;   /* raised panels / cards */
  --paper-3:    #DCD4C0;   /* inset chips */
  --ink:        #211E17;   /* primary text — field-log ink */
  --ink-soft:   #4A463A;   /* secondary text */
  --ink-faint:  #716C5D;   /* captions, meta */
  --rule:       #C7BEAA;   /* hairline rules & borders */

  /* Accent (water) */
  --teal:       #2E6E72;
  --teal-deep:  #234F53;

  /* Category colors (kept in sync with species-classification.json) */
  --c-invasive:   #BB4A2C;
  --c-native:     #3C7A4B;
  --c-non_native: #C2932E;
  --c-unknown:    #6E7268;

  /* Type */
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --sans:    "Public Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --maxw: 1080px;
}

/* ---- 2. Reset-ish base --------------------------------------------------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;   /* stop iOS from auto-zooming text */
}

a { color: var(--teal-deep); text-underline-offset: 2px; }

/* A faint repeating top-border motif evoking notebook ruling, used sparingly */
.rule-eyebrow {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---- 3. Masthead --------------------------------------------------------- */
.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.masthead__title h1 {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 1.42rem;
  line-height: 1.05;
  margin: 0;
  letter-spacing: -0.01em;
}
.masthead__title h1 span {
  display: block;
  font-weight: 500;
  color: var(--teal-deep);
}
.masthead__sub {
  margin: 5px 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* The "data stamp" — a small specimen-tag-style block, top right */
.masthead__stamp {
  flex: 0 0 auto;
  text-align: right;
  font-family: var(--mono);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 6px 9px;
  background: var(--paper-2);
  line-height: 1.2;
}
.stamp__label {
  display: block;
  font-size: 0.56rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.stamp__value {
  display: block;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--ink);
}
.stamp__meta {
  display: block;
  font-size: 0.6rem;
  color: var(--ink-faint);
  margin-top: 1px;
}

/* ---- 4. Map + floating controls ----------------------------------------- */
.map-shell {
  position: relative;
  width: 100%;
}

/* Explicit height is important: without it, Leaflet renders a blank/zero-height
   map. We give a viewport-relative height with a hard pixel floor as backup. */
#map {
  width: 100%;
  height: 62vh;
  min-height: 380px;
  background: #cdc7b8;     /* shows while tiles load */
  z-index: 1;
}

/* Controls panel floats over the map's top-right corner. */
.map-panel {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;           /* above Leaflet layers */
  width: 232px;
  max-width: calc(100% - 20px);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 5px;
  box-shadow: 0 6px 18px rgba(33, 30, 23, 0.18);
  overflow: hidden;
  font-size: 0.84rem;
}

.map-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  cursor: pointer;
  user-select: none;
  background: var(--paper-3);
  border-bottom: 1px solid var(--rule);
}
.map-panel__head h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
}
.map-panel__chev {
  transition: transform 0.18s ease;
  color: var(--ink-faint);
  font-size: 0.7rem;
}
.map-panel.is-collapsed .map-panel__chev { transform: rotate(-90deg); }
.map-panel.is-collapsed .map-panel__body { display: none; }

.map-panel__body { padding: 6px 11px 11px; }

.panel-group { padding-top: 8px; }
.panel-group + .panel-group {
  margin-top: 8px;
  border-top: 1px solid var(--rule);
}
.panel-group__label {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 2px 0 4px;
}

/* A filter row also serves as the legend: checkbox · color · label · count */
.filter-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;          /* comfortable touch target */
  padding: 2px 0;
  cursor: pointer;
}
.filter-row input {
  width: 17px; height: 17px;
  accent-color: var(--teal);
  margin: 0;
  flex: 0 0 auto;
}
.swatch {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.9);
  box-shadow: 0 0 0 1px rgba(33,30,23,0.25);
  flex: 0 0 auto;
}
.filter-row__label { flex: 1 1 auto; }
.filter-row__count {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  flex: 0 0 auto;
}

/* Segmented control (heat layer) + select (basemap) */
.seg {
  display: flex;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  background: var(--paper);
}
.seg button {
  flex: 1 1 0;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 7px 4px;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--rule); }
.seg button.is-active { background: var(--teal); color: #fff; }

.field-select {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.82rem;
  padding: 7px 8px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}

.mini-check {
  display: flex; align-items: center; gap: 8px;
  min-height: 34px; cursor: pointer; font-size: 0.82rem;
}
.mini-check input { width: 16px; height: 16px; accent-color: var(--teal); margin: 0; }

/* ---- 5. Readout (everything below the map) ------------------------------- */
.readout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 16px 8px;
}

.card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px 16px 14px;
  margin-bottom: 20px;
}
.card h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.12rem;
  margin: 4px 0 8px;
}
.card p { margin: 0 0 9px; font-size: 0.9rem; color: var(--ink-soft); }
.card p:last-child { margin-bottom: 0; }

.card--method strong { color: var(--ink); }
.legend-inline {
  display: inline-flex; align-items: baseline; gap: 5px;
  font-family: var(--mono); font-size: 0.78rem;
}

/* Summary "specimen tags" — small stat blocks in a row */
.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--teal);
  border-radius: 4px;
  padding: 10px 12px;
}
.stat__value { font-family: var(--display); font-weight: 600; font-size: 1.7rem; line-height: 1; }
.stat__label {
  font-family: var(--mono); font-size: 0.6rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-faint); margin-top: 5px; display: block;
}
.stat--invasive { border-left-color: var(--c-invasive); }
.stat--native   { border-left-color: var(--c-native); }

/* Composition bar (share of observations by category) */
.composition { margin-bottom: 22px; }
.composition__bar {
  display: flex; height: 16px; border-radius: 3px; overflow: hidden;
  border: 1px solid var(--rule);
}
.composition__seg { height: 100%; }
.composition__key {
  display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 8px;
  font-family: var(--mono); font-size: 0.72rem; color: var(--ink-soft);
}
.composition__key span { display: inline-flex; align-items: center; gap: 6px; }

/* Section heading for the inventory */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 6px; margin: 26px 0 0;
}
.section-head h2 { font-family: var(--display); font-weight: 600; font-size: 1.25rem; margin: 0; }
.section-head .rule-eyebrow { flex: 0 0 auto; }

/* Category group inside the inventory */
.taxa-group { margin-top: 18px; }
.taxa-group__head {
  display: flex; align-items: center; gap: 9px; margin-bottom: 6px;
}
.taxa-group__head .swatch { width: 14px; height: 14px; }
.taxa-group__title { font-weight: 600; font-size: 0.98rem; }
.taxa-group__n { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-faint); }

/* A single plant = a specimen tag */
.taxon {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--rule);
}
.taxon:last-child { border-bottom: 0; }
.taxon__tick {
  width: 4px; align-self: stretch; border-radius: 2px; flex: 0 0 auto;
  min-height: 30px;
}
.taxon__body { flex: 1 1 auto; min-width: 0; }
.taxon__common { font-weight: 500; font-size: 0.92rem; }
.taxon__sci {
  font-family: var(--mono); font-style: italic; font-size: 0.76rem;
  color: var(--ink-faint); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.taxon__flags { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 5px; }
.flag {
  font-family: var(--mono); font-size: 0.58rem; letter-spacing: 0.05em;
  text-transform: uppercase; padding: 2px 6px; border-radius: 999px;
  border: 1px solid var(--rule); color: var(--ink-soft); background: var(--paper-3);
}
.flag--priority { border-color: var(--c-invasive); color: var(--c-invasive); }
.flag--sensitive { border-color: var(--c-native); color: var(--c-native); }

.taxon__right { flex: 0 0 auto; text-align: right; }
.taxon__count {
  font-family: var(--mono); font-size: 0.95rem; font-weight: 500; color: var(--ink);
}
.taxon__count small { color: var(--ink-faint); font-weight: 400; }
.taxon__grade {
  font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-faint); margin-top: 2px; display: block;
}

/* ---- 6. Leaflet popup restyle (match the notebook look) ------------------ */
.leaflet-popup-content-wrapper {
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 8px 22px rgba(33,30,23,0.28);
}
.leaflet-popup-tip { background: var(--paper-2); border: 1px solid var(--rule); }
.leaflet-popup-content { margin: 11px 13px; font-family: var(--sans); line-height: 1.45; }

.pop__photo {
  width: 100%; height: 116px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--rule); margin-bottom: 8px; display: block;
}
.pop__chip {
  display: inline-block; font-family: var(--mono); font-size: 0.58rem;
  letter-spacing: 0.06em; text-transform: uppercase; color: #fff;
  padding: 2px 7px; border-radius: 999px; margin-bottom: 6px;
}
.pop__common { font-weight: 600; font-size: 0.96rem; }
.pop__sci { font-family: var(--mono); font-style: italic; font-size: 0.78rem; color: var(--ink-faint); }
.pop__meta { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-soft); margin-top: 6px; }
.pop__note {
  font-size: 0.76rem; color: var(--ink-soft); margin-top: 7px;
  padding-top: 7px; border-top: 1px solid var(--rule);
}
.pop__link {
  display: inline-block; margin-top: 8px; font-family: var(--mono);
  font-size: 0.72rem; font-weight: 500;
}
.pop__sensitive {
  margin-top: 7px; font-family: var(--mono); font-size: 0.66rem;
  color: var(--c-native); border-top: 1px solid var(--rule); padding-top: 7px;
}

/* Leaflet attribution & controls: make them quieter and on-brand */
.leaflet-control-attribution {
  background: rgba(233,227,213,0.82) !important;
  font-family: var(--mono); font-size: 0.6rem !important; color: var(--ink-faint) !important;
}
.leaflet-bar a { background: var(--paper-2); color: var(--ink); }
.leaflet-control-scale-line {
  background: rgba(233,227,213,0.82); border-color: var(--ink-faint);
  font-family: var(--mono); font-size: 0.62rem; color: var(--ink-soft);
}

/* ---- 7. Footer ----------------------------------------------------------- */
.site-footer {
  max-width: var(--maxw); margin: 0 auto; padding: 18px 16px 40px;
  border-top: 1px solid var(--rule); margin-top: 10px;
  font-size: 0.76rem; color: var(--ink-faint);
}
.site-footer p { margin: 0 0 7px; }
.site-footer .mono { font-family: var(--mono); }

/* ---- 8. Larger screens --------------------------------------------------- */
@media (min-width: 720px) {
  html, body { font-size: 17px; }
  .masthead { padding: 18px 28px 16px; }
  .masthead__title h1 { font-size: 1.78rem; }
  #map { height: 72vh; min-height: 460px; }
  .map-panel { width: 256px; top: 14px; right: 14px; }
  .readout { padding: 30px 28px 8px; }
  .stat-row { grid-template-columns: repeat(4, 1fr); }
  .site-footer { padding: 22px 28px 56px; }
}

/* ---- 9. Accessibility: respect reduced-motion preference ----------------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Visible keyboard focus for everyone navigating without a mouse */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
