/* ============================================================
   northwards — bicycle tour San Francisco → Prudhoe Bay
   Static rebuild. Responsive stylesheet.
   ============================================================ */

:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --ink: #1e2a2e;
  --muted: #5d6b70;
  --faint: #8a969a;
  --primary: #0b7285;
  --primary-dark: #084d5b;
  --primary-tint: #e3f0f2;
  --accent: #d9480f;
  --accent-tint: #fbe9e0;
  --border: #e4ded2;
  --border-strong: #cdc6b6;
  --shadow: 0 1px 2px rgba(30, 42, 46, .06), 0 6px 20px rgba(30, 42, 46, .06);
  --radius: 12px;
  --maxw: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

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

h1, h2, h3, h4, h5 { line-height: 1.25; color: var(--ink); }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: .2em 0 .4em; }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); }
h3 { font-size: 1.25rem; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- Top bar / navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(255, 255, 255, .95);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 16px;
  min-height: 60px;
}
.brand {
  display: flex; align-items: baseline; gap: 8px;
  font-weight: 800; letter-spacing: .5px; font-size: 1.25rem;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.brand:hover { text-decoration: none; color: var(--ink); }
.brand .arrow { color: var(--accent); }
.brand small {
  font-weight: 500; font-size: .72rem; letter-spacing: 1px;
  text-transform: uppercase; color: var(--faint);
}

.nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.nav a {
  display: block; padding: 8px 12px; border-radius: 8px;
  color: var(--muted); font-size: .82rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .6px;
}
.nav a:hover { background: var(--primary-tint); color: var(--primary-dark);
  text-decoration: none; }
.nav a.active { color: var(--primary-dark); }
.nav a.active::after {
  content: ""; display: block; height: 2px; margin-top: 4px;
  background: var(--accent); border-radius: 2px;
}

/* Language switcher (flag + code pills) — adapted from the northwards project */
.nw-lang { display: flex; gap: 6px; align-items: center; margin-left: 14px; }
.nw-lang-opt {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px; border-radius: 6px; line-height: 1;
  color: var(--muted); font-size: 12px; font-weight: 700; text-decoration: none;
  border: 1px solid transparent;
}
.nw-lang-opt:hover { background: var(--primary-tint); color: var(--primary-dark);
  text-decoration: none; }
.nw-lang-opt.active { background: var(--primary-tint); color: var(--primary-dark);
  border-color: var(--border-strong); }
.nw-flag { width: 20px; height: 14px; border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .2); display: block; }

.menu-toggle {
  display: none; margin-left: 10px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px;
  width: 42px; height: 38px; cursor: pointer; padding: 0;
  align-items: center; justify-content: center;
}
.menu-toggle span, .menu-toggle span::before, .menu-toggle span::after {
  content: ""; display: block; width: 20px; height: 2px;
  background: var(--ink); border-radius: 2px; position: relative;
}
.menu-toggle span::before { position: absolute; top: -6px; }
.menu-toggle span::after { position: absolute; top: 6px; }

