/**
 * /weather/ — live NWS forecast card (`.bi-wx`).
 * Tokens only (docs/DOC_DESIGN-SYSTEM.md). Enqueued by BBI2_Coded_Posts on the weather canvas.
 *
 * Anatomy, top to bottom:
 *   alert (only when NWS has one) → pink "right now" band → stat tiles → what to wear →
 *   this week (range bars on a shared scale; rows are tabs) → hour-by-hour chart → source line.
 *
 * Color language: ink for numbers and copy, Island Pink for temperature and selection,
 * the status-info blue for rain (the one thing pink cannot also mean).
 */

/* ---------------------------------------------------------------------------
   Card
   ------------------------------------------------------------------------ */

.bi-wx {
	position: relative;
	margin: 0 0 var(--space-10);
	overflow: hidden;
	font-family: var(--font-sans);
	font-size: var(--text-body);
	line-height: var(--leading-body);
	color: var(--color-ink);
	background: var(--color-white);
	border-radius: var(--radius-card-story);
	box-shadow: var(--shadow-card);
	font-variant-numeric: tabular-nums;
}

.bi-wx[aria-busy="true"] {
	min-height: 360px;
}

.bi-wx :focus-visible {
	outline: 2px solid var(--color-ink);
	outline-offset: 3px;
}

/* .bi-prose sets paragraph rhythm for the article; the card manages its own.
   Rules below are written as `.bi-wx .class` so they out-rank `.bi-prose p`. */
section.bi-wx p {
	margin: 0;
}

.bi-wx [hidden] {
	display: none;
}

.bi-wx h3 {
	margin: 0;
	font-family: var(--font-sans);
	font-size: var(--text-h6);
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--color-ink);
}

.bi-wx svg {
	display: block;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.bi-wx__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.bi-wx__wait {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 360px;
	padding: var(--space-8);
}

.bi-wx .bi-wx__fallback {
	padding: var(--space-8) var(--space-6);
	text-align: center;
}

/* ---------------------------------------------------------------------------
   Alert (NWS watch / warning / advisory)
   ------------------------------------------------------------------------ */

.bi-wx__alert {
	display: flex;
	gap: var(--space-3);
	align-items: flex-start;
	padding: var(--space-4) var(--space-5);
	background: var(--color-status-warn-bg);
	border-left: 4px solid var(--color-status-warn);
}

.bi-wx__alert.is-severe {
	background: var(--color-status-bad-bg);
	border-left-color: var(--color-status-bad);
}

.bi-wx__alert-icon {
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	margin-top: 2px;
	color: var(--color-status-warn);
}

.bi-wx__alert.is-severe .bi-wx__alert-icon {
	color: var(--color-status-bad);
}

.bi-wx__alert-body {
	min-width: 0;
	font-size: var(--text-ui);
	line-height: 1.45;
}

.bi-wx__alert-title {
	font-weight: 600;
}

.bi-wx__alert-when {
	display: block;
	font-size: var(--text-ui);
}

.bi-wx .bi-wx__alert-body a {
	font-weight: 600;
	color: var(--color-ink);
	border-bottom: 1px dotted var(--color-ink);
	text-decoration: none;
}

.bi-wx__alert details > summary {
	margin-top: var(--space-1);
	font-size: var(--text-small);
	font-weight: 600;
	cursor: pointer;
}

.bi-wx__alert details p {
	margin-top: var(--space-2);
	font-size: var(--text-small);
}

/* ---------------------------------------------------------------------------
   Right now — the pink band
   ------------------------------------------------------------------------ */

.bi-wx__now {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	grid-template-areas:
		"meta meta"
		"icon temp"
		"copy copy";
	gap: var(--space-3) var(--space-5);
	align-items: center;
	padding: var(--space-6) var(--space-5) var(--space-8);
	color: var(--color-on-pink);
	background: var(--color-pink);
}

.bi-wx__now h3,
.bi-wx__now p {
	color: var(--color-on-pink);
}

.bi-wx__meta {
	grid-area: meta;
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-1) var(--space-3);
	align-items: baseline;
}

