/* ==========================================================================
   The eye's life (os/eyelife.js, cookies.js, wreck.js, guests.js): talking to it, letting it
   out, feeding it, it wrecking the place, and the guests on the grid.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Talking: EYE.TXT, beside the eye
   -------------------------------------------------------------------------- */

.eyetalk {
	position: fixed;
	z-index: 6400;
	width: min(380px, calc(100vw - 16px));
	border: 2px solid var(--red);
	background: #050000;
	box-shadow: var(--glow), 6px 6px 0 rgb(255 69 69 / 0.35), 0 18px 40px rgb(0 0 0 / 0.7);
	animation: start-in 0.18s var(--ease-out);
}
.eyetalk__bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 3px 4px 3px 10px;
	background: var(--red);
	color: #000;
	font-family: var(--f-display);
	font-size: 14px;
	letter-spacing: 0.08em;
}
.eyetalk__x { display: grid; place-items: center; width: 24px; height: 22px; color: #000; }
.eyetalk__x svg { width: 12px; height: 12px; }
.eyetalk__line {
	min-height: 3.2em;
	margin: 0;
	padding: 14px 16px 10px;
	color: var(--white);
	font-size: 22px;
	line-height: 1.15;
}
.eyetalk__choices { display: grid; gap: 2px; padding: 0 6px 8px; transition: opacity 0.2s; }
.eyetalk__choices.is-waiting { opacity: 0.25; }
.eyetalk__choice {
	padding: 6px 10px;
	color: var(--pink);
	font-size: 20px;
	text-align: left;
}
.eyetalk__choice::before { content: '> '; color: var(--red); }
.eyetalk__choice:hover,
.eyetalk__choice:focus-visible { background: var(--red); color: #000; outline: none; }
.eyetalk__choice:hover::before,
.eyetalk__choice:focus-visible::before { color: #000; }
.eyetalk__choice.is-rude { color: var(--red); }
.eyetalk__choice.is-bye { color: rgb(255 211 211 / 0.6); }

/* --------------------------------------------------------------------------
   Out on the desktop: smaller, above the icons, leaning into where it is going
   -------------------------------------------------------------------------- */

.desk__eye.is-free {
	z-index: 4;
	scale: 0.55;
	rotate: var(--lean, 0deg);
	animation: none;
}

/* Eating: three chews. */
.desk__eye.is-eating .eye__lid { animation: eye-chomp 1s var(--ease-out); }
@keyframes eye-chomp {
	0%, 100% { transform: none; }
	12% { transform: scale(1.12, 0.12); }
	28% { transform: scale(1.04, 1.08); }
	44% { transform: scale(1.1, 0.2); }
	60% { transform: scale(1.03, 1.05); }
	76% { transform: scale(1.06, 0.3); }
}

/* --------------------------------------------------------------------------
   Losing it (os/wreck.js)
   -------------------------------------------------------------------------- */

.eyebeam {
	position: fixed;
	z-index: 6300;
	height: 6px;
	margin-top: -3px;
	transform-origin: 0 50%;
	border-radius: 3px;
	background: linear-gradient(#ff4545, #fff 40%, #fff 60%, #ff4545);
	box-shadow: 0 0 10px #ff4545, 0 0 26px rgb(255 69 69 / 0.8);
	pointer-events: none;
}
.scorch {
	position: absolute;
	z-index: 1;
	width: 110px;
	height: 80px;
	translate: -50% -50%;
	border-radius: 50%;
	/* Soot, not a ring: dark in the middle, smudged out, a faint warm edge. */
	background:
		radial-gradient(closest-side at 40% 55%, rgb(0 0 0 / 0.85), rgb(10 2 2 / 0.6) 50%, transparent 100%),
		radial-gradient(closest-side at 65% 40%, rgb(0 0 0 / 0.7), rgb(40 8 6 / 0.35) 60%, transparent 100%);
	filter: blur(3px);
	pointer-events: none;
}
.crack {
	position: absolute;
	inset: 0;
	z-index: 50;
	pointer-events: none;
}
.crack svg { width: 100%; height: 100%; }
.crack path,
.crack circle {
	fill: none;
	stroke: rgb(255 255 255 / 0.8);
	stroke-width: 1.4px;
	vector-effect: non-scaling-stroke;
	filter: drop-shadow(0 0 2px rgb(255 69 69 / 0.9));
}
.desk.is-wrecking::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 1;
	background: rgb(255 0 0 / 0.08);
	pointer-events: none;
	animation: wreck-flicker 0.24s steps(2) infinite;
}
@keyframes wreck-flicker { 50% { background: rgb(255 0 0 / 0.02); } }

/* --------------------------------------------------------------------------
   The cookie jar and cookies (pixel art, os/cookies.js)
   -------------------------------------------------------------------------- */

.cookiejar,
.cookie {
	position: absolute;
	z-index: 3;
	translate: -50% -50%;
	image-rendering: pixelated;
	-webkit-user-drag: none;
	touch-action: none;
}
.cookiejar { width: 88px; cursor: grab; filter: drop-shadow(0 8px 10px rgb(0 0 0 / 0.6)); }
.cookiejar.is-moving { cursor: grabbing; }
.cookiejar__img { display: block; width: 100%; image-rendering: pixelated; pointer-events: none; }
/* The lid: where cookies come from. */
.cookiejar__lid {
	position: absolute;
	left: 14%;
	right: 14%;
	top: 0;
	height: 26%;
	cursor: pointer;
}
.cookiejar:has(.cookiejar__lid:hover) .cookiejar__img { filter: brightness(1.25) drop-shadow(0 0 6px rgb(255 69 69 / 0.8)); }
.cookie { width: 48px; cursor: grab; }
.cookie.is-carried { z-index: 6; cursor: grabbing; scale: 1.15; filter: drop-shadow(0 10px 8px rgb(0 0 0 / 0.6)); }
.cookie.is-loose { filter: drop-shadow(0 4px 4px rgb(0 0 0 / 0.6)); }
.crumb {
	position: absolute;
	z-index: 3;
	width: 6px;
	height: 6px;
	pointer-events: none;
}

/* --------------------------------------------------------------------------
   Guests on the grid (os/guests.js)
   -------------------------------------------------------------------------- */

/* The handle over Snoop: drag him about. */
.desk__grab { position: absolute; z-index: 3; cursor: grab; touch-action: none; } /* above the icons layer, like the cookie jar */
.desk__grab[hidden] { display: none; }
.desk__grab.is-held { cursor: grabbing; }

.desk__guests {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	image-rendering: pixelated;
}

@media (prefers-reduced-motion: reduce) {
	.desk__eye.is-eating .eye__lid,
	.desk.is-wrecking::after { animation: none; }
}
