/* Listing page (and error page) */

.page-home, .page-error { background: var(--paper); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) max(clamp(16px, 4vw, 48px), env(safe-area-inset-right)) 14px max(clamp(16px, 4vw, 48px), env(safe-area-inset-left));
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.topbar.is-scrolled { border-bottom-color: var(--line); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -.01em;
  font-variation-settings: 'opsz' 48;
}
.brand-name em { font-style: italic; font-weight: 400; color: var(--red); }
.brand-sm .seal { width: 30px; height: 30px; }
.brand-sm .brand-name { font-size: 1.1rem; }

.topbar-nav { display: flex; gap: 8px; }
.topbar-link[aria-current="page"] { color: var(--red-deep); }
.topbar-link {
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  padding: .5em 1em;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(32px, 6vw, 72px) clamp(16px, 4vw, 48px) clamp(48px, 7vw, 96px);
}
.hero-contours {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: #d9ccb8;
  opacity: .55;
  pointer-events: none;
}
.hero-inner {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr);
  gap: clamp(32px, 5vw, 80px);
  align-items: center;
}
.hero h1 {
  margin: 14px 0 18px;
  font-family: var(--font-serif);
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: 1;
  font-variation-settings: 'opsz' 144, 'SOFT' 50;
}
.hero h1 em { font-style: italic; font-weight: 400; color: var(--red); }
.lede {
  max-width: 34em;
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  color: var(--ink-2);
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 560px;
  margin-top: 28px;
  padding: 6px 6px 6px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  transition: box-shadow .2s var(--ease), border-color .2s;
}
.search:focus-within { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); box-shadow: var(--shadow-lg); }
.search > .icon { color: var(--muted); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  padding: 10px 4px;
  color: var(--ink);
}
.search input::placeholder { color: #a39a8f; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search button {
  flex: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: .925rem;
  cursor: pointer;
  transition: background .2s;
}
.search button:hover { background: var(--red); }

/* All walks / My walks */
.scope {
  display: inline-flex;
  gap: 4px;
  margin-top: 16px;
  padding: 4px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  border-radius: 999px;
}
.scope-opt {
  display: inline-flex;
  align-items: center;
  gap: .45em;
  padding: .5em 1.1em;
  border-radius: 999px;
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink-2);
  transition: background .2s, color .2s, box-shadow .2s;
}
.scope-opt:hover { color: var(--ink); }
.scope-opt.is-active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.scope-opt .icon { width: 1em; height: 1em; color: var(--jade); }
.scope-count {
  min-width: 1.6em;
  padding: 0 .45em;
  border-radius: 999px;
  background: color-mix(in srgb, var(--jade) 14%, transparent);
  color: var(--jade);
  font-size: .78rem;
  text-align: center;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
  font-size: .9rem;
  color: var(--muted);
}
.hero-stats strong {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--ink);
  margin-right: .25em;
}

/* sketchbook illustration (server/views/sketchbook.js) */
@font-face {
  font-family: 'Caveat Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url('/vendor/fonts/caveat-latin-wght-normal.woff2') format('woff2-variations');
}
.hero-art { display: flex; justify-content: center; }
.sketchbook {
  width: min(100%, 340px);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transform: rotate(2deg);
}
.sketchbook-page { display: block; width: 100%; height: auto; }
.sb-hand { font-family: 'Caveat Variable', 'Caveat', 'Segoe Print', 'Bradley Hand', cursive; font-weight: 500; }
.sb-zh { font-family: 'Kaiti SC', 'STKaiti', 'KaiTi', 'Songti SC', 'SimSun', serif; font-weight: 400; }
.sb-wash { mix-blend-mode: multiply; }

/* ---------- walks ---------- */
.walks {
  box-sizing: content-box;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px) 96px;
  scroll-margin-top: 80px;
}
.walks-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.walks-head h2 {
  margin-top: 6px;
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 3.5vw, 2.5rem);
  font-weight: 500;
  letter-spacing: -.02em;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filter {
  padding: .5em 1.05em;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink-2);
  transition: background .2s, color .2s, border-color .2s;
}
.filter:hover { border-color: var(--ink); color: var(--ink); }
.filter.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* masonry: cards flow down up to three columns, each keeping its own height */
.grid {
  --gap: clamp(18px, 2.4vw, 28px);
  columns: 3 300px;
  column-gap: var(--gap);
  margin: 0;
  /* room for the hover lift of the first row */
  padding: 8px 0 0;
  list-style: none;
}
.card-item {
  break-inside: avoid;
  margin-bottom: var(--gap);
}
.card-item[hidden] { display: none; }
/* entrance lives on the <li> so it never competes with the card's hover transform */
.card-item { animation: rise .6s var(--ease) both; }
.card-item:nth-child(2) { animation-delay: .06s; }
.card-item:nth-child(3) { animation-delay: .12s; }
.card-item:nth-child(n+4) { animation-delay: .18s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.card {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--r-lg);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .55s var(--ease);
}
/* lifted shadow: faded in via opacity, which is far smoother than animating box-shadow */
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  box-shadow:
    0 6px 16px -4px rgba(29, 42, 51, .10),
    0 24px 48px -16px rgba(29, 42, 51, .22);
  opacity: 0;
  transition: opacity .55s var(--ease);
  pointer-events: none;
}
.card:focus-visible { outline-offset: 4px; }
@media (hover: hover) {
  .card:hover { transform: translateY(-6px); }
  .card:hover::after { opacity: 1; }
}
.card:focus-visible { transform: translateY(-6px); }
.card:focus-visible::after { opacity: 1; }
.card:active { transform: translateY(-2px); transition-duration: .15s; }

