/* =============================================================================
   TinySpacer — assets/css/components.css
   -----------------------------------------------------------------------------
   Reusable UI component library. Builds on the design tokens defined in
   assets/css/global.css — load global.css FIRST so every --ts-* variable is
   available here.

   Scope note (intentional, to avoid regenerating existing code):
     • Buttons  -> already defined in global.css (.ts-btn, .ts-btn--secondary).
                   Reused as-is; NOT redefined here.
     • Badge/Tag -> base .ts-badge / .ts-tag live in global.css. This file adds
                   only NEW, non-colliding modifiers (.ts-badge--outline, etc.).
     • Cards    -> base .ts-card lives in global.css. The component cards below
                   (category / article / newsletter) are NEW, distinctly-named
                   classes so there is zero selector collision.

   Enqueue (add to tinyspacer_enqueue_assets() in functions.php):
     wp_enqueue_style(
       'tinyspacer-components',
       get_theme_file_uri( 'assets/css/components.css' ),
       array( 'tinyspacer-global' ),
       filemtime( get_theme_file_path( 'assets/css/components.css' ) )
     );

   Mobile-first: base rules target small screens; wider layouts are layered on
   at min-width breakpoints. No JavaScript required by any component.

   Contents:
     1. Section Heading
     2. Category Card
     3. Article Card
     4. Newsletter Card
     5. CTA Box
     6. Breadcrumb
     7. Pagination
     8. Tag / Badge (modifiers only)
   ========================================================================== */

/* =============================================================================
   1. SECTION HEADING
   -----------------------------------------------------------------------------
   Composable heading block: optional eyebrow, title, optional lead/description.
   Left-aligned by default; add .ts-section-heading--center to center it.
   ========================================================================== */

.ts-section-heading {
	display: flex;
	flex-direction: column;
	gap: var(--ts-space-2);
	max-width: 62ch;
	margin-block-end: var(--ts-space-7);
}

.ts-section-heading--center {
	align-items: center;
	margin-inline: auto;
	text-align: center;
}

.ts-section-heading__eyebrow {
	font-family: var(--ts-font-heading);
	font-size: var(--ts-text-sm);
	font-weight: var(--ts-weight-medium);
	text-transform: uppercase;
	letter-spacing: var(--ts-tracking-caps);
	color: var(--ts-color-primary);
}

.ts-section-heading__title {
	font-family: var(--ts-font-heading);
	font-size: var(--ts-text-3xl);
	font-weight: var(--ts-weight-semibold);
	line-height: var(--ts-leading-tight);
	letter-spacing: var(--ts-tracking-tight);
	color: var(--ts-color-heading);
}

.ts-section-heading__lead {
	font-size: var(--ts-text-lg);
	line-height: var(--ts-leading-snug);
	color: var(--ts-color-text-muted);
}

/* =============================================================================
   2. CATEGORY CARD
   -----------------------------------------------------------------------------
   Image tile with an overlaid label. Whole card is a single link (the <a>
   IS the card), so it is one tab stop and fully keyboard operable.
   ========================================================================== */

.ts-category-card {
	position: relative;
	display: block;
	overflow: hidden;
	aspect-ratio: 1 / 1;
	color: var(--ts-white);
	text-decoration: none;
	background-color: var(--ts-color-surface-alt);
	border-radius: var(--ts-radius-lg);
	box-shadow: var(--ts-shadow-sm);
	transition: transform var(--ts-transition-slow), box-shadow var(--ts-transition-slow);
}

.ts-category-card:hover,
.ts-category-card:focus-visible {
	transform: translateY(-4px);
	box-shadow: var(--ts-shadow-lg);
}

.ts-category-card__image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--ts-transition-slow);
}

.ts-category-card:hover .ts-category-card__image {
	transform: scale(1.05);
}

/* Gradient scrim keeps the label legible over any image. */
.ts-category-card__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-end;
	padding: var(--ts-space-4);
	background: linear-gradient(
		to top,
		color-mix(in srgb, var(--ts-ink) 60%, transparent) 0%,
		transparent 55%
	);
}

.ts-category-card__label {
	font-family: var(--ts-font-heading);
	font-size: var(--ts-text-lg);
	font-weight: var(--ts-weight-semibold);
	line-height: var(--ts-leading-tight);
}

.ts-category-card__count {
	display: block;
	margin-block-start: 2px;
	font-family: var(--ts-font-body);
	font-size: var(--ts-text-sm);
	font-weight: var(--ts-weight-regular);
	opacity: 0.85;
}

/* =============================================================================
   3. ARTICLE CARD
   -----------------------------------------------------------------------------
   Pinterest-style vertical card: portrait media, meta, title, excerpt.
   Uses the stretched-link pattern so the whole card is clickable while the
   accessible target remains the title anchor (one tab stop, real link text).
   ========================================================================== */

