/* Footprint map — full viewport with thin header */
:root {
  --fp-header-h: 44px;
  /* keep brand green for chrome/header (matches the blog) */
  --fp-accent: #568203;
  --fp-accent-dark: #3a5602;
  /* heatmap accent (red) for stat values & city dots — contrasts with OSM greens */
  --fp-heat: #de2d26;
  --fp-heat-dark: #a50f15;
}

body.footprints-body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", sans-serif;
  overflow: hidden;
}

.footprints-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--fp-header-h);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0,0,0,0.08);
  z-index: 1000;
}

.dark .footprints-header,
[data-default-appearance="dark"] .footprints-header {
  background: rgba(40,40,40,0.92);
  border-bottom-color: rgba(255,255,255,0.08);
}

.footprints-home {
  color: var(--fp-accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}
.footprints-home:hover { opacity: 0.7; }

.footprints-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.08em;
}

.footprints-main {
  position: fixed;
  top: var(--fp-header-h);
  left: 0; right: 0; bottom: 0;
}

#footprint-app { width: 100%; height: 100%; position: relative; }
#footprint-map { width: 100%; height: 100%; }

/* Side panel */
#footprint-panel {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 320px;
  max-height: calc(100% - 2rem);
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 800;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.dark #footprint-panel,
[data-default-appearance="dark"] #footprint-panel {
  background: rgba(40,40,40,0.97);
  color: #ddd;
}
#footprint-panel.closed { transform: translateX(calc(100% + 1rem)); opacity: 0; pointer-events: none; }

#footprint-panel-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}

#footprint-close {
  position: absolute;
  top: 0.25rem; right: 0.5rem;
  background: none; border: none;
  font-size: 1.5rem; line-height: 1;
  color: #888;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  z-index: 1;
}
#footprint-close:hover { color: #222; }

#footprint-panel .hint {
  color: #666;
  font-size: 0.8rem;
  line-height: 1.6;
}

#footprint-panel h2 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem 0;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fp-heat-dark);
}
.dark #footprint-panel h2 { color: #f5a09a; }

#footprint-panel .stats {
  display: flex;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
  padding: 0.5rem;
  background: rgba(0,0,0,0.03);
  border-radius: 4px;
}
.dark #footprint-panel .stats { background: rgba(255,255,255,0.05); }

#footprint-panel .stat {
  flex: 1;
  text-align: center;
}
#footprint-panel .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--fp-heat-dark);
  line-height: 1;
}
.dark #footprint-panel .stat-value { color: #f5a09a; }
#footprint-panel .stat-label {
  font-size: 0.7rem;
  color: #888;
  margin-top: 0.2rem;
  letter-spacing: 0.04em;
}

#footprint-panel .trips-list {
  margin-top: 0.75rem;
  list-style: none;
  padding: 0;
}
#footprint-panel .trip-item {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}
.dark #footprint-panel .trip-item { border-bottom-color: rgba(255,255,255,0.08); }
#footprint-panel .trip-date { color: #444; font-variant-numeric: tabular-nums; }
.dark #footprint-panel .trip-date { color: #ccc; }
#footprint-panel .trip-days { color: #888; }
#footprint-panel .trip-sources {
  font-size: 0.65rem;
  color: #999;
}

#footprint-panel .trips-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: #888;
  letter-spacing: 0.06em;
  margin: 1rem 0 0.4rem;
  text-transform: uppercase;
}

