/**
 * Jukwaa component layer.
 *
 * Every value here resolves to a token generated by theme.json. No raw hex,
 * no magic numbers. If a value needs changing, it changes in theme.json and
 * every component follows.
 *
 * Scoping rule: components are prefixed .jk- so nothing here can collide with
 * core block classes or with FluentCart markup.
 */

/* ---------------------------------------------------------------- Primitives */

.jk-eyebrow {
	font-family: var(--wp--preset--font-family--utility);
	font-size: var(--wp--preset--font-size--micro);
	font-weight: 500;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--wp--preset--color--slate);
}

/* The pindo: the double hairline that separates human copy from machine fact.
   The one decorative device in the system. */
.jk-pindo {
	height: var(--wp--custom--line--pindo);
	border-top: 1px solid var(--wp--preset--color--line);
	border-bottom: 1px solid var(--wp--preset--color--line);
	background: transparent;
}

/* Focus is never removed, on anything. */
.jk-card a:focus-visible,
.jk-btn:focus-visible,
.jk-fav:focus-visible,
.jk-chip:focus-visible,
.jk-rail input:focus-visible {
	outline: 2px solid var(--wp--preset--color--action);
	outline-offset: 2px;
}

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

.jk-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--wp--preset--spacing--20);
	min-height: 44px; /* touch target floor */
	padding: 0.75rem 1.25rem;
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	border: 1px solid transparent;
	border-radius: var(--wp--custom--radius--control);
	cursor: pointer;
	text-decoration: none;
	transition:
		background-color var(--wp--custom--motion--fast) var(--wp--custom--motion--ease),
		border-color var(--wp--custom--motion--fast) var(--wp--custom--motion--ease);
}

.jk-btn--primary {
	background: var(--wp--preset--color--action);
	color: var(--wp--preset--color--surface);
}
.jk-btn--primary:hover { background: var(--wp--preset--color--action-hover); }

.jk-btn--secondary {
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--ink);
	border-color: var(--wp--preset--color--line);
}
.jk-btn--secondary:hover { border-color: var(--wp--preset--color--slate-light); }

.jk-btn--quiet {
	background: transparent;
	color: var(--wp--preset--color--ink-soft);
}
.jk-btn--quiet:hover { background: var(--wp--preset--color--line-soft); }

.jk-btn[disabled],
.jk-btn[aria-disabled="true"] {
	background: var(--wp--preset--color--line);
	color: var(--wp--preset--color--slate-light);
	cursor: not-allowed;
}

/* ------------------------------------------------------------------- Badges */

.jk-badge {
	font-family: var(--wp--preset--font-family--utility);
	font-size: 0.6875rem;
	font-weight: 500;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	padding: 4px 7px;
	border-radius: var(--wp--custom--radius--badge);
	border: 1px solid transparent;
	white-space: nowrap;
}

.jk-badge--new    { border-color: var(--wp--preset--color--ink); color: var(--wp--preset--color--ink); }
.jk-badge--best   { background: var(--wp--preset--color--money-fill); color: var(--wp--preset--color--money); }
.jk-badge--off    { background: var(--wp--preset--color--expiring-fill); color: var(--wp--preset--color--expiring); }
.jk-badge--free   { background: var(--wp--preset--color--free-fill); color: var(--wp--preset--color--free); }
.jk-badge--bundle { background: var(--wp--preset--color--ink); color: var(--wp--preset--color--surface); }

/* -------------------------------------------------------------- Product grid */

.jk-grid {
	display: grid;
	gap: var(--wp--custom--grid--gutter);
	grid-template-columns: repeat(auto-fill, minmax(var(--wp--custom--grid--card-min), 1fr));
}

.jk-card {
	display: flex;
	flex-direction: column;
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--card);
	overflow: hidden;
	transition:
		box-shadow var(--wp--custom--motion--base) var(--wp--custom--motion--ease),
		border-color var(--wp--custom--motion--base) var(--wp--custom--motion--ease);
}
.jk-card:hover,
.jk-card:focus-within {
	border-color: var(--wp--preset--color--slate-light);
	box-shadow: var(--wp--preset--shadow--raised);
}

