/*
 * Le Royaume de Cristal — socle visuel commun.
 * Nuit polaire, glace, cyan lumineux, argent. Rouge et vert seulement en petites touches (Flocon).
 */
:root {
  --abysse: #071430;
  --nuit: #0d1f45;
  --nuit-2: #163063;
  --nuit-3: #22457f;
  --glace: #bfeaff;
  --cyan: #5fe3ff;
  --cyan-fonce: #1aa6d6;
  --argent: #d6e2ef;
  --neige: #f3f9ff;
  --texte: #eaf6ff;
  --texte-doux: #a9c4e0;
  --or: #ffd27a;
  --rouge: #e0445b;
  --sapin: #46b07a;
  --alerte: #ff9aa8;

  --police-titre: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --police-texte: 'Nunito', system-ui, sans-serif;

  --t-xs: 0.875rem;
  --t-s: 1rem;
  --t-m: 1.125rem;
  --t-l: 1.375rem;
  --t-xl: 1.75rem;
  --t-2xl: 2.25rem;

  --esp-1: 4px;
  --esp-2: 8px;
  --esp-3: 12px;
  --esp-4: 16px;
  --esp-5: 24px;
  --esp-6: 32px;
  --esp-7: 48px;
  --esp-8: 64px;

  --rayon-s: 10px;
  --rayon-m: 16px;
  --rayon-l: 24px;

  --lueur-cyan: 0 0 24px rgba(95, 227, 255, 0.45);
  --duree-rapide: 150ms;
  --duree: 260ms;
  --courbe-arrivee: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--police-texte);
  font-size: var(--t-s);
  line-height: 1.55;
  color: var(--texte);
  background-color: var(--abysse);
}

h1, h2, h3 {
  font-family: var(--police-titre);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.02em;
  margin: 0 0 var(--esp-3);
  text-wrap: balance;
}

p { margin: 0 0 var(--esp-4); }

img { max-width: 100%; display: block; }

a { color: var(--glace); text-underline-offset: 3px; }
a:hover { color: #fff; }

:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 6px;
}

.visuellement-cache {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.lien-evitement {
  position: absolute;
  left: var(--esp-4);
  top: -100px;
  background: var(--cyan);
  color: var(--abysse);
  padding: var(--esp-2) var(--esp-4);
  border-radius: var(--rayon-s);
  z-index: 100;
}
.lien-evitement:focus { top: var(--esp-4); }

/* ---------- Le décor : château, aurore, neige ---------- */
.decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background-color: var(--abysse);
  background-image:
    linear-gradient(180deg, rgba(7, 20, 48, 0.15) 0%, rgba(7, 20, 48, 0.55) 55%, rgba(7, 20, 48, 0.92) 100%),
    url('../assets/img/chateau.jpg'),
    url('../assets/img/village.jpg');
  background-size: cover;
  background-position: center 35%;
}
@media (max-aspect-ratio: 3/4) {
  .decor {
    background-image:
      linear-gradient(180deg, rgba(7, 20, 48, 0.1) 0%, rgba(7, 20, 48, 0.5) 50%, rgba(7, 20, 48, 0.92) 100%),
      url('../assets/img/chateau-portrait.jpg'),
      url('../assets/img/village-800.jpg');
    /* Le château se place entre le titre et Flocon, le bas reste nuit */
    background-size: cover, 100% auto, 100% auto;
    background-position: center, center -14vw, center -14vw;
    background-repeat: no-repeat;
  }
}

.decor__aurore {
  position: absolute;
  inset: -20% -10% 40%;
  background:
    radial-gradient(40% 30% at 30% 40%, rgba(80, 255, 200, 0.22), transparent 70%),
    radial-gradient(35% 25% at 70% 30%, rgba(140, 120, 255, 0.20), transparent 70%),
    radial-gradient(30% 20% at 50% 55%, rgba(95, 227, 255, 0.16), transparent 70%);
  filter: blur(30px);
  mix-blend-mode: screen;
  animation: aurore 26s ease-in-out infinite alternate;
}
@keyframes aurore {
  0% { transform: translateX(-4%) skewX(-6deg); opacity: 0.7; }
  50% { transform: translateX(3%) skewX(4deg); opacity: 1; }
  100% { transform: translateX(-2%) skewX(-2deg); opacity: 0.8; }
}

