/* TheWhitesOnTheRoad.ca — public site */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; display: block; }
a { color: var(--accent); }

button, input, textarea, select { font: inherit; color: inherit; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ header */

.site-header {
  position: sticky; top: 0; z-index: 500;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; gap: 18px;
  min-height: 62px;
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark { font-size: 22px; line-height: 1; }
.brand-name {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 600; letter-spacing: -.01em;
}
.brand-tag { color: var(--ink-faint); font-size: 13px; display: none; }
@media (min-width: 900px) { .brand-tag { display: inline; } }

/* On a phone the site title is long enough to wrap to three lines and crush
   the nav — clamp it to one line and let it ellipsize instead. */
@media (max-width: 640px) {
  .header-inner { gap: 10px; min-height: 54px; }
  .brand { flex: 1; min-width: 0; }
  .brand-name {
    font-size: 16px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }
  .nav { flex: none; gap: 2px; }
  .nav a, .nav button { padding: 7px 9px; font-size: 14px; }
}
/* Below this the title only ever renders as an ellipsis, which reads as
   breakage. Drop to the 🚐 alone — the <h1> underneath carries the name. */
@media (max-width: 520px) {
  .brand-name { display: none; }
}

.nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.nav a, .nav button {
  background: none; border: 0; cursor: pointer;
  padding: 8px 12px; border-radius: 9px;
  color: var(--ink-soft); text-decoration: none; font-size: 15px;
}
.nav a:hover, .nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { color: var(--ink); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: filter .15s ease, transform .05s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-sm { padding: 6px 12px; font-size: 14px; border-radius: 8px; }
.btn-danger { background: #b5453a; color: #fff; }

/* -------------------------------------------------------------------- hero */

.hero { padding: 28px 0 18px; }
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4.5vw, 44px); line-height: 1.12;
  margin: 0 0 8px; letter-spacing: -.02em;
}
.hero p { margin: 0; color: var(--ink-soft); font-size: 17px; max-width: 60ch; }

.stat-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 20px; font-family: var(--font-display); }
.stat span { font-size: 12px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .08em; }

/* ------------------------------------------------------------------- scope */

.scope-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 22px 0 14px;
}
.scope {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 16px; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--ink-soft);
}
.scope:hover { border-color: var(--accent); color: var(--ink); }
.scope.active {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-ink); font-weight: 600;
}
.scope-note { margin-left: auto; font-size: 13px; color: var(--ink-faint); }

/* --------------------------------------------------------------------- map */

.map-shell {
  position: relative;
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); background: var(--surface-2);
}
#map { height: min(62vh, 560px); width: 100%; }
@media (max-width: 700px) { #map { height: 58vh; } }

/* The basemap is tinted per theme; markers and routes must stay untouched. */
.leaflet-tile-pane { filter: var(--map-filter); }

.map-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 450;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: 12.5px; box-shadow: var(--shadow);
  max-width: 55%;
}
.map-legend .row { display: flex; align-items: center; gap: 8px; }
.map-legend .row + .row { margin-top: 5px; }
.swatch { width: 16px; height: 4px; border-radius: 2px; flex: none; }
/* Dashed legend key, matching the inferred-route polylines. */
.swatch-dash {
  height: 0; border-top: 3px dashed var(--route); border-radius: 0; opacity: .6;
}
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

.map-empty {
  position: absolute; inset: 0; z-index: 460; display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  text-align: center; padding: 24px; pointer-events: none;
}
.map-empty div { max-width: 34ch; color: var(--ink-soft); }

