/* FS Library — frontend
 * Two themes:
 *   .fs-library--theme-standard  → minimal, inherits theme typography/colors
 *   .fs-library--theme-cinematic → full-bleed FeatherSouls paper backdrop,
 *                                  Cormorant Garamond titles, dark cinematic
 *                                  player frames matching wedding-portal__gallery-card
 */

/* ─── Wrapper + box-sizing ─────────────────────────── */
.fs-library {
	width: 100%;
	margin: 32px 0;
	box-sizing: border-box;
}

.fs-library *,
.fs-library *::before,
.fs-library *::after {
	box-sizing: border-box;
}

/* ─── Grid layout ──────────────────────────────────── */
.fs-library__grid {
	display: grid;
	gap: 32px;
	width: 100%;
}

.fs-library--cols-1 .fs-library__grid { grid-template-columns: 1fr; }
.fs-library--cols-2 .fs-library__grid { grid-template-columns: repeat(2, 1fr); }
.fs-library--cols-3 .fs-library__grid { grid-template-columns: repeat(3, 1fr); }
.fs-library--cols-4 .fs-library__grid { grid-template-columns: repeat(4, 1fr); }
.fs-library--cols-5 .fs-library__grid { grid-template-columns: repeat(5, 1fr); }
.fs-library--cols-6 .fs-library__grid { grid-template-columns: repeat(6, 1fr); }

@media (max-width: 1024px) {
	.fs-library--cols-3 .fs-library__grid,
	.fs-library--cols-4 .fs-library__grid,
	.fs-library--cols-5 .fs-library__grid,
	.fs-library--cols-6 .fs-library__grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 640px) {
	.fs-library .fs-library__grid {
		grid-template-columns: 1fr !important;
		gap: 24px;
	}
}

/* ─── Items + titles + player frame ────────────────── */
.fs-library__item {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.fs-library__title {
	margin: 0 0 12px;
	font-size: 18px;
	line-height: 1.3;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-align: center;
	color: inherit;
}

.fs-library__player {
	position: relative;
	width: 100%;
	padding-top: var(--fs-aspect-padding, 56.25%);
	background: #000;
	overflow: hidden;
	border-radius: 4px;
}

.fs-library__player iframe,
.fs-library__player video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
	background: #000;
}

/* ─── Heading (used by both themes if filled in) ───── */
.fs-library__heading {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	text-align: center;
	margin: 0 0 28px;
}

.fs-library__heading-kicker {
	font-size: 0.78rem;
	letter-spacing: 0.32em;
	text-transform: uppercase;
	color: rgba(0, 0, 0, 0.55);
}

.fs-library__heading-title {
	margin: 0;
	font-size: clamp(1.6rem, 3vw, 2.6rem);
	font-weight: 500;
	letter-spacing: 0.06em;
	color: inherit;
}

.fs-library__heading-script {
	font-style: italic;
	font-size: clamp(1rem, 1.4vw, 1.25rem);
	color: rgba(0, 0, 0, 0.6);
}

/* ═══════════════════════════════════════════════════════════════
 *  CINEMATIC THEME — matches wedding-portal palette/typography
 * ═══════════════════════════════════════════════════════════════ */

/* Page-level cleanup when a cinematic library is on the page.
   The body class is added by FS_Library::body_class_filter(). */

/* 1. Prevent horizontal scrollbar caused by 100vw + body scrollbar. */
html.fs-library-cinematic-html,
body.fs-library-cinematic-page {
	overflow-x: hidden !important;
	background-color: #f6f1e9 !important;
}

/* 2. THE WATERCOLOR LAYER — fixed-position pseudo-element behind everything.
      This is the bullet-proof way to guarantee the wallpaper is visible at
      every scroll position with NO white strip anywhere — top, bottom, or
      between rows of cards. The pseudo-element is pinned to the viewport
      (inset: 0 + position: fixed), so it can't be cut off by any wrapper's
      min-height shortfall, the WP admin bar offset, or theme container
      gaps. The library wrapper above it is transparent so this shows through. */
