/*
 * Tesla-biler: kortet med faner og varianttabellen ([tesla_bil]).
 * Indlæses kun på sider, hvor en bil vises (inc/tesla-biler-visning.php).
 * Farver som ladekort.css, så de to features ligner hinanden.
 */

.tbil,
.tbil-model {
	--tb-accent: #5b0b0b;
	--tb-ink: #171a20;
	--tb-muted: #5c5e62;
	--tb-line: #dcdde0;
	--tb-soft: #f4f4f4;
	--tb-good: #1e7a3e;
	--tb-radius: 10px;
	color: var(--tb-ink);
}

.tbil *,
.tbil-model * {
	box-sizing: border-box;
}

.tbil-model,
.tbil-gruppe {
	margin: 1.5rem 0 2rem;
}

.tbil[hidden],
.tbil [hidden] {
	display: none !important;
}

/* ---------- kortet ---------- */

.tbil {
	border: 1px solid var(--tb-line);
	border-radius: var(--tb-radius);
	background: #fff;
	overflow: clip; /* ikke hidden: det ville slå position: sticky fra på bilkortet */
}

.tbil__head {
	display: grid;
	grid-template-columns: 300px minmax(0, 1fr);
	gap: 1.75rem;
	padding: 1.25rem 1.25rem 0;
	align-items: start;
}

.tbil__head > .tbil-kort {
	position: sticky;
	top: 1rem;
	margin-bottom: 1.25rem;
}

.tbil__main {
	min-width: 0;
}

.tbil__info {
	padding-top: 0.25rem;
}

.tbil__intro {
	margin: 1rem 0 0;
	font-size: 0.95rem;
	line-height: 1.55;
	color: var(--tb-muted);
}

/* ---------- bilkortet (gammeldags kvartetkort) ---------- */

.tbil-kort {
	--kort-roed: #b3161b;
	--kort-creme: #f6ecd0;
	--kort-linje: #cdbf9a;
	margin: 0;
	padding: 9px;
	border: 1px solid #d9d4c7;
	border-radius: 14px;
	background: #fdfcf8;
	box-shadow: 0 1px 0 #fff inset, 0 6px 18px rgba(23, 26, 32, 0.14);
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
	color: #1c1c1c;
}

.tbil-kort__top {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	height: 44px;
	padding: 0 10px;
	border-radius: 8px 8px 0 0;
	background: var(--kort-roed);
	color: #fff;
}

.tbil-kort__nr {
	font-size: 1.7rem;
	font-weight: 800;
	letter-spacing: -0.02em;
	line-height: 1;
}

.tbil-kort__maerke {
	grid-column: 2;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.3em;
	text-transform: uppercase;
}

/* Flaget i højre hjørne, som på et gammelt kvartetkort. */
.tbil-kort__flag,
.tbil-kort__land {
	grid-column: 3;
	justify-self: end;
}

.tbil-kort__flag {
	display: block;
	width: 45px;
	height: 30px;
	border: 2px solid #fff;
	border-radius: 2px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.tbil-kort__land {
	padding: 2px 6px;
	border-radius: 3px;
	background: #fff;
	color: #1c1c1c;
	font-size: 0.75rem;
	font-weight: 800;
}

.tbil-kort__foto {
	position: relative;
	aspect-ratio: 4 / 3;
	background: linear-gradient(160deg, #e9e6df, #cfcac0);
	overflow: hidden;
}

.tbil-kort__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	filter: saturate(1.08) contrast(1.03);
}

.tbil-kort__kredit {
	position: absolute;
	right: 4px;
	bottom: 3px;
	padding: 1px 5px;
	border-radius: 3px;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	font-size: 0.62rem;
	line-height: 1.4;
}

.tbil-kort__navn,
.tbil-kort__data,
.tbil-kort__foto {
	margin: 0;
}

.tbil-kort__navn {
	display: block;
	text-align: left;
	padding: 6px 10px;
	background: #1f5fa8;
	color: #fff;
	font-size: 1.05rem;
	font-weight: 800;
	line-height: 1.25;
}

.tbil-kort__data {
	margin: 0;
	padding: 4px 10px 2px;
	background: var(--kort-creme);
}

.tbil-kort__data div {
	display: flex;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 3px 0 2px;
	border-bottom: 1px solid var(--kort-linje);
	font-size: 0.92rem;
}

.tbil-kort__data div:last-child {
	border-bottom: 0;
}

.tbil-kort__data dd {
	margin: 0;
	font-weight: 700;
	white-space: nowrap;
}

.tbil-kort__fod {
	display: flex;
	justify-content: space-between;
	padding: 5px 10px 6px;
	border-radius: 0 0 8px 8px;
	background: var(--kort-creme);
	border-top: 1px solid var(--kort-linje);
	font-size: 0.72rem;
	color: #6b6150;
}

.tbil__kicker {
	margin: 0 0 0.15rem;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--tb-accent);
}

