/* Shared light/dark palette for all pages. theme.js sets data-theme on <html>. */
:root,:root[data-theme="light"]{
  color-scheme:light;
  --bg:#f7f6f2;--panel:#fff;--line:#d8d6cd;--line-strong:#b9b6aa;
  --ink:#222;--ink2:#444;--sub:#777;--muted:#666;
  --inset:#f1efe8;--ctrl:#fff;--ctrl-active:#e8e6de;--on-ink:#fff;
  --shadow:rgba(0,0,0,.06);--elim:#c62828;
  --up:#2e7d32;--down:#c62828;
}
:root[data-theme="dark"]{
  color-scheme:dark;
  --bg:#12151a;--panel:#191d24;--line:#2a2f38;--line-strong:#454c58;
  --ink:#eef0f2;--ink2:#c4cad2;--sub:#9aa3af;--muted:#9aa3af;
  --inset:#0f1216;--ctrl:#1c2029;--ctrl-active:#262b35;--on-ink:#0f1216;
  --shadow:rgba(0,0,0,.35);--elim:#ef5350;
  --up:#66bb6a;--down:#ef5350;
}
/* Prevents Mobile Safari from auto-inflating the font size of short, isolated text (like a lone
   row label next to a wrapped control) beyond what its CSS actually specifies. */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%;}
html,body{background:var(--bg);color:var(--ink);}

.theme-bar{display:flex;justify-content:flex-end;margin:0 0 14px;min-height:30px;}
/* issue #27: the theme setting is now a single dropdown trigger (icon + current theme + chevron)
   instead of an always-visible three-button row. */
.theme-dd{position:relative;display:inline-block;}
.theme-trigger{display:inline-flex;align-items:center;gap:6px;padding:5px 10px;border:1px solid var(--line);border-radius:8px;
  background:var(--panel);color:var(--ink2);font:inherit;font-size:12px;font-weight:500;line-height:1.4;cursor:pointer;}
.theme-trigger:hover{border-color:var(--line-strong);color:var(--ink);}
.theme-trigger:focus-visible{outline:2px solid var(--line-strong);outline-offset:1px;}
.theme-trigger svg{width:14px;height:14px;flex:none;}
.theme-trigger .theme-chevron{width:10px;height:10px;color:var(--sub);}
.theme-menu{position:absolute;top:calc(100% + 6px);right:0;background:var(--panel);border:1px solid var(--line);border-radius:10px;
  box-shadow:0 6px 18px var(--shadow);padding:4px;display:flex;flex-direction:column;min-width:148px;z-index:20;}
.theme-menu[hidden]{display:none;} /* higher specificity than .theme-menu's display:flex, so [hidden] actually hides it */
.theme-menu button{display:flex;align-items:center;gap:8px;margin:0;border:none;background:transparent;color:var(--ink);font:inherit;
  font-size:12.5px;padding:7px 10px;border-radius:6px;cursor:pointer;text-align:left;white-space:nowrap;}
.theme-menu button:hover{background:var(--inset);}
.theme-menu button[aria-checked="true"]{background:var(--inset);font-weight:600;}
.theme-menu button:focus-visible{outline:2px solid var(--line-strong);outline-offset:1px;}
.theme-menu svg{width:14px;height:14px;flex:none;color:var(--ink2);}

/* F1Controls — season/round picker, shared across data-driven pages */
.f1c{background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:12px 14px;margin:0 0 16px;}
.f1c-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:6px 0;}
.f1c-label{font-size:12.5px;color:var(--sub);display:flex;align-items:center;gap:6px;}
.f1c-year{font:inherit;background:var(--inset);color:var(--ink);border:1px solid var(--line);border-radius:6px;padding:5px 8px;}
.f1c-status,.f1c-statusline{font-size:11.5px;color:var(--sub);}
/* issue #23/#48: small text buttons in the status line and error message (Refresh data, Retry) */
.f1c-link{font:inherit;font-size:11.5px;font-weight:400;background:none;border:none;border-radius:0;padding:0;color:var(--ink2);
  text-decoration:underline;text-underline-offset:2px;cursor:pointer;transform:none;opacity:1;}
