/* ÉCLOSION — carte de vœux interactive au lavis. Couleurs reprises de config.js (variables posées par eclosion.js). */
@font-face { font-family: "Instrument Serif"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/instrument-serif-latin.woff2) format("woff2"); }
@font-face { font-family: "Instrument Serif"; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/instrument-serif-italique-latin.woff2) format("woff2"); }

:root {
  --paper: #f6e4c8;
  --ink: #2f2925;
  --accent: #b4596a;
  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); }
body { font-family: var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; }
[hidden] { display: none !important; }

.ec, .ec-stage { position: fixed; inset: 0; }
.ec-stage { overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; cursor: crosshair; }
.ec-canvas, .ec-layers { position: absolute; inset: 0; width: 100%; height: 100%; }
.ec-layers { z-index: 0; }   /* contexte d'empilement : les images de secours restent sous l'interface */
.ec-canvas { display: block; }
.ec.is-fallback .ec-canvas { display: none; }

/* Fondus de secours : les deux images d'un tableau, superposées avec le même recadrage */
.ec-scene { position: absolute; inset: 0; opacity: 0; transition: opacity var(--fade, 750ms) ease; }
.ec-scene.is-on { opacity: 1; }
.ec-scene img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.ec-scene .ec-after { opacity: 0; transition: opacity 1.6s ease; }
.ec-scene.is-revealed .ec-after { opacity: 1; }

/* Titre et repères : discrets */
.ec-head { position: absolute; top: max(16px, env(safe-area-inset-top)); left: max(18px, env(safe-area-inset-left)); display: flex; align-items: center; gap: 14px; pointer-events: none; transition: opacity .8s ease; }
.ec-title { margin: 0; font: italic 400 clamp(15px, 1.35vw, 19px)/1.2 var(--serif); letter-spacing: .01em; color: color-mix(in srgb, var(--ink) 72%, transparent); }
.ec-dots { display: flex; gap: 7px; margin: 0; padding: 0; list-style: none; }
.ec-dots li { width: 6px; height: 6px; border-radius: 50%; background: color-mix(in srgb, var(--ink) 22%, transparent); transition: background .6s ease, transform .6s ease; }
.ec-dots li.is-done { background: color-mix(in srgb, var(--accent) 70%, transparent); }
.ec-dots li.is-current { background: color-mix(in srgb, var(--ink) 62%, transparent); transform: scale(1.15); }
.ec.is-final .ec-head { opacity: 0; }

