/**
 * TechInnovationPro global stylesheet.
 *
 * Only layout primitives that theme.json can't express live here.
 * Header and footer styles are in site-header.css and site-footer.css.
 * Colors, type and spacing always come from theme.json presets.
 * Breakpoints: 600px (tablet), 1024px (desktop), 1280px (wide).
 * See DESIGN_SYSTEM.md.
 */

/* ---------------------------------------------------------------------
 * 1. Responsive gutters (UI §A1): 16px mobile, 24px tablet, 32px desktop.
 * ------------------------------------------------------------------- */
:root {
	--tip-gutter: 16px;
}

@media (min-width: 600px) {

	:root {
		--tip-gutter: 24px;
	}
}

@media (min-width: 1024px) {

	:root {
		--tip-gutter: 32px;
	}
}

/* ---------------------------------------------------------------------
 * 2. Accessibility foundations (UI §A12, §C2).
 * ------------------------------------------------------------------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--wp--preset--color--brand);
	outline-offset: var(--wp--custom--focus--offset);
}

:where(.wp-element-button, .wp-block-button__link, .wp-block-search__button) {
	min-height: var(--wp--custom--touch-target);
}

@media (prefers-reduced-motion: reduce) {

	*,
	*::before,
	*::after {
		scroll-behavior: auto !important; /* Utility override: honor reduced motion everywhere. */
		transition-duration: 0.01ms !important; /* Utility override. */
		animation-duration: 0.01ms !important; /* Utility override. */
	}
}

/* ---------------------------------------------------------------------
 * 3. Layout primitives (UI §A2).
 *    .tip-layout-sidebar: content (8 cols) + sidebar (4 cols) from 1024px;
 *    below that the sidebar follows the content in source order.
 * ------------------------------------------------------------------- */
.tip-layout-sidebar {
	display: grid;
	gap: var(--wp--preset--spacing--7);
}

@media (min-width: 1024px) {

	.tip-layout-sidebar {
		grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
		gap: var(--wp--preset--spacing--6);
	}

	.tip-layout-sidebar > .tip-sidebar__sticky {
		position: sticky;
		top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--wp--preset--spacing--8));
		align-self: start;
	}
}

/* Horizontal scroll container for wide tables (A11Y-05, UI §B5). */
.tip-scroll-region {
	overflow-x: auto;
	overscroll-behavior-x: contain;
}

/* ---------------------------------------------------------------------
 * 4. Cards (UI §A6).
 *    "Card" and "Label" block styles: the same declarations theme.json
 *    section styles produced, printed once instead of per block instance
 *    (inc/assets.php). Low specificity (:root :where) as before; this file
 *    loads after the global styles, so the cascade order is unchanged.
 * ------------------------------------------------------------------- */
:root :where(.wp-block-group.is-style-card) {
	color: var(--wp--preset--color--text);
	background-color: var(--wp--preset--color--surface);
	border-radius: var(--wp--custom--radius--card);
	box-shadow: var(--wp--preset--shadow--card);
}

:root :where(.wp-block-group.is-style-card.wp-block-group-is-layout-flow, .wp-block-group.is-style-card.wp-block-group-is-layout-constrained) > * {
	margin-block-start: 0;
	margin-block-end: 0;
}

:root :where(.wp-block-group.is-style-card.wp-block-group-is-layout-flex, .wp-block-group.is-style-card.wp-block-group-is-layout-grid) {
	gap: 0;
}

:root :where(.wp-block-post-terms.is-style-label) {
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--label);
	font-weight: 700;
	line-height: var(--wp--custom--line-height--tight);
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

:root :where(.is-style-label a:where(:not(.wp-element-button))) {
	color: var(--wp--preset--color--brand);
	text-decoration: none;
}

:root :where(.is-style-label a:where(:not(.wp-element-button)):hover) {
	text-decoration: underline;
}

.is-style-card {
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.is-style-card .wp-block-post-featured-image {
	margin: 0;
}

.tip-card__body {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--2);
	padding: var(--wp--preset--spacing--4);
}

.tip-card__body > * {
	margin-block: 0;
}

.tip-card__meta {
	gap: var(--wp--preset--spacing--2);
	color: var(--wp--preset--color--text-muted);
}

/* ---------------------------------------------------------------------
 * 5. Section header (UI §A7): title left, "See all" right.
 *    On mobile the link moves under the section (handled by wrapping).
 * ------------------------------------------------------------------- */
.tip-section-header {
	padding-block-start: var(--wp--preset--spacing--3);
	border-block-start: 3px solid var(--wp--preset--color--text);
	row-gap: var(--wp--preset--spacing--2);
}

.tip-section-header h2 {
	font-size: clamp(1.625rem, 1.2rem + 1.4vw, 2.25rem);
	line-height: 1.08;
}

/* Small pink label above the section title ("The latest", "AI desk"…). */
.tip-section-header__titles > * {
	margin-block: 0;
}

