/* ==================================================================
   CROSS 인테리어컷 갤러리 v1.9
   - 높이 고정 + 원본 비율(기본, 잘림 없음) / 프레임 채우기 / 비율 고정
   - 화면별 썸네일 개수 지정, 넘치면 가로 스크롤, 적으면 가운데 정렬
   - 무한 로테이션(복제 슬라이드는 JS가 생성)
   ================================================================== */

.cxg {
	--cxg-accent: #b4324a;
	--cxg-ink: #23201f;
	--cxg-muted: #837c78;
	--cxg-line: #e4dfdb;
	--cxg-bg: #ffffff;
	--cxg-frame-bg: #f0edea;
	--cxg-gap: 10px;        /* 큰 사진 사이 여백 */
	--cxg-tgap: 10px;       /* 썸네일 사이 여백 */
	--cxg-rad: 2px;         /* 큰 사진 모서리 */
	--cxg-trad: 2px;        /* 썸네일 모서리 */
	--cxg-abw: 2px;         /* 선택된 썸네일 테두리 두께 */
	/* 위 값들은 숏코드가 인라인으로 덮어씁니다 */
	--cxg-pad: 20px;
	--cxg-max: 1160px;
	/* 컨테이너 안쪽 폭의 절반 — 화살표·카운터 고정 좌표 기준.
	   JS가 실제 컨테이너를 재서 덮어씁니다. 아래는 로드 전 근사값입니다. */
	--cxg-half: min(50vw - var(--cxg-pad), (var(--cxg-max, 1160px) - var(--cxg-pad) * 2) / 2);

	/* 숏코드가 --cxg-h-* / --cxg-n-* 를 인라인으로 주입합니다 */
	--cxg-h: var(--cxg-h-mo, 260px);
	--cxg-n: var(--cxg-n-mo, 4);
	--cxg-ratio: 3 / 2;

	padding: 0;
	background: var(--cxg-bg);
	color: var(--cxg-ink);
}

@media (min-width: 601px) {
	.cxg { --cxg-h: var(--cxg-h-tb, 380px); --cxg-n: var(--cxg-n-tb, 5); }
}

@media (min-width: 1025px) {
	.cxg { --cxg-h: var(--cxg-h-pc, 500px); --cxg-n: var(--cxg-n-pc, 6); }
}

.cxg--ratio-4-3  { --cxg-ratio: 4 / 3; }
.cxg--ratio-3-2  { --cxg-ratio: 3 / 2; }
.cxg--ratio-16-9 { --cxg-ratio: 16 / 9; }
.cxg--ratio-1-1  { --cxg-ratio: 1 / 1; }

.cxg__inner {
	max-width: var(--cxg-max);
	margin: 0 auto;
	padding: 0 var(--cxg-pad);
}

/* 부모 컨테이너에 맞춤 — 테마 컨테이너 폭을 그대로 씁니다 */
.cxg--w-inherit .cxg__inner {
	max-width: none;
	padding: 0;
}

/* ---------- 헤더 ---------- */
.cxg__head { margin-bottom: 28px; }

.cxg .cxg__title {
	margin: 0 0 10px;
	font-size: 28px;
	line-height: 1.35;
	font-weight: 600;
	letter-spacing: -0.02em;
}

.cxg__lead {
	max-width: 46em;
	margin: 0;
	font-size: 15px;
	line-height: 1.85;
	color: var(--cxg-muted);
}

/* ---------- 대형 이미지 ---------- */
.cxg__viewport { position: relative; overflow: hidden; }

.cxg__track {
	display: flex;
	align-items: flex-start;
	margin: 0;
	padding: 0;
	list-style: none;
	will-change: transform;
	transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
	touch-action: pan-y;   /* 세로만 브라우저에, 가로는 JS가 받음 */
}

.cxg__track.is-jump,
.cxg__track.is-dragging { transition: none; }

.cxg__slide {
	flex: 0 0 100%;
	max-width: 100%;
	touch-action: pan-y;
}

.cxg__figure { margin: 0; }

.cxg__media {
	position: relative;
	box-sizing: border-box;
	overflow: hidden;
	border-radius: var(--cxg-rad);
	background: var(--cxg-frame-bg);
	height: var(--cxg-h);
}

.cxg--ratio .cxg__media {
	height: auto;
	aspect-ratio: var(--cxg-ratio);
}

