/* Cat House Flick Galleries v1.0.0 */
:root {
	--chm-fg-black: #000;
	--chm-fg-white: #fff;
	--chm-fg-soft: rgba(255, 255, 255, .72);
	--chm-fg-line: rgba(255, 255, 255, .28);
	--chm-fg-serif: "Didot", "Bodoni 72", "Bodoni MT", "Playfair Display", Georgia, "Times New Roman", serif;
}

/* Old grid: hidden, or kept as tappable thumbnails */
[data-chm-fg="hidden"] { display: none !important; }
.chm-fg-tappable { cursor: zoom-in; }

/* ---------- Cover card in the article ---------- */
.chm-fg-wrap { margin: 1.5em 0; max-width: 100%; }

.chm-fg-cover {
	position: relative;
	display: block;
	overflow: hidden;
	background: var(--chm-fg-black);
	cursor: pointer;
	aspect-ratio: 4 / 5;
	max-height: 82vh;
	width: 100%;
	-webkit-tap-highlight-color: transparent;
}
.chm-fg-cover-img {
	position: absolute; inset: 0;
	width: 100% !important; height: 100% !important; max-width: none !important;
	object-fit: cover; object-position: 50% 25%;
	margin: 0 !important;
	transition: transform .6s ease;
}
.chm-fg-cover::after {
	content: ""; position: absolute; inset: 0;
	background: linear-gradient(to top, rgba(0, 0, 0, .78) 0%, rgba(0, 0, 0, .2) 38%, transparent 60%);
	pointer-events: none;
}
.chm-fg-cover-text {
	position: absolute; left: 0; right: 3.5rem; bottom: 0; z-index: 1;
	padding: 1.4rem 1.25rem;
	color: var(--chm-fg-white);
	display: flex; flex-direction: column; gap: .35rem;
}
.chm-fg-cover-title {
	font-family: var(--chm-fg-serif);
	font-size: clamp(1.9rem, 6vw, 3.2rem);
	line-height: 1.02;
	letter-spacing: -.01em;
}
.chm-fg-cover-sub { font-size: .95rem; color: var(--chm-fg-soft); }

/* The one motion moment: a thin line rising, telling people to swipe up */
.chm-fg-cover-swipe {
	position: absolute; right: 1.4rem; bottom: 1.6rem; z-index: 1;
	width: 1px; height: 3.2rem;
	background: var(--chm-fg-line);
	overflow: hidden;
}
.chm-fg-cover-swipe::after {
	content: ""; position: absolute; left: 0; width: 1px; height: 40%;
	background: var(--chm-fg-white);
	animation: chm-fg-rise 1.8s ease-in-out infinite;
}
@keyframes chm-fg-rise { from { top: 100%; } to { top: -40%; } }

.chm-fg-cover:focus-visible, .chm-fg-thumb:focus-visible { outline: 2px solid var(--chm-fg-white); outline-offset: 3px; }

.chm-fg-strip {
	display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px;
	margin-top: 3px;
}
.chm-fg-thumb {
	position: relative; display: block;
	padding: 0; margin: 0; border: 0; border-radius: 0;
	background: var(--chm-fg-black);
	aspect-ratio: 1 / 1; overflow: hidden; cursor: pointer;
}
.chm-fg-thumb img {
	width: 100% !important; height: 100% !important; max-width: none !important;
	object-fit: cover; object-position: 50% 25%; margin: 0 !important; display: block;
}
.chm-fg-more {
	position: absolute; inset: 0;
	display: flex; align-items: center; justify-content: center;
	background: rgba(0, 0, 0, .55);
	color: var(--chm-fg-white);
	font-family: var(--chm-fg-serif); font-size: 1.6rem;
}

@media (hover: hover) {
	.chm-fg-cover:hover .chm-fg-cover-img { transform: scale(1.025); }
}
@media (min-width: 900px) {
	.chm-fg-cover { aspect-ratio: 3 / 2; }
}

/* ---------- Full-screen viewer ---------- */
html.chm-fg-lock, html.chm-fg-lock body { overflow: hidden !important; overscroll-behavior: none; }

.chm-fg-viewer {
	position: fixed; inset: 0; z-index: 2147483000;
	background: var(--chm-fg-black);
	color: var(--chm-fg-white);
	display: none;
}
.chm-fg-viewer.chm-fg-open { display: block; }

.chm-fg-feed {
	position: absolute; inset: 0;
	overflow-y: auto; overflow-x: hidden;
	scroll-snap-type: y mandatory;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	outline: none;
}
.chm-fg-feed::-webkit-scrollbar { display: none; }

