/* ==========================================================================
   INTERACTION INVITATION — Screen 1: Touch & Slide Language Selector
   Mobile-first. Gesture primer. Regional language loading.
   ========================================================================== */

/* ---------- Base ---------- */
.ii-container {
	position: fixed;
	inset: 0;
	z-index: 10000;
	background: #FAFAF7;
	overflow: hidden;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
	font-family: 'Inter', system-ui, sans-serif;
	transition: background-color 0.8s ease;
}

.ii-container.dimmed {
	background: #1a1a1a;
}

.ii-container.welcome-state {
	background: #FAFAF7;
}

/* ---------- Language Words ---------- */
.ii-words {
	position: absolute;
	inset: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0;
	padding: 80px 20px 200px;
}

.ii-word {
	position: absolute;
	font-family: 'Cormorant Garamond', Georgia, serif;
	font-weight: 700;
	font-size: clamp(1.75rem, 5.5vw, 2.875rem);
	color: #0A0A0A;
	opacity: 0.6;
	cursor: pointer;
	transition: opacity 0.4s ease, transform 0.3s ease, color 0.3s ease, text-shadow 0.4s ease;
	-webkit-tap-highlight-color: transparent;
	padding: 16px 24px;
	min-height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	/* Ensure words receive pointer/hover events above all layers */
	z-index: 30;
	pointer-events: auto;
}

.ii-word.pre-detected {
	opacity: 0.85;
}

.ii-word.glow {
	opacity: 1;
	color: #C9A84C;
	text-shadow: 0 0 30px rgba(201, 168, 76, 0.3);
	transform: scale(1.05);
}

.ii-word.target {
	opacity: 1;
	color: #C9A84C;
	text-shadow: 0 0 40px rgba(201, 168, 76, 0.5);
	transform: scale(1.15);
}

.ii-word.faded {
	opacity: 0.1;
}

.ii-word.dissolved {
	opacity: 0;
	transform: scale(0.5) translateY(20px);
	transition: opacity 0.6s ease, transform 0.6s ease;
}

.ii-word.burst {
	animation: wordBurst 0.5s ease-out;
}

@keyframes wordBurst {
	0% { transform: scale(1); }
	50% { transform: scale(1.3); }
	100% { transform: scale(1); }
}

/* Pulse animation for breathing words */
.ii-word.breathing {
	animation: breathe 3s ease-in-out infinite;
}

.ii-word:nth-child(2) { animation-delay: 0.3s; }
.ii-word:nth-child(3) { animation-delay: 0.7s; }
.ii-word:nth-child(4) { animation-delay: 1.1s; }
.ii-word:nth-child(5) { animation-delay: 1.5s; }

@keyframes breathe {
	0%, 100% { opacity: 0.5; }
	50% { opacity: 0.8; }
}

.ii-word.pre-detected.breathing {
	animation-name: breatheStrong;
}

@keyframes breatheStrong {
	0%, 100% { opacity: 0.7; }
	50% { opacity: 1; }
}

/* ---------- Fingerprint ---------- */
.ii-fingerprint {
	position: absolute;
	bottom: 25%;
	left: 50%;
	transform: translateX(-50%);
	width: 72px;
	height: 72px;
	opacity: 0;
	transition: opacity 0.6s ease;
	z-index: 10;
}

.ii-fingerprint.visible {
	opacity: 1;
}

.ii-fingerprint-circle {
	width: 72px;
	height: 72px;
	border: 2px solid rgba(201, 168, 76, 0.4);
	border-radius: 50%;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ii-fingerprint-inner {
	width: 40px;
	height: 40px;
	background: radial-gradient(circle, rgba(201, 168, 76, 0.15) 0%, transparent 70%);
	border-radius: 50%;
}

/* Ring removed — pulse only */
.ii-fingerprint-ring {
	display: none;
}

/* Fingerprint pulse */
.ii-fingerprint.pulse .ii-fingerprint-circle {
	animation: fpPulse 2s ease-in-out infinite;
}

@keyframes fpPulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0.3); }
	50% { box-shadow: 0 0 0 15px rgba(201, 168, 76, 0); }
}

