/* =================================================================
   VISTERRA RUNS — RACE DISCOVERY (search + filters + featured carousel)
   Used on the homepage and on /races + /races-es. Namespaced under .rd so it
   cannot collide with the homepage's global overrides.

   DESIGN STANDARD: /portland (exact tokens). No gradients, glows, blur, cyan,
   synthetic badges or robotic card headers. Cards are Portland paper cards;
   a real photo (optional per race) sits on top of the card with no overlay.
   ================================================================= */
.rd {
  --rd-ink: #0b1118;
  --rd-navy: #07111d;
  --rd-page: #f4ede1;
  --rd-paper: #fff9ee;
  --rd-body: #314051;
  --rd-muted: #5d6672;
  --rd-label: #5f6b68;
  --rd-orange: #ef4415;
  --rd-orange-btn: #f04722;
  --rd-orange-shadow: #2b1209;
  --rd-orange-text: #b8360f;
  --rd-line: rgba(11, 17, 24, 0.16);
  --rd-line-strong: rgba(11, 17, 24, 0.3);
  --rd-display: 'Barlow Condensed', 'Arial Narrow', Arial, sans-serif;
  --rd-text: 'Barlow', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --rd-mono: 'Space Mono', 'Courier New', monospace;
  background: var(--rd-paper);
  color: var(--rd-ink);
  font-family: var(--rd-text);
  padding: clamp(64px, 8vw, 112px) 0;
}
.rd *, .rd *::before, .rd *::after { box-sizing: border-box; }
.rd :focus-visible { outline: 3px solid var(--rd-orange-btn); outline-offset: 3px; }

/* ── Heading (Portland kicker + title) ── */
.rd-head { max-width: 760px; margin-bottom: 32px; }
.rd-eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--rd-mono); font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--rd-orange); margin-bottom: 18px;
}
.rd-eyebrow::before { content: ""; width: 34px; height: 2px; background: currentColor; flex-shrink: 0; }
.rd .rd-title { font-family: var(--rd-display); font-weight: 700; text-transform: uppercase; font-size: clamp(36px, 4.6vw, 56px); line-height: 0.96; letter-spacing: -0.01em; color: var(--rd-ink); margin: 0 0 16px; }
.rd-lead { font-size: clamp(17px, 1.6vw, 19px); line-height: 1.55; color: var(--rd-body); margin: 0; max-width: 60ch; }

/* ── Search panel (flat Portland card, no shadow) ── */
.rd-panel { background: rgba(255, 255, 255, 0.56); border: 1px solid var(--rd-line); border-radius: 8px; padding: clamp(18px, 2.4vw, 26px); }
.rd-form { display: grid; gap: 14px; grid-template-columns: 1fr; margin: 0; }
@media (min-width: 640px) { .rd-form { grid-template-columns: repeat(3, minmax(0, 1fr)); } .rd-field--q { grid-column: 1 / -1; } .rd-actions { grid-column: 1 / -1; } }
@media (min-width: 1040px) { .rd-form { grid-template-columns: minmax(0, 2.1fr) repeat(3, minmax(0, 1fr)) auto; align-items: end; } .rd-field--q, .rd-actions { grid-column: auto; } }
.rd-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.rd-label { font-family: var(--rd-text); font-size: 13px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--rd-label); }
.rd-input, .rd-select {
  width: 100%; height: 52px; margin: 0; padding: 0 14px;
  font-family: var(--rd-text); font-size: 16px; font-weight: 600; color: var(--rd-ink);
  background-color: #fff; border: 1px solid var(--rd-line-strong); border-radius: 6px;
  appearance: none; -webkit-appearance: none; box-shadow: none;
}
.rd-input { padding-left: 44px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%235d6672' stroke-width='2.2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 14px center; }
.rd-input::placeholder { color: #7c858f; font-weight: 500; }
.rd-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.rd-select { padding-right: 40px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%230b1118' stroke-width='2.5' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.rd-input:hover, .rd-select:hover { border-color: var(--rd-ink); }
.rd-input:focus, .rd-select:focus { outline: none; border-color: var(--rd-ink); box-shadow: 0 0 0 3px rgba(240, 71, 34, 0.22); }
.rd-select.is-active { border-color: var(--rd-ink); }
.rd-actions { display: flex; }
.rd .rd-submit {
  width: 100%; min-height: 52px; padding: 0 24px; white-space: nowrap; cursor: pointer;
  font-family: var(--rd-text); font-size: 14px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.03em;
  color: #fff; background: var(--rd-orange-btn); border: 1px solid var(--rd-orange-btn); border-radius: 6px;
  box-shadow: 5px 5px 0 var(--rd-orange-shadow); transition: transform 0.15s, box-shadow 0.15s;
}
.rd .rd-submit:hover { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--rd-orange-shadow); }

.rd-subbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 18px; }
.rd-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rd-chips-label { font-size: 14px; font-weight: 700; color: var(--rd-muted); margin-right: 2px; }
.rd .rd-chip { font-family: var(--rd-text); font-size: 14px; font-weight: 800; color: var(--rd-ink); background: rgba(255, 255, 255, 0.48); border: 1px solid var(--rd-line); border-radius: 999px; padding: 9px 15px; cursor: pointer; line-height: 1.2; }
.rd .rd-chip:hover { border-color: var(--rd-ink); }
.rd .rd-clear { font-family: var(--rd-text); font-size: 15px; font-weight: 800; color: var(--rd-ink); background: none; border: 0; padding: 6px 2px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.rd .rd-clear[hidden] { display: none; }
.rd-count { font-size: 15px; font-weight: 700; color: var(--rd-body); margin: 24px 0 16px; min-height: 1.4em; }

/* ── Race cards (results + featured share one renderer) ── */
.rd-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.rd .rd-card {
  display: flex; flex-direction: column; height: 100%; overflow: hidden; text-decoration: none; color: var(--rd-ink);
  background: rgba(255, 255, 255, 0.56); border: 1px solid var(--rd-line); border-radius: 8px;
  transition: border-color 0.15s;
}
.rd .rd-card:hover { border-color: var(--rd-ink); }
/* Real photography (optional per race): sits above the copy, no overlay or gradient needed. */
.rd-photo { aspect-ratio: 16 / 10; background-color: var(--rd-page); background-size: cover; background-position: center; border-bottom: 1px solid var(--rd-line); }
.rd-body { display: flex; flex-direction: column; flex: 1; padding: 22px 22px 20px; gap: 8px; }
.rd-date { font-size: 14px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--rd-orange); margin: 0; }
.rd .rd-name { font-family: var(--rd-display); font-weight: 700; text-transform: uppercase; font-size: 27px; line-height: 0.98; letter-spacing: 0; color: var(--rd-ink); margin: 0; overflow-wrap: anywhere; }
.rd-place { font-size: 15px; color: var(--rd-muted); margin: 0; }
.rd-facts { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin: 10px 0 0; padding-top: 12px; border-top: 1px solid var(--rd-line); font-size: 15px; }
.rd-distance { font-weight: 700; color: var(--rd-ink); }
.rd-status { font-weight: 700; color: var(--rd-muted); }
.rd-status--limited, .rd-status--check { color: var(--rd-orange-text); }
.rd-cta { margin-top: auto; padding-top: 16px; font-size: 14px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.03em; color: var(--rd-orange); }
.rd-cta::after { content: " \2192"; }