.chm-fg-slide {
	position: relative;
	height: 100vh; height: 100dvh;
	scroll-snap-align: start; scroll-snap-stop: always;
	display: flex; align-items: center; justify-content: center;
	overflow: hidden;
}
.chm-fg-slide img {
	width: 100%; height: 100%;
	object-fit: contain;
	opacity: 0; transition: opacity .25s ease;
	user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.chm-fg-slide.chm-fg-ready img { opacity: 1; }

/* Top bar */
.chm-fg-bar {
	position: absolute; top: 0; left: 0; right: 0; z-index: 2;
	display: flex; align-items: center; gap: 1rem;
	padding: max(.9rem, env(safe-area-inset-top)) 1rem .9rem 1.1rem;
	background: linear-gradient(to bottom, rgba(0, 0, 0, .6), transparent);
	pointer-events: none;
}
.chm-fg-title {
	flex: 1; min-width: 0;
	font-family: var(--chm-fg-serif); font-size: 1.15rem;
	white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chm-fg-count { font-size: .85rem; color: var(--chm-fg-soft); font-variant-numeric: tabular-nums; }
.chm-fg-close {
	pointer-events: auto;
	position: relative; width: 2.75rem; height: 2.75rem;
	border: 0; border-radius: 50%; padding: 0;
	background: rgba(0, 0, 0, .35); cursor: pointer;
}
.chm-fg-close span::before, .chm-fg-close span::after {
	content: ""; position: absolute; left: 50%; top: 50%;
	width: 1.1rem; height: 1.5px; background: var(--chm-fg-white);
}
.chm-fg-close span::before { transform: translate(-50%, -50%) rotate(45deg); }
.chm-fg-close span::after { transform: translate(-50%, -50%) rotate(-45deg); }

/* Desktop up/down buttons */
.chm-fg-nav {
	position: absolute; right: 1.5rem; top: 50%; z-index: 2;
	transform: translateY(-50%);
	display: none; flex-direction: column; gap: .75rem;
}
.chm-fg-nav button {
	position: relative; width: 3rem; height: 3rem;
	border: 1px solid var(--chm-fg-line); border-radius: 50%; padding: 0;
	background: rgba(0, 0, 0, .35); cursor: pointer;
	transition: border-color .2s ease;
}
.chm-fg-nav button::before {
	content: ""; position: absolute; left: 50%; top: 50%;
	width: .65rem; height: .65rem;
	border-left: 1.5px solid var(--chm-fg-white); border-top: 1.5px solid var(--chm-fg-white);
}
.chm-fg-prev::before { transform: translate(-50%, -25%) rotate(45deg); }
.chm-fg-next::before { transform: translate(-50%, -75%) rotate(225deg); }
.chm-fg-nav button:hover { border-color: var(--chm-fg-white); }
.chm-fg-close:focus-visible, .chm-fg-nav button:focus-visible, .chm-fg-end a:focus-visible, .chm-fg-end button:focus-visible {
	outline: 2px solid var(--chm-fg-white); outline-offset: 3px;
}

/* First-screen hint, gone once they move */
.chm-fg-hint {
	position: absolute; left: 50%; bottom: max(1.6rem, env(safe-area-inset-bottom)); z-index: 2;
	transform: translateX(-50%);
	font-size: .85rem; color: var(--chm-fg-soft);
	pointer-events: none; transition: opacity .3s ease;
}
.chm-fg-moved .chm-fg-hint { opacity: 0; }

/* Last screen */
.chm-fg-end {
	flex-direction: column; gap: .9rem;
	padding: 2rem; text-align: center;
}
.chm-fg-end p { margin: 0; }
.chm-fg-end-title { font-family: var(--chm-fg-serif); font-size: clamp(2.2rem, 7vw, 3.6rem); line-height: 1.05; }
.chm-fg-end-sub { color: var(--chm-fg-soft); max-width: 32ch; }
.chm-fg-end-btn {
	margin-top: .8rem;
	display: inline-block; padding: .95rem 1.6rem;
	background: var(--chm-fg-white); color: var(--chm-fg-black) !important;
	text-decoration: none !important; font-weight: 600;
}
.chm-fg-end-back {
	border: 0; background: none; padding: .6rem;
	color: var(--chm-fg-soft); text-decoration: underline; cursor: pointer; font: inherit;
}

@media (min-width: 900px) and (hover: hover) {
	.chm-fg-nav { display: flex; }
	.chm-fg-hint { display: none; }
	.chm-fg-bar { padding-left: 2rem; padding-right: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
	.chm-fg-cover-swipe::after { animation: none; top: 30%; }
	.chm-fg-cover-img, .chm-fg-slide img { transition: none; }
	.chm-fg-feed { scroll-behavior: auto; }
}
