/* ============================================================
   Bells Canyon Trail Guide — shared stylesheet
   ============================================================ */

:root {
  color-scheme: light;
  /* Surfaces & ink */
  --bg: #f7f6f1;
  --surface: #fcfcfb;
  --surface-2: #f0efe8;
  --ink: #1c1b18;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);

  /* Brand */
  --pine: #235c42;
  --pine-deep: #17402f;
  --pine-wash: #e4ede7;
  --water: #2a78d6;
  --water-wash: #e3edfa;
  --amber: #b4690e;
  --amber-wash: #f7ecdc;
  --granite: #6d6a63;

  /* Chart series (validated palette, light mode) */
  --series-green: #008300;
  --series-blue: #2a78d6;
  --series-orange: #eb6834;
  --series-aqua: #1baf7a;
  --series-yellow: #eda100;

  /* Status (fixed) */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 18, 0.06), 0 8px 24px rgba(20, 24, 18, 0.07);
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121410;
    --surface: #1b1e19;
    --surface-2: #23261f;
    --ink: #f2f1ea;
    --ink-2: #c3c2b7;
    --muted: #918f88;
    --hairline: #2e312a;
    --border: rgba(255, 255, 255, 0.10);

    --pine: #5aa37f;
    --pine-deep: #7dbd9c;
    --pine-wash: #1f2f26;
    --water: #3987e5;
    --water-wash: #1c2735;
    --amber: #e0964a;
    --amber-wash: #33271a;
    --granite: #a5a29a;

    --series-green: #008300;
    --series-blue: #3987e5;
    --series-orange: #d95926;
    --series-aqua: #199e70;
    --series-yellow: #c98500;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; }

a { color: var(--pine); }
a:hover { color: var(--pine-deep); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  margin: 0 0 0.5em;
  text-wrap: balance;
}

h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.25rem; }

p { margin: 0 0 1em; }

.container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---------- Header / nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  display: block;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-2);
  font-size: 0.95rem;
  font-weight: 500;
}

.nav-links a:hover { background: var(--surface-2); color: var(--ink); }

.nav-links a[aria-current="page"] {
  background: var(--pine-wash);
  color: var(--pine-deep);
  font-weight: 600;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 800px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    background: var(--surface);
    border-bottom: 1px solid var(--hairline);
    padding: 0.6rem 1rem 0.9rem;
    box-shadow: var(--shadow);
  }
  .nav-links.open { display: flex; }
  .nav-links a { border-radius: var(--radius-sm); padding: 0.65rem 0.75rem; }
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--pine-wash), var(--bg) 90%);
  border-bottom: 1px solid var(--hairline);
}

.hero-inner {
  position: relative;
  padding: 3.5rem 0 0;
  text-align: center;
}

.hero .kicker {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pine);
  margin-bottom: 0.75rem;
}

.hero p.lede {
  max-width: 640px;
  margin: 0 auto 1.5rem;
  font-size: 1.15rem;
  color: var(--ink-2);
}

.hero-scene { display: block; width: 100%; margin-top: 1rem; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1rem;
}

/* Hero side photos */
.hero-layout {
  display: grid;
  grid-template-areas: "left copy right";
  grid-template-columns: 1fr minmax(0, 620px) 1fr;
  gap: 1.5rem 2.25rem;
  align-items: center;
}
.hero-copy { grid-area: copy; }
.hero-photo {
  display: block;
  position: relative;
  max-width: 250px;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 5px solid var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}
.hero-photo.left  { grid-area: left;  justify-self: end;   transform: rotate(-3deg); }
.hero-photo.right { grid-area: right; justify-self: start; transform: rotate(3deg); }
.hero-photo:hover { transform: rotate(0deg) scale(1.03); }
.hero-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}
.hero-photo .hp-label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 1.4rem 0.75rem 0.55rem;
  background: linear-gradient(transparent, rgba(12, 18, 14, 0.65));
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.02em;
}
@media (max-width: 940px) {
  .hero-layout {
    grid-template-areas:
      "copy copy"
      "left right";
    grid-template-columns: 1fr 1fr;
  }
  .hero-photo.left, .hero-photo.right {
    justify-self: center;
    max-width: min(185px, 42vw);
  }
}

