/* Adthletics - race calendar (calendar.html). Loads after site.css.
   A month grid (left, stays in view) and the chosen day's races (right); on
   phones the grid sits above the list. */

.cal-head {
  padding-block: clamp(36px, 6vw, 72px) 28px;
}

.cal-head .eyebrow { color: var(--accent); }

.cal-title {
  max-width: 14ch;
  margin-top: 14px;
  font-size: clamp(40px, 6vw, 80px);
}

.cal-lead {
  max-width: 52ch;
  margin-top: 16px;
  font-size: 19px;
  color: var(--ink-soft);
}

.cal-layout {
  display: grid;
  grid-template-columns: minmax(300px, 460px) minmax(0, 1fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: start;
  padding-bottom: clamp(56px, 8vw, 96px);
}

/* ---------- The month ---------- */

.cal-month {
  position: sticky;
  top: 20px;
  padding: 22px;
  border: 1.5px solid var(--ink);
  border-radius: 22px;
  background: #fffdf8;
}

.cal-month-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cal-month-title {
  flex: 1;
  min-width: 0;
  font-size: clamp(19px, 1.9vw, 25px);
  text-align: center;
  white-space: nowrap;
}

.cal-arrow {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 18px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.cal-arrow:hover:not(:disabled) { color: var(--cream); background: var(--ink); }
.cal-arrow:disabled { opacity: 0.25; cursor: not-allowed; }

.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.cal-weekdays {
  margin-top: 18px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.cal-grid { margin-top: 8px; }

.cal-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--ink-line);
  border-radius: 10px;
  font: inherit;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cal-cell.is-blank { border: 0; cursor: default; }

.cal-num {
  font-family: var(--display);
  font-weight: 800;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.cal-cell:hover:not(:disabled):not([aria-pressed="true"]) {
  border-color: var(--ink);
  background: rgba(17, 17, 17, 0.05);
}

/* Days with races: the "!" in the corner. */
.cal-cell.has-races { border-color: rgba(0, 119, 255, 0.45); }

.cal-bang {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
  background: var(--accent);
}

/* Today: an accent ring and the word under the number. */
.cal-cell.is-today {
  border: 2px solid var(--accent);
  box-shadow: inset 0 0 0 2px rgba(0, 119, 255, 0.12);
}

.cal-today {
  position: absolute;
  bottom: 3px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

/* The chosen day. */
.cal-cell[aria-pressed="true"] {
  border-color: var(--ink);
  color: var(--cream);
  background: var(--ink);
}

.cal-cell[aria-pressed="true"] .cal-today { color: var(--accent-bright); }

/* Past days: there, but out of play. */
.cal-cell.is-past {
  border-color: transparent;
  color: rgba(17, 17, 17, 0.28);
  background: rgba(17, 17, 17, 0.03);
  cursor: not-allowed;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--ink-soft);
}

.cal-legend li { display: flex; align-items: center; gap: 8px; }

.cal-legend-bang {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
  color: #ffffff;
  background: var(--accent);
}

.cal-legend-today {
  width: 17px;
  height: 17px;
  border: 2px solid var(--accent);
  border-radius: 5px;
}

/* ---------- The chosen day ---------- */

.cal-day-title { font-size: clamp(28px, 3.2vw, 40px); }

.cal-filters {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 16px 0;
  border-block: 1px solid var(--ink-line);
}

.cal-sports {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cal-sports button {
  padding: 7px 13px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.cal-sports button:hover { background: rgba(17, 17, 17, 0.06); }

.cal-sports button[aria-pressed="true"] {
  color: var(--cream);
  background: var(--ink);
}

.cal-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.cal-field {
  display: grid;
  flex: 1 1 180px;
  gap: 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.cal-field select,
.cal-field input {
  width: 100%;
  min-height: 40px;
  padding: 6px 0;
  border: 0;
  border-bottom: 1.5px solid rgba(17, 17, 17, 0.3);
  border-radius: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  background: transparent;
}

.cal-field select:focus-visible,
.cal-field input:focus-visible {
  outline: none;
  border-bottom-color: var(--accent);
  box-shadow: 0 1.5px 0 var(--accent);
}

.cal-filter-note { font-size: 13px; color: var(--ink-soft); }

.cal-count {
  margin-top: 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

.race {
  padding-block: 16px;
  border-bottom: 1px solid var(--ink-line);
}

.race-name {
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 105%;
  font-size: 20px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.race-name a {
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0 2px;
  transition: background-size 0.25s ease, color 0.15s ease;
}

.race-name a::after {
  content: " ↗";
  font-family: var(--body);
  font-size: 0.75em;
  color: var(--ink-soft);
}

.race-name a:hover {
  color: var(--accent);
  background-size: 100% 2px;
}

.race-place { margin-top: 4px; color: var(--ink-soft); }

.race-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.race-tags li {
  padding: 2px 10px;
  border: 1px solid var(--ink-line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.race-tags .race-sport { border-color: var(--ink); font-weight: 800; }

/* The sport tag carries the sport's colour. */
.race[data-sport="triathlon"] .race-sport,
.race[data-sport="multisport"] .race-sport { border-color: var(--accent); color: var(--accent); }
.race[data-sport="trail"] .race-sport { border-color: #2f7d4a; color: #2f7d4a; }
.race[data-sport="cycling"] .race-sport { border-color: #c27a00; color: #c27a00; }

.race-runs { margin-top: 8px; font-size: 14px; font-weight: 600; }

.race-via {
  margin-top: 8px;
  font-size: 12.5px;
  color: rgba(17, 17, 17, 0.5);
}

.cal-more {
  display: flex;
  margin: 28px auto 0;
}

.cal-credit {
  display: grid;
  gap: 8px;
  max-width: 70ch;
  padding-block: 20px clamp(64px, 8vw, 104px);
  border-top: 1px solid var(--ink-line);
  font-size: 14px;
  color: var(--ink-soft);
}

.cal-credit a { color: var(--ink); text-underline-offset: 2px; }

/* ---------- Responsive ---------- */

@media (max-width: 899px) {
  .cal-layout { grid-template-columns: minmax(0, 1fr); }
  .cal-month { position: static; max-width: 520px; width: 100%; margin-inline: auto; }
}

@media (max-width: 420px) {
  .cal-month { padding: 16px 12px; }
  .cal-weekdays, .cal-grid { gap: 3px; }
  .cal-num { font-size: 15px; }
  .cal-bang { top: 2px; right: 2px; width: 14px; height: 14px; font-size: 10px; }
  .cal-today { font-size: 8px; bottom: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .cal-cell,
  .cal-sports button,
  .race-name a { transition: none; }
}