body.fs-library-cinematic-page::before {
	content: "";
	position: fixed;
	inset: 0;
	z-index: -1;
	background-color: #f6f1e9;
	background-image:
		radial-gradient(circle at 18% 16%, rgba(255, 237, 211, 0.22), transparent 30%),
		radial-gradient(circle at 82% 84%, rgba(220, 195, 158, 0.14), transparent 38%),
		var(--fs-watercolor-bg, none);
	background-position: center, center, center;
	background-size: cover, cover, cover;
	background-repeat: no-repeat, no-repeat, no-repeat;
	pointer-events: none;
}

/* Ensure body has no z-index gap that could hide the ::before */
body.fs-library-cinematic-page {
	position: relative;
	z-index: 0;
}

/* 2. Hide ALL theme chrome (header, footer, navigation, page title) so the
      cinematic library page feels like a standalone takeover — same UX as
      the homepage portal experience. The `:not(.fs-library__heading)` lets
      our own optional <header> heading element survive. */
body.fs-library-cinematic-page header:not(.fs-library__heading),
body.fs-library-cinematic-page footer,
body.fs-library-cinematic-page .site-header,
body.fs-library-cinematic-page .site-footer,
body.fs-library-cinematic-page .wp-block-template-part,
body.fs-library-cinematic-page .entry-header,
body.fs-library-cinematic-page .entry-footer,
body.fs-library-cinematic-page .wp-block-post-title {
	display: none !important;
}

/* 3. Zero out the theme's container padding/margin so our wrapper truly
      reaches the top-left/top-right edges of the viewport. */
body.fs-library-cinematic-page,
body.fs-library-cinematic-page main,
body.fs-library-cinematic-page article,
body.fs-library-cinematic-page .wp-site-blocks,
body.fs-library-cinematic-page .entry-content,
body.fs-library-cinematic-page .wp-block-group,
body.fs-library-cinematic-page .is-layout-constrained,
body.fs-library-cinematic-page .is-layout-flow {
	margin: 0 !important;
	padding: 0 !important;
	max-width: none !important;
}

.fs-library--theme-cinematic {
	/* Full-bleed escape from the WP theme content container.
	 * The calc() margin trick is more reliable than left:50%/right:50% because
	 * it doesn't require position:relative and survives flex/grid parents.
	 * !important is intentional — themes commonly set max-width on .entry-content > *. */
	width: 100vw !important;
	max-width: 100vw !important;
	margin-left: calc(50% - 50vw) !important;
	margin-right: calc(50% - 50vw) !important;
	margin-top: 0 !important;
	margin-bottom: 0 !important;
	box-sizing: border-box !important;

	padding: clamp(60px, 10vh, 140px) clamp(20px, 5vw, 80px);

	/* Transparent wrapper — the watercolor lives on body::before (fixed
	 * position, behind everything) so it covers the viewport at every
	 * scroll position. Letting the wrapper be transparent prevents any
	 * visible boundary between wrapper and body. */
	background: transparent;
}

.fs-library--theme-cinematic .fs-library__grid {
	gap: clamp(36px, 4vw, 64px) clamp(28px, 3vw, 48px);
	max-width: 1400px;
	margin-left: auto;
	margin-right: auto;
	justify-items: stretch;
	align-items: start;
}

/* Heading — mirrors wedding-portal__gallery-heading */
.fs-library--theme-cinematic .fs-library__heading {
	margin: 0 auto clamp(40px, 6vh, 70px);
	gap: 6px;
	text-shadow:
		0 1px 0 rgba(255, 252, 245, 0.7),
		0 10px 24px rgba(73, 62, 45, 0.08);
}

.fs-library--theme-cinematic .fs-library__heading-kicker {
	font-family: 'Cormorant Garamond', 'Times New Roman', serif;
	font-size: clamp(0.68rem, 0.82vw, 0.9rem);
	letter-spacing: 0.44em;
	text-transform: uppercase;
	color: rgba(92, 77, 54, 0.78);
}

.fs-library--theme-cinematic .fs-library__heading-title {
	font-family: 'Cormorant Garamond', 'Times New Roman', serif;
	font-size: clamp(2.2rem, 3.1vw, 3.6rem);
	font-weight: 500;
	letter-spacing: 0.14em;
	color: rgba(88, 67, 36, 0.94);
	text-transform: none;
}

.fs-library--theme-cinematic .fs-library__heading-script {
	font-family: 'Great Vibes', 'Cormorant Garamond', cursive;
	font-style: normal;
	margin-top: 2px;
	font-size: clamp(1.3rem, 1.5vw, 1.85rem);
	line-height: 0.95;
	color: rgba(73, 58, 37, 0.9);
}

