/*
 * Component styles: cards, hero extras, search panel, newsletter,
 * single/page layouts, topics grid, theme toggle icon states.
 * Depends on custom properties defined in style.css (loaded first).
 */

/* =========================================================
   Theme toggle icon swap — driven by [data-theme] on <body>,
   set in header.php.
   ========================================================= */
.tpm-icon-sun { display: none; }
.tpm-icon-moon { display: block; }
[data-theme="dark"] .tpm-icon-sun { display: block; }
[data-theme="dark"] .tpm-icon-moon { display: none; }

/* =========================================================
   Search panel — #tpm-search-panel toggled via [hidden] by main.js
   ========================================================= */
.tpm-search-panel {
	border-bottom: 1px solid var(--tpm-color-border);
	background: var(--tpm-color-bg);
	padding: var(--tpm-space-3) 0;
}
.tpm-search-panel[hidden] { display: none; }

.tpm-search-input {
	width: 100%;
	padding: var(--tpm-space-2) var(--tpm-space-3);
	border: 1px solid var(--tpm-color-border);
	border-radius: var(--tpm-radius);
	background: var(--tpm-color-surface);
	color: var(--tpm-color-text);
	font-size: 1rem;
}

.tpm-search-results {
	margin-top: var(--tpm-space-2);
	max-height: min(320px, 60vh);
	overflow-y: auto;
}
.tpm-search-results:empty { display: none; }

.tpm-search-result {
	display: block;
	padding: var(--tpm-space-2) var(--tpm-space-3);
	border-radius: var(--tpm-radius);
	color: var(--tpm-color-text);
}

.tpm-search-result:hover, .tpm-search-result:focus {
	background: var(--tpm-color-bg-alt);
	text-decoration: none;
}

.tpm-search-result-type {
	display: inline-block;
	font-size: 0.75rem;
	text-transform: uppercase;
	color: var(--tpm-color-text-muted);
	margin-left: var(--tpm-space-2);
}

/* =========================================================
   Card grid — .tpm-card used by template-parts/content.php
   and woocommerce/content-product.php
   ========================================================= */
.tpm-card-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--tpm-space-4);
	list-style: none;
	margin: var(--tpm-space-5) 0;
	padding: 0;
}

.tpm-card {
	background: var(--tpm-color-surface);
	border: 1px solid var(--tpm-color-border);
	border-radius: var(--tpm-radius-lg);
	overflow: hidden;
	box-shadow: var(--tpm-shadow);
	display: flex;
	flex-direction: column;
}

/*
 * No-crop thumbnails (P1.21 / Issue 6): object-fit:contain (was cover)
 * shows the complete image instead of cropping it to fill the box, and
 * the background fill below gives any resulting letterboxed space (when
 * the image's aspect ratio doesn't exactly match the 3:2 box) a clean,
 * intentional-looking neutral fill rather than empty/transparent space.
 * Applies to both blog cards (template-parts/content.php) and WooCommerce
 * product cards (woocommerce/content-product.php), which share this same
 * .tpm-card-thumb markup. Paired with the corresponding image-size crop
 * flags now set to false in inc/setup.php (techpromaster-card) and
 * inc/customizer/settings.php (techpromaster_wc_catalog_crop default) —
 * object-fit alone can't restore image data a hard crop already discarded
 * at upload time, so both the CSS and the source-image generation needed
 * to change together.
 */
.tpm-card-thumb { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: var(--tpm-color-bg-alt); }
.tpm-card-thumb img { width: 100%; height: 100%; object-fit: contain; }
.tpm-card-body { padding: var(--tpm-space-3); display: flex; flex-direction: column; gap: var(--tpm-space-2); flex: 1; }

