/**
 * Components: buttons, forms, cards, pagination and shared block furniture.
 */

/* --- Buttons --------------------------------------------------------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--sp-2xs);
	/* 44px minimum target height. WCAG 2.2 AA, 2.5.8 Target Size (Minimum). */
	min-height: 44px;
	padding: var(--sp-2xs) var(--sp-md);
	background-color: var(--c-brand);
	color: var(--c-text-inverse);
	font-family: var(--font-heading);
	font-size: var(--fs-base);
	font-weight: var(--fw-bold);
	line-height: var(--lh-snug);
	text-align: center;
	text-decoration: none;
	border: 2px solid var(--c-brand);
	border-radius: var(--radius-sm);
	cursor: pointer;
	transition: background-color var(--dur-fast) var(--ease),
	            border-color var(--dur-fast) var(--ease),
	            color var(--dur-fast) var(--ease);
}

.btn:hover {
	background-color: var(--c-brand-dark);
	border-color: var(--c-brand-dark);
	color: var(--c-text-inverse);
}

.btn--secondary {
	background-color: transparent;
	color: var(--c-brand);
}

.btn--secondary:hover {
	background-color: var(--c-brand);
	color: var(--c-text-inverse);
}

.btn--accent {
	background-color: var(--c-accent);
	border-color: var(--c-accent);
	color: var(--c-black);
}

.btn--accent:hover {
	background-color: var(--c-accent-dark);
	border-color: var(--c-accent-dark);
	color: var(--c-black);
}

/* For use over imagery and dark overlays. */
.btn--inverse {
	background-color: var(--c-white);
	border-color: var(--c-white);
	color: var(--c-brand-dark);
}

.btn--inverse:hover {
	background-color: transparent;
	color: var(--c-white);
}

.btn--lg {
	min-height: 52px;
	padding-inline: var(--sp-lg);
	font-size: var(--fs-md);
}

.btn--block {
	width: 100%;
}

/* --- Forms ----------------------------------------------------------- */

label {
	display: block;
	margin-bottom: var(--sp-3xs);
	font-size: var(--fs-sm);
	font-weight: var(--fw-medium);
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="date"],
textarea,
select {
	width: 100%;
	min-height: 44px;
	padding: var(--sp-2xs) var(--sp-xs);
	background-color: var(--c-white);
	color: var(--c-text);
	border: 1px solid var(--c-border-strong);
	border-radius: var(--radius-sm);
	transition: border-color var(--dur-fast) var(--ease);
}

input:hover,
textarea:hover,
select:hover {
	border-color: var(--c-grey-500);
}

/* Focus is handled by the global :focus-visible rule in base.css. The border
   change here is supplementary, not the sole indicator. */
input:focus,
textarea:focus,
select:focus {
	border-color: var(--c-brand);
}

textarea {
	min-height: 140px;
	resize: vertical;
}

::placeholder {
	color: var(--c-grey-500);
	opacity: 1;
}

/* Required field marker, paired with the required attribute on the input. */
.required-marker {
	color: var(--c-error);
}

.field-error {
	margin-top: var(--sp-3xs);
	color: var(--c-error);
	font-size: var(--fs-sm);
}

/* --- Search form ----------------------------------------------------- */

.search-form {
	display: flex;
	align-items: stretch;
	gap: 0;
	max-width: 100%;
}

.search-form__field {
	min-width: 0;
	border-right: 0;
	border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.search-form__submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 44px;
	min-height: 44px;
	padding: 0;
	background-color: var(--c-brand);
	color: var(--c-white);
	border: 1px solid var(--c-brand);
	border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
	cursor: pointer;
	transition: background-color var(--dur-fast) var(--ease);
}

.search-form__submit:hover {
	background-color: var(--c-brand-dark);
}

.search-form__submit svg {
	width: 18px;
	height: 18px;
	fill: currentColor;
}

/* --- Cards ----------------------------------------------------------- */

.card {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	background-color: var(--c-white);
	border: 1px solid var(--c-border);
	border-radius: var(--radius-md);
	transition: box-shadow var(--dur-base) var(--ease),
	            transform var(--dur-base) var(--ease);
}

.card:hover {
	box-shadow: var(--shadow-lg);
	transform: translateY(-2px);
}

.card__media {
	aspect-ratio: 16 / 10;
	overflow: hidden;
	background-color: var(--c-grey-100);
}

.card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.card__body {
	display: flex;
	flex-direction: column;
	flex: 1;
	gap: var(--sp-2xs);
	padding: var(--sp-sm);
}

.card__title {
	font-size: var(--fs-lg);
}

/* The whole card is clickable, but only the title is a real link, so the
   accessible name and tab order stay correct. */
