/* The car development section of a team page (scripts/carDevelopment.js).
   One plot, a column per round: the Car score as a line across the top, the
   updates filed for that race as a bar beneath, and the chosen round's
   updates written out below. Tokens come from signal.css; the team's colour
   is the profile page's own --team-colour. */

.cd {
  --cd-ink: var(--sg-ink);
  --cd-muted: var(--sg-muted);
  --cd-line: var(--sg-line);
  --cd-line-strong: var(--sg-line-strong);
  --cd-mist: var(--sg-mist);
  --cd-paper: var(--sg-paper);
  --cd-ease: var(--sg-ease, cubic-bezier(0.22, 1, 0.36, 1));
  --cd-track: clamp(132px, 22vw, 188px);
  --cd-bars: 76px;
  padding: 2.5rem 0;
  border-top: 1px solid var(--cd-line);
}
.cd[hidden] { display: none; }

.cd-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; }
.cd-head h2 { margin: 0 0 1.25rem; font-size: 1.5rem; }
.cd-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--cd-ink); font-size: 0.875rem; font-weight: 650; text-decoration: underline; text-decoration-color: var(--team-colour); text-decoration-thickness: 2px; text-underline-offset: 0.3em; }
.cd-link:hover { text-decoration-color: var(--cd-ink); }