.tpm-card-badge {
	align-self: flex-start;
	background: var(--tpm-color-bg-alt);
	color: var(--tpm-color-primary);
	font-size: 0.75rem;
	font-weight: 700;
	padding: 2px var(--tpm-space-2);
	border-radius: 999px;
}
/*
 * Dark-mode contrast fix: --tpm-color-primary (#2563eb) as badge text on
 * --tpm-color-bg-alt in dark mode (#111827) measures ~3.43:1 — below WCAG
 * AA's 4.5:1 for this element's own text at 0.75rem/700. Same
 * --tpm-color-primary-light substitution already established and measured
 * at ~7.02:1 for the generic-link fix (style.css, ":where([data-theme="dark"])
 * a") and repeated for several other primary-colored components there —
 * this badge was using the same failing token but had never received the
 * same treatment.
 */
[data-theme="dark"] .tpm-card-badge {
	color: var(--tpm-color-primary-light);
}
.tpm-badge-sale { background: var(--tpm-color-danger); color: #fff; position: absolute; top: var(--tpm-space-2); left: var(--tpm-space-2); }
.tpm-card-title { font-size: 1.05rem; margin: 0; }
.tpm-card-title a { color: var(--tpm-color-text); }

.tpm-card-meta {
	display: flex;
	align-items: center;
	gap: var(--tpm-space-2);
	margin-top: var(--tpm-space-2);
	font-size: 0.8125rem;
	color: var(--tpm-color-text-muted);
}
.tpm-card-author { display: flex; align-items: center; gap: var(--tpm-space-1); }
.tpm-card-author img { border-radius: 50%; }
.tpm-card-price { font-weight: 700; color: var(--tpm-color-text); }

/* =========================================================
   Topics grid
   ========================================================= */
.tpm-topics { padding: var(--tpm-space-6) 0; }

.tpm-topics-grid {
	display: flex;
	flex-wrap: wrap;
	gap: var(--tpm-space-2);
	margin-top: var(--tpm-space-3);
}

.tpm-topic-pill {
	padding: var(--tpm-space-2) var(--tpm-space-4);
	border: 1px solid var(--tpm-color-border);
	border-radius: 999px;
	color: var(--tpm-color-text);
}

.tpm-topic-pill:hover, .tpm-topic-pill:focus {
	border-color: var(--tpm-color-primary);
	color: var(--tpm-color-primary);
	text-decoration: none;
}

/* =========================================================
   Featured Articles Ticker (P1.21 / Issue 2)
   Server-rendered <ul>, animated with a pure-CSS seamless marquee:
   the track's content is rendered twice by front-page.php, and
   translateX(-50%) lands exactly on the start of the duplicate copy,
   so the loop has no visible seam. --tpm-ticker-duration is set
   inline per-instance from the admin-controlled scroll-speed setting.
   ========================================================= */
.tpm-ticker {
	border-top: 1px solid var(--tpm-color-border);
	border-bottom: 1px solid var(--tpm-color-border);
	background: var(--tpm-color-bg-alt);
	padding: var(--tpm-space-3) 0;
	overflow: hidden;
}

.tpm-ticker-heading {
	font-size: 0.8125rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--tpm-color-text-muted);
	margin: 0 0 var(--tpm-space-2);
}

.tpm-ticker-viewport {
	overflow: hidden;
	width: 100%;

	/* Fade the edges so the track visibly starts/ends mid-scroll rather than with a hard clip line — a small, standard marquee polish detail. */
	-webkit-mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent);
	mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent);
}

.tpm-ticker-track {
	display: flex;
	align-items: center;
	gap: var(--tpm-space-6);
	list-style: none;
	margin: 0;
	padding: 0 var(--tpm-space-4);
	width: max-content;
	animation: tpm-ticker-scroll var(--tpm-ticker-duration, 40s) linear infinite;
}

/* Pause on hover (spec requirement) and on keyboard focus (so a keyboard user tabbing into a link isn't fighting a moving target). */
.tpm-ticker-viewport:hover .tpm-ticker-track,
.tpm-ticker-track:focus-within {
	animation-play-state: paused;
}

