/**
 * Grovidex component foundations.
 *
 * Reusable building blocks for the storefront. This file contains no
 * page layout; homepage composition arrives in a later phase. All
 * classes are gvx- prefixed and inert until used in markup.
 */

/* ==================================================================
 * 1. Buttons
 * ================================================================== */

.gvx-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--gvx-space-2);
	min-height: 44px;
	padding: var(--gvx-space-2) var(--gvx-space-5);
	border: 1px solid transparent;
	border-radius: var(--gvx-radius-sm);
	font-family: var(--gvx-font-sans);
	font-size: var(--gvx-text-base);
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition:
		background-color var(--gvx-duration) var(--gvx-ease),
		border-color var(--gvx-duration) var(--gvx-ease),
		color var(--gvx-duration) var(--gvx-ease);
}

/* Primary: gold with dark ink text (gold + white fails contrast). */
.gvx-btn--primary {
	background-color: var(--gvx-gold);
	color: var(--gvx-ink);
}

.gvx-btn--primary:hover,
.gvx-btn--primary:focus-visible {
	background-color: var(--gvx-gold-dark);
	color: var(--gvx-ink);
}

/* Secondary: teal outline on white. */
.gvx-btn--secondary {
	background-color: var(--gvx-surface);
	border-color: var(--gvx-teal);
	color: var(--gvx-teal);
}

.gvx-btn--secondary:hover,
.gvx-btn--secondary:focus-visible {
	background-color: var(--gvx-teal-tint);
	color: var(--gvx-teal-dark);
}

/* Text link control (e.g. "View all"). Non-color affordance (arrow
   glyph in markup) plus underline: never hover-color-only. */
.gvx-link {
	display: inline-flex;
	align-items: center;
	gap: var(--gvx-space-1);
	min-height: 44px;
	color: var(--gvx-teal);
	font-family: var(--gvx-font-sans);
	font-size: var(--gvx-text-sm);
	font-weight: 600;
	text-decoration: none;
}

.gvx-link:hover,
.gvx-link:focus-visible {
	color: var(--gvx-teal-dark);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

/* ==================================================================
 * 2. Discovery chips
 * ================================================================== */

.gvx-chip-row {
	display: flex;
	flex-wrap: wrap;
	gap: var(--gvx-space-2);
}

.gvx-chip {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: var(--gvx-space-2) var(--gvx-space-4);
	background-color: var(--gvx-surface);
	border: 1px solid var(--gvx-border);
	border-radius: var(--gvx-radius-pill);
	color: var(--gvx-teal);
	font-family: var(--gvx-font-sans);
	font-size: var(--gvx-text-sm);
	font-weight: 500;
	text-decoration: none;
	white-space: nowrap;
	transition:
		border-color var(--gvx-duration) var(--gvx-ease),
		box-shadow var(--gvx-duration) var(--gvx-ease);
}

.gvx-chip:hover,
.gvx-chip:focus-visible {
	border-color: var(--gvx-teal);
	box-shadow: var(--gvx-shadow-sm);
	color: var(--gvx-teal-dark);
}

/* ==================================================================
 * 3. Section heading pattern
 * ================================================================== */

.gvx-section__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--gvx-space-4);
	margin-bottom: var(--gvx-space-5);
}

.gvx-section__title {
	margin: 0;
	font-size: var(--gvx-text-xl);
	font-weight: 700;
	color: var(--gvx-ink);
	line-height: var(--gvx-leading-tight);
}

.gvx-section__sub {
	margin-top: var(--gvx-space-1);
	font-size: var(--gvx-text-sm);
	color: var(--gvx-ink-muted);
}

/* ==================================================================
 * 4. Card base
 * ================================================================== */

.gvx-card {
	position: relative;
	display: flex;
	flex-direction: column;
	background-color: var(--gvx-surface);
	border: 1px solid var(--gvx-border);
	border-radius: var(--gvx-radius-md);
	box-shadow: var(--gvx-shadow-sm);
	transition:
		border-color var(--gvx-duration) var(--gvx-ease),
		box-shadow var(--gvx-duration) var(--gvx-ease),
		transform var(--gvx-duration) var(--gvx-ease);
}

.gvx-card:hover,
.gvx-card:focus-within {
	border-color: var(--gvx-teal);
	box-shadow: var(--gvx-shadow-md);
}

