/**
 * Radu Sava Widgets — Shared Overlay Styles
 *
 * Accessible modal overlay core, Photo Lightbox, and Film Player.
 */

/* ==========================================================================
   Overlay Core (Dialog / Scroll Lock / Focus Ring)
   ========================================================================== */

.rs-overlay {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: rgba(8, 8, 7, 0.96);
	color: var(--rs-bone, #ece8e1);
	box-sizing: border-box;
	animation: rs-overlay-fade-in 0.3s ease;
	overscroll-behavior: contain;
}

.rs-overlay[hidden] {
	display: none;
}

@keyframes rs-overlay-fade-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

/* Accessible focus ring reset for Hello theme buttons (zero-specificity :where so widget styles win) */
:where(.rs-overlay) :where(button, a) {
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	border: 0;
	border-radius: 0;
	color: inherit;
	font: inherit;
	text-decoration: none;
	cursor: pointer;
}

:where(.rs-overlay) :where(button, a):focus-visible {
	outline: 1px solid currentColor;
	outline-offset: 4px;
}

/* Close button */
.rs-overlay .rs-overlay__close,
.rs-overlay__close {
	-webkit-appearance: none;
	appearance: none;
	background: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	color: var(--rs-bone, #ece8e1);
	cursor: pointer;
	min-height: 44px;
	padding: 8px 12px;
	font-family: var(--rs-font-mono, "IBM Plex Mono", ui-monospace, monospace);
	font-size: clamp(0.688rem, 0.76vw, 0.912rem);
	letter-spacing: 0.16em;
	text-transform: uppercase;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	transition: opacity 0.2s ease, color 0.2s ease;
}

.rs-overlay .rs-overlay__close:hover,
.rs-overlay .rs-overlay__close:focus,
.rs-overlay .rs-overlay__close:focus-visible,
.rs-overlay__close:hover,
.rs-overlay__close:focus,
.rs-overlay__close:focus-visible {
	background: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	color: var(--rs-gold, #e3b26a);
}

.rs-overlay .rs-overlay__close:focus-visible,
.rs-overlay__close:focus-visible {
	outline: 1px solid currentColor;
	outline-offset: 4px;
}

.rs-overlay .rs-overlay__close span[aria-hidden="true"],
.rs-overlay__close span[aria-hidden="true"] {
	font-size: 1.25em;
	line-height: 1;
}

/* Typography tokens inside overlays */
.rs-overlay .rs-mono {
	font-family: var(--rs-font-mono, "IBM Plex Mono", ui-monospace, monospace);
	font-size: clamp(0.688rem, 0.76vw, 0.912rem);
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

/* ==========================================================================
   Photo Lightbox (.rs-lbx)
   ========================================================================== */

.rs-lbx {
	display: grid;
	grid-template-rows: auto 1fr auto;
	padding: calc(env(safe-area-inset-top, 0px) + 14px) var(--rs-gutter, clamp(1rem, 3.2vw, 3.84rem)) calc(env(safe-area-inset-bottom, 0px) + 14px);
	touch-action: pan-y;
}

.rs-lbx__top {
	display: flex;
	justify-content: space-between;
	align-items: center;
	color: var(--rs-bone-2, #a7a198);
}

.rs-lbx__stage {
	position: relative;
	display: grid;
	place-items: center;
	min-height: 0;
	padding: clamp(8px, 2vw, 32px) 0;
}

.rs-lbx__img {
	max-width: 100%;
	max-height: calc(100svh - 150px);
	object-fit: contain;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
	transition: opacity 0.25s ease;
}

.rs-overlay.rs-lbx .rs-lbx__nav,
.rs-overlay .rs-lbx__nav,
.rs-lbx__nav {
	-webkit-appearance: none;
	appearance: none;
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: clamp(44px, 4vw, 72px);
	aspect-ratio: 1;
	padding: 0 !important;
	min-height: 0 !important;
	border-radius: 50% !important;
	border: 1px solid rgba(236, 232, 225, 0.4) !important;
	background: rgba(8, 8, 7, 0.35) !important;
	color: var(--rs-bone, #ece8e1);
	display: grid;
	place-items: center;
	cursor: pointer;
	transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
	z-index: 2;
}

.rs-overlay.rs-lbx .rs-lbx__nav:hover,
.rs-overlay.rs-lbx .rs-lbx__nav:focus,
.rs-overlay.rs-lbx .rs-lbx__nav:focus-visible,
.rs-overlay .rs-lbx__nav:hover,
.rs-overlay .rs-lbx__nav:focus,
.rs-overlay .rs-lbx__nav:focus-visible,
.rs-lbx__nav:hover,
.rs-lbx__nav:focus,
.rs-lbx__nav:focus-visible {
	background: var(--rs-bone, #ece8e1) !important;
	border-color: var(--rs-bone, #ece8e1) !important;
	color: var(--rs-film, #0b0b0a) !important;
}

.rs-overlay.rs-lbx .rs-lbx__nav:focus-visible,
.rs-overlay .rs-lbx__nav:focus-visible,
.rs-lbx__nav:focus-visible {
	outline: 1px solid currentColor;
	outline-offset: 4px;
}

.rs-lbx__nav svg {
	width: 34%;
	height: auto;
}

.rs-lbx__nav--prev {
	left: 0;
}

.rs-lbx__nav--next {
	right: 0;
}

.rs-lbx__bottom {
	display: flex;
	justify-content: space-between;
	gap: 16px;
	color: var(--rs-bone-2, #a7a198);
}

.rs-lbx__caption {
	color: var(--rs-bone, #ece8e1);
}

/* ==========================================================================
   Film Player (.rs-vbox)
   ========================================================================== */

.rs-vbox {
	display: grid;
	place-items: center;
	padding: clamp(16px, 4vw, 80px);
}

.rs-vbox .rs-overlay__close {
	position: absolute;
	top: calc(env(safe-area-inset-top, 0px) + 16px);
	right: var(--rs-gutter, clamp(1rem, 3.2vw, 3.84rem));
	z-index: 5;
}

.rs-vbox__figure {
	margin: 0;
	width: min(100%, calc((100svh - 170px) * 16 / 9), 2400px);
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.rs-vbox__media {
	width: 100%;
	aspect-ratio: 16 / 9;
	background: #000000;
	position: relative;
	overflow: hidden;
}

.rs-vbox__media video,
.rs-vbox__media iframe {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
	object-fit: contain;
}

.rs-vbox figcaption {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 16px;
	flex-wrap: wrap;
	color: var(--rs-bone-2, #a7a198);
}

.rs-vbox__title {
	color: var(--rs-bone, #ece8e1);
	font-family: var(--rs-font-display, "Cormorant Garamond", Georgia, serif);
	font-style: italic;
	font-weight: 300;
	font-size: clamp(20px, 1.6vw, 34px);
	letter-spacing: 0;
	text-transform: none;
}

.rs-vbox__link a {
	color: var(--rs-gold, #e3b26a);
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color 0.2s ease;
}

.rs-vbox__link a:hover {
	border-bottom-color: var(--rs-gold, #e3b26a);
}

/* ==========================================================================
   Responsive & Accessibility
   ========================================================================== */

@media (max-width: 767px) {
	.rs-lbx__nav {
		display: none;
	}

	.rs-vbox {
		padding: 16px;
	}

	.rs-vbox .rs-overlay__close {
		top: calc(env(safe-area-inset-top, 0px) + 8px);
		right: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.rs-overlay {
		animation: none !important;
	}

	.rs-lbx__img,
	.rs-lbx__nav,
	.rs-overlay__close {
		transition: none !important;
	}
}
