/* ===== Tokens ===== */
:root {
  --paper: #F3F6F4;
  --paper-raised: #FFFFFF;
  --ink: #1E2B27;
  --ink-soft: #4B5B55;
  --accent: #1F6E7A;
  --warm: #C9862E;
  --line: #D8DFDA;
  --line-strong: #B9C4BE;
  --shadow: 0 1px 2px rgba(20, 32, 28, .06), 0 8px 20px -12px rgba(20, 32, 28, .18);
  --shadow-lg: 0 4px 10px rgba(20, 32, 28, .08), 0 24px 48px -20px rgba(20, 32, 28, .28);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131C19;
    --paper-raised: #182420;
    --ink: #E7EEEA;
    --ink-soft: #9FB0A9;
    --accent: #57BCC7;
    --warm: #E3A756;
    --line: #28352F;
    --line-strong: #374841;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 24px -14px rgba(0, 0, 0, .6);
    --shadow-lg: 0 4px 14px rgba(0, 0, 0, .5), 0 30px 60px -24px rgba(0, 0, 0, .7);
  }
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Serif 4", Georgia, serif;
  line-height: 1.55;
}
img, video { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3 {
  font-family: "Big Shoulders Display", "Arial Narrow", sans-serif;
  font-weight: 800;
  letter-spacing: .01em;
  text-wrap: balance;
  margin: 0;
}
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ===== Site header / footer ===== */
.site-header {
  padding: 32px 0 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 40px;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.site-header a.brand {
  text-decoration: none;
  display: inline-block;
}
.site-header h1 { font-size: clamp(28px, 4vw, 38px); }
.site-header .tagline { color: var(--ink-soft); font-size: 15px; margin-top: 6px; }

.site-socials { display: flex; gap: 8px; flex-wrap: wrap; }
.site-socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  color: var(--ink-soft);
  transition: border-color .15s ease, color .15s ease, transform .15s ease;
}
.site-socials a svg { width: 17px; height: 17px; }
.site-socials a:hover, .site-socials a:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
}
/* AllTrails' mark is near-black — invisible on the dark theme's near-black
   button surface, so relight it instead of leaving it unreadable. */
@media (prefers-color-scheme: dark) {
  .site-socials a[data-social="alltrails"] svg { fill: #E7EEEA; }
}

.site-footer {
  margin-top: 64px;
  padding: 28px 0 48px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: .04em;
}
.site-footer a { color: var(--accent); text-decoration: none; }

/* ===== Homepage: Basecamp Grid ===== */
.trip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  padding-bottom: 64px;
}
.trip-card {
  display: block;
  position: relative;
  text-decoration: none;
  color: inherit;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.trip-card:hover, .trip-card:focus-visible {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
  z-index: 1;
}
.trip-card .cover {
  aspect-ratio: 4 / 3;
  background: var(--line);
  object-fit: cover;
  width: 100%;
}
.trip-card .body { padding: 16px 18px 18px; }
.trip-card h2 { font-size: 22px; margin-bottom: 4px; }
.trip-card .location { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 12px; }
.trip-card .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: .02em;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  padding: 3px 9px;
  border-radius: 100px;
  white-space: nowrap;
}
.chip.warm { color: var(--warm); border-color: var(--warm); }

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-soft);
  margin-bottom: 64px;
}
.empty-state code {
  font-family: "JetBrains Mono", monospace;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
}

/* ===== Trip page: Ridgeline ===== */
.trip-topbar { display: flex; justify-content: flex-end; padding: 24px 0 0; }
.trip-title { padding: 20px 0 8px; }
.trip-title h1 { font-size: clamp(34px, 6vw, 58px); }

.stat-bar {
  background: var(--paper-raised);
  border-bottom: 1px solid var(--line);
}
.stat-bar .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  padding: 22px 24px;
}
.stat-bar .stat b {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 19px;
  color: var(--ink);
}
.stat-bar .stat span {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 2px;
}

.summary {
  max-width: 68ch;
  font-size: 17.5px;
  color: var(--ink-soft);
  padding: 32px 0 8px;
}

