/* ==========================================================================
   Domstroy — Category Carousel (home "Արագ կատեգորիաներ")
   Markup: template-parts/home/category-carousel.php
   All selectors are scoped to .dcc / .dcc-card to avoid touching global styles.
   ========================================================================== */

/* ---------- Sticky behaviour (kept from the previous block) ---------- */
html, body, #page, .site-main, .site-content, main.main, .section {
	overflow-x: clip !important;
}
.section-quick-cats.dcc {
	--dcc-red: #CA3338;
	--dcc-card-bg: #3a3c42;
	--dcc-card-bg-hover: #42454c;
	--dcc-border: hsla(0, 0%, 100%, .06);
	--dcc-text: #f2f2f3;
	--dcc-w: 156px;
	--dcc-gap: 14px;
	--dcc-stage: 92px;
	--dcc-ease-out: cubic-bezier(.22, 1, .36, 1);
	--dcc-ease-spring: cubic-bezier(.34, 1.56, .64, 1);

	background: #32353c;
	transition: box-shadow .3s ease;
	margin-top: -1px;
	contain: none !important;
	padding-bottom: 24px;
}
@media (min-width: 769px) {
	.section-quick-cats.dcc {
		position: -webkit-sticky !important;
		position: sticky !important;
		top: 0 !important;
		z-index: 990;
	}
}
body.quick-cats-stuck .section-quick-cats.dcc {
	box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
body.quick-cats-stuck .header {
	transform: translateY(-100%) !important;
	visibility: hidden;
	transition: transform .3s ease, visibility .3s ease;
}

/* ---------- Header / arrows ---------- */
.dcc .dcc__header { margin-bottom: 8px; }
.dcc .dcc__nav[hidden] { display: none; }
.dcc .dcc__arrow { transition: background .2s ease, transform .2s ease, opacity .2s ease; }
.dcc .dcc__arrow:hover { background: var(--dcc-red); }
.dcc .dcc__arrow:focus-visible {
	outline: 2px solid var(--dcc-red);
	outline-offset: 3px;
}
.dcc .dcc__arrow:disabled { opacity: .35; cursor: default; }

/* ---------- Viewport / track ---------- */
.dcc__viewport {
	position: relative;
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-padding-inline: 2px;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	/* room for the hover lift + shadow, which would otherwise be clipped */
	padding: 10px 2px 16px;
	margin: -10px -2px -16px;
	touch-action: pan-x pan-y;
}
.dcc__viewport::-webkit-scrollbar { display: none; }

/* Soft edge fade that tells "there is more" — removed at the ends */
.dcc--js .dcc__viewport {
	--dcc-fade-l: 0px;
	--dcc-fade-r: 40px;
	-webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--dcc-fade-l), #000 calc(100% - var(--dcc-fade-r)), transparent 100%);
	mask-image: linear-gradient(to right, transparent 0, #000 var(--dcc-fade-l), #000 calc(100% - var(--dcc-fade-r)), transparent 100%);
}
.dcc--js .dcc__viewport.is-scrolled { --dcc-fade-l: 40px; }
.dcc--js .dcc__viewport.is-end { --dcc-fade-r: 0px; }

.dcc__viewport.is-dragging {
	scroll-snap-type: none;
	cursor: grabbing;
}
.dcc__viewport.is-dragging .dcc-card { pointer-events: none; }

.dcc__track {
	display: flex;
	gap: var(--dcc-gap);
	list-style: none;
	margin: 0;
	padding: 0;
}
.dcc__item {
	flex: 0 0 var(--dcc-w);
	display: flex;
	scroll-snap-align: start;
	margin: 0;
}

/* ---------- Card ---------- */
.dcc-card {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	width: 100%;
	min-height: 100%;
	padding: 14px 8px;
	container-type: inline-size;
	background: var(--dcc-card-bg);
	border: 1px solid var(--dcc-border);
	border-radius: 14px;
	color: var(--dcc-text);
	text-decoration: none;
	-webkit-tap-highlight-color: transparent;
	transition:
		transform .35s var(--dcc-ease-out),
		box-shadow .35s var(--dcc-ease-out),
		border-color .3s ease,
		background-color .3s ease;
	user-select: none;
	-webkit-user-select: none;
	-webkit-user-drag: none;
}
.dcc-card:focus-visible {
	outline: 2px solid var(--dcc-red);
	outline-offset: 3px;
}
.dcc-card:active {
	transform: scale(.96);
	transition-duration: .08s;
}

/* Illustration "stage" — a soft lit plate that gives every icon the same base */
.dcc-card__stage {
	position: relative;
	display: grid;
	place-items: center;
	flex-shrink: 0;
	width: var(--dcc-stage);
	height: var(--dcc-stage);
	border-radius: 50%;
	background:
		radial-gradient(circle at 50% 38%, hsla(0, 0%, 100%, .16) 0%, hsla(0, 0%, 100%, .05) 45%, transparent 70%);
	isolation: isolate;
}
.dcc-card__glow {
	position: absolute;
	inset: 6%;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(202, 51, 56, .38) 0%, rgba(202, 51, 56, 0) 68%);
	opacity: 0;
	transform: scale(.7);
	transition: opacity .4s ease, transform .5s var(--dcc-ease-out);
	z-index: -1;
}
.dcc-card__shadow {
	position: absolute;
	left: 22%;
	right: 22%;
	bottom: 4%;
	height: 10%;
	border-radius: 50%;
	background: radial-gradient(ellipse at center, rgba(0, 0, 0, .55) 0%, rgba(0, 0, 0, 0) 70%);
	transform-origin: center;
	z-index: -1;
}
.dcc-card__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	transform-origin: 50% 85%;
	will-change: transform;
	pointer-events: none;
	filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .28));
}
img.dcc-card__img { border-radius: 50%; }   /* round badge artwork stays round */
.dcc-card__img--fallback { width: 62%; height: 62%; }

