/* =========================================================
   Hills n Thrills n Bellyaches — stylesheet
   Colours and fonts live in :root so they're easy to change.
   ========================================================= */

:root {
  --peat: #2b2620;        /* main text, dark sections */
  --moss: #4a5d3a;        /* primary accent */
  --heather: #8a6f8f;     /* secondary accent */
  --sunrise: #d9733b;     /* highlights, buttons */
  --bracken: #b9895a;
  --mist: #f4f1ea;        /* page background */
  --paper: #fffdf8;       /* cards */
  --line: #e2dccf;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;

  --max: 1120px;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--mist);
  color: var(--peat);
  line-height: 1.65;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

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

.wrap { width: min(var(--max), 92vw); margin-inline: auto; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(244, 241, 234, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; gap: 16px;
}
.logo {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.15rem;
  text-decoration: none; color: var(--peat);
  display: flex; align-items: center; gap: 10px;
  letter-spacing: -0.01em;
}
.logo svg { flex-shrink: 0; }
.logo span em { font-style: italic; color: var(--sunrise); font-weight: 600; }
.nav { display: flex; gap: 22px; }
.nav a {
  text-decoration: none; color: var(--peat);
  font-size: 0.92rem; font-weight: 500;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--sunrise); }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background: var(--peat); color: var(--mist);
  padding: 110px 0 150px;
}
.hero .contours {
  position: absolute; inset: 0; opacity: 0.18; pointer-events: none;
}
.hero .wrap { position: relative; }
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.18em;
  font-size: 0.75rem; font-weight: 600; color: var(--bracken);
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 7vw, 5.4rem);
  line-height: 1.02; letter-spacing: -0.03em;
  margin: 18px 0 22px; max-width: 14ch; font-weight: 700;
}
.hero h1 em { color: var(--sunrise); font-style: italic; font-weight: 500; }
.hero p.lede { font-size: 1.2rem; max-width: 46ch; opacity: 0.85; }
.hero .ridge {
  position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 120px;
}

.btn {
  display: inline-block; margin-top: 32px;
  background: var(--sunrise); color: #fff;
  padding: 13px 24px; border-radius: 999px;
  text-decoration: none; font-weight: 600; font-size: 0.95rem;
  transition: transform .15s ease, background .15s ease;
}
.btn:hover { background: #c4612b; color: #fff; transform: translateY(-2px); }
.btn.ghost {
  background: transparent; border: 1.5px solid currentColor; color: inherit;
  margin-left: 10px;
}
.btn.ghost:hover { background: rgba(255,255,255,.08); }

/* ---------- Stats strip ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: -56px; position: relative; z-index: 2;
  box-shadow: 0 12px 30px -18px rgba(43,38,32,.35);
}
.stat { padding: 24px 26px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: none; }
.stat .num {
  font-family: var(--font-display); font-size: 2rem; font-weight: 700;
  color: var(--moss); line-height: 1;
}
.stat .label { font-size: 0.82rem; color: #6b6458; margin-top: 6px; }

/* ---------- Sections ---------- */
section.block { padding: 90px 0; }
.section-head {
  display: flex; justify-content: space-between; align-items: end;
  gap: 20px; margin-bottom: 36px; flex-wrap: wrap;
}
.section-head h2 {
  font-family: var(--font-display); font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  letter-spacing: -0.02em; line-height: 1.1;
}

/* ---------- Post cards ---------- */
.posts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; }
.post-card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  text-decoration: none; color: inherit;
  transition: transform .2s ease, box-shadow .2s ease;
}
.post-card:hover {
  transform: translateY(-4px); color: inherit;
  box-shadow: 0 18px 36px -20px rgba(43,38,32,.45);
}
.post-card .thumb {
  aspect-ratio: 16 / 10; background: var(--moss);
  position: relative; overflow: hidden;
}
.post-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.post-card .thumb svg { width: 100%; height: 100%; }
.tag {
  position: absolute; top: 14px; left: 14px;
  background: var(--paper); color: var(--peat);
  font-size: 0.72rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; padding: 5px 10px; border-radius: 999px;
}
.post-card .body { padding: 22px 22px 24px; display: flex; flex-direction: column; flex: 1; }
.post-card .date { font-size: 0.8rem; color: #8a8273; }
.post-card h3 {
  font-family: var(--font-display); font-size: 1.35rem;
  line-height: 1.2; margin: 6px 0 10px; letter-spacing: -0.01em;
}
.post-card p { font-size: 0.95rem; color: #554f45; flex: 1; }
.metrics {
  display: flex; gap: 16px; margin-top: 18px; padding-top: 14px;
  border-top: 1px dashed var(--line); font-size: 0.82rem; color: #6b6458;
}
.metrics b { color: var(--peat); font-weight: 600; }

.post-card.featured { grid-column: span 3; flex-direction: row; }
.post-card.featured .thumb { flex: 1.3; aspect-ratio: auto; min-height: 340px; }
.post-card.featured .body { flex: 1; padding: 40px; justify-content: center; }
.post-card.featured h3 { font-size: 2rem; }

/* ---------- Bellyache-o-meter (fun rating) ---------- */
.meter { display: inline-flex; gap: 3px; vertical-align: middle; }
.meter i {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--line); display: inline-block;
}
.meter i.on { background: var(--sunrise); }

/* ---------- About teaser ---------- */
.about-teaser {
  display: grid; grid-template-columns: 1fr 1.2fr; gap: 60px; align-items: center;
}
.portrait {
  aspect-ratio: 4 / 5; border-radius: var(--radius);
  background: linear-gradient(160deg, var(--heather), var(--moss));
  display: grid; place-items: center; color: rgba(255,255,255,.75);
  font-size: 0.9rem; text-align: center; padding: 20px;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); }
