/* EMDB front end. Inherits the theme's fonts and colors. */
:root {
	--emdb-border: color-mix(in srgb, currentColor 20%, transparent);
	/* Tints mix from currentColor so they work on light and dark themes alike. */
	--emdb-bg: color-mix(in srgb, currentColor 7%, transparent);
	--emdb-accent: var(--wp--preset--color--accent-3, #503aa8);
	--emdb-target: color-mix(in srgb, var(--emdb-accent) 40%, transparent);
}

.emdb-vehicle-view { max-width: 1140px; margin: 0 auto; padding: 1.5rem 0 3rem; }
.emdb-vehicle-title { margin: 0 0 .25rem; }
.emdb-vehicle-meta { margin: 0 0 1.5rem; opacity: .75; }
.emdb-key-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; list-style: none; margin: 0 0 2rem; padding: 0; }
.emdb-key-figures li { border: 1px solid var(--emdb-border); border-radius: 8px; padding: 1rem; }
.emdb-key-figures strong { display: block; font-size: 1.6em; line-height: 1.2; }
.emdb-key-figures span { font-size: .9em; opacity: .8; }
.emdb-key-figures .emdb-efficiency small { display: block; font-size: .75em; opacity: .7; margin-top: .25rem; }
.emdb-key-figures .emdb-efficiency span { display: block; }
.emdb-specs { margin: 0 0 2rem; }
.emdb-specs h2, .emdb-related h2, .emdb-related-posts h2 { font-size: 1.25em; margin: 0 0 .5rem; }
.emdb-spec-table, .emdb-table { width: 100%; border-collapse: collapse; }
.emdb-spec-table th, .emdb-spec-table td, .emdb-table th, .emdb-table td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--emdb-border); vertical-align: top; }
.emdb-spec-table th { width: 40%; font-weight: 600; }
.emdb-table thead th { border-bottom-width: 2px; }
.emdb-table tbody tr:nth-child(even) { background: var(--emdb-bg); }
.emdb-table tbody tr:target { background: var(--emdb-target); }
.emdb-table caption { caption-side: top; text-align: left; font-size: .85em; margin-bottom: .5rem; }
.emdb-table th a { text-decoration: none; }
.emdb-table .emdb-num { text-align: right; white-space: nowrap; }
.emdb-table-scroll { overflow-x: auto; }
.emdb-related ul { columns: 2 260px; padding-left: 1.2em; }
.emdb-source { font-size: .85em; opacity: .8; margin-top: 2rem; }
.emdb-note { font-size: .85em; opacity: .8; }
.emdb-updated, .emdb-csv { font-size: .9em; }
/* Data updated block: small muted line at the bottom of EV Database pages. */
.emdb-data-updated { margin-top: var(--wp--preset--spacing--40, 2rem); font-size: .85em; opacity: .75; }
.emdb-data-updated p { margin: 0; }
.emdb-data-updated a { color: inherit; }

/* Filters: an even grid. Every field has a small label on top, so all cells share
   one height and wrap cleanly. Range fieldsets split their cell into two inputs. */