.card-media {
  position: relative;
  isolation: isolate;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: #e9e1d3;
}
/* staggered photo heights, once there are columns to stagger */
@media (min-width: 680px) {
  .card-item:nth-child(5n+2) .card-media { aspect-ratio: 4 / 5; }
  .card-item:nth-child(5n+3) .card-media { aspect-ratio: 1 / 1; }
  .card-item:nth-child(5n+4) .card-media { aspect-ratio: 3 / 2; }
  .card-item:nth-child(5n) .card-media { aspect-ratio: 5 / 6; }
}
.card-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.4s var(--ease);
}
.card-media::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(20, 24, 28, .28) 0%, transparent 30%, transparent 70%, rgba(20, 24, 28, .12) 100%);
  pointer-events: none;
}
@media (hover: hover) {
  .card:hover .card-media img { transform: scale(1.04); }
}
.card:focus-visible .card-media img { transform: scale(1.04); }

.card-fallback {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .16), transparent 45%),
    repeating-radial-gradient(circle at 70% 120%, transparent 0 18px, rgba(255, 255, 255, .07) 18px 19px),
    linear-gradient(135deg, #d6452a, #9c2f1a);
}
.card-media.is-fallback .card-fallback { display: flex; }
.card-media.is-fallback img { display: none; }
.fallback-mark .icon { width: 44px; height: 44px; opacity: .9; }
.fallback-city {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-style: italic;
}
.card-item:nth-child(3n+2) .card-fallback { background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .16), transparent 45%),
    repeating-radial-gradient(circle at 70% 120%, transparent 0 18px, rgba(255, 255, 255, .07) 18px 19px),
    linear-gradient(135deg, #2a7466, #184a42); }
.card-item:nth-child(3n) .card-fallback { background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, .16), transparent 45%),
    repeating-radial-gradient(circle at 70% 120%, transparent 0 18px, rgba(255, 255, 255, .07) 18px 19px),
    linear-gradient(135deg, #2e3f4d, #1a252e); }

.chip {
  position: absolute;
  z-index: 1;
  top: 14px;
  display: inline-flex;
  align-items: center;
  gap: .35em;
  padding: .38em .8em;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 650;
}
.chip .icon { width: 1em; height: 1em; }
.chip-glass {
  left: 14px;
  color: #fff;
  background: rgba(20, 24, 28, .35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .25);
}
.chip-price { right: 14px; background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.chip-price.is-free { background: var(--jade); color: #fff; }
.chip-price.is-owned { background: var(--jade); color: #fff; }

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 22px 8px;
}
.card-kicker { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.card-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 550;
  letter-spacing: -.015em;
  font-variation-settings: 'opsz' 72;
}
.card-intro {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: .925rem;
  color: var(--ink-2);
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: auto 0 0;
  padding: 10px 0 0;
  list-style: none;
  font-size: .85rem;
  font-weight: 550;
  color: var(--ink-2);
}
.card-meta li { display: inline-flex; align-items: center; gap: .4em; min-width: 0; }
.card-meta .icon { color: var(--red); }
.meta-date { flex-basis: 100%; color: var(--muted); font-weight: 500; }
.meta-date .icon { color: var(--muted); }
.meta-start { flex-basis: 100%; }
.meta-start span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 22px 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line-2);
  font-size: .875rem;
  font-weight: 650;
  color: var(--red-deep);
}
.card-cta .icon {
  box-sizing: content-box;
  width: 16px;
  height: 16px;
  padding: 7px;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red-deep);
  transition: transform .45s var(--ease), background-color .3s, color .3s;
}
@media (hover: hover) {
  .card:hover .card-cta .icon { transform: translateX(3px); background: var(--red); color: #fff; }
}
.card:focus-visible .card-cta .icon { transform: translateX(3px); background: var(--red); color: #fff; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 64px 16px;
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed var(--line);
  border-radius: var(--r-lg);
}
.empty[hidden] { display: none; }
.empty strong { color: var(--ink); font-size: 1.1rem; }
.empty .btn-ghost { margin-top: 12px; color: var(--ink); }
.empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--card);
  color: var(--red);
  box-shadow: var(--shadow-sm);
}