.bi-wx__meta-time {
	font-size: var(--text-ui);
	font-weight: 600;
}

.bi-wx__icon {
	grid-area: icon;
	width: 64px;
	height: 64px;
}

.bi-wx__icon svg {
	width: 100%;
	height: 100%;
	stroke-width: 1.5;
}

.bi-wx .bi-wx__temp {
	grid-area: temp;
	font-size: 4.25rem;
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.03em;
}

.bi-wx__deg {
	font-size: 0.5em;
	font-weight: 600;
	vertical-align: top;
	letter-spacing: 0;
}

.bi-wx__copy {
	grid-area: copy;
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
	min-width: 0;
}

.bi-wx .bi-wx__cond {
	font-size: var(--text-h3);
	font-weight: 600;
	line-height: 1.3;
	text-wrap: balance;
}

.bi-wx .bi-wx__feels {
	font-size: var(--text-ui);
	font-weight: 600;
	line-height: 1.4;
	text-wrap: pretty;
}

/* ---------------------------------------------------------------------------
   Stat tiles
   ------------------------------------------------------------------------ */

/* Beat `.bi-prose ul` (disc + 1.25em indent) — that was squeezing the tiles. */
.bi-wx ul.bi-wx__stats {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 1px;
	margin: 0;
	padding: 0;
	list-style: none;
	background: var(--color-line);
	border-bottom: 1px solid var(--color-line);
}

.bi-wx .bi-wx__stat {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
	margin: 0;
	padding: var(--space-4) var(--space-5);
	background: var(--color-white);
}

.bi-wx__stat-label {
	font-size: var(--text-h6);
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.bi-wx__stat-value {
	display: flex;
	gap: var(--space-2);
	align-items: center;
	font-size: var(--text-h3);
	font-weight: 600;
	line-height: 1.2;
}

.bi-wx__stat-value svg {
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	color: var(--color-pink);
}

.bi-wx__stat-sub {
	font-size: var(--text-small);
	line-height: 1.4;
	overflow-wrap: break-word;
}

/* ---------------------------------------------------------------------------
   What to wear
   ------------------------------------------------------------------------ */

.bi-wx__tip {
	display: flex;
	flex-direction: column;
	gap: var(--space-1);
	padding: var(--space-4) var(--space-5);
	background: var(--color-canvas);
	border-left: 4px solid var(--color-pink);
}

.bi-wx .bi-wx__tip-text {
	font-size: var(--text-body);
	line-height: 1.45;
	text-wrap: pretty;
}

/* ---------------------------------------------------------------------------
   This week — rows are tabs; bars share the week's min→max scale
   ------------------------------------------------------------------------ */

.bi-wx__week {
	padding: var(--space-5) var(--space-3) var(--space-3);
}

.bi-wx__head {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-1) var(--space-4);
	align-items: baseline;
	justify-content: space-between;
	margin: 0 var(--space-2) var(--space-3);
}

.bi-wx .bi-wx__note {
	font-size: var(--text-small);
	line-height: 1.4;
}

.bi-wx__days {
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 0;
}

.bi-wx__day-block {
	display: flex;
	flex-direction: column;
}

