/* hoponline.ch Gallery. Colours and sizes are custom properties, so a page
   can restyle it, e.g. `.my-section { --hopg-accent: #000; }`.
   Defaults match the DDM Massage site (cream text, sand accent, dark cards);
   it is made for a dark background. */

.wp-block-gallery.is-style-hop-carousel,
.hopg-ui,
.hopg-lightbox {
	--hopg-card: clamp(240px, 72vw, 380px);
	--hopg-ratio: 3 / 4;
	--hopg-radius: clamp(1.25rem, 2.5vw, 2rem);
	--hopg-text: #f3ede1;
	--hopg-mute: #957b64;
	--hopg-gold: #dbb18e;
	--hopg-accent: #dbb18e;
	--hopg-card-bg: #3a3029;
	--hopg-line: rgba(243, 237, 225, 0.14);
	--hopg-serif: var(--global-heading-font-family, 'Cormorant Garamond', Georgia, serif);
	--hopg-sans: var(--global-body-font-family, 'DM Sans', system-ui, sans-serif);
	--hopg-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Photos can't be dragged out or long-press saved on phones. */
.wp-block-gallery.is-style-hop-carousel img,
.hopg-lightbox img {
	-webkit-user-drag: none;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
}

/* ---------- Carousel ---------- */

/* Core Gallery uses flex-wrap + width rules with an ID in :not(), hence the !important.
   Side padding lets the first and last card reach the centre. */
.wp-block-gallery.is-style-hop-carousel {
	display: flex !important;
	flex-wrap: nowrap !important;
	align-items: center;
	gap: clamp(0.9rem, 2vw, 1.75rem) !important;
	width: 100%;
	padding: 1rem calc(50% - var(--hopg-card) / 2) 1.5rem !important;
	box-sizing: border-box;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	counter-reset: hopg-card;
	cursor: grab;
	-webkit-user-select: none;
	user-select: none;
}
/* Full width: bleed to the screen edges. */
.wp-block-gallery.is-style-hop-carousel.alignfull {
	width: 100vw;
	max-width: 100vw;
	margin-left: calc(50% - 50vw) !important;
	margin-right: calc(50% - 50vw) !important;
	padding-left: calc(50vw - var(--hopg-card) / 2) !important;
	padding-right: calc(50vw - var(--hopg-card) / 2) !important;
}
.wp-block-gallery.is-style-hop-carousel::-webkit-scrollbar { display: none; }
.wp-block-gallery.is-style-hop-carousel.is-dragging { cursor: grabbing; }
.wp-block-gallery.is-style-hop-carousel.is-dragging a { pointer-events: none; }
.wp-block-gallery.is-style-hop-carousel.is-gliding { scroll-snap-type: none; }
.wp-block-gallery.is-style-hop-carousel:focus-visible { outline: 2px solid var(--hopg-gold); outline-offset: 4px; }

/* Cards: carousel.js sets --d (0 = centred, 1 = a card or more away). */
.wp-block-gallery.is-style-hop-carousel > .wp-block-image {
	position: relative;
	flex: 0 0 var(--hopg-card) !important;
	width: var(--hopg-card) !important;
	aspect-ratio: var(--hopg-ratio);
	margin: 0 !important;
	overflow: hidden;
	scroll-snap-align: center;
	background: var(--hopg-card-bg);
	border-radius: var(--hopg-radius);
	box-shadow: 0 0 0 1px rgba(184, 153, 106, calc(0.35 * (1 - var(--d, 1)))), 0 24px 50px rgba(0, 0, 0, 0.45);
	counter-increment: hopg-card;
	opacity: calc(1 - var(--d, 0) * 0.45) !important;
	transform: scale(calc(1 - var(--d, 0) * 0.12)) !important;
	transition: none !important;
}
.wp-block-gallery.is-style-hop-carousel > .wp-block-image a { display: block; height: 100%; -webkit-user-drag: none; }
.wp-block-gallery.is-style-hop-carousel > .wp-block-image img {
	width: 100% !important;
	height: 100% !important;
	object-fit: cover !important;
	border-radius: 0 !important;
	filter: grayscale(calc(var(--d, 0) * 0.9)) !important;
	transform: scale(calc(1.08 - var(--d, 0) * 0.08));
	transition: none;
	-webkit-user-drag: none;
	pointer-events: none;
}
.wp-block-gallery.is-style-hop-carousel > .wp-block-image figcaption { display: none; }
/* Card number, bottom-left, over a soft shade. */
.wp-block-gallery.is-style-hop-carousel > .wp-block-image::before {
	content: counter(hopg-card, decimal-leading-zero);
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1;
	padding: 2.5rem 1.1rem 0.9rem;
	background: linear-gradient(transparent, rgba(13, 11, 10, 0.75));
	font-family: var(--hopg-serif);
	font-style: italic;
	font-size: 1.5rem;
	color: var(--hopg-text);
	opacity: calc(1 - var(--d, 0));
	pointer-events: none;
}
/* The card being shown in the lightbox (it flies back into this spot). */
.wp-block-gallery.is-style-hop-carousel > .wp-block-image.is-active img { visibility: hidden; }

/* Counter, progress line, arrows. */
.hopg-ui {
	display: flex;
	align-items: center;
	gap: 1rem;
	max-width: 38rem;
	margin: 0.75rem auto 0;
	padding: 0 1rem;
	font-family: var(--hopg-serif);
	font-style: italic;
	font-size: 1.15rem;
	color: var(--hopg-mute);
}
.hopg-ui__cur { color: var(--hopg-accent); min-width: 1.6em; }
.hopg-ui__bar {
	position: relative;
	flex: 1;
	height: 1px;
	background: var(--hopg-line);
	overflow: hidden;
}
.hopg-ui__bar span {
	position: absolute;
	inset: 0;
	background: var(--hopg-accent);
	transform-origin: left;
	transform: scaleX(var(--p, 0));
	transition: transform 0.4s var(--hopg-ease);
}
.hopg-ui__hint {
	font-family: var(--hopg-sans);
	font-style: normal;
	font-size: 0.68rem;
	letter-spacing: 0.28em;
	text-transform: uppercase;
	color: var(--hopg-gold);
	transition: opacity 0.4s;
}
.hopg-ui button {
	display: grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 1px solid rgba(242, 234, 223, 0.2);
	border-radius: 50%;
	background: transparent;
	color: var(--hopg-text);
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
	transition: background 0.3s, border-color 0.3s;
}
.hopg-ui button:hover { background: var(--hopg-accent); border-color: var(--hopg-accent); }
@media (hover: none) {
	.hopg-ui button { display: none; } /* swipe on touch screens */
}

/* ---------- Lightbox ---------- */

.hopg-lightbox { position: fixed; inset: 0; z-index: 100000; overscroll-behavior: contain; }
.hopg-lightbox[hidden] { display: none; }

.hopg-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background:
		radial-gradient(60% 50% at 50% 45%, rgba(192, 55, 55, 0.18), transparent 70%),
		rgba(10, 8, 7, 0.96);
	/* No backdrop-filter: blurring under an animated clip-path flickers on Android. */
}

