/* Gasolineras de España: the card design (since 2.0.0). It takes the colours and the font of the theme unless the
   widget chooses its own (.gdew-card--custom), and adapts to the room it is given (container queries), not to the
   screen: a 200 px sidebar or a 780 px column.
   Every rule of the parts goes with .gdew-card.gdew-card in front, and a small reset clears what themes put on h2, lists,
   images and links (bullets, margins, ::before, colours): the card looks the same whatever the theme. */

.gdew-card {
	--gdew-bg: transparent;
	--gdew-fg: inherit;
	--gdew-accent: #f04b19;
	--gdew-radius: 10px;
	--gdew-line: color-mix(in srgb, currentColor 16%, transparent);
	--gdew-soft: color-mix(in srgb, currentColor 66%, transparent);
	/* green and red mixed with the colour of the text: lighter on dark themes, darker on light ones */
	--gdew-down: color-mix(in srgb, #1a8a3c 72%, currentColor);
	--gdew-up: color-mix(in srgb, #d32f2f 72%, currentColor);
	container-type: inline-size;
	contain-intrinsic-inline-size: 20em;
	box-sizing: border-box;
	/* in a wide column the prices would end far from their gas station: at most 38em (570 px with 15 px, still the wide
	   layout) with one or two fuels, and 6em more for each other fuel (56em with five): the name keeps about 250 px */
	max-width: 38em;
	margin: 0 0 1.5em;
	padding: .9em 1em .7em;
	border: 1px solid var(--gdew-line);
	border-radius: var(--gdew-radius);
	color: var(--gdew-fg);
	background: var(--gdew-bg);
	line-height: 1.35;
	text-align: left;
}

.gdew-card--fuels-3 {
	max-width: 44em;
}

.gdew-card--fuels-4 {
	max-width: 50em;
}

.gdew-card--fuels-5 {
	max-width: 56em;
}

/* the average price: as wide as its columns (about 12em each fuel), with no empty room at the right */
.gdew-card--average {
	max-width: 26em;
}

.gdew-card--average.gdew-card--fuels-3 {
	max-width: 38em;
}

.gdew-card--average.gdew-card--fuels-4 {
	max-width: 50em;
}

.gdew-card--average.gdew-card--fuels-5 {
	max-width: 60em;
}

/* a browser without container queries (or a flex parent that would measure it as 0 px): no container */
@supports not (contain-intrinsic-inline-size: 1px) {
	.gdew-card {
		container-type: normal;
	}
}

@supports not (color: color-mix(in srgb, red 50%, blue)) {
	.gdew-card {
		--gdew-line: rgba(127, 127, 127, .3);
		--gdew-soft: inherit;
		--gdew-down: #1a7f37;
		--gdew-up: #c62828;
	}

	.gdew-card.gdew-card .gdew-tag--best,
	.gdew-card.gdew-card .gdew-st__dir {
		background: rgba(240, 75, 25, .14);
	}

	.gdew-card.gdew-card .gdew-st__save--below {
		background: rgba(26, 138, 60, .12);
	}
}

.gdew-card--custom {
	border-color: transparent;
	--gdew-line: color-mix(in srgb, var(--gdew-fg) 12%, transparent);
	--gdew-soft: color-mix(in srgb, var(--gdew-fg) 66%, transparent);
}

/* --- reset against the theme --- */

.gdew-card *,
.gdew-card *::before,
.gdew-card *::after {
	box-sizing: border-box;
}

.gdew-card.gdew-card :is(h2, p, ul, li, dl, dt, dd, figure, figcaption, img, svg, a, span, div) {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
	text-shadow: none;
	float: none;
	clear: none;
	text-indent: 0;
	text-transform: none;
	letter-spacing: normal;
	font-style: normal;
	text-decoration: none;
	transition: none;
	max-width: none;
	min-height: 0;
}

.gdew-card.gdew-card :is(ul, li) {
	list-style: none !important;
}

.gdew-card.gdew-card li {
	padding-left: 0 !important;
	padding-right: 0 !important;
	background-image: none !important;
}

.gdew-card.gdew-card *::before,
.gdew-card.gdew-card *::after {
	content: none !important;
}

.gdew-card.gdew-card a {
	color: inherit;
}

.gdew-card.gdew-card [hidden] {
	display: none !important;
}

.gdew-card.gdew-card a:focus-visible {
	outline: 2px solid var(--gdew-accent);
	outline-offset: 2px;
}

/* --- header --- */

.gdew-card.gdew-card .gdew-card__title {
	margin: 0 0 .6em;
	color: inherit;
	font-family: inherit;
	font-size: 1.15em;
	font-weight: 700;
	line-height: 1.25;
}

.gdew-card.gdew-card .gdew-card__place {
	margin: -.3em 0 .6em;
	color: var(--gdew-soft);
	font-size: max(13px, .9em);
}

/* --- list of gas stations --- */

.gdew-card.gdew-card .gdew-st {
	display: grid;
	grid-template-columns: 40px 1fr auto;
	grid-template-areas: "icon main dir" "prices prices prices" "save save save";
	column-gap: .65em;
	row-gap: .35em;
	padding: .75em 0 !important;
	border-top: 1px solid var(--gdew-line);
}

.gdew-card.gdew-card .gdew-st:first-child {
	border-top: 0;
	padding-top: .2em !important;
}

.gdew-card.gdew-card .gdew-st:last-child {
	padding-bottom: .5em !important;
}

.gdew-card.gdew-card .gdew-st__icon {
	grid-area: icon;
	display: block;
	width: 40px;
	height: 40px;
	padding: 3px;
	border: 1px solid var(--gdew-line);
	border-radius: 8px;
	background: #fff;
	object-fit: contain;
}

.gdew-card.gdew-card .gdew-st__main {
	grid-area: main;
	min-width: 0;
}

.gdew-card.gdew-card .gdew-st__name {
	font-weight: 700;
	overflow-wrap: anywhere;
}

.gdew-card.gdew-card .gdew-st__name a {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

.gdew-card.gdew-card .gdew-st__addr {
	font-size: max(13px, .87em);
	overflow-wrap: anywhere;
}

.gdew-card.gdew-card .gdew-st__street {
	color: var(--gdew-soft);
}

.gdew-card.gdew-card .gdew-st__km {
	font-weight: 600;
	white-space: nowrap;
}

.gdew-card.gdew-card .gdew-st__tags {
	display: flex;
	flex-wrap: wrap;
	gap: .3em .5em;
	align-items: center;
	margin-top: .3em;
	font-size: max(13px, .85em);
}

.gdew-card.gdew-card .gdew-tag {
	padding: .05em .5em;
	border: 1px solid var(--gdew-line);
	border-radius: 99px;
	color: var(--gdew-soft);
	font-weight: 600;
	line-height: 1.45;
	white-space: nowrap;
}

/* the orange stays in the tint and the border; the text, of the colour of the card (4.5:1 without darkening the orange) */
.gdew-card.gdew-card .gdew-tag--best {
	border-color: var(--gdew-accent);
	background: color-mix(in srgb, var(--gdew-accent) 14%, transparent);
	color: inherit;
	font-weight: 700;
}

.gdew-card.gdew-card .gdew-st__dir {
	grid-area: dir;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: color-mix(in srgb, var(--gdew-accent) 16%, transparent);
	color: var(--gdew-accent);
	transition: background-color .15s;
}

.gdew-card.gdew-card .gdew-st__dir:hover {
	background: color-mix(in srgb, var(--gdew-accent) 26%, transparent);
}

.gdew-card.gdew-card .gdew-st__dir svg {
	display: block;
}

/* --- prices --- */

.gdew-card.gdew-card :is(.gdew-st__prices, .gdew-avg) {
	grid-area: prices;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(6.4em, 1fr));
	gap: .3em .6em;
}

.gdew-card.gdew-card .gdew-price {
	min-width: 0;
}

.gdew-card.gdew-card .gdew-price dt {
	color: var(--gdew-soft);
	font-size: max(13px, .8em);
	font-weight: 400;
}

.gdew-card.gdew-card .gdew-price dd {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: .3em;
	row-gap: 0;
	font-size: 1.15em;
	font-weight: 700;
	font-variant-numeric: tabular-nums lining-nums;
	white-space: normal;
}

.gdew-card.gdew-card .gdew-price--avg dd {
	font-size: 1.3em;
	font-weight: 700;
}

.gdew-card.gdew-card .gdew-price--none dd {
	color: var(--gdew-soft);
	font-weight: 400;
}

.gdew-card.gdew-card .gdew-chg {
	font-size: max(13px, .62em);
	font-weight: 600;
	font-variant-numeric: tabular-nums lining-nums;
	white-space: nowrap;
}

.gdew-card.gdew-card .gdew-chg--up {
	color: var(--gdew-up);
}

.gdew-card.gdew-card .gdew-chg--down {
	color: var(--gdew-down);
}

.gdew-card.gdew-card .gdew-st__save {
	grid-area: save;
	justify-self: start;
	padding: .15em .6em;
	border-radius: .6em;
	font-size: max(13px, .82em);
	line-height: 1.3;
}

.gdew-card.gdew-card .gdew-st__save--below {
	background: color-mix(in srgb, var(--gdew-down) 12%, transparent);
	box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gdew-down) 25%, transparent);
	color: var(--gdew-down);
}

