/*
   Layout for the fuel price chart. Every colour is a token from
   /assets/styles.css — the series hues included — so light and dark mode and
   any future retheme happen in one place.
*/

/* ----- controls ---------------------------------------------------------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  align-items: flex-end;
}

.controls--range {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  align-items: center;
}

.seg {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.seg legend,
.picker legend,
.picker__count {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  padding: 0;
  margin-bottom: 6px;
}

.seg__options {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.seg__option {
  position: relative;
  display: inline-flex;
}

.seg__option + .seg__option { border-left: 1px solid var(--border-strong); }

.seg__option input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.seg__option span {
  padding: 7px 13px;
  font-size: 0.9rem;
  background: var(--bg-elevated);
  color: var(--text-muted);
  white-space: nowrap;
}

.seg__option:hover span { color: var(--text); }

.seg__option input:checked + span {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.seg__option input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.inline-field.checkbox { gap: 8px; }
.inline-field.checkbox input { accent-color: var(--accent); }

.controls--range select { max-width: 11rem; }
.controls--range button { padding: 6px 11px; font-size: 0.85rem; }

/* ----- country picker ---------------------------------------------------- */

.picker {
  border: 0;
  margin: 16px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
  min-width: 0;
}

.picker__count { margin: 0 0 10px; font-weight: 500; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

.chip:hover { border-color: var(--accent); color: var(--text); }

.chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: inherit;
}

.chip input:disabled { cursor: not-allowed; }
.chip:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.chip:has(input:disabled):hover { border-color: var(--border-strong); color: var(--text-muted); }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.chip--on {
  background: var(--bg-sunken);
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 550;
}

.chip__dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--border-strong);
}

/* ----- chart ------------------------------------------------------------- */

.chart-note {
  color: var(--text-muted);
  font-size: 0.875rem;
  max-width: var(--measure);
}

.chart__frame { position: relative; }

.chart__svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: pan-y;
}

.chart__grid line { stroke: var(--border); stroke-width: 1; }
.chart__grid .chart__grid-v { stroke: var(--border); opacity: 0.55; }
.chart__axis { stroke: var(--border-strong); stroke-width: 1; }

.chart__tick {
  fill: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart__crosshair { stroke: var(--border-strong); stroke-width: 1; }

.chart__line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart__line--dashed { stroke-dasharray: 7 5; }

.chart__dot {
  stroke: var(--bg-elevated);
  stroke-width: 2;
}

.chart__end {
  fill: var(--text);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

/* Catches the pointer across the whole plot so the crosshair snaps to a week
   instead of asking the reader to hit a 2px line. */
.chart__surface { fill: transparent; }

.chart__tip {
  position: absolute;
  top: 8px;
  pointer-events: none;
  min-width: 9rem;
  max-width: 15rem;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  z-index: 1;
}

.chart__tip-date {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chart__tip-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 3px;
}

.chart__tip-rows li {
  display: grid;
  grid-template-columns: 12px auto 1fr;
  align-items: center;
  gap: 7px;
}

.chart__tip-key {
  width: 12px;
  height: 2px;
  border-radius: 1px;
}

.chart__tip-key--dashed {
  background-image: linear-gradient(to right, var(--bg-elevated) 40%, transparent 40%);
  background-size: 5px 100%;
}

.chart__tip-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.chart__tip-label { color: var(--text-muted); }

/* ----- legend ------------------------------------------------------------ */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  font-size: 0.85rem;
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend__key {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  flex: none;
}

.legend__key--dashed {
  background-image: linear-gradient(to right, var(--bg-elevated) 40%, transparent 40%);
  background-size: 6px 100%;
}

.legend__name { color: var(--text); }

.legend__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.legend__empty { color: var(--text-muted); }

/* ----- table ------------------------------------------------------------- */

.table-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.table-head h2 { margin: 0; }

.table-scroll { overflow-x: auto; }

#table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

#table caption {
  caption-side: top;
  text-align: left;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 6px 0 12px;
  max-width: var(--measure);
}

#table th,
#table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

#table thead th {
  padding: 0;
  border-bottom: 1px solid var(--border-strong);
}

#table thead th button {
  width: 100%;
  border: 0;
  background: none;
  padding: 7px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: right;
  border-radius: 0;
}

#table thead th:first-child,
#table thead th:first-child button,
#table tbody th { text-align: left; }

#table thead th button:hover { color: var(--accent); }

#table thead th[aria-sort="ascending"] button::after { content: " ↑"; }
#table thead th[aria-sort="descending"] button::after { content: " ↓"; }

#table tbody th { font-weight: 500; }

/* The dot carries the series identity next to the name — never on the text. */
#table tbody th .chip__dot {
  display: inline-block;
  margin-right: 8px;
  vertical-align: baseline;
}

#table tbody td {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

#table tbody tr.is-selected { background: var(--bg-sunken); }
#table tbody tr.is-selected th { font-weight: 650; }

/* ----- notes ------------------------------------------------------------- */

.notes h2 { margin-bottom: 0.6em; }
.notes p {
  max-width: var(--measure);
  color: var(--text-muted);
  font-size: 0.9rem;
}
.notes p:last-child { margin-bottom: 0; }

.notes code {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

@media (max-width: 640px) {
  .controls { gap: 12px 16px; }
  .controls--range select { max-width: 100%; flex: 1 1 auto; }
  .inline-field { flex: 1 1 auto; }
}
