html.ep404-show,
html.ep404-show body {
	overflow: hidden !important;
}

.ep404-intro {
	position: fixed;
	inset: 0;
	z-index: 2147483647;
	display: none;
	overflow: hidden;
	background: #030303;
	color: #f7f7f3;
	opacity: 1;
	isolation: isolate;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

html.ep404-show .ep404-intro {
	display: block;
}

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

.ep404-stage {
	position: absolute;
	inset: 0;
	overflow: hidden;
	background: #030303;
}

.ep404-noise {
	position: absolute;
	inset: -8%;
	z-index: 22;
	opacity: 0;
	pointer-events: none;
	mix-blend-mode: screen;
	background:
		repeating-linear-gradient(0deg, rgba(255,255,255,.10) 0 1px, rgba(0,0,0,0) 1px 3px),
		linear-gradient(90deg, rgba(0,255,255,.10), rgba(255,0,180,.10)),
		repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 2px, rgba(0,0,0,0) 2px 6px);
	filter: contrast(1.25) saturate(1.15);
	will-change: opacity, transform, background-position, clip-path;
}



.ep404-noise-canvas {
	position: absolute;
	inset: 0;
	z-index: 95;
	display: block;
	width: 100%;
	height: 100%;
	opacity: 0;
	pointer-events: none;
	image-rendering: pixelated;
	mix-blend-mode: normal;
	will-change: opacity, transform, filter;
}

.ep404-intro.is-terminal-glitch .ep404-noise-canvas {
	opacity: 1;
	animation:
		ep404-terminal-canvas 1250ms steps(2, end) forwards,
		ep404-terminal-canvas-jump 90ms steps(1, end) infinite;
}

.ep404-intro.is-terminal-glitch .ep404-noise {
	z-index: 94;
	opacity: 1;
	mix-blend-mode: screen;
	filter: contrast(2.2) saturate(1.8) brightness(1.18);
	animation:
		ep404-terminal-noise 1250ms steps(2, end) forwards,
		ep404-terminal-noise-pan 70ms linear infinite;
}

.ep404-intro.is-terminal-glitch .ep404-stage::before,
.ep404-intro.is-terminal-glitch .ep404-stage::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 96;
	pointer-events: none;
}

.ep404-intro.is-terminal-glitch .ep404-stage::before {
	background:
		linear-gradient(90deg, transparent 0 16%, rgba(0,255,255,.65) 16% 18%, transparent 18% 57%, rgba(255,0,174,.65) 57% 60%, transparent 60%),
		repeating-linear-gradient(0deg, rgba(255,255,255,.18) 0 1px, transparent 1px 3px);
	mix-blend-mode: screen;
	animation: ep404-terminal-flashes 1250ms steps(1, end) forwards;
}

.ep404-intro.is-terminal-glitch .ep404-stage::after {
	background: #fff;
	opacity: 0;
	animation: ep404-terminal-whiteout 1250ms steps(1, end) forwards;
}

.ep404-art-shell {
	position: absolute;
	left: 0;
	top: 0;
	width: clamp(300px, 47vmin, 570px);
	aspect-ratio: 2702 / 2664;
	will-change: transform, filter;
	opacity: 0;
}

.ep404-intro.is-prepared .ep404-art-shell {
	opacity: 1;
}

.ep404-artwork {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transform-origin: 0 0;
	will-change: transform, opacity, clip-path, filter;
	user-select: none;
	pointer-events: none;
}

.ep404-artwork-clone {
	opacity: 0;
}

.ep404-artwork-cyan {
	mix-blend-mode: screen;
	filter:
		sepia(1)
		saturate(7)
		hue-rotate(122deg)
		brightness(1.06);
}

.ep404-artwork-magenta {
	mix-blend-mode: screen;
	filter:
		sepia(1)
		saturate(8)
		hue-rotate(275deg)
		brightness(.92);
}