@keyframes tpm-ticker-scroll {
	from { transform: translateX(0); }
	to { transform: translateX(-50%); }
}

.tpm-ticker-item {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: var(--tpm-space-2);
	white-space: nowrap;
}

.tpm-ticker-item a {
	color: var(--tpm-color-text);
	font-weight: 600;
	font-size: 0.9375rem;
}

.tpm-ticker-item a:hover,
.tpm-ticker-item a:focus-visible {
	color: var(--tpm-color-primary);
	text-decoration: none;
}

.tpm-ticker-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--tpm-color-primary);
	flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
	.tpm-ticker-track { animation: none; }
}

@media (max-width: 480px) {
	.tpm-ticker-track { gap: var(--tpm-space-4); }
	.tpm-ticker-item a { font-size: 0.875rem; }
}

/* =========================================================
   Homepage section heading row (P1.21 / Issues 3 & 4)
   Shared by the menu-driven category sections and the WooCommerce
   homepage integration sections — heading + optional product-count
   badge on the left, a "view all" link on the right.
   ========================================================= */
.tpm-section-heading {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: var(--tpm-space-2) var(--tpm-space-3);
}
.tpm-section-heading h2 { margin: 0; }

.tpm-section-link {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin-left: auto;
	font-weight: 600;
	font-size: 0.9375rem;
	color: var(--tpm-color-primary);
	white-space: nowrap;
}
/*
 * Dark-mode contrast fix: same --tpm-color-primary token, same measured
 * ~3.45:1 failure against the dark background as the generic-link fix in
 * style.css (":where([data-theme=\"dark\"]) a") — but that fallback rule
 * uses :where() specifically so it doesn't touch component classes with
 * their own explicit color (this one), so it was never actually reaching
 * this element. Directly affects every "View all" link in every homepage
 * section (Prompt Engineering / Guides & Tutorials / Reviews / Tech News,
 * the legacy per-menu-category sections, and the WooCommerce homepage
 * section), so this was worth fixing rather than leaving for a future pass.
 */
[data-theme="dark"] .tpm-section-link {
	color: var(--tpm-color-primary-light);
}

.tpm-section-link:hover,
.tpm-section-link:focus-visible {
	text-decoration: underline;
}
.tpm-section-link .tpm-icon { width: 16px; height: 16px; }

/* Product download-count text on homepage WooCommerce cards (Issue 4/5). */
.tpm-card-downloads {
	font-size: 0.8125rem;
	color: var(--tpm-color-text-muted);
}

/* =========================================================
   Newsletter
   ========================================================= */
.tpm-newsletter {
	background: var(--tpm-color-bg-alt);
	padding: var(--tpm-space-6) 0;
	text-align: center;
}

.tpm-newsletter-form {
	display: flex;
	gap: var(--tpm-space-2);
	justify-content: center;
	max-width: 480px;
	margin: var(--tpm-space-3) auto 0;
	flex-wrap: wrap;
}

.tpm-newsletter-form input[type="email"] {
	flex: 1;
	min-width: 220px;
	padding: var(--tpm-space-2) var(--tpm-space-3);
	border: 1px solid var(--tpm-color-border);
	border-radius: var(--tpm-radius);
}
.tpm-newsletter-status { width: 100%; font-size: 0.875rem; margin-top: var(--tpm-space-2); }

/*
 * Hardcoded rather than var(--tpm-color-success): the raw brand green
 * (#16a34a) measures 3.15:1 against this section's --tpm-color-bg-alt in
 * light mode — a real WCAG AA failure for 14px text (needs 4.5:1),
 * confirmed via the WCAG relative-luminance formula. #166534 (light mode)
 * / #22c55e (dark mode) both clear 4.5:1 against their respective
 * backgrounds while staying in the same green family — the same
 * per-theme-shade approach already used for the status badges in
 * assets/css/woocommerce.css.
 */