/* Legend */
#footprint-legend {
  position: absolute;
  bottom: 1rem; left: 1rem;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(6px);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  font-size: 0.7rem;
  z-index: 700;
  min-width: 160px;
}
.dark #footprint-legend,
[data-default-appearance="dark"] #footprint-legend {
  background: rgba(40,40,40,0.95);
  color: #ccc;
}
.legend-title { margin-bottom: 0.3rem; color: #555; }
.dark .legend-title { color: #aaa; }
.legend-bar {
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(to right,
    #fee5d9 0%, #fcae91 25%, #fb6a4a 50%, #de2d26 75%, #a50f15 100%);
}
.legend-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.2rem;
  color: #888;
}

/* City dots */
.city-dot {
  background: var(--fp-heat);
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* Auth button (top-right of map) — distinctive red accent so it's visible */
#footprint-auth {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 850;
  width: 40px; height: 40px;
  background: var(--fp-heat);
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  font-size: 1.15rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  transition: transform 0.15s;
}
#footprint-auth:hover { background: var(--fp-heat-dark); transform: scale(1.05); }
.dark #footprint-auth {
  border-color: #444;
}
/* Move panel left so auth button doesn't overlap */
#footprint-panel { right: calc(1rem + 50px); }
@media (max-width: 640px) {
  #footprint-panel { right: 0; }
  #footprint-auth { top: 0.5rem; right: 0.5rem; }
}

/* Login modal */
#footprint-login-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
}
#footprint-login-modal.hidden { display: none; }
.login-card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem 1.75rem;
  width: 300px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.dark .login-card { background: #2a2a2a; color: #ddd; }
.login-card h3 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--fp-heat-dark);
}
.dark .login-card h3 { color: #f5a09a; }
#login-form input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
  box-sizing: border-box;
  background: white;
}
.dark #login-form input { background: #1a1a1a; color: #ddd; border-color: #555; }
.login-error {
  color: #c44;
  font-size: 0.8rem;
  margin-top: 0.4rem;
  min-height: 1.1em;
}
.login-actions {
  display: flex; gap: 0.5rem; margin-top: 1rem;
}
.login-actions button {
  flex: 1;
  padding: 0.45rem;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  background: var(--fp-heat);
  color: white;
  font-weight: 600;
}
.login-actions button.secondary {
  background: transparent;
  color: #888;
  border: 1px solid #ccc;
}
.dark .login-actions button.secondary { color: #aaa; border-color: #555; }

/* Region subhead and last-visit (panel) */
.region-sub {
  font-size: 0.7rem; color: #888;
  letter-spacing: 0.04em; margin-bottom: 0.5rem;
}
.last-visit {
  font-size: 0.75rem; color: #666; margin-bottom: 0.5rem;
}
.dark .last-visit { color: #aaa; }
.record-sources {
  font-size: 0.7rem; color: #888; margin-bottom: 0.4rem;
}

/* Admin mode UI */
#footprint-admin {
  position: absolute;
  top: calc(1rem + 50px); left: 1rem;
  width: 280px;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  padding: 0.75rem 1rem;
  z-index: 800;
  font-size: 0.78rem;
  border: 1px solid var(--fp-heat);
}
.dark #footprint-admin { background: rgba(40,40,40,0.97); color: #ddd; }
#footprint-admin .admin-title {
  font-weight: 700; color: var(--fp-heat-dark); margin-bottom: 0.4rem;
  display: flex; justify-content: space-between; align-items: center;
}
#footprint-admin .badge {
  background: var(--fp-heat); color: white; padding: 1px 6px;
  border-radius: 8px; font-size: 0.7rem; font-weight: 600;
}
#footprint-admin .admin-add summary {
  cursor: pointer; padding: 0.3rem 0; color: #555; user-select: none;
}
.dark #footprint-admin .admin-add summary { color: #aaa; }
#footprint-admin form label {
  display: block; margin: 0.4rem 0 0.1rem; font-size: 0.7rem; color: #666;
}
.dark #footprint-admin form label { color: #aaa; }
#footprint-admin form input {
  width: 100%; padding: 0.3rem 0.5rem; border: 1px solid #ccc;
  border-radius: 3px; font-size: 0.8rem; box-sizing: border-box;
  background: white;
}
.dark #footprint-admin form input { background: #2a2a2a; color: #ddd; border-color: #555; }
#footprint-admin form button[type="submit"] {
  margin-top: 0.5rem; width: 100%; padding: 0.4rem;
  background: var(--fp-heat); color: white; border: none;
  border-radius: 3px; font-weight: 600; cursor: pointer;
}
#footprint-admin .admin-actions {
  display: flex; gap: 0.4rem; margin-top: 0.6rem;
}
#footprint-admin .admin-actions button {
  flex: 1; padding: 0.35rem; border: 1px solid var(--fp-heat);
  background: var(--fp-heat); color: white;
  border-radius: 3px; font-size: 0.72rem; cursor: pointer;
}
#footprint-admin .admin-actions button.secondary {
  background: transparent; color: var(--fp-heat);
}
#footprint-admin .admin-hint {
  font-size: 0.65rem; color: #888; line-height: 1.5; margin-top: 0.5rem;
}

/* Delete buttons in record rows */
.trip-del, .trip-del-pending {
  background: none; border: 1px solid transparent;
  color: #c44; font-weight: 700; cursor: pointer;
  padding: 0 4px; margin-left: 4px; border-radius: 3px;
  font-size: 0.9rem; line-height: 1;
}
.trip-del:hover, .trip-del-pending:hover {
  background: #fee; border-color: #c44;
}

/* Flash messages */
#footprint-flash {
  position: absolute; bottom: 4rem; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.85); color: white;
  padding: 0.5rem 1rem; border-radius: 6px;
  font-size: 0.8rem; z-index: 1500;
  opacity: 0; transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
#footprint-flash.visible {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* Mobile */
@media (max-width: 640px) {
  #footprint-panel {
    top: auto;
    right: 0; left: 0;
    bottom: 0;
    width: auto;
    max-height: 60%;
    border-radius: 12px 12px 0 0;
  }
  #footprint-panel.closed { transform: translateY(100%); }
  #footprint-legend { font-size: 0.6rem; padding: 0.4rem 0.6rem; }
}
