/* ==========================================================================
   Portafolio · Daniel Gimeno
   Sala de exposición: visor centrado + índice con marcos uniformes.
   ========================================================================== */

:root {
	--bg: #0a0908;
	--bg-raised: #14120f;
	--mat: #161410;
	--line: rgba(244, 239, 230, 0.1);
	--text: #f4efe6;
	--text-muted: #8f8778;
	--accent: #c4a15a;
	--serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
	--sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--ease: cubic-bezier(0.22, 0.61, 0.36, 1);
	--thumb-h: 92px;
	--header-pad: env(safe-area-inset-top);
	--footer-pad: env(safe-area-inset-bottom);
}

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

html {
	-webkit-text-size-adjust: 100%;
	height: 100%;
	height: 100dvh;
}

body {
	margin: 0;
	min-height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family: var(--sans);
	font-size: 16px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

body.is-viewer {
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	overscroll-behavior: none;
}

img {
	display: block;
	max-width: 100%;
}

a {
	color: inherit;
}

button {
	font: inherit;
	color: inherit;
}

.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 200;
	padding: 12px 18px;
	background: var(--accent);
	color: #17130a;
	font-weight: 600;
	text-decoration: none;
}

.skip-link:focus {
	left: 12px;
	top: 12px;
}

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 3px;
}

/* --------------------------------------------------------------- Cabecera */

.masthead {
	flex: 0 0 auto;
	position: relative;
	z-index: 40;
	padding: calc(8px + var(--header-pad)) clamp(14px, 2.4vw, 32px) 10px;
	border-bottom: 1px solid var(--line);
	background: rgba(10, 9, 8, 0.88);
	backdrop-filter: saturate(140%) blur(16px);
	-webkit-backdrop-filter: saturate(140%) blur(16px);
}

.masthead__row {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 12px;
}

.masthead__home {
	justify-self: start;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 7px 13px 7px 7px;
	border: 1px solid var(--line);
	border-radius: 999px;
	color: var(--text-muted);
	font-size: 0.78rem;
	letter-spacing: 0.06em;
	text-decoration: none;
	text-transform: uppercase;
	transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background-color 0.25s var(--ease);
}

.masthead__home svg {
	width: 16px;
	height: 16px;
}

.masthead__home:hover {
	color: var(--text);
	border-color: rgba(255, 255, 255, 0.28);
	background: rgba(255, 255, 255, 0.04);
}

.masthead__brand {
	text-align: center;
	min-width: 0;
}

.masthead__title {
	margin: 0;
	font-family: var(--serif);
	font-size: clamp(1.05rem, 2vw, 1.45rem);
	font-weight: 400;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

.masthead__subtitle {
	margin: 2px 0 0;
	color: var(--text-muted);
	font-size: 0.7rem;
	letter-spacing: 0.18em;
	text-transform: uppercase;
}

.modes {
	display: none;
	justify-self: end;
	gap: 6px;
}

.js .modes {
	display: inline-flex;
}

.modes__btn {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 7px 12px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: transparent;
	color: var(--text-muted);
	font-size: 0.76rem;
	letter-spacing: 0.04em;
	cursor: pointer;
	transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background-color 0.25s var(--ease);
}

.modes__btn svg {
	width: 14px;
	height: 14px;
}

.modes__btn:hover {
	color: var(--text);
	border-color: rgba(255, 255, 255, 0.28);
}

.modes__btn.is-active {
	color: #17130a;
	background: var(--accent);
	border-color: var(--accent);
	font-weight: 600;
}

/* ---------------------------------------------------------------- Filtros */

.filters {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 8px;
}

.filters__chip {
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
	padding: 6px 13px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: transparent;
	color: var(--text-muted);
	font-size: 0.78rem;
	letter-spacing: 0.04em;
	cursor: pointer;
	transition: color 0.25s var(--ease), border-color 0.25s var(--ease), background-color 0.25s var(--ease);
}

.filters__count {
	font-size: 0.66rem;
	opacity: 0.7;
	font-variant-numeric: tabular-nums;
}

.filters__chip:hover {
	color: var(--text);
	border-color: rgba(255, 255, 255, 0.28);
}

.filters__chip.is-active {
	color: #17130a;
	background: var(--accent);
	border-color: var(--accent);
	font-weight: 600;
}

/* ------------------------------------------------------------------ Visor */

main {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.atelier {
	display: none;
	flex: 1 1 auto;
	min-height: 0;
	flex-direction: column;
}

.js body.is-viewer .atelier {
	display: flex;
}

.stage {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	align-items: stretch;
}

.stage__canvas {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	min-height: 0;
	margin: 8px 56px 8px;
}

.stage__image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: center;
	opacity: 0;
	pointer-events: none;
	user-select: none;
	transition: opacity 0.4s var(--ease);
}

.stage__image.is-shown {
	opacity: 1;
	pointer-events: auto;
	cursor: default;
}

body.can-zoom .stage__image.is-shown {
	cursor: zoom-in;
}

body.is-zoomed .stage__canvas {
	overflow: auto;
	-webkit-overflow-scrolling: touch;
	cursor: grab;
}

body.is-zoomed .stage__image {
	position: relative;
	inset: auto;
	width: auto;
	height: auto;
	max-width: none;
	max-height: none;
	margin: 0 auto;
	display: none;
}

body.is-zoomed .stage__image.is-shown {
	display: block;
	cursor: grab;
}

body.is-zoomed.is-panning .stage__canvas,
body.is-zoomed.is-panning .stage__image.is-shown {
	cursor: grabbing;
}

body.is-zoomed .caption,
body.is-zoomed .filmstrip,
body.is-zoomed .nav {
	opacity: 0;
	pointer-events: none;
}

.stage__spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 34px;
	height: 34px;
	margin: -17px 0 0 -17px;
	border: 2px solid rgba(255, 255, 255, 0.16);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.85s linear infinite;
}

