/* Retro Glitch CSS */

/* Base retro text styles */
.retro-text {
	font-family: "Courier New", monospace;
	font-weight: bold;
	text-transform: uppercase;
	letter-spacing: 2px;
	color: #c0c0c0;
	text-shadow: 0 0 10px #808080;
}

.retro-neon {
	color: #ffffff;
	text-shadow: 0 0 5px #ffffff, 0 0 10px #ffffff, 0 0 20px #ffffff;
}

.retro-cyan {
	color: #a0a0a0;
	text-shadow: 0 0 5px #a0a0a0, 0 0 10px #a0a0a0;
}

/* Glitch effects */
.glitch {
	position: relative;
	color: #fff;
	font-family: "Courier New", monospace;
	font-weight: bold;
}

.glitch::before,
.glitch::after {
	content: attr(data-text);
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

.glitch::before {
	animation: glitch-1 0.5s infinite;
	color: #666666;
	z-index: -1;
}

.glitch::after {
	animation: glitch-2 0.5s infinite;
	color: #999999;
	z-index: -2;
}

/* Glitch animations */
@keyframes glitch-1 {

	0%,
	14%,
	15%,
	49%,
	50%,
	99%,
	100% {
		transform: translate(0);
	}

	15%,
	49% {
		transform: translate(-2px, 2px);
	}
}

@keyframes glitch-2 {

	0%,
	20%,
	21%,
	62%,
	63%,
	99%,
	100% {
		transform: translate(0);
	}

	21%,
	62% {
		transform: translate(2px, -2px);
	}
}

/* Scanlines effect */
.scanlines {
	position: relative;
	overflow: hidden;
}

.scanlines::after {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: linear-gradient(transparent 50%, rgba(128, 128, 128, 0.1) 50%);
	background-size: 100% 4px;
	pointer-events: none;
	animation: scanlines 0.1s linear infinite;
}

@keyframes scanlines {
	0% {
		transform: translateY(0);
	}

	100% {
		transform: translateY(4px);
	}
}

/* CRT screen effect */
.crt-screen {
	background: #000;
	border-radius: 10px;
	padding: 20px;
	position: relative;
	box-shadow: inset 0 0 50px rgba(128, 128, 128, 0.1), 0 0 20px rgba(0, 0, 0, 0.8);
}

.crt-screen::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.3) 100%);
	pointer-events: none;
}

/* Flicker effect */
.flicker {
	animation: flicker 0.15s infinite linear;
}

@keyframes flicker {

	0%,
	19%,
	21%,
	23%,
	25%,
	54%,
	56%,
	100% {
		opacity: 1;
	}

	20%,
	24%,
	55% {
		opacity: 0.4;
	}

	22% {
		opacity: 0.1;
	}
}

/* Static noise */
.static {
	position: relative;
	overflow: hidden;
}

.static::after {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-image: radial-gradient(circle, transparent 20%, rgba(255, 255, 255, 0.1) 21%),
		radial-gradient(circle, transparent 20%, rgba(255, 255, 255, 0.05) 21%);
	background-size: 3px 3px, 7px 7px;
	animation: static 0.2s steps(2, end) infinite;
	pointer-events: none;
}

@keyframes static {
	0% {
		transform: translate(0, 0);
	}

	50% {
		transform: translate(-1px, 1px);
	}

	100% {
		transform: translate(1px, -1px);
	}
}

/* Grain effects */
.grain {
	position: relative;
	overflow: hidden;
}

.grain::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-image: radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
		radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
		radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.01) 1px, transparent 1px);
	background-size: 2px 2px, 3px 3px, 4px 4px;
	animation: grain 0.8s steps(8, end) infinite;
	pointer-events: none;
	z-index: 1;
}

@keyframes grain {

	0%,
	100% {
		transform: translate(0, 0) rotate(0deg);
	}

	10% {
		transform: translate(-1px, 1px) rotate(1deg);
	}

	20% {
		transform: translate(1px, 0px) rotate(-1deg);
	}

	30% {
		transform: translate(-1px, -1px) rotate(0deg);
	}

	40% {
		transform: translate(1px, 1px) rotate(1deg);
	}

	50% {
		transform: translate(0px, -1px) rotate(-1deg);
	}

	60% {
		transform: translate(-1px, 0px) rotate(0deg);
	}

	70% {
		transform: translate(1px, -1px) rotate(1deg);
	}

	80% {
		transform: translate(0px, 1px) rotate(-1deg);
	}

	90% {
		transform: translate(-1px, -1px) rotate(0deg);
	}
}

.grain-heavy {
	position: relative;
	overflow: hidden;
}