/* Two rows: search, make and year first; status, efficiency, range and the button after. */
.emdb-filters { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1rem; }
.emdb-filter-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem 1rem; align-items: end; }
.emdb-filter-primary { grid-template-columns: 2fr 1fr 1.5fr; }
.emdb-filter-row > label { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
@media (max-width: 782px) { .emdb-filter-primary { grid-template-columns: 1fr; } }
.emdb-filters .emdb-field-label { display: block; font-size: .8em; font-weight: 600; opacity: .8; line-height: 1.2; }
.emdb-filters fieldset.emdb-range { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; border: 0; margin: 0; padding: 0; min-width: 0; }
.emdb-filters fieldset.emdb-range legend { padding: 0; margin-bottom: .3rem; }
.emdb-filters fieldset.emdb-range label { min-width: 0; }
.emdb-filters input, .emdb-filters select { width: 100%; box-sizing: border-box; padding: .4rem .6rem; min-width: 0; }
.emdb-filter-actions { display: flex; align-items: end; }
/* Filter button matches the theme's footer category pills. */
.emdb-filters button[type="submit"] { padding: 5px 15px; border: 0; border-radius: 15px; background-color: #fff; color: #000; font: inherit; font-weight: bold; line-height: 1.6; cursor: pointer; transition: background-color .25s, color .25s; }
.emdb-filters button[type="submit"]:hover, .emdb-filters button[type="submit"]:focus-visible { background-color: #282828; color: #fff; }
.emdb-filters button[type="submit"]:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* Pagination: links, the current page and the dots share one box model so
   every item sits on the same center line. */
.emdb-pagination { margin-top: 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.emdb-pagination .page-numbers { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-width: 2.2em; margin: 0; padding: .2rem .7rem; border: 1px solid transparent; border-radius: 999px; line-height: 1.5; vertical-align: middle; text-decoration: none; color: inherit; }
.emdb-pagination .page-numbers.current { background: color-mix(in srgb, currentColor 18%, transparent); border-color: color-mix(in srgb, currentColor 40%, transparent); font-weight: 600; }
.emdb-pagination .page-numbers.dots { padding-left: .2rem; padding-right: .2rem; min-width: 0; }

.emdb-unit-toggle { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; margin: 0 0 .75rem; }
.emdb-unit-toggle a, .emdb-unit-toggle strong { padding: .15rem .75rem; border: 1px solid var(--emdb-border); border-radius: 999px; text-decoration: none; }
/* Selected unit is a quiet tinted pill; the other one is clearly clickable and
   flips to the white footer-pill look on hover. */
.emdb-unit-toggle strong { background: color-mix(in srgb, currentColor 18%, transparent); border-color: color-mix(in srgb, currentColor 40%, transparent); }
.emdb-unit-toggle a { color: inherit; font-weight: 600; border-color: currentColor; transition: background-color .25s, color .25s, border-color .25s; }
.emdb-unit-toggle a:hover, .emdb-unit-toggle a:focus-visible { background-color: #fff; border-color: #fff; color: #000; }
.emdb-pagination a.page-numbers { border-color: var(--emdb-border); transition: background-color .25s, color .25s, border-color .25s; }
.emdb-pagination a.page-numbers:hover, .emdb-pagination a.page-numbers:focus-visible { background-color: #fff; border-color: #fff; color: #000; }
.emdb-table th a { transition: opacity .2s; }
.emdb-table th a:hover, .emdb-table th a:focus-visible { opacity: .8; }
.emdb-unit-hint { font-size: .85em; opacity: .75; }

.emdb-breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; margin: 0; padding: 0; font-size: .9em; }
.emdb-breadcrumbs li { display: flex; align-items: center; }
.emdb-breadcrumbs li + li::before { content: "/"; margin: 0 .45em; opacity: .6; }

.emdb-make-list ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); grid-auto-rows: 1fr; gap: 1rem; list-style: none; margin: 0; padding: 0; }
.emdb-make-list li { display: flex; min-width: 0; }
.emdb-make-list a { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: .25rem; box-sizing: border-box; min-height: 5rem; border: 1px solid var(--emdb-border); border-radius: 8px; padding: 1rem; text-decoration: none; color: inherit; background: var(--emdb-bg); transition: border-color .15s, background-color .15s; }
.emdb-make-list a:hover, .emdb-make-list a:focus-visible { border-color: currentColor; background: color-mix(in srgb, currentColor 12%, transparent); }
.emdb-make-list .emdb-make-name { display: block; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.emdb-make-list a span + span { display: block; font-size: .85em; line-height: 1.3; opacity: .75; }
/* Current lineup vs older makes and rows. Active items get a quiet accent
   edge; inactive ones are muted but stay readable and clickable. */
.emdb-make-list li.is-active a { border-color: color-mix(in srgb, var(--emdb-accent) 55%, currentColor 15%); box-shadow: inset 3px 0 0 var(--emdb-accent); }
.emdb-make-list li.is-inactive a { opacity: .6; background: transparent; border-style: dashed; transition: opacity .15s, border-color .15s, background-color .15s; }
.emdb-make-list li.is-inactive a:hover, .emdb-make-list li.is-inactive a:focus-visible { opacity: .85; }
.emdb-table tbody tr.is-active > td:first-child { box-shadow: inset 3px 0 0 var(--emdb-accent); }
.emdb-table tbody tr.is-inactive > td { color: color-mix(in srgb, currentColor 62%, transparent); }
.emdb-table tbody tr.is-inactive a { opacity: .7; transition: opacity .15s; }
.emdb-table tbody tr.is-inactive:hover > td, .emdb-table tbody tr.is-inactive:focus-within > td { color: inherit; }
.emdb-table tbody tr.is-inactive:hover a, .emdb-table tbody tr.is-inactive:focus-within a { opacity: 1; }
/* Rows: no underlines, accent tint on hover or focus (above zebra,
   :target and the active/inactive styling), and the whole row is one click
   target via the stretched-link pattern: the first cell's link gets an
   ::after covering the row, and the tr is the positioned box. Chrome 104+,
   Firefox and Safari position table rows; browsers without :has() simply
   keep a normal link in the first cell. Links in other cells sit above the
   overlay so they stay clickable. Inactive rows mute with color, not td
   opacity, so no cell forms a stacking context above the overlay. No JS. */
.emdb-table a, .emdb-table a:hover, .emdb-table a:focus, .emdb-make-list a, .emdb-make-list a:hover, .emdb-make-list a:focus { text-decoration: none; }
.emdb-table tbody tr { transition: background-color .15s; }
.emdb-table tbody tr:hover, .emdb-table tbody tr:focus-within { background-color: color-mix(in srgb, var(--emdb-accent) 24%, transparent); }
.emdb-table tbody tr:has(td:first-child a) { position: relative; cursor: pointer; }
.emdb-table tbody tr:has(td:first-child a) td:first-child a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.emdb-table tbody tr:has(td:first-child a) td:not(:first-child) a { position: relative; z-index: 2; }
.emdb-table tbody tr:has(td:first-child a) td:first-child a:focus-visible { outline: none; }
.emdb-table tbody tr:has(a:focus-visible) { outline: 2px solid currentColor; outline-offset: -2px; }
.emdb-make-list .screen-reader-text, .emdb-table .screen-reader-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.emdb-figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; list-style: none; margin: 1rem 0 0; padding: 0; }
.emdb-figures li { border: 1px solid var(--emdb-border); border-radius: 8px; padding: .75rem 1rem; background: var(--emdb-bg); }
.emdb-figures span { display: block; font-size: .85em; opacity: .8; }
.emdb-figures strong { display: block; margin-top: .15rem; }

.emdb-specs-link { border-left: 4px solid var(--emdb-accent); padding: .75rem 1rem; background: var(--emdb-bg); }
.emdb-specs-link p { margin: 0; }

.emdb-related-posts ul { list-style: none; margin: 0; padding: 0; }
.emdb-related-posts li { margin: 0 0 .5rem; }
.emdb-related-posts time { font-size: .85em; opacity: .75; margin-left: .35rem; }
.emdb-all-news { margin-top: .75rem; }

@media (max-width: 600px) {
	.emdb-vehicle-view { padding: 1rem; }
	.emdb-spec-table th { width: 50%; }
	.emdb-table th, .emdb-table td, .emdb-spec-table th, .emdb-spec-table td { padding: .4rem .5rem; font-size: .9em; }
	.emdb-make-list a, .emdb-figures li, .emdb-specs-link { padding: .75rem; }
}