.gdew-card.gdew-card .gdew-st__save--above {
	background: color-mix(in srgb, currentColor 7%, transparent);
	color: color-mix(in srgb, currentColor 75%, transparent);
}

.gdew-card.gdew-card .gdew-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	border: 0;
	white-space: nowrap;
}

/* --- average price: each fuel with its own line of the last 30 days --- */

.gdew-card.gdew-card .gdew-avg {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(9.5em, 1fr));
	gap: .8em 1em;
}

.gdew-card.gdew-card .gdew-avgf {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.gdew-card.gdew-card .gdew-avgf__name {
	color: var(--gdew-soft);
	font-size: max(13px, .8em);
}

.gdew-card.gdew-card .gdew-avgf__price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	column-gap: .3em;
	font-size: 1.3em;
	font-weight: 700;
	font-variant-numeric: tabular-nums lining-nums;
}

.gdew-card.gdew-card .gdew-avgf__line {
	display: block;
	width: 100%;
	height: 40px;
	margin-top: .35em;
	overflow: visible;
	color: var(--gdew-accent);
}

.gdew-card.gdew-card .gdew-avgf__range {
	margin-top: .3em;
	color: var(--gdew-soft);
	font-size: max(13px, .75em);
	font-variant-numeric: tabular-nums lining-nums;
}