.stage__spinner[hidden] {
	display: none;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

.nav,
.tool {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--line);
	border-radius: 50%;
	background: rgba(20, 18, 15, 0.62);
	color: var(--text);
	cursor: pointer;
	transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease), opacity 0.25s var(--ease);
}

.nav {
	position: absolute;
	top: 50%;
	z-index: 3;
	width: 48px;
	height: 48px;
	transform: translateY(-50%);
}

.nav svg {
	width: 24px;
	height: 24px;
}

.nav--prev {
	left: 10px;
}

.nav--next {
	right: 10px;
}

.nav:hover,
.tool:hover {
	background: rgba(255, 255, 255, 0.12);
	border-color: rgba(255, 255, 255, 0.3);
}

.stage__tools {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 3;
	display: flex;
	gap: 8px;
}

.tool {
	width: 40px;
	height: 40px;
}

.tool svg {
	width: 18px;
	height: 18px;
}

.tool[aria-pressed="true"] {
	background: var(--accent);
	border-color: var(--accent);
	color: #17130a;
}

.tool[hidden] {
	display: none;
}

/* --------------------------------------------------------------- Leyenda */

.caption {
	flex: 0 0 auto;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: baseline;
	gap: 12px;
	padding: 2px clamp(16px, 3vw, 40px) 6px;
	text-align: center;
}

.caption__kicker {
	margin: 0;
	justify-self: start;
	color: var(--accent);
	font-size: 0.68rem;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

.caption__title {
	margin: 0;
	font-family: var(--serif);
	font-size: clamp(1.05rem, 2vw, 1.45rem);
	font-weight: 400;
	letter-spacing: 0.02em;
	line-height: 1.2;
}

.caption__index {
	margin: 0;
	justify-self: end;
	color: var(--text-muted);
	font-size: 0.78rem;
	letter-spacing: 0.1em;
	font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ Filmstrip */

.filmstrip {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 4px 24px calc(14px + var(--footer-pad));
	overflow-x: auto;
	scrollbar-width: thin;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scroll-snap-type: x proximity;
}

.filmstrip::before,
.filmstrip::after {
	content: "";
	flex: 1 1 0;
	min-width: 8px;
}

.filmstrip::-webkit-scrollbar {
	height: 5px;
}

.filmstrip::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, 0.18);
	border-radius: 3px;
}

.filmstrip__item {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	height: var(--thumb-h);
	min-width: 52px;
	padding: 4px;
	border: 1px solid transparent;
	border-radius: 2px;
	background: var(--mat);
	cursor: pointer;
	opacity: 0.55;
	scroll-snap-align: center;
	transition: opacity 0.25s var(--ease), border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.filmstrip__item img {
	max-height: calc(var(--thumb-h) - 10px);
	max-width: 168px;
	width: auto;
	height: auto;
	object-fit: contain;
	object-position: center;
}

.filmstrip__item:hover {
	opacity: 0.88;
}

.filmstrip__item.is-current {
	opacity: 1;
	border-color: var(--accent);
	box-shadow: 0 0 0 1px var(--accent);
}

/* ---------------------------------------------------------------- Índice */

.salon {
	--gutter: 6px;
	--row-height: 280px;
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	gap: var(--gutter);
	max-width: 1680px;
	margin: 0 auto;
	padding: 10px clamp(10px, 1.6vw, 18px) 56px;
}

.js body.is-viewer .salon {
	display: none;
}

.js body.is-index .atelier {
	display: none;
}

.js body.is-index main,
html:not(.js) main {
	display: block;
	flex: none;
}

.salon__card {
	position: relative;
	display: block;
	flex: 0 0 auto;
	height: var(--row-height);
	width: calc(var(--row-height) * var(--ratio));
	overflow: hidden;
	background: var(--mat);
	color: inherit;
	text-decoration: none;
}

.salon__card img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.55s var(--ease), filter 0.35s var(--ease);
}