.tip-section-header__eyebrow {
	margin-block-end: var(--wp--preset--spacing--2) !important; /* Keeps the gap inside the flex title group. */
	color: var(--wp--preset--color--signature);
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--label);
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

/* Pink on white is for decoration only below 18px: darken it for AA (4.5:1). */
:where(body) .tip-section-header__eyebrow {
	color: #c4114f;
}

.tip-section-header > * {
	margin-block: 0;
}

/* ---------------------------------------------------------------------
 * 6. Post list layouts: block styles on core/post-template
 *    (registered in inc/homepage.php; chosen in the Site Editor).
 * ------------------------------------------------------------------- */
.wp-block-post-template[class*="is-style-tip-"] {
	display: grid;
	gap: var(--wp--preset--spacing--5);
}

.wp-block-post-template[class*="is-style-tip-"] > li {
	margin-block: 0;
}

/* Grid: 1 column on mobile, 2 on tablet, --tip-grid-cols (default 4) on desktop. */
.wp-block-post-template.is-style-tip-grid {
	--tip-grid-cols: 4;
	grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 600px) {

	.wp-block-post-template.is-style-tip-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 1024px) {

	.wp-block-post-template.is-style-tip-grid {
		grid-template-columns: repeat(var(--tip-grid-cols), minmax(0, 1fr));
	}
}

/* A single-item grid (e.g. the lead story) always spans the full width. */
.wp-block-post-template.is-style-tip-grid:has(> li:only-child) {
	grid-template-columns: minmax(0, 1fr);
}

/* List: stacked horizontal cards. */
.wp-block-post-template.is-style-tip-list {
	gap: var(--wp--preset--spacing--4);
}

/* Lead + list: first story large, the rest as a list beside it (desktop) or below it. */
@media (min-width: 1024px) {

	.wp-block-post-template.is-style-tip-lead {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		align-items: start;
	}

	.wp-block-post-template.is-style-tip-lead > li:first-child {
		grid-row: span 3;
	}

	/* Only one story: no empty list column. */
	.wp-block-post-template.is-style-tip-lead:has(> li:only-child) {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Numbered list (C5): rank number + headline card. */
.wp-block-post-template.is-style-tip-numbered {
	gap: var(--wp--preset--spacing--4);
	counter-reset: tip-rank;
}

.wp-block-post-template.is-style-tip-numbered > li {
	display: grid;
	grid-template-columns: 3rem minmax(0, 1fr);
	align-items: start;
	counter-increment: tip-rank;
}

.wp-block-post-template.is-style-tip-numbered > li::before {
	content: counter(tip-rank, decimal-leading-zero);
	color: var(--wp--preset--color--brand);
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--heading-3);
	font-weight: 800;
	line-height: 1;
}


/* ---------------------------------------------------------------------
 * 7. Card variants (UI §A6). The base card is section 4.
 * ------------------------------------------------------------------- */
.tip-card__labels {
	gap: var(--wp--preset--spacing--2) var(--wp--preset--spacing--3);
}

.tip-card__labels:not(:has(a)) {
	display: none;
}

.tip-card__excerpt {
	display: -webkit-box;
	overflow: hidden;
	color: var(--wp--preset--color--text-muted);
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.tip-card__excerpt p {
	margin: 0;
}

.tip-card__ribbon {
	color: #c4114f;
	font-size: var(--wp--preset--font-size--label);
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

/* Hero (C1): large headline under the image. */
.tip-card--hero .tip-card__body {
	gap: var(--wp--preset--spacing--3);
	padding: var(--wp--preset--spacing--5);
}

/* Review (C6): square product image on a light background. */
.tip-card--review .wp-block-post-featured-image {
	background-color: var(--wp--preset--color--surface-alt);
}

/* Headline cards (C4/C5) have no image or card surface. */
.tip-card--headline {
	background-color: transparent;
	box-shadow: none;
}

.tip-card--headline .tip-card__body {
	padding: 0;
}

/*
 * Horizontal card (C3): any image card inside a List layout or after the
 * lead story in a Lead + list layout. Excerpts are hidden in this form.
 */
:is(.is-style-tip-list > li, .is-style-tip-lead > li:not(:first-child)) .tip-card:not(.tip-card--headline) {
	flex-direction: row;
	align-items: flex-start;
}

:is(.is-style-tip-list > li, .is-style-tip-lead > li:not(:first-child)) .tip-card .wp-block-post-featured-image {
	flex: 0 0 clamp(96px, 38%, 160px);
}

:is(.is-style-tip-list > li, .is-style-tip-lead > li:not(:first-child)) .tip-card .tip-card__body {
	padding: var(--wp--preset--spacing--3);
}

:is(.is-style-tip-list > li, .is-style-tip-lead > li:not(:first-child)) .tip-card__excerpt {
	display: none;
}

:is(.is-style-tip-list > li, .is-style-tip-lead > li:not(:first-child)) .wp-block-post-title {
	font-size: var(--wp--preset--font-size--card-title-sm);
}

/* Mobile: card excerpts hidden except the hero deck (UI §B1.4). */
@media (max-width: 599.98px) {

	.tip-card:not(.tip-card--hero) .tip-card__excerpt {
		display: none;
	}
}

/* Empty-state message in a list. */
.tip-empty {
	padding: var(--wp--preset--spacing--5);
	border: 1px dashed var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--card);
	color: var(--wp--preset--color--text-muted);
	text-align: center;
}

/* ---------------------------------------------------------------------
 * 8. Shared editorial parts: breadcrumbs, author photo, sidebar titles,
 *    back-to-top and the reading progress bar (UI §B2–B7).
 * ------------------------------------------------------------------- */
.tip-breadcrumbs__list {
	gap: var(--wp--preset--spacing--1) var(--wp--preset--spacing--2);
	font-size: var(--wp--preset--font-size--meta);
	color: var(--wp--preset--color--text-muted);
}

.tip-breadcrumbs__item + .tip-breadcrumbs__item::before {
	content: "›";
	margin-inline-end: var(--wp--preset--spacing--2);
	color: var(--wp--preset--color--text-muted);
}

.tip-breadcrumbs__item a {
	color: inherit;
}

/* Mobile: Home › … › current (UI §C3). */
@media (max-width: 599.98px) {

	.tip-breadcrumbs__item:not(:first-child):not(:last-child) {
		display: none;
	}

	.tip-breadcrumbs__item:last-child:not(:nth-child(-n+2))::before {
		content: "› … ›";
	}
}

/* ---------------------------------------------------------------------
 * 8b. Chips: subtopics, related topics, filters, expertise (UI §B2, §B6).
 * ------------------------------------------------------------------- */
.tip-chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--2);
	padding: 0;
	list-style: none;
	font-size: var(--wp--preset--font-size--meta);
}