.route-section { padding: 24px 0 12px; }
.route-section h2 { font-size: 15px; }
.route-preview {
  display: block;
  position: relative;
  margin-top: 14px;
  width: 100%;
  max-width: 380px;
  aspect-ratio: 16 / 9;
  border: 0;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #000;
  box-shadow: var(--shadow-lg);
}
.route-preview img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; }
.route-preview:hover img { transform: scale(1.04); }
.route-preview-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  pointer-events: none;
}
.route-preview-play svg { width: 40px; height: 40px; filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .5)); }

/* ===== Trip gallery: grid / slideshow / lightbox ===== */
.gallery-section { padding: 40px 0 24px; }
.gallery-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
}
.gallery-count {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.gallery-controls-right { display: flex; gap: 8px; }
.gallery-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: .04em;
  padding: 7px 13px;
  border-radius: 100px;
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.gallery-view-btn svg { width: 14px; height: 14px; }
.gallery-view-btn:hover { border-color: var(--accent); color: var(--ink); }
.gallery-view-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.gallery-grid[hidden], .slideshow-view[hidden], .lightbox[hidden] { display: none !important; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.gallery-item {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 0;
  padding: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--line);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.gallery-item-img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; }
.gallery-item:hover .gallery-item-img { transform: scale(1.04); }
.gallery-item-play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  pointer-events: none;
}
.gallery-item-play svg { width: 34px; height: 34px; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .5)); }
.gallery-item-badge {
  position: absolute; top: 8px; right: 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: rgba(10, 16, 14, .65);
  color: #fff;
  padding: 3px 8px;
  border-radius: 100px;
}

.nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  color: var(--ink);
  cursor: pointer;
}
.nav-btn svg { width: 18px; height: 18px; }
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Slideshow: inline view that replaces the grid */
.slideshow-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.slideshow-media-wrap {
  position: relative;
  width: 100%;
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.slideshow-media { max-width: 100%; max-height: 70vh; width: auto; height: auto; }
.slideshow-side-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, .35);
  border-color: rgba(255, 255, 255, .25);
  color: #fff;
}
.slideshow-side-nav:hover { background: rgba(0, 0, 0, .55); color: #fff; border-color: rgba(255, 255, 255, .5); }
.slideshow-side-prev { left: 16px; }
.slideshow-side-next { right: 16px; }
.slideshow-info { text-align: center; max-width: 68ch; }
.slideshow-date {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.slideshow-caption { margin-top: 6px; font-size: 15px; color: var(--ink-soft); font-style: italic; }
.slideshow-counter { margin-top: 8px; font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--ink-soft); }
.slideshow-nav { display: flex; gap: 12px; }

/* Fullscreen lightbox overlay, shared by grid clicks and slideshow expand */
body.gallery-lightbox-open { overflow: hidden; }
.lightbox {
  position: fixed; inset: 0;
  z-index: 1000;
  background: rgba(8, 12, 10, .96);
  display: flex;
  flex-direction: column;
}
.lightbox-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
}
.lightbox-topbar-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lightbox-trip-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: .03em;
  color: rgba(255, 255, 255, .4);
}
.lightbox-counter {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: .08em;
  color: rgba(255, 255, 255, .75);
}
.lightbox-close {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .2);
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.lightbox-close svg { width: 16px; height: 16px; }
.lightbox-close:hover { background: rgba(255, 255, 255, .1); }
.lightbox-media-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
  padding: 0 24px;
}
.lightbox-media { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-prev, .lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, .35);
  border-color: rgba(255, 255, 255, .25);
  color: #fff;
}
.lightbox-prev:hover, .lightbox-next:hover { background: rgba(0, 0, 0, .55); color: #fff; border-color: rgba(255, 255, 255, .5); }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-info {
  padding: 12px 24px 24px;
  text-align: center;
  color: #fff;
}
.lightbox-date {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .6);
}
.lightbox-caption {
  margin-top: 6px;
  font-size: 14.5px;
  font-style: italic;
  color: rgba(255, 255, 255, .85);
  max-width: 68ch;
  margin-left: auto;
  margin-right: auto;
}

.back-link {
  display: inline-block;
  margin: 8px 0 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  letter-spacing: .04em;
  color: var(--accent);
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

@media (max-width: 560px) {
  .stat-bar .wrap { gap: 18px 26px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
  .slideshow-side-prev { left: 8px; }
  .slideshow-side-next { right: 8px; }
}