/* Fixed ratio so a ragged mix of creator uploads still renders as a clean grid. */
.jk-card__field {
	position: relative;
	aspect-ratio: 4 / 3;
	background: var(--wp--preset--color--line-soft);
	overflow: hidden;
}
.jk-card__field img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.jk-card__flags {
	position: absolute;
	inset: var(--wp--preset--spacing--20) auto auto var(--wp--preset--spacing--20);
	display: flex;
	gap: 6px;
}

.jk-fav {
	position: absolute;
	inset: var(--wp--preset--spacing--20) var(--wp--preset--spacing--20) auto auto;
	width: 32px;
	height: 32px;
	display: grid;
	place-items: center;
	border-radius: var(--wp--custom--radius--pill);
	background: rgba(255, 255, 255, 0.92);
	border: 1px solid var(--wp--preset--color--line);
	color: var(--wp--preset--color--ink-soft);
	cursor: pointer;
}

.jk-card__peek {
	position: absolute;
	inset: auto var(--wp--preset--spacing--20) var(--wp--preset--spacing--20) var(--wp--preset--spacing--20);
	padding: var(--wp--preset--spacing--20);
	text-align: center;
	font-size: var(--wp--preset--font-size--tiny);
	font-weight: 600;
	color: var(--wp--preset--color--surface);
	background: rgba(14, 20, 24, 0.88);
	border-radius: var(--wp--custom--radius--control);
	opacity: 0;
	transform: translateY(4px);
	transition:
		opacity var(--wp--custom--motion--base) var(--wp--custom--motion--ease),
		transform var(--wp--custom--motion--base) var(--wp--custom--motion--ease);
}
.jk-card:hover .jk-card__peek,
.jk-card:focus-within .jk-card__peek {
	opacity: 1;
	transform: none;
}

/* Quick preview is a hover affordance, so it must never be the only route to
   the action. On touch it is hidden and the whole card is the target. */
@media (hover: none) {
	.jk-card__peek { display: none; }
}

.jk-card__body {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--30) 0;
}

.jk-card__title {
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.3;
}
.jk-card__title a { text-decoration: none; color: inherit; }
.jk-card__title a:hover { text-decoration: underline; }

.jk-card__by,
.jk-card__rating {
	font-size: var(--wp--preset--font-size--tiny);
	color: var(--wp--preset--color--slate);
	font-variant-numeric: tabular-nums;
}
.jk-card__stars { color: var(--wp--preset--color--money); }

.jk-card__price {
	display: flex;
	align-items: baseline;
	gap: var(--wp--preset--spacing--20);
	margin-top: var(--wp--preset--spacing--20);
}
.jk-card__now {
	font-family: var(--wp--preset--font-family--display);
	font-size: 1.0625rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}
.jk-card__now--free { color: var(--wp--preset--color--free); }
.jk-card__was {
	font-size: var(--wp--preset--font-size--tiny);
	color: var(--wp--preset--color--slate-light);
	text-decoration: line-through;
}

.jk-card .jk-pindo { margin-top: var(--wp--preset--spacing--30); }

/* The jina: one line of machine truth on the bottom edge of the card. */
.jk-card__jina {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--20);
	padding: 9px var(--wp--preset--spacing--30) 11px;
	font-family: var(--wp--preset--font-family--utility);
	font-size: 0.6875rem;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--wp--preset--color--slate);
}
.jk-card__jina span:not(:last-child)::after {
	content: "·";
	margin-left: var(--wp--preset--spacing--20);
	color: var(--wp--preset--color--slate-light);
}

/* ------------------------------------------------------------- Filter rail */

