/* First screen of the home pages: search, race list and map. Without JavaScript
   only the static map image and the search form show. */

/* Search */
.home-search { display: flex; gap: 8px; max-width: 640px; }
.home-search input {
  flex: 1; min-width: 0; height: 52px; padding: 0 18px; border: 0; border-radius: 999px;
  font: inherit; font-size: 16px; color: var(--ink); background: #FFFFFF;
}
.home-search input::placeholder { color: var(--muted); }
.home-search input:focus-visible, .home-search button:focus-visible { outline: 3px solid var(--mint-strong); outline-offset: 2px; }
.home-search button {
  flex-shrink: 0; height: 52px; padding: 0 24px; border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 16px; font-weight: 700; color: #FFFFFF; background: var(--accent);
}
.home-search button:hover { background: var(--accent-hover); }
.home-search-label {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Layout. Heights are fixed so nothing shifts when the list and map arrive. */
.home-map { --home-map-h: min(52vh, 440px); display: flex; flex-direction: column; gap: 20px; padding: 20px var(--gutter) 40px; }
.home-map-list { display: none; }
.home-js .home-map-list { display: flex; flex-direction: column; gap: 12px; order: 2; min-height: 380px; min-width: 0; }
.home-map-pane { position: relative; order: 1; height: var(--home-map-h); border-radius: 20px; overflow: hidden; background: var(--mint); }

@media (min-width: 821px) {
  .home-map { --home-map-h: clamp(420px, calc(100vh - 300px), 720px); }
  .home-js .home-map { display: grid; grid-template-columns: minmax(340px, 480px) minmax(0, 1fr); gap: 24px; }
  .home-js .home-map-list { order: 0; height: var(--home-map-h); min-height: 0; }
  .home-js #home-race-list { flex: 1; overflow-y: auto; }
}

/* Static image and interactive map stacked in the pane. */
.home-map-static, .home-map-static picture, .home-map-static img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.home-map-static img { object-fit: cover; }
.home-map-go {
  position: absolute; left: 12px; bottom: 12px; padding: 8px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 700; color: #FFFFFF; background: var(--forest);
}
.map-capable .home-map-go { display: none; }
.map-capable.map-tap .home-map-go { display: block; }
.home-map-credit { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: #5B6E66; }
/* Two classes, to outrank maplibre-gl.css, which loads later and sets position: relative. */
.home-map-pane .home-map-canvas { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity 0.35s ease; }
.map-ready .home-map-pane .home-map-canvas { opacity: 1; pointer-events: auto; }
/* The image stays under the map while it fades in, then goes. */
.map-ready .home-map-static, .map-ready .home-map-credit { visibility: hidden; transition: visibility 0s 0.35s; }
@media (prefers-reduced-motion: reduce) {
  .home-map-pane .home-map-canvas, .map-ready .home-map-static, .map-ready .home-map-credit { transition: none; }
}
.rm-controls, .rm-status { visibility: hidden; }
.map-ready .rm-controls, .map-ready .rm-status { visibility: visible; }

/* List head and links */
.home-map-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 15px; color: var(--muted); min-height: 22px; }
.home-map-meta strong { color: var(--ink); }
.home-map-reset { padding: 0; border: 0; background: none; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; color: var(--accent); }
.home-map-reset:hover { color: var(--forest); }
.home-map-reset[hidden] { display: none; }
.home-map-more { padding: 12px; border: 1px solid var(--border); border-radius: 999px; background: #FFFFFF; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; color: var(--accent); }
.home-map-more:hover { border-color: var(--accent); color: var(--forest); }
.home-map-more[hidden] { display: none; }
.home-js .home-map-list { scroll-margin-top: 8px; }
/* The loader from race-map.js takes over once the map is asked for. */
.map-capable.map-tap.map-loading .home-map-go { display: none; }
.home-map-all { font-size: 15px; font-weight: 700; }
.home-map-empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* Race rows, the same as on /explore */
.race-list { background: #FFFFFF; border: 1px solid var(--border); border-radius: 20px; display: flex; flex-direction: column; }
.race-list:empty { border: 0; background: none; }
.race { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 20px; border-top: 1px solid var(--mint); color: var(--ink); }
.race.first { border-top: 0; }
.race:hover { background: #F1F6F3; color: var(--ink); }
.date-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 14px; background: var(--mint); }
.wd { font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: 0.5px; }
.day { font-size: 22px; font-weight: 800; line-height: 1; color: var(--forest); }
.race-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.race-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.race-title { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { flex-shrink: 0; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; color: #FFFFFF; background: var(--forest); padding: 3px 7px; border-radius: 6px; }
.race-place { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); min-width: 0; }
.race-place svg { flex-shrink: 0; }
.race-place span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dists { display: flex; gap: 6px; flex-wrap: wrap; }
.dist { font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: #F1F6F3; color: #2E4A3E; border: 1px solid #E1EAE5; }

@media (max-width: 820px) {
  .race { grid-template-columns: 56px minmax(0, 1fr); gap: 14px; padding: 14px 16px; }
  .race .chevron { display: none; }
  .race-title-row { align-items: flex-start; }
  .race-title { white-space: normal; }
  .badge { margin-top: 2px; }
}

/* Phones: keep the App Store link, search and map in the first screen. */
@media (max-width: 639px) {
  .nav { padding: 12px var(--gutter); gap: 12px; flex-wrap: nowrap; }
  .nav-links { gap: 14px; font-size: 14px; flex-wrap: nowrap; white-space: nowrap; }
  .nav-links a[href="#features"], .nav-links a[href="#regions"] { display: none; }
  .nav-links .btn-nav { padding: 8px 14px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-mark img { width: 28px; height: 28px; }
  .brand-name { font-size: 17px; }
  .hero-lede { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .home-search input, .home-search button { height: 46px; }
  .home-search input { padding: 0 14px; }
  .home-search input::placeholder { font-size: 14px; }
  .home-search button { padding: 0 16px; }
  .home-map { padding-top: 14px; gap: 14px; }
}