.ep404-loading {
	position: absolute;
	left: 50%;
	top: 50%;
	z-index: 8;
	transform: translate(-50%, -50%);
	padding: .55rem .7rem;
	background: rgba(0, 0, 0, .16);
	color: rgba(255, 255, 255, .96);
	font-size: clamp(.82rem, 1.3vw, 1.05rem);
	font-weight: 450;
	letter-spacing: .045em;
	line-height: 1;
	white-space: nowrap;
	text-shadow: 0 1px 12px rgba(0, 0, 0, .9);
	transition: opacity 110ms linear;
}

.ep404-loading.is-hidden {
	opacity: 0;
}

.ep404-copy {
	position: absolute;
	z-index: 10;
	left: 50%;
	bottom: clamp(24px, 6vh, 66px);
	width: min(92vw, 920px);
	transform: translateX(-50%);
	text-align: center;
	opacity: 0;
	filter: blur(5px);
	will-change: opacity, transform, filter;
}

.ep404-copy.is-visible {
	animation: ep404-copy-in 520ms cubic-bezier(.16, .82, .25, 1) forwards;
}

.ep404-code {
	font-size: clamp(3.2rem, 8.8vw, 7.4rem);
	font-weight: 500;
	letter-spacing: .045em;
	line-height: .82;
}

.ep404-title {
	margin-top: .55rem;
	font-size: clamp(1.25rem, 2.5vw, 2.25rem);
	letter-spacing: .035em;
	line-height: 1.05;
}

.ep404-arrival {
	margin-top: clamp(1rem, 2vh, 1.55rem);
	font-family: Newsreader, Georgia, serif;
	font-size: clamp(1.08rem, 2vw, 1.7rem);
	font-weight: 400;
	letter-spacing: .01em;
	line-height: 1.2;
}

.ep404-museum {
	margin-top: .55rem;
	font-size: clamp(.9rem, 1.35vw, 1.15rem);
	font-weight: 600;
	letter-spacing: .08em;
	line-height: 1.2;
}

.ep404-skip {
	position: absolute;
	z-index: 30;
	top: max(18px, env(safe-area-inset-top));
	right: max(18px, env(safe-area-inset-right));
	border: 0;
	border-bottom: 1px solid rgba(255, 255, 255, .55);
	border-radius: 0;
	padding: .25rem 0;
	background: transparent;
	color: rgba(255, 255, 255, .78);
	font: 500 .72rem/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
	letter-spacing: .09em;
	text-transform: uppercase;
	cursor: pointer;
	transition: color 160ms ease, border-color 160ms ease;
}

.ep404-skip:hover,
.ep404-skip:focus-visible {
	color: #fff;
	border-color: #fff;
	outline: none;
}

.ep404-intro.is-closing {
	animation: ep404-overlay-out 680ms cubic-bezier(.55, 0, 1, .55) forwards;
}

.ep404-intro.is-terminal-glitch .ep404-stage {
	animation: ep404-terminal-stage 1250ms steps(2, end) forwards;
}

.ep404-intro.is-terminal-glitch .ep404-art-shell {
	animation: ep404-terminal-shell 1250ms steps(2, end) forwards;
}

.ep404-intro.is-terminal-glitch .ep404-copy {
	animation: ep404-terminal-copy 1250ms steps(2, end) forwards;
}

.ep404-intro.is-terminal-glitch .ep404-noise {
	opacity: .92;
	animation: ep404-terminal-noise 1250ms steps(2, end) forwards, ep404-terminal-noise-pan 70ms linear infinite;
}

.ep404-art-shell.is-glitching {
	animation: ep404-shell-jitter 1080ms steps(2, end);
}

.ep404-art-shell.is-glitching .ep404-artwork-cyan {
	animation: ep404-cyan-glitch 1040ms steps(2, end);
}

.ep404-art-shell.is-glitching .ep404-artwork-magenta {
	animation: ep404-magenta-glitch 1040ms steps(2, end);
}


/*
 * Glitch finale sottile e intermittente.
 * Le fasce sono volutamente più piccole rispetto al glitch dello zoom.
 */