.card__title a {
	color: var(--c-heading);
	text-decoration: none;
}

.card__title a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.card--linked {
	position: relative;
}

.card__title a:hover {
	color: var(--c-brand);
}

.card__meta {
	color: var(--c-text-muted);
	font-size: var(--fs-sm);
}

.card__excerpt {
	flex: 1;
	font-size: var(--fs-sm);
}

/* --- Grids ----------------------------------------------------------- */

.grid {
	display: grid;
	gap: var(--sp-md);
}

/*
 * Explicit column counts rather than auto-fit.
 *
 * auto-fit collapses empty tracks, so a section with a single item stretched
 * that item across the full 1280px container. Fixed counts keep one news
 * post sitting in a third of the row, which is what the grid implies.
 */
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1024px) {
	.grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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

@media (max-width: 600px) {
	.grid--2,
	.grid--3,
	.grid--4 { grid-template-columns: minmax(0, 1fr); }
}

/* --- Section headings ------------------------------------------------ */

.block__header {
	max-width: var(--container-narrow);
	margin-bottom: var(--sp-lg);
}

.block__header--centred {
	margin-inline: auto;
	text-align: center;
}

.block__title {
	margin: 0;
}

.block__subtitle {
	margin-top: var(--sp-2xs);
	color: var(--c-text-muted);
	font-size: var(--fs-md);
}

/* --- Overlay helper -------------------------------------------------- */

/* Shared by every block that places text over a background image. Applied as
   a pseudo-element so the markup stays clean and the overlay cannot be
   focused or read by assistive technology. */
.has-overlay {
	position: relative;
	background-position: center;
	background-size: cover;
	background-repeat: no-repeat;
}

.has-overlay::before {
	content: "";
	position: absolute;
	inset: 0;
	background-color: var(--c-overlay);
	pointer-events: none;
}

.has-overlay--strong::before {
	background-color: var(--c-overlay-strong);
}

.has-overlay > * {
	position: relative;
	z-index: var(--z-base);
}

.has-overlay,
.has-overlay :is(h1, h2, h3, h4, h5, h6) {
	color: var(--c-text-inverse);
}

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

.pagination {
	margin-top: var(--sp-xl);
}

.pagination .nav-links {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: var(--sp-3xs);
}

.pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: var(--sp-3xs) var(--sp-2xs);
	border: 1px solid var(--c-border-strong);
	border-radius: var(--radius-sm);
	text-decoration: none;
}

.pagination .page-numbers.current {
	background-color: var(--c-brand);
	border-color: var(--c-brand);
	color: var(--c-white);
}

.pagination .page-numbers:hover:not(.current) {
	border-color: var(--c-brand);
	color: var(--c-brand);
}

/* --- Notices --------------------------------------------------------- */

.notice {
	padding: var(--sp-sm);
	border-left: 4px solid var(--c-brand);
	border-radius: var(--radius-sm);
	background-color: var(--c-bg-subtle);
}

.notice--empty {
	text-align: center;
	color: var(--c-text-muted);
}

/* --- Entry content --------------------------------------------------- */

.entry-content {
	max-width: var(--container-narrow);
}

.entry-meta {
	margin-bottom: var(--sp-sm);
	color: var(--c-text-muted);
	font-size: var(--fs-sm);
}

.entry-footer {
	margin-top: var(--sp-lg);
	padding-top: var(--sp-sm);
	border-top: 1px solid var(--c-border);
	font-size: var(--fs-sm);
}

/* =====================================================================
 * Competitive redesign additions
 *
 * Patterns the competitor set (SanDisk, Western Digital, DataLocker,
 * Apricorn) all use and the previous theme had no equivalent for.
 * ================================================================== */

/* --- Inverse sections ------------------------------------------------ */

/* Near-black ground used for hero, trust strips and feature sections. The
   whole category alternates light and dark bands down the page rather than
   running everything on white. */
.bg-inverse {
	background-color: var(--c-bg-inverse);
	color: var(--c-grey-300);
}

.bg-inverse :is(h1, h2, h3, h4, h5, h6) {
	color: var(--c-white);
}

.bg-inverse a:not(.btn) {
	color: var(--c-accent);
}

.bg-subtle {
	background-color: var(--c-bg-subtle);
}

/* --- Certification / trust strip ------------------------------------- */

/* Monochrome badge row. Every competitor runs one of these high on the page:
   it is the single strongest trust signal in this category. */
.trust-strip {
	padding-block: var(--sp-lg);
	border-block: 1px solid var(--c-border);
}

.bg-inverse .trust-strip,
.trust-strip.bg-inverse {
	border-color: var(--c-grey-700);
}

