/**
 * The home-page index dashboard.
 *
 * The first thing a visitor sees, and the page's argument: this practice
 * publishes numbers, and here they are.
 *
 * ## Design notes worth keeping
 *
 * Tiles are on the page's own ground rather than floating on cards with
 * shadows. A dashboard of fifteen shadowed cards reads as a component library;
 * a ruled grid reads as a table of results, which is what this is.
 *
 * The hairline rule at the top of each tile is the only decoration, and it
 * carries information: full-strength accent where the index publishes, muted
 * where it does not. So the shape of the catalogue is legible at a glance
 * without reading a word.
 *
 * Figures use tabular numerals throughout. In a grid, digits that do not line
 * up column to column read as sloppiness before they read as data.
 */

/*
 * A 1280px frame with 24px desktop and 16px mobile gutters, per the Phase 2
 * experience specification. The theme's band is 84rem (1344px) wide, which is
 * the right measure for prose and too wide for a four-column data grid: at
 * 1344px the tiles gain width they do not need and the figures drift apart
 * from their own labels. The gutters are set here rather than on the band so
 * the dashboard keeps them on a page whose band has none.
 */
.pem-dash {
	--dash-gap: clamp(.75rem, 1.6vw, 1.25rem);

	/*
	 * 1280px in px, and border-box, because the specification says 1280 and
	 * means it. `80rem` measured 1297px here: the theme scales its root font
	 * size with the viewport, so a rem is 16.21px at 1440 and the frame drifts
	 * wider exactly where the cap matters most. Content-box would have added
	 * the gutters on top of the cap for the same reason.
	 */
	box-sizing: border-box;
	max-width: 1280px;
	margin-inline: auto;
	padding-block: clamp(2rem, 5vw, 3.5rem) clamp(2rem, 4vw, 3rem);
	padding-inline: 16px;
}

@media (min-width: 600px) {
	.pem-dash { padding-inline: 24px; }
}

/*
 * No max-width here.
 *
 * `max-width: 46rem` used to sit on this wrapper, and it is a READING MEASURE
 * — roughly 70 characters, the right line length for the paragraph below. A
 * display heading is not prose and does not want it: at 736px the title
 * "Industrial decarbonisation indices" needed 763px, missed a single line by
 * 27px, and `text-wrap: balance` then split it into two balanced lines.
 *
 * So the measure moved onto the prose that wants it and the heading is free to
 * use the column. Below roughly 820px the heading still wraps, which is
 * correct — the fix gives it the room it needs rather than forbidding the wrap,
 * so nothing overflows on a phone.
 */
.pem-dash__head {
	margin: 0 0 clamp(1.25rem, 3vw, 2rem);
}

.pem-dash__title {
	margin: 0 0 .5rem;
	font-size: var(--step-3, 2rem);
	line-height: 1.1;
	text-wrap: balance;
}

.pem-dash__lead {
	max-width: 46rem;
	margin: 0;
	color: var(--ink-2, inherit);
	font-size: var(--step-0, 1rem);
	line-height: 1.6;
}

/*
 * The availability count reads as a status line, not as more lead prose, so it
 * is set a step down and given its own space. It says how many of the indices
 * carry a figure today — a number that changes — which is a different kind of
 * statement from the sentence above it.
 */
.pem-dash__avail {
	/* Prose, so it keeps the reading measure the wrapper used to impose. */
	max-width: 46rem;
	margin: .75rem 0 0;
	color: var(--ink-2, inherit);
	font-size: var(--step--1, .875rem);
	line-height: 1.55;
}

/*
 * Column counts by width, from the Phase 2 experience specification: four at
 * ≥1200px, three at 900–1199, two at 600–899 and one below 600.
 *
 * This replaces `repeat(auto-fill, minmax(14rem, 1fr))`. The reasoning that
 * chose auto-fill still stands and is not being overturned — the objection was
 * to a count hardcoded at EVERY width, which strands the last tile when the
 * catalogue grows. Counts that change with the viewport do not do that: any
 * number of tiles reflows, and the fifteenth sits on a short final row exactly
 * as the sixteenth will.
 *
 * What auto-fill could not do is hit the specified counts. At the 1280px frame
 * a 14rem floor fits five columns, not four, so the layout the specification
 * describes was unreachable by tuning the floor alone.
 */
.pem-dash__grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--dash-gap);
}

