/**
 * Front-page photo-frame collage.
 * Artboard: 2093 × 5375 — stage and frames share the same percentage space.
 */

.hds-home-collage {
	display: block;
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	line-height: 0;
	box-sizing: border-box;
}

.hds-home-collage__stage {
	position: relative;
	width: 100%;
	aspect-ratio: var(--artboard-w, 2093) / var(--artboard-h, 5375);
	overflow: hidden;
	background-color: #f3f2ef;
	container-type: inline-size;
	container-name: hds-collage;
}

.hds-home-collage__bg {
	display: block;
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	/* top_back.jpg matches artboard aspect (≈2093/5375); fill stage exactly. */
	object-fit: fill;
	object-position: center top;
	z-index: 1;
	pointer-events: none;
	user-select: none;
}

.hds-home-collage__bg--placeholder {
	background: #f3f2ef;
}

.hds-home-collage__frames {
	position: absolute;
	inset: 0;
	z-index: 2;
	pointer-events: none;
}

/* —— Frame shell —— */
.hds-photo-frame {
	position: absolute;
	left: var(--frame-x);
	top: var(--frame-y);
	width: var(--frame-w);
	aspect-ratio: 1 / var(--frame-ratio);
	z-index: var(--frame-z);
	transform: rotate(var(--frame-rotate));
	transform-origin: center center;
	pointer-events: none;
	text-decoration: none;
	color: inherit;
}

.hds-photo-frame--link {
	pointer-events: auto;
	cursor: pointer;
	-webkit-user-drag: none;
}

/* Figma 586:3496: transparent captions, positioned independently of photos. */
.hds-home-collage__popups {
	position: absolute;
	inset: 0;
	z-index: 50;
	pointer-events: none;
}

.hds-collage-popup {
	--underline-scale: 0;
	--underline-delay: 0s;
	position: absolute;
	left: var(--popup-x);
	top: var(--popup-y);
	width: max-content;
	display: block;
	margin: 0;
	padding: 0;
	background: transparent;
	color: #000;
	text-decoration: none;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	cursor: pointer;
	/* Brief grace period when moving from a photo to its nearby caption. */
	transition: opacity .18s ease .18s, visibility 0s linear .36s;
}

.hds-collage-popup:focus-visible {
	outline: 2px solid #000;
	outline-offset: 4px;
}

.hds-collage-popup__title {
	display: flex;
	flex-direction: column;
	gap: .4em;
	margin: 0;
	padding: 0;
	font-family: "Noto Serif JP", serif;
	font-weight: 400;
	font-size: calc(13 / 2093 * 100cqw);
	line-height: 1.2;
	letter-spacing: 0;
	text-align: left;
	white-space: normal;
	/* Keep the final line box intact so every underline has the same gap. */
	text-box-trim: none;
}

.hds-collage-popup__line {
	position: relative;
	display: block;
	width: fit-content;
	min-height: 1em;
	padding-bottom: .2em;
	white-space: pre;
}

.hds-collage-popup__line::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	/* Each line reserves its own text-to-underline spacing. */
	bottom: 0;
	/* Borders snap thin strokes to device pixels; filled fractional heights
	 * can rasterize differently between lines. */
	height: 0;
	border-bottom: .5px solid currentColor;
	transform: scaleX(var(--underline-scale));
	transform-origin: left center;
	transition: transform .45s cubic-bezier(.65, 0, .35, 1);
	/* Start drawing after the caption has finished fading in. */
	transition-delay: var(--underline-delay);
}

.hds-collage-popup__latin {
	font-family: "Cormorant Garamond", serif;
	font-size: calc(16 / 13 * 1em);
	line-height: 0;
}

@media (prefers-reduced-motion: reduce) {
	.hds-collage-popup,
	.hds-collage-popup__line::after {
		transition: none !important;
	}
}

.hds-photo-frame__shadow,
.hds-photo-frame__frame,
.hds-photo-frame__seal {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: fill;
	pointer-events: none;
	user-select: none;
}

.hds-photo-frame__shadow {
	z-index: 1;
}

.hds-photo-frame__frame {
	z-index: 2;
	transition: filter 0.35s ease;
}

.hds-photo-frame__seal {
	z-index: 3;
}