.dcc-card__title {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: calc(1.3em * 2);
	margin: 0;
	font-family: "Noto Sans Armenian", sans-serif;
	font-size: .8rem;
	/* scale with the card so the longest Armenian words
	   ("Գյուղատնտեսական", "էլեկտրականություն") fit on one line */
	font-size: clamp(11px, calc(100cqi / 10.6), 13px);
	font-weight: 600;
	line-height: 1.3;
	text-align: center;
	color: inherit;
	word-break: normal;
	overflow-wrap: break-word; /* last resort only, on very narrow phones */
	transition: color .3s ease;
}

/* ---------- Entrance (pure CSS, plays once on page load) ----------
   The block sits at the top of the home page, so it is on screen at load.
   Entrance runs on the <li> and the stage; hover runs on the <img>, so the
   two never fight and the entrance never replays. */
.dcc__item {
	animation: dcc-rise .55s var(--dcc-ease-out) both;
	animation-delay: calc(var(--dcc-i, 0) * 45ms);
}
.dcc-card__stage {
	animation: dcc-pop .8s var(--dcc-ease-out) both;
	animation-delay: calc(var(--dcc-i, 0) * 45ms + 120ms);
}

/* after the pointer leaves: ease back from the lifted pose instead of snapping */
.dcc-card.is-leaving .dcc-card__img    { animation: dcc-settle .4s var(--dcc-ease-out) both; }
.dcc-card.is-leaving .dcc-card__shadow { animation: dcc-shadow-settle .4s var(--dcc-ease-out) both; }

