/* ============================================================
   Berkeley Walks — topographic trail-guide UI
   Palette: kraft paper, deep forest, terracotta, contour gold
   ============================================================ */

:root {
  --paper: #f3ecdc;
  --paper-2: #ece2cc;
  --card: #fbf7ec;
  --ink: #272620;
  --ink-soft: #5b574c;
  --forest: #2f5d50;
  --forest-deep: #234a40;
  --moss: #6f9173;
  --rust: #bd4f2a;
  --rust-deep: #9c3d1f;
  --gold: #cf9b3e;
  --line: rgba(39, 38, 32, 0.13);
  --line-strong: rgba(39, 38, 32, 0.24);
  --shadow: 0 8px 30px rgba(35, 45, 35, 0.18);
  --shadow-sm: 0 2px 10px rgba(35, 45, 35, 0.14);
  --sheet-h: 168px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family:
    "DM Sans",
    system-ui,
    -apple-system,
    sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

a {
  color: var(--forest);
}

.view {
  min-height: 100%;
}

/* ===================== LIST VIEW ===================== */

.masthead {
  position: relative;
  overflow: hidden;
  background: linear-gradient(
    160deg,
    var(--forest) 0%,
    var(--forest-deep) 100%
  );
  color: var(--paper);
  padding: calc(var(--safe-top) + 38px) 22px 40px;
  border-bottom: 3px solid var(--ink);
}

/* faux contour lines */
.masthead__topo {
  position: absolute;
  inset: -40% -10% auto -10%;
  height: 200%;
  opacity: 0.16;
  background-image: repeating-radial-gradient(
    ellipse 120% 80% at 78% 18%,
    transparent 0 16px,
    rgba(243, 236, 220, 0.9) 16px 18px
  );
  pointer-events: none;
}

.masthead__inner {
  position: relative;
}

.kicker {
  margin: 0 0 4px;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}

.wordmark {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(2.6rem, 13vw, 3.4rem);
  line-height: 0.92;
  letter-spacing: -0.02em;
}
.wordmark span {
  display: block;
  font-style: italic;
  font-weight: 400;
  color: var(--moss);
}

.lede {
  margin: 16px 0 0;
  max-width: 30ch;
  font-size: 1rem;
  line-height: 1.5;
  color: rgba(243, 236, 220, 0.88);
}

/* ---- walk cards ---- */
.walklist {
  display: grid;
  gap: 16px;
  padding: 22px 16px 8px;
  max-width: 640px;
  margin: 0 auto;
}

.loading {
  text-align: center;
  color: var(--ink-soft);
  padding: 40px 0;
}

.card {
  display: block;
  position: relative;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 16px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
  overflow: hidden;
}
.card:active {
  transform: translateY(1px) scale(0.995);
}
@media (hover: hover) {
  .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
  }
}

.card__index {
  position: absolute;
  top: 10px;
  right: 14px;
  font-family: "Fraunces", serif;
  font-size: 3.4rem;
  line-height: 1;
  color: var(--line-strong);
  font-weight: 600;
  pointer-events: none;
}

.card__name {
  margin: 0 70px 6px 0;
  font-family: "Fraunces", serif;
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
}

.card__summary {
  margin: 0 0 14px;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tag {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1.3px solid var(--ink);
  background: transparent;
}
.tag--dist {
  background: var(--gold);
  border-color: var(--ink);
}
.tag--time {
  background: var(--paper-2);
}
.tag--diff {
  background: var(--moss);
  color: var(--paper);
  border-color: var(--forest-deep);
}
.tag--loop::before {
  content: "↻ ";
}

.colophon {
  max-width: 640px;
  margin: 8px auto 0;
  padding: 18px 22px calc(28px + var(--safe-bottom));
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-soft);
}
.colophon a {
  color: var(--rust-deep);
}

/* ===================== DETAIL VIEW ===================== */

#view-detail {
  position: fixed;
  inset: 0;
}

#map {
  position: absolute;
  inset: 0;
  bottom: 0;
  background: var(--paper-2);
  z-index: 1;
}

