:root {
	color-scheme: dark;
	--fg: rgba(255, 255, 255, 0.92);
	--fg-dim: rgba(255, 255, 255, 0.62);
	--glass: rgba(16, 16, 18, 0.42);
	--glass-strong: rgba(16, 16, 18, 0.62);
	--line: rgba(255, 255, 255, 0.12);
	--radius: 14px;
	--gap: clamp(12px, 2.4vw, 24px);
	--fade: 900ms;
	font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
	font-size: 15px;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
}

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

html, body {
	margin: 0;
	height: 100%;
	background: #000;
	color: var(--fg);
	overflow: hidden;
}

body { touch-action: pan-x pan-y; }

a { color: inherit; }

svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* ---------- Stage ---------- */

.stage {
	position: fixed;
	inset: 0;
	overflow: hidden;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
}

.backdrop {
	position: absolute;
	inset: -40px;
	background: center / cover no-repeat;
	filter: blur(32px) brightness(0.55) saturate(1.2);
	transition: background-image var(--fade) ease;
}

.slide {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity var(--fade) ease, transform 8s ease-out;
	transform: scale(1.015);
	-webkit-user-drag: none;
	pointer-events: none;
}

.slide.contain { object-fit: contain; }

.slide.active {
	opacity: 1;
	transform: scale(1);
}

/* ---------- Overlay UI ---------- */

.ui {
	position: fixed;
	inset: 0;
	pointer-events: none;
	padding:
		max(var(--gap), env(safe-area-inset-top))
		max(var(--gap), env(safe-area-inset-right))
		max(var(--gap), env(safe-area-inset-bottom))
		max(var(--gap), env(safe-area-inset-left));
}

.ui > * { pointer-events: auto; transition: opacity 500ms ease; }

body.idle .ui > :not(.card) { opacity: 0; pointer-events: none; }

.glass {
	background: var(--glass);
	backdrop-filter: blur(18px) saturate(1.4);
	-webkit-backdrop-filter: blur(18px) saturate(1.4);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

/* Contact card */

.card {
	position: absolute;
	top: max(var(--gap), env(safe-area-inset-top));
	left: max(var(--gap), env(safe-area-inset-left));
	padding: 14px 18px 15px;
	max-width: calc(100% - 2 * var(--gap));
}

.card h1 {
	margin: 0 0 6px;
	font-size: 1.05rem;
	font-weight: 600;
	letter-spacing: 0.01em;
}

.card address {
	font-style: normal;
	font-size: 0.87rem;
	color: var(--fg-dim);
}

.card a {
	text-decoration: none;
	border-bottom: 1px solid rgba(255, 255, 255, 0.25);
	transition: color 150ms, border-color 150ms;
}

.card a:hover { color: #fff; border-color: #fff; }

/* Set tabs */

.sets {
	position: absolute;
	top: max(var(--gap), env(safe-area-inset-top));
	right: max(var(--gap), env(safe-area-inset-right));
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 4px;
	border-radius: 999px;
}

.tabs { display: flex; gap: 2px; }

.tab, .icon-btn {
	font: inherit;
	font-size: 0.9rem;
	color: var(--fg-dim);
	background: transparent;
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	transition: background-color 150ms, color 150ms;
}

.tab { padding: 8px 16px; }

.tab:hover, .icon-btn:hover { color: var(--fg); background: rgba(255, 255, 255, 0.08); }

.tab[aria-pressed="true"] {
	color: #111;
	background: rgba(255, 255, 255, 0.9);
}

.icon-btn {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	padding: 0;
}

.play-btn .icon-pause { display: none; }
.play-btn[aria-pressed="true"] .icon-play { display: none; }
.play-btn[aria-pressed="true"] .icon-pause { display: block; }

/* Prev / next */

.nav-btn {
	position: absolute;
	top: 50%;
	translate: 0 -50%;
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	padding: 0;
	color: var(--fg);
	background: var(--glass);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border: 1px solid var(--line);
	border-radius: 50%;
	cursor: pointer;
	opacity: 0.85;
	transition: opacity 250ms, background-color 150ms;
}

.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.prev { left: max(var(--gap), env(safe-area-inset-left)); }
.nav-btn.next { right: max(var(--gap), env(safe-area-inset-right)); }
.nav-btn:hover { background: var(--glass-strong); opacity: 1; }

/* Caption */

.caption {
	position: absolute;
	left: 50%;
	bottom: max(var(--gap), env(safe-area-inset-bottom));
	translate: -50% 0;
	display: flex;
	align-items: center;
	gap: 12px;
	max-width: min(760px, calc(100% - 2 * var(--gap)));
	padding: 9px 16px;
	border-radius: 999px;
	font-size: 0.9rem;
	white-space: nowrap;
}

.counter {
	color: var(--fg-dim);
	font-variant-numeric: tabular-nums;
	font-size: 0.82rem;
}

.title {
	overflow: hidden;
	text-overflow: ellipsis;
}

.title:empty { display: none; }

.map {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 0.82rem;
	color: var(--fg-dim);
	text-decoration: none;
	padding: 2px 8px 2px 6px;
	margin: -2px -8px -2px 0;
	border-radius: 999px;
	transition: background-color 150ms, color 150ms;
}

.map svg { width: 16px; height: 16px; }
.map:hover { color: var(--fg); background: rgba(255, 255, 255, 0.1); }
.map[hidden] { display: none; }

.copyright {
	position: absolute;
	right: max(var(--gap), env(safe-area-inset-right));
	bottom: max(var(--gap), env(safe-area-inset-bottom));
	margin: 0;
	padding: 9px 0;
	font-size: 0.75rem;
	color: rgba(255, 255, 255, 0.5);
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
	pointer-events: none;
}

:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.85);
	outline-offset: 2px;
}