.tpm-newsletter-status.is-success { color: #166534; }
[data-theme="dark"] .tpm-newsletter-status.is-success { color: #22c55e; }
.tpm-newsletter-status.is-error { color: var(--tpm-color-danger); }

/* =========================================================
   Single post / Page layout
   ========================================================= */
.tpm-single-layout {
	padding: var(--tpm-space-6) 0;
}

/*
 * .tpm-single-row holds ONLY the article and sidebar (single.php) — it is
 * deliberately a separate grid from comments_template()'s output, which
 * is a plain full-width block sibling below it. Keeping comments outside
 * this grid is what makes the sticky sidebar (below) stop correctly at
 * the bottom of the article instead of overlapping the comments section:
 * when comments used to be a third item in this same grid (placed via
 * grid-column: 1 / -1), the sticky sidebar's containing block extended
 * into that shared grid area and it kept sticking past the row boundary,
 * visually overlapping the top of the comments section on the way down —
 * confirmed with real-browser scroll testing, not just reasoned about.
 */
.tpm-single-row {
	display: grid;
	grid-template-columns: 1fr 300px;
	gap: var(--tpm-space-5);
	align-items: start;
}
.tpm-single-article { grid-column: 1; }
.tpm-single-sidebar {
	grid-column: 2;
	position: sticky;
	/* Sits below the sticky site header (--tpm-header-height) with one
	   spacing unit of breathing room, same offset pattern used elsewhere
	   in this file (see the mobile menu's `top: var(--tpm-header-height)`
	   a few lines up). Scoped to .tpm-single-row (above), so it naturally
	   stops sticking once the row (i.e. the article) ends — no JS, no
	   max-height/overflow trick needed. Verified in headless Chromium:
	   sticks smoothly with no jump, and detaches cleanly with no overlap.
	   position: sticky is supported by all evergreen Chrome/Firefox/
	   Safari/Edge releases without a vendor prefix. */
	top: calc(var(--tpm-header-height) + var(--tpm-space-5));
}
.tpm-single-meta { display: flex; align-items: center; gap: var(--tpm-space-2); color: var(--tpm-color-text-muted); font-size: 0.875rem; margin: var(--tpm-space-2) 0 var(--tpm-space-4); }
.tpm-single-thumb { margin-bottom: var(--tpm-space-4); border-radius: var(--tpm-radius-lg); overflow: hidden; }
.tpm-single-content { max-width: 720px; line-height: 1.75; }
.tpm-single-content img { border-radius: var(--tpm-radius); }

.tpm-page-hero { aspect-ratio: 16 / 6; overflow: hidden; }
.tpm-page-hero img { width: 100%; height: 100%; object-fit: cover; }
.tpm-page-header { padding: var(--tpm-space-5) 0 var(--tpm-space-3); }

/* =========================================================
   Comments (comments.php, techpromaster_comment_callback())
   ========================================================= */
.tpm-comments { margin-top: var(--tpm-space-7); padding-top: var(--tpm-space-6); border-top: 1px solid var(--tpm-color-border); max-width: 720px; }
.tpm-comments-title { margin: 0 0 var(--tpm-space-5); }

.tpm-comment-list,
.tpm-comment-list ul.children {
	list-style: none;
	margin: 0;
	padding: 0;
}

.tpm-comment-list > li + li,
.tpm-comment-list ul.children > li + li {
	margin-top: var(--tpm-space-4);
}

/* Threaded replies indent, with a rail so nesting stays legible without endless horizontal creep on mobile. */
.tpm-comment-list ul.children {
	margin: var(--tpm-space-4) 0 0 var(--tpm-space-5);
	padding-left: var(--tpm-space-4);
	border-left: 2px solid var(--tpm-color-border);
}

.tpm-comment-body { display: flex; flex-direction: column; gap: var(--tpm-space-2); }
.tpm-comment-meta { display: flex; align-items: flex-start; gap: var(--tpm-space-3); }
.tpm-comment-avatar { border-radius: 50%; flex-shrink: 0; width: 44px; height: 44px; }
.tpm-comment-author-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--tpm-space-2); }
.tpm-comment-author { font-weight: 700; color: var(--tpm-color-text); }
.tpm-comment-date { font-size: 0.8125rem; color: var(--tpm-color-text-muted); text-decoration: none; }
.tpm-comment-date:hover { color: var(--tpm-color-primary); }

