/* ==========================================================================
   Endurance Radar — upcoming official iRacing endurance races.

   Scoped under .endurance (itself inside .racedata, so it inherits the race-data
   colour variables and type). Kept in its own folder with its own data + JS: this
   is third-party iRacing information, deliberately separate from WOR league data.

   How duration is encoded
   -----------------------
   Race length is a MAGNITUDE, so it rides on LENGTH (the meter bar, hours mapped
   0→24) rather than on colour — length is the accurate channel and needs no colour
   key. Colour carries one thing only: whether an event is a marathon (12h+), and
   even that is always accompanied by the written duration ("24 Hours") and a
   MARATHON tag, so nothing is ever colour-alone. The two accents were validated
   against this page's panel colour (#111c33): ΔE 15.6 normal vision, 15.4 under
   deuteranopia, both above the ≥15 / ≥8 floors, contrast ≥ 3:1.
   ========================================================================== */
.endurance {
  --meter: #d59a34;          /* regular endurance   */
  --meter-marathon: #ffd166; /* marathon 12h+       */
}

/* The "why this page exists" intro sits ABOVE .racedata, centred, using the same
   Tailwind classes as the home page hero — so it needs no styling of its own here. */

/* ---- NEXT UP hero -------------------------------------------------------- */
/* the "specials coming up" block — one card per event, up to 30 days out */
.endurance .soon-head {
  font-family: "Racing Sans One", sans-serif; font-size: 17px; color: var(--amber);
  margin: 24px 0 10px; letter-spacing: .3px;
}
.endurance .soon-head span { color: var(--muted); font-size: 12px; font-family: inherit; }
.endurance .soon-grid { display: grid; gap: 7px; }
@media (min-width: 860px) {
  /* two across once there's room; a lone card still spans the full width */
  .endurance .soon-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .endurance .soon-grid > :only-child { grid-column: 1 / -1; }
}