.trust-strip__label {
	margin-bottom: var(--sp-md);
	color: var(--c-text-muted);
	font-family: var(--font-heading);
	font-size: var(--fs-xs);
	font-weight: var(--fw-bold);
	letter-spacing: var(--ls-caps);
	text-align: center;
	text-transform: uppercase;
}

.trust-strip__items {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: clamp(var(--sp-md), 4vw, var(--sp-2xl));
	margin: 0;
	padding: 0;
	list-style: none;
}

.trust-strip__item img {
	width: auto;
	max-height: 48px;
	/* Desaturated so a wall of differently-coloured accreditation marks does
	   not fight the page. Restored on hover. */
	filter: grayscale(1);
	opacity: 0.65;
	transition: filter var(--dur-base) var(--ease),
	            opacity var(--dur-base) var(--ease);
}

.trust-strip__item:hover img {
	filter: grayscale(0);
	opacity: 1;
}

.bg-inverse .trust-strip__item img {
	filter: grayscale(1) invert(1) brightness(1.6);
}

/* --- Feature grid ---------------------------------------------------- */

/* Icon + heading + copy, in a 2x2 or 1x4. DataLocker's "Why Choose" block
   and WD's feature rows are both this pattern. */
.feature-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: var(--sp-lg);
}

.feature {
	display: flex;
	flex-direction: column;
	gap: var(--sp-2xs);
}

.feature__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	margin-bottom: var(--sp-2xs);
	color: var(--c-brand);
}

.bg-inverse .feature__icon {
	color: var(--c-accent);
}

.feature__icon svg {
	width: 28px;
	height: 28px;
	fill: currentColor;
}

.feature__title {
	font-size: var(--fs-md);
	font-weight: var(--fw-bold);
}

.feature__text {
	color: var(--c-text-muted);
	font-size: var(--fs-sm);
}

.bg-inverse .feature__text {
	color: var(--c-grey-400);
}

/* --- Spec list ------------------------------------------------------- */

/* Key/value rows for technical specifications. The product pages in this
   category live or die on how readable this table is. */
.spec-list {
	margin: 0;
	border-top: 1px solid var(--c-border);
	font-size: var(--fs-sm);
}

.spec-list__row {
	display: grid;
	grid-template-columns: minmax(140px, 1fr) 2fr;
	gap: var(--sp-sm);
	padding-block: var(--sp-xs);
	border-bottom: 1px solid var(--c-border);
}

.spec-list__key {
	color: var(--c-text-muted);
	font-weight: var(--fw-medium);
}

.spec-list__value {
	font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
	.spec-list__row {
		grid-template-columns: 1fr;
		gap: var(--sp-3xs);
	}
}

/* --- Stat row -------------------------------------------------------- */

.stat-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: var(--sp-lg);
	margin: 0;
	padding: 0;
	list-style: none;
}

.stat {
	text-align: center;
}

.stat__value {
	display: block;
	color: var(--c-brand);
	font-family: var(--font-heading);
	/* Sized to hold a short technical value such as "AES-XTS 256" on one
	   line at desktop. Figures here are rarely a bare number. */
	font-size: var(--fs-xl);
	font-weight: var(--fw-black);
	letter-spacing: var(--ls-display);
	line-height: var(--lh-snug);
	text-wrap: balance;
}

.bg-inverse .stat__value {
	color: var(--c-accent);
}

.stat__label {
	display: block;
	margin-top: var(--sp-3xs);
	color: var(--c-text-muted);
	font-size: var(--fs-sm);
}

/* --- Button refinements ---------------------------------------------- */

/* Tighter, squarer and with the grotesque face, matching the category. */
.btn {
	font-family: var(--font-heading);
	font-weight: var(--fw-bold);
	letter-spacing: var(--ls-base);
	border-radius: var(--radius-sm);
}

.btn--ghost {
	background-color: transparent;
	border-color: currentColor;
	color: var(--c-white);
}

.btn--ghost:hover {
	background-color: var(--c-white);
	border-color: var(--c-white);
	color: var(--c-grey-900);
}

/* Paired CTAs, as used in every hero in the set. */
.btn-group {
	display: flex;
	flex-wrap: wrap;
	gap: var(--sp-xs);
}

@media (max-width: 480px) {
	.btn-group {
		flex-direction: column;
	}

	.btn-group .btn {
		width: 100%;
	}
}

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

.card {
	border-radius: var(--radius-md);
	box-shadow: none;
}

.card:hover {
	border-color: var(--c-brand);
	box-shadow: var(--shadow-md);
	transform: none;
}

.card__title {
	letter-spacing: var(--ls-heading);
}