.tpm-comment-awaiting-moderation {
	font-size: 0.8125rem;
	font-style: italic;
	color: var(--tpm-color-text-muted);
	background: var(--tpm-color-bg-alt);
	padding: 2px var(--tpm-space-2);
	border-radius: var(--tpm-radius);
}

.tpm-comment-content { line-height: 1.7; color: var(--tpm-color-text); }
.tpm-comment-content p:last-child { margin-bottom: 0; }

.tpm-comment-reply { margin-top: var(--tpm-space-1); }

.tpm-comment-reply a.comment-reply-link,
.tpm-comment-reply a.comment-reply-login {
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--tpm-color-primary);
	text-decoration: none;
}

.tpm-comment-reply a.comment-reply-link:hover,
.tpm-comment-reply a.comment-reply-login:hover { text-decoration: underline; }

.tpm-comments-pagination { display: flex; justify-content: space-between; gap: var(--tpm-space-3); margin-top: var(--tpm-space-5); }
.tpm-comments-pagination a { color: var(--tpm-color-primary); text-decoration: none; font-weight: 600; }
.tpm-comments-pagination a:hover { text-decoration: underline; }
.tpm-comments-closed { color: var(--tpm-color-text-muted); font-style: italic; margin-top: var(--tpm-space-5); }

/* Comment form — reuses .tpm-btn-primary (style.css) for the submit button via class_submit; fields below are core's own default markup, themed generically so a plugin/filter that adds extra fields still inherits consistent styling. */
.tpm-comment-form { margin-top: var(--tpm-space-6); }
.tpm-comment-form .comment-reply-title { margin: 0 0 var(--tpm-space-4); }
.tpm-comment-form .comment-reply-title small a { font-size: 0.8125rem; font-weight: 500; margin-left: var(--tpm-space-2); }
.tpm-comment-form p { margin: 0 0 var(--tpm-space-4); }
.tpm-comment-form label { display: block; font-weight: 600; margin-bottom: var(--tpm-space-1); font-size: 0.9375rem; }
.tpm-comment-form .required { color: var(--tpm-color-danger); }

