/* ==========================================================================
   WOR at the Specials — our members' top-10 finishes in iRacing's marquee
   special events.

   Scoped under .specials (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 finishing position is encoded
   ---------------------------------
   Position is ORDINAL, and the top three carry a cultural convention that reads
   instantly, so P1/P2/P3 wear gold/silver/bronze and everything from P4 to P10
   is neutral. Colour is never the only channel: the position is ALWAYS written
   in the badge ("P1", "P7"), so a reader who can't separate the hues loses
   nothing.

   Validated against this page's panel (#111c33) with the palette validator:
   worst adjacent pair ΔE 14.7 under protanopia (floor 8) and 15.5 normal vision
   (floor 15), every step ≥ 3:1 contrast. The validator's lightness-band and
   chroma-floor checks fail by design — they police CATEGORICAL palettes, and
   this is an ordinal medal ramp in which silver is meant to read as grey.
   ========================================================================== */
.specials {
  --gold: #ffd166;
  --silver: #cbd5e1;
  --bronze: #e08a4a;
}

/* ---- headline tiles ------------------------------------------------------ */
.specials .tiles { grid-template-columns: repeat(5, 1fr); }
.specials .tile.g::before { background: var(--gold); }
@media (max-width: 900px) { .specials .tiles { grid-template-columns: repeat(2, 1fr); } }

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

/* ---- the position badge — colour + the written position, always ---------- */
.specials .pos {
  display: inline-grid; place-items: center; min-width: 40px; height: 34px;
  border-radius: 9px; font-family: "Racing Sans One", sans-serif; font-size: 15px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--ink-2);
  font-variant-numeric: tabular-nums; padding: 0 7px;
}
.specials .pos.p1 { background: var(--gold);   border-color: var(--gold);   color: #06182b; font-weight: 700; }
.specials .pos.p2 { background: var(--silver); border-color: var(--silver); color: #06182b; font-weight: 700; }
.specials .pos.p3 { background: var(--bronze); border-color: var(--bronze); color: #06182b; font-weight: 700; }
.specials .pos.sm { min-width: 33px; height: 27px; font-size: 13px; }

/* medal tallies on a driver/team row */
.specials .medals { display: flex; gap: 5px; align-items: center; }
.specials .medal {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px;
  padding: 3px 8px; border-radius: 999px; font-variant-numeric: tabular-nums;
  border: 1px solid var(--line); color: var(--muted); background: rgba(255,255,255,.04);
}
.specials .medal.g { color: #06182b; background: var(--gold);   border-color: var(--gold);   font-weight: 700; }
.specials .medal.s { color: #06182b; background: var(--silver); border-color: var(--silver); font-weight: 700; }
.specials .medal.b { color: #06182b; background: var(--bronze); border-color: var(--bronze); font-weight: 700; }
.specials .medal.z { opacity: .35; }

/* ---- driver / team rows -------------------------------------------------- */
.specials .plist { display: flex; flex-direction: column; gap: 7px; }
.specials .prow {
  display: grid; grid-template-columns: 34px 1fr auto auto; gap: 14px; align-items: center;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 15px;
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.specials .prow:hover { border-color: #33507a; }
.specials .prow:focus-visible { outline: 2px solid var(--blue-br); outline-offset: 2px; }
.specials .prow .rank { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.specials .prow .who { min-width: 0; }
.specials .prow .who h3 { font-size: 15.5px; line-height: 1.25; }
.specials .prow .who .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.specials .prow .tot { color: var(--ink-2); font-size: 12.5px; text-align: right; white-space: nowrap; }
.specials .prow .tot b { font-family: "Racing Sans One", sans-serif; font-size: 17px; color: var(--ink); display: block; }
.specials .prow[aria-expanded="true"] { border-color: var(--blue-br); }

/* a driver's / team's expanded result list */
.specials .drawer { padding: 2px 0 12px 12px; border-left: 2px solid var(--line); margin: 2px 0 6px 16px; }

/* ---- one result row ------------------------------------------------------ */
.specials .res {
  display: grid; grid-template-columns: 46px 60px 1fr auto; gap: 13px; align-items: center;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 11px; padding: 10px 14px; margin-bottom: 7px;
}
.specials .res.win { border-color: rgba(255,209,102,.45); }
/* Series logo. It streams from iRacing's CDN; if there's no logo for that event
   (common pre-2014) the <img> deletes itself and this wrapper shows a 🏁 tile. */
.specials .logowrap { display: grid; place-items: center; }
.specials .logowrap img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.specials .logowrap.failed { background: rgba(255,255,255,.05); border-radius: 6px; }
.specials .logowrap.failed::after { content: "🏁"; }
.specials .res .logowrap { width: 60px; height: 36px; font-size: 15px; }
.specials .res .mid { min-width: 0; }
.specials .res .mid h4 { font-size: 14.5px; line-height: 1.25; }
.specials .res .mid .where { color: var(--ink-2); font-size: 12px; margin-top: 2px; }
.specials .res .mid .who { color: var(--muted); font-size: 12px; margin-top: 3px; }
.specials .res .mid .who b { color: var(--ink-2); font-weight: 600; }
.specials .res .right { text-align: right; white-space: nowrap; font-size: 11.5px; color: var(--muted); }
.specials .res .right .fld { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.specials .res .right a { font-size: 11.5px; }

/* context chips: split, field, class size, SoF */
.specials .chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.specials .chips 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;
  font-variant-numeric: tabular-nums;
}
.specials .chips span.cls { color: var(--blue-br); border-color: rgba(56,169,232,.4); }
.specials .chips span.top { color: var(--gold); border-color: rgba(255,209,102,.4); }

/* team-mate chips — league members stand out, guests are present but quiet */
.specials .mates { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.specials .mate {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--muted);
}
.specials .mate.wor { color: var(--ink); border-color: rgba(56,209,122,.45); background: rgba(56,209,122,.10); font-weight: 600; }

/* ---- event cards --------------------------------------------------------- */
.specials .evgrid { display: grid; gap: 11px; grid-template-columns: repeat(2, 1fr); }
@media (max-width: 820px) { .specials .evgrid { grid-template-columns: 1fr; } }
.specials .ev {
  display: grid; grid-template-columns: 68px 1fr; gap: 13px;
  background: linear-gradient(150deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 13px; padding: 13px 15px;
}
.specials .ev .logowrap { width: 68px; height: 42px; font-size: 17px; }
.specials .ev h3 { font-size: 15.5px; line-height: 1.2; }
.specials .ev .where { color: var(--ink-2); font-size: 12px; margin-top: 3px; }
.specials .ev .field { color: var(--muted); font-size: 11.5px; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ---- year headings ------------------------------------------------------- */
.specials .yr {
  display: flex; align-items: center; gap: 12px; margin: 22px 0 10px;
  color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: 2px;
}
.specials .yr::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.specials .empty { color: var(--muted); padding: 26px 0; text-align: center; }

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 780px) {
  .specials .res { grid-template-columns: 46px 1fr; }
  .specials .res .logowrap { display: none; }
  .specials .res .right { grid-column: 2; text-align: left; }
  .specials .prow { grid-template-columns: 28px 1fr; }
  .specials .prow .tot, .specials .prow .medals { grid-column: 2; }
  .specials .prow .tot { text-align: left; }
  .specials .filters select, .specials .filters input { min-width: 0; width: 100%; }
  .specials .f-field { flex: 1 1 170px; }
  .specials .f-count { margin-left: 0; }
}
