:root {
  --bg: #0e0f10;
  --bg-elev: #16181a;
  --fg: #ececec;
  --fg-mute: #9aa0a6;
  --accent: #c9a96e;
  --line: #24272a;
  --max-w: 1400px;
  --gap: 14px;
  --radius: 4px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

/* ───────── Header ───────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(14, 15, 16, 0.85);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--fg);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  font-family: var(--font-serif);
  font-size: 22px;
  letter-spacing: 0.02em;
}
.brand-sub {
  color: var(--fg-mute);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.primary-nav {
  display: flex;
  gap: clamp(12px, 2.5vw, 28px);
  justify-content: center;
  flex-wrap: wrap;
}
.primary-nav a {
  color: var(--fg);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 2px;
  border-bottom: 1px solid transparent;
}
.primary-nav a:hover {
  border-bottom-color: var(--accent);
  text-decoration: none;
}

/* ───────── Hero ───────── */
.hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: clamp(48px, 9vw, 110px) clamp(16px, 4vw, 40px) clamp(24px, 5vw, 48px);
  text-align: center;
}
.hero-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(36px, 7vw, 72px);
  margin: 0 0 12px;
  letter-spacing: 0.01em;
}
.hero-tag {
  color: var(--fg-mute);
  font-size: clamp(15px, 1.6vw, 18px);
  margin: 0;
}

/* ───────── Sections ───────── */
.portfolio-section,
.news-section,
.contact,
.teaser {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: clamp(40px, 6vw, 80px) clamp(16px, 4vw, 40px);
  border-top: 1px solid var(--line);
}
.section-head {
  margin-bottom: clamp(20px, 3vw, 36px);
}
.section-head h2,
.contact h2,
.teaser h2,
.news-section h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(26px, 4vw, 40px);
  margin: 0 0 6px;
}
.section-head p,
.contact > p,
.teaser p {
  color: var(--fg-mute);
  margin: 0;
}

/* ───────── Gallery (responsive grid) ───────── */
.gallery {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), 1fr);
  gap: var(--gap);
}

@media (max-width: 1100px) { .gallery { --cols: 3; } }
@media (max-width: 820px)  { .gallery { --cols: 2; } }
@media (max-width: 520px)  { .gallery { --cols: 1; gap: 10px; } }
@media (min-width: 1500px) { .gallery { --cols: 4; } }

.tile {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--bg-elev);
  border-radius: var(--radius);
  cursor: zoom-in;
  aspect-ratio: 3 / 2;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 600ms ease, opacity 400ms ease;
  opacity: 0;
}
.tile img.loaded { opacity: 1; }
.tile:hover img { transform: scale(1.035); }

.tile-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 10px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.6), rgba(0,0,0,0));
  color: var(--fg);
  font-size: 13px;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}
.tile:hover .tile-caption,
.tile:focus-visible .tile-caption { opacity: 1; }

