/* Running Club demo: one stylesheet, no external fonts or assets. */

:root {
  --navy: #0d3056;
  --navy-soft: #1f4874;
  --ink: #0d3056;
  --muted: #475a70;
  --pink: #ffe9f4;
  --cream: #fff9e6;
  --amber: #fcaf04;
  --amber-ink: #7a4d00;
  --white: #ffffff;
  --line: #e4dcc6;
  --ok-bg: #e6f4ea;
  --ok-ink: #1d5b2c;
  --full-bg: #f3e3e8;
  --full-ink: #8a1f3d;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(13, 48, 86, 0.06), 0 4px 14px rgba(13, 48, 86, 0.06);
  --wrap: 72rem;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Thai", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
}

main {
  flex: 1 0 auto;
}

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

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 0.5rem;
  color: var(--navy);
}

h1 {
  font-size: clamp(1.75rem, 1.3rem + 2.2vw, 2.75rem);
  letter-spacing: -0.01em;
}

h2 {
  font-size: clamp(1.3rem, 1.1rem + 1vw, 1.75rem);
}

h3 {
  font-size: 1.1rem;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--navy);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--navy);
  outline-offset: 2px;
  border-radius: 4px;
}

.on-navy :focus-visible,
.site-header :focus-visible,
.site-footer :focus-visible {
  outline-color: var(--amber);
}

main:focus {
  outline: none;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 10;
  background: var(--amber);
  color: var(--navy);
  font-weight: 700;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 0.5rem;
}

/* Demo banner (every page) */
.demo-banner {
  background: var(--amber);
  color: var(--navy);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  padding: 0.4rem var(--gutter);
}

.demo-banner p {
  margin: 0;
}

/* Header */
.site-header {
  background: var(--navy);
  color: var(--white);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--white);
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
}

.brand svg {
  flex: none;
}

.portal-link {
  color: var(--white);
  font-size: 0.875rem;
  white-space: nowrap;
}

.site-nav {
  width: 100%;
  order: 3;
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.site-nav a {
  display: block;
  color: var(--white);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.45rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.site-nav a:hover {
  background: var(--navy-soft);
}

.site-nav a[aria-current="page"] {
  background: var(--pink);
  color: var(--navy);
}

/* Hero */
.hero {
  background: var(--pink);
  padding: 2rem 0 2.25rem;
}

.hero-inner {
  display: grid;
  gap: 1.5rem;
  align-items: center;
}

.eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy);
  background: var(--white);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  margin-bottom: 0.75rem;
}

.lede {
  font-size: 1.1rem;
  max-width: 36rem;
}

.hero-art {
  display: none;
}

.page-head {
  background: var(--pink);
  padding: 1.75rem 0 1.5rem;
}

.page-head p {
  margin: 0;
  max-width: 40rem;
}

/* Buttons */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 1.15rem;
  border-radius: 999px;
  border: 2px solid var(--navy);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--navy);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--navy-soft);
  border-color: var(--navy-soft);
}

.btn-secondary {
  background: var(--white);
  color: var(--navy);
}

.btn-secondary:hover {
  background: var(--cream);
}

/* Sections */
.section {
  padding: 2rem 0;
}

.section-cream {
  background: var(--cream);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 1rem;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

/* Stats */
.stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 6.25rem;
}

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Cards and lists */
.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  min-height: 9.5rem;
}

.card h2,
.card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.35rem;
}

.run-when {
  font-weight: 700;
  color: var(--amber-ink);
  font-size: 0.9rem;
  margin: 0 0 0.25rem;
}

.meta {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.meta li {
  font-size: 0.85rem;
  background: var(--cream);
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  color: var(--ink);
}

.place {
  color: var(--muted);
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
}

.spots {
  font-weight: 700;
}

.spots-open {
  background: var(--ok-bg) !important;
  color: var(--ok-ink) !important;
}

.spots-full {
  background: var(--full-bg) !important;
  color: var(--full-ink) !important;
}

.route-card {
  min-height: 11rem;
}

.route-card p {
  margin: 0.5rem 0 0;
}

.route-distance {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

/* Skeletons (keep space while data loads) */
.skeleton {
  background: linear-gradient(90deg, #f6f1e2 0%, #fbf7ec 50%, #f6f1e2 100%);
  border-color: transparent;
  box-shadow: none;
}

.skeleton .stat-value,
.skeleton .stat-label {
  color: transparent;
}

@media (prefers-reduced-motion: no-preference) {
  .skeleton {
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
  }
}

@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

/* Notices */
.notice {
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  background: var(--white);
}

.notice h2,
.notice h3 {
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.notice p:last-child {
  margin-bottom: 0;
}

.notice-mock {
  background: var(--cream);
  border-left: 6px solid var(--amber);
}

.notice-error {
  background: var(--pink);
  border-left: 6px solid var(--full-ink);
}

.notice-error .btn {
  margin-top: 0.5rem;
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}

.filters label {
  font-weight: 700;
}

.filters select {
  font: inherit;
  min-height: 44px;
  padding: 0.4rem 2rem 0.4rem 0.75rem;
  border: 2px solid var(--navy);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--navy);
}

.result-count {
  color: var(--muted);
  margin: 0;
}

/* Leaderboard */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

caption {
  text-align: left;
  padding: 0.9rem 1rem 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

th,
td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-top: 1px solid var(--line);
  height: 3rem;
}

thead th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--cream);
}

th.num,
td.num {
  text-align: right;
}

.rank {
  width: 3.5rem;
}

tbody tr:nth-child(-n + 3) .rank-badge {
  background: var(--amber);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: var(--cream);
  color: var(--navy);
  font-weight: 800;
}

.bar {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: var(--pink);
  margin-top: 0.35rem;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--navy);
  border-radius: 999px;
}

/* Footer */
.site-footer {
  background: var(--navy);
  color: var(--white);
  padding: 1.5rem 0;
  font-size: 0.9rem;
}

.site-footer a {
  color: var(--white);
}

.site-footer p {
  margin: 0 0 0.4rem;
}

/* 404 */
.lost {
  padding-top: 3rem;
  padding-bottom: 3rem;
}

.lost .big {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--amber-ink);
  margin-bottom: 0.5rem;
}

/* Wider screens */
@media (min-width: 600px) {
  .card-list-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 760px) {
  .site-nav {
    width: auto;
    order: 0;
  }

  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hero {
    padding: 3rem 0;
  }

  .hero-inner {
    grid-template-columns: 1.4fr 1fr;
  }

  .hero-art {
    display: block;
  }

  .card-list-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1000px) {
  .card-list-runs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Page-level error box (only shown when data/mock.json fails) */
.data-error {
  margin-top: 1.5rem;
}

[hidden] {
  display: none !important;
}