.bi-wx__day {
	display: grid;
	grid-template-columns: 3.25rem 2.75rem 2rem minmax(0, 1fr) 2rem;
	gap: var(--space-2);
	align-items: center;
	width: 100%;
	margin: 0;
	padding: var(--space-3) var(--space-2);
	font: inherit;
	color: inherit;
	text-align: left;
	background: transparent;
	border: 0;
	border-top: 1px solid var(--color-line);
	border-radius: 0;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.bi-wx__day-block:first-child .bi-wx__day {
	border-top: 0;
}

.bi-wx__day:hover {
	background: var(--color-canvas);
}

.bi-wx__day[aria-expanded="true"] {
	background: var(--color-canvas);
	box-shadow: inset 4px 0 0 var(--color-pink);
	border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.bi-wx__day-block:has(.bi-wx__day[aria-expanded="true"]) + .bi-wx__day-block .bi-wx__day {
	border-top-color: transparent;
}

.bi-wx__day-name {
	font-size: var(--text-ui);
	font-weight: 600;
	line-height: 1.25;
}

.bi-wx__day-date {
	display: none;
	font-size: var(--text-small);
	font-weight: 400;
}

/* Under 480px the icon and rain chance stack in one column so the bar keeps its width. */
.bi-wx__day-sky {
	display: flex;
	flex-direction: column;
	gap: 2px;
	align-items: center;
	justify-content: center;
	min-width: 0;
	min-height: 46px; /* rows without a rain chance stay the same height */
}

.bi-wx__day-icon {
	width: 28px;
	height: 28px;
}

.bi-wx__day-icon svg {
	width: 100%;
	height: 100%;
}

.bi-wx__day-pop {
	display: inline-flex;
	gap: 2px;
	align-items: center;
	font-size: var(--text-small);
	font-weight: 600;
	color: var(--color-status-info);
}

.bi-wx__day-pop svg {
	width: 12px;
	height: 12px;
	fill: currentColor;
	stroke: none;
}

.bi-wx__day-lo,
.bi-wx__day-hi {
	font-size: var(--text-ui);
	font-weight: 600;
}

.bi-wx__day-lo {
	text-align: right;
}

.bi-wx__bar {
	position: relative;
	height: 8px;
	background: var(--color-line);
	border-radius: var(--radius-pill);
}

.bi-wx__bar-fill {
	position: absolute;
	top: 0;
	bottom: 0;
	min-width: 8px;
	background: var(--color-pink);
	border-radius: inherit;
}

.bi-wx__bar-now {
	position: absolute;
	top: 50%;
	width: 14px;
	height: 14px;
	margin: -7px 0 0 -7px;
	background: var(--color-white);
	border: 3px solid var(--color-ink);
	border-radius: 50%;
	box-shadow: 0 0 0 2px var(--color-white);
}

.bi-wx__day-qpf {
	display: none;
	font-size: var(--text-small);
	text-align: right;
}

/* ---------------------------------------------------------------------------
   Hour by hour
   ------------------------------------------------------------------------ */

.bi-wx__hourly {
	padding: var(--space-4) var(--space-5) var(--space-6);
	background: var(--color-canvas);
	border-radius: 0 0 var(--radius-card) var(--radius-card);
	box-shadow: inset 4px 0 0 var(--color-pink);
}

.bi-wx__hourly-head {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-1) var(--space-3);
	align-items: baseline;
	margin-bottom: var(--space-2);
}

.bi-wx__hourly-head h3 {
	font-size: var(--text-h4);
	letter-spacing: normal;
	text-transform: none;
}

.bi-wx .bi-wx__hourly-sum {
	max-width: 46em;
	margin-bottom: var(--space-3);
}

.bi-wx .bi-wx__hourly-sum p {
	margin: 0 0 var(--space-2);
	font-size: var(--text-ui);
	line-height: 1.5;
	text-wrap: pretty;
}

.bi-wx .bi-wx__hourly-sum strong {
	font-weight: 600;
	color: var(--color-ink);
}

.bi-wx ul.bi-wx__facts {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--space-2) var(--space-6);
	margin: 0 0 var(--space-5);
	padding: 0;
	font-size: var(--text-small);
	line-height: 1.4;
	list-style: none;
}

.bi-wx .bi-wx__facts li {
	margin: 0;
	padding: 0;
}

.bi-wx .bi-wx__facts strong {
	font-weight: 600;
	color: var(--color-ink);
}

.bi-wx__chart {
	position: relative;
	width: 100%;
	min-height: 200px;
}

.bi-wx__chart svg {
	display: block;
	width: 100%;
	height: auto;
	overflow: visible;
	stroke: none;
}

.bi-wx__chart text {
	font-family: var(--font-sans);
	fill: var(--color-ink);
}

.bi-wx .bi-wx__chart-empty {
	padding: var(--space-6) 0;
	font-size: var(--text-ui);
}

