/* National Park Checklist — design language mirrors pudmap */

:root {
  --accent: #2d6a4f;
  --us: #2d6a4f;
  --ca: #c1121f;
  --ca-dark: #8b1a1a;
  --accent-strong: #1b4332;
  --accent-mid: #40916c;
  --accent-soft: #d8f3dc;
  --gold: #f59e0b;
  --gold-dark: #92400e;
  --gold-soft: #fffbeb;
  --blue: #2563eb;
  --ink: #1a1a1a;
  --ink-soft: #5a5a5a;
  --line: #e0e0e0;
  --surface: #ffffff;
  --rust: #9a3412;
  --serif: 'Georgia', 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
}

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

#map { position: absolute; inset: 0; background: #eef2ec; }

/* ---------- panels ---------- */

.panel {
  position: absolute;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  padding: 14px 16px;
  z-index: 1000;
}

#head { top: 12px; left: 12px; max-width: 330px; }

#head h1 {
  margin: 0;
  font: 700 20px/1.25 var(--serif);
  color: var(--accent-strong);
}

#head .sub { margin: 4px 0 0; font-size: 12px; color: var(--ink-soft); }

#controls {
  top: 12px;
  right: 12px;
  width: 236px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

.field { margin-bottom: 11px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

input[type="search"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 500 12px/1.3 var(--sans);
  color: var(--ink);
  background: var(--surface);
}

input[type="search"]:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--accent-mid);
  outline-offset: 1px;
}

.seg { display: flex; gap: 4px; }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 1 45%; }

.seg button {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font: 500 12px/1 var(--sans);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.seg button:hover { background: var(--accent-soft); border-color: var(--accent-mid); }
.seg button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font: 600 12px/1 var(--sans);
  color: var(--accent);
  cursor: pointer;
}
.btn:hover { background: var(--accent-soft); border-color: var(--accent-mid); }

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  font: 500 11.5px/1 var(--sans);
  color: var(--ink-soft);
  text-decoration: underline;
  cursor: pointer;
}
.link-btn:hover { color: var(--rust); }

.actions-row { display: flex; justify-content: space-between; gap: 8px; }

/* the sheet handle only exists on the phone layout */
.sheet-handle {
  display: none;
  width: 100%;
  padding: 2px 0 9px;
  border: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
  background: none;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.sheet-handle .grab {
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #cfd8d3;
}
.sheet-handle .sheet-label {
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.3px;
  color: var(--ink-soft);
}
.sheet-handle[aria-expanded="true"] .grab { background: var(--accent-mid); }

/* ---------- region chips ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 4px; }

.chip {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font: 500 10.5px/1.4 var(--sans);
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover { background: var(--accent-soft); border-color: var(--accent-mid); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip.ca { border-color: #f3c1c4; color: var(--ca-dark); }
.chip.ca:hover { background: #ffe5e5; border-color: var(--ca); }
.chip.ca[aria-pressed="true"] {
  background: var(--ca);
  border-color: var(--ca);
  color: #fff;
}

/* ---------- progress ---------- */

.prog-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.prog-label {
  width: 18px;
  font: 700 9.5px/1 var(--sans);
  letter-spacing: 0.4px;
  color: var(--ink-soft);
}
.prog-label.ca { color: var(--ca); }

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar > div {
  height: 100%;
  width: 0;
  border-radius: 3px;
  transition: width 0.3s;
}

#progress-fill-us { background: var(--us); }
#progress-fill-ca { background: var(--ca); }

.prog-count {
  min-width: 44px;
  text-align: right;
  font: 500 10px/1 var(--sans);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

#progress-text { margin-top: 2px; }

/* ---------- detail card ---------- */

#detail {
  bottom: 30px;
  left: 12px;
  max-width: 380px;
  max-height: 64vh;
  overflow-y: auto;
  display: none;
  z-index: 1100;
}

#detail.open { display: block; }

#detail h3 {
  margin: 0;
  padding-right: 30px;
  font: 700 18px/1.25 var(--serif);
  color: var(--accent-strong);
}

#detail .state { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }

.detail-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--line);
  font-size: 18px;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-close:hover { background: #d0d0d0; }

.visited-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.visited-badge.visited { background: var(--gold); color: #fff; }
.visited-badge.visited.ca { background: var(--ca); }

.country-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 10px;
  font: 700 9px/1.6 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.country-tag.us { background: #d8f3dc; color: #1b4332; }
.country-tag.ca { background: #ffe5e5; color: #8b1a1a; }
.visited-badge.unvisited { background: #eceff1; color: var(--ink-soft); }

.notice {
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  line-height: 1.4;
}
.notice b {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1px;
}
.notice.permit { background: #fef3c7; color: #78350f; }
.notice.access { background: #e0f2fe; color: #075985; }

#detail .section { margin-top: 12px; }

#detail .section h4 {
  margin: 0 0 6px;
  font: 700 10px/1.25 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-soft);
}

#detail .nearby { display: flex; flex-direction: column; gap: 4px; }

#detail .nearby-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: #f8f9fa;
  border-radius: 4px;
  font-size: 12px;
}

#detail .nearby-item .name { font-weight: 500; }
#detail .nearby-item .dist {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 11px;
}
#detail .nearby-item .iata { font-weight: 700; color: var(--accent); margin-right: 4px; }
#detail .nearby-empty { font-size: 12px; color: var(--ink-soft); font-style: italic; }

#detail .actions { display: flex; gap: 8px; margin-top: 14px; }

#detail .toggle-btn {
  flex: 1;
  padding: 9px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--surface);
  font: 600 13px/1 var(--sans);
  color: var(--accent);
  cursor: pointer;
}
#detail .toggle-btn:hover { background: var(--accent-soft); }
#detail .toggle-btn.visited {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}

#detail .toggle-btn.visited.ca {
  background: var(--ca);
  border-color: var(--ca);
}