.ep404-art-shell.is-idle-glitching .ep404-artwork-cyan {
	animation: ep404-idle-cyan 2300ms steps(1, end) infinite;
}

.ep404-art-shell.is-idle-glitching .ep404-artwork-magenta {
	animation: ep404-idle-magenta 2700ms steps(1, end) infinite;
}

.ep404-art-shell.is-idle-glitching .ep404-artwork-base {
	animation: ep404-idle-base 3100ms steps(1, end) infinite;
}

@keyframes ep404-idle-cyan {
	0%, 7%, 100% {
		opacity: 0;
		clip-path: inset(0 0 100% 0);
		translate: 0 0;
	}
	8% {
		opacity: .24;
		clip-path: inset(14% 0 79% 0);
		translate: -4px 0;
	}
	10% {
		opacity: .18;
		clip-path: inset(46% 0 48% 0);
		translate: 5px 0;
	}
	12% {
		opacity: 0;
	}
	51% {
		opacity: .2;
		clip-path: inset(69% 0 25% 0);
		translate: -3px 0;
	}
	53% {
		opacity: .14;
		clip-path: inset(31% 0 64% 0);
		translate: 4px 0;
	}
	55% {
		opacity: 0;
	}
}

@keyframes ep404-idle-magenta {
	0%, 18%, 100% {
		opacity: 0;
		clip-path: inset(100% 0 0 0);
		translate: 0 0;
	}
	19% {
		opacity: .2;
		clip-path: inset(22% 0 72% 0);
		translate: 4px 0;
	}
	21% {
		opacity: .16;
		clip-path: inset(58% 0 36% 0);
		translate: -5px 0;
	}
	23% {
		opacity: 0;
	}
	73% {
		opacity: .18;
		clip-path: inset(82% 0 12% 0);
		translate: 3px 0;
	}
	75% {
		opacity: .13;
		clip-path: inset(39% 0 56% 0);
		translate: -4px 0;
	}
	77% {
		opacity: 0;
	}
}

@keyframes ep404-idle-base {
	0%, 41%, 44%, 78%, 81%, 100% {
		translate: 0 0;
		filter: none;
	}
	42% {
		translate: -1px 0;
		filter: contrast(1.04);
	}
	43% {
		translate: 1px 0;
	}
	79% {
		translate: 0 -1px;
		filter: contrast(1.03);
	}
	80% {
		translate: 0 1px;
	}
}

@keyframes ep404-shell-jitter {
	0%   { translate: 0 0; filter: contrast(1); }
	12%  { translate: -8px 1px; filter: contrast(1.28); }
	22%  { translate: 11px -2px; }
	34%  { translate: -3px 3px; }
	46%  { translate: 7px -1px; filter: contrast(1.12); }
	61%  { translate: -5px 0; }
	78%  { translate: 2px 1px; }
	100% { translate: 0 0; filter: contrast(1); }
}

@keyframes ep404-cyan-glitch {
	0%, 100% { opacity: 0; clip-path: inset(0 0 100% 0); translate: 0 0; }
	8%  { opacity: .48; clip-path: inset(11% 0 66% 0); translate: -11px 0; }
	19% { opacity: .58; clip-path: inset(68% 0 13% 0); translate: 14px 0; }
	31% { opacity: .33; clip-path: inset(38% 0 42% 0); translate: -7px 0; }
	49% { opacity: .52; clip-path: inset(78% 0 5% 0); translate: 9px 0; }
	71% { opacity: .2; clip-path: inset(21% 0 63% 0); translate: -4px 0; }
}

@keyframes ep404-magenta-glitch {
	0%, 100% { opacity: 0; clip-path: inset(100% 0 0 0); translate: 0 0; }
	10% { opacity: .43; clip-path: inset(55% 0 24% 0); translate: 12px 0; }
	24% { opacity: .56; clip-path: inset(5% 0 77% 0); translate: -15px 0; }
	42% { opacity: .28; clip-path: inset(72% 0 8% 0); translate: 7px 0; }
	58% { opacity: .46; clip-path: inset(26% 0 55% 0); translate: -10px 0; }
	77% { opacity: .18; clip-path: inset(84% 0 4% 0); translate: 4px 0; }
}