.bi-wx__legend {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2) var(--space-4);
	margin: var(--space-3) 0 0;
	padding: 0;
	font-size: var(--text-small);
	list-style: none;
}

.bi-wx__legend li {
	display: inline-flex;
	gap: var(--space-2);
	align-items: center;
}

.bi-wx__swatch {
	display: inline-block;
	width: 14px;
	height: 14px;
	border-radius: 3px;
}

.bi-wx__swatch--temp {
	background: var(--color-pink);
}

.bi-wx__swatch--rain {
	background: var(--color-status-info);
}

.bi-wx__swatch--night {
	background: var(--color-canvas);
	border: 1px solid var(--color-line-strong);
}

/* ---------------------------------------------------------------------------
   Source line
   ------------------------------------------------------------------------ */

.bi-wx__foot {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2) var(--space-4);
	align-items: baseline;
	justify-content: space-between;
	padding: var(--space-4) var(--space-5);
	font-size: var(--text-ui);
	line-height: 1.45;
	background: var(--color-canvas-subtle);
	border-top: 1px solid var(--color-line);
}

.bi-wx__foot.is-stale {
	background: var(--color-status-warn-bg);
}

.bi-wx .bi-wx__foot p {
	font-size: var(--text-ui);
	line-height: 1.45;
}

.bi-wx__foot a {
	font-weight: 600;
	color: var(--color-pink);
	text-decoration: none;
	border-bottom: 1px dotted var(--color-pink);
}

.bi-wx__foot a:hover,
.bi-wx__foot a:focus-visible {
	color: var(--color-pink-hover);
	border-bottom-color: var(--color-pink-hover);
}

/* ---------------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------------ */

@media (min-width: 480px) {
	.bi-wx ul.bi-wx__stats {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.bi-wx ul.bi-wx__facts {
		grid-template-columns: 1fr 1fr;
	}

	.bi-wx__day {
		grid-template-columns: 5.5rem 2rem 3.25rem 2.25rem minmax(0, 1fr) 2.25rem;
		gap: var(--space-3);
	}

	.bi-wx__day-sky {
		display: contents;
	}

	.bi-wx__day-date {
		display: block;
	}

	.bi-wx__icon {
		width: 80px;
		height: 80px;
	}

	.bi-wx__temp {
		font-size: 5rem;
	}
}

@media (min-width: 768px) {
	.bi-wx__now {
		grid-template-columns: auto auto minmax(0, 1fr);
		grid-template-areas:
			"meta meta meta"
			"icon temp copy";
		gap: var(--space-4) var(--space-6);
		padding: var(--space-6) var(--space-8) var(--space-8);
	}

	.bi-wx__copy {
		padding-left: var(--space-4);
		border-left: 1px solid color-mix(in srgb, var(--color-on-pink) 45%, transparent);
	}

	/* Card is 52rem — six columns makes the subtitles collide. Stay at 3×2. */
	.bi-wx .bi-wx__stat {
		padding: var(--space-5);
	}

	.bi-wx__stat-value {
		font-size: var(--text-h4);
	}

	.bi-wx__tip {
		flex-direction: row;
		gap: var(--space-4);
		align-items: baseline;
		padding: var(--space-4) var(--space-8);
	}

	.bi-wx__tip h3 {
		flex: 0 0 auto;
	}

	.bi-wx__week {
		padding: var(--space-5) var(--space-5) var(--space-3);
	}

	.bi-wx__day {
		grid-template-columns: 6.5rem 2rem 3.5rem 2.5rem minmax(0, 1fr) 2.5rem 3.5rem;
		padding: var(--space-3) var(--space-3);
	}

	.bi-wx__day-qpf {
		display: block;
	}

	.bi-wx__hourly {
		padding: var(--space-5) var(--space-8) var(--space-6);
	}

	.bi-wx__foot {
		padding: var(--space-4) var(--space-8);
	}
}

@media (prefers-reduced-motion: no-preference) {
	.bi-wx__day {
		transition: background-color 200ms ease, box-shadow 200ms ease, border-radius 200ms ease;
	}
}