@media (prefers-reduced-motion: no-preference) {
	.gvx-card:hover,
	.gvx-card:focus-within {
		transform: translateY(-2px);
	}
}

/* Stretched primary link: the whole card is one interaction that
   opens the target page. The focus ring wraps the entire card. */
.gvx-card__link {
	color: var(--gvx-ink);
	text-decoration: none;
}

.gvx-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
}

.gvx-card__link:focus-visible {
	outline: none; /* replaced by the full-card ring below, never removed */
}

.gvx-card__link:focus-visible::after {
	outline: 2px solid var(--gvx-teal);
	outline-offset: 2px;
	border-radius: var(--gvx-radius-md);
}

/* ==================================================================
 * 5. Product card
 * Visual hierarchy: cover → context/publisher → title → price →
 * MRP (when valid) → savings (when valid). No cart action here:
 * the card opens the WooCommerce product page.
 * ================================================================== */

.gvx-card--product {
	min-width: 0;
}

/* Portrait-friendly image stage: the cover is fully contained (never
   cropped, never distorted) on a warm neutral ground, with breathing
   room so the artwork reads as a book, not a thumbnail. The fixed
   4/5 aspect ratio keeps stages — and therefore card heights — aligned
   across the rail and prevents CLS; it is intentionally NOT retuned in
   Phase 12AW because the card width (rail column) and total card
   height are both locked, so any ratio change would grow every card
   without a safe place to absorb the extra height (title/price areas
   are themselves locked). Padding is tightened further instead (12AU:
   12px → 8px; 12AW: 8px → 6px) — this is a pure content-box change,
   so it improves fill on every source ratio without touching the
   frame's own box size. Portrait covers grow to fill the available
   height; wide combo covers grow to fill the available width —
   object-fit: contain picks whichever the source image's own ratio
   calls for. */
.gvx-product__media {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 4 / 5;
	padding: 0.375rem; /* 6px — Phase 12AW; no design token lands here */
	background-color: var(--gvx-surface-dim);
	border-radius: calc(var(--gvx-radius-md) - 1px) calc(var(--gvx-radius-md) - 1px) 0 0;
	overflow: hidden;
}

.gvx-product__media img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

/* Single merchandising badge on the image stage (top-left). Card
   templates render at most one: "%d%% OFF" only for a genuine
   WooCommerce discount, or NEW in the New Arrivals context. */
.gvx-product__badge {
	position: absolute;
	top: var(--gvx-space-2);
	left: var(--gvx-space-2);
	z-index: 1;
	display: inline-flex;
	align-items: center;
	padding: 2px var(--gvx-space-2);
	border-radius: var(--gvx-radius-pill);
	font-size: var(--gvx-text-xs);
	font-weight: 700;
	letter-spacing: 0.02em;
	white-space: nowrap;
}

.gvx-product__badge--save {
	background-color: var(--gvx-gold);
	color: var(--gvx-ink);
}

.gvx-product__badge--new {
	background-color: var(--gvx-teal);
	color: var(--gvx-ink-on-dark);
}

.gvx-product__body {
	display: flex;
	flex-direction: column;
	flex-grow: 1;
	gap: var(--gvx-space-1);
	/* Extra bottom padding gives the price row breathing room against
	   the card edge (Phase 12G). */
	padding: var(--gvx-space-3) var(--gvx-space-3) var(--gvx-space-4);
}

.gvx-product__eyebrow {
	font-size: var(--gvx-text-xs);
	font-weight: 500;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--gvx-ink-muted);
}

/* Title: prominent after the cover, visually clamped to two lines
   (the full title stays in the DOM/link text), with an EXACT
   two-line box so titles, prices and stages align across cards.
 *
 * Root cause of the 12M defect (verified against production computed
 * styles): external heading rules (Astra/Elementor kit, specificity
 * (0,1,1)) overrode this h3's line-height to 1.15 while the reserved
 * em-height assumed 1.35 — the box edge then cut through line 3,
 * leaving a glyph fragment (legacy -webkit-line-clamp paints trailing
 * lines and relies on the overflow edge to hide them). Two defenses:
 * (0,2,0) specificity so our line-height always wins, and height/
 * max-height locked to exactly 2 × that same line-height — the
 * overflow edge and the two-line boundary can never diverge, at any
 * font-size, even if the clamp itself is defeated. */