.tbil__navn {
	margin: 0 0 0.6rem;
	font-size: clamp(1.35rem, 2.6vw, 1.75rem);
	line-height: 1.2;
}

.tbil__navn span {
	font-weight: 400;
	color: var(--tb-muted);
}

.tbil__navn:focus {
	outline: none;
}

/* Variantvælgeren: <details> med links, virker uden JS. */
.tbil__vaelg {
	position: relative;
	display: inline-block;
	margin-bottom: 0.75rem;
}

.tbil__vaelg summary {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	min-height: 40px;
	padding: 0 0.9rem;
	border: 1px solid var(--tb-line);
	border-radius: 8px;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	list-style: none;
	background: #fff;
}

.tbil__vaelg summary::-webkit-details-marker {
	display: none;
}

.tbil__vaelg summary::after {
	content: "";
	width: 7px;
	height: 7px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: translateY(-2px) rotate(45deg);
}

.tbil__vaelg[open] summary::after {
	transform: translateY(2px) rotate(-135deg);
}

.tbil__vaelg summary:focus-visible {
	outline: 2px solid var(--tb-accent);
	outline-offset: 2px;
}

.tbil__vaelg ul {
	position: absolute;
	z-index: 30;
	top: calc(100% + 4px);
	left: 0;
	min-width: 280px;
	max-width: calc(100vw - 32px);
	margin: 0;
	padding: 0.3rem;
	list-style: none;
	background: #fff;
	border: 1px solid var(--tb-line);
	border-radius: var(--tb-radius);
	box-shadow: 0 8px 24px rgba(23, 26, 32, 0.12);
}

.tbil__vaelg li {
	margin: 0;
}

.tbil__vaelg a,
.tbil__valgt {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.6rem 0.7rem;
	border-radius: 6px;
	color: var(--tb-ink);
	text-decoration: none;
	font-size: 0.95rem;
}

.tbil__vaelg a:hover,
.tbil__vaelg a:focus-visible {
	background: var(--tb-soft);
	outline: none;
}

.tbil__valgt {
	font-weight: 700;
	box-shadow: inset 3px 0 0 var(--tb-accent);
}

.tbil__vaelg small {
	color: var(--tb-muted);
	font-size: 0.85rem;
	white-space: nowrap;
}

.tbil__pris {
	margin: 0 0 0.25rem;
	font-size: 0.95rem;
	color: var(--tb-muted);
}

.tbil__pris small {
	display: block;
	font-size: 0.78rem;
}

.tbil__pris strong {
	font-size: 1.45rem;
	color: var(--tb-ink);
}

.tbil__dato {
	margin: 0;
	font-size: 0.8rem;
	color: var(--tb-muted);
}

/* Faner */
.tbil__tabs {
	display: flex;
	gap: 0.25rem;
	margin: 1.25rem 0 0;
	padding: 0;
	border-bottom: 1px solid var(--tb-line);
	overflow-x: auto;
	scrollbar-width: none;
}

.tbil__tabs::-webkit-scrollbar {
	display: none;
}

.tbil__tabs [role="tab"] {
	flex: 0 0 auto;
	min-height: 44px;
	padding: 0 0.8rem;
	border: 0;
	border-bottom: 3px solid transparent;
	background: none;
	color: var(--tb-muted);
	font: inherit;
	font-size: 0.92rem;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
}

.tbil__tabs [role="tab"]:hover {
	color: var(--tb-ink);
}

.tbil__tabs [role="tab"][aria-selected="true"] {
	color: var(--tb-ink);
	border-bottom-color: var(--tb-accent);
}

.tbil__tabs [role="tab"]:focus-visible {
	outline: 2px solid var(--tb-accent);
	outline-offset: -2px;
}

