/* Overview gallery, compare table and model page. Colours come from style.css. */

main:has(.page-oversikt), main:has(.page-modell) { max-width: 1320px; }

/* --- Filters: one row that wraps on small screens --- */
.oversikt-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 22px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 16px; margin: 0 0 16px;
}
.oversikt-form .filter { display: flex; flex-direction: column; gap: 6px; }
.filter-label { color: var(--muted); font-size: 13px; }
.oversikt-form select, .oversikt-form input[type="number"] {
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 7px 8px; font-size: 14px;
}
.oversikt-form input[type="number"] { width: 120px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg label { padding: 6px 12px; font-size: 14px; cursor: pointer; border-right: 1px solid var(--line); }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: #fff; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.always { color: var(--ok); font-size: 14px; padding: 6px 0; }

/* --- "Hel el eller laddhybrid?" box --- */
.el-vs-phev { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; }
.el-vs-phev summary { cursor: pointer; font-weight: 600; }
.evp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 24px; margin-top: 10px; }
.evp-grid h4 { margin: 0 0 6px; }
.evp-grid ul { margin: 0; padding-left: 18px; line-height: 1.5; font-size: 14px; }

/* --- Badges: blue for electric, orange for plug-in hybrid --- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; vertical-align: middle; }
.badge-el { background: #1f4fa3; color: #fff; }
.badge-phev { background: #9a5b12; color: #fff; }

/* --- Gallery --- */
.group { margin: 28px 0 0; }
.group-title { font-size: 20px; margin: 0 0 2px; }
.group-title small { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 8px; }
.group-intro { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.group-note { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.gal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.gal-photo { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--bg); }
.gal-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-photo .badge { position: absolute; top: 10px; left: 10px; }
.gal-photo .no-photo, .modell-photo .no-photo, .ad-grid .no-photo {
  display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 12px;
}
.gal-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.gal-body .brand, .modell-intro .brand { margin: 0; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.gal-body h4 { margin: 0; font-size: 19px; }
.gal-body h4 a { color: inherit; text-decoration: none; }
.gal-lead { margin: 0; color: var(--muted); font-size: 13px; }
.gal-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 0; }
.gal-stats dt { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.gal-stats dd { margin: 0; font-size: 15px; font-weight: 600; }
.gal-blurb { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text); background: var(--bg); padding: 8px 10px; border-radius: 6px; }
.gal-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding-top: 4px; }
.pick { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; font-size: 14px; }
.pick input { width: 18px; height: 18px; accent-color: var(--accent); }

