/* ==========================================================================
   Effects: CRT, screensaver, power screen, toasts, context menu
   ========================================================================== */

/* CRT: scanlines, a slow roll bar and a vignette. Pointer-transparent. */
.fx-crt {
	position: fixed;
	inset: 0;
	z-index: 8000;
	pointer-events: none;
	background:
		repeating-linear-gradient(0deg, rgb(0 0 0 / 0.22) 0 1px, transparent 1px 3px),
		radial-gradient(120% 120% at 50% 50%, transparent 60%, rgb(0 0 0 / 0.55) 100%);
	mix-blend-mode: multiply;
}
.fx-crt::after {
	content: '';
	position: absolute;
	inset: -20% 0 auto;
	height: 20%;
	background: linear-gradient(180deg, transparent, rgb(255 255 255 / 0.035), transparent);
	animation: crt-roll 7s linear infinite;
	mix-blend-mode: screen;
}
.no-crt .fx-crt { display: none; }

@keyframes crt-roll { to { transform: translateY(700%); } }

@media (max-width: 899px) {
	.fx-crt { background: repeating-linear-gradient(0deg, rgb(0 0 0 / 0.16) 0 1px, transparent 1px 3px); }
}

/* --------------------------------------------------------------------------
   Screensaver
   -------------------------------------------------------------------------- */

.saver {
	position: fixed;
	inset: 0;
	z-index: 8500;
	background: #000;
	animation: fade-in 0.8s ease both;
}
.saver[hidden] { display: none; }
.saver canvas { width: 100%; height: 100%; }
@keyframes fade-in { from { opacity: 0; } }

/* --------------------------------------------------------------------------
   Shut down
   -------------------------------------------------------------------------- */

.power {
	position: fixed;
	inset: 0;
	z-index: 9500;
	display: grid;
	place-content: center;
	justify-items: center;
	gap: 28px;
	padding: 24px;
	background: #000;
	text-align: center;
}
.power[hidden] { display: none; }
.power__line {
	color: #ff8a3d;
	font-family: var(--f-display);
	font-size: clamp(20px, 3vw, 38px);
	text-transform: uppercase;
	text-shadow: 0 0 12px rgb(255 138 61 / 0.6);
	animation: fade-in 1.2s 0.6s both;
}
.power__btn {
	display: grid;
	justify-items: center;
	gap: 8px;
	color: var(--pink);
	font-family: var(--f-display);
	font-size: 12px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	animation: fade-in 1s 1.6s both;
}
.power__icon { width: 64px; filter: drop-shadow(0 0 10px var(--red)); }
.power__btn:hover .power__icon { filter: drop-shadow(0 0 22px var(--red)) brightness(1.3); }

.power__note {
	margin: -12px 0 0;
	color: var(--pink);
	font-family: var(--f-display);
	font-size: clamp(14px, 1.4vw, 20px);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	animation: fade-in 1s 1.2s both;
}
.power__note[hidden] { display: none; }

.os.is-shutting-down,
.taskbar.is-shutting-down { animation: crt-off 0.6s var(--ease-in) forwards; }

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */

.toasts {
	position: fixed;
	right: 16px;
	bottom: calc(var(--taskbar-h) + 14px);
	z-index: 7000;
	display: grid;
	gap: 10px;
	justify-items: end;
	pointer-events: none;
}
@media (max-width: 899px) {
	.toasts { left: 16px; right: 16px; bottom: calc(16px + var(--safe-b)); justify-items: stretch; }
}

.toast {
	display: flex;
	align-items: center;
	gap: 12px;
	max-width: 380px;
	padding: 10px 14px;
	border: 2px solid var(--red);
	background: #080000;
	box-shadow: var(--glow), 0 12px 30px rgb(0 0 0 / 0.6);
	pointer-events: auto;
	animation: toast-in 0.4s var(--ease-snap) both;
}
.toast.is-out { animation: toast-out 0.3s var(--ease-in) forwards; }
.toast .pd-icon { width: 34px; flex: none; }
.toast__text { font-size: 20px; line-height: 1.15; }
.toast__text b { font-family: var(--f-display); font-size: 12px; font-weight: 400; letter-spacing: 0.08em; text-transform: uppercase; display: block; color: var(--red); }
.toast a { margin-left: auto; font-family: var(--f-display); font-size: 11px; text-transform: uppercase; white-space: nowrap; }