.tbil__panel {
	min-height: 260px;
	padding: 1.1rem 0 1.25rem;
}

.tbil__panel:focus-visible {
	outline: 2px solid var(--tb-accent);
	outline-offset: -2px;
}

.tbil__panel h3 {
	margin: 0 0 0.5rem;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--tb-muted);
}

.tbil__tom,
.tbil__note {
	margin: 0.75rem 0 0;
	font-size: 0.85rem;
	color: var(--tb-muted);
}

.tbil__muted {
	color: var(--tb-muted);
	font-size: 0.85em;
}

/* Specifikationslister */
.tbil__specs {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	column-gap: 2rem;
	margin: 0;
}

.tbil__specs div {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.55rem 0;
	border-bottom: 1px solid var(--tb-soft);
	font-size: 0.95rem;
}

.tbil__specs dt {
	color: var(--tb-muted);
}

.tbil__specs dd {
	margin: 0;
	font-weight: 600;
	text-align: right;
}

/* Plus og minus */
.tbil__pm {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.5rem;
}

.tbil__pm ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.tbil__pm li {
	position: relative;
	margin: 0 0 0.55rem;
	padding-left: 1.5rem;
	font-size: 0.95rem;
	line-height: 1.45;
}

.tbil__pm li::before {
	position: absolute;
	left: 0;
	top: 0;
	width: 1.1rem;
	font-weight: 700;
	text-align: center;
}

.tbil__pm-kol--plus li::before {
	content: "+";
	color: var(--tb-good);
}

.tbil__pm-kol--minus li::before {
	content: "–";
	color: var(--tb-accent);
}

.tbil__kilde {
	font-size: 0.78rem;
	color: var(--tb-muted);
}

/* Prisudvikling */
.tbil__prisinfo {
	margin: 0 0 0.5rem;
	font-size: 0.9rem;
	color: var(--tb-muted);
}

.tbil__badge {
	display: inline-block;
	padding: 0.1rem 0.45rem;
	border-radius: 4px;
	font-weight: 700;
	font-size: 0.85rem;
	background: var(--tb-soft);
	color: var(--tb-ink);
}

.tbil__badge--ned {
	color: var(--tb-good);
}

.tbil__badge--op {
	color: var(--tb-accent);
}

.tbil-graf {
	position: relative;
	margin: 0;
}

.tbil-graf svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
}

.tbil-graf__grid {
	stroke: var(--tb-line);
	stroke-width: 1;
}

.tbil-graf__ylab,
.tbil-graf__xlab {
	font-size: 12px;
	fill: var(--tb-muted);
}

.tbil-graf__ylab {
	text-anchor: end;
}

.tbil-graf__xlab {
	text-anchor: middle;
}

.tbil-graf__linje {
	fill: none;
	stroke: var(--tb-accent);
	stroke-width: 2;
	stroke-linejoin: round;
}

.tbil-graf__dot {
	fill: var(--tb-accent);
	stroke: #fff;
	stroke-width: 2;
}

.tbil-graf__hit {
	fill: transparent;
}

.tbil-graf__pt {
	cursor: pointer;
	outline: none;
}

.tbil-graf__pt:hover .tbil-graf__dot,
.tbil-graf__pt:focus .tbil-graf__dot {
	r: 6.5;
}

.tbil-graf__tip {
	position: absolute;
	z-index: 5;
	padding: 0.35rem 0.6rem;
	border-radius: 6px;
	background: var(--tb-ink);
	color: #fff;
	font-size: 0.82rem;
	white-space: nowrap;
	pointer-events: none;
}

.tbil__data {
	margin-top: 0.5rem;
	font-size: 0.88rem;
}

.tbil__data summary {
	cursor: pointer;
	color: var(--tb-muted);
}

.tbil__data table {
	width: 100%;
	margin-top: 0.5rem;
	border-collapse: collapse;
}

.tbil__data th,
.tbil__data td {
	padding: 0.4rem 0.5rem 0.4rem 0;
	border-bottom: 1px solid var(--tb-soft);
	text-align: left;
}

/* Rækkevidde */
.tbil__rv {
	margin: 0;
	padding: 0;
	list-style: none;
}

.tbil__rv li {
	display: grid;
	grid-template-columns: minmax(0, 13rem) minmax(0, 1fr) 6.5rem;
	align-items: center;
	gap: 0.75rem;
	padding: 0.5rem 0;
	font-size: 0.95rem;
}