.gvx-card--product .gvx-product__title {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow: hidden;
	margin: 0;
	padding: 0;
	height: calc(2 * var(--gvx-leading-snug) * 1em);
	max-height: calc(2 * var(--gvx-leading-snug) * 1em);
	flex-shrink: 0;
	font-size: var(--gvx-text-sm);
	font-weight: 600;
	color: var(--gvx-ink);
	line-height: var(--gvx-leading-snug);
}

@media (min-width: 768px) {
	.gvx-card--product .gvx-product__title {
		font-size: 0.9375rem; /* 15px on wider cards */
	}
}

/* ==================================================================
 * 6. Exam / category card
 * ================================================================== */

.gvx-card--exam {
	align-items: flex-start;
	gap: var(--gvx-space-3);
	padding: var(--gvx-space-4);
}

/* Category accent identities (Phase 12K): each fixed exam slot gets a
   restrained semantic color on the icon chip only — titles/counts
   keep the consistent ink/muted typography, and the card hover picks
   up the accent subtly. Consumers without a modifier (e.g. the
   Advantage icons) fall back to the brand teal. */
.gvx-exam--bpsc {
	--gvx-exam-accent: #2456a6; /* deep blue — government/public service */
	--gvx-exam-tint: #e8eef8;
}

.gvx-exam--ssc {
	--gvx-exam-accent: #6d4fa1; /* violet — staff-selection exams */
	--gvx-exam-tint: #f0ebf8;
}

.gvx-exam--railway {
	--gvx-exam-accent: #c25a1f; /* warm orange — railway */
	--gvx-exam-tint: #fbeee3;
}

.gvx-exam--upsc {
	--gvx-exam-accent: #3b4ca8; /* indigo — civil services */
	--gvx-exam-tint: #eaedf9;
}

.gvx-exam--jee {
	--gvx-exam-accent: #a06a10; /* amber — engineering/technical */
	--gvx-exam-tint: #fbf3e0;
}

.gvx-exam--bihar-board {
	--gvx-exam-accent: #2f7d4f; /* green — school board/education */
	--gvx-exam-tint: #e9f4ec;
}

.gvx-card--exam:hover,
.gvx-card--exam:focus-within {
	border-color: var(--gvx-exam-accent, var(--gvx-teal));
}

.gvx-exam__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	flex-shrink: 0;
	background-color: var(--gvx-exam-tint, var(--gvx-teal-tint));
	border-radius: var(--gvx-radius-sm);
	color: var(--gvx-exam-accent, var(--gvx-teal));
}

.gvx-exam__name {
	font-size: var(--gvx-text-base);
	font-weight: 600;
	color: var(--gvx-ink);
}

.gvx-exam__count {
	font-size: var(--gvx-text-sm);
	color: var(--gvx-ink-muted);
}

/* ==================================================================
 * 7. Campaign cards
 * ================================================================== */

/* Small campaign card: title + arrow affordance. */
.gvx-card--campaign {
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	gap: var(--gvx-space-4);
	padding: var(--gvx-space-4) var(--gvx-space-5);
}

.gvx-campaign__title {
	font-size: var(--gvx-text-md);
	font-weight: 600;
	color: var(--gvx-ink);
}

/* Large merchandising panel: dark teal, inverted text, gold accents.
   Pair with .gvx-on-dark so focus rings switch to gold. */
.gvx-card--campaign-hero {
	background-color: var(--gvx-teal);
	border-color: var(--gvx-teal);
	border-radius: var(--gvx-radius-lg);
	padding: var(--gvx-space-6) var(--gvx-space-5);
	color: var(--gvx-ink-on-dark);
}

.gvx-card--campaign-hero:hover,
.gvx-card--campaign-hero:focus-within {
	border-color: var(--gvx-gold);
}

.gvx-card--campaign-hero .gvx-campaign__title {
	font-size: var(--gvx-text-2xl);
	font-weight: 700;
	color: var(--gvx-surface);
	line-height: var(--gvx-leading-tight);
}

.gvx-campaign__sub {
	font-size: var(--gvx-text-base);
	color: var(--gvx-ink-on-dark);
}

/* ==================================================================
 * 8. Publisher card
 * ================================================================== */

/* Publisher tiles (Phase 12K): the ORIGINAL brand logo is the visual
   focus when one is configured (local Media Library attachment via
   the standard term thumbnail meta) — contained, never cropped,
   stretched, filtered or recolored; the name drops to a supporting
   line. Without a genuine logo the tile is a deliberate centered
   wordmark — never a fake logo, initials mark or placeholder. */
