/* ============ Tokens ============ */
:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-2: #eef2ea;
  --ink: #17251d;
  --ink-2: #4b5a51;
  --line: #dfe4da;
  --brand: #1f4d3a;
  --brand-2: #2f6b50;
  --brand-ink: #ffffff;
  --accent: #c8642c;
  --sun: #f2b54a;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --easy: #2e8b57;
  --moderate: #c98a12;
  --hard: #c8642c;
  --expert: #8e2c48;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20,40,30,.06), 0 8px 24px rgba(20,40,30,.08);
  --font-display: "Fraunces", Georgia, serif;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1612; --surface: #16201a; --surface-2: #1c2a22; --ink: #e8efe9; --ink-2: #a6b5ab;
    --line: #2a3a30; --brand: #7cc4a0; --brand-2: #5aab84; --brand-ink: #0f1612;
    --danger-bg: #3a1c1a; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1612; --surface: #16201a; --surface-2: #1c2a22; --ink: #e8efe9; --ink-2: #a6b5ab;
  --line: #2a3a30; --brand: #7cc4a0; --brand-2: #5aab84; --brand-ink: #0f1612;
  --danger-bg: #3a1c1a; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

/* ============ Base ============ */
* { 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; }
img, svg { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-2); }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
main { min-height: 70vh; outline: none; }
.section { padding: 64px 0; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.section-head p { margin: 0; max-width: 560px; }
.eyebrow { font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; display: block; }

/* ============ Buttons ============ */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 12px 22px; font: 600 .95rem var(--font); cursor: pointer; background: var(--brand); color: var(--brand-ink); transition: transform .15s, background .15s; text-decoration: none !important; }
.btn:hover { background: var(--brand-2); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-light { background: #fff; color: #1f4d3a; }
.btn-light:hover { background: #f0f4ef; }
.btn-outline-light { background: transparent; color: #fff; border: 1.5px solid rgba(255,255,255,.6); }
.btn-outline-light:hover { background: rgba(255,255,255,.12); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-sm { padding: 8px 16px; font-size: .88rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ============ Nav ============ */
.nav { 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(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--brand); font-weight: 500; font-size: 1.15rem; text-decoration: none !important; }
.brand b { font-weight: 700; margin-left: 2px; }
.brand span { color: var(--ink); }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a { color: var(--ink-2); font-weight: 500; padding: 8px 12px; border-radius: 8px; text-decoration: none; }
.nav-links a:hover, .nav-links a.active { color: var(--ink); background: var(--surface-2); }
.nav-links .nav-sos { color: var(--danger); }
.nav-toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--ink); margin: 5px 0; border-radius: 2px; }
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav-links { position: absolute; top: 68px; left: 0; right: 0; flex-direction: column; align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--line); padding: 12px 16px 20px; display: none; }
  .nav-links.open { display: flex; }
  .nav-links .btn { justify-content: center; margin-top: 8px; }
}

/* ============ Hero ============ */
.hero { position: relative; color: #fff; overflow: hidden; background: linear-gradient(180deg, #f6c27a 0%, #e98b5a 32%, #7a5a7d 62%, #2b3f4f 100%); }
.hero-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-content { position: relative; padding: 110px 0 170px; max-width: 720px; }
.hero h1 { color: #fff; text-shadow: 0 2px 30px rgba(0,0,0,.25); }
.hero p { font-size: 1.15rem; max-width: 560px; color: rgba(255,255,255,.92); }
.hero-ctas { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.hero-stats { position: relative; margin-top: -70px; z-index: 2; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.stat { padding: 22px 24px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.9rem; color: var(--brand); }
.stat span { color: var(--ink-2); font-size: .9rem; }
@media (max-width: 700px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .hero-content { padding: 72px 0 140px; }
}

/* ============ Page header ============ */
.page-head { background: var(--brand); color: #fff; padding: 56px 0 48px; position: relative; overflow: hidden; }
:root[data-theme="dark"] .page-head { background: #1a3a2c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .page-head { background: #1a3a2c; } }
.page-head h1 { color: #fff; font-size: clamp(2rem, 4vw, 3rem); }
.page-head p { color: rgba(255,255,255,.85); max-width: 620px; margin: 0; }
.page-head .eyebrow { color: var(--sun); }
.page-head.danger { background: #8f2a20; }

/* ============ Cards / grids ============ */
.grid { display: grid; gap: 22px; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
@media (max-width: 400px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.card-link { color: inherit; text-decoration: none !important; transition: transform .2s; }
.card-link:hover { transform: translateY(-4px); }
.card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-body h3 { margin: 0; }
.card-body p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.card-foot { display: flex; gap: 14px; flex-wrap: wrap; font-size: .87rem; color: var(--ink-2); margin-top: auto; padding-top: 10px; }
.card-foot span { display: inline-flex; align-items: center; gap: 5px; }
.trail-img { aspect-ratio: 16/10; position: relative; overflow: hidden; background: var(--surface-2); }
.trail-img img, .trail-img svg { width: 100%; height: 100%; object-fit: cover; }
.trail-img .badge { position: absolute; top: 12px; left: 12px; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; letter-spacing: .02em; color: #fff; }
.badge-Easy { background: var(--easy); }
.badge-Moderate { background: var(--moderate); }
.badge-Hard { background: var(--hard); }
.badge-Expert { background: var(--expert); }
.chip { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

/* ============ Filters ============ */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 24px; }
.filters input[type=search] { flex: 1; min-width: 220px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; font: 600 .85rem var(--font); color: var(--ink-2); cursor: pointer; }
.seg button.on { background: var(--brand); color: var(--brand-ink); }

/* ============ Forms ============ */
input, select, textarea { width: 100%; font: 1rem var(--font); padding: 11px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 14px; }
label > input, label > select, label > textarea { margin-top: 6px; font-weight: 400; }
.form-error { color: var(--danger); font-size: .9rem; font-weight: 500; margin: 0 0 6px; min-height: 0; }
.form-error:empty { display: none; }
label small { display: block; margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .form-row { grid-template-columns: 1fr; } }

/* ============ Trail detail ============ */
.detail-hero { position: relative; height: 360px; overflow: hidden; }
.detail-hero > img, .detail-hero > svg { width: 100%; height: 100%; object-fit: cover; }
.detail-hero .overlay { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(0,0,0,.65)); display: flex; align-items: flex-end; }
.detail-hero h1 { color: #fff; margin: 8px 0 4px; }
.detail-hero p { color: rgba(255,255,255,.9); margin: 0 0 28px; font-size: 1.1rem; }
.detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 32px; padding: 40px 0 64px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
@media (max-width: 600px) { .facts { grid-template-columns: repeat(2, 1fr); } }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.fact b { display: block; font-size: 1.25rem; font-family: var(--font-display); }
.fact span { font-size: .8rem; color: var(--ink-2); }
.map { height: 380px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 0; }
.map-big { height: min(70vh, 640px); }
.list-check { list-style: none; padding: 0; margin: 0 0 1.4em; }
.list-check li { padding: 6px 0 6px 28px; position: relative; }
.list-check li::before { content: ""; position: absolute; left: 4px; top: 14px; width: 12px; height: 6px; border-left: 2.5px solid var(--brand-2); border-bottom: 2.5px solid var(--brand-2); transform: rotate(-45deg); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.panel h3 { margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .93rem; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 500; }
.note { font-size: .85rem; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 10px 14px; }

/* ============ Communities & hikes ============ */
.comm-cover { height: 110px; position: relative; display: flex; align-items: flex-end; padding: 14px 20px; color: #fff; }
.comm-avatar { width: 56px; height: 56px; border-radius: 14px; background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.5); display: grid; place-items: center; font: 700 1.3rem var(--font-display); }
.hike { display: grid; grid-template-columns: 76px 1fr auto; gap: 18px; align-items: center; padding: 18px 20px; }
.hike + .hike { border-top: 1px solid var(--line); }
.date-tile { background: var(--surface-2); border-radius: 12px; text-align: center; padding: 8px 4px; }
.date-tile b { display: block; font: 700 1.6rem var(--font-display); color: var(--brand); line-height: 1.1; }
.date-tile span { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.hike h3 { margin: 0 0 2px; font-size: 1.1rem; }
.hike-meta { font-size: .88rem; color: var(--ink-2); display: flex; gap: 6px 14px; flex-wrap: wrap; }
.hike-meta span { display: inline-flex; align-items: center; gap: 5px; }
.avatars { display: flex; margin-top: 8px; }
.avatars i { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); margin-left: -8px; display: grid; place-items: center; font: 700 .7rem var(--font); color: #fff; font-style: normal; }
.avatars i:first-child { margin-left: 0; }
@media (max-width: 640px) {
  .hike { grid-template-columns: 60px 1fr; }
  .hike > :last-child { grid-column: 1 / -1; }
}
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.demo-banner { background: #fff7e0; color: #6b4e00; border: 1px solid #f3dc9b; border-radius: 12px; padding: 10px 16px; font-size: .88rem; margin-bottom: 22px; }
:root[data-theme="dark"] .demo-banner { background: #2d2610; color: #f0d68a; border-color: #4f4416; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .demo-banner { background: #2d2610; color: #f0d68a; border-color: #4f4416; } }

/* ============ Feature strip ============ */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 22px; }
.feature { padding: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.feature .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--brand); margin-bottom: 14px; }
.feature h3 { margin-bottom: 6px; }
.feature p { color: var(--ink-2); margin: 0; font-size: .95rem; }

.cta-band { background: var(--brand); color: #fff; border-radius: 24px; padding: 48px; display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; }
:root[data-theme="dark"] .cta-band { background: #1a3a2c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cta-band { background: #1a3a2c; } }
.cta-band h2 { color: #fff; margin: 0 0 6px; }
.cta-band p { margin: 0; color: rgba(255,255,255,.85); }
@media (max-width: 600px) { .cta-band { padding: 32px 24px; } }

/* ============ Emergency ============ */
.sos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.sos-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); text-decoration: none !important; transition: transform .15s; }
.sos-card:hover { transform: translateY(-2px); }
.sos-card.primary { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.sos-card b { display: block; font-size: 1.05rem; }
.sos-card small { color: var(--ink-2); }
.sos-card > div { min-width: 0; }
.sos-num { font: 700 1.4rem var(--font-display); color: var(--danger); white-space: nowrap; flex-shrink: 0; }
.sos-num.long { font-size: 1.05rem; }
.sos-fab { position: fixed; right: 18px; bottom: 18px; z-index: 40; width: 58px; height: 58px; border-radius: 50%; background: var(--danger); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: .04em; box-shadow: 0 6px 20px rgba(192,57,43,.45); text-decoration: none !important; }
.sos-fab:hover { background: #a93226; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; padding: 10px 0 10px 44px; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 8px; width: 30px; height: 30px; border-radius: 50%; background: var(--danger); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; }

/* ============ Footer ============ */
.footer { background: var(--surface); border-top: 1px solid var(--line); margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; padding: 48px 0 28px; }
.footer-grid h4 { margin: 0 0 10px; font-size: .85rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); }
.footer-grid a:not(.brand) { display: block; color: var(--ink); padding: 3px 0; }
.brand-foot { margin-bottom: 10px; }
.footer-bottom { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 18px 0 28px; border-top: 1px solid var(--line); font-size: .85rem; }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }

/* ============ Modal & toast ============ */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(10,20,15,.55); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--surface); border-radius: 20px; width: min(520px, 100%); max-height: 90vh; overflow: auto; padding: 28px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-close { position: absolute; right: 14px; top: 10px; border: 0; background: none; font-size: 1.8rem; cursor: pointer; color: var(--ink-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px); background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 12px; font-weight: 500; transition: transform .3s; z-index: 120; max-width: calc(100% - 32px); }
.toast.show { transform: translate(-50%, 0); }

.leaflet-popup-content { font-family: var(--font); }
.leaflet-popup-content a { font-weight: 600; }