.ts-article-card {
	position: relative;
	display: flex;
	flex-direction: column;
	background-color: var(--ts-color-surface);
	border: 1px solid var(--ts-color-border);
	border-radius: var(--ts-radius-lg);
	box-shadow: var(--ts-shadow-sm);
	overflow: hidden;
	transition: transform var(--ts-transition-slow), box-shadow var(--ts-transition-slow), border-color var(--ts-transition-base);
}

.ts-article-card:hover,
.ts-article-card:focus-within {
	transform: translateY(-4px);
	box-shadow: var(--ts-shadow-lg);
	border-color: color-mix(in srgb, var(--ts-color-primary) 35%, var(--ts-color-border));
}

.ts-article-card__media {
	position: relative;
	overflow: hidden;
	aspect-ratio: 4 / 5;
	background-color: var(--ts-color-surface-alt);
}

.ts-article-card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--ts-transition-slow);
}

.ts-article-card:hover .ts-article-card__media img {
	transform: scale(1.04);
}

/* Floating category chip on the media. */
.ts-article-card__category {
	position: absolute;
	top: var(--ts-space-3);
	left: var(--ts-space-3);
	z-index: 2;
}

.ts-article-card__body {
	display: flex;
	flex-direction: column;
	gap: var(--ts-space-2);
	padding: var(--ts-space-5);
}

.ts-article-card__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ts-space-2);
	font-size: var(--ts-text-sm);
	color: var(--ts-color-text-subtle);
}

.ts-article-card__title {
	font-family: var(--ts-font-heading);
	font-size: var(--ts-text-lg);
	font-weight: var(--ts-weight-semibold);
	line-height: var(--ts-leading-snug);
	color: var(--ts-color-heading);
}

.ts-article-card__title a {
	color: inherit;
	text-decoration: none;
}

/* Stretched link: expand the title anchor to cover the whole card. */
.ts-article-card__title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.ts-article-card__excerpt {
	font-size: var(--ts-text-base);
	line-height: var(--ts-leading-normal);
	color: var(--ts-color-text-muted);
}

/* Keep interactive footer elements above the stretched link. */
.ts-article-card__footer {
	position: relative;
	z-index: 2;
	margin-block-start: auto;
	padding-block-start: var(--ts-space-3);
}

/* =============================================================================
   4. NEWSLETTER CARD
   -----------------------------------------------------------------------------
   Soft-tinted signup card. The form posts nowhere by itself — wire it to your
   mailing-list handler (action + hidden fields) when integrating.
   ========================================================================== */

.ts-newsletter {
	display: flex;
	flex-direction: column;
	gap: var(--ts-space-4);
	padding: clamp(var(--ts-space-6), 4vw, var(--ts-space-8));
	background-color: var(--ts-color-primary-soft);
	border: 1px solid color-mix(in srgb, var(--ts-color-primary) 22%, var(--ts-color-border));
	border-radius: var(--ts-radius-xl);
	text-align: center;
}

.ts-newsletter__title {
	font-family: var(--ts-font-heading);
	font-size: var(--ts-text-2xl);
	font-weight: var(--ts-weight-semibold);
	line-height: var(--ts-leading-tight);
	color: var(--ts-color-heading);
}

.ts-newsletter__text {
	max-width: 48ch;
	margin-inline: auto;
	color: var(--ts-color-text-muted);
}

.ts-newsletter__form {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ts-space-3);
	justify-content: center;
	width: 100%;
	max-width: 30rem;
	margin-inline: auto;
}

.ts-newsletter__field {
	flex: 1 1 14rem;
}

.ts-newsletter__note {
	font-size: var(--ts-text-sm);
	color: var(--ts-color-text-subtle);
}

/* =============================================================================
   5. CTA BOX
   -----------------------------------------------------------------------------
   High-emphasis call-to-action band. Text + action, stacked on mobile and
   row-aligned from the medium breakpoint up.
   ========================================================================== */

.ts-cta {
	display: flex;
	flex-direction: column;
	gap: var(--ts-space-5);
	padding: clamp(var(--ts-space-6), 4vw, var(--ts-space-8));
	background-color: var(--ts-color-primary);
	color: var(--ts-color-on-primary);
	border-radius: var(--ts-radius-xl);
	box-shadow: var(--ts-shadow-md);
}

.ts-cta__content {
	display: flex;
	flex-direction: column;
	gap: var(--ts-space-2);
}

.ts-cta__title {
	font-family: var(--ts-font-heading);
	font-size: var(--ts-text-2xl);
	font-weight: var(--ts-weight-semibold);
	line-height: var(--ts-leading-tight);
	color: var(--ts-color-on-primary);
}