/* floating map buttons */
.map-btn {
  position: absolute;
  z-index: 600;
  border: 1.5px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-family: "DM Sans", sans-serif;
}
.map-btn--back {
  top: calc(var(--safe-top) + 12px);
  left: 12px;
  padding: 9px 15px 9px 11px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
}
.map-btn--locate {
  top: calc(var(--safe-top) + 12px);
  right: 12px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--forest);
}
.map-btn--locate.is-active {
  background: var(--forest);
  color: var(--paper);
}
.map-btn:active {
  transform: scale(0.96);
}

/* bottom sheet */
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 650;
  background: var(--card);
  border-top: 2.5px solid var(--ink);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 34px rgba(35, 45, 35, 0.22);
  padding: 0 18px calc(16px + var(--safe-bottom));
  max-height: 86vh;
  overflow-y: auto;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  -webkit-overflow-scrolling: touch;
}
/* collapsed: only header + CTA peek up */
.sheet.is-collapsed {
  transform: translateY(calc(100% - var(--sheet-h) - var(--safe-bottom)));
}

.sheet__grab {
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: var(--line-strong);
  margin: 10px auto 6px;
  cursor: grab;
}

.sheet__head {
  margin-bottom: 12px;
}
.sheet__title {
  margin: 0 0 3px;
  font-family: "Fraunces", serif;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.01em;
}
.sheet__stats {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--rust-deep);
  letter-spacing: 0.01em;
}

.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  background: var(--rust);
  color: var(--paper);
  border: 1.5px solid var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: 0 3px 0 var(--rust-deep);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
}
.cta:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--rust-deep);
}
.cta-sub {
  margin: 8px 2px 4px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-align: center;
}
.cta-sub.is-live {
  color: var(--forest);
  font-weight: 600;
}

.sheet__body {
  padding-top: 6px;
}

.summary {
  margin: 6px 0 14px;
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--ink);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.chip {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 11px;
  background: var(--paper-2);
  border: 1.2px solid var(--line-strong);
  border-radius: 999px;
}
.chip::before {
  content: "◦ ";
  color: var(--rust);
  font-weight: 700;
}

.turns {
  border-top: 1.5px solid var(--line);
  border-bottom: 1.5px solid var(--line);
  margin: 4px 0 14px;
}
.turns summary {
  padding: 14px 2px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.turns summary::-webkit-details-marker {
  display: none;
}
.turns summary::after {
  content: "+";
  font-size: 1.3rem;
  color: var(--rust);
}
.turns[open] summary::after {
  content: "–";
}
.turnlist {
  margin: 0 0 14px;
  padding: 0 0 0 4px;
  list-style: none;
  counter-reset: turn;
}
.turnlist li {
  counter-increment: turn;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.92rem;
}
.turnlist li::before {
  content: counter(turn);
  font-family: "Fraunces", serif;
  font-weight: 600;
  color: var(--moss);
  text-align: center;
}
.turnlist .turn-dist {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.credit {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 8px 0 2px;
}

/* ---- Leaflet marker tweaks ---- */
.you-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2b6cff;
  border: 3px solid #fff;
  box-shadow:
    0 0 0 2px rgba(43, 108, 255, 0.4),
    0 1px 6px rgba(0, 0, 0, 0.4);
}
.you-pulse {
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0% {
    box-shadow:
      0 0 0 0 rgba(43, 108, 255, 0.45),
      0 1px 6px rgba(0, 0, 0, 0.4);
  }
  70% {
    box-shadow:
      0 0 0 16px rgba(43, 108, 255, 0),
      0 1px 6px rgba(0, 0, 0, 0.4);
  }
  100% {
    box-shadow:
      0 0 0 0 rgba(43, 108, 255, 0),
      0 1px 6px rgba(0, 0, 0, 0.4);
  }
}
.endpoint-pin {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-sm);
  font-size: 0;
}
.endpoint-pin span {
  transform: rotate(45deg);
  font-size: 13px;
  font-weight: 700;
  color: var(--paper);
}
.pin-start {
  background: var(--forest);
}
.pin-end {
  background: var(--rust);
}

.leaflet-container {
  font-family: "DM Sans", sans-serif;
  background: var(--paper-2);
}

@media (min-width: 760px) {
  .sheet {
    left: auto;
    right: 18px;
    bottom: 18px;
    width: 380px;
    border-radius: 18px;
    border: 2px solid var(--ink);
    max-height: calc(100% - 36px);
  }
  .sheet.is-collapsed {
    transform: none;
  }
}
