/* National Parks tracker — deep spruce ground, slab signage type, map-first. */

:root {
  --spruce:    #14291f;   /* page ground */
  --moss:      #1d3a2b;   /* panels, rows */
  --fern:      #2e5c42;   /* borders, hover */
  --bone:      #ede8da;   /* primary type */
  --lichen:    #a7c4a0;   /* secondary type, unvisited markers */
  --goldenrod: #e0a32e;   /* the one accent: visited */

  --shell: 68rem;
  --radius: 6px;

  /* Renders the native date picker and its icon for a dark ground */
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--spruce);
  color: var(--bone);
  font-family: 'Alegreya Sans', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

h1, h2, h3, .slab {
  font-family: Bitter, Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: var(--goldenrod); }

:focus-visible {
  outline: 2px solid var(--goldenrod);
  outline-offset: 2px;
}

/* --- Masthead ---------------------------------------------------------- */

.masthead {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 1.1rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.masthead h1 { font-size: 1.6rem; }

.masthead .home {
  display: block;
  font-family: 'Alegreya Sans', system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--lichen);
  text-decoration: none;
  margin-bottom: 0.15rem;
}
.masthead .home:hover { color: var(--goldenrod); }

.tally {
  font-family: Bitter, Georgia, serif;
  font-size: 0.95rem;
  color: var(--lichen);
}
.tally b {
  color: var(--goldenrod);
  font-size: 1.35rem;
  font-weight: 700;
}

/* --- Map: the hero ----------------------------------------------------- */

.map-wrap {
  max-width: var(--shell);
  margin: 0 auto 1.5rem;
  padding: 0 1.25rem;
}

#map {
  /* Tall enough for fitBounds to reach zoom 4 on the contiguous US. At 24rem the
     fit was height-constrained to zoom 3, which left the states small and a lot
     of Atlantic showing. */
  height: 28rem;
  border-radius: var(--radius);
  border: 1px solid var(--fern);
  background: var(--moss);
}

/* OSM tiles ship light; darken and green them so the map reads as part of the
   page rather than a bright rectangle pasted onto it. Tiles only — the filter
   would otherwise eat the markers and controls too. */
.leaflet-tile-pane {
  filter: invert(1) grayscale(1) brightness(0.92) contrast(1.06)
          sepia(0.45) hue-rotate(70deg) saturate(0.75);
}

/* Leaflet chrome, retuned for the spruce ground */
.leaflet-container { font-family: 'Alegreya Sans', system-ui, sans-serif; }
.leaflet-control-attribution {
  background: rgba(20, 41, 31, 0.82) !important;
  color: var(--lichen) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--lichen) !important; }
.leaflet-bar a {
  background: var(--moss) !important;
  color: var(--bone) !important;
  border-color: var(--fern) !important;
}
.leaflet-bar a:hover { background: var(--fern) !important; }
.leaflet-popup-content-wrap, .leaflet-popup-tip {
  background: var(--moss);
  color: var(--bone);
  border: 1px solid var(--fern);
}
.leaflet-popup-content { margin: 0.55rem 0.8rem; font-size: 0.88rem; }
.leaflet-popup-content b { font-family: Bitter, Georgia, serif; }
.leaflet-popup-close-button { color: var(--lichen) !important; }

/* --- Filters ----------------------------------------------------------- */

.filters {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 1.25rem 0.75rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.chip {
  font: inherit;
  font-size: 0.88rem;
  background: transparent;
  color: var(--lichen);
  border: 1px solid var(--fern);
  border-radius: 999px;
  padding: 0.25rem 0.85rem;
  cursor: pointer;
}
.chip:hover { color: var(--bone); }
.chip[aria-pressed="true"] {
  background: var(--goldenrod);
  border-color: var(--goldenrod);
  color: #24180a;
  font-weight: 700;
}

.search {
  font: inherit;
  font-size: 0.88rem;
  flex: 1 1 8rem;
  min-width: 7rem;
  background: var(--moss);
  border: 1px solid var(--fern);
  border-radius: var(--radius);
  color: var(--bone);
  padding: 0.32rem 0.7rem;
}
.search::placeholder { color: var(--lichen); opacity: 0.75; }

.sort-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--lichen);
  white-space: nowrap;
}

.sort {
  font: inherit;
  font-size: 0.88rem;
  background: var(--moss);
  border: 1px solid var(--fern);
  border-radius: var(--radius);
  color: var(--bone);
  padding: 0.28rem 0.5rem;
  cursor: pointer;
}

/* --- Park list --------------------------------------------------------- */

/* State heading. Bone, not goldenrod — goldenrod means "visited" and nothing else. */
.group {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-family: Bitter, Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--bone);
  margin: 0;
  padding: 1.6rem 0.3rem 0.4rem;
  border-bottom: 1px solid var(--fern);
}
.group:first-child { padding-top: 0.4rem; }
.group span {
  font-family: 'Alegreya Sans', system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--lichen);
}