/* Texte de chaque tableau, écrit à l'encre dans le blanc du papier */
.ec-caption { position: absolute; display: flex; flex-direction: column; gap: .45em; pointer-events: none; transition: opacity .5s ease; }
.ec-caption.is-out { opacity: 0; }
.ec-caption p { margin: 0; text-wrap: balance; text-shadow: 0 0 22px color-mix(in srgb, var(--paper) 92%, transparent), 0 0 7px color-mix(in srgb, var(--paper) 85%, transparent); }
.ec-caption .ec-cap-1 { font: 400 clamp(26px, 2.9vw, 46px)/1.1 var(--serif); color: var(--ink); }
.ec-caption .ec-cap-2 { font: italic 400 clamp(20px, 2vw, 31px)/1.2 var(--serif); color: var(--accent); }
.ec-caption--right, .ec-caption--right-low { left: 56%; right: 6vw; top: 50%; transform: translateY(-50%); max-width: 520px; }
.ec-caption--right-low { top: 64%; }
.ec-caption--left { left: 6vw; right: 56%; top: 50%; transform: translateY(-50%); }
.ec-caption--top { left: 0; right: 0; top: max(10vh, calc(env(safe-area-inset-top) + 48px)); align-items: center; text-align: center; padding: 0 24px; }
.ec-caption [data-ink] { opacity: 0; }
.ec-caption [data-ink].is-on { animation: ec-ink var(--d, 2.2s) cubic-bezier(.3,.1,.25,1) var(--t, 0s) both; }
.ec-caption [data-ink] { -webkit-mask-image: linear-gradient(90deg, #000 40%, transparent 60%); mask-image: linear-gradient(90deg, #000 40%, transparent 60%); -webkit-mask-size: 300% 100%; mask-size: 300% 100%; -webkit-mask-position: 0 0; mask-position: 0 0; }
@media (max-aspect-ratio: 4/5), (max-width: 640px) {
  .ec-caption, .ec-caption--right, .ec-caption--right-low, .ec-caption--left { left: 0; right: 0; top: max(8.5vh, calc(env(safe-area-inset-top) + 46px)); transform: none; max-width: none; align-items: center; text-align: center; padding: 0 22px; }
  .ec-caption .ec-cap-1 { font-size: clamp(24px, 6.6vw, 32px); }
  .ec-caption .ec-cap-2 { font-size: clamp(19px, 5.2vw, 25px); }
  .ec-caption--m-bottom { top: auto; bottom: max(96px, calc(env(safe-area-inset-bottom) + 88px)); }
}

/* Bouton musique, discret, en haut à droite */
.ec-sound { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); width: 40px; height: 40px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: color-mix(in srgb, var(--ink) 62%, transparent); cursor: pointer; transition: color .25s ease, background .25s ease; animation: ec-in 1s ease .6s both; }
.ec-sound:hover { color: var(--ink); background: color-mix(in srgb, var(--paper) 70%, transparent); }
.ec-sound:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ec-sound svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ec-sound svg path:first-child { fill: currentColor; fill-opacity: .18; }
.ec-sound[aria-pressed="true"] .off, .ec-sound[aria-pressed="false"] .on { display: none; }

/* Invitation du premier tableau */
.ec-hint { position: absolute; left: 50%; bottom: max(28px, calc(env(safe-area-inset-bottom) + 18px)); transform: translateX(-50%); margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none;
  font: italic 400 clamp(17px, 1.6vw, 21px)/1.2 var(--serif); color: color-mix(in srgb, var(--ink) 78%, transparent); text-shadow: 0 0 14px var(--paper), 0 0 4px var(--paper);
  transition: opacity .7s ease, transform .7s ease; animation: ec-in 1.2s ease .3s both; }
.ec-hint svg { width: 84px; height: 18px; fill: none; stroke: color-mix(in srgb, var(--accent) 75%, transparent); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 130; animation: ec-stroke 2.6s ease-in-out infinite; }
.ec-hint.is-out { opacity: 0; transform: translate(-50%, 6px); }
@keyframes ec-stroke { 0% { stroke-dashoffset: 130; } 55%, 75% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -130; } }
@keyframes ec-in { from { opacity: 0; } }

/* Boutons */
.ec-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 1px solid color-mix(in srgb, var(--ink) 24%, transparent); border-radius: 999px;
  background: color-mix(in srgb, var(--paper) 72%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  color: var(--ink); font: 500 14px/1 var(--sans); letter-spacing: .02em; cursor: pointer; transition: background .25s ease, border-color .25s ease, opacity .5s ease; }