/* --- Compare --- */
.compare-photo { display: block; width: 150px; height: 100px; object-fit: cover; border-radius: 6px; margin-bottom: 6px; }
.compare-remove { font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.compare-hint { color: var(--muted); }
.compare-bar {
  position: sticky; bottom: 12px; z-index: 5; margin: 20px auto 0; width: fit-content;
  display: flex; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 24px; padding: 8px 10px 8px 18px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
.compare-bar[hidden] { display: none; }
.compare-count { font-size: 14px; }

/* --- Model page --- */
.back { margin: 0 0 12px; }
.modell-top { display: grid; grid-template-columns: minmax(280px, 1.1fr) 1fr; gap: 20px; align-items: start; }
.modell-photo { aspect-ratio: 4 / 3; background: var(--panel); border-radius: 10px; overflow: hidden; }
.modell-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modell-intro h2 { margin: 2px 0 8px; font-size: 26px; }
.pro-con-head { margin: 10px 0 2px; color: var(--muted); font-size: 13px; }
.pro-con { list-style: none; padding: 0; margin: 0; line-height: 1.6; font-size: 14px; }
.pro-con .pro { color: var(--ok); }
.pro-con .con { color: var(--bad); }
.modell-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin: 20px 0 0; align-items: start; }
.modell-cols .family-stats { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.tco-box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.tco-box h3 { margin: 0 0 8px; font-size: 16px; }
.tco-table td { padding: 6px 4px; }
.tco-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.ads-title { margin: 24px 0 10px; font-size: 16px; }
.ad-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.ad-grid li { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.ad-grid a { color: inherit; text-decoration: none; display: flex; flex-direction: column; }
.ad-grid img, .ad-grid .no-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--bg); }
.ad-text { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; min-width: 0; }
.ad-text span { color: var(--muted); font-size: 12px; }
/* Range on electricity: brighter than the grey lines, so it is easy to compare. */
.ad-text .ad-el { color: var(--text); }
/* Auctions: a badge on the photo and a word after the price ("bud just nu"),
   so nobody takes a low bid for the real price. */
.ad-grid a { position: relative; }
.auction-badge {
  position: absolute; top: 8px; left: 8px; z-index: 1;
  background: var(--warn); color: #1a1406; font-size: 12px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.03em;
}
.ad-text .bid-word { color: var(--warn); font-size: 12px; font-weight: 600; }
.ad-grid a:hover .ex-title { text-decoration: underline; }
/* "Köp hos Riddermark Bil Uppsala →": the car is on the dealer's own site (dealer_links.py). */
.ad-text .ad-buy { align-self: flex-start; margin: 6px 0 2px; padding: 3px 9px; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; }
.ad-grid a.ad-alt { display: block; padding: 0 10px 8px; color: var(--muted); font-size: 12px; text-decoration: underline; }

/* "Korten visar bilar för 480 000–600 000 kr" and "kostar sällan över". */
.band-note { margin: 0 0 14px; font-size: 14px; color: var(--text); }
.band-note .info { display: inline-block; }
.budget-note { margin: 0; font-size: 13px; color: var(--warn); }
.list-toggle { margin: 0 0 10px; font-size: 14px; color: var(--muted); }

/* Model page equipment filter: small boxes in a row, wraps on a phone. */
.equip-filter { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.equip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.equip-box { font-size: 14px; cursor: pointer; white-space: nowrap; }
.equip-count { font-size: 13px; color: var(--muted); }
/* Ad tile: trim level first, then the equipment words as small chips. */
.ad-text .ad-equip { display: flex; flex-wrap: wrap; gap: 3px; margin: 3px 0 1px; }
.ad-text .chip, .ad-text .lvl { font-size: 11px; line-height: 1.5; padding: 0 6px; border-radius: 8px;
  border: 1px solid var(--line); color: var(--text); }
/* Bas grey, Mellan blue, Topp green. The word says it too, so colour is only a help. */
.ad-text .lvl { font-weight: 600; }
.ad-text .lvl-2 { border-color: var(--accent); }
.ad-text .lvl-3 { border-color: var(--ok); background: rgba(47, 170, 106, 0.15); }
.ad-text .ad-facts { color: var(--text); }

/* "Klarar er vanliga dag på el": green yes, yellow almost, red no. */
.gal-stats .fit { grid-column: 1 / -1; }
/* An open (i) takes the whole row, so its text is not squeezed into half the card. */
.gal-stats > div:has(details.info[open]),
.family-stats > div:has(details.info[open]) { grid-column: 1 / -1; }

/* The sums behind "Kostnad/mån" inside its (i). How it was counted in small grey text. */
.info-sums { width: 100%; border-collapse: collapse; margin: 0 0 10px; }
.info-sums caption { text-align: left; font-weight: 600; margin-bottom: 4px; }
.info-sums td { padding: 3px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
.info-sums td:last-child { text-align: right; white-space: nowrap; padding-left: 10px; font-variant-numeric: tabular-nums; }
.info-sums td small { display: block; color: var(--muted); font-size: 12px; }
.info-sums .sum td { font-weight: 700; border-bottom: none; }
.fit-ja dd { color: var(--ok); }
.fit-nastan dd { color: var(--warn); }
.fit-nej dd { color: var(--bad); }

/* "Större batteri från ca X kr" on the gallery card and the model page. */
.step-hint { margin: 0; font-size: 13px; line-height: 1.4; color: var(--text);
  border-left: 3px solid var(--warn); padding: 4px 8px; background: var(--bg); border-radius: 0 6px 6px 0; }
.step-hint .info { display: inline-block; }
.step-link { margin: 4px 0 0; font-size: 14px; }
.tco-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

/* Price against range on electricity (model page). */
#rackvidd { margin: 20px 0 8px; }
.range-chart { margin: 10px 0 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.range-chart h3 { margin: 0 0 6px; }
.range-chart svg { width: 100%; height: auto; display: block; }
.range-chart .grid { stroke: var(--line); stroke-width: 1; }
.range-chart .tick, .range-chart .axis { fill: var(--muted); font-size: 11px; }
.range-chart .line-label { fill: var(--text); font-size: 11px; }
.range-chart .budget-line { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; }
.range-chart .day-line { stroke: var(--warn); stroke-width: 2; stroke-dasharray: 6 4; }
.range-chart .dot-in { fill: var(--ok); stroke: var(--ok); }
.range-chart .dot-out { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.range-chart a:hover circle { stroke: var(--text); stroke-width: 2.5; }
.range-chart figcaption { color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.4; }
.range-chart .key-in { color: var(--ok); }
/* Zoom and hover card (static/range_chart.js). pan-y: on a phone an up/down
   swipe still scrolls the page, a sideways drag zooms the price. */
.range-chart { position: relative; }
.range-chart .chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.range-chart .zoom-reset { font-size: 13px; padding: 4px 12px; }
.range-chart .zoom-reset[hidden] { display: none; }
.range-chart svg { cursor: crosshair; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.range-chart circle { cursor: pointer; }
.range-chart circle.hot { stroke: var(--text); stroke-width: 2.5; }
.range-chart .brush { fill: rgba(76, 139, 245, 0.15); stroke: var(--accent); stroke-width: 1; }
/* The card looks like an ad tile. It never catches the mouse, so it cannot hide other dots. */
.chart-card {
  position: absolute; z-index: 20; width: 240px; pointer-events: none; overflow: hidden;
  display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--muted); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
.chart-card[hidden] { display: none; }
.chart-card img, .chart-card .no-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--bg); }
.chart-card .no-photo { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.ad-text .chip-hw { font-weight: 600; }

@media (max-width: 760px) {
  .modell-top, .modell-cols { grid-template-columns: 1fr; }
}

/* The car's short code (car_codes.py), on the tile and in the chart's hover card. */
.ad-text .ad-code { float: right; font: 600 11px/1.6 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.08em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

/* The watch form at the bottom of the overview (watches.py). */
.watch { margin: 32px 0 8px; padding: 18px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.watch h3 { margin: 0 0 6px; font-size: 18px; }
.watch p { margin: 0 0 12px; color: var(--muted); font-size: 14px; max-width: 62ch; }
.watch-row { display: flex; flex-wrap: wrap; gap: 8px; }
.watch-row input { flex: 1 1 220px; min-width: 0; padding: 9px 10px; font-size: 15px; background: var(--bg);
  color: var(--text); border: 1px solid var(--line); border-radius: 6px; }