/* ---------- "Bought a walk?" (paste an access link) ---------- */
.unlock {
  box-sizing: content-box;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px) 56px;
}
.unlock-box {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.unlock-box summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
  font-size: .95rem;
  color: var(--ink-2);
}
.unlock-box summary::-webkit-details-marker { display: none; }
.unlock-box summary > .icon:first-child { width: 20px; height: 20px; color: var(--jade); }
.unlock-box summary > span { flex: 1; min-width: 0; }
.unlock-box summary strong { color: var(--ink); }
.unlock-box summary .chev { color: var(--muted); transition: transform .2s var(--ease); }
.unlock-box[open] summary .chev { transform: rotate(180deg); }
.unlock-fields {
  display: flex;
  gap: 8px;
  padding: 0 18px;
}
.unlock-fields input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper-2);
  font: .9rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink);
}
.unlock-fields input:focus {
  outline: 0;
  border-color: color-mix(in srgb, var(--jade) 50%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--jade) 15%, transparent);
}
.unlock-fields button {
  flex: none;
  padding: 0 18px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--jade);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}
.unlock-fields button:hover { background: #174a42; }
.unlock-hint { padding: 10px 18px 16px; font-size: .82rem; color: var(--muted); }
.unlock-hint a { color: var(--jade); font-weight: 600; }

/* ---------- install banner (install.js) ---------- */
.install {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(560px, calc(100% - 24px));
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 14px 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.install[hidden] { display: none; }
.install.is-in { opacity: 1; transform: translate(-50%, 0); }
.install .seal { flex: none; }
.install-text { flex: 1; min-width: 0; font-size: .85rem; color: var(--ink-2); }
.install-text > strong { display: block; font-size: .95rem; color: var(--ink); }
.install-text p { margin: 2px 0 0; line-height: 1.45; }
.install-text p strong { color: var(--ink); font-weight: 650; }
.install-text .icon { width: 1.1em; height: 1.1em; vertical-align: -.2em; color: #2f7cf6; }
.install-btn {
  flex: none;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}
.install-btn[hidden] { display: none; }
.install-btn:hover { background: var(--red-deep); }
.install-close {
  flex: none;
  align-self: flex-start;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: -6px -6px 0 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.install-close:hover { background: var(--paper); color: var(--ink); }
@media (display-mode: standalone) {
  .install { display: none; }
}

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); background: var(--paper-2); }
.footer-inner {
  box-sizing: content-box;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 48px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  font-size: .8rem;
  color: var(--muted);
}
.footer-inner .brand { margin-right: auto; color: var(--ink); }
.footer-nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer-nav a { font-weight: 600; color: var(--ink-2); text-decoration: none; }
.footer-nav a:hover { color: var(--red-deep); text-decoration: underline; }

/* ---------- error page ---------- */
.error-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.error-card {
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  color: var(--ink-2);
}
.error-card h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 500;
  letter-spacing: -.02em;
  color: var(--ink);
}
.error-card .seal { margin-bottom: 8px; }
.error-card .btn-ghost { margin-top: 10px; }

/* offline page: walks saved on this device (install.js) */
.offline-list {
  width: 100%;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}
.offline-list a {
  display: block;
  padding: 12px 14px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
  font-weight: 600;
  text-decoration: none;
}
.offline-list a:hover { border-color: var(--jade); }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-art { display: none; }
}
@media (max-width: 520px) {
  .search { gap: 6px; padding-left: 14px; }
  .search > .icon { flex: none; }
  .search input { font-size: 16px; padding-right: 0; text-overflow: ellipsis; }
  .search button { padding: 11px 16px; }
  .search-btn-more { display: none; }
  .install { gap: 12px; padding: 12px 12px 12px 14px; }
  .install .seal { width: 34px; height: 34px; }
  .unlock-fields { flex-direction: column; }
  .unlock-fields input { font-size: 16px; }
  .unlock-fields button { padding: 13px 18px; }
  .topbar-link { padding: .45em .8em; font-size: .8rem; }
}
@media (max-width: 360px) {
  .topbar { gap: 10px; }
  .topbar .brand { gap: 8px; }
  .topbar .seal { width: 30px; height: 30px; }
  .topbar .brand-name { font-size: 1.05rem; white-space: nowrap; }
  .topbar-nav { gap: 6px; }
}