/* ── Empty state ── */
.rd-empty { background: rgba(255, 255, 255, 0.56); border: 1px solid var(--rd-line); border-radius: 8px; padding: 26px; }
.rd .rd-empty h3 { font-family: var(--rd-display); font-weight: 700; text-transform: uppercase; font-size: 30px; line-height: 1; margin: 0 0 10px; color: var(--rd-ink); }
.rd-empty p { margin: 0 0 16px; color: var(--rd-body); }
.rd-empty-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.rd .rd-btn-ghost { display: inline-flex; align-items: center; min-height: 46px; padding: 0 18px; font-family: var(--rd-text); font-size: 14px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.03em; color: var(--rd-ink); background: transparent; border: 1px solid var(--rd-ink); border-radius: 6px; text-decoration: none; cursor: pointer; }
.rd .rd-btn-ghost:hover { background: var(--rd-ink); color: var(--rd-paper); }
.rd-note { font-size: 14px; color: var(--rd-muted); margin: 18px 0 0; }
.rd-note a { color: var(--rd-ink); font-weight: 700; text-underline-offset: 3px; }

/* ── Featured carousel ── */
.rd-featured { margin-top: clamp(48px, 6vw, 72px); }
.rd-featured-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.rd .rd-featured-title { font-family: var(--rd-display); font-weight: 700; text-transform: uppercase; font-size: clamp(30px, 3.6vw, 44px); line-height: 0.96; letter-spacing: -0.01em; margin: 0; color: var(--rd-ink); }
.rd-arrows { display: none; gap: 10px; }
@media (min-width: 768px) { .rd-arrows { display: flex; } }
.rd .rd-arrow { width: 44px; height: 44px; display: grid; place-items: center; background: transparent; color: var(--rd-ink); border: 1px solid var(--rd-line-strong); border-radius: 50%; cursor: pointer; padding: 0; }
.rd .rd-arrow:hover:not(:disabled) { background: var(--rd-ink); border-color: var(--rd-ink); color: var(--rd-paper); }
.rd .rd-arrow:disabled { opacity: 0.35; cursor: default; }
.rd-arrow svg { width: 18px; height: 18px; }
.rd-track {
  list-style: none; margin: 0; padding: 2px 2px 14px; display: grid; grid-auto-flow: column; gap: 16px;
  grid-auto-columns: 82%; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  scrollbar-width: none; min-height: 252px;
}
.rd-track::-webkit-scrollbar { display: none; }
.rd-track > li { scroll-snap-align: start; min-width: 0; }
@media (min-width: 560px) { .rd-track { grid-auto-columns: calc((100% - 16px) / 2.15); } }
@media (min-width: 900px) { .rd-track { grid-auto-columns: calc((100% - 32px) / 3); } }
@media (min-width: 1180px) { .rd-track { grid-auto-columns: calc((100% - 48px) / 4); } }
.rd-skeleton { height: 238px; border-radius: 8px; border: 1px solid var(--rd-line); background: rgba(255, 255, 255, 0.4); }

@media (prefers-reduced-motion: reduce) {
  .rd .rd-card, .rd .rd-submit { transition: none; }
  .rd-track { scroll-behavior: auto; }
}