/* ---------- 높이 고정 · 원본 비율 (잘림 없음) ----------
   활성 사진이 화면 정중앙, 좌우 사진은 남는 폭만큼 걸쳐 보입니다.
   비활성 사진을 흐리게 하지 않습니다.
   --cxg-arn(사진의 가로/세로 비)을 숏코드가 슬라이드마다 인라인으로 넣습니다.
   폭을 미리 계산할 수 있어 이미지가 늦게 떠도 레이아웃이 밀리지 않습니다. */
.cxg--auto .cxg__viewport {
	overflow: visible;
	clip-path: inset(-30px calc(50% - 50vw) -80px calc(50% - 50vw));
}

/* 컨테이너 폭에 맞춤 — 바깥으로 흘러나가는 부분을 잘라냅니다 */
.cxg--contain .cxg__viewport {
	overflow: hidden;
	clip-path: none;
}

.cxg--auto .cxg__slide {
	flex: 0 0 auto;
	max-width: none;
	padding: 0 calc(var(--cxg-gap) / 2);
	opacity: 1;
}

.cxg--auto .cxg__media {
	width: calc(var(--cxg-h) * var(--cxg-arn, 1.5));
	height: var(--cxg-h);
}

.cxg--auto .cxg__caption {
	max-width: calc(var(--cxg-h) * var(--cxg-arn, 1.5));
}

/* 캡션 표시 방식 — 현재 사진만 / 전부 / 표시 안 함 */
.cxg--cap-active .cxg__slide:not(.is-active) .cxg__caption { visibility: hidden; }
.cxg--cap-none .cxg__caption { display: none; }

/* 프레임 채우기 — 테마가 img 에 height:auto !important 를 거는 경우가 많아
   이 구간만 !important 로 되받습니다. 셀렉터는 클래스가 아닌 자식 img 기준. */
.cxg .cxg__media > img,
.cxg .cxg__thumb-media > img {
	position: absolute !important;
	top: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	left: 0 !important;
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	min-width: 0 !important;
	min-height: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
	object-fit: cover !important;
	-webkit-user-drag: none;
	user-select: none;
}

.cxg__caption {
	margin-top: 14px;
	text-align: center;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: -0.01em;
}

/* ---------- 장수 표시 ---------- */
.cxg__counter {
	position: absolute;
	right: calc(50% - var(--cxg-half));
	top: calc(var(--cxg-h) - 42px);
	z-index: 2;
	margin: 0;
	padding: 2px 11px;
	border-radius: 999px;
	background: rgba(35, 32, 31, 0.66);
	color: #fff;
	font-size: 12px;
	font-variant-numeric: tabular-nums;
}

.cxg--ratio .cxg__counter { top: auto; bottom: 54px; }

/* ---------- 좌우 버튼 ---------- */
.cxg__nav {
	position: absolute;
	top: calc(var(--cxg-h) / 2);
	z-index: 3;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	margin-top: -22px;
	padding: 0;
	border: 1px solid var(--cxg-line);
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.94);
	color: var(--cxg-ink);
	cursor: pointer;
}

.cxg--ratio .cxg__nav { top: 40%; }