.salon__meta {
	position: absolute;
	inset: auto 0 0 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 28px 12px 10px;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 10%, rgba(0, 0, 0, 0));
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.salon__name {
	font-family: var(--serif);
	font-size: 0.98rem;
	line-height: 1.25;
	color: #fff;
}

.salon__kind {
	color: var(--accent);
	font-size: 0.64rem;
	letter-spacing: 0.14em;
	text-transform: uppercase;
}

@media (hover: hover) {
	.salon__card:hover img,
	.salon__card:focus-visible img {
		transform: scale(1.15);
	}

	.salon__card:hover .salon__meta,
	.salon__card:focus-visible .salon__meta,
	.salon__card.is-current .salon__meta {
		opacity: 1;
		transform: none;
	}
}

@media (hover: none) {
	.salon__meta {
		opacity: 1;
		transform: none;
	}
}

.salon__card.is-hidden {
	display: none;
}

.salon__empty {
	margin: 0;
	padding: 48px 24px 80px;
	text-align: center;
	color: var(--text-muted);
}

.site-footer {
	display: none;
	padding: 26px 24px calc(34px + var(--footer-pad));
	border-top: 1px solid var(--line);
	text-align: center;
	color: var(--text-muted);
	font-size: 0.78rem;
	letter-spacing: 0.06em;
}

html:not(.js) .site-footer,
body.is-index .site-footer {
	display: block;
}

.site-footer a {
	color: var(--text-muted);
	text-decoration: none;
	border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.site-footer a:hover {
	color: var(--text);
}

/* ------------------------------------------------------------ Adaptación */

@media (hover: hover) and (pointer: fine) {
	.nav,
	.stage__tools {
		opacity: 0.38;
	}

	.stage:hover .nav,
	.stage:hover .stage__tools,
	.nav:focus-visible,
	.stage__tools:focus-within {
		opacity: 1;
	}
}

@media (max-width: 760px) {
	:root {
		--thumb-h: 74px;
	}

	.masthead__row {
		grid-template-columns: auto 1fr auto;
		gap: 8px;
	}

	.masthead__title {
		letter-spacing: 0.1em;
		font-size: 0.98rem;
	}

	.masthead__subtitle {
		display: none;
	}

	.masthead__home {
		padding: 6px 10px 6px 6px;
		font-size: 0;
		gap: 0;
	}

	.masthead__home svg {
		width: 18px;
		height: 18px;
	}

	.modes__btn {
		padding: 6px 9px;
		font-size: 0;
		gap: 0;
	}

	.modes__btn svg {
		width: 16px;
		height: 16px;
	}

	.filters {
		flex-wrap: nowrap;
		justify-content: flex-start;
		overflow-x: auto;
		margin-top: 10px;
		padding-bottom: 2px;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}

	.filters::-webkit-scrollbar {
		display: none;
	}

	.filters__chip {
		flex: 0 0 auto;
		padding: 6px 11px;
		font-size: 0.74rem;
	}

	.stage__canvas {
		margin: 4px 8px 0;
	}

	.nav {
		width: 40px;
		height: 40px;
		background: rgba(10, 9, 8, 0.55);
	}

	.nav--prev {
		left: 6px;
	}

	.nav--next {
		right: 6px;
	}

	.stage__tools {
		top: 8px;
		right: 8px;
	}

	.caption {
		grid-template-columns: 1fr auto;
		grid-template-areas:
			"title index"
			"kicker kicker";
		gap: 2px 12px;
		padding: 8px 16px 4px;
		text-align: left;
	}

	.caption__title {
		grid-area: title;
		font-size: 1.05rem;
	}

	.caption__index {
		grid-area: index;
		align-self: center;
	}

	.caption__kicker {
		grid-area: kicker;
	}

	.filmstrip {
		padding: 8px 16px calc(12px + var(--footer-pad));
		gap: 8px;
		mask-image: linear-gradient(to right, transparent, #000 16px, #000 calc(100% - 16px), transparent);
	}

	.salon {
		--gutter: 4px;
		padding: 6px 6px 48px;
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		transition-duration: 0.01ms !important;
	}

	.filmstrip {
		scroll-behavior: auto;
	}
}