.gdew-card.gdew-card .gdew-avg__note {
	margin: .7em 0 .2em;
	color: var(--gdew-soft);
	font-size: max(13px, .78em);
}

/* --- messages and footer --- */

.gdew-card.gdew-card .gdew-card__msg {
	margin: .4em 0;
	color: var(--gdew-soft);
}

.gdew-card.gdew-card .gdew-card__foot {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: .3em 1em;
	padding-top: .6em;
	border-top: 1px solid var(--gdew-line);
	font-size: max(13px, .85em);
}

.gdew-card.gdew-card .gdew-card__time {
	color: var(--gdew-soft);
	font-variant-numeric: tabular-nums lining-nums;
}

.gdew-card.gdew-card .gdew-card__logo {
	display: inline-flex;
	align-items: center;
	margin-left: auto;
	line-height: 0;
}

.gdew-card.gdew-card .gdew-card__logo .gdew-logo {
	display: block;
	width: 145px;
	height: auto;
	color: var(--gdew-fg);
}

/* --- wide (a content column): the prices beside the name, the savings under the name --- */
@container (min-width: 520px) {
	.gdew-card.gdew-card .gdew-st {
		grid-template-columns: 40px minmax(0, 1fr) auto auto;
		grid-template-areas: "icon main prices dir" "icon save prices dir";
		align-items: center;
	}

	.gdew-card.gdew-card .gdew-st__prices {
		grid-template-columns: none;
		grid-auto-flow: column;
		grid-auto-columns: minmax(5.6em, auto);
		justify-content: end;
		text-align: right;
	}

	.gdew-card.gdew-card .gdew-st__prices dd {
		flex-direction: column;
		align-items: flex-end;
		gap: 0;
	}

	.gdew-card.gdew-card .gdew-avg {
		grid-template-columns: repeat(auto-fit, minmax(9em, 1fr));
	}
}

/* --- very narrow (a 200 px sidebar): without the icon, each price on one line with its label --- */
@container (max-width: 240px) {
	.gdew-card.gdew-card .gdew-st {
		grid-template-columns: 1fr auto;
		grid-template-areas: "main dir" "prices prices" "save save";
	}

	.gdew-card.gdew-card .gdew-st__icon {
		display: none;
	}

	.gdew-card.gdew-card .gdew-st__prices {
		grid-template-columns: 1fr;
		gap: .15em;
	}

	.gdew-card.gdew-card .gdew-st__prices .gdew-price {
		display: flex;
		flex-wrap: wrap;
		align-items: baseline;
		justify-content: space-between;
		column-gap: .5em;
	}

	.gdew-card.gdew-card .gdew-st__prices dd {
		justify-content: flex-end;
	}

	.gdew-card.gdew-card .gdew-card__logo .gdew-logo {
		width: 120px;
	}
}