/* Per-player film title — uppercase Cormorant in sepia */
.fs-library--theme-cinematic .fs-library__title {
	font-family: 'Cormorant Garamond', 'Times New Roman', serif;
	font-size: clamp(0.95rem, 1.2vw, 1.2rem);
	font-weight: 500;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: rgba(88, 67, 36, 0.94);
	margin: 0 0 14px;
}

/* Player frame — matches wedding-portal__gallery-card */
.fs-library--theme-cinematic .fs-library__player {
	background: rgb(10, 12, 18);
	border-radius: 0;
	box-shadow:
		0 34px 74px rgba(0, 0, 0, 0.32),
		inset 0 1px 0 rgba(255, 255, 255, 0.06);
	transition: box-shadow 280ms ease, transform 280ms ease;
}

.fs-library--theme-cinematic .fs-library__player:hover {
	box-shadow:
		0 42px 84px rgba(0, 0, 0, 0.42),
		inset 0 1px 0 rgba(255, 240, 210, 0.12);
	transform: translateY(-2px);
}

.fs-library--theme-cinematic .fs-library__player iframe,
.fs-library--theme-cinematic .fs-library__player video {
	background: rgb(10, 12, 18);
}

@media (max-width: 900px) {
	.fs-library--theme-cinematic {
		padding: clamp(40px, 6vh, 80px) clamp(16px, 4vw, 40px);
	}
	.fs-library--theme-cinematic .fs-library__heading-title {
		font-size: clamp(1.56rem, 6.2vw, 2.6rem);
		letter-spacing: 0.09em;
	}
	.fs-library--theme-cinematic .fs-library__heading-script {
		font-size: clamp(1.1rem, 3.8vw, 1.5rem);
	}
}

@media (max-width: 640px) {
	.fs-library--theme-cinematic {
		padding: 48px 18px 64px;
	}
	.fs-library--theme-cinematic .fs-library__heading-kicker {
		letter-spacing: 0.32em;
	}
}

/* ═══════════════════════════════════════════════════════════════
 *  SIDE MENU (cinematic mode only)
 *  Mirrors wedding-portal__side-menu — round glassmorphism toggle +
 *  vertical stack of round icon buttons (Invite / About / Gallery / Inquiry)
 *  that fade in below it. Ported from wp-polish.css so the look is
 *  identical to the homepage portal menu.
 * ═══════════════════════════════════════════════════════════════ */

.fs-library__side-menu {
	position: fixed;
	top: max(16px, env(safe-area-inset-top, 0px));
	right: max(16px, env(safe-area-inset-right, 0px));
	z-index: 100050;
	display: flex;
	flex-direction: column;
	align-items: center;
	pointer-events: none;
}

/* Push menu down when WP admin bar is showing */
body.admin-bar .fs-library__side-menu {
	top: max(48px, calc(32px + env(safe-area-inset-top, 0px)));
}
@media (max-width: 782px) {
	body.admin-bar .fs-library__side-menu {
		top: max(62px, calc(46px + env(safe-area-inset-top, 0px)));
	}
}

.fs-library__side-menu-toggle,
.fs-library__side-menu-item {
	pointer-events: auto;
}

.fs-library__side-menu-toggle {
	width: 44px;
	height: 44px;
	display: inline-flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 4px;
	appearance: none;
	padding: 0;
	border: 1px solid rgba(177, 145, 91, 0.26);
	border-radius: 999px;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.20), rgba(255, 255, 255, 0.10));
	-webkit-backdrop-filter: blur(16px) saturate(145%);
	backdrop-filter: blur(16px) saturate(145%);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42), 0 10px 24px rgba(38, 24, 10, 0.06);
	color: rgba(122, 95, 47, 0.72);
	cursor: pointer;
	transition: transform 220ms ease, border-color 220ms ease, background-color 220ms ease, color 220ms ease, box-shadow 220ms ease;
}

.fs-library__side-menu-toggle:hover,
.fs-library__side-menu.is-open .fs-library__side-menu-toggle {
	transform: translateY(-1px);
	border-color: rgba(177, 145, 91, 0.40);
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.14));
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 12px 28px rgba(38, 24, 10, 0.08);
	color: rgba(122, 95, 47, 0.96);
}