/* Pulsing "they are here right now" marker. */
.live-marker { position: relative; }
.live-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent);
}
.live-dot::after {
  content: ""; position: absolute; inset: -8px; border-radius: 50%;
  border: 2px solid var(--accent); opacity: .8;
  animation: ping 2.2s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes ping { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .live-dot::after { animation: none; opacity: .35; } }

.pin {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50% 50% 50% 6px;
  transform: rotate(-45deg);
  background: var(--accent); border: 2px solid var(--surface);
  box-shadow: 0 2px 6px rgba(0,0,0,.28);
  color: var(--accent-ink); font-size: 13px;
}
.pin > * { transform: rotate(45deg); }
.pin-endpoint { border-radius: 50%; transform: none; background: var(--surface); color: var(--ink); border: 2px solid var(--ink-soft); }
.pin-endpoint > * { transform: none; }

.leaflet-popup-content-wrapper {
  border-radius: 12px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 12px 14px; min-width: 190px; }
.pop-title { font-weight: 700; font-family: var(--font-display); font-size: 16px; margin: 0 0 2px; }
.pop-place { color: var(--ink-faint); font-size: 12.5px; margin: 0 0 8px; }
.pop-thumb { border-radius: 8px; margin: 0 0 8px; width: 100%; height: 110px; object-fit: cover; }

/* ------------------------------------------------------------------- posts */

.section-head {
  display: flex; align-items: baseline; gap: 12px; margin: 38px 0 16px;
}
.section-head h2 {
  font-family: var(--font-display); font-size: 26px; margin: 0; letter-spacing: -.01em;
}
.section-head .count { color: var(--ink-faint); font-size: 14px; }

.post-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column; cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 6px 12px rgba(0,0,0,.08), 0 18px 40px rgba(0,0,0,.10); }
.card-media { aspect-ratio: 16 / 10; background: var(--surface-2); position: relative; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-count {
  position: absolute; right: 10px; bottom: 10px;
  background: rgba(0,0,0,.62); color: #fff; font-size: 12px;
  padding: 3px 9px; border-radius: 999px; backdrop-filter: blur(4px);
}
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-meta { font-size: 12px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .07em; }
.card h3 { font-family: var(--font-display); font-size: 19px; margin: 0; line-height: 1.25; }
.card p { margin: 0; color: var(--ink-soft); font-size: 14.5px; }
.card-foot { margin-top: auto; padding-top: 10px; font-size: 13px; color: var(--ink-faint); display: flex; gap: 14px; }

.empty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 42px 24px; text-align: center; color: var(--ink-soft);
}

/* ------------------------------------------------------------------ dialog */

dialog {
  border: 0; padding: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
  max-width: min(720px, 94vw); width: 100%;
}
dialog::backdrop { background: rgba(20,16,12,.55); backdrop-filter: blur(3px); }
.dialog-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.dialog-head h2 { font-family: var(--font-display); font-size: 21px; margin: 0; flex: 1; }
.dialog-body { padding: 22px; max-height: min(72vh, 720px); overflow: auto; }
.dialog-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.x-btn {
  background: none; border: 0; cursor: pointer; font-size: 22px; line-height: 1;
  color: var(--ink-faint); padding: 4px 8px; border-radius: 8px;
}
.x-btn:hover { background: var(--surface-2); color: var(--ink); }

/* -------------------------------------------------------------------- form */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); }
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="date"], .field input[type="datetime-local"], .field input[type="number"],
.field textarea, .field select {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg);
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.field textarea { min-height: 120px; resize: vertical; }
.field .hint { font-size: 12.5px; color: var(--ink-faint); margin-top: 5px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 14.5px; }
.check input { margin-top: 4px; }

