:root {
	--dashboard-shell-width: 78rem;
	--copy-shell-width: 45rem;
	--panel-gap: 1.25rem;
}

header {
	padding: clamp(0.85rem, 2.4vw, 1.35rem) 1rem 0.5rem;
}

header h1 {
	margin: 0;
	max-width: 15ch;
	font-size: clamp(1.85rem, 3.35vw, 3.1rem);
	line-height: 0.98;
	text-wrap: balance;
}

header nav {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin-top: 0.75rem;
}

main h2 {
	font-size: clamp(1.55rem, 2.35vw, 2.2rem);
	line-height: 1.05;
	margin-bottom: 0.75rem;
}

article h3 {
	font-size: clamp(1.3rem, 1.85vw, 1.8rem);
	line-height: 1.08;
}

main.page-main,
footer {
	box-sizing: border-box;
	justify-self: center;
}

main.page-main {
	width: min(calc(100% - 2rem), var(--copy-shell-width));
}

main.dashboard-main {
	grid-column: 1 / -1;
	width: min(calc(100% - 2rem), var(--dashboard-shell-width));
}

footer {
	width: min(calc(100% - 2rem), var(--copy-shell-width));
}

.grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--panel-gap);
}

article {
	margin: 0;
}

.metric-card {
	height: 100%;
}

.metric-card h3,
.dashboard-panel h2 {
	margin-top: 0;
}

.metric-card p:last-child {
	margin-bottom: 0;
}

.dashboard-layout {
	display: grid;
	gap: 1.5rem;
}

.dashboard-panels {
	display: grid;
	gap: var(--panel-gap);
	align-items: start;
}

.dashboard-panel {
	height: 100%;
}

.table-scroll {
	max-height: 24rem;
	overflow: auto;
}

.table-scroll table {
	margin: 0;
}

.clickable-row {
	position: relative;
}

.clickable-row .row-link::after {
	content: "";
	position: absolute;
	inset: 0;
}

.clickable-row:hover {
	background: var(--table-row-hover-background, rgba(0, 0, 0, 0.04));
}

.chart-shell {
	width: 100%;
	height: 20rem;
}

.chart-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem 1.25rem;
	margin-top: 0.6rem;
	font-size: 0.82rem;
	color: var(--text-light, #6c757d);
}

.chart-legend__item {
	display: flex;
	align-items: center;
	gap: 0.35rem;
}

.chart-legend__swatch {
	display: inline-block;
	width: 0.85rem;
	height: 0.85rem;
	border-radius: 2px;
	flex-shrink: 0;
}

.dashboard-updated {
	margin-top: 0;
	color: var(--text-light, #6c757d);
	font-size: 0.85em;
}

/* Recent episode cards */
.ep-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 1rem;
}

.ep-card {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--card-border-color, rgba(0,0,0,0.12));
	border-radius: 0.5rem;
	overflow: hidden;
	margin: 0;
}

.ep-card__link {
	display: block;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: var(--card-swatch-background, #e9ecef);
}

.ep-card__thumb {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.2s ease;
}

.ep-card:hover .ep-card__thumb {
	transform: scale(1.03);
}

.ep-card__body {
	padding: 0.75rem;
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	flex: 1;
}

.ep-card__meta {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	flex-wrap: wrap;
}

.ep-card__num {
	font-weight: 600;
	font-size: 0.8rem;
	color: var(--text-light, #6c757d);
}

.ep-card__season {
	font-size: 0.75rem;
	color: var(--text-light, #6c757d);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ep-card__body h3 {
	margin: 0;
	font-size: 0.95rem;
	line-height: 1.3;
}

.ep-card__body h3 a {
	text-decoration: none;
	color: inherit;
}

.ep-card__body h3 a:hover {
	text-decoration: underline;
}

.ep-card__desc {
	font-size: 0.82rem;
	color: var(--text-light, #6c757d);
	line-height: 1.45;
	margin: 0;
}

.ep-card__footer {
	display: flex;
	justify-content: space-between;
	font-size: 0.78rem;
	color: var(--text-light, #6c757d);
	margin-top: auto;
	padding-top: 0.35rem;
}

/* Quiz page */
#quiz-shell {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
}

#quiz-loading {
	display: none;
}

#quiz-loading.htmx-request {
	display: block;
}

.quiz-question {
	border: 1px solid var(--card-border-color, rgba(0,0,0,0.12));
	border-radius: 0.5rem;
	padding: 1.25rem;
}

.quiz-question p {
	font-weight: 600;
	margin-top: 0;
}

.quiz-options {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	border: none;
	padding: 0;
	margin: 0;
}

.quiz-option {
	text-align: left;
	cursor: pointer;
}

.quiz-option:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.quiz-result {
	font-weight: 600;
	margin: 0.75rem 0 0.5rem;
}

.quiz-result--correct {
	color: var(--ins-color, #22863a);
}

.quiz-result--wrong {
	color: var(--del-color, #cb2431);
}

.quiz-correct-answer {
	font-size: 0.9rem;
	color: var(--text-light, #6c757d);
	margin: 0;
}

.quiz-load-more {
	text-align: center;
	padding: 0.75rem 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
}

.quiz-load-more[hidden] {
	display: none;
}

.quiz-load-more-spinner {
	display: none;
	width: 1rem;
	height: 1rem;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: quiz-spin 0.7s linear infinite;
	opacity: 0.7;
}

.quiz-load-more-spinner.htmx-request {
	display: inline-block;
}

.quiz-answer-spinner {
	display: none;
	width: 1rem;
	height: 1rem;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: quiz-spin 0.7s linear infinite;
	opacity: 0.7;
	margin-top: 0.5rem;
}

.quiz-answer-spinner.htmx-request {
	display: inline-block;
}

@keyframes quiz-spin {
	to { transform: rotate(360deg); }
}