.tpm-comment-textarea,
.tpm-comment-form input[type="text"],
.tpm-comment-form input[type="email"],
.tpm-comment-form input[type="url"] {
	width: 100%;
	padding: var(--tpm-space-3);
	border: 1px solid var(--tpm-color-border);
	border-radius: var(--tpm-radius);
	background: var(--tpm-color-bg);
	color: var(--tpm-color-text);
	font-family: inherit;
	font-size: 1rem;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tpm-comment-textarea { resize: vertical; }

.tpm-comment-textarea:focus,
.tpm-comment-form input[type="text"]:focus,
.tpm-comment-form input[type="email"]:focus,
.tpm-comment-form input[type="url"]:focus {
	outline: none;
	border-color: var(--tpm-color-primary);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.tpm-comment-form .comment-form-cookies-consent { display: flex; align-items: center; gap: var(--tpm-space-2); }
.tpm-comment-form .comment-form-cookies-consent label { margin: 0; font-weight: 400; }

.tpm-comment-form .comment-notes,
.tpm-comment-form .logged-in-as { color: var(--tpm-color-text-muted); font-size: 0.875rem; }
.tpm-comment-form .logged-in-as a { color: var(--tpm-color-primary); }

/* comment_form()'s built-in must_log_in / comment_notes notice when a context (e.g. product reviews, via techpromaster_require_login_for_reviews()) requires an account. */
#respond .must-log-in,
#respond .comment-form-must-log-in {
	color: var(--tpm-color-text-muted);
}

#respond .must-log-in a,
#respond .comment-form-must-log-in a { color: var(--tpm-color-primary); font-weight: 600; }

@media (max-width: 600px) {
	.tpm-comment-list ul.children { margin-left: var(--tpm-space-3); padding-left: var(--tpm-space-3); }
	.tpm-comment-avatar { width: 36px; height: 36px; }
	.tpm-comments-pagination { flex-direction: column; gap: var(--tpm-space-2); }
}

/* =========================================================
   Archive / search / 404
   ========================================================= */
.tpm-archive-header { padding: var(--tpm-space-6) 0 var(--tpm-space-3); }
.tpm-no-results { text-align: center; padding: var(--tpm-space-7) 0; }
.tpm-social-links { list-style: none; display: flex; gap: var(--tpm-space-3); padding: 0; margin: var(--tpm-space-3) 0 0; }

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

@media (max-width: 782px) {
	.tpm-card-grid { grid-template-columns: 1fr; }
	.tpm-single-row { grid-template-columns: 1fr; }
	.tpm-single-sidebar {
		grid-column: 1;
		/* Sidebar stacks full-width below the article on mobile/tablet —
		   sticky only makes sense in the two-column desktop layout, so
		   it's switched off here to avoid the sidebar pinning itself
		   over article content on narrow screens. */
		position: static;
		max-height: none;
	}
}

@media (max-width: 480px) {
	.tpm-card-grid { gap: var(--tpm-space-3); margin: var(--tpm-space-4) 0; }
}

/* =========================================================
   Layout-utility selectors — small display/spacing rules
   consumed directly by template class names (index.php,
   home.php, archive.php, search.php, 404.php, single.php,
   the WooCommerce templates, and template-parts/content.php).
   ========================================================= */
.tpm-icon { width: 20px; height: 20px; }

.tpm-main { display: block; }
.tpm-single, .tpm-archive, .tpm-search, .tpm-blog-index, .tpm-page, .tpm-404, .tpm-featured { display: block; }
.tpm-shop-main { display: block; }

.tpm-archive-description { color: var(--tpm-color-text-muted); margin-top: var(--tpm-space-2); }

.tpm-card-date, .tpm-card-reading-time {
	color: var(--tpm-color-text-muted);
	font-size: 0.8125rem;
}

.tpm-single-header { margin-bottom: var(--tpm-space-4); }

.tpm-page-links { margin-top: var(--tpm-space-4); }

.tpm-menu-item--has-children { position: relative; }

/* =========================================================
   MEGA MENU (nav redesign)
   Emitted by TechProMaster_Nav_Walker (inc/walkers.php):
   .tpm-mega-panel > .tpm-mega-panel-inner > ul.tpm-mega-grid
     > li.tpm-mega-col > a.tpm-mega-col-head (+ optional
       ul.tpm-mega-col-links > li.tpm-mega-link-item > a.tpm-mega-link)
   ========================================================= */

/*
 * Desktop anchoring (P1.19): previously position:fixed; left:50% centered
 * the panel on the *viewport*, regardless of which top-level item triggered
 * it — an item near the header's left or right edge opened a panel that
 * visually "jumped" toward the screen's center instead of dropping beneath
 * the link. .tpm-menu-item--has-children already establishes
 * position:relative (above), so the panel is now position:absolute against
 * its own trigger; main.js computes and sets an inline `left` on open,
 * clamped to stay within the viewport, then clears it on close. left:0
 * below is a same-as-tablet static fallback for the instant before JS
 * runs — harmless, since the panel is invisible (opacity:0,
 * pointer-events:none) until .is-open regardless.
 */
.tpm-mega-panel {
	position: absolute;
	top: 100%;
	left: 0;
	width: min(1100px, calc(100vw - 32px));
	margin: 0;
	padding: 8px 0 0;
	opacity: 0;
	pointer-events: none;
	transform: translateY(-8px) scale(0.98);
	transform-origin: top center;
	transition: opacity 0.18s ease, transform 0.18s ease;
	z-index: 100;
}

.tpm-mega-panel.is-open {
	opacity: 1;
	pointer-events: auto;
	transform: translateY(0) scale(1);
}

.tpm-mega-panel-inner {
	background: var(--tpm-color-surface);
	border: 1px solid var(--tpm-color-border);
	border-radius: 16px;
	box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.06);
	padding: var(--tpm-space-5);
	max-height: calc(100vh - var(--tpm-header-height) - 32px);
	overflow-y: auto;
}