.ts-cta__text {
	color: color-mix(in srgb, var(--ts-white) 88%, transparent);
	max-width: 52ch;
}

.ts-cta__actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ts-space-3);
}

/* Neutral (white) button reads well on the sage background. */
.ts-cta .ts-btn--neutral {
	--_btn-bg: var(--ts-white);
	--_btn-fg: var(--ts-color-primary-active);
}

@media (min-width: 48em) { /* 768px */
	.ts-cta {
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		gap: var(--ts-space-8);
	}

	.ts-cta__actions {
		flex: 0 0 auto;
	}
}

/* =============================================================================
   6. BREADCRUMB
   -----------------------------------------------------------------------------
   Semantic <nav><ol> trail. Separators are CSS pseudo-content so they are not
   announced by screen readers. Mark the current page with aria-current="page".
   ========================================================================== */

.ts-breadcrumb {
	font-size: var(--ts-text-sm);
}

.ts-breadcrumb__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--ts-space-2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.ts-breadcrumb__item {
	display: inline-flex;
	align-items: center;
	color: var(--ts-color-text-muted);
}

/* Decorative separator before every item except the first. */
.ts-breadcrumb__item + .ts-breadcrumb__item::before {
	content: "/";
	margin-inline-end: var(--ts-space-2);
	color: var(--ts-color-border-strong);
}

.ts-breadcrumb__link {
	color: var(--ts-color-text-muted);
	text-decoration: none;
	transition: color var(--ts-transition-fast);
}

.ts-breadcrumb__link:hover {
	color: var(--ts-color-primary);
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

.ts-breadcrumb__item[aria-current="page"] {
	color: var(--ts-color-heading);
	font-weight: var(--ts-weight-medium);
}

/* =============================================================================
   7. PAGINATION
   -----------------------------------------------------------------------------
   Styles the markup emitted by the_posts_pagination() (WordPress adds
   .page-numbers / .current / .dots), and also works with a hand-written
   <nav class="ts-pagination"> as shown in the demo.
   ========================================================================== */

.ts-pagination {
	margin-block-start: var(--ts-space-8);
}

.ts-pagination .nav-links,
.ts-pagination__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: var(--ts-space-2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.ts-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	height: 44px;
	padding-inline: var(--ts-space-3);
	font-family: var(--ts-font-heading);
	font-size: var(--ts-text-base);
	font-weight: var(--ts-weight-medium);
	color: var(--ts-color-text);
	text-decoration: none;
	background-color: var(--ts-color-surface);
	border: 1px solid var(--ts-color-border);
	border-radius: var(--ts-radius-md);
	transition: color var(--ts-transition-fast), background-color var(--ts-transition-fast), border-color var(--ts-transition-fast);
}

.ts-pagination a.page-numbers:hover {
	color: var(--ts-color-primary-active);
	background-color: var(--ts-color-primary-soft);
	border-color: transparent;
}

.ts-pagination .page-numbers.current {
	color: var(--ts-color-on-primary);
	background-color: var(--ts-color-primary);
	border-color: var(--ts-color-primary);
}

.ts-pagination .page-numbers.dots {
	background: none;
	border-color: transparent;
	color: var(--ts-color-text-subtle);
}

/* Prev/next keep a comfortable label + arrow. */
.ts-pagination .page-numbers.prev,
.ts-pagination .page-numbers.next {
	gap: var(--ts-space-1);
}

/* =============================================================================
   8. TAG / BADGE (modifiers only — base classes live in global.css)
   ========================================================================== */

/* Outlined badge for low-emphasis contexts. */
.ts-badge--outline {
	color: var(--ts-color-primary-active);
	background-color: transparent;
	border: 1px solid color-mix(in srgb, var(--ts-color-primary) 45%, var(--ts-color-border));
}

/* Solid badge for high emphasis (e.g. "New", "Featured"). */
.ts-badge--solid {
	color: var(--ts-color-on-primary);
	background-color: var(--ts-color-primary);
}

/* Active/selected tag state to pair with the base .ts-tag. */
.ts-tag--active {
	color: var(--ts-color-on-primary);
	background-color: var(--ts-color-primary);
	border-color: var(--ts-color-primary);
}

.ts-tag--active:hover {
	color: var(--ts-color-on-primary);
	background-color: var(--ts-color-primary-hover);
	border-color: var(--ts-color-primary-hover);
}

/* =============================================================================
   Reduced motion: neutralize component transitions/transforms
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
	.ts-category-card,
	.ts-category-card__image,
	.ts-article-card,
	.ts-article-card__media img {
		transition-duration: 0.001ms !important;
	}

	.ts-category-card:hover,
	.ts-article-card:hover,
	.ts-category-card:hover .ts-category-card__image,
	.ts-article-card:hover .ts-article-card__media img {
		transform: none !important;
	}
}