/* ---------- Hover (mouse only): Lottie-style "jump & settle" ---------- */
@media (hover: hover) and (pointer: fine) {
	.dcc-card:hover {
		transform: translateY(-4px);
		background-color: var(--dcc-card-bg-hover);
		border-color: rgba(202, 51, 56, .55);
		box-shadow: 0 14px 28px rgba(0, 0, 0, .35), 0 0 0 1px rgba(202, 51, 56, .18);
	}
	.dcc-card:hover .dcc-card__glow {
		opacity: 1;
		transform: scale(1);
	}
	.dcc-card:hover .dcc-card__img {
		animation: dcc-jump .7s var(--dcc-ease-out) both;
	}
	.dcc-card:hover .dcc-card__shadow {
		animation: dcc-shadow-jump .7s var(--dcc-ease-out) both;
	}
	.dcc-card:active { transform: translateY(-2px) scale(.97); }
}

/* Keyboard users get the same settle pose without the bounce */
.dcc-card:focus-visible .dcc-card__glow { opacity: 1; transform: scale(1); }

/* ---------- Keyframes ---------- */
@keyframes dcc-rise {
	from { opacity: 0; transform: translateY(14px); }
	to   { opacity: 1; transform: none; }
}
/* intro: drop in, overshoot, settle */
@keyframes dcc-pop {
	0%   { opacity: 0; transform: translateY(10px) scale(.55) rotate(-10deg); }
	55%  { opacity: 1; transform: translateY(-5px) scale(1.08) rotate(4deg); }
	78%  { transform: translateY(1px) scale(.97) rotate(-1.5deg); }
	100% { opacity: 1; transform: none; }
}
/* hover: anticipation squash → stretch jump → wobble → hold a lifted pose */
@keyframes dcc-jump {
	0%   { transform: none; }
	16%  { transform: translateY(2px) scale(1.08, .9); }
	40%  { transform: translateY(-12px) scale(.95, 1.07) rotate(-6deg); }
	62%  { transform: translateY(-5px) scale(1.06, .97) rotate(4deg); }
	80%  { transform: translateY(-8px) scale(1.06) rotate(-2deg); }
	100% { transform: translateY(-6px) scale(1.07) rotate(-2deg); }
}
@keyframes dcc-shadow-jump {
	0%   { transform: scale(1); opacity: 1; }
	16%  { transform: scale(1.12, 1); opacity: 1; }
	40%  { transform: scale(.55); opacity: .45; }
	62%  { transform: scale(.85); opacity: .8; }
	100% { transform: scale(.78); opacity: .7; }
}
@keyframes dcc-settle {
	from { transform: translateY(-6px) scale(1.07) rotate(-2deg); }
	to   { transform: none; }
}
@keyframes dcc-shadow-settle {
	from { transform: scale(.78); opacity: .7; }
	to   { transform: scale(1); opacity: 1; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
	.section-quick-cats.dcc { --dcc-w: 138px; --dcc-stage: 84px; --dcc-gap: 12px; }
}
@media (max-width: 575px) {
	.section-quick-cats.dcc {
		/* ~3.3 cards: the cut-off 4th card hints that the row scrolls */
		--dcc-w: max(96px, calc((100vw - 32px - 3 * 10px) / 3.3));
		--dcc-stage: 72px;
		--dcc-gap: 10px;
		padding-bottom: 16px;
	}
	.dcc-card { padding: 12px 6px; gap: 8px; border-radius: 12px; }
	.dcc .dcc__nav { display: none; } /* swipe on phones */
	.dcc--js .dcc__viewport { --dcc-fade-r: 18px; }
	.dcc--js .dcc__viewport.is-scrolled { --dcc-fade-l: 18px; }
	.dcc--js .dcc__viewport.is-end { --dcc-fade-r: 0px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
	.dcc__item,
	.dcc-card__stage,
	.dcc-card__img,
	.dcc-card__shadow,
	.dcc-card:hover .dcc-card__img,
	.dcc-card:hover .dcc-card__shadow {
		animation: none !important;
	}
	.dcc-card, .dcc-card__glow { transition-duration: .01ms !important; }
	.dcc-card:hover { transform: none; }
}