.msg { padding: 11px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.msg-error { background: #fdecea; color: #8c2f24; border: 1px solid #f3c9c3; }
.msg-ok    { background: var(--accent-soft); color: var(--ink); border: 1px solid var(--line); }
[data-theme="midnight"] .msg-error { background: #3a201c; color: #f2c0b8; border-color: #5c332c; }

/* ------------------------------------------------------------- post detail */

.post-detail h1 { font-family: var(--font-display); font-size: 28px; margin: 0 0 6px; line-height: 1.2; }
.post-detail .meta { color: var(--ink-faint); font-size: 13.5px; margin: 0 0 18px; }
.post-body { font-size: 16.5px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.gallery { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin: 20px 0; }
.gallery img { border-radius: 10px; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; }

.comments { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 20px; }
.comment { padding: 12px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 4px; }
.comment-author { font-weight: 700; }
.badge-host {
  background: var(--accent); color: var(--accent-ink);
  font-size: 10.5px; padding: 2px 7px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
}
.comment-time { color: var(--ink-faint); margin-left: auto; font-size: 12.5px; }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ----------------------------------------------------------------- lightbox */

.lightbox {
  position: fixed; inset: 0; z-index: 2000; display: none;
  background: rgba(10,8,6,.94); place-items: center;
}
.lightbox.open { display: grid; }
.lightbox img { max-width: 94vw; max-height: 86vh; object-fit: contain; border-radius: 6px; }
.lightbox .cap { color: #f0ece6; text-align: center; margin-top: 12px; font-size: 14.5px; max-width: 70ch; padding: 0 20px; }
.lb-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.12); color: #fff; border: 0;
  width: 46px; height: 46px; border-radius: 50%; font-size: 22px; cursor: pointer;
}
.lb-prev { left: 18px; } .lb-next { right: 18px; }
.lb-close { position: absolute; top: 18px; right: 18px; transform: none; }
.lb-btn:hover { background: rgba(255,255,255,.24); }

/* ------------------------------------------------------------------ footer */

.site-footer {
  margin-top: 56px; padding: 26px 0 40px;
  border-top: 1px solid var(--line); color: var(--ink-faint); font-size: 13.5px;
}
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.site-footer a { color: var(--ink-soft); }
.theme-picker { margin-left: auto; display: flex; align-items: center; gap: 8px; }
@media (max-width: 560px) { .theme-picker { margin-left: 0; width: 100%; } }
.theme-picker select { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(120%);
  background: var(--ink); color: var(--bg);
  padding: 12px 20px; border-radius: 999px; box-shadow: var(--shadow);
  z-index: 3000; transition: transform .25s ease; font-size: 14.5px; max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite; margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Standing notice for an account still in the approval queue. */
.pending-bar {
  background: var(--accent-soft); color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px; font-size: 14px; text-align: center;
}
.pending-bar strong { color: var(--ink); }

/* ------------------------------------------------------- clickable stats */

.stat-link { text-decoration: none; color: inherit; display: block; transition: transform .14s ease, border-color .14s ease; }
.stat-link:hover { transform: translateY(-2px); border-color: var(--accent); }
.stat-link:hover b { color: var(--accent); }

/* ------------------------------------------------------------ trip cards */

.trip-list { display: grid; gap: 18px; }
.trip-card {
  position: relative; display: flex; gap: 18px; align-items: stretch;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
}
.trip-card:hover { transform: translateY(-3px); box-shadow: 0 6px 12px rgba(0,0,0,.08), 0 18px 40px rgba(0,0,0,.10); }
.trip-stripe { width: 6px; flex: none; }
.trip-cover { width: 190px; flex: none; object-fit: cover; align-self: stretch; background: var(--surface-2); }
.trip-cover-empty { display: grid; place-items: center; font-size: 34px; }
.trip-body { padding: 18px 20px 18px 16px; flex: 1; min-width: 0; }
/* With a cover image the stripe+image already provide the left edge. */
.trip-cover + .trip-body { padding-left: 2px; }
.trip-body h3 { font-family: var(--font-display); font-size: 21px; margin: 4px 0 6px; }
.trip-body p { margin: 0 0 10px; color: var(--ink-soft); font-size: 14.5px; }
.trip-badge {
  margin-left: 10px; background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; padding: 2px 9px; font-size: 10.5px; letter-spacing: .05em;
}
.trip-badge-soon { background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line); }
.trip-stats { display: flex; gap: 20px; flex-wrap: wrap; font-size: 14px; color: var(--ink-soft); }
.trip-stats b { font-family: var(--font-display); font-size: 17px; color: var(--ink); }
@media (max-width: 640px) {
  .trip-card { flex-wrap: wrap; }
  .trip-stripe { width: 100%; height: 5px; }
  .trip-cover { width: 100%; height: 170px; }
  .trip-body, .trip-cover + .trip-body { padding: 14px 18px 18px; }
  .trip-stats { gap: 14px; }
}
/* Breathing room between the brand mark and the first nav link on a phone. */
@media (max-width: 520px) {
  .brand { margin-right: 6px; }
  .header-inner { gap: 12px; }
}

/* ------------------------------------------------------------ photo wall */

.photo-wall { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.wall-item { margin: 0; background: var(--surface); border: 1px solid var(--line);
             border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.wall-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; cursor: zoom-in;
                 transition: transform .2s ease; }
.wall-item:hover img { transform: scale(1.03); }
.wall-item figcaption { padding: 10px 12px; font-size: 13px; display: grid; gap: 2px; }
.wall-item figcaption a { font-weight: 600; text-decoration: none; }
.wall-item figcaption a:hover { text-decoration: underline; }
.wall-item figcaption span { color: var(--ink-faint); font-size: 12px; }

/* ---------------------------------------------------------------- avatars */

.avatar {
  display: inline-grid; place-items: center; flex: none;
  border-radius: 50%; overflow: hidden; background: var(--surface-2);
  color: #3a3128; font-weight: 700; line-height: 1; user-select: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-emoji, .avatar-initials { display: block; }

.comment-row { display: flex; gap: 12px; align-items: flex-start; }
.comment-main { flex: 1; min-width: 0; }

.nav-me { display: inline-flex !important; align-items: center; gap: 8px; }
.nav-me-name { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .nav-me-name { display: none; } }

.avatar-editor { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.avatar-preview { flex: none; }
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
@media (max-width: 520px) { .avatar-grid { grid-template-columns: repeat(4, 1fr); } }
.avatar-pick {
  aspect-ratio: 1; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; font-size: 20px; display: grid; place-items: center;
  transition: transform .12s ease;
}
.avatar-pick:hover { transform: scale(1.08); }
.avatar-pick.picked { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
