/* Wavelet Travel Map v2
   VOICE  quiet, photographic: the map and the pictures do the talking
   IDEA   an atlas with a contact sheet clipped to it
   COLOUR white / deep ink, logo teal accent; routes coloured by year (old = cool, new = warm)
   TYPE   Fraunces for names (echoes the Wavelet logo), Inter for everything else
   LAYOUT fixed-height side panel that scrolls inside itself, map fills the rest; bottom sheet on phones */

:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #12181b);
  --bg2: light-dark(#f4f6f7, #1a2226);
  --ink: light-dark(#18242a, #e7eef0);
  --muted: light-dark(#5f6f76, #93a3a9);
  --line: light-dark(#e3e8ea, #2a353a);
  --accent: light-dark(#23708a, #5fb4cc);
  --shadow: 0 8px 28px rgba(10, 25, 32, .18);
  --panel: 360px;
}
* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#app { display: grid; grid-template-columns: var(--panel) 1fr; height: 100vh; height: 100dvh; position: relative; }
#map { position: relative; height: 100%; background: var(--bg2); }

/* ---------- panel ---------- */
#panel { display: flex; flex-direction: column; height: 100%; overflow: hidden; border-right: 1px solid var(--line); background: var(--bg); z-index: 2; }
#listView, #tripView { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.brand { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 10px; }
.wordmark { text-decoration: none; color: var(--accent); display: flex; align-items: baseline; gap: 10px; }
.wordmark span { font: 600 28px/1 Fraunces, Georgia, serif; letter-spacing: -.01em; }
.wordmark small { font-size: 13px; color: var(--muted); letter-spacing: .02em; padding-left: 10px; border-left: 1px solid var(--line); }
.sheet-toggle { display: none; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px 20px 12px; }
.stats div { display: flex; flex-direction: column; }
.stats b { font: 600 19px/1.15 Inter, sans-serif; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats span { font-size: 12px; color: var(--muted); }

.search { display: flex; align-items: center; gap: 8px; margin: 0 20px; padding: 0 12px; height: 40px; border-radius: 10px; background: var(--bg2); border: 1px solid transparent; }
.search:focus-within { border-color: var(--accent); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font: 15px Inter, sans-serif; color: var(--ink); height: 100%; }

.hist-wrap { padding: 14px 20px 6px; }
.hist { display: flex; align-items: flex-end; gap: 2px; height: 46px; touch-action: none; user-select: none; cursor: crosshair; }
.hist i { flex: 1; background: var(--c); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .9; transition: opacity .15s; }
.hist.filtered i:not(.on) { opacity: .18; }
.hist-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font-size: 12px; }

.list { flex: 1; overflow-y: auto; padding: 4px 0 24px; overscroll-behavior: contain; scrollbar-width: thin; }
.group h2 { position: sticky; top: 0; z-index: 1; margin: 0; padding: 10px 20px 6px; font: 600 12px/1 Inter, sans-serif; color: var(--muted); background: var(--bg); display: flex; justify-content: space-between; }
.trip { display: grid; grid-template-columns: 46px 1fr 10px; align-items: center; gap: 12px; width: 100%; padding: 7px 20px; border: 0; background: none; text-align: left; }
.trip:hover, .trip:focus-visible { background: var(--bg2); outline: none; }
.trip .th { width: 46px; height: 46px; border-radius: 8px; background: var(--bg2) center/cover no-repeat; }
.trip .nm { display: block; font: 600 15px/1.25 Fraunces, Georgia, serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip .mt { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip .mt em { font-style: normal; color: var(--accent); }
.trip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.empty { padding: 30px 20px; color: var(--muted); }

/* ---------- trip view ---------- */
.trip-head { padding: 4px 20px 12px; border-bottom: 1px solid var(--line); }
.back { border: 0; background: none; padding: 6px 0; color: var(--accent); font-size: 13px; font-weight: 500; }
.trip-head h1 { margin: 4px 0 2px; font: 600 28px/1.1 Fraunces, Georgia, serif; text-wrap: balance; }
.sub { margin: 0; color: var(--muted); font-size: 13.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips span { font-size: 12.5px; padding: 3px 9px; border-radius: 99px; background: var(--bg2); white-space: nowrap; }
.chips b { font-weight: 600; }
.trip-body { flex: 1; overflow-y: auto; padding: 14px 20px 30px; overscroll-behavior: contain; }
.profile { margin-bottom: 16px; }
.profile-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
#pRead { font-variant-numeric: tabular-nums; color: var(--ink); }
#pSvg { display: block; width: 100%; height: 110px; touch-action: none; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ph { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 8px; overflow: hidden; background: var(--bg2) center/cover no-repeat; }
.ph span { position: absolute; inset: auto 0 0 0; padding: 14px 6px 5px; font-size: 11px; line-height: 1.2; color: #fff; text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.65)); opacity: 0; transition: opacity .15s; }
.ph:hover span, .ph:focus-visible span { opacity: 1; }
.ph:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- map ui ---------- */
.mapui { position: absolute; top: 14px; right: 14px; left: 14px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; z-index: 3; pointer-events: none; }
.mapui > * { pointer-events: auto; }
.seg, .pill { background: var(--bg); border-radius: 10px; box-shadow: var(--shadow); border: 0; }
.seg { display: flex; padding: 3px; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.pill { min-width: 40px; height: 40px; font-weight: 600; font-size: 13px; display: inline-grid; place-items: center; }
.pill[aria-pressed="true"] { background: var(--accent); color: #fff; }
.loading { position: absolute; left: calc(var(--panel) + 16px); bottom: 36px; padding: 6px 12px; border-radius: 99px; background: var(--bg); box-shadow: var(--shadow); font-size: 12.5px; z-index: 3; }

/* photo markers */
.pm { width: 38px; height: 38px; padding: 0; border-radius: 50%; border: 2.5px solid var(--c, #fff); background: #ccc center/cover no-repeat; box-shadow: 0 2px 8px rgba(0,0,0,.35); transition: transform .15s; }
.pm:hover, .pm:focus-visible { transform: scale(1.25); z-index: 5; outline: none; }
.pm.cl { width: 46px; height: 46px; border-color: #fff; box-shadow: 4px 4px 0 -1px #fff, 4px 4px 6px rgba(0,0,0,.3), 0 2px 8px rgba(0,0,0,.35); border-radius: 10px; }
.pm.cl b { position: absolute; top: -8px; right: -10px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: #fff; font: 600 11.5px/22px Inter, sans-serif; }
.hover-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.4); pointer-events: none; }

.maplibregl-popup-content { padding: 0; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); background: var(--bg); color: var(--ink); }
.maplibregl-popup-tip { display: none; }
.card { min-width: 160px; max-width: 200px; }
.card img { display: block; margin: 0 auto; width: auto; height: auto; max-width: 100%; } /* thumbnail at its own size */
.card div { padding: 8px 10px 10px; }
.card b { display: block; font: 600 14px/1.25 Fraunces, Georgia, serif; }
.card span { font-size: 12px; color: var(--muted); }
.card small { display: block; margin-top: 4px; font-size: 11.5px; color: var(--accent); }
.pinned .card img { cursor: zoom-in; }
.pinned .maplibregl-popup-content { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.maplibregl-ctrl-attrib { font-size: 11px; }

/* ---------- lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; gap: 12px; background: rgba(8, 14, 17, .92); animation: fade .2s ease; }
.lb figure { margin: 0; display: flex; flex-direction: column; align-items: center; max-width: min(92vw, 1100px); }
/* photos show at their own pixel size: never enlarged, only shrunk if bigger than the window */
.lb figure { position: relative; min-height: 120px; justify-content: center; }
.lb img { display: block; width: auto; height: auto; max-width: 100%; max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); border-radius: 4px; transition: opacity .2s; }
.lb img.loading { opacity: 0; }
.lb.busy figure::before { content: ""; position: absolute; width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.lb figcaption { color: #e9eef0; text-align: center; margin-top: 12px; }
.lb figcaption strong { display: block; font: 600 20px/1.3 Fraunces, Georgia, serif; }
.lb figcaption span { font-size: 13px; color: #a9b7bc; }
.lb-x, .lb-nav { border: 0; background: rgba(255,255,255,.1); color: #fff; border-radius: 50%; width: 48px; height: 48px; font-size: 26px; line-height: 1; flex: none; }
.lb-x { position: absolute; top: 16px; right: 16px; font-size: 18px; }
.lb-x:hover, .lb-nav:hover { background: rgba(255,255,255,.22); }
@keyframes fade { from { opacity: 0; } }

/* ---------- phones: map on top, list as a bottom sheet ---------- */
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #map { grid-row: 1; }
  #panel { grid-row: 2; height: 42dvh; border-right: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; margin-top: -16px; box-shadow: 0 -6px 20px rgba(0,0,0,.12); transition: height .25s ease; }
  #panel.expanded { height: 82dvh; }
  .brand { padding: 10px 16px 6px; }
  .wordmark span { font-size: 22px; }
  .sheet-toggle { display: block; border: 0; background: var(--bg2); border-radius: 8px; width: 44px; height: 32px; }
  #panel.expanded .sheet-toggle { transform: rotate(180deg); }
  .stats { padding: 4px 16px 10px; }
  .stats b { font-size: 16px; }
  .search { margin: 0 16px; }
  .hist-wrap { padding: 10px 16px 4px; }
  .mapui { top: 10px; right: 10px; left: 10px; justify-content: flex-end; }
  .seg button { padding: 7px 9px; }
  .loading { left: 12px; bottom: 50px; }
  .lb-nav { position: absolute; bottom: 20px; }
  .lb-prev { left: 20px; } .lb-next { right: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