.about-teaser h2 {
  font-family: var(--font-display); font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  line-height: 1.1; margin: 12px 0 18px; letter-spacing: -0.02em;
}
.about-teaser p + p { margin-top: 14px; }

/* ---------- Upcoming races ---------- */
.races { background: var(--moss); color: var(--mist); }
.races .eyebrow { color: #d6c9a8; }
.race-list { list-style: none; }
.race-list li {
  display: grid; grid-template-columns: 120px 1fr auto; gap: 24px;
  align-items: center; padding: 22px 0;
  border-bottom: 1px solid rgba(244,241,234,.2);
}
.race-list .when {
  font-family: var(--font-display); font-size: 1.1rem; font-weight: 600;
}
.race-list .name { font-size: 1.15rem; font-weight: 600; }
.race-list .where { font-size: 0.88rem; opacity: .75; }
.race-list .dist {
  background: rgba(244,241,234,.12); padding: 6px 14px;
  border-radius: 999px; font-size: 0.85rem; font-weight: 600;
}

/* ---------- Newsletter / follow ---------- */
.follow {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 50px; text-align: center;
}
.follow h2 { font-family: var(--font-display); font-size: 2rem; margin-bottom: 10px; }
.follow form {
  display: flex; gap: 10px; max-width: 460px; margin: 26px auto 0;
}
.follow input {
  flex: 1; padding: 13px 18px; border-radius: 999px;
  border: 1.5px solid var(--line); font: inherit; background: var(--mist);
}
.follow input:focus { outline: 2px solid var(--sunrise); border-color: transparent; }
.follow button {
  border: none; cursor: pointer; font: inherit; font-weight: 600;
  background: var(--sunrise); color: #fff; padding: 13px 24px; border-radius: 999px;
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--peat); color: rgba(244,241,234,.75);
  padding: 50px 0; margin-top: 90px; font-size: 0.9rem;
}
.site-footer .wrap {
  display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.site-footer a { color: var(--mist); text-decoration: none; margin-left: 18px; }
.site-footer a:hover { color: var(--sunrise); }

/* =========================================================
   Single post page
   ========================================================= */
.post-hero {
  background: var(--peat); color: var(--mist);
  padding: 80px 0 70px; position: relative; overflow: hidden;
}
.post-hero .contours { position: absolute; inset: 0; opacity: .15; }
.post-hero .wrap { position: relative; max-width: 780px; }
.post-hero h1 {
  font-family: var(--font-display); font-size: clamp(2.2rem, 5.5vw, 3.8rem);
  line-height: 1.05; letter-spacing: -0.025em; margin: 16px 0;
}
.post-hero .meta { opacity: .75; font-size: 0.92rem; }
.back { color: var(--bracken); text-decoration: none; font-size: 0.88rem; }
.back:hover { color: var(--sunrise); }

.race-card {
  max-width: 780px; margin: -36px auto 0; position: relative; z-index: 2;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  display: grid; grid-template-columns: repeat(5, 1fr);
  box-shadow: 0 12px 30px -18px rgba(43,38,32,.35);
}
.race-card > div { padding: 18px 20px; border-right: 1px solid var(--line); }
.race-card > div:last-child { border-right: none; }
.race-card .k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .1em; color: #8a8273; }
.race-card .v { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; margin-top: 2px; }

.elevation {
  max-width: 780px; margin: 40px auto 0; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px 12px;
}
.elevation .k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .1em; color: #8a8273; }

article.prose { max-width: 700px; margin: 50px auto 0; font-size: 1.1rem; }
article.prose p { margin-bottom: 1.3em; }
article.prose h2 {
  font-family: var(--font-display); font-size: 1.8rem;
  margin: 1.8em 0 .6em; letter-spacing: -0.01em; line-height: 1.2;
}
article.prose blockquote {
  border-left: 4px solid var(--sunrise); padding: 6px 0 6px 22px;
  font-family: var(--font-display); font-style: italic; font-size: 1.35rem;
  margin: 1.6em 0; color: var(--moss);
}
article.prose figure { margin: 2em 0; }
article.prose figure .ph {
  aspect-ratio: 16/9; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--bracken), var(--moss));
  display: grid; place-items: center; color: rgba(255,255,255,.8); font-size: .9rem;
}
article.prose figcaption { font-size: 0.85rem; color: #8a8273; margin-top: 8px; text-align: center; }
article.prose ul { margin: 0 0 1.3em 1.2em; }
article.prose li { margin-bottom: .4em; }

.callout {
  background: #f7ebe0; border-radius: var(--radius); padding: 22px 26px; margin: 2em 0;
}
.callout strong { color: var(--sunrise); }

.post-nav {
  max-width: 700px; margin: 60px auto 0; padding-top: 30px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 20px; font-size: .95rem;
}
.post-nav a { text-decoration: none; font-weight: 600; }

/* ---------- About page ---------- */
.page-intro { max-width: 760px; }
.page-intro h1 {
  font-family: var(--font-display); font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.05; letter-spacing: -0.03em; margin: 14px 0 22px;
}
.kit { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 30px; }
.kit div {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
}
.kit h3 { font-family: var(--font-display); font-size: 1.1rem; margin-bottom: 6px; }
.kit p { font-size: .92rem; color: #554f45; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .posts { grid-template-columns: 1fr 1fr; }
  .post-card.featured { grid-column: span 2; flex-direction: column; }
  .post-card.featured .thumb { min-height: 240px; }
  .post-card.featured .body { padding: 26px; }
  .about-teaser { grid-template-columns: 1fr; gap: 36px; }
  .portrait { max-width: 360px; }
  .kit { grid-template-columns: 1fr; }
  .race-card { grid-template-columns: repeat(3, 1fr); }
  .race-card > div:nth-child(3) { border-right: none; }
  .race-card > div:nth-child(n+4) { border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .nav { gap: 14px; }
  .nav a.hide-sm { display: none; }
  .logo span { font-size: 0.95rem; }
  .hero { padding: 70px 0 120px; }
  .btn.ghost { margin-left: 0; margin-top: 12px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(2) { border-right: none; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .posts { grid-template-columns: 1fr; }
  .post-card.featured { grid-column: span 1; }
  .race-list li { grid-template-columns: 1fr auto; }
  .race-list .when { grid-column: 1 / -1; font-size: .95rem; }
  .follow { padding: 34px 22px; }
  .follow form { flex-direction: column; }
  .race-card { grid-template-columns: 1fr 1fr; }
  .race-card > div { border-right: 1px solid var(--line) !important; }
  .race-card > div:nth-child(2n) { border-right: none !important; }
  .race-card > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .site-footer a { margin: 0 14px 0 0; }
}

/* ---------- Additions for the CMS version ---------- */
.prose-lite p + p { margin-top: 14px; }
.posts .post-card.featured:only-child { grid-column: 1 / -1; }
article.prose img { border-radius: var(--radius); }

/* ---------- Hero background photo (set in dashboard) ---------- */
.hero.has-photo {
  background:
    linear-gradient(180deg, rgba(43,38,32,.55) 0%, rgba(43,38,32,.75) 100%),
    var(--hero-photo) center / cover no-repeat,
    var(--peat);
}
.hero.has-photo .contours { opacity: 0.08; }
