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

:root {
  --forest: #1c2b1e;
  --forest-mid: #2d4430;
  --accent: #e8a44a;
  --accent-light: #f5c97a;
  --off-white: #f6f4f0;
  --text-dark: #1a1a18;
  --text-mid: #4a4a46;
  --text-light: #8a8a84;
  --border: rgba(0,0,0,0.10);
  --radius: 12px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--off-white);
  color: var(--text-dark);
  min-height: 100vh;
}

/* NAV */
nav {
  background: var(--forest);
  padding: 0 2.5rem;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.logo-name {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
  line-height: 1;
}

.logo-tagline {
  font-size: 11px;
  font-weight: 300;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.strava-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #FC4C02;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}

.strava-btn:hover { opacity: 0.88; }

.strava-icon {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* HERO */
.hero {
  background: var(--forest);
  padding: 5rem 2.5rem 4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 60% 40%, rgba(232,164,74,0.08) 0%, transparent 65%);
  pointer-events: none;
}

.hero-eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.2rem;
}

.hero-headline {
  font-family: 'Fraunces', serif;
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
  letter-spacing: -1px;
  max-width: 680px;
  margin: 0 auto 1.2rem;
}

.hero-headline em {
  font-style: italic;
  font-weight: 300;
  color: var(--accent-light);
}

.hero-sub {
  font-size: 16px;
  font-weight: 300;
  color: rgba(255,255,255,0.55);
  max-width: 460px;
  margin: 0 auto;
  line-height: 1.6;
}

/* FILTERS */
.filters-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 2.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  position: sticky;
  top: 68px;
  z-index: 90;
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-light);
  white-space: nowrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 12px;
  color: var(--text-mid);
  white-space: nowrap;
}

.filter-input {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  color: var(--text-dark);
  background: var(--off-white);
  outline: none;
  transition: border-color 0.15s;
  width: 90px;
}

.filter-input:focus { border-color: var(--forest); }

.filter-input[type="date"] { width: 140px; }

select.filter-input {
  width: 160px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.filter-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.filter-results {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-light);
  white-space: nowrap;
}

/* GRID */
.grid-section {
  padding: 2.5rem 2.5rem 4rem;
  max-width: 1400px;
  margin: 0 auto;
}

.race-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

@media (max-width: 1100px) { .race-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 780px)  { .race-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .race-grid { grid-template-columns: 1fr; } }

/* TILE */
.tile {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 3/4;
  cursor: pointer;
  background-size: cover;
  background-position: center;
}

.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.08) 0%,
    rgba(0,0,0,0.15) 40%,
    rgba(0,0,0,0.65) 100%
  );
  transition: background 0.3s ease;
}

.tile:hover::after {
  background: linear-gradient(to bottom, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.82) 100%);
}

