/* LTC Cycling Routes — modern responsive styling, light + dark. */
:root {
  --bg: #f6f7f9;
  --bg-soft: #eef0f4;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e7ec;
  --border-strong: #d3d8e0;
  --text: #131722;
  --muted: #5b6472;
  --muted-2: #833;
  /* Club colours (from the kit): volt / navy / cyan / hot pink */
  --volt: #c2e412;
  --navy: #12225f;
  --cyan: #17b0e6;
  --pink: #ff2e9a;
  --accent: #16277a;        /* club navy — links, focus, primary */
  --accent-ink: #ffffff;
  --yellow: #eaa60c;
  --green: #1f9d55;
  --blue: #1273d4;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 6px 20px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 40px rgba(16,24,40,.18);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1140px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1116;
  --bg-soft: #141922;
  --surface: #171d27;
  --surface-2: #1d242f;
  --border: #262d39;
  --border-strong: #333c4a;
  --text: #e7ebf1;
  --muted: #9aa4b2;
  --volt: #cdf22a;
  --navy: #0c1948;
  --cyan: #35c1f0;
  --pink: #ff53ad;
  --accent: #6f8dff;        /* lighter navy-blue for links on dark */
  --yellow: #f2c14e;
  --green: #43c07f;
  --blue: #46a8ff;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 18px 50px rgba(0,0,0,.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
a { color: inherit; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
/* Jersey-style colour stripe across the very top. */
.site-header::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--volt) 0%, var(--cyan) 38%, var(--pink) 68%, var(--navy) 100%);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  color: var(--navy); background: linear-gradient(135deg, var(--volt), #a6d400);
  box-shadow: var(--shadow);
}
:root[data-theme="dark"] .brand-mark { color: #0c1948; }
.brand h1 { font-size: 1.15rem; margin: 0; letter-spacing: -.01em; line-height: 1.1; }
.brand-sub { margin: 0; font-size: .8rem; color: var(--muted); }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 12px; cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.96); }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }

