/**
 * base.css — short normalize, typography, links, cards, and the shared
 * accessibility utilities. Mobile-first: single column by default.
 */

/* ---------- Normalize (short, deliberate — no reset library) ---------- */

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--ils-bg);
	color: var(--ils-fg);
	font-family: var(--ils-font-sans);
	font-size: var(--ils-fs-base);
	line-height: var(--ils-lh-normal);
	-webkit-font-smoothing: antialiased;
}

/*
 * Media defaults, wrapped in :where() so they carry ZERO specificity.
 *
 * This matters more than it looks. `img[width][height]` is specificity (0,2,1),
 * which beats an ordinary component rule like `.ils-top-bar__logo img` (0,1,1)
 * — so without :where() this block silently overrides the height of every image
 * that carries width/height attributes, which is all of them: the masthead
 * logo, the Opinion portraits, every core-rendered thumbnail. Zero-specificity
 * defaults let a component say what it means and win.
 */
:where(img, svg, video) {
	max-width: 100%;
	height: auto;
	display: block;
}

/*
 * Let the width/height attributes drive the aspect ratio so the browser
 * reserves the right box before a lazy image arrives. `height: auto` is what
 * allows that ratio to apply — without it the attribute height would be used
 * literally and a responsive image would distort.
 */
:where(img[width][height]) {
	height: auto;
}

/*
 * Headlines are the serif; everything else stays on the system sans.
 *
 * Letter-spacing is left alone rather than tightened. Reith is drawn with its
 * own spacing and negative tracking on a serif at headline size closes the
 * counters — the thing that makes a big serif headline look cramped.
 */
h1, h2, h3, h4 {
	margin: 0;
	font-family: var(--ils-font-serif);
	font-weight: var(--ils-weight-heading);
	line-height: var(--ils-lh-tight);
}

p {
	margin: 0 0 var(--ils-sp-4);
}

ul, ol {
	margin: 0;
	padding: 0;
}

li {
	list-style: none;
}

a {
	color: var(--ils-link);
	text-decoration: none;
}

a:hover,
a:focus-visible {
	color: var(--ils-link-hover);
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 2px;
}

button {
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
}

time {
	font-variant-numeric: tabular-nums;
}

hr {
	border: 0;
	border-top: var(--ils-border-hairline);
	margin: var(--ils-sp-4) 0;
}

/* ---------- Focus: always visible, never removed ---------- */

:focus-visible {
	outline: var(--ils-focus-ring);
	outline-offset: var(--ils-focus-offset);
}

/* ---------- Accessibility utilities ---------- */

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.ils-skip-link:focus,
.ils-skip-link:focus-visible {
	position: fixed !important;
	top: var(--ils-sp-2);
	left: var(--ils-sp-2);
	z-index: var(--ils-z-skip);
	width: auto;
	height: auto;
	clip: auto;
	margin: 0;
	padding: var(--ils-sp-2) var(--ils-sp-4);
	background: var(--ils-red);
	color: var(--ils-white);
	font-weight: 700;
	text-decoration: none;
}

[hidden] {
	display: none !important;
}

/* ---------- Layout shell ---------- */

.ils-main {
	max-width: var(--ils-max-width);
	margin: 0 auto;
	padding: 0 var(--ils-gutter);
}

.ils-main:focus {
	outline: none;
}

/* ---------- Cards: the single most reused component ---------- */

.ils-card {
	margin: 0;
	padding-bottom: var(--ils-sp-4);
	border-bottom: var(--ils-border-hairline);
}

.ils-card__img {
	width: 100%;
	background: var(--ils-gray-100);
}

.ils-card__media,
.ils-card__media-link {
	display: block;
	margin-bottom: var(--ils-sp-2);
}

.ils-card__kicker {
	display: block;
	margin-bottom: var(--ils-sp-1);
	color: var(--ils-red);
	font-size: var(--ils-fs-xs);
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.ils-card__headline {
	font-size: var(--ils-fs-base);
	line-height: var(--ils-lh-snug);
	margin-bottom: var(--ils-sp-2);
}

.ils-card__deck {
	margin: 0 0 var(--ils-sp-2);
	color: var(--ils-gray-600);
	font-size: var(--ils-fs-sm);
	line-height: var(--ils-lh-normal);
}

.ils-card__time,
.ils-card__meta {
	display: block;
	color: var(--ils-fg-muted);
	font-size: var(--ils-fs-xs);
}

.ils-card__meta {
	display: flex;
	gap: var(--ils-sp-1);
	align-items: center;
	flex-wrap: wrap;
}

.ils-card__sep {
	color: var(--ils-gray-300);
}

/* Hero card: bigger headline, image first */
.ils-card--hero .ils-card__headline--hero {
	font-size: var(--ils-fs-xl);
}

.ils-card--hero .ils-card__deck {
	font-size: var(--ils-fs-base);
}

.ils-card__photo-credit {
	display: block;
	padding-top: var(--ils-sp-1);
	color: var(--ils-fg-muted);
	font-size: var(--ils-fs-xs);
	text-align: right;
}

/* Small card: thumbnail beside the headline from tablet up */
.ils-card--sm {
	display: grid;
	grid-template-columns: 96px 1fr;
	gap: var(--ils-sp-3);
	align-items: start;
}

.ils-card--sm .ils-card__media-link {
	margin-bottom: 0;
}

.ils-card--sm .ils-card__headline {
	font-size: var(--ils-fs-sm);
}

/* Video card: play overlay centred on the thumbnail */
.ils-card--video .ils-card__media-link {
	position: relative;
}

.ils-card__play {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	pointer-events: none;
}

.ils-card__img--placeholder {
	aspect-ratio: 16 / 9;
	background: var(--ils-gray-200);
}

/* ---------- Pagination ---------- */

.ils-pagination {
	margin: var(--ils-sp-6) 0;
}

.ils-pagination .nav-links {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ils-sp-2);
	align-items: center;
}

.ils-pagination .page-numbers {
	display: inline-block;
	min-width: 2.25rem;
	padding: var(--ils-sp-2) var(--ils-sp-3);
	border: var(--ils-border-hairline);
	font-size: var(--ils-fs-sm);
	text-align: center;
}

.ils-pagination .page-numbers.current {
	background: var(--ils-red);
	border-color: var(--ils-red);
	color: var(--ils-white);
	font-weight: 700;
}

/* ---------- Search form (core get_search_form output) ---------- */

.search-form {
	display: flex;
	gap: var(--ils-sp-2);
	max-width: 30rem;
}

.search-form label {
	flex: 1;
}

.search-form .search-field {
	width: 100%;
	padding: var(--ils-sp-2) var(--ils-sp-3);
	border: 1px solid var(--ils-rule-strong);
	font: inherit;
}

.search-form .search-submit {
	padding: var(--ils-sp-2) var(--ils-sp-4);
	background: var(--ils-red);
	color: var(--ils-white);
	font-weight: 700;
}

/* ---------- Icons ---------- */

.ils-icon {
	width: 1.25rem;
	height: 1.25rem;
	fill: currentColor;
}

/* ---------- Tablet and up ---------- */

@media (min-width: 48em) {
	.ils-card--hero .ils-card__headline--hero {
		font-size: var(--ils-fs-2xl);
	}

	.ils-card--sm {
		grid-template-columns: 120px 1fr;
	}

	.ils-card--sm .ils-card__headline {
		font-size: var(--ils-fs-base);
	}
}