.tpm-mega-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: var(--tpm-space-6);
	list-style: none;
	margin: 0;
	padding: 0;
}

.tpm-mega-col {
	display: flex;
	flex-direction: column;
	gap: var(--tpm-space-3);
	min-width: 0;
}

.tpm-mega-col-head {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--tpm-space-2);
	padding: var(--tpm-space-3);
	border-radius: 12px;
	text-decoration: none;
	transition: background-color 0.15s ease;
}

.tpm-mega-col-head:hover,
.tpm-mega-col-head:focus-visible {
	background: var(--tpm-color-primary);
	color: #fff;
	text-decoration: none;
}

.tpm-mega-col-head:hover .tpm-mega-col-title,
.tpm-mega-col-head:focus-visible .tpm-mega-col-title,
.tpm-mega-col-head:hover .tpm-mega-col-desc,
.tpm-mega-col-head:focus-visible .tpm-mega-col-desc {
	color: #fff;
}

.tpm-mega-col-head:hover .tpm-mega-col-icon,
.tpm-mega-col-head:focus-visible .tpm-mega-col-icon {
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
}

.tpm-mega-col-head:focus-visible {
	outline: 2px solid var(--tpm-color-primary);
	outline-offset: 2px;
}

.tpm-mega-col-icon {
	width: 36px;
	height: 36px;
	padding: 8px;
	box-sizing: border-box;
	border-radius: 10px;
	background: var(--tpm-color-bg-alt);
	color: var(--tpm-color-primary);
	flex-shrink: 0;
}

.tpm-mega-col-title {
	font-weight: 600;
	font-size: 0.9375rem;
	letter-spacing: -0.008em;
	color: var(--tpm-color-text);
	white-space: nowrap;
}

.tpm-mega-col-desc {
	font-size: 0.8125rem;
	color: var(--tpm-color-text-muted);
	line-height: 1.45;
}

/* Grouped columns (have children): head becomes a compact section label. */
.tpm-mega-col--grouped .tpm-mega-col-head {
	flex-direction: row;
	align-items: center;
	padding: var(--tpm-space-2) var(--tpm-space-3);
}

.tpm-mega-col--grouped .tpm-mega-col-title {
	font-size: 0.8125rem;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--tpm-color-text-muted);
}

.tpm-mega-col--grouped .tpm-mega-col-icon {
	width: 24px;
	height: 24px;
	padding: 4px;
	background: transparent;
}