/* Media window: photo / text + texture, SVG-masked */
.hds-photo-frame__media {
	position: absolute;
	left: var(--media-left);
	top: var(--media-top);
	width: var(--media-width);
	height: var(--media-height);
	z-index: 4;
	overflow: hidden;
	-webkit-mask-image: var(--mask-url);
	mask-image: var(--mask-url);
	-webkit-mask-size: 100% 100%;
	mask-size: 100% 100%;
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-position: center;
	mask-position: center;
	container-type: size;
}

.hds-photo-frame__photo {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	opacity: 0.8;
	/* Per-frame via --photo-sepia (0–1). Default: 0.3. */
	filter: sepia(var(--photo-sepia, 0.3));
	transition: filter 0.35s ease;
	z-index: 1;
	pointer-events: none;
	user-select: none;
	transform: rotate(var(--photo-rotate, 0deg));
	transform-origin: center center;
}

@media (hover: hover) {
	.hds-home-collage:not(.hds-home-collage--no-hover) .hds-photo-frame--link:hover .hds-photo-frame__photo {
		filter: sepia(var(--photo-sepia, 0.3)) brightness(1.08);
	}

	.hds-home-collage:not(.hds-home-collage--no-hover) .hds-photo-frame--link:hover .hds-photo-frame__frame {
		filter: brightness(1.06);
	}
}

.hds-home-collage:not(.hds-home-collage--no-hover) .hds-photo-frame--link:focus-visible .hds-photo-frame__photo {
	filter: sepia(var(--photo-sepia, 0.3)) brightness(1.08);
}

.hds-home-collage:not(.hds-home-collage--no-hover) .hds-photo-frame--link:focus-visible .hds-photo-frame__frame {
	filter: brightness(1.06);
}

/* No.5: Figma photo layer size/position inside media AABB (not full-bleed cover). */
.hds-photo-frame--05 .hds-photo-frame__photo {
	inset: auto;
	left: var(--photo-left);
	top: var(--photo-top);
	width: var(--photo-width);
	height: var(--photo-height);
	right: auto;
	bottom: auto;
}

/* Texture PNG is full-frame; mask to the same media window as the photo. */
.hds-photo-frame__texture {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: fill;
	opacity: var(--texture-opacity, 0.7);
	z-index: 5;
	pointer-events: none;
	user-select: none;
	-webkit-mask-image: var(--mask-url);
	mask-image: var(--mask-url);
	-webkit-mask-size: var(--media-width) var(--media-height);
	mask-size: var(--media-width) var(--media-height);
	-webkit-mask-position: var(--media-left) var(--media-top);
	mask-position: var(--media-left) var(--media-top);
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
}

/*
 * No.1–38: texture inside .hds-photo-frame__media so photo + texture share
 * one SVG mask. Full-frame mapping via inverse insets; parent clips.
 */
.hds-photo-frame--01 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--02 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--03 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--04 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--05 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--06 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--07 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--08 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--09 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--10 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--11 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--12 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--13 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--14 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--15 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--16 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--17 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--18 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--19 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--20 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--21 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--22 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--23 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--24 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--25 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--26 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--27 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--28 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--29 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--30 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--31 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--32 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--33 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--34 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--35 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--36 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--37 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--38 .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--message .hds-photo-frame__media .hds-photo-frame__texture,
.hds-photo-frame--circle .hds-photo-frame__media .hds-photo-frame__texture {
	inset: auto;
	left: calc(var(--media-left-f) / var(--media-width-f) * -100%);
	top: calc(var(--media-top-f) / var(--media-height-f) * -100%);
	width: calc(100% / var(--media-width-f));
	height: calc(100% / var(--media-height-f));
	z-index: 2;
	-webkit-mask-image: none;
	mask-image: none;
}

/* Decor (message / circle): texture only inside media, no photo, no CSS sepia */
.hds-photo-frame--decor .hds-photo-frame__photo {
	display: none;
}