.tip-chips a {
	display: inline-flex;
	align-items: center;
	min-height: var(--wp--custom--touch-target);
	padding-inline: var(--wp--preset--spacing--4);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--button);
	color: var(--wp--preset--color--text);
	text-decoration: none;
}

.tip-chips a:hover {
	text-decoration: underline;
}

.tip-chips a[aria-current] {
	border-color: var(--wp--preset--color--brand);
	background-color: var(--wp--preset--color--brand);
	color: var(--wp--preset--color--bg);
}

.tip-author-photo--initials {
	background-color: var(--wp--preset--color--surface-alt);
	color: var(--wp--preset--color--text);
	border-radius: 50%;
}

.tip-sidebar-title {
	margin-block: 0 var(--wp--preset--spacing--4);
	font-size: var(--wp--preset--font-size--card-title);
}

/* Back to top: a plain link at the end of the page; floats once the reader has scrolled (reading.js). */
.tip-back-to-top {
	margin-block-start: var(--wp--preset--spacing--6);
	font-size: var(--wp--preset--font-size--body-sm);
	text-align: end;
}

.tip-js .tip-back-to-top {
	position: fixed;
	inset-inline-end: var(--tip-gutter);
	inset-block-end: var(--wp--preset--spacing--5);
	z-index: 90;
	margin: 0;
	visibility: hidden;
	opacity: 0;
}

/* Fade in only: a fade-out transition made the button flash mid-screen
 * while the page loaded (when .tip-js is added). */
.tip-js .tip-back-to-top.is-visible {
	visibility: visible;
	opacity: 1;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

.tip-js .tip-back-to-top a {
	display: inline-flex;
	align-items: center;
	gap: var(--wp--preset--spacing--2);
	min-height: var(--wp--custom--touch-target);
	padding-inline: var(--wp--preset--spacing--4);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--button);
	background-color: var(--wp--preset--color--bg);
	box-shadow: var(--wp--preset--shadow--card);
	color: var(--wp--preset--color--text);
	text-decoration: none;
}

/* Reading progress: a thin bar at the top of the window (decorative). */
.tip-reading-progress {
	position: fixed;
	inset-block-start: var(--wp-admin--admin-bar--height, 0);
	inset-inline: 0;
	z-index: 101;
	height: 3px;
	margin: 0;
	background-color: var(--wp--preset--color--brand);
	transform: scaleX(var(--tip-progress, 0));
	transform-origin: left center;
	pointer-events: none;
}

/* Page containers for templates whose main element has no constrained layout. */
.tip-article,
.tip-archive {
	box-sizing: border-box;
	width: 100%;
	max-width: calc(var(--wp--style--global--wide-size) + 2 * var(--tip-gutter));
	margin-inline: auto;
	padding: var(--wp--preset--spacing--6) var(--tip-gutter) var(--wp--preset--spacing--8);
}

