@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@400;600;700&family=IBM+Plex+Mono:wght@400;600&display=swap');

/* ── Tokens ──────────────────────────────────────────── */
:root {
  --paper:    #E8DFC9;
  --ink:      #26402E;
  --red:      #9E3B2C;
  --blue:     #3F5E7A;
  --grey:     #6B675E;
  --border:   1px solid #26402E;
  --font-head: 'Barlow Condensed', 'Archivo Narrow', Arial Narrow, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
  --font-body: system-ui, sans-serif;
  --radius:   0;
  --nav-h:    48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16201A;
    --ink:   #D4C9A8;
    --grey:  #9B9589;
  }
}

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

html { font-size: 16px; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + 1rem);
}

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

img { max-width: 100%; display: block; }

/* ── Typography ──────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

.mono { font-family: var(--font-mono); }
.ele  { font-family: var(--font-mono); font-weight: 600; }

/* ── Layout ──────────────────────────────────────────── */
.page { max-width: 680px; margin: 0 auto; padding: 1rem 1rem 0; }
.full-page { padding: 1rem 1rem 0; }

.page-header {
  border-bottom: var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.page-header h1 { flex: 1; }

/* ── Bottom Navigation ───────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--paper);
  border-top: var(--border);
  display: flex;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: var(--font-head);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--grey);
  border: none;
  background: none;
  cursor: pointer;
  text-decoration: none;
  padding: 4px 0;
  border-right: var(--border);
}

.nav-item:last-child { border-right: none; }
.nav-item.active { color: var(--ink); background: rgba(38,64,46,0.06); }

.nav-icon {
  font-size: 1.1rem;
  line-height: 1;
  font-style: normal;
}

/* ── Cards ───────────────────────────────────────────── */
.card {
  border: var(--border);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--paper);
}

.card-link { display: block; text-decoration: none; color: inherit; }
.card-link:hover { background: rgba(38,64,46,0.04); }

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-title {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  flex: 1;
}

.card-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--grey);
}

.card-sub {
  font-size: 0.85rem;
  color: var(--grey);
  margin-top: 0.25rem;
}

/* ── Stats bar ───────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 0;
  border: var(--border);
  margin-bottom: 1rem;
}

.stat {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border-right: var(--border);
  text-align: center;
}

.stat:last-child { border-right: none; }

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 600;
  display: block;
}

.stat-label {
  font-family: var(--font-head);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--grey);
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.6rem 1.2rem;
  border: var(--border);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  min-height: 48px;
}

.btn:hover { background: var(--ink); color: var(--paper); text-decoration: none; }

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}

.btn-primary:hover { background: #1a2d1f; color: var(--paper); }

.btn-red {
  background: var(--red);
  color: var(--paper);
  border-color: var(--red);
}

.btn-red:hover { background: #7a2d20; }

.btn-full { display: flex; width: 100%; text-align: center; }
.btn-stack .btn + .btn { margin-top: 0.5rem; }
.btn + .btn { margin-top: 0; }

/* ── Forms ───────────────────────────────────────────── */
.field { margin-bottom: 1rem; }

label {
  display: block;
  font-family: var(--font-head);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
  color: var(--grey);
}

input, select, textarea {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: var(--border);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  border-radius: 0;
  min-height: 48px;
  appearance: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

textarea { min-height: 80px; resize: vertical; }

.radio-group { display: flex; gap: 0; border: var(--border); }
.radio-option { flex: 1; text-align: center; }
.radio-option input { display: none; }
.radio-option label {
  display: block;
  padding: 0.6rem 0.5rem;
  cursor: pointer;
  color: var(--grey);
  border-right: var(--border);
  margin: 0;
  text-align: center;
}
.radio-option:last-child label { border-right: none; }
.radio-option input:checked + label { background: var(--ink); color: var(--paper); }

/* ── Map ─────────────────────────────────────────────── */
#map {
  width: 100%;
  height: calc(100dvh - var(--nav-h) - 80px);
  min-height: 400px;
  border: var(--border);
  margin-bottom: 0.5rem;
}

/* ── Achievements / Stamps ───────────────────────────── */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.stamp-wrap {
  display: flex;
  justify-content: center;
}

.stamp {
  width: 130px;
  height: 130px;
  border: 3px solid var(--red);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px;
  position: relative;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}

.stamp:active { opacity: 0.75; }

.stamp::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid var(--red);
  opacity: 0.5;
}

.stamp.earned {
  transform: rotate(var(--rot, -2deg));
}

.stamp.unearned {
  border-style: dashed;
  border-color: var(--grey);
  opacity: 0.4;
}