.tpm-mega-col-links {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.tpm-mega-link {
	display: block;
	padding: 10px var(--tpm-space-3);
	border-radius: 10px;
	color: var(--tpm-color-text);
	font-size: 0.9375rem;
	white-space: nowrap;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.tpm-mega-link:hover,
.tpm-mega-link:focus-visible {
	background: var(--tpm-color-primary);
	color: #fff;
	text-decoration: none;
}

.tpm-mega-link:focus-visible {
	outline: 2px solid var(--tpm-color-primary);
	outline-offset: 2px;
}

.tpm-mega-link[aria-current="page"] {
	color: var(--tpm-color-primary);
}

@media (prefers-reduced-motion: reduce) {
	.tpm-mega-panel,
	.tpm-hamburger-line,
	.tpm-primary-nav,
	.tpm-add-to-cart {
		transition: none !important;
	}
}

/* Tablet: simplified single-column dropdown instead of the full grid. */
@media (min-width: 783px) and (max-width: 1024px) {
	.tpm-mega-panel {
		position: absolute;
		top: 100%;
		left: 0;
		width: 320px;
		transform: translateY(-4px) scale(0.98);
	}

	.tpm-mega-panel.is-open {
		transform: translateY(4px) scale(1);
	}

	.tpm-mega-grid {
		grid-template-columns: 1fr;
	}

	.tpm-mega-col--grouped .tpm-mega-col-head {
		padding-top: var(--tpm-space-3);
	}
}

/* Mobile: mega panel collapses into an inline expandable section within the off-canvas nav. */
@media (max-width: 782px) {
	.tpm-mega-panel {
		position: static;
		width: 100%;
		opacity: 1;
		pointer-events: auto;
		transform: none;
		max-height: 0;
		overflow: hidden;
		padding: 0;
		transition: max-height 0.25s ease;
	}

	.tpm-mega-panel.is-open {
		max-height: 2000px;

		/*
		 * Explicit transform reset, kept for clarity even though it's a
		 * no-op today: desktop's .tpm-mega-panel.is-open (above) now only
		 * ever sets translateY(0) scale(1) — identity, no visible effect —
		 * since P1.19 moved horizontal placement out of `transform` and
		 * into a JS-computed `left` (main.js). The specificity collision
		 * this comment used to warn about (both rules sharing (0,2,0) and
		 * desktop's translateX(-50%) winning on source order, shifting the
		 * open mobile panel ~50% of its own width off-screen) can't recur
		 * structurally now that desktop's transform has no horizontal
		 * component to leak in. Left explicit rather than removed, since
		 * relying on "translateY(0) scale(1) happens to look like none" is
		 * more fragile than just saying none.
		 */
		transform: none;
	}

	.tpm-mega-panel-inner {
		border: none;
		border-radius: 0;
		box-shadow: none;
		padding: 0 var(--tpm-space-3) var(--tpm-space-3);
	}

	.tpm-mega-grid {
		grid-template-columns: 1fr;
		gap: var(--tpm-space-3);
	}
	.tpm-mega-col-head { padding-left: var(--tpm-space-2); min-height: 44px; }

	/* Column descriptions add clutter in the single-column mobile accordion; desktop is unaffected (this rule is scoped inside this media query only). */
	.tpm-mega-col-desc { display: none; }
	.tpm-mega-link { min-height: 44px; display: flex; align-items: center; }
	.tpm-menu-link[aria-expanded] .tpm-menu-chevron { margin-left: auto; }

	.tpm-menu-link[aria-expanded] {
		width: 100%;
		justify-content: space-between;
	}
}

.tpm-widget { margin-bottom: var(--tpm-space-4); }
.tpm-widget-title { font-size: 0.9375rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--tpm-color-text-muted); }

.tpm-footer-col--brand { grid-column: span 1; }
.tpm-footer-tagline { color: var(--tpm-color-text-muted); margin: 0 0 var(--tpm-space-2); }
.tpm-footer-widget-row { display: block; }

.tpm-download-btn { margin-top: var(--tpm-space-4); }

.tpm-hero.has-bg-image { color: #fff; }

.tpm-hero.has-bg-image h1,
.tpm-hero.has-bg-image p { color: #fff; }
.tpm-hero.has-bg-image .tpm-hero-eyebrow { color: var(--tpm-color-primary-light); }
.tpm-hero.has-bg-image .tpm-hero-stats { color: rgba(255, 255, 255, 0.85); }
.tpm-hero.has-bg-image .tpm-hero-stats strong { color: #fff; }