.grain-heavy::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-image: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
		radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
		radial-gradient(circle at 40% 60%, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
		radial-gradient(circle at 60% 40%, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
	background-size: 1.5px 1.5px, 2.5px 2.5px, 3.5px 3.5px, 4.5px 4.5px;
	animation: grain-heavy 0.6s steps(10, end) infinite;
	pointer-events: none;
	z-index: 1;
}

@keyframes grain-heavy {

	0%,
	100% {
		transform: translate(0, 0) rotate(0deg);
	}

	8% {
		transform: translate(-2px, 1px) rotate(1deg);
	}

	16% {
		transform: translate(1px, -1px) rotate(-1deg);
	}

	24% {
		transform: translate(-1px, -2px) rotate(0deg);
	}

	32% {
		transform: translate(2px, 1px) rotate(1deg);
	}

	40% {
		transform: translate(-1px, -1px) rotate(-1deg);
	}

	48% {
		transform: translate(1px, 2px) rotate(0deg);
	}

	56% {
		transform: translate(-2px, 0px) rotate(1deg);
	}

	64% {
		transform: translate(1px, -2px) rotate(-1deg);
	}

	72% {
		transform: translate(0px, 1px) rotate(0deg);
	}

	80% {
		transform: translate(-1px, -1px) rotate(1deg);
	}

	88% {
		transform: translate(2px, -1px) rotate(-1deg);
	}

	96% {
		transform: translate(-1px, 2px) rotate(0deg);
	}
}

/* Update body to include grain */
body {
	margin: 0;
	padding: 20px;
	background: #0a0a0a;
	font-family: "Courier New", monospace;
	color: #c0c0c0;
	min-height: 100vh;
	position: relative;
}

body::after {
	content: "";
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-image: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.008) 1px, transparent 1px),
		radial-gradient(circle at 70% 70%, rgba(255, 255, 255, 0.006) 1px, transparent 1px);
	background-size: 5px 5px, 7px 7px;
	animation: grain 1.2s steps(6, end) infinite;
	pointer-events: none;
	z-index: 0;
}

/* Ensure content stays above grain */
.container {
	max-width: 1200px;
	margin: 0 auto;
	position: relative;
	z-index: 2;
}

.section {
	margin: 40px 0;
	padding: 20px;
	border: 1px solid #333;
	border-radius: 5px;
	background: rgba(0, 0, 0, 0.5);
}

.section h2 {
	color: #ffffff;
	text-shadow: 0 0 10px #ffffff;
	margin-bottom: 20px;
	font-size: 1.5em;
}

.demo-item {
	margin: 20px 0;
	padding: 15px;
	background: rgba(0, 0, 0, 0.3);
	border-left: 3px solid #808080;
}

.demo-item h3 {
	color: #a0a0a0;
	margin-bottom: 10px;
	font-size: 1.1em;
}

.demo-item p {
	color: #888;
	font-size: 0.9em;
	margin-bottom: 15px;
}

.grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 20px;
	margin: 20px 0;
}

.card {
	background: rgba(0, 0, 0, 0.7);
	padding: 20px;
	border-radius: 5px;
	border: 1px solid #333;
}

/* Retro button styles for anchor elements */
.retro-button {
	display: inline-block;
	background: transparent;
	border: 2px solid #808080;
	padding: 10px 20px;
	cursor: pointer;
	text-decoration: none;
	font-family: "Courier New", monospace;
	font-weight: bold;
	text-transform: uppercase;
	letter-spacing: 1px;
	transition: all 0.2s ease;
	position: relative;
	/* Add these properties to prevent resizing */
	box-sizing: border-box;
	min-height: 44px;
	/* Ensures consistent height */
	white-space: nowrap;
	/* Prevents text wrapping */
	overflow: hidden;
	/* Contains pseudo-elements */
}

.retro-button:hover {
	border-color: #ffffff;
	box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.retro-button.retro-text {
	color: #c0c0c0;
	border-color: #808080;
}

.retro-button.retro-neon {
	color: #ffffff;
	border-color: #ffffff;
}

.retro-button.retro-cyan {
	color: #a0a0a0;
	border-color: #a0a0a0;
}

/* Ensure static effect doesn't cause layout shifts */
.retro-button.static::after {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: -1;
	/* Keep behind text */
}

/* Ensure glitch effect doesn't cause layout shifts */
.retro-button.glitch::before,
.retro-button.glitch::after {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: -1;
	/* Keep behind main text */
}

/* Ensure glitch effect works on anchor elements */
a.glitch {
	position: relative;
	color: #fff;
	font-family: "Courier New", monospace;
	font-weight: bold;
}

a.glitch::before,
a.glitch::after {
	content: attr(data-text);
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	padding: inherit;
	text-align: center;
}

a.glitch::before {
	animation: glitch-1 0.5s infinite;
	color: #666666;
	z-index: -1;
}

a.glitch::after {
	animation: glitch-2 0.5s infinite;
	color: #999999;
	z-index: -2;
}
