/* ============================================================
   Homepage
   ============================================================ */

/* ---------- Hero ---------- */
.hero { position: relative; padding: 80px 0 56px; overflow: hidden; }
.hero-bg {
	position: absolute; inset: 0; z-index: -1;
	background:
		radial-gradient(1100px 520px at 80% -10%, var(--accent-soft), transparent 60%),
		var(--bg);
}
.hero-grid {
	max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
	display: grid; grid-template-columns: 1.05fr .95fr; gap: 40px; align-items: center;
}

/* big logo as the headline */
.hero-logo { display: inline-flex; align-items: center; gap: 30px; }
.hero-logo svg { height: clamp(54px, 9vw, 92px); width: auto; }
.hero-logo .name {
	font-weight: 500;
	font-size: clamp(3rem, 9vw, 5.5rem); line-height: 1; color: var(--ink);
}
.hero p.lead {
	font-size: 1.25rem; color: var(--ink-soft);
	margin: 26px 0 32px; max-width: 32ch;
}
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }

/* mascot in a disk, head poking above, soft-faded bottom */
.hero-portrait {
	position: relative; display: flex; justify-content: center; align-items: flex-end;
	min-height: 480px;
	transform: translateY(-26px); /* lift so she reads as centred */
}
.portrait-disk {
	position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
	width: clamp(280px, 34vw, 380px); aspect-ratio: 1; border-radius: 50%;
	background: linear-gradient(150deg, var(--accent) 0%, #b29bff 100%);
	opacity: .16;
}
.hero-mascot {
	position: relative; z-index: 2;
	max-height: 540px; width: auto;
	-webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent 96%);
	mask-image: linear-gradient(to bottom, #000 72%, transparent 96%);
	will-change: transform; backface-visibility: hidden;
	animation: floaty 5s ease-in-out infinite;
}
@keyframes floaty { 0%, 100% { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(0, -12px, 0); } }

/* Sastra-style dialogue box (matches the engine: dark rounded box, accent name) */
.sastra-box {
	background: rgba(0, 0, 0, .72);
	border-radius: 20px;
	padding: 18px 22px;
	color: #fff;
	box-shadow: var(--shadow-md);
}
.sastra-box .sb-name {
	color: #b29bff; font-weight: 700; font-size: 1.25rem; /* ~1.2x the text, like the engine */
	margin-bottom: 8px; font-family: var(--font); line-height: 1.2;
}
.sastra-box .sb-text { font-size: 1.05rem; line-height: 1.6; min-height: 1.6em; } /* reserve a line so the name doesn't jump while typing */

.hero-chip {
	position: absolute; z-index: 3;
	left: -6px; bottom: 96px;
	max-width: 270px;
	will-change: transform;
	animation: floaty 5.5s ease-in-out infinite .5s;
}

/* ---------- VN emulator (strictly mirrors the Sastra dialogue layout) ---------- */
.vn-demo-wrap { max-width: 900px; margin: 0 auto; }
.vn {
	container-type: inline-size;
	position: relative; aspect-ratio: 16 / 9;
	border-radius: var(--radius-lg); overflow: hidden;
	border: 1px solid var(--border); box-shadow: var(--shadow-lg);
	background: #2a2140; cursor: pointer; user-select: none;
}
.vn-bg {
	position: absolute; inset: 0;
	background:
		radial-gradient(120% 90% at 72% -18%, #ffb3d9, transparent 52%),
		radial-gradient(120% 100% at 18% 122%, #2a1a44, transparent 58%),
		linear-gradient(160deg, #2a2140, #4a3a6b 60%, #6b4a7a);
}
.vn-sun { position: absolute; width: 14cqw; aspect-ratio: 1; border-radius: 50%; top: 12%; right: 16%; background: radial-gradient(circle, #fff6da, #ffcaa0); filter: blur(2px); opacity: .9; }
/* sprite fade — matches the engine's .vn-sprite transition */
.vn-sprite {
	position: absolute; bottom: 0; right: 7%; height: 90%; width: auto;
	opacity: 0; transform: translateY(2cqw) scale(.98);
	transition: opacity .45s cubic-bezier(.25,.46,.45,.94), transform .45s cubic-bezier(.25,.46,.45,.94);
	pointer-events: none;
}
.vn-sprite.show { opacity: 1; transform: none; }

/* dialogue layout — mirrors the engine's single-dialogue.
   Centering is done with flexbox (NO transforms), so it stays perfectly centred
   on every screen and never drifts after tab-out/compositing. */
.vn-stage {
	position: absolute; inset: 0;
	display: flex; justify-content: center; align-items: center; /* center position (engine default) */
	padding: 6cqw;
	pointer-events: none;
}
.vn-stage.pos-bottom { align-items: flex-end; padding-bottom: 7cqw; } /* bottom position: grows upward */
.vn-dialogue {
	display: flex; align-items: center; gap: 4.5cqw; max-width: 100%;
	opacity: 0; transition: opacity .5s cubic-bezier(.25,.46,.45,.94); /* exact engine scene-layer fade */
}
.vn-dialogue.show { opacity: 1; }

.vn-avatar {
	width: 17cqw; height: 17cqw; border-radius: 2.3cqw; object-fit: cover; flex: none;
	transition: all .3s ease;
}
/* content is sized by its text between a min and max width (like the engine's
   min-width:400 / max-width:600), NOT flex — so hiding the avatar never resizes it */
.vn-content {
	background: rgba(0, 0, 0, .7); border-radius: 2.3cqw; padding: 3.4cqw;
	width: fit-content; min-width: 40cqw; max-width: 58cqw; color: #fff;
	transition: all .3s ease;
}
.vn-name { color: #b29bff; font-weight: 700; font-size: 2.7cqw; margin-bottom: 1.4cqw; }
.vn-text { font-size: 2.3cqw; line-height: 1.6; min-height: 3.6cqw; white-space: pre-wrap; }
/* sprite speaking: avatar hidden, box centred horizontally (width unchanged) */
.vn-dialogue.no-avatar { gap: 0; }
.vn-dialogue.no-avatar .vn-avatar { display: none; }
.vn-hint {
	position: absolute; right: 3cqw; bottom: 2.6cqw;
	color: rgba(255,255,255,.75); font-size: 1.7cqw; font-weight: 600;
	display: flex; align-items: center; gap: .4em; pointer-events: none;
}
.vn-hint .pulse { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }

/* on small screens the stage shrinks, so scale the UI up a little to stay readable */
@container (max-width: 540px) {
	.vn-stage { padding: 4cqw; }
	.vn-stage.pos-bottom { padding-bottom: 6cqw; }
	.vn-dialogue { gap: 4cqw; }
	.vn-avatar { width: 22cqw; height: 22cqw; border-radius: 3cqw; }
	.vn-content { padding: 4.2cqw; min-width: 50cqw; max-width: 78cqw; border-radius: 3cqw; }
	.vn-name { font-size: 4cqw; margin-bottom: 1.8cqw; }
	.vn-text { font-size: 3.5cqw; min-height: 5cqw; }
	.vn-hint { font-size: 2.8cqw; bottom: 3cqw; }
	.vn-sun { width: 18cqw; }
}

.demo-caption { text-align: center; color: var(--muted); margin-top: 16px; font-size: .95rem; }
.art-credit { text-align: center; color: var(--muted); opacity: .65; font-size: .85rem; margin: 0 0 40px; }

/* ---------- Features ---------- */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-top: 8px; }
.feature {
	background: var(--panel); border: 1px solid var(--border);
	border-radius: var(--radius); padding: 26px 24px;
	transition: transform .2s ease, border-color .2s ease;
}
.feature:hover { transform: translateY(-4px); border-color: var(--accent-soft); }
.feature .ic { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent); margin-bottom: 15px; }
.feature .ic svg { width: 24px; height: 24px; }
.feature .ic i { font-size: 22px; }
.feature h3 { margin: 0 0 8px; font-size: 1.18rem; }
.feature p { margin: 0; color: var(--ink-soft); }

/* ---------- Code showcase ---------- */
.showcase-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 72px; align-items: center; }
.code-card { background: #1d1726; border-radius: var(--radius); overflow: hidden; border: 1px solid #322a3f; }
.code-card .bar { display: flex; gap: 7px; padding: 13px 16px; background: #251e30; border-bottom: 1px solid #322a3f; align-items: center; }
.code-card .dot { width: 12px; height: 12px; border-radius: 50%; }
.code-card .bar .fname { margin-left: 10px; color: #b6acc4; font-family: var(--mono); font-size: .82rem; }
.code-card pre { margin: 0; padding: 22px; overflow-x: auto; }
.code-card code { font-family: var(--mono); font-size: .92rem; line-height: 1.75; }
.yk { color: #ff7eb6; } .yv { color: #b8e994; } .yc { color: #8a7fa0; font-style: italic; } .yp { color: #c9b6ff; }

/* ---------- Use cases ---------- */
.usecases { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.usecase { text-align: center; padding: 26px 18px; border-radius: var(--radius); background: var(--bg-alt); border: 1px solid var(--border); }
.usecase .emoji { font-size: 2rem; }
.usecase h4 { margin: 10px 0 6px; }
.usecase p { margin: 0; color: var(--ink-soft); font-size: .95rem; }

/* ---------- Steps ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; counter-reset: step; }
.step { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px 24px 24px; }
.step::before {
	counter-increment: step; content: counter(step);
	position: absolute; top: -18px; left: 24px; width: 38px; height: 38px; border-radius: 50%;
	background: var(--accent); color: #fff; font-weight: 800; display: grid; place-items: center;
}
.step h3 { margin: 6px 0 8px; }
.step p { margin: 0; color: var(--ink-soft); }

/* ---------- CTA ---------- */
.cta-wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.cta-band {
	position: relative; overflow: visible;
	background: linear-gradient(130deg, var(--accent), #b29bff);
	color: #fff; border-radius: var(--radius-lg);
	padding: 52px 48px; padding-right: 340px; /* reserve room for Zahra */
}
.cta-text { max-width: 640px; }
.cta-band h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 12px; }
.cta-band p { margin: 0 0 26px; max-width: 48ch; font-size: 1.1rem; opacity: .96; }
.cta-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.cta-band .btn-ghost { background: #fff; border-color: transparent; }
.cta-band .btn-ghost:hover { background: #fff; }
.cta-zahra {
	position: absolute; right: 44px; bottom: 0;  /* feet on the band's base */
	height: 375px; width: auto; pointer-events: none; /* head pokes above the top */
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
	.features, .usecases, .steps { grid-template-columns: 1fr 1fr; }
	.showcase-grid { grid-template-columns: 1fr; gap: 32px; }
	.hero-grid { grid-template-columns: 1fr; }
	.hero { padding-top: 48px; text-align: center; }
	.hero-logo { justify-content: center; }
	.hero p.lead { max-width: none; margin-left: auto; margin-right: auto; }
	.hero-actions { justify-content: center; }
	.hero-portrait { min-height: 420px; margin-top: 16px; transform: none; }
	.cta-band { padding-right: 280px; }
	.cta-zahra { height: 290px; right: 28px; }
	/* centre the "Write easily" text column once it stacks */
	.showcase-grid > div:last-child { text-align: center; }
}
@media (max-width: 720px) {
	.cta-band { padding-right: 48px; }
	.cta-zahra { display: none; }
}
@media (max-width: 640px) {
	.features, .usecases, .steps { grid-template-columns: 1fr; }
	.hero-mascot { max-height: 400px; }
	/* centre the chip with auto-margins (NOT transform — the floaty animation
	   uses transform, which would override transform-based centering). fit-content
	   width means it expands evenly left and right as the text types in. */
	.hero-chip {
		left: 0; right: 0; margin-left: auto; margin-right: auto;
		width: fit-content; max-width: 80%; bottom: 64px;
	}
	.cta-band { text-align: center; padding: 44px 28px; }
	.cta-text { max-width: none; }
	.cta-band p { margin-left: auto; margin-right: auto; }
	.cta-actions { justify-content: center; }
}