/* ───────── Contact ───────── */
.contact-list {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: grid;
  gap: 12px;
  max-width: 480px;
}
.contact-list li {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: baseline;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.contact-label {
  color: var(--fg-mute);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

/* ───────── News ───────── */
.news-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 24px;
}
.news-item {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.news-item:last-child { border-bottom: 0; }
.news-date {
  color: var(--fg-mute);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
}
.news-title {
  font-family: var(--font-serif);
  font-size: clamp(18px, 2vw, 22px);
  margin: 0 0 6px;
  line-height: 1.3;
}
.news-title a { color: var(--fg); }
.news-title a:hover { color: var(--accent); text-decoration: none; }
.news-lede {
  color: var(--fg-mute);
  margin: 0 0 6px;
  font-size: 15px;
}
.news-more {
  margin-top: 18px;
  color: var(--fg-mute);
  font-size: 14px;
}
@media (max-width: 640px) {
  .news-item { grid-template-columns: 1fr; gap: 4px; }
}

/* ───────── News post page ───────── */
.news-post {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(40px, 6vw, 80px) clamp(16px, 4vw, 40px);
}
.post-head { margin-bottom: clamp(24px, 4vw, 40px); }
.post-date {
  color: var(--fg-mute);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin: 0 0 12px;
  font-variant-numeric: tabular-nums;
}
.post-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(28px, 5vw, 44px);
  margin: 0;
  line-height: 1.2;
}
.post-body {
  font-size: 17px;
  line-height: 1.7;
}
.post-body h2, .post-body h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  margin-top: 1.6em;
}
.post-body h2 { font-size: 24px; }
.post-body h3 { font-size: 20px; }
.post-body p  { margin: 0 0 1.1em; }
.post-body ul, .post-body ol { margin: 0 0 1.1em 1.2em; }
.post-body code {
  background: var(--bg-elev);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.92em;
}
.post-body pre {
  background: var(--bg-elev);
  padding: 14px 16px;
  border-radius: var(--radius);
  overflow-x: auto;
}
.post-back {
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* Post gallery: same .gallery/.tile shapes as the home portfolio, plus a
   heading above. Wrapping section gives the post body room to breathe. */
.post-gallery {
  margin: 2.4em 0 1.6em;
}
.post-gallery-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(20px, 2.4vw, 26px);
  margin: 0 0 14px;
}

/* GPX route map at the top of a news post. */
.post-map {
  margin: 0 0 1.8em;
}
.post-map img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  background: var(--bg-elev);
}
.post-map figcaption {
  margin-top: 6px;
  color: var(--fg-mute);
  font-size: 12px;
  text-align: right;
}
.post-map figcaption a {
  color: var(--fg-mute);
  text-decoration: underline;
}

/* Inline download link in a post body. */
.post-download {
  margin: 1.8em 0;
  padding: 14px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.post-download .download-link {
  color: var(--accent);
  font-weight: 600;
}
.post-download .download-meta {
  color: var(--fg-mute);
  font-size: 13px;
  margin-left: 8px;
}
.post-download .lock {
  margin: 0 4px;
}

/* Responsive 16:9 iframe for embedded videos (YouTube / Vimeo). */
.video-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  margin: 1.6em 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elev);
}
.video-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* ───────── Footer ───────── */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px clamp(16px, 4vw, 40px);
  color: var(--fg-mute);
  font-size: 13px;
  text-align: center;
}

/* ───────── Lightbox ───────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: clamp(16px, 4vw, 40px);
}
.lightbox.open { display: flex; }
.lb-stage {
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
#lb-img {
  max-width: 100%;
  /* Reserve room for caption + padding. JS adjusts on the fly via --vh */
  max-height: calc(var(--vh, 100vh) - 120px);
  object-fit: contain;
  box-shadow: 0 10px 60px rgba(0,0,0,0.6);
}
#lb-caption {
  color: var(--fg-mute);
  font-size: 13px;
  text-align: center;
}
.lb-close, .lb-nav {
  position: absolute;
  background: transparent;
  border: 0;
  color: var(--fg);
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
  padding: 12px 16px;
  opacity: 0.7;
  transition: opacity 150ms ease;
}
.lb-close:hover, .lb-nav:hover { opacity: 1; }
.lb-close { top: 8px; right: 8px; font-size: 30px; }
.lb-prev { left: 8px;  top: 50%; transform: translateY(-50%); }
.lb-next { right: 8px; top: 50%; transform: translateY(-50%); }

@media (max-width: 520px) {
  .lb-prev, .lb-next { font-size: 28px; padding: 8px 10px; }
}

/* ───────── Mobile nav tweaks ───────── */
@media (max-width: 640px) {
  .site-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "nav";
    gap: 8px 16px;
  }
  .brand { grid-area: brand; }
  .primary-nav { grid-area: nav; justify-content: flex-start; }
  .brand-sub { display: none; }
}