.hopg-lightbox__stage {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 4.5rem 1rem 5.5rem;
	touch-action: none;
	cursor: grab;
}
.hopg-lightbox__stage.is-dragging { cursor: grabbing; }

.hopg-lightbox__img {
	display: block;
	max-width: none;
	object-fit: cover; /* size is set by carousel.js from the image's aspect ratio */
	border-radius: 0.9rem;
	box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(184, 153, 106, 0.3);
	user-select: none;
	-webkit-user-drag: none;
	will-change: transform;
}

/* Controls fade in after the image lands. */
.hopg-lightbox button,
.hopg-lightbox__count {
	opacity: 0;
	transition: opacity 0.4s var(--hopg-ease);
}
.hopg-lightbox.is-open button,
.hopg-lightbox.is-open .hopg-lightbox__count {
	opacity: 1;
	transition-delay: 0.35s;
}

.hopg-lightbox button {
	position: absolute;
	z-index: 1;
	display: grid;
	place-items: center;
	width: 3rem;
	height: 3rem;
	padding: 0;
	border: 1px solid rgba(242, 234, 223, 0.2);
	border-radius: 50%;
	background: rgba(13, 11, 10, 0.5);
	color: var(--hopg-text);
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
}
.hopg-lightbox.is-open button:hover { background: var(--hopg-accent); border-color: var(--hopg-accent); color: #fff; }
.hopg-lightbox__close { top: 1rem; right: 1rem; }
/* The × is two lines, so it sits dead centre (a glyph doesn't) and can animate. */
.hopg-lightbox__close::before,
.hopg-lightbox__close::after {
	content: "";
	grid-area: 1 / 1;
	width: 1.1rem;
	height: 2px;
	border-radius: 1px;
	background: currentColor;
	transform: rotate(45deg);
}
.hopg-lightbox__close::after { transform: rotate(-45deg); }
/* Closing: the cross spins a full turn and turns red, fading only at the end
   (the keyframes' opacity overrides the controls' quick fade-out). */
.hopg-lightbox.is-closing .hopg-lightbox__close {
	animation: hopg-x-out 0.55s cubic-bezier(0.5, 0, 0.3, 1) forwards;
	background: var(--hopg-accent);
	border-color: var(--hopg-accent);
	color: #fff;
}
@keyframes hopg-x-out {
	0% { transform: rotate(0) scale(1); opacity: 1; }
	70% { transform: rotate(270deg) scale(0.9); opacity: 1; }
	100% { transform: rotate(360deg) scale(0.4); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
	.hopg-lightbox.is-closing .hopg-lightbox__close { animation: none; }
}
.hopg-lightbox__prev { left: 1rem; top: 50%; margin-top: -1.5rem; }
.hopg-lightbox__next { right: 1rem; top: 50%; margin-top: -1.5rem; }
@media (max-width: 700px) {
	/* On phones you swipe; arrows move to the bottom corners. */
	.hopg-lightbox__prev,
	.hopg-lightbox__next { top: auto; bottom: 1.25rem; margin-top: 0; }
}

.hopg-lightbox__count {
	position: absolute;
	left: 50%;
	bottom: 1.75rem;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 0.9rem;
	margin: 0;
	font-family: var(--hopg-serif);
	font-style: italic;
	font-size: 1.25rem;
	color: var(--hopg-text);
	pointer-events: none;
}
.hopg-lightbox__cur { color: var(--hopg-accent); }
.hopg-lightbox__sep { width: 2.5rem; height: 1px; background: var(--hopg-gold); opacity: 0.6; }

/* ---------- Desktop: all photos in full colour ----------
   The photo in focus stays big in the centre, the others a little smaller,
   but none of them greyed out or faded. */
@media (min-width: 1025px) {
	.wp-block-gallery.is-style-hop-carousel > .wp-block-image { opacity: 1 !important; }
	.wp-block-gallery.is-style-hop-carousel > .wp-block-image img { filter: none !important; }
	.wp-block-gallery.is-style-hop-carousel > .wp-block-image::before { opacity: 1; }
	/* Room below the cards, so their soft shadow isn't cut off by the strip */
	.wp-block-gallery.is-style-hop-carousel { padding-bottom: 4.5rem !important; }
	.wp-block-gallery.is-style-hop-carousel + .hopg-ui { margin-top: -1.75rem; }
}