.cd-facts { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin: 0 0 28px; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--cd-line); background: var(--cd-mist); }
.cd-facts div { padding: 18px 20px; box-shadow: inset 1px 0 0 var(--cd-line); }
.cd-facts div:first-child { box-shadow: none; }
.cd-facts dt { color: var(--cd-muted); font-size: 0.8125rem; }
.cd-facts dd { margin: 6px 0 0; font-size: clamp(1.5rem, 2.6vw, 2.125rem); font-weight: 720; letter-spacing: -0.035em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.cd-facts small { color: var(--cd-muted); font-size: 0.8125rem; font-weight: 600; letter-spacing: 0; }

/* ---- The plot ---- */

.cd-figure { --cd-rounds: 16; --cd-at: 0.5; position: relative; display: grid; gap: 12px; }
.cd-readout { justify-self: center; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px; min-height: 40px; max-width: 100%; margin: 0; padding: 8px 18px; border-radius: 999px; background: var(--sg-night); color: var(--sg-cream); font-size: 0.875rem; font-variant-numeric: tabular-nums; transition: padding 260ms var(--cd-ease); }
.cd-readout b { color: var(--sg-orange); font-weight: 760; }
.cd-readout span:first-of-type { font-weight: 700; }
.cd-readout-fact { color: var(--sg-muted-dark); }

.cd-plot { --cd-gutter: 30px; position: relative; padding: 4px 0 0 var(--cd-gutter); }
.cd-plot.is-unscored { --cd-gutter: 0px; }
/* the round in hand, as a line down the plot */
.cd-plot::before { content: ""; position: absolute; top: 0; bottom: 28px; left: calc(var(--cd-gutter) + var(--cd-at) / var(--cd-rounds) * (100% - var(--cd-gutter))); width: 1px; background: var(--cd-line-strong); transition: left 320ms var(--cd-ease); pointer-events: none; }
.cd-lines { position: absolute; top: 4px; left: var(--cd-gutter); width: calc(100% - var(--cd-gutter)); height: var(--cd-track); overflow: visible; pointer-events: none; }
.cd-grid { stroke: var(--cd-line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.cd-score { fill: none; stroke: var(--cd-ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.cd-scale { position: absolute; top: 4px; left: 0; width: 100%; height: var(--cd-track); color: var(--cd-muted); font-size: 0.6875rem; font-weight: 650; font-variant-numeric: tabular-nums; pointer-events: none; }
.cd-scale span { position: absolute; left: 0; bottom: calc(var(--cd-y) * 100%); line-height: 1; transform: translateY(50%); }

.cd-columns { position: relative; display: grid; grid-template-columns: repeat(var(--cd-rounds), minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
.cd-columns li { display: grid; }
.cd-col { display: grid; grid-template-rows: var(--cd-track) var(--cd-bars) 28px; justify-items: center; min-width: 0; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--cd-muted); font: inherit; cursor: pointer; transition: background-color 220ms var(--cd-ease); }
/* the highlight sits under the bars only, so it never covers the score line */
.cd-col:hover { background: linear-gradient(to bottom, transparent var(--cd-track), var(--cd-mist) var(--cd-track)); }
.cd-plot.is-unscored .cd-col:hover { background: var(--cd-mist); }
.cd-col[aria-pressed="true"] { color: var(--cd-ink); }
.cd-col:focus-visible { outline: 2px solid var(--sg-orange); outline-offset: -2px; }
.cd-plot.is-unscored .cd-col { grid-template-rows: 0 var(--cd-bars) 28px; }
.cd-track { position: relative; width: 100%; }
.cd-dot { position: absolute; left: 50%; bottom: calc(var(--cd-y) * 100%); width: 10px; height: 10px; border-radius: 50%; background: var(--team-colour); box-shadow: 0 0 0 2px var(--cd-ink); transform: translate(-50%, 50%); transition: transform 260ms var(--cd-ease); }
.cd-col:hover .cd-dot, .cd-col[aria-pressed="true"] .cd-dot { transform: translate(-50%, 50%) scale(1.45); }
.cd-bars { position: relative; display: flex; flex-direction: column-reverse; align-items: center; justify-content: flex-start; gap: 2px; width: 100%; padding-top: 18px; border-top: 1px solid var(--cd-line); }
.cd-bar { display: block; width: min(64%, 26px); height: calc(var(--cd-share) * (var(--cd-bars) - 20px)); min-height: 4px; border-radius: 4px; background: var(--team-colour); box-shadow: inset 0 0 0 1px var(--cd-line-strong); }
.cd-bar.is-circuit { background: repeating-linear-gradient(135deg, var(--team-colour) 0 3px, var(--cd-paper) 3px 6px); }
.cd-bar.is-reliability { background: var(--cd-muted); box-shadow: none; }
.cd-count { order: 9; font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.cd-round { align-self: center; font-size: 0.8125rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.cd-col[aria-pressed="true"] .cd-round { display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 999px; background: var(--cd-ink); color: var(--cd-paper); }

.cd-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0; padding: 0; list-style: none; color: var(--cd-muted); font-size: 0.8125rem; }
.cd-legend li { display: flex; align-items: center; gap: 8px; }
.cd-legend .cd-bar { width: 14px; height: 10px; min-height: 0; border-radius: 3px; }
.cd-key-score { position: relative; width: 22px; height: 2px; background: var(--cd-ink); }
.cd-key-score::after { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: var(--team-colour); box-shadow: 0 0 0 2px var(--cd-ink); transform: translate(-50%, -50%); }

/* ---- The chosen round ---- */

.cd-detail { margin-top: 24px; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--cd-line); background: var(--cd-paper); }
.cd-detail-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 32px; padding: 22px 24px 20px; border-bottom: 1px solid var(--cd-line); box-shadow: inset 4px 0 0 var(--team-colour); border-radius: 16px 16px 0 0; }
.cd-detail-round { margin: 0 0 4px; color: var(--cd-muted); font-size: 0.8125rem; font-weight: 650; }
.cd-detail-head h3 { margin: 0; font-size: clamp(1.25rem, 2.4vw, 1.625rem); letter-spacing: -0.03em; line-height: 1.2; }
.cd-detail-score { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; }
.cd-detail-score dt { color: var(--cd-muted); font-size: 0.75rem; }
.cd-detail-score dd { margin: 2px 0 0; font-size: 1.25rem; font-weight: 720; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cd-detail-score dd.is-up { color: var(--sg-orange-ink); }
.cd-detail-score dd.is-down { color: var(--cd-muted); }

.cd-updates { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); margin: 0; padding: 0; list-style: none; }
.cd-update { padding: 18px 24px; box-shadow: inset 0 -1px 0 var(--cd-line), inset -1px 0 0 var(--cd-line); animation: cd-in 420ms var(--cd-ease) both; }
.cd-update-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; }
.cd-update-head strong { font-size: 1.0625rem; font-weight: 700; letter-spacing: -0.02em; }
.cd-update-reason { padding: 3px 10px; border-radius: 999px; background: var(--cd-mist); color: var(--cd-muted); font-size: 0.75rem; font-weight: 650; }
.cd-update.is-circuit .cd-update-reason { color: var(--sg-orange-ink); }
.cd-update-summary { max-width: 62ch; margin: 6px 0 0; color: var(--cd-muted); line-height: 1.55; }
.cd-none { margin: 0; padding: 22px 24px; color: var(--cd-muted); }
@keyframes cd-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.cd-detail-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; margin: 0; padding: 8px 24px 12px; }
.cd-step { display: flex; gap: 8px; margin-left: auto; }
.cd-step-button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--cd-mist); box-shadow: inset 0 0 0 1px var(--cd-line); color: var(--cd-ink); font: inherit; font-size: 0.8125rem; font-weight: 650; cursor: pointer; transition: background-color 220ms var(--cd-ease); }
.cd-step-button:hover:not(:disabled) { background: var(--cd-line); }
.cd-step-button:disabled { color: var(--cd-muted); opacity: 0.5; cursor: default; }
.cd-step-button:focus-visible { outline: 2px solid var(--sg-orange); outline-offset: 2px; }

@media (max-width: 760px) {
  .cd { --cd-bars: 64px; }
  .cd-plot { --cd-gutter: 22px; }
  .cd-facts { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
  .cd-facts div { padding: 14px 16px; }
  .cd-facts div:nth-child(odd) { box-shadow: none; }
  .cd-facts div:nth-child(n + 3) { box-shadow: inset 0 1px 0 var(--cd-line); }
  .cd-facts div:nth-child(4) { box-shadow: inset 0 1px 0 var(--cd-line), inset 1px 0 0 var(--cd-line); }
  .cd-col { border-radius: 6px; }
  .cd-dot { width: 8px; height: 8px; }
  .cd-bar { width: min(70%, 16px); border-radius: 3px; }
  .cd-count, .cd-round { font-size: 0.6875rem; }
  .cd-col[aria-pressed="true"] .cd-round { min-width: 20px; height: 20px; padding: 0 2px; }
  .cd-detail-head { padding: 18px 18px 16px; }
  .cd-update, .cd-none { padding: 16px 18px; }
  .cd-detail-links { padding: 6px 18px 12px; }
  .cd-step { width: 100%; margin-left: 0; }
  .cd-step-button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .cd-plot::before, .cd-dot, .cd-readout, .cd-col, .cd-step-button { transition: none; }
  .cd-update { animation: none; }
}

/* ---- the season as a count, and the drivers' power unit parts ---- */

.cd-tally, .cd-power { margin-top: clamp(20px, 2.4vw, 32px); }
.cd-tally h3, .cd-power h3 { margin: 0 0 10px; font-size: 1.125rem; font-weight: 720; letter-spacing: -0.03em; }
.cd-table-wrap { overflow-x: auto; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--dk-ln-e2e2df, #e2e2df); }
.cd-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cd-table th, .cd-table td { padding: 9px 14px; border-bottom: 1px solid var(--dk-ln-e2e2df, #e2e2df); text-align: left; font-weight: 500; }
.cd-table thead th { background: var(--dk-bg-f3f3f1, #f3f3f1); color: var(--dk-fg-5c5c5a, #5c5c5a); font-size: 0.75rem; font-weight: 650; }
.cd-table thead th small { display: block; font-size: 0.6875rem; font-weight: 500; }
.cd-table tbody tr:last-child > * { border-bottom: 0; }
.cd-table .cd-num { text-align: right; white-space: nowrap; }
.cd-table tbody td:first-child { width: 3.5rem; color: var(--dk-fg-5c5c5a, #5c5c5a); font-weight: 650; }
.cd-table tbody tr.is-none td.cd-num:nth-child(3) { color: var(--dk-fg-5c5c5a, #5c5c5a); }
.cd-table tfoot th, .cd-table tfoot td { border-top: 1px solid var(--dk-ln-cfcfcb, #cfcfcb); border-bottom: 0; background: var(--dk-bg-f3f3f1, #f3f3f1); font-weight: 720; }
.cd-pick { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 650; text-align: left; cursor: pointer; }
.cd-pick:hover, .cd-driver:hover { text-decoration: underline; text-decoration-color: var(--orange, #ff6b00); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.cd-pick:focus-visible, .cd-driver:focus-visible { outline: 2px solid var(--orange, #ff6b00); outline-offset: 3px; }
.cd-driver { color: inherit; font-weight: 650; text-decoration: none; }
.cd-power-table abbr { text-decoration: none; }
.cd-part { display: inline-flex; align-items: center; justify-content: center; min-width: 1.75rem; height: 1.75rem; border-radius: 8px; font-weight: 720; }
.cd-part.is-limit { box-shadow: inset 0 0 0 1.5px var(--orange, #ff6b00); }
.cd-part.is-over { background: var(--orange, #ff6b00); color: #141414; }
.cd-power-key { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; padding: 0; list-style: none; color: var(--dk-fg-5c5c5a, #5c5c5a); font-size: 0.8125rem; }
.cd-power-key li { display: inline-flex; align-items: center; gap: 8px; }
.cd-power-key .cd-part { min-width: 1rem; width: 1rem; height: 1rem; border-radius: 5px; }
.cd-power-note { margin: 8px 0 0; color: var(--dk-fg-5c5c5a, #5c5c5a); font-size: 0.8125rem; }

@media (max-width: 560px) {
  .cd-table th, .cd-table td { padding: 8px 8px; }
  .cd-power-table thead th small { display: none; }
  /* seven parts and a name across a phone: tighter cells rather than a sideways scroll */
  .cd-power-table th, .cd-power-table td { padding: 8px 3px; }
  .cd-power-table th:first-child { padding-left: 10px; }
  .cd-power-table thead th { font-size: 0.6875rem; }
  .cd-part { min-width: 1.5rem; height: 1.5rem; }
}