#detail .wish-btn {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font: 600 12px/1 var(--sans);
  color: var(--ink-soft);
  cursor: pointer;
}
#detail .wish-btn:hover { border-color: #6d28d9; color: #6d28d9; }
#detail .wish-btn.on { background: #a78bfa; border-color: #6d28d9; color: #fff; }

.park-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--accent);
  text-decoration: none;
}
.park-link:hover { text-decoration: underline; }

/* ---------- legend ---------- */

#legend {
  bottom: 30px;
  right: 12px;
  z-index: 1000;
  width: 168px;
  padding: 10px 12px;
  font-size: 11.5px;
}

#legend > summary {
  cursor: pointer;
  font: 700 11px/1.2 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-soft);
  list-style: none;
}
#legend > summary::-webkit-details-marker { display: none; }
#legend[open] > summary { margin-bottom: 8px; }

.legend-row { display: flex; align-items: center; gap: 7px; margin-top: 5px; }

.sw {
  width: 14px; height: 10px;
  border-radius: 2px;
  display: inline-block;
  border: 1px solid transparent;
}
.sw.us-open { background: #74c69d; border-color: #52b788; }
.sw.ca-open { background: #8ecae6; border-color: #219ebc; }
.sw.us-visited { background: var(--gold); border-color: var(--gold-dark); }
.sw.wish { background: #a78bfa; border-color: #6d28d9; }
.sw.ca-visited { background: var(--ca); border-color: var(--ca-dark); }
.sw.dim { background: rgba(116,198,157,0.18); border-color: #d7e3dc; }
.legend-row .sw + .sw { margin-left: 3px; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.city { background: #6b7280; }
.dot.air.major { background: #1d4ed8; }
.dot.air.regional { background: #3b82f6; }
.dot.air.limited { background: #93c5fd; }

.legend-note {
  margin: 9px 0 0;
  font-size: 10px;
  line-height: 1.35;
  color: var(--ink-soft);
}

/* ---------- list view ---------- */

#list {
  position: absolute;
  inset: 0;
  background: var(--surface);
  z-index: 1200;
  overflow-y: auto;
  padding: 0 20px 20px;
}

.list-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1060px;
  margin: 0 auto;
  padding: 12px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

#list-search {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 500 12.5px/1.3 var(--sans);
  background: var(--surface);
  color: var(--ink);
}

.sort {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-soft);
}
.sort select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font: 500 12px/1 var(--sans);
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
}

#list header {
  max-width: 1060px;
  margin: 16px auto 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

#list h2 {
  margin: 0 0 3px;
  font: 700 24px/1.25 var(--serif);
  color: var(--accent-strong);
}

#list header p { margin: 0; font-size: 12.5px; color: var(--ink-soft); }

#list table {
  max-width: 1060px;
  margin: 0 auto;
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#list th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-soft);
  white-space: nowrap;
}

#list td {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

#list tbody tr { cursor: pointer; transition: background 0.12s; }
#list tbody tr:hover { background: var(--accent-soft); }
#list tbody tr.visited { background: var(--gold-soft); }
#list tbody tr.visited:hover { background: #fef3c7; }

#list .park-name { font-weight: 600; }
/* give the name room to sit on one line where the table has space */
@media (min-width: 861px) {
  #list .park-name { min-width: 300px; }
}
#list .park-region {
  display: block;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--ink-soft);
  margin-top: 1px;
}
#list .flag {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #fef3c7;
  color: #78350f;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

#list .park-state { color: var(--ink-soft); font-size: 12px; white-space: nowrap; }

#list .c-check { width: 40px; }
#list .c-cities, #list .c-airports {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  white-space: normal;
}
#list .muted { color: #9aa0a6; }

#list .empty { padding: 32px; text-align: center; color: var(--ink-soft); }

/* country sections */
#list tr.group-row { cursor: default; }
#list tr.group-row:hover { background: transparent; }
#list tr.group-row th {
  position: sticky;
  top: var(--bar-h, 52px);
  z-index: 4;
  background: #f4f7f5;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  font: 700 11px/1.2 var(--sans);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent-strong);
}
#list tr.group-row.ca th { background: #fff4f4; color: var(--ca-dark); }
#list .group-count {
  margin-left: 8px;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.2px;
  text-transform: none;
  color: var(--ink-soft);
}