/* ---------- Ink Hand ---------- */
.ii-hand {
	position: absolute;
	z-index: 20;
	opacity: 0;
	transition: opacity 0.5s ease;
	pointer-events: none;
	display: flex;
	align-items: center;
	justify-content: center;
	/* Transform set dynamically per emoji in JS */
	transform-origin: center top;
}

.ii-hand.visible {
	opacity: 0.8;
}

/* ---------- Trail ---------- */
.ii-trail {
	position: absolute;
	inset: 0;
	z-index: 5;
	pointer-events: none;
}

.ii-trail canvas {
	width: 100%;
	height: 100%;
}

/* ---------- Ripple Burst ---------- */
.ii-ripple {
	position: absolute;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	border: 2px solid #C9A84C;
	opacity: 1;
	transform: scale(1);
	animation: rippleExpand 0.8s ease-out forwards;
	pointer-events: none;
	z-index: 30;
}

@keyframes rippleExpand {
	0% { transform: scale(1); opacity: 1; }
	100% { transform: scale(8); opacity: 0; }
}

/* ---------- Instructions ---------- */
.ii-instructions {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	/* 75% closer to center: was padding 24px (edge), now ~25% from center */
	padding: 24px 20%;
	display: flex;
	justify-content: space-between;
	align-items: flex-end;
	z-index: 15;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.4s ease;
}

.ii-instructions.visible {
	opacity: 1;
}

.ii-instruction-left,
.ii-instruction-right {
	font-family: 'JetBrains Mono', monospace;
	font-size: 0.6875rem;
	font-weight: 400;
	letter-spacing: 0.04em;
	line-height: 1.5;
	max-width: 45%;
}

.ii-instruction-left {
	color: rgba(250, 250, 247, 0.5);
}

.ii-instruction-right {
	color: #C9A84C;
	text-align: right;
}

/* Light mode instructions */
.ii-container:not(.dimmed) .ii-instruction-left {
	color: rgba(10, 10, 10, 0.35);
}

/* ---------- Welcome Screen ---------- */
.ii-welcome {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	text-align: center;
	padding: 40px 24px;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.5s ease, visibility 0.5s ease;
	z-index: 50;
}

.ii-welcome.visible {
	opacity: 1;
	visibility: visible;
}

.ii-welcome-eyebrow {
	font-family: 'JetBrains Mono', monospace;
	font-size: 0.6875rem;
	font-weight: 500;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: #C9A84C;
	margin-bottom: 1.5rem;
}