.tbil__rv strong {
	text-align: right;
	white-space: nowrap;
}

.tbil__rv-bar {
	height: 8px;
	border-radius: 4px;
	background: var(--tb-soft);
	overflow: hidden;
}

.tbil__rv-bar i {
	display: block;
	height: 100%;
	border-radius: 4px;
	background: var(--tb-accent);
	opacity: 0.8;
}

.tbil__rv-wltp .tbil__rv-bar i {
	background: var(--tb-muted);
	opacity: 0.45;
}

/* Udstyr */
.tbil__udstyr {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 1.25rem 2rem;
}

.tbil__udstyr ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.tbil__u {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	padding: 0.25rem 0;
	font-size: 0.95rem;
}

.tbil__u span {
	flex: 0 0 1rem;
	font-weight: 700;
	text-align: center;
}

.tbil__u em {
	margin-left: auto;
	font-style: normal;
	font-size: 0.78rem;
	color: var(--tb-muted);
	white-space: nowrap;
}

.tbil__u--standard span {
	color: var(--tb-good);
}

.tbil__u--tilvalg span {
	color: var(--tb-ink);
}

.tbil__u--nej {
	color: var(--tb-muted);
}

.tbil__kilder {
	margin: 0;
	padding: 0.75rem 1.25rem;
	border-top: 1px solid var(--tb-line);
	background: var(--tb-soft);
	font-size: 0.78rem;
	color: var(--tb-muted);
}

.tbil__kilder a,
.tbil__data a {
	color: inherit;
}

/* ---------- modelvisningen ---------- */

.tbil-model__titel {
	margin: 0 0 0.5rem;
	font-size: clamp(1.3rem, 2.4vw, 1.6rem);
}

.tbil-model__intro {
	margin: 0 0 1rem;
	color: var(--tb-muted);
}

.tbil-model__scroll {
	margin-bottom: 1.25rem;
	overflow-x: auto;
	border: 1px solid var(--tb-line);
	border-radius: var(--tb-radius);
}

.tbil-model__tabel {
	width: 100%;
	min-width: 560px;
	border-collapse: collapse;
	font-size: 0.93rem;
}

.tbil-model__tabel tr,
.tbil-model__tabel th,
.tbil-model__tabel td,
.tbil__data tr,
.tbil__data td,
.tbil__data th {
	background: #fff; /* sitets tabelstriber rammer ellers også disse tabeller */
}

.tbil-model__tabel th,
.tbil-model__tabel td {
	padding: 0.65rem 0.9rem;
	border-bottom: 1px solid var(--tb-soft);
	text-align: left;
	white-space: nowrap;
}

.tbil-model__tabel thead th {
	background: var(--tb-soft);
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--tb-muted);
}

.tbil-model__tabel tbody tr:last-child th,
.tbil-model__tabel tbody tr:last-child td {
	border-bottom: 0;
}

.tbil-model__tabel a {
	color: var(--tb-accent);
	font-weight: 700;
}

/* ---------- mobil ---------- */

@media (max-width: 767px) {
	.tbil__head {
		grid-template-columns: 1fr;
		gap: 1rem;
		padding: 1rem 1rem 0;
	}

	.tbil-kort {
		width: 100%;
		max-width: 340px;
		margin: 0 auto;
	}

	.tbil__head > .tbil-kort {
		position: static;
		margin-bottom: 0;
	}

	.tbil__panel {
		padding: 1rem 0;
	}

	.tbil__pm {
		grid-template-columns: 1fr;
		gap: 1rem;
	}

	.tbil__rv li {
		grid-template-columns: minmax(0, 1fr) auto;
		row-gap: 0.3rem;
	}

	.tbil__rv-bar {
		grid-column: 1 / -1;
		grid-row: 2;
	}

	.tbil__kilder {
		padding: 0.75rem 1rem;
	}

	/* SVG'en skaleres ned til ca. 55 %, så etiketterne skal være større i SVG-enheder. */
	.tbil-graf__ylab,
	.tbil-graf__xlab {
		font-size: 20px;
	}
}

/* Staging-forhåndsvisningen (pages/tesla-biler-preview.php). */
.tbil-preview {
	max-width: 1100px;
	margin: 2rem auto;
	padding: 0 16px;
}