.list {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

.park {
  border-bottom: 1px solid rgba(46, 92, 66, 0.5);
}

.park-head {
  width: 100%;
  display: grid;
  grid-template-columns: 1.4rem 1fr auto;
  align-items: baseline;
  gap: 0.85rem;
  padding: 0.85rem 0.3rem;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.park-head:hover .park-name { color: var(--goldenrod); }

/* Filled disc = visited, hollow ring = not yet */
.pip {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  border: 1.5px solid var(--lichen);
  justify-self: center;
  align-self: center;
}
.park.visited .pip {
  background: var(--goldenrod);
  border-color: var(--goldenrod);
  box-shadow: 0 0 0 3px rgba(224, 163, 46, 0.18);
}

.park-name {
  font-family: Bitter, Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
}

.park-sub {
  display: block;
  font-size: 0.85rem;
  color: var(--lichen);
}

.states {
  font-size: 0.78rem;
  color: var(--lichen);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* --- Expanded detail --------------------------------------------------- */

.detail {
  padding: 0.2rem 0.3rem 1.4rem 3.15rem;
}
.detail[hidden] { display: none; }

.visit {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  padding: 0.6rem 0;
  border-top: 1px solid rgba(46, 92, 66, 0.35);
}
.visit:first-child { border-top: 0; }

.visit-when {
  font-family: Bitter, Georgia, serif;
  font-size: 0.9rem;
  min-width: 11rem;
}
.visit-notes {
  flex: 1;
  font-size: 0.92rem;
  color: var(--lichen);
  white-space: pre-wrap;
  max-width: 46rem;
}

.rating { display: inline-flex; gap: 2px; vertical-align: middle; margin-left: 0.5rem; }
.rating i {
  width: 0.42rem;
  height: 0.85rem;
  border-radius: 1px;
  background: rgba(237, 232, 218, 0.16);
  display: block;
}
.rating i.on { background: var(--goldenrod); }

.empty {
  color: var(--lichen);
  font-size: 0.92rem;
  padding: 0.4rem 0 0.6rem;
}

/* --- Visit form -------------------------------------------------------- */

.visit-form {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(46, 92, 66, 0.35);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
}

.field { display: flex; flex-direction: column; gap: 0.22rem; }
.field span { font-size: 0.78rem; color: var(--lichen); }

.visit-form input,
.visit-form select,
.visit-form textarea {
  font: inherit;
  font-size: 0.9rem;
  background: var(--moss);
  border: 1px solid var(--fern);
  border-radius: var(--radius);
  color: var(--bone);
  padding: 0.3rem 0.55rem;
}
.visit-form textarea { min-width: 18rem; min-height: 2.4rem; resize: vertical; flex: 1; }

.btn {
  font: inherit;
  font-size: 0.9rem;
  background: var(--goldenrod);
  border: 1px solid var(--goldenrod);
  border-radius: var(--radius);
  color: #24180a;
  font-weight: 700;
  padding: 0.34rem 1rem;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }

.btn-quiet {
  background: transparent;
  border-color: var(--fern);
  color: var(--lichen);
  font-weight: 400;
}
.btn-quiet:hover { color: var(--bone); filter: none; }

.visit-actions { display: flex; gap: 0.4rem; }
.link-btn {
  font: inherit;
  font-size: 0.82rem;
  background: none;
  border: 0;
  color: var(--lichen);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--goldenrod); }

/* --- Toast ------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--moss);
  border: 1px solid var(--fern);
  border-left: 3px solid var(--goldenrod);
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  z-index: 1000;
}
.toast.bad { border-left-color: #d9603f; }
.toast[hidden] { display: none; }

/* --- Login ------------------------------------------------------------- */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.gate form {
  width: min(22rem, 100%);
  background: var(--moss);
  border: 1px solid var(--fern);
  border-radius: var(--radius);
  padding: 1.6rem;
}
.gate h1 { font-size: 1.3rem; margin-bottom: 0.3rem; }
.gate p { color: var(--lichen); font-size: 0.9rem; margin: 0 0 1.1rem; }
.gate input {
  font: inherit;
  width: 100%;
  background: var(--spruce);
  border: 1px solid var(--fern);
  border-radius: var(--radius);
  color: var(--bone);
  padding: 0.45rem 0.7rem;
  margin-bottom: 0.8rem;
}
.gate .btn { width: 100%; }
.gate .err { color: #f0a08a; font-size: 0.88rem; margin: 0 0 0.8rem; }

/* --- Small screens ----------------------------------------------------- */

@media (max-width: 34rem) {
  body { font-size: 16px; }
  /* Full-bleed: the side gutters cost ~40px of width, which is the difference
     between fitting the mainland at zoom 3 and dropping to the whole globe. */
  .map-wrap { padding: 0; }
  #map {
    height: 17rem;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .detail { padding-left: 0.3rem; }
  .park-head { grid-template-columns: 1.1rem 1fr; }
  .states { grid-column: 2; }
  .visit { flex-direction: column; gap: 0.25rem; }
  .visit-when { min-width: 0; }
  .visit-form textarea { min-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