.stamp.unearned::before { border-color: var(--grey); }

.stamp-icon {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--red);
  line-height: 1;
  margin-bottom: 4px;
}

.stamp.unearned .stamp-icon { color: var(--grey); }

.stamp-name {
  font-family: var(--font-head);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--red);
  line-height: 1.2;
}

.stamp.unearned .stamp-name { color: var(--grey); }

.stamp-date {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--red);
  margin-top: 4px;
}

.stamp-hint {
  display: none;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  line-height: 1.35;
  color: var(--grey);
  text-align: center;
  padding: 2px;
  width: 100%;
}

.stamp.earned.showing-hint .stamp-hint { color: var(--red); }

.stamp.showing-hint {
  transform: none !important;
}

.stamp.showing-hint .stamp-content { display: none; }
.stamp.showing-hint .stamp-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

@keyframes stamp-thunk {
  0%   { transform: rotate(var(--rot, -2deg)) scale(1.4); opacity: 0; }
  60%  { transform: rotate(var(--rot, -2deg)) scale(0.96); opacity: 1; }
  80%  { transform: rotate(var(--rot, -2deg)) scale(1.03); }
  100% { transform: rotate(var(--rot, -2deg)) scale(1); }
}

.stamp.just-earned {
  animation: stamp-thunk 0.25s ease-out forwards;
}

@media (prefers-reduced-motion: reduce) {
  .stamp.just-earned { animation: none; }
}

/* ── Progress bar ────────────────────────────────────── */
.progress-wrap {
  border: var(--border);
  height: 8px;
  margin-top: 0.4rem;
  background: var(--paper);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--ink);
  transition: width 0.3s;
}

/* ── Peak list ───────────────────────────────────────── */
.peak-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(38,64,46,0.15);
  font-size: 0.9rem;
}

.peak-row:last-child { border-bottom: none; }
.peak-row.done .peak-name { color: var(--grey); }
.peak-row.done::before { content: '✓ '; color: var(--ink); font-family: var(--font-mono); }
.peak-name { flex: 1; }
.peak-ele { font-family: var(--font-mono); font-size: 0.85rem; color: var(--grey); }
.peak-region { font-size: 0.75rem; color: var(--grey); }

/* ── Logbook entries ─────────────────────────────────── */
.ascent-entry {
  border-left: 3px solid var(--ink);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  background: rgba(38,64,46,0.03);
}

.ascent-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
}

.ascent-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--grey);
}

.ascent-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--grey);
  margin-top: 0.2rem;
}

/* ── Search ──────────────────────────────────────────── */
.search-results {
  border: var(--border);
  border-top: none;
  max-height: 260px;
  overflow-y: auto;
}

.search-result-item {
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(38,64,46,0.15);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.search-result-item:hover, .search-result-item.selected {
  background: var(--ink);
  color: var(--paper);
}

.search-result-item:hover .peak-ele,
.search-result-item.selected .peak-ele { color: rgba(232,223,201,0.7); }

/* ── Onboarding peak picker ──────────────────────────── */
.picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0;
}

.picker-item {
  border: var(--border);
  padding: 0.35rem 0.6rem;
  font-family: var(--font-head);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.picker-item.checked {
  background: var(--ink);
  color: var(--paper);
}

/* ── Chip / Tag ──────────────────────────────────────── */
.chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border: var(--border);
  color: var(--grey);
}

.chip.source-gps   { border-color: var(--blue); color: var(--blue); }
.chip.source-photo { border-color: var(--ink);  color: var(--ink); }
.chip.source-manual{ border-color: var(--grey); }

/* ── Toast ───────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: #111;
  color: #fff;
  font-family: var(--font-head);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.5rem 1.2rem;
  letter-spacing: 0.04em;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.toast.show { opacity: 1; transform: translateY(0); }

/* ── Misc ────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: var(--border);
  margin: 1rem 0;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--grey);
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  background: var(--ink);
  color: var(--paper);
}

.text-red   { color: var(--red); }
.text-grey  { color: var(--grey); }
.text-small { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ── Leaflet overrides ───────────────────────────────── */
.leaflet-container { background: #d4c9a8; }
.leaflet-control-zoom a {
  font-family: var(--font-mono) !important;
  border-radius: 0 !important;
}
.leaflet-popup-content-wrapper { border-radius: 0 !important; border: var(--border) !important; }
.leaflet-popup-tip { background: var(--paper) !important; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 420px) {
  h1 { font-size: 1.6rem; }
  .stats-bar { flex-wrap: wrap; }
  .stat { min-width: 33%; }
}