.endurance .hero-logo { width: 38px; height: 24px; object-fit: contain; display: block; }
.endurance .hero-logo.ph { display: grid; place-items: center; font-size: 12px; background: rgba(255,255,255,.05); border-radius: 5px; }
/* the "no specials scheduled yet" state — explains itself rather than sitting blank */
.endurance .nextup.none { grid-template-columns: 1fr; border-color: var(--line); background: rgba(255,255,255,.03); }
.endurance .nextup.none::before { background: linear-gradient(180deg, #38a9e8, #1f4e75); }
.endurance .nextup.none h2 { font-size: 19px; color: var(--ink-2); }
.endurance .nextup.none .where { max-width: 74ch; }
.endurance .nextup {
  display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center;
  background: linear-gradient(135deg, rgba(245,181,61,.10), var(--panel-2) 55%);
  border: 1px solid rgba(245,181,61,.34); border-radius: 9px;
  padding: 6px 11px; position: relative; overflow: hidden;
}
.endurance .np-main { min-width: 0; display: flex; flex-direction: column; }
.endurance .np-name {
  font-family: "Racing Sans One", sans-serif; font-size: 13.5px; color: var(--ink);
  line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.endurance .np-where {
  font-size: 10.5px; color: var(--ink-2); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.endurance .nextup::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: linear-gradient(180deg, #ffd166, #b9852a);
}
.endurance .nextup .tag {
  display: inline-block; text-transform: uppercase; letter-spacing: 1px;
  font-size: 9px; font-weight: 700; color: #06182b; background: var(--amber);
  padding: 2px 7px; border-radius: 999px;
}
.endurance .nextup h2 { font-size: 17px; margin: 3px 0 1px; line-height: 1.15; }
.endurance .nextup .where { color: var(--ink-2); font-size: 12px; line-height: 1.4; }
.endurance .countdown {
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.endurance .countdown .big {
  font-family: "Racing Sans One", sans-serif; font-size: 14px; color: var(--amber); line-height: 1.1;
}
.endurance .countdown .lbl { color: var(--muted); font-size: 9.5px; text-transform: uppercase; letter-spacing: 1px; }

/* ---- filters (one row above the timeline) -------------------------------- */
.endurance .filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  margin: 22px 0 4px; padding: 13px 15px;
  background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 13px;
}
.endurance .f-field { display: flex; flex-direction: column; gap: 5px; }
.endurance .f-lbl {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted);
}
.endurance .filters select {
  font: inherit; font-size: 13px; color: var(--ink); cursor: pointer;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 11px; min-width: 190px; max-width: 300px;
}
.endurance .filters select:focus-visible { outline: 2px solid var(--blue-br); outline-offset: 1px; }
.endurance .chip-btn {
  font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink-2);
  background: rgba(255,255,255,.04); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 999px; transition: background .12s, color .12s, border-color .12s;
}
.endurance .chip-btn:hover { background: rgba(255,255,255,.09); color: var(--ink); }
.endurance .chip-btn.active { background: var(--blue-br); border-color: var(--blue-br); color: #06182b; font-weight: 700; }
.endurance .chip-btn.ghost { color: var(--muted); }
.endurance .f-count { margin-left: auto; color: var(--muted); font-size: 12.5px; padding-bottom: 8px; }

/* ---- the timeline: one row per SESSION, in time order --------------------- */
.endurance .day {
  display: flex; align-items: center; gap: 12px;
  margin: 24px 0 10px; color: var(--ink-2);
  font-size: 12px; text-transform: uppercase; letter-spacing: 2px;
}
.endurance .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.endurance .row {
  display: grid; grid-template-columns: 112px 76px 1fr 168px; gap: 15px; align-items: center;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 8px; position: relative; overflow: hidden;
}
.endurance .row.is-marathon { border-color: rgba(255,209,102,.42); }
.endurance .row-time { display: flex; flex-direction: column; gap: 2px; }
.endurance .row-time .t {
  font-family: "Racing Sans One", sans-serif; font-size: 19px; color: var(--ink);
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.endurance .row-time .r { font-size: 11px; color: var(--muted); }
/* UTC beneath the viewer's own time — iRacing quotes schedules in UTC, and it's the
   neutral reference when members in different timezones are arranging a team */
.endurance .row-time .r.utc { color: var(--ink-2); font-variant-numeric: tabular-nums; }
/* which of the event's published slots this is — so "let's take slot 3" is unambiguous */
.endurance .row-time .r.slot { color: var(--blue-br); }
.endurance .row-time .t.sm { font-size: 15px; }   /* a date range needs more room than a clock time */
/* an announced special: dates are public, session times aren't out yet */
.endurance .row.is-announced { background: linear-gradient(160deg, rgba(56,169,232,.07), var(--panel)); }
.endurance .row-dur .tbc {
  font-size: 11px; line-height: 1.35; color: var(--muted);
  text-transform: uppercase; letter-spacing: .8px;
}
.endurance .row-logo { width: 76px; height: 46px; object-fit: contain; display: block; }
.endurance .row-logo.ph { display: grid; place-items: center; font-size: 18px; background: rgba(255,255,255,.05); border-radius: 7px; }
.endurance .row-main { min-width: 0; }
.endurance .row-main h3 { font-size: 15.5px; line-height: 1.25; }
.endurance .row-main .where { color: var(--ink-2); font-size: 12.5px; margin: 3px 0 0; }
.endurance .tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0 0; }
.endurance .tags span {
  font-size: 10.5px; color: var(--ink-2); background: rgba(255,255,255,.05);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px;
}
.endurance .tags span.lic { color: var(--amber); border-color: rgba(245,181,61,.4); }
.endurance .tags span.sp { color: #06182b; background: var(--blue-br); border-color: var(--blue-br); font-weight: 700; }
/* team size — the "can I solo this?" answer, called out because it decides entry */
.endurance .tags span.drv { color: var(--good); border-color: rgba(56,209,122,.42); }
.endurance .tags span.drv.req { color: var(--amber); border-color: rgba(245,181,61,.45); }

/* forecast. Rain likelihood is ORDINAL, so it steps through one hue (blue) getting
   brighter as rain gets likelier — never a red/green/amber rainbow. The chip always
   spells out the percentage, so the colour only reinforces what the text already says. */
.endurance .tags span.wx { color: var(--ink-2); }
.endurance .tags span.rain { font-weight: 600; }
.endurance .tags span.rain.dry { color: var(--muted); }
.endurance .tags span.rain.mid { color: #7cc4ef; border-color: rgba(124,196,239,.45); background: rgba(124,196,239,.10); }
.endurance .tags span.rain.hi  { color: #06182b; background: var(--blue-br); border-color: var(--blue-br); font-weight: 700; }
.endurance .row-dur { text-align: right; }
.endurance .row.is-special { border-color: rgba(56,169,232,.5); }
.endurance .row.is-special::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, #38a9e8, #007AC2);
}
.endurance .row.is-marathon::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, #ffd166, #b9852a);
}

/* ---- month grouping ------------------------------------------------------ */

/* ---- race length: meter (magnitude) + the written duration ---------------- */
.endurance .dur-top { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; }
.endurance .dur-val { font-family: "Racing Sans One", sans-serif; font-size: 19px; color: var(--ink); }
.endurance .dur-tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: 1.1px; text-transform: uppercase;
  color: #06182b; background: var(--meter-marathon); padding: 3px 8px; border-radius: 999px;
}
.endurance .meter { height: 7px; border-radius: 999px; background: rgba(255,255,255,.07); margin-top: 6px; overflow: hidden; }
.endurance .meter i { display: block; height: 100%; border-radius: 999px; background: var(--meter); }
.endurance .row.is-marathon .meter i { background: var(--meter-marathon); }

.endurance .empty { color: var(--muted); padding: 26px 0; text-align: center; }

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 900px) {
  .endurance .row { grid-template-columns: 78px 1fr; gap: 12px; }
  .endurance .row-logo { display: none; }          /* the series name already says it */
  .endurance .row-dur { grid-column: 2; text-align: left; }
  .endurance .row-dur .dur-top { justify-content: flex-start; }
  .endurance .nextup { grid-template-columns: 1fr; gap: 12px; }
  .endurance .countdown { text-align: left; }
  .endurance .filters select { min-width: 0; width: 100%; }
  .endurance .f-field { flex: 1 1 190px; }
  .endurance .f-count { margin-left: 0; }
}
