/* ============================================================
   DINKLE — stylesheet
   ============================================================ */

:root {
  --primary: #2d6a4f;
  --primary-dark: #1b4332;
  --primary-light: #52b788;
  --primary-pale: #d8f3dc;
  --accent: #f4a261;
  --accent-dark: #e76f51;
  --bg: #f0fdf4;
  --card-bg: #ffffff;
  --text: #1a3a2a;
  --text-muted: #5a7a68;
  --border: #d1fae5;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.12);
  --radius: 12px;
  --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

#app { display: flex; flex-direction: column; height: 100%; }

/* ── Header ─────────────────────────────────────────────── */
#header {
  background: var(--primary-dark);
  color: white;
  padding: 0;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  position: sticky;
  top: 0;
  z-index: 200;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}

.header-top h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.header-top h1 span { opacity: .75; font-size: 14px; font-weight: 400; margin-left: 6px; }

.header-actions { display: flex; gap: 8px; }

.btn-discover {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background .15s, transform .1s;
}
.btn-discover:hover { background: var(--accent-dark); }
.btn-discover:active { transform: scale(.96); }

.btn-icon {
  background: rgba(255,255,255,.15);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s;
}
.btn-icon:hover { background: rgba(255,255,255,.25); }

/* ── View tabs ───────────────────────────────────────────── */
.view-tabs {
  display: flex;
  border-top: 1px solid rgba(255,255,255,.1);
}
.view-tab {
  flex: 1;
  background: none;
  border: none;
  color: rgba(255,255,255,.65);
  padding: 9px 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  letter-spacing: .3px;
}
.view-tab.active {
  color: white;
  border-bottom-color: var(--accent);
}

/* ── Filter bar ──────────────────────────────────────────── */
#filter-bar {
  background: var(--primary);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.filter-row-1 {
  display: flex;
  gap: 8px;
}

#search-input {
  flex: 1;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  padding: 7px 12px;
  color: white;
  font-size: 14px;
  outline: none;
}
#search-input::placeholder { color: rgba(255,255,255,.55); }
#search-input:focus { border-color: rgba(255,255,255,.5); background: rgba(255,255,255,.2); }

.filter-select {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  padding: 7px 10px;
  color: white;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
}
.filter-select option { background: var(--primary-dark); color: white; }
.filter-select:focus { border-color: rgba(255,255,255,.5); }

.filter-row-2 {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.filter-chip.active {
  background: var(--primary-pale);
  color: var(--primary-dark);
  border-color: var(--primary-pale);
  font-weight: 600;
}

.results-count {
  color: rgba(255,255,255,.6);
  font-size: 12px;
  padding: 0 2px;
  align-self: center;
}

/* ── Views ───────────────────────────────────────────────── */
.view { display: none; flex: 1; overflow: hidden; }
.view.active { display: flex; flex-direction: column; }

/* ── List view ───────────────────────────────────────────── */
#list-view {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#park-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.park-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  border: 2px solid transparent;
  position: relative;
}
.park-card:hover { box-shadow: var(--shadow-md); }
.park-card:active { transform: scale(.99); }
.park-card.visited { border-color: var(--primary-pale); }
.park-card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244,162,97,.25), var(--shadow-md);
  animation: highlight-pulse 1.5s ease-out;
}

