/* North Country Trail — full trail viewer, shell (step 1, Nov 2026).
   Adapted from the Itasca Moraine chapter viewer's style.css (v4):
   same paper panel left / map fills the rest, same design tokens.
   Minnesota-only and chapter-specific rules are left out. Plain CSS,
   no build step. app.js carries matching constants (COLORS) at its
   head — keep the two in step. */

:root {
  --paper: #f7f5ee;        /* panel background */
  --paper-line: #c9c2ab;   /* panel borders */
  --paper-hover: #f1eee1;  /* quiet hover / notice background */
  --ink: #1c2a1e;          /* body text */
  --ink-soft: #5a665c;     /* keys, captions */
  --trail: #1a9850;        /* natural tread green */
  --trail-deep: #14532d;   /* emphasis */
  --urban: #e08214;        /* urban sidewalk amber */
  --road: #d7301f;         /* road red */
  --highlight: #b2182b;    /* selected chapter */
  --header-tint: #eef3e6;  /* record-sheet header band */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  color: var(--ink);
}

/* Unify the basemaps into the panel's warm register. Overlays live
   in other panes, unaffected. */
.leaflet-tile-pane { filter: saturate(0.82) sepia(0.06) brightness(1.01); }

/* Leaflet chrome recoloured to the paper system. */
.leaflet-bar a,
.leaflet-control-layers {
  background: var(--paper);
  border-color: var(--paper-line);
}
.leaflet-bar { border-radius: 8px; overflow: hidden; }
.leaflet-control-scale-line {
  background: rgba(247, 245, 238, 0.88);
  border-color: var(--paper-line);
  font-size: 10px;
}

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

/* ------------------------------------------------------------ panel */

#panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 319px;
  height: 100%;
  overflow-y: auto;
  background: var(--paper);
  border-right: 1px solid var(--paper-line);
  padding: 14px 16px 20px;
  box-sizing: border-box;
  z-index: 1000;
}
#panel h2 {
  font-size: 0.95rem;
  margin: 16px 0 6px;
  border-bottom: 1px solid #d8d2bd;
  padding-bottom: 3px;
}

/* Masthead (ITM pattern, Nov 24, 2026 reshape): the association
   logo carries the association, the wordmark carries the trail —
   one row on plain paper, closed by a hairline. */
.masthead {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--paper-line);
}
.masthead-logo {
  height: 44px;
  width: auto;
  max-width: 128px;
  object-fit: contain;
  object-position: left center;
}
.masthead-words { min-width: 0; }
#panel h1 {
  font-size: 17px;
  font-weight: 700;
  color: var(--trail-deep);
  letter-spacing: 0.01em;
  line-height: 1.15;
  margin: 0;
  /* ITM's two-line wrap: the 319px column leaves ~191px for the
     words, and "North Country Trail" at 17px would fit on one
     line — cap the title so it breaks after "Country", exactly
     as "Itasca Moraine Chapter" breaks after "Moraine". */
  max-width: 130px;
}
.masthead-desc {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  margin: 3px 0 0;
}

/* Present button (ITM pattern): a small icon at the panel edge,
   riding at the right end of the masthead row. */
.present-btn {
  margin-left: auto;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  color: var(--ink);
  background: #fff;
  border: 1px solid #b9cba5;
  border-radius: 6px;
  cursor: pointer;
}
.present-btn:hover { background: var(--paper-hover); }

/* Map-corner actions (ITM idiom): small icon-only squares floating
   top-right over the map, in the Present button's style — copy
   link, print, whole trail. */
#map-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  gap: 6px;
}
#map-actions button {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: #fff;
  border: 1px solid #b9cba5;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
#map-actions button:hover { background: var(--paper-hover); }
#map-actions button.copied { background: var(--header-tint); }

/* --------------------------------------------------------- chapters */

/* Chapter dropdown, alone (Nov 24, 2026 — ITM panel rebuild): the
   chapter listbox is gone; the select is the only chapter picker,
   no heading, no label, no hint. Same field pattern as the Wayback
   year aerial selector. */
#chapter-select {
  width: 100%;
  margin: 2px 0 10px;
  padding: 6px 8px;
  font-size: 0.92rem;
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

/* --------------------------------------------------------- gazetteer */

#gazetteer { position: relative; }
#gaz-search {
  width: 100%;
  padding: 6px 9px;
  font-size: 0.9rem;
  border: 1px solid #a89a5b;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
}
#gaz-search:focus {
  outline: 2px solid var(--trail);
  outline-offset: 1px;
}
#gaz-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1200;
  background: #fff;
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  max-height: 260px;
  overflow-y: auto;
}
#gaz-results:empty { display: none; }
.gaz-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  background: none;
  border: none;
  border-bottom: 1px solid #ece9db;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink);
}
.gaz-result:last-child { border-bottom: none; }
.gaz-result:hover { background: var(--paper-hover); }
div.gaz-result { cursor: default; color: var(--ink-soft); }
.gaz-name { display: block; }
.gaz-meta {
  display: block;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.gaz-more {
  padding: 5px 10px;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--ink-soft);
}

/* --------------------------------------------------------- inspector */