@media (min-width: 600px) {
	.pem-dash__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
	.pem-dash__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1200px) {
	.pem-dash__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.pem-dash-tile {
	display: flex;
	flex-direction: column;
	gap: .2rem;
	padding: 1rem 1.1rem 1.15rem;
	border: 1px solid var(--rule-hair, rgba(255, 255, 255, .12));
	border-top: 2px solid var(--accent, currentColor);
	border-radius: 3px;
	text-decoration: none;
	color: inherit;
	background: var(--surface-1, transparent);
	transition: border-color .15s ease, transform .15s ease, background-color .15s ease;
}

.pem-dash-tile:hover,
.pem-dash-tile:focus-visible {
	border-color: var(--accent, currentColor);
	background: var(--surface-2, transparent);
	transform: translateY(-1px);
}

.pem-dash-tile:focus-visible {
	outline: 2px solid var(--accent, currentColor);
	outline-offset: 2px;
}

.pem-dash-tile__code {
	font-family: var(--font-mono, ui-monospace, monospace);
	font-size: var(--step--2, .75rem);
	letter-spacing: .08em;
	color: var(--ink-2, inherit);
}

/*
 * Two lines of room whether the name needs them or not.
 *
 * The figure below starts where the name ends, so a one-line name and a
 * two-line name in the same row put their figures at different heights — and
 * fifteen 2rem numerals at four different heights read as a broken grid before
 * they read as data. Reserving the second line costs a few pixels on the short
 * names and buys one baseline across every row.
 */
.pem-dash-tile__name {
	font-size: var(--step--1, .9rem);
	line-height: 1.3;
	font-weight: 600;
	text-wrap: balance;
	margin-bottom: .35rem;
	min-height: 2.6em;
}

/*
 * Top-anchored, NOT `margin-top: auto`. Bottom-anchoring lines the figures up
 * with the bottom of the tile, which sounds equivalent and is not: the meta
 * lines beneath a figure vary from none to three, so the bottom-anchored
 * number floats by whatever that tile happens to carry below it.
 */
.pem-dash-tile__figure {
	font-size: var(--step-3, 2rem);
	line-height: 1.05;
	font-variant-numeric: tabular-nums;
}

.pem-dash-tile__unit,
.pem-dash-tile__against,
.pem-dash-tile__meta {
	font-size: var(--step--2, .75rem);
	line-height: 1.4;
	color: var(--ink-2, inherit);
}

/* The denominator rides with the number. PIDI-N is 3.93 or 1.59 depending on it. */
.pem-dash-tile__against {
	color: var(--ink-1, inherit);
}

/* The one thing that IS bottom-anchored: a badge belongs on the tile's floor. */
.pem-dash-tile__tag {
	align-self: flex-start;
	margin-top: auto;
	padding: .1rem .45rem;
	border: 1px solid var(--rule-hair, rgba(255, 255, 255, .18));
	border-radius: 2px;
	font-size: var(--step--2, .7rem);
	letter-spacing: .05em;
	text-transform: uppercase;
	color: var(--ink-2, inherit);
}

/*
 * An index awaiting its first observation is muted, not hidden, and not
 * decorated in a warning colour. Nothing is wrong with it — DO-NOT 29 is the
 * product working. Amber here would tell a visitor the site is broken.
 */
.pem-dash-tile--waiting {
	border-top-color: var(--rule-hair, rgba(255, 255, 255, .25));
}

/*
 * Sits where a figure would, not at the foot of the tile — the empty state is
 * the answer to the same question the number answers, so it belongs in the
 * same place on the tile. Pushed to the bottom it read as a footnote.
 */
.pem-dash-tile__pending {
	padding: .45rem 0 .35rem;
	font-size: var(--step--1, .85rem);
	font-style: italic;
	color: var(--ink-2, inherit);
}

.pem-dash-tile__why {
	font-size: var(--step--2, .72rem);
	line-height: 1.4;
	color: var(--ink-2, inherit);
	opacity: .85;
}

.pem-dash__more {
	margin: clamp(1.25rem, 3vw, 2rem) 0 0;
	font-size: var(--step--1, .9rem);
}

@media (prefers-reduced-motion: reduce) {
	.pem-dash-tile { transition: none; }
	.pem-dash-tile:hover,
	.pem-dash-tile:focus-visible { transform: none; }
}