.tile.mountain { background: linear-gradient(160deg, #6b8fa3 0%, #3a5f6e 35%, #1e3540 70%, #0e1e26 100%); }
.tile.trail    { background: linear-gradient(160deg, #8aab6e 0%, #4d7a3a 35%, #2a4a22 70%, #162914 100%); }
.tile.road     { background: linear-gradient(160deg, #b5bec8 0%, #7a8fa0 35%, #4a5e6e 70%, #2a3540 100%); }
.tile.coastal  { background: linear-gradient(160deg, #7ab8c8 0%, #3a8aa0 35%, #1e5568 70%, #0e2e3a 100%); }
.tile.desert   { background: linear-gradient(160deg, #d4a87a 0%, #a07040 35%, #6a4520 70%, #3a2510 100%); }
.tile.nordic   { background: linear-gradient(160deg, #a8c4d4 0%, #6a9ab0 35%, #3a6070 70%, #1e3540 100%); }
.tile.mixed    { background: linear-gradient(160deg, #9aab8e 0%, #6a7a5a 35%, #3a4a2a 70%, #1a2a10 100%); }

.tile-base {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.2rem;
  transition: opacity 0.3s ease;
}

.tile:hover .tile-base { opacity: 0; }

.tile-name {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.2px;
}

.tile-meta {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.65);
  margin-top: 4px;
  letter-spacing: 0.3px;
}

.tile-attendees {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.avatars { display: flex; }

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  margin-left: -6px;
}

.avatar:first-child { margin-left: 0; }

.going-count {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  font-weight: 500;
}

/* HOVER OVERLAY */
.tile-hover {
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.tile:hover .tile-hover {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.hover-name {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 0.7rem;
}

.hover-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.hover-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.hover-row-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255,255,255,0.45);
}

.hover-row-val {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.9);
  text-align: right;
}

.hover-divider {
  border: none;
  border-top: 0.5px solid rgba(255,255,255,0.15);
  margin: 8px 0;
}

.hover-attendees { margin-top: auto; }

.hover-attendee-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255,255,255,0.45);
  margin-bottom: 6px;
}

.hover-faces {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hover-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.hover-row-distances {
  align-items: flex-start;
}

.dist-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  max-width: 65%;
}

.dist-pill {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.12);
  border: 0.5px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
}

.hover-cta {
  margin-top: 12px;
  background: var(--accent);
  color: var(--text-dark);
  border: none;
  border-radius: 7px;
  padding: 9px 0;
  width: 100%;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.3px;
}

.hover-cta:hover { background: var(--accent-light); }

.badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(232,164,74,0.25);
  color: var(--accent-light);
  margin-bottom: 8px;
  border: 0.5px solid rgba(232,164,74,0.35);
}

.tile-terrain-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.30);
  border: 0.5px solid rgba(255,255,255,0.25);
  border-radius: 5px;
  padding: 3px 8px;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

/* APPLY BTN (filter bar) */
.apply-btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 18px;
  background: var(--forest);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.apply-btn:hover { opacity: 0.88; }

.clear-filters {
  margin-left: 8px;
  font-size: 12px;
  color: var(--text-light);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

.clear-filters:hover { color: var(--text-dark); }

/* SUGGEST BTN (filter bar) */
.suggest-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--forest);
  border-radius: 8px;
  color: var(--forest);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.suggest-btn:hover {
  background: var(--forest);
  color: #fff;
}

.suggest-btn-icon {
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
}

/* SUGGEST BANNER (bottom of grid) */
.suggest-banner {
  margin-top: 3rem;
  padding: 2.2rem 2rem;
  background: #fff;
  border: 1px dashed rgba(0,0,0,0.15);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.suggest-banner-text h3 {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.suggest-banner-text p {
  font-size: 14px;
  color: var(--text-mid);
  font-weight: 300;
  line-height: 1.5;
  max-width: 540px;
}

.suggest-banner-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--forest);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 22px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
}

.suggest-banner-cta:hover { background: var(--forest-mid); }

/* LOAD MORE */
.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 0 0 4rem;
}

.load-more-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--forest);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 32px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.load-more-btn:hover { opacity: 0.85; }

/* FOOTER */
footer {
  background: var(--forest);
  color: rgba(255,255,255,0.45);
  text-align: center;
  padding: 2rem 2.5rem;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

footer a:hover { color: var(--accent-light); }

/* NAV USER (logged-in state) */
.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-username {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.nav-logout {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  transition: color 0.15s;
}

.nav-logout:hover { color: #fff; }

@media (max-width: 600px) {
  nav { padding: 0 1.25rem; }
  .hero { padding: 3.5rem 1.25rem 3rem; }

  .filters-bar {
    padding: 1rem 1.25rem;
    gap: 0.75rem;
    flex-direction: column;
    align-items: stretch;
  }

  .filter-label { display: none; }
  .filter-divider { display: none; }
  .filter-results { margin-left: 0; }

  .suggest-btn { width: 100%; justify-content: center; }

  .filter-group {
    width: 100%;
  }

  .filter-group label {
    min-width: 60px;
  }

  .filter-input {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .filter-input[type="date"] {
    width: auto;
    flex: 1;
    min-width: 0;
  }

  select.filter-input {
    width: auto;
    flex: 1;
  }

  .grid-section { padding: 1.5rem 1rem 3rem; }
}

/* AVATAR PALETTE */
:root {
  --avatar-color-0: #4a7c59;
  --avatar-color-1: #2e6b9e;
  --avatar-color-2: #8b5e3c;
  --avatar-color-3: #6b4c8a;
}

/* AVATARS */
.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.6);
  object-fit: cover;
  margin-right: -6px;
  flex-shrink: 0;
  display: block;
}

.avatar--initial {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
}

.avatar--overflow {
  background: rgba(0,0,0,0.30);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar--lg {
  width: 30px;
  height: 30px;
}

.avatars, .hover-faces {
  display: flex;
  align-items: center;
}

/* TILE MINE — thin accent border */
.tile--mine {
  outline: 2px solid #4a7c59;
  outline-offset: -2px;
}

/* ATTENDANCE BUTTONS on hover overlay */
.attendance-buttons {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.hover-cta--going {
  background: #4a7c59;
  color: #fff;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  padding: 10px 18px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  transition: opacity 0.15s;
}

.hover-cta--going:hover { opacity: 0.88; }

.hover-cta--interested {
  background: transparent;
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.6);
  cursor: pointer;
  border-radius: 8px;
  padding: 10px 18px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  transition: background 0.15s;
}

.hover-cta--interested:hover { background: rgba(255,255,255,0.12); }

/* ATTENDANCE STATUS (already attending) */
.attendance-status {
  margin-top: 4px;
}

.attendance-status-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  margin-bottom: 6px;
}

.attendance-actions {
  display: flex;
  gap: 10px;
}

.attendance-change,
.attendance-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.6);
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  transition: color 0.15s;
}

.attendance-change:hover,
.attendance-remove:hover {
  color: #fff;
}