@keyframes highlight-pulse {
  0% { box-shadow: 0 0 0 6px rgba(244,162,97,.5), var(--shadow-md); }
  100% { box-shadow: 0 0 0 3px rgba(244,162,97,.25), var(--shadow-md); }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.3;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.distance-badge {
  background: var(--primary-pale);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.visited-badge {
  background: #dcfce7;
  color: #166534;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.card-neighborhood {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.type-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.card-icons {
  display: flex;
  gap: 6px;
  font-size: 14px;
  margin-bottom: 8px;
}

.card-features {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.approx-note {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

/* ── Map view ────────────────────────────────────────────── */
#map-view { position: relative; overflow: visible; }

#map {
  width: 100%;
  flex: 1;
  min-height: 0;
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-md) !important;
}
.popup-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--primary-dark);
  margin-bottom: 3px;
}
.popup-neighborhood {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.popup-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.popup-approx { font-size: 11px; color: #9ca3af; margin-bottom: 6px; }
.popup-btn {
  display: block;
  background: var(--primary);
  color: white;
  text-align: center;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  width: 100%;
}

/* ── Detail overlay ──────────────────────────────────────── */
#detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 500;
  display: none;
  align-items: flex-end;
}
#detail-overlay.open { display: flex; }

@media (min-width: 640px) {
  #detail-overlay { align-items: center; justify-content: center; }
}

#detail-panel {
  background: var(--card-bg);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slide-up .25s ease-out;
}

@media (min-width: 640px) {
  #detail-panel {
    border-radius: var(--radius);
    max-width: 580px;
    max-height: 85vh;
  }
}

@keyframes slide-up {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 10;
}

.detail-title { font-size: 18px; font-weight: 700; color: var(--primary-dark); line-height: 1.3; }
.detail-neighborhood { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.btn-close {
  background: var(--bg);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.btn-close:hover { background: var(--border); }

.detail-body { padding: 16px 18px 28px; }

.detail-section { margin-bottom: 18px; }
.detail-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-item { }
.detail-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.detail-value { font-size: 13px; color: var(--text); font-weight: 500; }

.detail-full { grid-column: 1 / -1; }

.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.btn-visit {
  flex: 1;
  min-width: 140px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-visit:hover { background: var(--primary-dark); }
.btn-visit.visited { background: #16a34a; }
.btn-visit.unvisit { background: #6b7280; }

.btn-directions {
  flex: 1;
  min-width: 140px;
  background: #dbeafe;
  color: #1e40af;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: block;
  transition: background .15s;
}
.btn-directions:hover { background: #bfdbfe; }

.visit-date-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.visit-date-row input[type=date] {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.visit-date-row input:focus { border-color: var(--primary-light); }

.notes-area {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
.notes-area:focus { border-color: var(--primary-light); }

.btn-save-notes {
  margin-top: 8px;
  background: var(--primary-pale);
  color: var(--primary-dark);
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-save-notes:hover { background: #b7e4c7; }
.notes-saved { font-size: 12px; color: var(--primary); margin-left: 8px; opacity: 0; transition: opacity .3s; }
.notes-saved.show { opacity: 1; }

.approx-banner {
  background: #f3f4f6;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

/* ── Toast ───────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--primary-dark);
  color: white;
  padding: 11px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  z-index: 1000;
  transition: transform .3s ease, opacity .3s ease;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  text-overflow: ellipsis;
  overflow: hidden;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ── Print view ──────────────────────────────────────────── */
#print-view {
  display: none;
  padding: 24px;
}

.print-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 16px;
}
.print-header h1 { font-size: 22px; color: var(--primary-dark); }
.print-header p { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.print-close {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}

.print-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}
.btn-print-now {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.print-sort-label { font-size: 13px; color: var(--text-muted); }
.print-sort-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}

.print-list { display: flex; flex-direction: column; gap: 0; }

.print-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid #e5e7eb;
}
.print-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid #374151;
  border-radius: 3px;
  margin-top: 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.print-checkbox.checked { background: #16a34a; border-color: #16a34a; color: white; }
.print-park-name { font-size: 14px; font-weight: 700; color: var(--primary-dark); }
.print-park-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.print-park-features { font-size: 11px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }
.print-dist { font-size: 12px; color: var(--text-muted); white-space: nowrap; margin-top: 2px; }

/* ── Utilities ───────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── @media print ────────────────────────────────────────── */
@media print {
  #app > *:not(#print-view) { display: none !important; }
  #print-view { display: block !important; }
  .print-controls { display: none !important; }
  .print-close { display: none !important; }
  body { background: white; }
  @page { margin: 1.5cm; }
}