.decor__neige {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Panneaux de cristal ---------- */
.cristal {
  position: relative;
  color: var(--texte);
  background:
    linear-gradient(155deg, rgba(190, 234, 255, 0.22) 0%, rgba(120, 180, 240, 0.09) 38%, rgba(20, 50, 110, 0.30) 100%);
  border: 1px solid rgba(190, 234, 255, 0.45);
  border-radius: var(--rayon-l);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 0 40px rgba(120, 210, 255, 0.10),
    0 24px 60px rgba(0, 8, 30, 0.55);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  isolation: isolate;
}
/* Reflet de glace qui traverse le haut du panneau */
.cristal::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.02) 22%, transparent 23%),
    linear-gradient(115deg, transparent 70%, rgba(255, 255, 255, 0.05) 71%, transparent 80%);
  pointer-events: none;
  z-index: -1;
}
/* Petites facettes aux coins */
.cristal::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 28px;
  width: 64px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 12px var(--cyan);
  pointer-events: none;
}

/* ---------- Boutons magiques ---------- */
.bouton {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--esp-2);
  min-height: 50px;
  padding: var(--esp-3) var(--esp-6);
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #9ff0ff 0%, #4fd2f5 45%, #1d9fd6 100%);
  color: #04213f;
  font: 800 var(--t-s)/1.2 var(--police-texte);
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -3px 0 rgba(4, 50, 100, 0.25),
    0 6px 22px rgba(60, 200, 255, 0.45);
  transition: transform var(--duree-rapide), box-shadow var(--duree-rapide), filter var(--duree-rapide);
}
.bouton::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  transform: skewX(-20deg);
  transition: left 600ms ease;
  pointer-events: none;
}
.bouton:hover { filter: brightness(1.06); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), inset 0 -3px 0 rgba(4, 50, 100, 0.25), 0 8px 30px rgba(60, 200, 255, 0.65); }
.bouton:hover::after { left: 120%; }
.bouton:active { transform: scale(0.97); }
.bouton[disabled],
.bouton[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; transform: none; filter: grayscale(0.4); }
.bouton svg { width: 20px; height: 20px; flex: none; }

.bouton--doux {
  background: rgba(190, 234, 255, 0.08);
  color: var(--glace);
  box-shadow: inset 0 0 0 1.5px rgba(190, 234, 255, 0.6);
}
.bouton--doux:hover { background: rgba(190, 234, 255, 0.16); box-shadow: inset 0 0 0 1.5px var(--glace), 0 0 18px rgba(95, 227, 255, 0.3); }
.bouton--doux::after { display: none; }

.bouton--petit { min-height: 42px; padding: var(--esp-2) var(--esp-4); font-size: var(--t-xs); }
.bouton--grand { min-height: 58px; font-size: var(--t-m); padding-inline: var(--esp-7); }

.lien-bouton {
  background: none;
  border: 0;
  padding: var(--esp-2) 0;
  font: inherit;
  color: var(--texte-doux);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  min-height: 44px;
}
.lien-bouton:hover { color: var(--texte); }
.lien-bouton--danger { color: var(--alerte); }