.cxg__nav svg {
	width: 19px; height: 19px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.cxg__nav:hover { border-color: var(--cxg-ink); }
.cxg__nav--prev { left: calc(50% - var(--cxg-half)); }
.cxg__nav--next { right: calc(50% - var(--cxg-half)); }
.cxg__nav[disabled] { opacity: 0.28; cursor: default; }

/* ---------- 썸네일 레일 ---------- */
.cxg__thumbs {
	margin-top: 18px;
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	/* touch-action 을 건드리지 않습니다. 기본값이라야 브라우저가 가로 스크롤을 처리합니다 */
}

.cxg__thumbs::-webkit-scrollbar { display: none; }

/* width:max-content + margin auto → 적으면 가운데, 많으면 스크롤 */
.cxg__thumbs-inner {
	display: flex;
	gap: var(--cxg-tgap);
	width: max-content;
	min-width: 100%;
	margin: 0 auto;
	padding: 2px 0;
	justify-content: center;
}

.cxg__thumb {
	flex: 0 0 auto;
	/* JS가 레일의 실제 폭을 재서 --cxg-tw 를 넣습니다.
	   vw 기반 계산은 스크롤바·테마 여백 때문에 몇 px씩 어긋나 마지막 썸네일이 잘립니다. */
	width: var(--cxg-tw, calc(
		(min(100vw - var(--cxg-pad) * 2, var(--cxg-max) - var(--cxg-pad) * 2)
		- (var(--cxg-n) - 1) * var(--cxg-tgap)) / var(--cxg-n)
	));
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
	text-align: center;
	-webkit-tap-highlight-color: transparent;
}

.cxg__thumb-media {
	position: relative;
	display: block;
	box-sizing: border-box;
	overflow: hidden;
	border: var(--cxg-abw) solid transparent;   /* 비활성은 자리만 차지 */
	border-radius: var(--cxg-trad);
	background: var(--cxg-frame-bg);
	aspect-ratio: 3 / 2;
	transition: border-color 0.2s ease;
}

.cxg .cxg__thumb-img {
	object-fit: cover;      /* 여백 없이 채웁니다 */
	object-position: center;
	opacity: 0.62;
	transition: opacity 0.2s ease;
}

.cxg__thumb-label {
	display: block;
	margin-top: 6px;
	overflow: hidden;
	font-size: 11.5px;
	line-height: 1.35;
	color: var(--cxg-muted);
	white-space: nowrap;
	text-overflow: ellipsis;
	transition: color 0.2s ease;
}

.cxg__thumb.is-active .cxg__thumb-media { border-color: var(--cxg-accent); }   /* 선택된 것만 */
.cxg .cxg__thumb.is-active .cxg__thumb-img { opacity: 1; }
.cxg__thumb.is-active .cxg__thumb-label { color: var(--cxg-ink); font-weight: 600; }

.cxg--nolabel .cxg__thumb-label { display: none; }

/* ---------- 하단 불릿 ---------- */
/* 썸네일 줄 아래 */
.cxg__dots {
	display: flex;
	justify-content: center;
	gap: 6px;
	margin-top: 16px;
}

.cxg__dot {
	width: 22px;
	height: 3px;
	padding: 0;
	border: 0;
	border-radius: 2px;
	background: var(--cxg-line);
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.cxg__dot.is-active { background: var(--cxg-accent); }

.cxg__thumb:focus-visible .cxg__thumb-media,
.cxg__nav:focus-visible { outline: 2px solid var(--cxg-accent); outline-offset: 2px; }

.cxg__sr {
	position: absolute;
	width: 1px; height: 1px;
	margin: -1px; padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

/* ==================================================================
   PC — 좌우 반쪽 노출
   ================================================================== */
@media (min-width: 769px) {

	.cxg .cxg__title { font-size: 38px; }

	.cxg__head { margin-bottom: 40px; text-align: center; }
	.cxg__lead { margin: 0 auto; text-align: center; }

	.cxg__caption { margin-top: 18px; font-size: 17px; }

	.cxg--peek:not(.cxg--auto) .cxg__viewport {
		overflow: visible;
		clip-path: inset(-40px calc(50% - 50vw) -60px calc(50% - 50vw));
	}

	/* 컨테이너 맞춤이 항상 우선 */
	.cxg--contain .cxg__viewport {
		overflow: hidden;
		clip-path: none;
	}

	.cxg--peek:not(.cxg--auto) .cxg__slide {
		flex: 0 0 58%;
		max-width: 58%;
		padding: 0 10px;
		opacity: 0.3;
		transition: opacity 0.5s ease;
	}

	.cxg--peek:not(.cxg--auto) .cxg__slide.is-active { opacity: 1; }

	.cxg--cap-active.cxg--peek:not(.cxg--auto) .cxg__caption {
		opacity: 0;
		transition: opacity 0.4s ease;
	}

	.cxg--cap-active.cxg--peek:not(.cxg--auto) .cxg__slide.is-active .cxg__caption { opacity: 1; }

	.cxg--peek:not(.cxg--auto) .cxg__nav--prev { left: 16%; }
	.cxg--peek:not(.cxg--auto) .cxg__nav--next { right: 16%; }
	.cxg--peek:not(.cxg--auto) .cxg__counter { right: 22.5%; }

	/* 원본 비율 모드: 폭이 사진마다 달라 % 좌표를 쓸 수 없습니다.
	   JS가 현재 사진의 실제 폭을 --cxg-aw 로 넘겨주고, 버튼·카운터를 그 가장자리에 붙입니다. */
	/* 원본 비율 모드는 사진마다 폭이 달라 사진에 물리면 화살표가 매번 움직입니다.
	   컨테이너 기준 고정 좌표(--cxg-half)를 그대로 씁니다. */

	.cxg__thumbs { margin-top: 24px; }
}

@media (prefers-reduced-motion: reduce) {
	.cxg__track, .cxg__slide, .cxg__caption,
	.cxg__thumb-media, .cxg__thumb-img, .cxg__thumb-label { transition: none !important; }
}