.ii-welcome-title {
	font-family: 'Cormorant Garamond', Georgia, serif;
	font-size: clamp(1.25rem, 3.5vw, 2.25rem);
	font-weight: 700;
	line-height: 1.25;
	color: #0A0A0A;
	margin-bottom: 1rem;
	max-width: 520px;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.ii-welcome-subtitle {
	font-family: 'Inter', system-ui, sans-serif;
	font-size: 0.9375rem;
	color: #475569;
	line-height: 1.5;
}

/* ---------- Bridge Screen ---------- */
.ii-bridge {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	text-align: center;
	padding: 40px 24px;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.6s ease, visibility 0.6s ease;
	z-index: 50;
	background: var(--di-parchment, #FAFAF7);
}

.ii-bridge.visible {
	opacity: 1;
	visibility: visible;
}

.ii-bridge-line1,
.ii-bridge-line2 {
	font-family: 'Inter', system-ui, sans-serif;
	font-size: clamp(1rem, 3vw, 1.375rem);
	font-weight: 400;
	color: #475569;
	line-height: 1.5;
}

.ii-bridge-separator {
	font-size: 0.75rem;
	color: #C9A84C;
	opacity: 0.5;
	margin: 2rem 0;
	letter-spacing: 0.5em;
}

.ii-bridge-thesis {
	font-family: 'Cormorant Garamond', Georgia, serif;
	font-size: clamp(1.75rem, 5vw, 3rem);
	font-weight: 700;
	font-style: italic;
	color: #0A0A0A;
	line-height: 1.2;
	margin-bottom: 2.5rem;
}

.ii-bridge-cta {
	font-family: 'Space Grotesk', system-ui, sans-serif;
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #FAFAF7;
	background: #0A0A0A;
	padding: 1.125rem 2.5rem;
	min-height: 48px;
	display: inline-flex;
	align-items: center;
	cursor: pointer;
	transition: background 0.3s ease, color 0.3s ease;
}

.ii-bridge-cta:active {
	background: #C9A84C;
	color: #0A0A0A;
}

/* Mobile bridge adjustments */
.ii-container.mobile-mode .ii-bridge {
	padding: 2rem 1.5rem;
}

.ii-container.mobile-mode .ii-bridge-thesis {
	font-size: clamp(1.5rem, 6vw, 2rem);
}

/* ---------- Escape Grid ---------- */
.ii-escape {
	position: absolute;
	inset: 0;
	background: #FAFAF7;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 24px;
	z-index: 100;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ii-escape.visible {
	opacity: 1;
	visibility: visible;
}

.ii-escape-title {
	font-family: 'Space Grotesk', system-ui, sans-serif;
	font-size: 1.25rem;
	font-weight: 600;
	color: #0A0A0A;
	margin-bottom: 2rem;
	text-align: center;
}

.ii-escape-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
	width: 100%;
	max-width: 400px;
}

@media (min-width: 768px) {
	.ii-escape-grid {
		grid-template-columns: repeat(3, 1fr);
		max-width: 600px;
	}
}

.ii-escape-btn {
	background: #FFFFFF;
	border: 1px solid #CBD5E1;
	padding: 16px 12px;
	text-align: center;
	cursor: pointer;
	transition: border-color 0.2s ease, background 0.2s ease;
	min-height: 64px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	-webkit-tap-highlight-color: rgba(201, 168, 76, 0.1);
}

.ii-escape-btn:hover,
.ii-escape-btn:active {
	border-color: #C9A84C;
	background: rgba(201, 168, 76, 0.04);
}

.ii-escape-btn .native {
	font-family: 'Cormorant Garamond', Georgia, serif;
	font-size: 1.25rem;
	font-weight: 700;
	color: #0A0A0A;
}

.ii-escape-btn .english {
	font-family: 'JetBrains Mono', monospace;
	font-size: 0.625rem;
	color: #475569;
	letter-spacing: 0.04em;
}

/* ---------- Skip Link ---------- */
.ii-skip {
	position: absolute;
	top: 20px;
	right: 20px;
	font-family: 'JetBrains Mono', monospace;
	font-size: 0.6875rem;
	color: rgba(71, 85, 105, 0.4);
	text-decoration: none;
	letter-spacing: 0.04em;
	z-index: 60;
	padding: 8px 12px;
	min-height: 48px;
	display: flex;
	align-items: center;
	transition: color 0.2s ease;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.ii-skip:hover {
	color: #C9A84C;
}

/* ---------- Touch Indicator (user's own touch) ---------- */
.ii-touch-indicator {
	position: absolute;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(201, 168, 76, 0.15);
	border: 1px solid rgba(201, 168, 76, 0.3);
	transform: translate(-50%, -50%) scale(0);
	transition: transform 0.15s ease;
	pointer-events: none;
	z-index: 25;
}

.ii-touch-indicator.active {
	transform: translate(-50%, -50%) scale(1);
}

/* Shooting star trail dot */
.ii-star-trail {
	position: absolute;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(201,168,76,0.7) 0%, rgba(201,168,76,0) 70%);
	pointer-events: none;
	z-index: 24;
	animation: starFade 0.8s ease-out forwards;
}

@keyframes starFade {
	0% { opacity: 1; transform: scale(1); }
	100% { opacity: 0; transform: scale(0.2); }
}

/* ---------- Safe Area ---------- */
@supports (padding: env(safe-area-inset-bottom)) {
	.ii-instructions {
		padding-bottom: calc(20px + env(safe-area-inset-bottom));
	}
	.ii-escape {
		padding-bottom: calc(40px + env(safe-area-inset-bottom));
	}
}

/* ==========================================================================
   MOBILE — Stacked language list. No emoji demo. Premium and immediate.
   ========================================================================== */

.ii-mobile {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: 100svh;
	padding: 1.5rem 2rem;
	gap: 0;
}

.ii-mobile-separator {
	font-size: 0.75rem;
	color: #C9A84C;
	opacity: 0.4;
	margin-bottom: 1rem;
	letter-spacing: 0.5em;
}

.ii-mobile-list {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0;
	width: 100%;
	max-width: 320px;
	flex: 1;
	justify-content: center;
}

.ii-mobile-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.15rem;
	background: none;
	border: none;
	cursor: pointer;
	padding: 0.6rem 2rem;
	width: 100%;
	border-bottom: 1px solid rgba(250, 250, 247, 0.06);
	transition: transform 0.3s ease, border-color 0.3s ease;
	-webkit-tap-highlight-color: rgba(201, 168, 76, 0.1);
	min-height: 48px;
}

.ii-mobile-item:last-child {
	border-bottom: none;
}

.ii-mobile-native {
	font-family: 'Cormorant Garamond', Georgia, serif;
	font-size: clamp(1.35rem, 5.5vw, 2rem);
	font-weight: 700;
	color: rgba(250, 250, 247, 0.5);
	line-height: 1.2;
	transition: color 0.3s ease, text-shadow 0.3s ease, transform 0.3s ease;
}

.ii-mobile-english {
	font-family: 'JetBrains Mono', monospace;
	font-size: 0.625rem;
	font-weight: 400;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: rgba(250, 250, 247, 0.2);
	transition: color 0.3s ease;
}

/* Pre-detected language — slightly brighter */
.ii-mobile-item--detected .ii-mobile-native {
	color: rgba(250, 250, 247, 0.75);
}
.ii-mobile-item--detected .ii-mobile-english {
	color: rgba(201, 168, 76, 0.4);
}

/* Active/tapped state */
.ii-mobile-item--active .ii-mobile-native {
	color: #C9A84C;
	text-shadow: 0 0 30px rgba(201, 168, 76, 0.5);
	transform: scale(1.1);
}
.ii-mobile-item--active .ii-mobile-english {
	color: #C9A84C;
}

/* Hover/touch emphasis */
.ii-mobile-item:active .ii-mobile-native {
	color: #C9A84C;
	text-shadow: 0 0 20px rgba(201, 168, 76, 0.3);
}

.ii-mobile-footer {
	margin-top: 1rem;
	padding-bottom: env(safe-area-inset-bottom, 0.5rem);
	font-family: 'JetBrains Mono', monospace;
	font-size: 0.6875rem;
	font-weight: 400;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: rgba(201, 168, 76, 0.35);
}

/* Mobile mode overrides */
.ii-container.mobile-mode .ii-welcome {
	padding: 2rem 1.5rem;
}

.ii-container.mobile-mode .ii-welcome-title {
	font-size: clamp(1.25rem, 5vw, 1.75rem);
	max-width: 300px;
}

/* ---------- WebGazer UI — hidden ---------- */
#webgazerVideoFeed,
#webgazerFaceOverlay,
#webgazerFaceFeedbackBox,
#webgazerGazeDot {
	display: none !important;
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
	.ii-word.breathing,
	.ii-word.pre-detected.breathing {
		animation: none;
		opacity: 0.7;
	}
	.ii-fingerprint.pulse .ii-fingerprint-circle {
		animation: none;
	}
	.ii-ripple {
		animation-duration: 0.01ms;
	}
}