.gvx-card--publisher {
	align-items: center;
	justify-content: center;
	gap: var(--gvx-space-2);
	min-height: 128px;
	padding: var(--gvx-space-4);
	text-align: center;
}

/* Consistent logo stage: fixed visual band, natural aspect ratios. */
.gvx-publisher__stage {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 64px;
	flex-shrink: 0;
}

.gvx-publisher__logo {
	max-height: 60px;
	max-width: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

/* Supporting name under a real logo. */
.gvx-publisher__name--support {
	font-size: var(--gvx-text-xs);
	font-weight: 500;
	color: var(--gvx-ink-muted);
	-webkit-line-clamp: 2;
	line-clamp: 2;
}

/* Wordmark fallback when a publisher has no logo image. Long real
   names (e.g. "Kiran Institute of Career Excellence") clamp visually
   to three lines at a readable size — the full name stays in the DOM
   and no taxonomy term is ever renamed. */
.gvx-publisher__name {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
	font-size: var(--gvx-text-sm);
	font-weight: 600;
	color: var(--gvx-ink);
	line-height: var(--gvx-leading-snug);
	text-align: center;
	overflow-wrap: break-word;
}

/* ==================================================================
 * 9. Collection card (merchandising tile)
 * ================================================================== */

.gvx-card--collection {
	justify-content: space-between;
	gap: var(--gvx-space-3);
	min-height: 120px;
	padding: var(--gvx-space-5);
	border-color: transparent;
}

.gvx-card--collection.gvx-tint-teal {
	background-color: var(--gvx-teal-tint);
}

.gvx-card--collection.gvx-tint-sand {
	background-color: var(--gvx-sand);
}

.gvx-card--collection.gvx-tint-neutral {
	background-color: var(--gvx-surface-dim);
}

.gvx-collection__label {
	font-size: var(--gvx-text-lg);
	font-weight: 700;
	color: var(--gvx-ink);
	line-height: var(--gvx-leading-tight);
}

.gvx-collection__desc {
	font-size: var(--gvx-text-sm);
	color: var(--gvx-ink-muted);
}

/* ==================================================================
 * 10. Trust items
 * ================================================================== */

.gvx-trust {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--gvx-space-3) var(--gvx-space-4);
}

.gvx-trust__item {
	display: flex;
	align-items: center;
	gap: var(--gvx-space-2);
	font-size: var(--gvx-text-sm);
	font-weight: 500;
	color: var(--gvx-ink);
}

.gvx-trust__icon {
	width: 20px;
	height: 20px;
	flex-shrink: 0;
	color: var(--gvx-teal);
}