/* ---------- Hero ---------- */
.hero {
  position: relative; color: #fff;
  background: #0a3540 center/cover no-repeat;
  border-bottom: 3px solid var(--accent);
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,32,40,.35) 0%, rgba(8,32,40,.72) 100%);
}
.hero-inner {
  position: relative; z-index: 1; max-width: var(--maxw);
  margin: 0 auto; padding: 46px 20px 30px;
}
.hero h1 { color: #fff; margin: 0 0 6px; text-shadow: 0 2px 12px rgba(0,0,0,.4); }
.hero .tagline {
  font-size: 1.05rem; color: #eaf6f8; margin: 0 0 22px;
  text-shadow: 0 1px 8px rgba(0,0,0,.5);
}
.odometer {
  display: flex; flex-wrap: wrap; gap: 12px;
}
.stat-chip {
  background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.22);
  border-radius: 10px; padding: 10px 16px; backdrop-filter: blur(2px);
  min-width: 92px;
}
.stat-chip .num {
  font-size: 1.5rem; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-chip .lbl {
  font-size: .68rem; text-transform: uppercase; letter-spacing: 1px;
  color: #d4e8eb; margin-top: 5px;
}

/* ---------- Layout blocks ---------- */
main { padding: 30px 0 50px; }
.section-title { margin: 0 0 4px; }
.section-lead { color: var(--muted); margin: 0 0 22px; max-width: 70ch; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.pad { padding: 22px; }

/* ---------- Home / news ---------- */
.newsgrid { display: grid; gap: 18px; }
.news {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; overflow: hidden;
}
.news h3 { margin: 0; }
.news-meta { color: var(--faint); font-size: .82rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; margin: 2px 0 12px; }
.news-body { color: #2c3a3e; }
.news-body p:first-child { margin-top: 0; }
.news details > summary {
  cursor: pointer; color: var(--primary); font-weight: 700;
  list-style: none; margin-top: 8px; display: inline-block;
}
.news details > summary::-webkit-details-marker { display: none; }
.news details > summary::after { content: " ▾"; }
.news details[open] > summary::after { content: " ▴"; }
.news details[open] > summary { margin-bottom: 8px; }

/* ---------- Diary ---------- */
.diary-layout { display: grid; grid-template-columns: 320px 1fr; gap: 22px;
  align-items: start; }
.stage-list-card { position: sticky; top: 76px; }
.sortbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sortbar label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.sortbar select {
  flex: 1; min-width: 120px; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); font: inherit; font-size: .85rem;
}
.stage-list { max-height: 66vh; overflow-y: auto; }
.stage-list a {
  display: flex; align-items: baseline; gap: 8px;
  padding: 9px 16px; border-bottom: 1px solid var(--border);
  color: var(--ink); font-size: .9rem;
}
.stage-list a:hover { background: var(--primary-tint); text-decoration: none; }
.stage-list a.rest { color: var(--faint); font-style: italic; }
.stage-list .n { color: var(--faint); font-variant-numeric: tabular-nums;
  min-width: 26px; text-align: right; font-size: .8rem; }
.stage-list .nm { flex: 1; }
.stage-list .v { color: var(--primary-dark); font-weight: 700; font-size: .8rem;
  white-space: nowrap; }

#map, #stage-map { width: 100%; background: #dfe7e4; }
#map { height: 74vh; min-height: 460px; border-radius: var(--radius); }
#stage-map { height: 280px; border-radius: 10px; border: 1px solid var(--border); }
.map-hint { color: var(--muted); font-size: .9rem; margin: 0 0 14px; }
.leaflet-popup-content { font: inherit; }
.leaflet-popup-content a { font-weight: 700; }

/* ---------- Stage report ---------- */
.stage-nav {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.stage-nav a { font-size: .85rem; font-weight: 700; }
.btn {
  display: inline-block; padding: 8px 14px; border-radius: 8px;
  background: var(--primary); color: #fff !important; font-weight: 700;
  font-size: .85rem; border: 0;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.ghost { background: var(--surface); color: var(--primary-dark) !important;
  border: 1px solid var(--border-strong); }
.btn.ghost:hover { border-color: var(--primary); background: var(--primary-tint); }
.btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }

.stage-head h1 { margin-bottom: 2px; }
.stage-sub { color: var(--muted); margin: 0 0 18px; font-weight: 600; }

.statgrid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px;
  margin: 0 0 22px;
}
.statgrid .cell {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 10px; text-align: center;
}
.statgrid .cell .v { font-size: 1.15rem; font-weight: 800;
  font-variant-numeric: tabular-nums; }
.statgrid .cell .k { font-size: .66rem; text-transform: uppercase;
  letter-spacing: .6px; color: var(--faint); margin-top: 4px; }

.report { font-size: 1.02rem; color: #263237; }
.report p { margin: 0 0 1em; }

/* ---------- Photo gallery ---------- */
.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px; margin: 18px 0;
}
.gallery a { display: block; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: #000; }
.gallery img { width: 100%; height: 108px; object-fit: cover;
  transition: transform .25s ease, opacity .25s ease; }
.gallery a:hover img { transform: scale(1.05); opacity: .9; }

.matlist-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr));
  gap: 14px; margin: 14px 0; }
.matlist-figs a { border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; }

/* ---------- Lightbox ---------- */
.lb {
  position: fixed; inset: 0; z-index: 2000; display: none;
  background: rgba(10, 15, 17, .93); align-items: center; justify-content: center;
}
.lb.open { display: flex; }
.lb img { max-width: 92vw; max-height: 82vh; width: auto; height: auto;
  border-radius: 4px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lb-cap {
  position: absolute; bottom: 18px; left: 0; right: 0; text-align: center;
  color: #fff; padding: 0 60px; font-size: .95rem; text-shadow: 0 1px 4px #000;
}
.lb-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.12); border: 0; color: #fff;
  width: 52px; height: 52px; border-radius: 50%; cursor: pointer;
  font-size: 1.6rem; line-height: 1; display: flex; align-items: center;
  justify-content: center;
}
.lb-btn:hover { background: rgba(255,255,255,.25); }
.lb-prev { left: 16px; } .lb-next { right: 16px; }
.lb-close { position: absolute; top: 16px; right: 18px; width: 44px; height: 44px;
  font-size: 1.4rem; }