@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

/* --------------------------------------------------------------------------
   Desktop context menu
   -------------------------------------------------------------------------- */

.ctxmenu {
	position: fixed;
	z-index: 6000;
	min-width: 220px;
	padding: 4px;
	border: 2px solid var(--red);
	background: #050000;
	box-shadow: var(--glow), 0 18px 40px rgb(0 0 0 / 0.7);
	animation: start-in 0.18s var(--ease-out);
}
.ctxmenu[hidden] { display: none; }
.ctxmenu__item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	width: 100%;
	padding: 6px 12px;
	color: var(--white);
	font-size: 20px;
	text-align: left;
}
.ctxmenu__item:hover,
.ctxmenu__item:focus-visible { background: var(--red); color: var(--black); outline: none; }
.ctxmenu__item[aria-disabled='true'] { color: #6a3a3a; pointer-events: none; }
.ctxmenu__sep { height: 1.5px; margin: 4px 6px; background: var(--red-deep); }
.ctxmenu__key { color: var(--pink); font-size: 17px; }
.ctxmenu__item:hover .ctxmenu__key { color: var(--black); }

/* --------------------------------------------------------------------------
   The crash after poking the eye too many times (os/tantrum.js)
   -------------------------------------------------------------------------- */

html.is-melting { filter: url(#pd-melt); }
html.is-melting .os { animation: melt-shake 0.09s steps(2) infinite; }
@keyframes melt-shake { 0% { translate: -5px 2px; } 100% { translate: 6px -3px; } }

.melt { position: fixed; inset: 0; z-index: 9200; pointer-events: none; }
.melt.is-off { animation: crt-off 0.6s var(--ease-in) forwards; }
.melt__defs { position: absolute; width: 0; height: 0; overflow: hidden; }
/* Whole-screen inversions on the odd frame. */
.melt__flash { position: absolute; inset: 0; background: #fff; mix-blend-mode: difference; opacity: 0; }

.oops {
	position: absolute;
	width: min(400px, calc(100vw - 32px));
	border: 2px solid var(--red);
	background: #0b0303;
	box-shadow: 0 0 0 1px #000, 8px 8px 0 rgb(0 0 0 / 0.6), var(--glow);
	animation: oops-in 0.12s var(--ease-snap) both;
}
@keyframes oops-in { from { scale: 0.85; opacity: 0; } }
.oops__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	height: 34px;
	padding: 0 6px 0 10px;
	border-bottom: 2px solid var(--red);
	background: linear-gradient(90deg, #4a0d0d, #1a0505);
	color: var(--white);
	font-family: var(--f-display);
	font-size: 12px;
	letter-spacing: 0.06em;
}
.oops__x { display: grid; place-items: center; width: 24px; height: 22px; border: 1.5px solid var(--red); }
.oops__x .pd-glyph { width: 12px; height: 12px; }
.oops__body { display: flex; align-items: center; gap: 14px; padding: 16px 16px 6px; }
.oops__icon { flex: none; width: 40px; filter: drop-shadow(0 0 6px var(--red)); }
.oops__body p { margin: 0; color: var(--white); font-size: 19px; line-height: 1.2; }
.oops__actions { display: flex; justify-content: center; padding: 8px 16px 14px; }
.oops__ok { padding: 4px 26px; border: 1.5px solid var(--red); color: var(--white); font-family: var(--f-display); font-size: 12px; outline: 1px dotted var(--blush); outline-offset: -5px; }

.win.is-wobbling { animation: win-wobble 0.18s steps(2) infinite; }
@keyframes win-wobble { 0% { translate: -8px 4px; rotate: -0.6deg; } 100% { translate: 9px -5px; rotate: 0.8deg; } }