@keyframes ep404-terminal-stage {
	0%   { filter: none; transform: translate3d(0,0,0); }
	7%   { filter: contrast(1.8) brightness(1.2) saturate(1.5); transform: translate3d(-12px,2px,0); }
	14%  { filter: invert(.35) contrast(2.4); transform: translate3d(16px,-4px,0); }
	23%  { filter: contrast(2.8) brightness(.65) saturate(2); transform: translate3d(-8px,6px,0); }
	34%  { filter: invert(.8) contrast(3.2) brightness(1.6); transform: translate3d(20px,-2px,0); }
	48%  { filter: contrast(3.5) brightness(.45); transform: translate3d(-18px,0,0); }
	61%  { filter: invert(.5) contrast(2.6) saturate(2.4); transform: translate3d(11px,5px,0); }
	76%  { filter: contrast(4) brightness(1.7); transform: translate3d(-24px,-5px,0); }
	88%  { filter: invert(1) contrast(5); transform: translate3d(18px,2px,0); }
	100% { filter: contrast(5) brightness(.2); transform: translate3d(0,0,0); }
}

@keyframes ep404-terminal-shell {
	0%   { transform: translate3d(0,0,0) scale(1); opacity: 1; }
	12%  { transform: translate3d(-18px,2px,0) scale(1.02); }
	24%  { transform: translate3d(26px,-4px,0) scale(.98); }
	38%  { transform: translate3d(-31px,6px,0) scale(1.04); opacity: .72; }
	52%  { transform: translate3d(22px,-3px,0) scale(.96); opacity: .46; }
	68%  { transform: translate3d(-36px,1px,0) scale(1.05); opacity: .3; }
	84%  { transform: translate3d(28px,-5px,0) scale(.94); opacity: .12; }
	100% { transform: translate3d(0,0,0) scale(1); opacity: 0; }
}

@keyframes ep404-terminal-copy {
	0%   { opacity: 1; filter: blur(0); transform: translateX(-50%) translateY(0); }
	10%  { opacity: 1; transform: translateX(calc(-50% - 18px)) translateY(2px); }
	18%  { opacity: .7; transform: translateX(calc(-50% + 24px)) translateY(-3px); }
	27%  { opacity: .95; filter: blur(1px); transform: translateX(calc(-50% - 12px)) translateY(4px); }
	39%  { opacity: .5; transform: translateX(calc(-50% + 31px)) translateY(-2px); }
	55%  { opacity: .28; filter: blur(2px); transform: translateX(calc(-50% - 27px)) translateY(5px); }
	71%  { opacity: .15; transform: translateX(calc(-50% + 20px)) translateY(-4px); }
	100% { opacity: 0; filter: blur(5px); transform: translateX(-50%) translateY(0); }
}

@keyframes ep404-terminal-noise {
	0%   { opacity: 0; clip-path: inset(100% 0 0 0); }
	7%   { opacity: .75; clip-path: inset(0 0 78% 0); }
	14%  { opacity: .9; clip-path: inset(42% 0 32% 0); }
	23%  { opacity: 1; clip-path: inset(0 0 0 0); }
	36%  { opacity: .8; clip-path: inset(12% 0 5% 0); }
	49%  { opacity: 1; clip-path: inset(0 0 0 0); }
	63%  { opacity: .92; clip-path: inset(4% 0 0 0); }
	79%  { opacity: 1; clip-path: inset(0 0 0 0); }
	100% { opacity: 1; clip-path: inset(0 0 0 0); }
}