@media (min-width: 768px) {
	.gvx-trust {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* ==================================================================
 * 11. Horizontal mobile scroller
 * Keyboard-safe: items are ordinary links/cards reached with Tab;
 * scroll-padding keeps the focused item pulled into view.
 * ================================================================== */

.gvx-scroller {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: var(--gvx-scroller-col, 156px);
	gap: var(--gvx-space-3);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x proximity;
	scroll-padding-inline: var(--gvx-container-pad);
	/* Vertical breathing room so card shadows/focus rings aren't clipped. */
	padding-block: var(--gvx-space-1) var(--gvx-space-3);
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: var(--gvx-border) transparent;
}

.gvx-scroller > * {
	scroll-snap-align: start;
	min-width: 0;
}

/* Product rail: the shared slider track for Trending, New Arrivals
   and Recently Viewed — a horizontal scroller at every width. Mobile:
   one full card plus a visible peek of the next (finger swipe; native
   touch scrolling, vertical page scroll untouched). Desktop: stable
   card widths so ~3 cards show around 922px and ~5 at the 1200px
   container cap. The default scrollbar is visually retired on this
   rail only — scrolling itself is never disabled (swipe, keyboard and
   the arrow enhancement all still drive it). */
.gvx-product-rail {
	grid-auto-columns: min(76%, 260px);
	scrollbar-width: none;
}

.gvx-product-rail::-webkit-scrollbar {
	display: none;
}

@media (min-width: 768px) {
	.gvx-product-rail {
		grid-auto-columns: 216px;
		gap: var(--gvx-space-4);
	}
}

.gvx-section__tools {
	display: flex;
	align-items: center;
	gap: var(--gvx-space-4);
	flex-shrink: 0;
}

/* Rail-edge slider navigation (Phase 12J): each product rail sits
   inside a .gvx-slider wrapper; the nav group overlays that wrapper
   (anchored to the slider, never the viewport) and each button pins
   to the rail's left/right edge, vertically centered, half
   overhanging into the container padding so covers stay unobscured.
   Desktop-only progressive enhancement: the group ships with the
   `hidden` attribute and is revealed by slider.js; finger swipe owns
   touch widths. */
.gvx-slider {
	position: relative;
	min-width: 0;
}

.gvx-slider-nav {
	position: absolute;
	inset: 0;
	z-index: var(--gvx-z-raised);
	/* The overlay itself never intercepts rail interaction; only the
	   buttons do. */
	pointer-events: none;
}

/* Explicit, because the author display on the class would otherwise
   override the `hidden` attribute's UA display:none. */
.gvx-slider-nav[hidden] {
	display: none;
}

@media (max-width: 921px) {
	.gvx-slider-nav {
		display: none;
	}
}

.gvx-slider-btn {
	position: absolute;
	top: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	background-color: var(--gvx-surface);
	border: 1px solid var(--gvx-border);
	border-radius: var(--gvx-radius-pill);
	box-shadow: var(--gvx-shadow-sm);
	color: var(--gvx-teal);
	cursor: pointer;
	pointer-events: auto;
	transition:
		border-color var(--gvx-duration) var(--gvx-ease),
		background-color var(--gvx-duration) var(--gvx-ease),
		color var(--gvx-duration) var(--gvx-ease);
}

.gvx-slider-btn[data-gvx-slider-prev] {
	left: 0;
	transform: translate(-50%, -50%);
}

.gvx-slider-btn[data-gvx-slider-next] {
	right: 0;
	transform: translate(50%, -50%);
}

.gvx-slider-btn:hover:not(:disabled) {
	border-color: var(--gvx-teal);
	background-color: var(--gvx-teal-tint);
	color: var(--gvx-teal-dark);
}

.gvx-slider-btn:focus-visible {
	outline: 2px solid var(--gvx-teal);
	outline-offset: 2px;
}

.gvx-slider-btn:disabled {
	color: var(--gvx-ink-muted);
	opacity: 0.45;
	cursor: default;
}

/* ==================================================================
 * 12. Price presentation
 * Supports both explicit elements and WooCommerce wc_price() markup
 * (del/ins) so templates can pass Woo output straight through.
 * ================================================================== */

.gvx-price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: var(--gvx-space-2);
	margin-top: auto; /* pins price row to a shared baseline across cards */
	/* Minimum clearance below the clamped title even when it runs the
	   full two lines (4px body gap + 8px here ≈ 12px). */
	padding-top: var(--gvx-space-2);
	font-family: var(--gvx-font-sans);
}

.gvx-price__current,
.gvx-price ins {
	font-size: var(--gvx-text-md);
	font-weight: 700;
	color: var(--gvx-ink);
	text-decoration: none;
}

.gvx-price__mrp,
.gvx-price del {
	font-size: var(--gvx-text-sm);
	color: var(--gvx-ink-muted);
	text-decoration: line-through;
}

/* ==================================================================
 * 13. Genuine savings badge
 * Rendered only when a real sale price is lower than a real MRP.
 * Dark ink on warm sand: contrast-safe (never white on gold).
 * ================================================================== */

.gvx-badge--save {
	display: inline-flex;
	align-items: center;
	padding: 2px var(--gvx-space-2);
	background-color: var(--gvx-sand);
	border-radius: var(--gvx-radius-pill);
	font-size: var(--gvx-text-xs);
	font-weight: 600;
	color: var(--gvx-ink);
	white-space: nowrap;
}

/* ==================================================================
 * Grid foundations (layout primitives for later phases)
 * ================================================================== */

.gvx-grid {
	display: grid;
	gap: var(--gvx-space-3);
}

/* 2-up: exam discovery on mobile. */
.gvx-grid--2 {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Card grids that widen with the viewport. */
.gvx-grid--cards {
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

@media (min-width: 768px) {
	.gvx-grid {
		gap: var(--gvx-space-4);
	}

	.gvx-grid--cards {
		grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	}
}