.ec-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ec-btn:hover { background: color-mix(in srgb, var(--paper) 92%, #fff); border-color: color-mix(in srgb, var(--ink) 45%, transparent); }
.ec-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ec-reveal { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); opacity: .82; animation: ec-in 1s ease .6s both; }
.ec-reveal svg { fill: color-mix(in srgb, var(--accent) 55%, transparent); stroke: none; }
.ec-reveal:hover, .ec-reveal:focus-visible { opacity: 1; }
.ec-reveal.is-out { opacity: 0; pointer-events: none; }

/* Message final, écrit dans le ciel du verger */
.ec-final { position: absolute; left: 0; right: 0; top: max(7vh, calc(env(safe-area-inset-top) + 28px)); display: flex; flex-direction: column; align-items: center; gap: clamp(10px, 1.6vh, 18px); padding: 0 24px; text-align: center; cursor: default; }
.ec-final__text { display: flex; flex-direction: column; align-items: center; gap: .25em; }
.ec-line { margin: 0; max-width: 22ch; color: var(--ink); text-wrap: balance; text-shadow: 0 0 22px color-mix(in srgb, var(--paper) 90%, transparent), 0 0 6px color-mix(in srgb, var(--paper) 80%, transparent); }
.ec-line--1 { font: 400 clamp(30px, 4.4vw, 66px)/1.08 var(--serif); letter-spacing: -.005em; max-width: 18ch; }
.ec-line--2 { max-width: 30ch; font: italic 400 clamp(21px, 2.5vw, 36px)/1.2 var(--serif); color: var(--accent); }
.ec-final__logo { min-height: 1px; color: var(--ink); }
.ec-final__logo img, .ec-final__logo svg { display: block; height: var(--logo-h, 56px); width: auto; max-width: min(70vw, 320px); }
.ec-final__logo a { display: block; border-radius: 6px; }
.ec-final__logo a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.ec-final__actions { margin-top: 6px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ec-link { font: italic 400 17px/1.3 var(--serif); color: color-mix(in srgb, var(--ink) 75%, transparent); text-decoration: none; padding: 6px 10px; border-radius: 6px; text-shadow: 0 0 10px var(--paper); }
.ec-link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.ec-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ec-credit { position: fixed; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); margin: 0; text-align: center; font: 400 12px/1.4 var(--sans); letter-spacing: .03em; color: color-mix(in srgb, var(--ink) 55%, transparent); }
.ec-credit a { color: inherit; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.ec-credit a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.ec-credit a:focus-visible { outline: 2px solid var(--accent); }

/* Apparition « à l'encre » : chaque élément se dévoile de gauche à droite, bord doux, avec un léger flou qui sèche */
.ec-final [data-ink] { opacity: 0; }
.ec-final.is-on [data-ink] { animation: ec-ink var(--d, 2.2s) cubic-bezier(.3,.1,.25,1) var(--t, 0s) both; }
@keyframes ec-ink {
  0% { opacity: 0; filter: blur(6px); -webkit-mask-position: 100% 0; mask-position: 100% 0; }
  25% { opacity: 1; }
  100% { opacity: 1; filter: blur(0); -webkit-mask-position: 0 0; mask-position: 0 0; }
}
.ec-final [data-ink] { -webkit-mask-image: linear-gradient(90deg, #000 40%, transparent 60%); mask-image: linear-gradient(90deg, #000 40%, transparent 60%); -webkit-mask-size: 300% 100%; mask-size: 300% 100%; -webkit-mask-position: 0 0; mask-position: 0 0; }

/* Chargement */
.ec-loader { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--paper); font: italic 400 18px/1 var(--serif); color: color-mix(in srgb, var(--ink) 65%, transparent); transition: opacity .8s ease; }
.ec-loader.is-out { opacity: 0; pointer-events: none; }
.ec-loader__drop { width: 14px; height: 14px; border-radius: 50%; background: color-mix(in srgb, var(--ink) 55%, transparent); animation: ec-drop 1.6s ease-in-out infinite; }
@keyframes ec-drop { 0% { transform: scale(.4); opacity: .9; } 70% { transform: scale(2.6); opacity: 0; } 100% { opacity: 0; } }

.ec-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.ec-noscript { position: fixed; inset: auto 0 40% 0; text-align: center; font: 400 28px/1.3 var(--serif); padding: 0 24px; }

@media (max-width: 640px) {
  .ec-title { font-size: 15px; }
  .ec-reveal { padding: 0 15px; }
  .ec-hint { bottom: max(84px, calc(env(safe-area-inset-bottom) + 76px)); }
}

/* Animations réduites : fondus simples, sans flou ni balayage */
@media (prefers-reduced-motion: reduce) {
  .ec-hint svg { animation: none; stroke-dashoffset: 0; }
  .ec-final [data-ink] { -webkit-mask-image: none; mask-image: none; }
  .ec-final.is-on [data-ink], .ec-caption [data-ink].is-on { animation: ec-fade .9s ease var(--t, 0s) both; }
  .ec-caption [data-ink] { -webkit-mask-image: none; mask-image: none; }
  .ec-loader__drop { animation: none; }
  .ec-scene .ec-after { transition-duration: .9s; }
}
@keyframes ec-fade { from { opacity: 0; } to { opacity: 1; } }