/* No.18 text card (差し替えボード Group 88) */
.hds-photo-frame__text-card {
	position: absolute;
	inset: 0;
	z-index: 1;
	box-sizing: border-box;
	background-color: #eeebe5;
	color: #000;
	font-family: "Noto Serif JP", serif;
	font-weight: 400;
	/* Figma: 18.396px / 441px card width, line-height 35px */
	font-size: calc(18.396 / 441 * 100cqw);
	line-height: calc(35 / 18.396);
	letter-spacing: 0;
	text-align: left;
	/* Padding ratios from 差し替えボード Group 88 (441×441). */
	padding: 15.368% 9.904% 13.203% 11.66%;
	overflow: hidden;
}

.hds-photo-frame__text-card p {
	margin: 0;
	padding: 0;
}

/* Text card: still show texture over text like other frames */
.hds-photo-frame--text .hds-photo-frame__texture {
	z-index: 2;
}

/* Adjustment page: photos/bg are hittable so they can be dragged. */
body.hds-page-collage-preview .hds-home-collage__bg,
body.hds-page-collage-preview .hds-photo-frame__photo {
	pointer-events: auto;
	user-select: auto;
	-webkit-user-drag: auto;
}

/* Figma 591:4134 — centred mobile canvas with room to explore both sides. */
.hds-collage-gesture-hint {
	display: none;
}