/* ---------- Grid view ---------- */

.grid-view {
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	color: var(--fg);
	background: rgba(8, 8, 10, 0.86);
	backdrop-filter: blur(24px);
	-webkit-backdrop-filter: blur(24px);
	overflow-y: auto;
	overscroll-behavior: contain;
}

.grid-view[open] { animation: fade-in 250ms ease; }
.grid-view::backdrop { background: transparent; }

.grid-head {
	position: sticky;
	top: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: max(var(--gap), env(safe-area-inset-top)) var(--gap) 12px;
	background: linear-gradient(rgba(8, 8, 10, 0.95), rgba(8, 8, 10, 0));
}

.grid-head h2 {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 600;
}

.grid-head .icon-btn { color: var(--fg); background: rgba(255, 255, 255, 0.08); }

.grid {
	list-style: none;
	margin: 0;
	padding: 4px var(--gap) max(var(--gap), env(safe-area-inset-bottom));
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 10px;
}

.grid button {
	display: block;
	width: 100%;
	aspect-ratio: 4 / 3;
	padding: 0;
	border: 0;
	border-radius: 10px;
	overflow: hidden;
	background: #1a1a1d;
	cursor: pointer;
}

.grid img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 300ms ease, opacity 300ms ease;
	opacity: 0.9;
}

.grid button:hover img { transform: scale(1.04); opacity: 1; }
.grid button[aria-current="true"] { outline: 2px solid #fff; outline-offset: 2px; }

.noscript {
	position: fixed;
	inset: 0;
	display: grid;
	place-items: center;
	margin: 0;
}

@keyframes fade-in { from { opacity: 0; } }

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
	:root { font-size: 14px; }

	.card { padding: 10px 14px 11px; }
	.card h1 { font-size: 0.98rem; margin-bottom: 3px; }
	.card address { font-size: 0.8rem; }

	.sets {
		top: auto;
		bottom: calc(max(var(--gap), env(safe-area-inset-bottom)) + 52px);
		left: 50%;
		right: auto;
		translate: -50% 0;
	}

	.tab { padding: 8px 14px; }
	.nav-btn { display: none; }
	.copyright { display: none; }

	.caption {
		white-space: normal;
		border-radius: var(--radius);
		width: max-content;
		justify-content: center;
		text-align: center;
	}

	.grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
}

@media (hover: none) {
	.nav-btn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	:root { --fade: 1ms; }
	.slide { transition: opacity var(--fade); transform: none; }
	.slide.active { transform: none; }
}