/* Page hero (interior pages) */
.page-hero {
  background: linear-gradient(180deg, var(--pine-wash), var(--bg));
  border-bottom: 1px solid var(--hairline);
  padding: 2.75rem 0 2rem;
}
.page-hero .kicker {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pine);
}
.page-hero p { max-width: 700px; color: var(--ink-2); margin-bottom: 0; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.98rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary { background: var(--pine); color: #fff; }
.btn-primary:hover { background: var(--pine-deep); color: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary { color: #0e1511; }
  :root:not([data-theme="light"]) .btn-primary:hover { color: #0e1511; }
}

.btn-ghost { border-color: var(--hairline); color: var(--ink); background: var(--surface); }
.btn-ghost:hover { background: var(--surface-2); }

/* ---------- Layout blocks ---------- */

.section { padding: 3rem 0; }
.section + .section { padding-top: 0.5rem; }

.section-head { max-width: 700px; margin-bottom: 1.75rem; }
.section-head .kicker {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pine);
}
.section-head p { color: var(--ink-2); margin-bottom: 0; }

.grid {
  display: grid;
  gap: 1.1rem;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

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

.card h3 { margin-top: 0; }

.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.card-link {
  font-weight: 600;
  text-decoration: none;
}

/* Stat tiles */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  box-shadow: var(--shadow);
}
.stat-tile .stat-label {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-tile .stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.15;
}
.stat-tile .stat-note { font-size: 0.85rem; color: var(--ink-2); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-easy      { background: var(--pine-wash);  color: var(--pine-deep); }
.badge-moderate  { background: var(--water-wash); color: var(--water); }
.badge-hard      { background: var(--amber-wash); color: var(--amber); }
.badge-veryhard  { background: color-mix(in srgb, var(--status-critical) 14%, var(--surface)); color: var(--status-critical); }

/* Callouts */
.callout {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-left: 4px solid var(--pine);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 1rem 1.2rem;
  margin: 1.25rem 0;
}
.callout .icon { font-size: 1.3rem; line-height: 1.4; flex: none; }
.callout p { margin: 0; }
.callout strong { display: block; margin-bottom: 0.15rem; }
.callout-warning { border-left-color: var(--status-serious); }
.callout-danger  { border-left-color: var(--status-critical); }
.callout-info    { border-left-color: var(--water); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  min-width: 560px;
}

th, td {
  text-align: left;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}

thead th {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
}

tbody tr:last-child td { border-bottom: none; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Chart panel ---------- */

.chart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.25rem 0.9rem;
}
.chart-panel .chart-title { font-weight: 700; font-size: 1.02rem; margin: 0 0 0.1rem; font-family: var(--font-body); }
.chart-panel .chart-sub { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.75rem; }
.chart-panel figure { margin: 0; }

#elevation-chart { position: relative; }
#elevation-chart svg { display: block; width: 100%; height: auto; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px));
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 5;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .tt-title { font-weight: 700; }
.chart-tooltip .tt-row { color: var(--ink-2); font-variant-numeric: tabular-nums; }

details.data-table { margin-top: 0.75rem; }
details.data-table summary { cursor: pointer; font-size: 0.9rem; color: var(--ink-2); font-weight: 600; }
details.data-table .table-wrap { margin-top: 0.75rem; box-shadow: none; }

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

.map-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.map-panel svg { display: block; width: 100%; height: auto; }

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  padding: 0.85rem 0.5rem 0.25rem;
  font-size: 0.88rem;
  color: var(--ink-2);
}
.map-legend .key { display: inline-flex; align-items: center; gap: 0.5rem; }
.map-legend .swatch {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
  flex: none;
}
.map-legend .swatch.line { border-radius: 3px; height: 5px; width: 22px; border: none; }

/* ---------- Destination detail sections ---------- */

.dest {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  padding: 2rem 0;
  border-top: 1px solid var(--hairline);
}
.dest:first-of-type { border-top: none; }
@media (max-width: 720px) { .dest { grid-template-columns: 1fr; gap: 0.75rem; } }

.dest-stats { font-size: 0.92rem; color: var(--ink-2); }
.dest-stats dl { margin: 0.75rem 0 0; display: grid; gap: 0.35rem; }
.dest-stats dt { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.dest-stats dd { margin: 0 0 0.4rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

.dest-body h3 { margin-top: 0; font-size: 1.5rem; }
.dest-body .waypoint-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8em; height: 1.8em;
  border-radius: 50%;
  background: var(--pine);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  margin-right: 0.5rem;
  vertical-align: 0.15em;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dest-body .waypoint-num { color: #0e1511; }
}

/* ---------- Checklist ---------- */

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.checklist li { padding-left: 1.7rem; position: relative; }
.checklist li::before {
  content: "✓";
  position: absolute;
  left: 0; top: 0;
  font-weight: 700;
  color: var(--pine);
}

ul.rules { padding-left: 1.2rem; display: grid; gap: 0.45rem; margin: 0; }

/* ---------- FAQ ---------- */

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.2rem;
  margin-bottom: 0.7rem;
}
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 0.7rem 0 0; color: var(--ink-2); }

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--hairline);
  background: var(--surface);
  padding: 2.5rem 0 2rem;
  font-size: 0.9rem;
  color: var(--ink-2);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
}
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr; } }

.site-footer h4 { font-size: 1rem; margin-bottom: 0.6rem; font-family: var(--font-body); font-weight: 700; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.site-footer a { color: var(--ink-2); }
.site-footer a:hover { color: var(--pine); }

.footer-note {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hairline);
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------- Photo gallery ---------- */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.1rem;
}
@media (max-width: 900px) { .gallery-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .gallery-grid { grid-template-columns: 1fr; } }

.photo-card {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.photo-card .photo-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.photo-card figcaption {
  padding: 0.75rem 1rem 0.9rem;
  font-size: 0.88rem;
  color: var(--ink-2);
  line-height: 1.5;
}

.photo-card .credit,
.lightbox .credit {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}
.photo-card .credit a, .lightbox .credit a { color: var(--muted); }
.photo-card .credit a:hover, .lightbox .credit a:hover { color: var(--pine); }

dialog.lightbox {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  max-width: min(1100px, 94vw);
  width: 100%;
  box-shadow: var(--shadow);
}
dialog.lightbox::backdrop { background: rgba(8, 10, 8, 0.78); }

.lightbox img {
  display: block;
  width: 100%;
  max-height: 76vh;
  object-fit: contain;
  background: #101210;
}

.lightbox .lb-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.8rem 1.1rem 0.9rem;
  font-size: 0.92rem;
  color: var(--ink-2);
}

.lightbox .lb-close {
  flex: none;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.lightbox .lb-close:hover { background: var(--pine-wash); }
