/* Course map + elevation */

.course {
  width: min(100% - 3rem, 72rem);
  margin: 0 auto;
  padding: 1rem 0 4rem;
}

.course__header {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  margin-bottom: 1.5rem;
}

.course__header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.25rem, 6vw, 3.5rem);
  font-weight: 800;
  line-height: 0.95;
  text-transform: uppercase;
}

.course__intro {
  max-width: 34rem;
  margin: 0.75rem 0 0;
  color: #c3cad9;
}

.course__tabs {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.375rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(13, 21, 40, 0.7);
}

/* Sliding pill follows the selected distance. */
.course__tabs:has(.course__tab)::before {
  content: "";
  position: absolute;
  top: 0.25rem;
  bottom: 0.25rem;
  left: 0.25rem;
  width: calc(50% - 0.4375rem);
  border-radius: 999px;
  background: var(--amber);
  transition: transform 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

.course__tabs:has(.course__tab:nth-child(2)[aria-selected="true"])::before {
  transform: translateX(calc(100% + 0.375rem));
}

.course__tab {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  position: relative;
  transition: color 250ms ease;
}

.course__tab:hover {
  color: var(--ink);
}

.course__tab.is-active,
.course__tab[aria-selected="true"] {
  background: var(--amber);
  color: #131722;
}

.course__tabs:has(.course__tab) .course__tab {
  background: transparent;
}

.course__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 1.75rem;
  margin: 0 0 1.25rem;
}

.course__stat {
  min-width: 6.5rem;
}

.course__stat dt {
  margin: 0;
  color: var(--amber);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.course__stat dd {
  margin: 0.2rem 0 0;
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.course__panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--navy);
  overflow: hidden;
}

.course__map-wrap,
.course__elev-wrap {
  position: relative;
}

.course__map {
  width: 100%;
  height: clamp(280px, 58vw, 520px);
  background: #1a1f2a;
}

.course__attribution {
  margin: 0;
  padding: 0.375rem 0.5rem;
  background: var(--night);
  color: var(--muted);
  font-size: 0.6875rem;
  text-align: right;
}

.course__attribution a {
  color: inherit;
}

.course__attribution a:hover {
  color: var(--ink);
}

.course__map.maplibregl-map {
  font: inherit;
}

.course__map .maplibregl-ctrl-attrib {
  background: rgba(7, 11, 22, 0.72);
  color: #9aa3b8;
  font-size: 11px;
}

.course__map .maplibregl-ctrl-attrib a {
  color: #cfd5e3;
}

.course__map .maplibregl-ctrl-group {
  background: rgba(7, 11, 22, 0.88);
  border: 1px solid rgba(233, 236, 243, 0.12);
  box-shadow: none;
}

.course__map .maplibregl-ctrl-group button {
  background-color: transparent;
  width: 30px;
  height: 30px;
}

.course__map .maplibregl-ctrl-group button + button {
  border-top-color: rgba(233, 236, 243, 0.12);
}

.course__map .maplibregl-ctrl-group button span {
  filter: invert(1) brightness(1.15);
}

.course-mile-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1.5px solid rgba(233, 236, 243, 0.55);
  border-radius: 50%;
  background: rgba(13, 21, 40, 0.92);
  color: #e9ecf3;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.course-wpt-marker {
  position: relative;
  width: 0;
  height: 0;
}

.course-wpt-marker i {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 12px;
  height: 12px;
  border: 2px solid #0d1528;
  border-radius: 50%;
  background: var(--amber);
}

.course-wpt-marker--start i,
.course-wpt-marker--finish i {
  top: -7px;
  left: -7px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-color: var(--amber);
}

.course-wpt-marker span {
  position: absolute;
  top: -28px;
  left: 10px;
  white-space: nowrap;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(7, 11, 22, 0.82);
  color: #f2f4f8;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  pointer-events: none;
}

.course__elev {
  display: block;
  width: 100%;
  height: auto;
  border-top: 1px solid var(--line);
  background: #080e1b;
}

.course-elev-area {
  fill: rgba(233, 236, 243, 0.05);
}

.course-elev-fill {
  fill: rgba(242, 180, 90, 0.18);
}

.course-elev-line {
  stroke: rgba(233, 236, 243, 0.35);
  stroke-width: 1.75;
}

.course-elev-line-hot {
  stroke: var(--amber);
  stroke-width: 2.25;
}

.course-elev-grid {
  stroke: rgba(233, 236, 243, 0.08);
  stroke-width: 1;
}

.course-elev-xlabel,
.course-elev-ylabel {
  fill: var(--muted);
  font-size: 12px;
  font-family: var(--body);
}

.course-elev-aid line {
  stroke: rgba(242, 180, 90, 0.28);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.course-elev-aid text {
  fill: rgba(242, 180, 90, 0.85);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--body);
}

.course-elev-cursor {
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 1.25;
}

.course-elev-dot {
  fill: #fff;
  stroke: var(--amber);
  stroke-width: 2.5;
}

.course__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.875rem 1.25rem;
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--line);
  background: rgba(7, 11, 22, 0.55);
}

/* Keep the readouts clear of the fixed back-to-top arrow until the content column is narrower than the viewport gutter. */
@media (max-width: 1279px) {
  .course__controls {
    padding-right: 4.5rem;
  }
}

.course__play {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition:
    border-color 200ms ease,
    color 200ms ease,
    transform 150ms cubic-bezier(0.16, 1, 0.3, 1);
}

.course__play:hover {
  border-color: rgba(242, 180, 90, 0.6);
  color: var(--amber);
}

.course__play:active {
  transform: scale(0.92);
}

.course__play[aria-pressed="true"] {
  border-color: var(--amber);
  color: var(--amber);
}

.course__scrub {
  flex: 1;
  min-width: 10rem;
  accent-color: var(--amber);
}

.course__readouts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.course__readouts strong {
  color: var(--ink);
  font-weight: 600;
}

.course__cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  margin-top: 2rem;
}

.course__cta p {
  margin: 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
}

.course__aids {
  margin: 1.5rem 0 0;
}

.course__aids h3 {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 800;
  text-transform: uppercase;
}

.course__aid-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--line);
}

@media (min-width: 900px) {
  .course__aid-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(var(--aid-rows, 4), auto);
    grid-auto-flow: column;
  }
}

.course-aid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--night);
  transition: background-color 200ms ease;
}

.course-aid__name {
  transition: color 200ms ease;
}

@media (hover: hover) {
  .course-aid:hover {
    background: var(--navy);
  }

  .course-aid:hover .course-aid__name {
    color: var(--amber);
  }
}

/* Aid stations arrive in course order as the list scrolls in. */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .course__aid-list {
      overflow: clip;
    }

    .course-aid > * {
      animation: slide-in linear backwards;
      animation-timeline: view();
      animation-range: entry 10% entry 90%;
    }
  }
}

.course-aid__kind {
  display: none;
}

.course-aid__name {
  font-weight: 600;
}

.course-aid__mile {
  color: var(--muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.course__error {
  margin: 0 0 1rem;
  color: #f0a0a0;
}

.course__error[hidden] {
  display: none;
}

.course__note {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

@media (max-width: 700px) {
  .course__header {
    align-items: start;
  }

}