.check-btn {
  width: 26px;
  height: 26px;
  border: 2px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.check-btn:hover { border-color: var(--accent-mid); }
.check-btn[aria-pressed="true"] {
  background: var(--gold);
  border-color: var(--gold-dark);
  color: #fff;
}

#list .c-wish { width: 40px; text-align: center; }

.wish-add {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  font: 600 14px/1 var(--sans);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s;
}
.wish-add:hover { border-color: #6d28d9; color: #6d28d9; }
.wish-add.on { background: #a78bfa; border-color: #6d28d9; color: #fff; }

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

.leaflet-container { font: 13px/1.45 var(--sans); }

.park-label {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  font: 600 11px/1.2 var(--sans);
  color: var(--ink);
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.park-label:hover { background: var(--accent-soft); border-color: var(--accent-mid); }
.park-label.visited {
  background: var(--gold);
  border-color: var(--gold-dark);
  color: #fff;
  font-weight: 700;
}
.park-label.visited::before { content: "\2605 "; font-size: 10px; }

.park-label.wish {
  background: #ede9fe;
  border-color: #6d28d9;
  color: #4c1d95;
  font-weight: 700;
}
.park-label.wish::before { content: "\2606 "; font-size: 10px; }

.park-label.visited.ca {
  background: var(--ca);
  border-color: var(--ca-dark);
}

.leaflet-tooltip.gw-tip,
.leaflet-popup.gw-pop .leaflet-popup-content-wrapper {
  background: #111827;
  color: #fff;
  border: 0;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

.leaflet-tooltip.gw-tip {
  padding: 5px 9px;
  font: 500 11.5px/1.35 var(--sans);
}

.leaflet-tooltip.gw-tip::before { border-top-color: #111827; }

.leaflet-popup.gw-pop .leaflet-popup-content {
  margin: 8px 10px;
  font: 500 11.5px/1.4 var(--sans);
}

.leaflet-popup.gw-pop .leaflet-popup-tip { background: #111827; }

.gw-tip b,
.gw-pop b { font-weight: 700; }

.gw-tip .gw-sub,
.gw-pop .gw-sub {
  color: #d1d5db;
  font-size: 10.5px;
}

/* airport service tier tags */
.svc {
  display: inline-block;
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 999px;
  font: 700 9px/1.6 var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  vertical-align: 1px;
  white-space: nowrap;
}
.svc.major { background: #dbeafe; color: #1e3a8a; }
.svc.regional { background: #e0f2fe; color: #075985; }
.svc.limited { background: #fef3c7; color: #92400e; }

/* ---------- toast / error ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%) translateY(10px);
  background: #111827;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 3000;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#err {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 16px 20px;
  font-size: 14px;
  color: #991b1b;
  z-index: 2000;
  max-width: 400px;
  text-align: center;
}
#err.show { display: block; }

/* ---------- footer ---------- */

footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 7px 12px;
  background: rgba(255,255,255,0.92);
  font-size: 10px;
  color: var(--ink-soft);
  text-align: center;
  z-index: 900;
  pointer-events: none;
}

/* ---------- phone layout ---------- */

@media (max-width: 860px) {
  #head { max-width: 230px; padding: 10px 12px; }
  #head h1 { font-size: 15px; }
  #head .sub { font-size: 11px; }

  #controls {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 46vh;
    overflow-y: auto;
  }

  /* the detail card takes the sheet over, so the two never stack */
  body.detail-open #controls { display: none; }

  #controls {
    display: flex;
    flex-direction: column;
    padding: 10px 14px 12px;
  }
  #controls .field { margin-bottom: 9px; }
  /* the US/CA labels already say what the bars are */
  #controls .progress-field > label { display: none; }
  .sheet-handle { display: flex; }

  /* everything past search + view lives behind the handle on a phone */
  #sheet-more { display: none; }
  body.sheet-expanded #sheet-more { display: block; }

  #detail {
    bottom: 12px;
    left: 12px;
    right: 12px;
    max-width: none;
    max-height: 66vh;
  }

  #legend { display: none; }

  #list .c-cities, #list .c-airports {
    white-space: normal;
    max-width: 110px;
  }

  footer { display: none; }
}

/* ---------- print: a paper checklist ---------- */

@media print {
  #map, #head, #controls, #detail, #legend, #toast, footer,
  .list-bar, #err { display: none !important; }

  html, body {
    height: auto;
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  #list {
    position: static;
    overflow: visible;
    padding: 0;
    display: block !important;
  }

  #list h2 { font-size: 18pt; color: #000; }
  #list header p { color: #444; }

  #list table { width: 100%; font-size: 9.5pt; }
  #list th, #list td { border: 1px solid #bbb; padding: 4px 6px; }

  #list .c-check { width: 28px; }
  #list .c-wish, #list tr td:last-child { display: none; }

  .check-btn {
    width: 13px; height: 13px;
    border: 1px solid #333;
    border-radius: 2px;
    background: #fff;
    color: transparent;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .check-btn[aria-pressed="true"] {
    background: #f59e0b;
    border-color: #92400e;
    color: #fff;
  }

  #list tbody tr.visited { background: #fdf3d7; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #list .park-region, #list .flag { color: #444; }
}

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