/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #000;
  --bg2: #0a0a0a;
  --bg3: #111;
  --border: #1a1a1a;
  --text: #e8e8e8;
  --text-dim: #666;
  --text-muted: #333;
  --accent: #c8f0a0;
  --accent-dim: rgba(200, 240, 160, 0.15);
  --accent-glow: rgba(200, 240, 160, 0.06);
  --danger: #f0a0a0;
  --danger-dim: rgba(240, 160, 160, 0.15);
  --warn: #f0d080;
  --warn-dim: rgba(240, 208, 128, 0.15);
  --radius: 8px;
  --transition: 0.25s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== LAYOUT ===== */
.page {
  display: none;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  animation: fadeIn 0.4s ease;
}
.page.active { display: flex; }

.container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== TYPOGRAPHY ===== */
.headline {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 200;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text);
}

.subtext {
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ===== CARDS ===== */
.card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.card-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.card-value {
  font-size: 0.9rem;
  color: var(--text);
  text-align: right;
  word-break: break-word;
}

.card-value.accent { color: var(--accent); }
.card-value.dim    { color: var(--text-dim); }

/* ===== HINT BLOCK ===== */
.hint-block {
  border-left: 2px solid var(--accent);
  padding: 12px 16px;
  background: var(--accent-glow);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--text);
  line-height: 1.5;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  font-family: var(--font);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #000;
  width: 100%;
}
.btn-primary:hover { background: #d8ffc0; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  width: 100%;
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(240,160,160,0.2);
  width: 100%;
}
.btn-danger:hover { background: rgba(240,160,160,0.25); }

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* ===== INPUTS ===== */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

input[type="text"],
textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 12px 14px;
  width: 100%;
  transition: border-color var(--transition);
  resize: none;
  outline: none;
}
input[type="text"]:focus,
textarea:focus { border-color: var(--text-muted); }
input[type="text"]::placeholder,
textarea::placeholder { color: var(--text-muted); }

/* ===== FILE UPLOAD ===== */
.upload-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--text-muted);
  background: var(--accent-glow);
}
.upload-zone.has-image { border-style: solid; border-color: var(--accent); }

.upload-zone input[type="file"] { display: none; }

.upload-icon {
  font-size: 2rem;
  opacity: 0.4;
}
.upload-label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.upload-preview {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: calc(var(--radius) - 2px);
  display: none;
}
.upload-preview.visible { display: block; }

/* ===== WARNING BANNER ===== */
.banner {
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.85rem;
  line-height: 1.5;
  display: none;
}
.banner.visible { display: block; }
.banner-warn {
  background: var(--warn-dim);
  border: 1px solid rgba(240,208,128,0.2);
  color: var(--warn);
}
.banner-danger {
  background: var(--danger-dim);
  border: 1px solid rgba(240,160,160,0.2);
  color: var(--danger);
}
.banner-info {
  background: var(--accent-dim);
  border: 1px solid rgba(200,240,160,0.2);
  color: var(--accent);
}

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--border);
  width: 100%;
}

/* ===== STATUS DOT ===== */
.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2.5s ease-in-out infinite;
  flex-shrink: 0;
}
.status-dot.lost { background: var(--danger); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== NAV ===== */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  gap: 0;
  z-index: 100;
}

.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 12px 28px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
  border: none;
  background: none;
  font-family: var(--font);
}
.nav-link:hover,
.nav-link.active { color: var(--accent); }

.nav-link-icon { font-size: 1.1rem; }

/* ===== MAP PAGE ===== */
#map-page {
  padding: 0;
  justify-content: flex-start;
}

#map-container {
  width: 100%;
  height: calc(100vh - 56px);
  position: relative;
}

#leaflet-map {
  width: 100%;
  height: 100%;
}

.map-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 400;
  pointer-events: none;
}

.map-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ===== HISTORY PAGE ===== */
.history-header {
  padding-top: 24px;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: 80px;
}

.timeline-item {
  display: flex;
  gap: 16px;
  padding: 0 16px;
}

.timeline-spine {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 20px;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  margin-top: 16px;
  flex-shrink: 0;
}
.timeline-dot.suspicious { background: var(--warn); }
.timeline-dot.first      { background: var(--accent); box-shadow: 0 0 12px var(--accent); }

.timeline-line {
  width: 1px;
  flex: 1;
  background: var(--border);
  min-height: 20px;
}
.timeline-item:last-child .timeline-line { display: none; }

.timeline-content {
  flex: 1;
  padding: 12px 0 24px;
}

.timeline-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.timeline-hint {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.5;
}

.timeline-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.timeline-photo {
  margin-top: 10px;
  width: 100%;
  max-width: 240px;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
  cursor: pointer;
  transition: opacity var(--transition);
}
.timeline-photo:hover { opacity: 0.8; }

.suspicious-badge {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--warn);
  background: var(--warn-dim);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 6px;
}

/* ===== STATS ROW ===== */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-num {
  font-size: 1.6rem;
  font-weight: 200;
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

/* ===== GUARDIAN ROW ===== */
.guardian-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.guardian-count {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.9rem;
}

/* ===== LOADING ===== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 32px 0;
  justify-content: center;
}

/* ===== EMPTY / ERROR ===== */
.empty-state {
  text-align: center;
  padding: 48px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== LIGHTBOX ===== */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius);
}

/* ===== LOST MODE ===== */
.lost-state {
  text-align: center;
  padding: 24px 0;
}
.lost-state .headline { color: var(--text-muted); }
.lost-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 12px;
}

/* ===== LEAFLET OVERRIDES ===== */
.leaflet-container {
  background: #0a0a0a !important;
  font-family: var(--font) !important;
}

.leaflet-popup-content-wrapper {
  background: var(--bg3) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: none !important;
  color: var(--text) !important;
}

.leaflet-popup-tip {
  background: var(--bg3) !important;
}

.leaflet-popup-content {
  margin: 12px 16px !important;
  font-family: var(--font) !important;
  color: var(--text) !important;
  font-size: 0.82rem !important;
  line-height: 1.5 !important;
}

.leaflet-control-zoom a {
  background: var(--bg3) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) saturate(0.6); }

/* ===== RESPONSIVE ===== */
@media (max-width: 380px) {
  .nav-link { padding: 12px 20px; }
  .stats-row { grid-template-columns: 1fr; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
