/* DIRTSKILL pages and the home page DIRTSKILL box.
   Colors and fonts come from the DIRTSIM template's --ds-* variables;
   the fallbacks keep everything readable under any other template. */

.ds {
  --_bg: var(--ds-bg, #1e1e22);
  --_surface: var(--ds-surface, #27272b);
  --_line: var(--ds-line, #3b3b42);
  --_frame: var(--ds-frame, #4a4a52);
  --_rule: var(--ds-orange, #fa5900);
  --_text: var(--ds-text, #f1f1f3);
  --_muted: var(--ds-muted, #a7a7b0);
  --_accent: var(--ds-accent, #ff6b1a);
  --_ink: var(--ds-ink, #0c0c0e);
  --_up: var(--ds-up, #6fd38a);
  --_down: var(--ds-down, #ff6b81);
  --_display: var(--ds-display, "Saira", "Arial Narrow", sans-serif);
  color: var(--_text);
  font-variant-numeric: tabular-nums;
}

.ds a {
  color: var(--_text);
  text-decoration-color: var(--_frame);
  text-underline-offset: 3px;
}

.ds a:hover,
.ds a:focus-visible {
  color: var(--_accent);
  text-decoration-color: var(--_accent);
}

/* Page heads */

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

.ds-title {
  margin: 0;
  font-family: var(--_display);
  font-style: italic;
  font-stretch: 118%;
  font-weight: 800;
  font-size: clamp(2rem, 5.5vw, 3.25rem);
  line-height: 1;
}

.ds-sub {
  margin: 2.5rem 0 0.75rem;
  font-family: var(--_display);
  font-style: italic;
  font-stretch: 118%;
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1;
}

.ds .ds-back {
  display: inline-block;
  margin-bottom: 0.4rem;
  color: var(--_muted);
  font-size: 0.95rem;
  text-decoration: none;
}

.ds .ds-back:hover,
.ds .ds-back:focus-visible {
  color: var(--_accent);
}

.ds-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0.6rem 0 0;
  color: var(--_muted);
}

.ds-search input {
  width: min(18rem, 100%);
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--_line);
  border-radius: 4px;
  background: var(--_surface);
  color: var(--_text);
  font: inherit;
}

.ds-search input::placeholder {
  color: var(--_muted);
}

.ds-search input:focus-visible {
  outline: 2px solid var(--_accent);
  outline-offset: 1px;
  border-color: var(--_accent);
}

.ds-empty {
  padding: 1.5rem 0;
  color: var(--_muted);
  font-size: 1.1rem;
}

/* Tables */

.ds-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

.ds-table th,
.ds-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--_line);
  text-align: left;
  vertical-align: middle;
}

.ds-table thead th {
  padding-top: 0.4rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--_rule);
  color: var(--_muted);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.ds-table tbody th {
  font-weight: 600;
}

.ds-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.ds-table .ds-num {
  text-align: right;
  white-space: nowrap;
}

/* Rows that open a driver or a race when clicked. */
.ds-table tr[data-href] {
  cursor: pointer;
}

.ds-table tbody tr[data-href]:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ds-table tbody tr[data-href]:hover .ds-name a,
.ds-table tbody tr[data-href]:hover td a {
  color: var(--_accent);
}

.ds-table tbody a {
  text-decoration: none;
}

.ds-table tbody a:hover,
.ds-table tbody a:focus-visible {
  text-decoration: underline;
}

.ds-nowrap {
  white-space: nowrap;
}

.ds-muted,
.ds-table .ds-muted {
  color: var(--_muted);
}

.ds-strong {
  font-weight: 700;
}

/* Rank cells read like the lit numbers on a scoring tower. */
.ds-table .ds-rank {
  width: 3.5rem;
  color: var(--_accent);
  font-family: var(--_display);
  font-style: italic;
  font-stretch: 112%;
  font-weight: 800;
  font-size: 1.3rem;
  line-height: 1;
}

.ds-table .ds-rating {
  font-family: var(--_display);
  font-stretch: 112%;
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1;
}

.ds-podium .ds-rank {
  font-size: 1.55rem;
}

.ds-up {
  color: var(--_up);
  font-weight: 600;
}

.ds-down {
  color: var(--_down);
  font-weight: 600;
}

.ds-even {
  color: var(--_muted);
}

.ds-ai th,
.ds-ai td {
  color: var(--_muted);
}

.ds-tag {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0 0.4rem;
  border: 1px solid var(--_frame);
  border-radius: 3px;
  color: var(--_muted);
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: 0.1em;
}

.ds-table .ds-fast {
  color: var(--_accent);
  font-weight: 700;
}

.ds-pages {
  margin-top: 1.5rem;
}

/* Driver page */

.ds-profile {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin-bottom: 1.75rem;
}

.ds-profile-name {
  min-width: 0;
}

.ds-profile .ds-title {
  overflow-wrap: anywhere;
}

.ds-big {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* The rating is painted like the logo lettering: white, black outline,
   orange shadow, wide and slanted. */
.ds-big-value {
  color: #fff;
  font-family: var(--_display);
  font-style: italic;
  font-stretch: 125%;
  font-weight: 900;
  font-size: clamp(4rem, 14vw, 7rem);
  line-height: 0.9;
  -webkit-text-stroke: 0.05em var(--_ink);
  paint-order: stroke fill;
  text-shadow: 0.06em 0.06em 0 var(--_rule);
}

.ds-big-label {
  order: 2;
  margin-top: 0.5rem;
  color: var(--_muted);
  font-family: var(--_display);
  font-style: italic;
  font-stretch: 118%;
  font-weight: 700;
  font-size: 1.05rem;
}

.ds-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  margin: 0 0 1.5rem;
  border-top: 1px solid var(--_line);
  border-bottom: 1px solid var(--_line);
}

.ds-stats > div {
  padding: 0.75rem 1rem 0.85rem 0;
}

.ds-stats dt {
  color: var(--_muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.ds-stats dd {
  margin: 0.15rem 0 0;
  font-family: var(--_display);
  font-stretch: 112%;
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 1.1;
}

.ds-stats-sm {
  margin: 0;
  border: 0;
  grid-template-columns: repeat(2, minmax(5.5rem, auto));
}

.ds-stats-sm > div {
  padding: 0 0 0 1.5rem;
}

/* DIRTSKILL over time. The line stretches to fit; the axis numbers are
   plain text on top, so they stay the same size on a phone. */

.ds-chart-wrap {
  margin: 0.5rem 0;
}

.ds-chart {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
  grid-template-rows: 220px auto;
  margin: 0;
}

.ds-chart-y {
  position: relative;
  grid-column: 1;
  grid-row: 1;
}

.ds-chart-y span {
  position: absolute;
  right: 0.6rem;
  transform: translateY(-50%);
  color: var(--_muted);
  font-size: 0.8rem;
  line-height: 1;
}

.ds-chart-plot {
  position: relative;
  grid-column: 2;
  grid-row: 1;
}

.ds-chart-plot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ds-chart-x {
  position: relative;
  grid-column: 2;
  grid-row: 2;
  height: 1.7rem;
}

.ds-chart-x span {
  position: absolute;
  top: 0.4rem;
  transform: translateX(-50%);
  color: var(--_muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.ds-chart-x span:first-child {
  transform: none;
}

.ds-chart-x span:last-child {
  transform: translateX(-100%);
}

.ds-chart .ds-grid {
  stroke: var(--_line);
  stroke-width: 1;
}

.ds-chart .ds-line {
  fill: none;
  stroke: var(--_accent);
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.ds-chart .ds-area {
  fill: var(--_accent);
  opacity: 0.1;
}

.ds-chart-last {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid var(--_bg);
  border-radius: 50%;
  background: var(--_accent);
  transform: translate(-50%, -50%);
}

/* Home page box: top drivers as a scoring tower, framed like the logo
   (orange edge with a thin gray line inside). */

.ds-pylon {
  margin: 0;
  padding: 0.4rem 0.5rem;
  list-style: none;
  background: #151518;
  border: 3px solid var(--_rule);
  box-shadow: inset 0 0 0 4px #151518, inset 0 0 0 5px var(--_frame);
}

.ds-pylon li + li {
  border-top: 1px solid #2a2a30;
}

.ds .ds-pylon a {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.5rem 0.6rem;
  color: var(--_text);
  text-decoration: none;
}

.ds .ds-pylon a:hover,
.ds .ds-pylon a:focus-visible {
  background: #202025;
  color: var(--_text);
}

.ds-pylon-pos {
  color: var(--_accent);
  font-family: var(--_display);
  font-style: italic;
  font-stretch: 125%;
  font-weight: 800;
  font-size: 1.45rem;
  line-height: 1;
  text-align: right;
}

.ds-pylon-name {
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ds-pylon-val {
  font-family: var(--_display);
  font-stretch: 112%;
  font-weight: 700;
  font-size: 1.1rem;
}

.ds-pylon li:first-child .ds-pylon-pos {
  font-size: 1.8rem;
}

/* The tower lights up top to bottom once when the page opens. */
@media (prefers-reduced-motion: no-preference) {
  .ds-pylon li {
    animation: ds-light 0.35s ease-out both;
  }

  .ds-pylon li:nth-child(2) { animation-delay: 0.05s; }
  .ds-pylon li:nth-child(3) { animation-delay: 0.1s; }
  .ds-pylon li:nth-child(4) { animation-delay: 0.15s; }
  .ds-pylon li:nth-child(5) { animation-delay: 0.2s; }
  .ds-pylon li:nth-child(6) { animation-delay: 0.25s; }
  .ds-pylon li:nth-child(7) { animation-delay: 0.3s; }
  .ds-pylon li:nth-child(8) { animation-delay: 0.35s; }
  .ds-pylon li:nth-child(9) { animation-delay: 0.4s; }
  .ds-pylon li:nth-child(n + 10) { animation-delay: 0.45s; }
}

@keyframes ds-light {
  from {
    opacity: 0.15;
  }

  to {
    opacity: 1;
  }
}

.ds .ds-more {
  display: inline-block;
  margin-top: 0.85rem;
  color: var(--_accent);
  font-weight: 600;
}

/* Home page box: latest races, one per row like a results sheet. */

.ds-latest {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 2px solid var(--_rule);
}

.ds-latest li {
  border-bottom: 1px solid var(--_line);
}

.ds .ds-latest a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.1rem 1.5rem;
  padding: 0.7rem 0;
  color: var(--_text);
  text-decoration: none;
}

.ds .ds-latest a:hover .ds-latest-track,
.ds .ds-latest a:focus-visible .ds-latest-track {
  color: var(--_accent);
}

.ds-latest-track {
  grid-column: 1;
  font-weight: 700;
}

.ds-latest-win {
  grid-column: 1;
}

.ds-latest-meta {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--_muted);
  font-size: 0.9rem;
  text-align: right;
}

/* Smaller screens */

@media (max-width: 980px) {
  .ds .ds-lg {
    display: none;
  }
}

@media (max-width: 720px) {
  .ds .ds-md {
    display: none;
  }

  .ds-table th,
  .ds-table td {
    padding: 0.55rem 0.5rem;
  }

  .ds-big {
    align-items: flex-start;
  }

  .ds-stats-sm > div {
    padding: 0 1.5rem 0 0;
  }

  .ds-chart {
    grid-template-columns: 3rem minmax(0, 1fr);
    grid-template-rows: 170px auto;
  }
}

@media (max-width: 520px) {
  .ds .ds-latest a {
    grid-template-columns: 1fr;
  }

  .ds-latest-meta {
    grid-column: 1;
    grid-row: auto;
    text-align: left;
  }
}