@keyframes ep404-terminal-noise-pan {
	0%   { transform: translate3d(-5%, -3%, 0) scale(1.1); background-position: 0 0, 0 0, 0 0; }
	25%  { transform: translate3d(4%, 2%, 0) scale(1.08); background-position: 17px -13px, -21px 0, 11px 0; }
	50%  { transform: translate3d(-3%, 5%, 0) scale(1.12); background-position: -12px 19px, 16px 0, -15px 0; }
	75%  { transform: translate3d(5%, -4%, 0) scale(1.09); background-position: 23px -9px, -13px 0, 19px 0; }
	100% { transform: translate3d(0, 0, 0) scale(1.1); background-position: 0 0, 0 0, 0 0; }
}

@keyframes ep404-terminal-canvas {
	0%   { opacity: 0; filter: contrast(1); }
	6%   { opacity: .88; filter: contrast(1.6); }
	12%  { opacity: .35; filter: contrast(2.3); }
	19%  { opacity: 1; filter: contrast(2.8) brightness(1.15); }
	31%  { opacity: .68; filter: contrast(3.3); }
	43%  { opacity: 1; filter: contrast(4) brightness(1.35); }
	57%  { opacity: .82; filter: contrast(4.5); }
	72%  { opacity: 1; filter: contrast(5) brightness(1.6); }
	86%  { opacity: .92; filter: contrast(6); }
	100% { opacity: 1; filter: contrast(7) brightness(.65); }
}

@keyframes ep404-terminal-canvas-jump {
	0%   { transform: translate3d(-2%, 0, 0) scale(1.05); }
	25%  { transform: translate3d(2%, -1%, 0) scale(1.04); }
	50%  { transform: translate3d(-1%, 1%, 0) scale(1.06); }
	75%  { transform: translate3d(3%, 0, 0) scale(1.03); }
	100% { transform: translate3d(0, 0, 0) scale(1.05); }
}

@keyframes ep404-terminal-flashes {
	0%, 5%   { opacity: 0; transform: translateX(0); }
	6%       { opacity: .9; transform: translateX(-8%); }
	10%      { opacity: .15; }
	18%      { opacity: .8; transform: translateX(11%); }
	23%      { opacity: .05; }
	37%      { opacity: 1; transform: translateX(-14%); }
	44%      { opacity: .2; }
	58%      { opacity: .95; transform: translateX(9%); }
	66%      { opacity: .1; }
	79%      { opacity: 1; transform: translateX(-6%); }
	88%      { opacity: .3; }
	100%     { opacity: .75; transform: translateX(0); }
}

@keyframes ep404-terminal-whiteout {
	0%, 9%   { opacity: 0; }
	10%      { opacity: .75; }
	12%      { opacity: 0; }
	32%      { opacity: .35; }
	35%      { opacity: 0; }
	61%      { opacity: .55; }
	64%      { opacity: 0; }
	84%      { opacity: .92; }
	87%      { opacity: 0; }
	100%     { opacity: .18; }
}

@keyframes ep404-copy-in {
	from {
		opacity: 0;
		filter: blur(5px);
		transform: translateX(-50%) translateY(12px);
	}
	to {
		opacity: 1;
		filter: blur(0);
		transform: translateX(-50%) translateY(0);
	}
}

@keyframes ep404-overlay-out {
	from { opacity: 1; }
	to   { opacity: 0; visibility: hidden; }
}

@media (max-width: 680px) {
	.ep404-art-shell {
		width: min(78vw, 430px);
	}

	.ep404-copy {
		bottom: max(30px, calc(env(safe-area-inset-bottom) + 18px));
	}

	.ep404-code {
		font-size: clamp(3.1rem, 18vw, 5.8rem);
	}

	.ep404-title {
		font-size: clamp(1.12rem, 6vw, 1.65rem);
	}

	.ep404-arrival {
		max-width: 88vw;
		margin-right: auto;
		margin-left: auto;
		font-size: clamp(1rem, 4.8vw, 1.35rem);
	}
}

@media (prefers-reduced-motion: reduce) {
	.ep404-skip {
		display: none;
	}

	.ep404-artwork,
	.ep404-art-shell,
	.ep404-copy,
	.ep404-intro {
		animation-duration: 1ms !important;
		transition-duration: 1ms !important;
	}
}