/* Toolbar */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
  margin: 26px 0 12px;
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: .9rem; font-weight: 550; transition: all .15s;
}
.chip:hover { background: var(--surface-2); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.chip-yellow .dot { background: var(--yellow); }
.chip-green .dot { background: var(--green); }
.chip-blue .dot { background: var(--blue); }
.chip.is-active { color: #fff; border-color: transparent; background: var(--accent); }
:root[data-theme="dark"] .chip.is-active { background: #eef1f6; color: #12161d; }
.chip-yellow.is-active { background: var(--yellow); color: #3a2c00; }
.chip-green.is-active { background: var(--green); color: #04240f; }
.chip-blue.is-active { background: var(--blue); color: #fff; }
.chip.is-active .dot { box-shadow: 0 0 0 2px rgba(255,255,255,.6); }

.tools { display: flex; gap: 10px; align-items: center; }
.search {
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface);
  color: var(--muted); height: 42px;
}
.search input {
  border: 0; outline: 0; background: transparent; color: var(--text);
  font-size: .92rem; width: 160px; padding: 8px 0;
}
.sort select {
  height: 42px; padding: 0 34px 0 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: .92rem; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235b6472' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

.count { color: var(--muted); font-size: .88rem; margin: 6px 2px 16px; }

/* Grid */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: transform .16s ease, box-shadow .16s ease, border-color .16s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }

.thumb {
  position: relative; aspect-ratio: 16 / 9; cursor: pointer;
  background:
    radial-gradient(120% 120% at 15% 10%, color-mix(in srgb, var(--tint, var(--accent)) 20%, var(--surface)) 0%, var(--surface) 60%);
  border-bottom: 1px solid var(--border);
}
.thumb > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Lazy, non-interactive road map that fades in over the silhouette. */
.thumb-map { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity .4s ease; background: var(--surface-2); }
.thumb-map.is-ready { opacity: 1; }
.thumb-map .leaflet-container { background: var(--surface-2); font: inherit; }
/* Abstract the card basemap to near-monochrome so the coloured route stands out.
   Filter the TILE layer only — the route line lives in the overlay pane and stays vivid. */
.thumb-map .leaflet-tile-pane { filter: grayscale(1) contrast(.92) brightness(1.02); }
:root[data-theme="dark"] .thumb-map .leaflet-tile-pane { filter: grayscale(1) invert(1) brightness(.92) contrast(.85); }
.thumb-badge, .thumb-view { z-index: 2; }
.thumb .route-line { fill: none; stroke: var(--tint, var(--accent)); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.thumb .route-shadow { fill: none; stroke: rgba(0,0,0,.14); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.thumb .pin { fill: var(--tint, var(--accent)); stroke: #fff; stroke-width: 1.4; }
.thumb-badge {
  position: absolute; top: 10px; left: 10px; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 9px; border-radius: 999px; font-size: .72rem; font-weight: 600;
  background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: blur(4px);
  color: var(--muted); border: 1px solid var(--border);
}
.thumb-view {
  position: absolute; right: 10px; bottom: 10px; padding: 6px 11px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; color: var(--text);
  background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--border-strong);
  display: inline-flex; align-items: center; gap: 6px; opacity: 0; transform: translateY(4px); transition: .16s;
}
.card:hover .thumb-view { opacity: 1; transform: translateY(0); }

.card-body { padding: 15px 16px 16px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.card-title { margin: 0; font-size: 1.06rem; line-height: 1.25; letter-spacing: -.01em; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: .74rem; font-weight: 650; border: 1px solid transparent;
}
.tag .dot { width: 8px; height: 8px; border-radius: 50%; }
.tag-yellow { background: color-mix(in srgb, var(--yellow) 18%, transparent); color: color-mix(in srgb, var(--yellow) 62%, #000); border-color: color-mix(in srgb, var(--yellow) 40%, transparent); }
.tag-yellow .dot { background: var(--yellow); }
.tag-green { background: color-mix(in srgb, var(--green) 16%, transparent); color: color-mix(in srgb, var(--green) 72%, #000); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.tag-green .dot { background: var(--green); }
.tag-blue { background: color-mix(in srgb, var(--blue) 15%, transparent); color: color-mix(in srgb, var(--blue) 78%, #000); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
.tag-blue .dot { background: var(--blue); }
:root[data-theme="dark"] .tag-yellow { color: color-mix(in srgb, var(--yellow) 82%, #fff); }
:root[data-theme="dark"] .tag-green { color: color-mix(in srgb, var(--green) 78%, #fff); }
:root[data-theme="dark"] .tag-blue { color: color-mix(in srgb, var(--blue) 82%, #fff); }

.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px; margin-top: auto; }
.stat { display: flex; flex-direction: column; gap: 1px; padding: 8px 0; }
.stat .v { font-size: 1.04rem; font-weight: 700; letter-spacing: -.02em; }
.stat .l { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat + .stat { border-left: 1px solid var(--border); padding-left: 12px; }

.links { display: flex; gap: 8px; }
.btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 8px; border-radius: 10px; font-size: .82rem; font-weight: 600; text-decoration: none;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  transition: background .14s, border-color .14s, transform .1s;
}
.btn:hover { border-color: var(--border-strong); background: var(--bg-soft); }
.btn:active { transform: scale(.97); }
.btn svg { width: 15px; height: 15px; }
.btn-strava { color: #fff; background: #fc4c02; border-color: #fc4c02; }
.btn-strava:hover { background: #e34402; border-color: #e34402; }
.btn-garmin { color: #fff; background: #0a1a2f; border-color: #0a1a2f; }
:root[data-theme="dark"] .btn-garmin { background: #14243b; border-color: #223350; }

.empty { text-align: center; color: var(--muted); padding: 50px 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 44px; padding: 22px 0 40px; color: var(--muted); font-size: .85rem; }
.site-footer p { margin: 4px 0; }
.site-footer .attrib { font-size: .78rem; opacity: .8; }
.site-footer .attrib a { color: var(--accent); }
.site-footer .k { font-weight: 650; }
.k-yellow { color: color-mix(in srgb, var(--yellow) 65%, var(--text)); }
.k-green { color: color-mix(in srgb, var(--green) 70%, var(--text)); }
.k-blue { color: color-mix(in srgb, var(--blue) 72%, var(--text)); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8,12,20,.55); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; width: min(760px, 100%); max-height: 92vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 20px; animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-close { position: absolute; top: 14px; right: 14px; z-index: 2; }
.modal-head { padding-right: 46px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.modal-head h2 { margin: 0; font-size: 1.35rem; letter-spacing: -.02em; }
.detail-map { height: 300px; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.detail-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.detail-stats .d {
  flex: 1; min-width: 90px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
}
.detail-stats .d .v { font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; }
.detail-stats .d .l { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.profile-wrap { margin: 6px 0 16px; }
.profile-head { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.profile { width: 100%; display: block; }
.muted { color: var(--muted); }
.detail-links { display: flex; gap: 10px; flex-wrap: wrap; }
.detail-links .btn { flex: 1; min-width: 120px; }

@media (max-width: 560px) {
  .tools { width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .brand h1 { font-size: 1.02rem; }
  .modal-card { padding: 16px; border-radius: 16px; }
  .detail-map { height: 240px; }
}