/* ---------- Champs ---------- */
.champ { display: grid; gap: var(--esp-1); margin-bottom: var(--esp-4); }
.champ label,
.champ .etiquette { font-weight: 700; font-size: var(--t-xs); color: var(--glace); }
.champ .aide { font-size: var(--t-xs); color: var(--texte-doux); margin: 0; }
.champ input,
.champ select,
.champ textarea {
  font: inherit;
  font-size: max(16px, 1rem);
  color: var(--texte);
  background: rgba(4, 16, 42, 0.55);
  border: 1.5px solid rgba(190, 234, 255, 0.35);
  border-radius: var(--rayon-s);
  padding: 10px 12px;
  min-height: 48px;
  width: 100%;
  transition: border-color var(--duree-rapide), box-shadow var(--duree-rapide);
}
.champ select option { background: var(--nuit); color: var(--texte); }
.champ input::placeholder,
.champ textarea::placeholder { color: #7f9cc0; }
.champ textarea { min-height: 88px; resize: vertical; }
.champ input:focus-visible,
.champ select:focus-visible,
.champ textarea:focus-visible {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(95, 227, 255, 0.3), var(--lueur-cyan);
}
.champ .erreur { color: var(--alerte); font-size: var(--t-xs); font-weight: 700; margin: 0; }
.champ [aria-invalid='true'] { border-color: var(--alerte); }

/* ---------- Flocon ---------- */
.flocon {
  width: 120px;
  height: auto;
  filter: drop-shadow(0 0 18px rgba(150, 220, 255, 0.45)) drop-shadow(0 10px 16px rgba(0, 6, 25, 0.5));
  user-select: none;
  -webkit-user-drag: none;
}

.bulle {
  position: relative;
  background: linear-gradient(180deg, #ffffff, #e6f6ff);
  color: #0b2149;
  border-radius: var(--rayon-m);
  padding: var(--esp-3) var(--esp-4);
  font-size: var(--t-m);
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 0 0 1px rgba(190, 234, 255, 0.8), 0 10px 30px rgba(0, 8, 30, 0.4), 0 0 24px rgba(95, 227, 255, 0.25);
  max-width: 34ch;
}

/* ---------- Bouton du son ---------- */
.bouton-son {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  z-index: 40;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(190, 234, 255, 0.5);
  background: rgba(7, 20, 48, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--glace);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.bouton-son svg { width: 24px; height: 24px; }
.bouton-son[aria-pressed='true'] { color: var(--cyan); box-shadow: var(--lueur-cyan); }

/* Cristal (SVG) réutilisable */
.gemme { width: 40px; height: auto; filter: drop-shadow(0 0 10px rgba(95, 227, 255, 0.7)); }

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

/* ---------- Suivi de progression (organisateur) ---------- */
.suivi {
  list-style: none;
  margin: var(--esp-2) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--esp-1);
  position: relative;
}
.suivi__etape { display: grid; justify-items: center; text-align: center; gap: 4px; position: relative; font-size: 0.75rem; color: var(--texte-doux); }
.suivi__etape:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 6px;
  left: calc(50% + 9px);
  right: calc(-50% + 9px);
  height: 2px;
  background: rgba(190, 234, 255, 0.2);
}
.suivi__etape--fait:not(:last-child)::after { background: linear-gradient(90deg, #8ff5c8, rgba(143, 245, 200, 0.4)); }
.suivi__point {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(4, 16, 42, 0.8);
  box-shadow: inset 0 0 0 2px rgba(190, 234, 255, 0.35);
}
.suivi__etape--fait { color: var(--texte); }
.suivi__etape--fait .suivi__point { background: #8ff5c8; box-shadow: 0 0 10px rgba(143, 245, 200, 0.7); }
.suivi__etape--encours .suivi__point { background: var(--or); box-shadow: 0 0 10px rgba(255, 210, 122, 0.7); }
.suivi__texte { display: grid; gap: 2px; line-height: 1.25; }
.suivi__texte small { color: var(--texte-doux); font-size: 0.7rem; }
.suivi__epreuves { margin: var(--esp-2) 0 0; font-size: var(--t-xs); color: var(--texte-doux); }
.suivi-indispo { margin: var(--esp-1) 0 0; font-size: var(--t-xs); color: var(--texte-doux); font-style: italic; }

/* ---------- Fenêtre de confirmation ---------- */
.boite-dialogue {
  width: min(92vw, 460px);
  padding: var(--esp-6) var(--esp-5) var(--esp-5);
  border: 1px solid rgba(190, 234, 255, 0.5);
  border-radius: var(--rayon-l);
  color: var(--texte);
  background: linear-gradient(160deg, #1b3a72, #0d1f45 70%);
  box-shadow: 0 30px 80px rgba(0, 6, 25, 0.7), 0 0 40px rgba(95, 227, 255, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.boite-dialogue::backdrop { background: rgba(4, 10, 30, 0.7); backdrop-filter: blur(4px); }
.boite-dialogue h2 { font-size: var(--t-l); margin-bottom: var(--esp-3); }
.boite-dialogue p { color: #d8ecff; margin-bottom: var(--esp-5); }
.boite-dialogue__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--esp-3); }
.bouton--danger { background: linear-gradient(180deg, #ff9aa8, #e0445b); color: #3a0610; }