#inspector {
  margin-top: 14px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--paper-line);
  border-radius: 6px;
}
#inspector:empty { display: none; }
#inspector h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  color: var(--trail-deep);
}
#inspector p { margin: 4px 0; font-size: 0.92rem; }
.inspector-empty {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: 0;
}
.pop-note {
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.clear-chapter {
  padding: 5px 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--trail-deep);
  background: var(--header-tint);
  border: 1px solid var(--paper-line);
  border-radius: 5px;
  cursor: pointer;
}

/* ----------------------------------------------------- layer toggles */

/* Group headings (ITM pattern): small-caps disclosure rows —
   clicking a heading collapses its group. Groups start
   COLLAPSED (Nov 24, 2026 panel rebuild) — ITM shows only the
   grey group rows, nothing inside, until one is opened. */
.tog-group {
  display: flex;
  align-items: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 10px 0 2px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.tog-group:first-child { margin-top: 2px; }
.tog-group:hover { background: var(--paper-hover); }
.tog-group-body.collapsed { display: none; }

.tog-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.92rem;
}
.tog-row:hover { background: var(--paper-hover); }
.tog-row input { accent-color: var(--trail); margin: 0; }
.tog-stub { color: var(--ink-soft); cursor: default; }
.tog-stub:hover { background: none; }
.tog-coming {
  margin-left: auto;
  font-size: 0.75rem;
  font-style: italic;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ---------------------------------------------------------- basemaps */

#background-choices { display: flex; flex-direction: column; gap: 2px; }
.bg-choice {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--ink);
}
.bg-choice:hover { background: var(--paper-hover); }
.bg-choice.on {
  background: var(--header-tint);
  font-weight: 650;
  box-shadow: inset 0 0 0 1px #b9cba5;
}
.bg-choice.sub-choice { padding-left: 24px; }
.bg-choice:disabled {
  color: var(--ink-soft);
  cursor: default;
  font-style: italic;
}
.bg-choice:disabled:hover { background: none; }
.wayback-field {
  display: block;
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.wayback-field select {
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  font-size: 0.92rem;
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

/* Error-only status line (Nov 24, 2026 panel rebuild): no status
   line lives in the panel — app.js creates this element only when
   a load actually fails. */
.status {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 16px 0 0;
}
.status.error { color: var(--road); font-weight: 600; }

/* Panel footer (ITM R7): a wrapping flex row of green links, no
   separators — with three links it falls 2 + 1, the ITM 2×2
   shape. */
.panel-foot {
  margin-top: 8px;
  padding-top: 8px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.panel-foot a { color: var(--trail-deep); }

/* -------------------------------------------------------------- map */

/* Present mode (Nov 24, 2026 — ITM-look reshape): the panel
   hides and the map fills the screen; ‹ Show panel brings it
   back. */
body.presenting #panel { display: none; }
body.presenting #map { left: 0; }
#show-panel-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
  padding: 6px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
#show-panel-btn[hidden] { display: none; }

#map {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 319px;
  background: #ddd;
  z-index: 0;
}
body.base-white #map { background: #fff; }

/* Legend corner card (ITM pattern): bottom-left over the map,
   just above the scale control (bottom: 42px clears it); the
   card starts closed behind one button. */
#corner-ui {
  position: absolute;
  left: 10px;
  bottom: 42px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
#corner-buttons button {
  padding: 6px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.corner-card {
  width: 260px;
  max-width: 78vw;
  padding: 10px 14px 12px;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 8px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
}
/* Date chip (standing rule, Nov 28, 2026): time-stamped data shows
   its date in the corner, by source. Bottom-right, above the
   attribution line; one line per active dated layer. */
#data-dates {
  position: absolute;
  right: 10px;
  bottom: 30px;
  z-index: 1000;
  font-size: 0.8rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  padding: 3px 8px;
  max-width: 70vw;
}
#data-dates .data-date-line {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.corner-card h2 {
  font-size: 0.95rem;
  margin: 0 0 6px;
  color: var(--trail-deep);
}
.leg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  margin: 5px 0;
}
.leg-line {
  flex: 0 0 28px;
  border-top: 3px solid;
  border-top-style: solid;
}
.leg-dot {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0 9px;
}
.leg-fill {
  flex: 0 0 28px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  opacity: 0.7;
}
.leg-note {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 8px 0 0;
}

/* Map popups wear the panel's paper. */
.leaflet-popup-content-wrapper {
  background: var(--paper);
  border-radius: 8px;
}
.leaflet-popup-content { font-size: 0.92rem; line-height: 1.45; }
.leaflet-popup-content h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  color: var(--trail-deep);
}
.leaflet-popup-content p { margin: 4px 0; }

/* -------------------------------------------------------- narrow view */

@media (max-width: 720px) {
  #panel {
    position: static;
    width: 100%;
    height: auto;
    max-height: 46vh;
    border-right: none;
    border-bottom: 1px solid var(--paper-line);
  }
  #map {
    position: static;
    left: 0;
    height: 54vh;
  }
  /* Masthead compresses, never stacks (ITM pattern). */
  .masthead { padding-bottom: 6px; margin-bottom: 6px; gap: 10px; }
  .masthead-logo { height: 32px; max-width: 96px; }
  #panel h1 { font-size: 15px; white-space: nowrap; max-width: none; }
  .masthead-desc { font-size: 10px; }
}