.jk-rail {
	align-self: start;
	padding: var(--wp--preset--spacing--40);
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--card);
}
.jk-rail__group { padding: 14px 0; border-top: 1px solid var(--wp--preset--color--line-soft); }
.jk-rail__group:first-of-type { border-top: 0; padding-top: 0; }

.jk-rail label {
	display: flex;
	align-items: center;
	gap: 9px;
	min-height: 32px;
	font-size: var(--wp--preset--font-size--small);
	cursor: pointer;
}
.jk-rail input[type="checkbox"] {
	width: 16px;
	height: 16px;
	accent-color: var(--wp--preset--color--action);
}
/* Counts stop a buyer choosing a combination that returns nothing. */
.jk-rail__count {
	margin-left: auto;
	font-family: var(--wp--preset--font-family--utility);
	font-size: var(--wp--preset--font-size--micro);
	color: var(--wp--preset--color--slate-light);
	font-variant-numeric: tabular-nums;
}

.jk-chip {
	display: inline-flex;
	align-items: center;
	gap: var(--wp--preset--spacing--20);
	padding: 6px 10px 6px 12px;
	font-size: var(--wp--preset--font-size--tiny);
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--pill);
}

/* Desktop gets a sticky rail; mobile gets a bottom sheet, never a rail. */
@media (min-width: 801px) {
	.jk-browse {
		display: grid;
		gap: var(--wp--preset--spacing--50);
		grid-template-columns: 236px 1fr;
	}
	.jk-rail {
		position: sticky;
		top: calc(var(--wp--custom--header--height) + var(--wp--preset--spacing--40));
		max-height: calc(100vh - var(--wp--custom--header--height) - var(--wp--preset--spacing--80));
		overflow-y: auto;
	}
}

/* ------------------------------------------------- Loading and empty states */

.jk-skeleton {
	background: linear-gradient(
		90deg,
		var(--wp--preset--color--line-soft) 25%,
		#e7eaee 37%,
		var(--wp--preset--color--line-soft) 63%
	);
	background-size: 400% 100%;
	animation: jk-shimmer 1.4s ease infinite;
}
@keyframes jk-shimmer {
	0%   { background-position: 100% 0; }
	100% { background-position: 0 0; }
}

.jk-state {
	padding: var(--wp--preset--spacing--50);
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--card);
}
.jk-state__title {
	font-family: var(--wp--preset--font-family--display);
	font-weight: 600;
	margin-bottom: 6px;
}
.jk-state p {
	margin: 0;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--slate);
}
.jk-state--error { border-color: var(--wp--preset--color--expiring); }
.jk-state--error .jk-state__title { color: var(--wp--preset--color--expiring); }

/* ------------------------------------------------------------------ Motion */

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/* ------------------------------------------------ Parent theme compatibility */

/*
 * Twenty Twenty Five's template parts and patterns reference its own palette
 * slugs (base, contrast, accent-1..6). Our theme.json palette replaces the
 * parent's wholesale, so those references resolve to nothing and any inherited
 * parent markup renders transparent. These aliases map the parent's slugs onto
 * our semantic tokens.
 *
 * They live here rather than in theme.json's palette on purpose: adding them
 * as presets would put eight redundant swatches in the editor colour picker
 * and invite an editor to pick "accent-4" over "line soft". As plain custom
 * properties they do the compatibility job and stay invisible.
 *
 * Delete this block once phase 3 replaces every parent template part with ours.
 */
:root {
	--wp--preset--color--base:      var(--wp--preset--color--surface);
	--wp--preset--color--contrast:  var(--wp--preset--color--ink);
	--wp--preset--color--accent-1:  var(--wp--preset--color--action);
	--wp--preset--color--accent-2:  var(--wp--preset--color--money);
	--wp--preset--color--accent-3:  var(--wp--preset--color--canvas);
	--wp--preset--color--accent-4:  var(--wp--preset--color--line-soft);
	--wp--preset--color--accent-5:  var(--wp--preset--color--line);
	--wp--preset--color--accent-6:  var(--wp--preset--color--slate);
}