.f1c-link:hover{color:var(--ink);}
.f1c-link:disabled{color:var(--sub);text-decoration:none;cursor:default;}
/* issue #48: shown when f1api.dev couldn't be reached — failures are never cached, so Retry just reloads */
.f1c-error{font-size:12px;color:var(--elim);margin:6px 0;line-height:1.5;}
.f1c-error[hidden]{display:none;}
.f1c-error .f1c-link{font-size:12px;margin-left:4px;color:var(--elim);}
.f1c-round{flex:1;width:100%;accent-color:var(--ink);}
.f1c-roundlabel{display:block;font-size:12px;color:var(--ink2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;height:16px;}

/* Draggable actual/projected divider handle on the x-axis of a time-series chart */
.drag-handle{position:absolute;width:18px;height:18px;margin-left:-9px;margin-top:-9px;
  background:var(--panel);border:2px solid var(--ink2);border-radius:5px;cursor:grab;touch-action:none;
  box-shadow:0 1px 3px var(--shadow);z-index:5;}
.drag-handle:active{cursor:grabbing;background:var(--inset);}
.drag-handle::after{content:"";position:absolute;left:50%;top:50%;width:6px;height:6px;
  transform:translate(-50%,-50%);border-left:2px solid var(--sub);border-right:2px solid var(--sub);box-sizing:border-box;}

/* Small pill buttons — sort toggle, selection presets */
.btnrow{display:flex;flex-wrap:wrap;gap:6px;}
.pill{background:var(--inset);color:var(--ink2);border:1px solid var(--line);border-radius:6px;padding:4px 10px;font-size:11.5px;cursor:pointer;font:inherit;}
.pill:hover{border-color:var(--ink2);}
.pill.active{background:var(--ink);color:var(--on-ink);border-color:var(--ink);}

/* issue #13 (mobile): end-of-line chart labels fold into a legend list below the chart instead of
   squeezing the plot's right-hand padding. All sort controls (chart sort, driver/team picker sort)
   are plain <select> dropdowns at every screen size — see .ddSelect below. */
.endLegend{display:none;flex-direction:column;gap:5px;margin-top:10px;padding-top:10px;border-top:1px solid var(--line);}
.endLegendRow{display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--ink2);}
.endLegendRank{color:var(--sub);width:18px;text-align:right;flex:0 0 auto;font-variant-numeric:tabular-nums;}
.endLegendDot{width:8px;height:8px;border-radius:50%;flex:0 0 auto;}
.endLegendName{flex:1;font-weight:500;}
.endLegendPts{color:var(--sub);font-variant-numeric:tabular-nums;flex:0 0 auto;}
/* Shared visual style for a dropdown <select> used as a control (sort pickers, etc.) */
.ddSelect{font:inherit;font-size:12.5px;background:var(--inset);color:var(--ink);border:1px solid var(--line);border-radius:6px;padding:5px 8px;}
@media (max-width:600px){
  .endLegend{display:flex;}
}

/* issue #13: display-option checkboxes (replaces a pill row for toggles like Below P10/Mechanical
   DNFs/Sprints) — a row of label+checkbox pairs that wraps naturally at any width. The "Show" label
   sits on its own full-width line above this row (see position.html), so it never competes for
   horizontal space with the checkboxes themselves. */
.optCheckRow{display:flex;flex-wrap:wrap;gap:6px 14px;align-items:center;}
.optCheck{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--ink2);cursor:pointer;white-space:nowrap;}
.optCheck input{margin:0;}

/* issue #44: driver/team picker list below each chart — checkbox, (rank), team-color dot, name, points.
   Rows are built by F1Common.driverPickerRowHTML() (drivers) and constructors.html's team version. */
#driverPicker,#teamPicker{max-height:280px;overflow-y:auto;}
.pickerTeamLabel{font-size:11px;color:var(--sub);padding:10px 2px 4px;}
.pickerTeamLabel:first-child{padding-top:2px;}
.pickerRow{display:flex;align-items:center;gap:10px;padding:6px 2px;border-bottom:0.5px solid var(--line);cursor:pointer;}
.pickerRow:last-child{border-bottom:none;}
.pickerRow input{margin:0;flex:0 0 auto;}
.pickerRank{font-size:11px;color:var(--sub);width:16px;text-align:right;flex:0 0 auto;}
.pickerDot{width:8px;height:8px;border-radius:50%;flex:0 0 auto;}
.pickerCode,.pickerName{font-size:13px;font-weight:500;flex:1;}
.pickerCode.off,.pickerName.off{color:var(--sub);font-weight:400;}
.pickerCodeTag{font-size:10px;color:var(--sub);font-weight:400;margin-left:6px;}
.pickerPts{font-size:12px;color:var(--sub);font-variant-numeric:tabular-nums;flex:0 0 auto;}

/* issue #48: loading placeholder. controls.js puts .f1-loading on <html> while a season loads; each page
   marks its chart and picker slots with .f1-skel. The placeholder only appears if loading takes longer
   than 150ms, so instant loads from the cache don't flash. */
.f1-skel{position:relative;}
html.f1-loading .f1-skel{min-height:200px;}
html.f1-loading .drag-handle{visibility:hidden;} /* it'd sit on the placeholder at round 1 */
html.f1-loading .f1-skel::after{content:"";position:absolute;inset:0;z-index:6;border-radius:8px;background:var(--inset);
  animation:f1skel-show 0s linear .15s both, f1skel-pulse 1.4s ease-in-out .15s infinite;}
@keyframes f1skel-show{from{visibility:hidden;}to{visibility:visible;}}
@keyframes f1skel-pulse{0%,100%{opacity:1;}50%{opacity:.45;}}
@media (prefers-reduced-motion:reduce){
  html.f1-loading .f1-skel::after{animation:f1skel-show 0s linear .15s both;}
}

/* issue #47: places gained/lost in the standings since the previous round, just before the points */
.pickerMove{font-size:11px;font-weight:600;font-variant-numeric:tabular-nums;width:26px;text-align:right;flex:0 0 auto;}
.pickerMove.up{color:var(--up);}
.pickerMove.down{color:var(--down);}