.fs-library__side-menu-toggle span {
	width: 16px;
	height: 1.5px;
	border-radius: 999px;
	background: currentColor;
	display: block;
}

.fs-library__side-menu-panel {
	margin-top: 8px;
	width: 72px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(-8px);
	will-change: opacity, transform;
	transition: opacity 320ms ease, transform 320ms ease, visibility 0s linear 320ms;
}

.fs-library__side-menu.is-open .fs-library__side-menu-panel {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translateY(0);
	transition: opacity 320ms ease, transform 320ms ease, visibility 0s linear 0s;
}

.fs-library__side-menu-item {
	appearance: none;
	border: 0;
	padding: 0;
	width: 72px;
	background: transparent;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 3px;
	color: rgba(122, 95, 47, 0.74);
	cursor: pointer;
	text-decoration: none;
	transition: color 220ms ease, transform 220ms ease;
}

.fs-library__side-menu-item:hover {
	color: rgba(122, 95, 47, 0.98);
}

.fs-library__side-menu-icon {
	width: 44px;
	height: 44px;
	display: grid;
	place-items: center;
	border-radius: 999px;
	border: 1px solid rgba(177, 145, 91, 0.26);
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.20), rgba(255, 255, 255, 0.10));
	-webkit-backdrop-filter: blur(16px) saturate(145%);
	backdrop-filter: blur(16px) saturate(145%);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42), 0 10px 24px rgba(38, 24, 10, 0.06);
	transition: transform 220ms ease, border-color 220ms ease, background-color 220ms ease, box-shadow 220ms ease;
}

.fs-library__side-menu-item:hover .fs-library__side-menu-icon {
	transform: translateY(-1px);
	border-color: rgba(177, 145, 91, 0.40);
	background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.14));
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 12px 28px rgba(38, 24, 10, 0.08);
}

.fs-library__side-menu-icon svg {
	width: 22px;
	height: 22px;
	stroke: currentColor;
	stroke-width: 1.55;
	stroke-linecap: round;
	stroke-linejoin: round;
	fill: none;
}

.fs-library__side-menu-label {
	order: -1;
	display: block;
	width: 100%;
	text-align: center;
	font-size: 10px;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	line-height: 1.1;
	white-space: nowrap;
	color: rgba(122, 95, 47, 1);
}

/* Desktop glass softening — match the portal's exact resting state.
   Two stacked rules from wp-polish.css: opacity-0.5 + a more-solid white
   background override so the circles read clearly over the watercolor.
   Hover/open state ramps both border and inner-highlight up. */
@media (min-width: 768px) {
	.fs-library__side-menu-toggle,
	.fs-library__side-menu-icon {
		opacity: 0.5;
	}

	.fs-library__side-menu-toggle,
	.fs-library__side-menu-icon {
		border-color: rgba(177, 145, 91, 0.62);
		background: linear-gradient(180deg, rgba(255, 255, 255, 0.70), rgba(255, 255, 255, 0.56));
		box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76), 0 10px 24px rgba(38, 24, 10, 0.14);
		color: rgba(122, 95, 47, 0.92);
	}

	.fs-library__side-menu-toggle:hover,
	.fs-library__side-menu-item:hover .fs-library__side-menu-icon,
	.fs-library__side-menu.is-open .fs-library__side-menu-toggle {
		border-color: rgba(177, 145, 91, 0.75);
		background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.55));
		box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 12px 28px rgba(38, 24, 10, 0.16);
	}
}

/* Mobile sizing — mirrors the portal's mobile breakpoint */
@media (max-width: 767px) {
	.fs-library__side-menu {
		top: max(12px, env(safe-area-inset-top, 0px));
		right: max(12px, env(safe-area-inset-right, 0px));
	}
	.fs-library__side-menu-toggle {
		width: 40px;
		height: 40px;
	}
	.fs-library__side-menu-panel {
		width: 64px;
		gap: 6px;
	}
	.fs-library__side-menu-item {
		width: 64px;
	}
	.fs-library__side-menu-icon {
		width: 40px;
		height: 40px;
	}
	.fs-library__side-menu-icon svg {
		width: 20px;
		height: 20px;
	}
}
