/* Battle of Castles : page d'accueil (DA « Peinte »).
 * Palette et matières reprises du jeu : nuit bleue, parchemin, or.
 */

/* ---------------------------------------------------------------- Bases */
@property --angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@property --glow { syntax: '<number>'; initial-value: 0; inherits: false; }

:root {
	--nuit: #16203A;
	--nuit-2: #101829;
	--nuit-3: #0B111E;
	--ardoise: #232A36;
	--parchemin: #F2EDDE;
	--muted: #9FA9BC;
	--or: #E5B84E;
	--or-clair: #FBD97E;
	--or-fonce: #C99B36;
	--bleu: #3D7DD8;
	--rouge: #D9503F;
	--violet: #8F5BC7;
	--ligne: color-mix(in srgb, var(--parchemin) 12%, transparent);
	--rayon: 20px;
	--ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
	font-family: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
	background: var(--nuit-3);
	color: var(--parchemin);
	line-height: 1.6;
	overflow-x: hidden;
	-webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

.wrap { width: min(1180px, 100% - 48px); margin-inline: auto; }
.center { text-align: center; }

.skip {
	position: absolute; left: -9999px; top: 0; z-index: 100;
	background: var(--or); color: #1B2130; padding: 10px 18px; border-radius: 0 0 12px 0;
}
.skip:focus { left: 0; }

h1, h2, h3 { font-weight: 600; line-height: 1.15; text-wrap: balance; }

h2 {
	font-size: clamp(1.9rem, 4.4vw, 3rem);
	letter-spacing: .2px;
}

.eyebrow {
	display: inline-flex; align-items: center; gap: 10px;
	font-size: .82rem; letter-spacing: .18em; text-transform: uppercase;
	color: var(--or); margin-bottom: 14px;
}
.eyebrow::before, .eyebrow::after {
	content: ''; width: 26px; height: 1px;
	background: linear-gradient(90deg, transparent, var(--or));
}
.eyebrow::after { background: linear-gradient(90deg, var(--or), transparent); }

.lead {
	color: var(--muted); max-width: 660px; margin-inline: auto;
	font-size: 1.06rem; text-wrap: pretty;
}

/* -------------------------------------------------------------- Boutons */
.btn {
	--glow: 0;
	position: relative;
	display: inline-flex; align-items: center; justify-content: center; gap: 12px;
	padding: 17px 46px;
	font-size: 1.18rem; font-weight: 600; letter-spacing: .3px;
	color: #241B06;
	background: linear-gradient(180deg, var(--or-clair), var(--or) 52%, var(--or-fonce));
	border: 0; border-radius: 999px; cursor: pointer;
	box-shadow:
		0 2px 0 rgba(255, 255, 255, .45) inset,
		0 -3px 0 rgba(120, 80, 0, .35) inset,
		0 12px 30px rgba(0, 0, 0, .45),
		0 0 calc(28px + var(--glow) * 34px) color-mix(in srgb, var(--or) calc(28% + var(--glow) * 46%), transparent);
	transition: transform .18s var(--ease-out), --glow .3s linear, filter .2s;
	overflow: hidden;
	isolation: isolate;
	will-change: transform;
}
.btn:hover { --glow: 1; filter: saturate(1.06); }
.btn:active { transform: translateY(2px) scale(.99); }
.btn:focus-visible { outline: 3px solid var(--parchemin); outline-offset: 3px; }

/* Reflet qui balaie le bouton en continu. */
.btn::after {
	content: ''; position: absolute; inset: -40% -60%;
	background: linear-gradient(105deg, transparent 42%, rgba(255, 255, 255, .75) 50%, transparent 58%);
	transform: translateX(-120%);
	animation: sheen 4.6s ease-in-out infinite;
	pointer-events: none;
}
@keyframes sheen {
	0%, 62% { transform: translateX(-120%); }
	78%, 100% { transform: translateX(120%); }
}

.btn-ghost {
	background: color-mix(in srgb, var(--parchemin) 8%, transparent);
	color: var(--parchemin);
	border: 1px solid var(--ligne);
	box-shadow: none;
	backdrop-filter: blur(6px);
	font-size: 1rem; padding: 14px 30px;
}
.btn-ghost:hover { background: color-mix(in srgb, var(--parchemin) 14%, transparent); }
.btn-ghost::after { display: none; }

/* Onde au clic (posée par le JS). */
.ripple {
	position: absolute; border-radius: 50%; transform: translate(-50%, -50%) scale(0);
	background: radial-gradient(circle, rgba(255, 255, 255, .85), transparent 70%);
	animation: ripple .55s ease-out forwards; pointer-events: none;
}
@keyframes ripple { to { transform: translate(-50%, -50%) scale(1); opacity: 0; } }

/* ----------------------------------------------------------------- Hero */
.hero {
	position: relative;
	min-height: 100svh;
	display: grid; place-items: center;
	text-align: center;
	overflow: hidden;
	background: linear-gradient(180deg, #0C1430, #16203A 55%, #0F1726);
	padding: 74px 0 96px;
}

.scene { position: absolute; inset: 0; pointer-events: none; }

.layer {
	position: absolute; left: 50%; width: 118%;
	transform: translate3d(-50%, 0, 0);
	will-change: transform;
}
.layer img { width: 100%; height: auto; }

/* Le ciel couvre tout le cadre : la vallée et le premier plan se posent dessus. */
.layer-sky { top: -8%; height: 116%; opacity: .96; }
.layer-sky img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; }

.layer-valley { bottom: -8%; }
.layer-fg { bottom: -12%; width: 130%; }


/* Étoiles + lucioles + braises : un seul canvas plein cadre. */
.scene canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Halos des torches : deux points chauds qui respirent. */
.torch {
	position: absolute; width: 260px; height: 260px; border-radius: 50%;
	background: radial-gradient(circle, rgba(255, 187, 92, .42), rgba(255, 150, 40, .12) 45%, transparent 70%);
	mix-blend-mode: screen;
	animation: flicker 3.4s ease-in-out infinite;
}
.torch.t1 { left: 6%; bottom: 16%; }
.torch.t2 { right: 7%; bottom: 17%; animation-delay: -1.7s; }
@keyframes flicker {
	0%, 100% { opacity: .72; transform: scale(1); }
	28% { opacity: .95; transform: scale(1.06); }
	54% { opacity: .62; transform: scale(.97); }
	76% { opacity: .88; transform: scale(1.03); }
}

/* Voile atmosphérique + vignette : donne la profondeur au fond peint. */
.vignette {
	position: absolute; inset: 0;
	background:
		radial-gradient(120% 80% at 50% 42%, transparent 38%, rgba(6, 10, 22, .62) 100%),
		linear-gradient(180deg, rgba(8, 13, 28, .55) 0%, transparent 26%, transparent 62%, rgba(6, 10, 20, .85) 100%);
}

/* Grain animé, très léger : casse les aplats et fait « peint ». */
.grain {
	position: absolute; inset: -50%;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
	opacity: .045; mix-blend-mode: overlay;
	animation: grain 1.1s steps(3) infinite;
}
@keyframes grain {
	0% { transform: translate(0, 0); }
	33% { transform: translate(-3%, 2%); }
	66% { transform: translate(2%, -3%); }
	100% { transform: translate(0, 0); }
}

.hero-content {
	position: relative; z-index: 2;
	display: flex; flex-direction: column; align-items: center;
	padding-inline: 24px;
}

.crown {
	width: clamp(74px, 8vw, 116px);
	filter: drop-shadow(0 10px 22px rgba(0, 0, 0, .5)) drop-shadow(0 0 18px rgba(229, 184, 78, .45));
	animation: crown-in 1.1s var(--ease-out) both, float 5.5s ease-in-out 1.1s infinite;
	margin-bottom: -6px;
}
@keyframes crown-in {
	from { opacity: 0; transform: translateY(-70px) scale(.7) rotate(-8deg); }
}
@keyframes float {
	50% { transform: translateY(-9px); }
}

.logo {
	width: clamp(260px, 38vw, 510px);
	filter: drop-shadow(0 14px 30px rgba(0, 0, 0, .55));
	animation: logo-in 1.1s .18s var(--ease-out) both;
}
@keyframes logo-in {
	from { opacity: 0; transform: translateY(26px) scale(.94); filter: blur(6px); }
}

.hero h1 { margin: 0; }
.sr-only {
	position: absolute; width: 1px; height: 1px; overflow: hidden;
	clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.tagline {
	font-size: clamp(1.1rem, 2.2vw, 1.5rem);
	margin: 14px 0 4px; max-width: 34ch; text-wrap: balance;
	animation: rise .9s .4s var(--ease-out) both;
}
.tagline b { color: var(--or); font-weight: 600; }
.hero .sub {
	color: var(--muted); margin-bottom: 30px;
	animation: rise .9s .52s var(--ease-out) both;
}
.hero .cta { animation: rise .9s .64s var(--ease-out) both; }
.hero .hint {
	font-size: .92rem; color: var(--muted); margin-top: 14px;
	animation: rise .9s .74s var(--ease-out) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

.badges {
	list-style: none; display: flex; flex-wrap: wrap; justify-content: center;
	gap: 10px; margin-top: 30px;
	animation: rise .9s .86s var(--ease-out) both;
}
.badges li {
	display: inline-flex; align-items: center; gap: 8px;
	font-size: .9rem; color: var(--parchemin);
	padding: 7px 16px; border-radius: 999px;
	background: color-mix(in srgb, #0A1122 55%, transparent);
	border: 1px solid var(--ligne);
	backdrop-filter: blur(8px);
}
.badges li::before {
	content: ''; width: 7px; height: 7px; border-radius: 50%;
	background: var(--or); box-shadow: 0 0 10px var(--or);
}

.scroll-cue {
	position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
	z-index: 2; display: grid; justify-items: center; gap: 6px;
	color: var(--muted); font-size: .8rem; letter-spacing: .14em; text-transform: uppercase;
	animation: rise 1s 1.2s var(--ease-out) both;
}
.scroll-cue span {
	width: 22px; height: 22px; border-right: 2px solid var(--or); border-bottom: 2px solid var(--or);
	transform: rotate(45deg); animation: bob 1.8s ease-in-out infinite;
}
@keyframes bob { 50% { transform: rotate(45deg) translate(4px, 4px); opacity: .5; } }

/* ------------------------------------------------------------- Sections */
section { position: relative; padding: clamp(72px, 9vw, 120px) 0; }
.sect-head { text-align: center; margin-bottom: 54px; }

.band-nuit { background: linear-gradient(180deg, var(--nuit-3), var(--nuit-2)); }
.band-ardoise { background: var(--nuit-2); }

/* Révélation au défilement : scroll-driven quand le navigateur sait faire,
   IntersectionObserver (classe .in) en repli. */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity .7s var(--ease-out), transform .7s var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }
@supports (animation-timeline: view()) {
	.reveal { opacity: 1; transform: none; animation: reveal linear both; animation-timeline: view(); animation-range: entry 8% cover 32%; }
	@keyframes reveal { from { opacity: 0; transform: translateY(28px); } }
}

/* ---------------------------------------------------------------- Démo */
.demo-wrap { position: relative; }
.demo-frame {
	position: relative; border-radius: 24px; overflow: hidden;
	border: 1px solid color-mix(in srgb, var(--or) 34%, transparent);
	box-shadow: 0 40px 90px rgba(0, 0, 0, .55), 0 0 0 6px rgba(255, 255, 255, .02);
	background: #24351A;
	aspect-ratio: 16 / 9;
}
.demo-frame canvas { width: 100%; height: 100%; display: block; }
.demo-frame::after {
	content: ''; position: absolute; inset: 0; pointer-events: none;
	background: radial-gradient(130% 90% at 50% 45%, transparent 55%, rgba(6, 10, 20, .45));
}
.demo-live {
	position: absolute; top: 16px; left: 16px; z-index: 2;
	display: inline-flex; align-items: center; gap: 8px;
	padding: 6px 14px; border-radius: 999px; font-size: .82rem; letter-spacing: .1em; text-transform: uppercase;
	background: rgba(10, 16, 28, .68); border: 1px solid var(--ligne); backdrop-filter: blur(6px);
}
.demo-live::before {
	content: ''; width: 8px; height: 8px; border-radius: 50%; background: #62D66A;
	box-shadow: 0 0 10px #62D66A; animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }

.demo-caption {
	position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
	z-index: 3;
	z-index: 2; width: min(720px, calc(100% - 32px)); text-align: center;
	padding: 12px 22px; border-radius: 16px;
	background: rgba(10, 16, 28, .72); border: 1px solid var(--ligne);
	backdrop-filter: blur(10px);
	font-size: clamp(.9rem, 1.7vw, 1.05rem);
	transition: opacity .35s;
}
.demo-caption b { color: var(--or); font-weight: 600; }

.demo-legend {
	display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 26px;
	margin-top: 26px; color: var(--muted); font-size: .95rem;
}
.demo-legend i {
	width: 12px; height: 12px; border-radius: 4px; display: inline-block;
	margin-right: 8px; vertical-align: -1px;
}

/* --------------------------------------------------------------- Cartes */
.cards {
	display: grid; gap: 22px;
	grid-template-columns: repeat(auto-fit, minmax(248px, 1fr));
}
.card {
	position: relative; padding: 32px 26px 30px; border-radius: var(--rayon);
	background: linear-gradient(165deg, color-mix(in srgb, var(--ardoise) 92%, var(--bleu) 8%), #161C27);
	border: 1px solid var(--ligne);
	overflow: hidden;
	transform-style: preserve-3d;
	transition: transform .25s var(--ease-out), border-color .25s;
}
.card:hover { border-color: color-mix(in srgb, var(--or) 45%, transparent); }
/* Halo doré qui suit le curseur (variables posées par le JS). */
.card::before {
	content: ''; position: absolute; inset: -1px; opacity: 0; transition: opacity .3s;
	background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 0%),
		color-mix(in srgb, var(--or) 22%, transparent), transparent 62%);
	pointer-events: none;
}
.card:hover::before { opacity: 1; }
.card .ico {
	width: 62px; height: 62px; margin-bottom: 16px;
	filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .45));
}
.card h3 { font-size: 1.22rem; margin-bottom: 8px; color: var(--parchemin); }
.card p { color: var(--muted); font-size: .98rem; }
.card b { color: var(--or); font-weight: 500; }

/* ------------------------------------------------------------ Deux blocs */
.split {
	display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(30px, 5vw, 64px);
	align-items: center;
}
.split .shot {
	position: relative; border-radius: var(--rayon); overflow: hidden;
	border: 1px solid var(--ligne); box-shadow: 0 30px 70px rgba(0, 0, 0, .5);
}
.split .shot img { width: 100%; transition: transform .6s var(--ease-out); }
.split .shot:hover img { transform: scale(1.04); }
.steps { list-style: none; display: grid; gap: 16px; margin-top: 22px; }
.steps li { display: grid; grid-template-columns: 34px 1fr; gap: 14px; align-items: start; }
.steps b {
	display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
	background: color-mix(in srgb, var(--or) 18%, transparent);
	border: 1px solid color-mix(in srgb, var(--or) 40%, transparent);
	color: var(--or); font-size: .95rem;
}
.steps p { color: var(--muted); }
.steps strong { color: var(--parchemin); font-weight: 500; display: block; }

/* -------------------------------------------------------------- Chiffres */
.stats {
	display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px;
}
.stat {
	text-align: center; padding: 28px 18px; border-radius: var(--rayon);
	background: color-mix(in srgb, var(--ardoise) 60%, transparent);
	border: 1px solid var(--ligne);
}
.stat .n {
	font-size: clamp(2.2rem, 5vw, 3.2rem); font-weight: 600; line-height: 1;
	background: linear-gradient(180deg, var(--or-clair), var(--or-fonce));
	-webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat .l { color: var(--muted); font-size: .95rem; margin-top: 8px; }

/* ------------------------------------------------------- Sous le capot */
.forge { border-top: 1px solid var(--ligne); }
.techs { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.tech {
	padding: 26px 24px; border-radius: 16px;
	background: color-mix(in srgb, var(--ardoise) 45%, transparent);
	border: 1px solid var(--ligne);
	border-top: 2px solid color-mix(in srgb, var(--or) 55%, transparent);
}
.tech svg { width: 30px; height: 30px; fill: var(--or); margin-bottom: 12px; }
.tech h3 { font-size: 1.06rem; margin-bottom: 6px; }
.tech p { color: var(--muted); font-size: .94rem; }

/* Fil de lecture doré en haut de page. */
.progress {
	position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60;
	background: transparent; pointer-events: none;
}
.progress span {
	display: block; height: 100%; width: 0;
	background: linear-gradient(90deg, var(--or-fonce), var(--or-clair));
	box-shadow: 0 0 14px color-mix(in srgb, var(--or) 60%, transparent);
}

/* ------------------------------------------------------------- CTA final */
.final {
	position: relative; overflow: hidden; text-align: center;
	background: linear-gradient(180deg, var(--nuit-2), #0A1020);
	padding: clamp(80px, 10vw, 140px) 0;
}
.final::before {
	content: ''; position: absolute; inset: 0;
	background: url('../img/hero_valley.webp') center 30% / cover no-repeat;
	opacity: .3; filter: blur(1.5px);
}
.final::after {
	content: ''; position: absolute; inset: 0;
	background: radial-gradient(90% 70% at 50% 50%, transparent, #080D18 78%);
}
.final .wrap { position: relative; z-index: 1; }

/* --------------------------------------------------------------- Footer */
footer {
	background: #070C16; color: var(--muted); padding: 46px 0 34px; font-size: .92rem;
	border-top: 1px solid var(--ligne);
}
footer .flinks { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; margin: 16px 0 18px; }
footer a:hover { color: var(--or); }
footer .fbrand { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--parchemin); }
footer .fbrand img { width: 34px; }

/* ----------------------------------------------------------- Responsive */
@media (max-width: 900px) {
	.split { grid-template-columns: 1fr; }
	.torch { width: 180px; height: 180px; }
}
@media (max-width: 760px) {
	/* Sur petit écran la carte gagne en hauteur et la narration passe dessous. */
	.demo-frame { aspect-ratio: 4 / 3; }
	.demo-caption {
		position: static; transform: none; width: 100%; margin-top: 14px;
		background: color-mix(in srgb, var(--ardoise) 65%, transparent);
	}
	.demo-legend { margin-top: 18px; gap: 10px 18px; font-size: .88rem; }
	.demo-live { top: 10px; left: 10px; padding: 4px 10px; font-size: .7rem; }
}

@media (max-width: 620px) {
	/* Écran étroit : on zoome un peu le paysage pour garder les châteaux visibles
	   sur les côtés (ils sont peints dans la vallée). */
	.layer-valley { width: 150%; bottom: -4%; }
	.layer-fg { width: 165%; bottom: -6%; }
	.badges { gap: 8px; }
	.badges li { font-size: .82rem; padding: 6px 12px; }
	.hero .hint { font-size: .86rem; }
	.hero { padding: 56px 0 80px; }
	.demo-caption { bottom: 10px; padding: 9px 14px; }
	.btn { padding: 15px 32px; font-size: 1.06rem; }
}

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, *::before, *::after {
		animation-duration: .001ms !important; animation-iteration-count: 1 !important;
		transition-duration: .001ms !important;
	}
	.reveal { opacity: 1; transform: none; }
}