@media screen and (max-width: 781px) {
	/* viewport-fit=cover enables edge-to-edge painting; protect actual UI. */
	body.hds-page-interactive-collage {
		padding-top: env(safe-area-inset-top, 0px);
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}

	/* Anchor controls to the viewport, outside the zoomable collage. */
	body.hds-page-interactive-collage .hds-header {
		position: fixed;
		top: env(safe-area-inset-top, 0px);
		left: 0;
		right: 0;
	}

	/* The transparent header must not intercept captions behind its gaps. */
	body.hds-page-interactive-collage .hds-header,
	body.hds-page-interactive-collage .hds-header__inner {
		pointer-events: none;
	}

	body.hds-page-interactive-collage .hds-header__drawer-close {
		top: calc(6px + env(safe-area-inset-top, 0px));
	}

	.hds-home-collage[data-collage-mobile] {
		--collage-mobile-scale: 2.5249;
		overflow-x: auto;
		overflow-y: hidden;
		overscroll-behavior-x: contain;
		scrollbar-width: none;
		/* One gesture updates both axes; native scrolling locks to one axis. */
		touch-action: none;
		overflow-anchor: none;
	}

	.hds-home-collage[data-collage-mobile]::-webkit-scrollbar {
		display: none;
	}

	.hds-home-collage[data-collage-mobile] .hds-home-collage__stage {
		width: calc(100% * var(--collage-mobile-scale));
		max-width: none;
	}

	body.hds-page-interactive-collage .hds-photo-frame--link,
	body.hds-page-interactive-collage .hds-photo-frame__photo,
	body.hds-page-interactive-collage .hds-home-collage__bg {
		user-select: none;
		-webkit-user-drag: none;
	}

	/* The header stays in the phone viewport while the collage pans/zooms. */
	body.hds-page-interactive-collage .hds-header__inner {
		min-height: 60px;
		padding: 10px max(32px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
	}

	body.hds-page-interactive-collage .hds-header__logo,
	body.hds-page-interactive-collage .hds-header__logo img {
		width: 38.117px;
		height: 39.9px;
	}

	body.hds-page-interactive-collage .hds-header__menu-toggle {
		align-self: flex-start;
		margin-top: 9px;
	}

	/* Larger mobile captions wrap inside the visible screen, even when zoomed. */
	.hds-home-collage[data-collage-mobile] .hds-collage-popup {
		left: var(--popup-mobile-x, var(--popup-x));
		top: var(--popup-mobile-y, var(--popup-y));
		max-width: var(--popup-mobile-max-width, calc(100vw - 24px));
		transform: translate(var(--popup-mobile-shift-x, 0px), var(--popup-mobile-shift-y, 0px));
	}

	.hds-home-collage[data-collage-mobile] .hds-collage-popup__title {
		font-size: calc(20.8 / 2093 * 100cqw);
	}

	.hds-home-collage[data-collage-mobile] .hds-collage-popup__line {
		max-width: 100%;
		box-sizing: border-box;
		white-space: pre-wrap;
		overflow-wrap: anywhere;
	}

	/* First mobile tap previews the same caption/highlight as desktop hover. */
	.hds-home-collage[data-collage-mobile] .hds-collage-popup.is-tap-active {
		--underline-scale: 1;
		--underline-delay: .2s;
		opacity: var(--text-opacity, 1);
		visibility: visible;
		pointer-events: auto;
		transition: opacity .2s ease, visibility 0s;
	}

	.hds-home-collage[data-collage-mobile] .hds-photo-frame.is-tap-active .hds-photo-frame__photo {
		filter: sepia(var(--photo-sepia, 0.3)) brightness(1.18);
	}

	.hds-home-collage[data-collage-mobile] .hds-photo-frame.is-tap-active .hds-photo-frame__frame {
		filter: brightness(1.1);
	}

	.hds-collage-gesture-hint {
		/* Extend the shade into the area revealed behind Safari's toolbar.
		 * Keep the icon anchored to its existing safe visible position. */
		--hint-bottom-bleed: max(env(safe-area-inset-bottom, 0px), calc(100lvh - 100svh));
		position: fixed;
		inset: 0;
		z-index: 60;
		display: block;
		pointer-events: none;
		opacity: 0;
		visibility: hidden;
		transition: opacity .4s ease, visibility 0s linear .4s;
	}

	.hds-collage-gesture-hint.is-visible {
		opacity: 1;
		visibility: visible;
		transition: opacity .4s ease;
	}

	.hds-collage-gesture-hint__shade {
		/* Temporarily hide the backdrop while keeping the arrow animation. */
		display: none;
		position: absolute;
		inset: auto 0 calc(-1 * var(--hint-bottom-bleed));
		height: calc(min(38.2svh, 334px) + var(--hint-bottom-bleed));
		/* Equivalent to the Figma white-to-#898989 multiply gradient. */
		background: linear-gradient(to bottom, transparent, rgb(0 0 0 / .463));
	}

	/* Figma 602:7838 — 94.368px box, centred 33px above the lower edge. */
	.hds-collage-gesture-hint__arrows {
		position: absolute;
		left: calc(50% - 47.184px);
		bottom: max(33px, calc(env(safe-area-inset-bottom) + 20px));
		width: 94.368px;
		height: 94.368px;
	}

	.hds-collage-gesture-hint__axis {
		position: absolute;
		inset: 0;
		opacity: 1;
	}

	.hds-collage-gesture-hint__axis--horizontal {
		transform: rotate(90deg);
		opacity: 1;
	}

	.hds-collage-gesture-hint__pair {
		position: absolute;
		left: calc(50% - 4.09454px);
		top: calc(50% - 35.943px + .69px);
		width: 8.18908px;
		height: 71.886px;
	}

	/* Clip the original SVG into two halves so its arrowheads never stretch. */
	.hds-collage-gesture-hint__half {
		position: absolute;
		left: 0;
		width: 8.18908px;
		height: 35.943px;
		overflow: hidden;
		transform: translateY(var(--gesture-inward));
	}

	.hds-collage-gesture-hint__half--start {
		--gesture-inward: 7px;
		top: 0;
	}

	.hds-collage-gesture-hint__half--end {
		--gesture-inward: -7px;
		bottom: 0;
	}

	.hds-collage-gesture-hint__half img {
		position: absolute;
		left: 0;
		display: block;
		max-width: none;
	}

	.hds-collage-gesture-hint__half--start img { top: 0; }
	.hds-collage-gesture-hint__half--end img { bottom: 0; }

	/* Figma 602:8337 — all four arrows expand and contract together twice. */
	.hds-collage-gesture-hint.is-visible .hds-collage-gesture-hint__half {
		animation: hds-gesture-spread 1.05s ease-in-out .4s 2 both;
	}
}

@keyframes hds-gesture-spread {
	0%, 100% { transform: translateY(var(--gesture-inward)); }
	50% { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
	.hds-collage-gesture-hint { transition: none; }
	.hds-collage-gesture-hint .hds-collage-gesture-hint__axis,
	.hds-collage-gesture-hint .hds-collage-gesture-hint__half {
		animation: none !important;
		opacity: 1;
		transform: none;
	}
	.hds-collage-gesture-hint .hds-collage-gesture-hint__axis--horizontal {
		transform: rotate(90deg);
	}
}