.lb-count { position: absolute; top: 22px; left: 22px; color: #cfd8da;
  font-size: .85rem; }

/* ---------- Statistics table ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.stat { width: 100%; border-collapse: collapse; min-width: 640px;
  background: var(--surface); font-size: .9rem; }
table.stat caption { text-align: left; font-weight: 800; padding: 14px 12px;
  font-size: 1.05rem; }
table.stat th, table.stat td { padding: 9px 12px; border-bottom: 1px solid var(--border);
  text-align: right; font-variant-numeric: tabular-nums; }
table.stat thead th { background: var(--primary); color: #fff; border-bottom: 0;
  font-weight: 700; position: sticky; top: 0; }
table.stat tbody th { text-align: left; color: var(--muted); font-weight: 700; }
table.stat tbody tr:hover { background: var(--surface-2); }
table.stat td.total, table.stat th.total { background: var(--primary-tint);
  font-weight: 800; color: var(--primary-dark); }

/* ---------- Planning ---------- */
.plan-layout { display: grid; grid-template-columns: 230px 1fr; gap: 22px;
  align-items: start; }
.plan-nav { position: sticky; top: 76px; }
.plan-nav .grp { padding: 6px 0; }
.plan-nav .grp > span { display: block; padding: 8px 14px; font-size: .72rem;
  text-transform: uppercase; letter-spacing: 1px; color: var(--faint);
  font-weight: 800; }
.plan-nav a { display: block; padding: 8px 14px; color: var(--ink);
  font-size: .9rem; border-left: 3px solid transparent; }
.plan-nav a:hover { background: var(--primary-tint); text-decoration: none; }
.plan-nav a.active { border-left-color: var(--accent);
  background: var(--surface-2); color: var(--primary-dark); font-weight: 700; }
.prose { font-size: 1.02rem; color: #263237; }
.prose h3 { margin-top: 0; }
.prose ul { text-align: left; }
.prose iframe { width: 100%; max-width: 480px; border: 1px solid var(--border);
  border-radius: 8px; }

/* ---------- About ---------- */
.about-layout { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 18px;
  align-items: start; }
.about-photo { border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); box-shadow: var(--shadow); }
.about-text { text-align: left; }

/* ---------- Guestbook ---------- */
.gb-note {
  background: var(--accent-tint); border: 1px solid #f0c3ad;
  border-radius: 10px; padding: 12px 16px; color: #8a3510; margin: 0 0 20px;
  font-weight: 600;
}
.gb-list { display: grid; gap: 14px; }
.gb {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow);
}
.gb-head { display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; flex-wrap: wrap; }
.gb-name { font-weight: 800; }
.gb-date { color: var(--faint); font-size: .8rem; white-space: nowrap; }
.gb-text { margin: 8px 0 0; color: #2c3a3e; }
.gb-reply {
  margin: 12px 0 0 0; padding: 10px 14px; border-left: 3px solid var(--primary);
  background: var(--surface-2); border-radius: 0 8px 8px 0; color: #2c3a3e;
}
.gb-reply::before { content: "↳ Manuel"; display: block; font-weight: 700;
  font-size: .75rem; color: var(--primary-dark); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: .5px; }

/* ---------- Footer ---------- */
footer {
  margin-top: auto;
  border-top: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: .85rem;
}
footer .wrap { padding: 24px 20px; display: flex; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; }
footer a { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .diary-layout { grid-template-columns: 1fr; }
  .stage-list-card { position: static; }
  .stage-list { max-height: none; }
  .plan-layout { grid-template-columns: 1fr; }
  .plan-nav { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .plan-nav .grp { padding: 0; }
  .plan-nav .grp > span { display: none; }
  .about-layout { grid-template-columns: 1fr; }
  .about-photo { max-width: 320px; margin: 0 auto; }
  .statgrid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 760px) {
  .nav {
    display: none; position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; gap: 0; background: var(--surface);
    border-bottom: 1px solid var(--border); padding: 8px;
    box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px; border-radius: 8px; font-size: .9rem; }
  .nav a.active::after { display: none; }
  .nav a.active { background: var(--primary-tint); }
  .menu-toggle { display: flex; }
  .nw-lang { margin-left: auto; }
  .brand small { display: none; }
}

@media (max-width: 440px) {
  .statgrid { grid-template-columns: repeat(2, 1fr); }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .gallery img { height: 84px; }
  .stat-chip { flex: 1 1 40%; }
}
