/* ═══════════════════════════════════════════════════════════════════
   QUIZ-WORLDS-SHARED.CSS — Académie Pirate
   CSS commun à TOUS les mondes — élimine la duplication
   Remplace les parties identiques dans :
     quiz-histoire.css, quiz-kanto.css, quiz-pays-du-feu.css,
     quiz-namek.css, quiz-grand-bleu.css, quiz-english.css
   ⚠️ Charger AVANT le CSS spécifique à chaque monde
   Version : 1.0 — 12 Avril 2026
   ═══════════════════════════════════════════════════════════════════

   USAGE dans index.html (APRÈS tokens.css, AVANT quiz-{monde}.css) :
   <link rel="stylesheet" href="css/quiz-worlds-shared.css">
   ═══════════════════════════════════════════════════════════════════ */

/* ── Variables partagées par monde via CSS custom properties ─────
   Chaque monde déclare ses propres valeurs sur son conteneur racine
   ex: #gb-iles-sec { --w-color: #e63946; --w-name: 'Grand Bleu'; }
   ──────────────────────────────────────────────────────────────── */

/* ── GRILLE D'ÎLES — pattern commun tous mondes ────────────────── */

/* Conteneur niveaux */
.w-levels-sec {
  position: relative;
  z-index: 5;
  padding: var(--ap-space-4) var(--ap-space-4) 100px;
}

/* Header section */
.w-map-header {
  text-align: center;
  padding: var(--ap-space-6) var(--ap-space-4) var(--ap-space-4);
  position: relative;
}

.w-map-title {
  font-family: var(--ap-font-display);
  font-size: var(--ap-display-md);
  letter-spacing: 4px;
  color: var(--ap-gold);
  text-shadow: 2px 2px 0 #000;
  margin-bottom: var(--ap-space-2);
}

.w-map-sub {
  font-family: var(--ap-font-body);
  font-size: var(--ap-text-sm);
  font-weight: 800;
  color: var(--ap-text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── Grille des îles ─────────────────────────────────────────── */
.w-islands-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(10px, 3vw, 16px);
  padding: var(--ap-space-4);
  max-width: 1100px;
  margin: 0 auto;
}

@media (min-width: 600px) {
  .w-islands-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .w-islands-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1200px) {
  .w-islands-grid { grid-template-columns: repeat(4, 1fr); gap: 20px; }
}

/* ── Carte d'île ─────────────────────────────────────────────── */
.w-isle-card {
  position: relative;
  border-radius: var(--ap-r-xl);
  overflow: hidden;
  background: var(--ap-dark-2);
  border: 2px solid rgba(255,255,255,.08);
  cursor: pointer;
  transition:
    transform     var(--ap-duration-base) var(--ap-ease),
    box-shadow    var(--ap-duration-base) var(--ap-ease),
    border-color  var(--ap-duration-base) var(--ap-ease);
  /* Touch feedback immédiat */
  -webkit-tap-highlight-color: transparent;
  /* Performance */
  contain: layout style;
  /* Ratio cohérent sur tous les écrans */
  aspect-ratio: 2 / 3;
}

.w-isle-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--isle-color, var(--ap-gold));
  box-shadow:
    0 8px 32px rgba(0,0,0,.5),
    0 0 20px rgba(var(--isle-color-rgb, 255 215 0) / 0.2);
}

.w-isle-card:active {
  transform: translateY(-1px) scale(1.01);
  transition-duration: 80ms;
}

/* Île complétée */
.w-isle-card.done {
  border-color: var(--ap-green);
}
.w-isle-card.done::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: var(--ap-green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  color: var(--ap-dark-1);
  z-index: 3;
  box-shadow: 0 2px 8px rgba(6,214,160,.4);
}

/* ── Image héros ─────────────────────────────────────────────── */
.w-isle-img-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.w-isle-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  transition: transform var(--ap-duration-slower) var(--ap-ease);
}

.w-isle-card:hover .w-isle-img {
  transform: scale(1.06);
}

/* Fallback emoji si image 404 */
.w-isle-img-fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: var(--ap-dark-3);
}

/* Gradient overlay bas de carte */
.w-isle-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to top,
    rgba(5,8,16,.95) 0%,
    rgba(5,8,16,.6) 40%,
    transparent 70%
  );
}

/* ── Infos carte (bas) ───────────────────────────────────────── */
.w-isle-body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: var(--ap-space-3) var(--ap-space-3) var(--ap-space-4);
}

.w-isle-num {
  font-family: var(--ap-font-body);
  font-size: var(--ap-text-xs);
  font-weight: 900;
  color: rgba(255,255,255,.4);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.w-isle-name {
  font-family: var(--ap-font-display);
  font-size: clamp(.85rem, 2.5vw, 1.1rem);
  letter-spacing: 2px;
  color: var(--isle-color, var(--ap-gold));
  text-shadow: 1px 1px 0 #000;
  line-height: 1.1;
  margin-bottom: 3px;
}

.w-isle-topic {
  font-family: var(--ap-font-body);
  font-size: var(--ap-text-xs);
  font-weight: 700;
  color: rgba(255,255,255,.5);
  line-height: 1.3;
  margin-bottom: 4px;
}

.w-isle-level {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--ap-r-full);
  border: 1px solid var(--isle-color, var(--ap-gold));
  font-family: var(--ap-font-display);
  font-size: 0.6rem;
  letter-spacing: 1.5px;
  color: var(--isle-color, var(--ap-gold));
  opacity: 0.8;
}

.w-isle-stars {
  font-size: var(--ap-text-xs);
  color: var(--ap-gold);
  margin-top: 3px;
  font-weight: 800;
}

/* ── Bouton retour niveaux ───────────────────────────────────── */
.w-back-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--ap-space-2);
  padding: var(--ap-space-2) var(--ap-space-4);
  background: rgba(255,255,255,.06);
  border: 1.5px solid rgba(255,255,255,.12);
  border-radius: var(--ap-r-full);
  font-family: var(--ap-font-body);
  font-size: var(--ap-text-sm);
  font-weight: 800;
  color: var(--ap-text-dim);
  cursor: pointer;
  transition: all var(--ap-duration-fast) var(--ap-ease);
  -webkit-tap-highlight-color: transparent;
  min-height: var(--ap-touch-min);
  margin-bottom: var(--ap-space-4);
}
.w-back-btn:hover {
  background: rgba(255,255,255,.1);
  color: var(--ap-text);
  border-color: rgba(255,255,255,.25);
}

/* ── Grille niveaux ──────────────────────────────────────────── */
.w-levels-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(12px, 3vw, 20px);
  padding: var(--ap-space-4);
  max-width: 800px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .w-levels-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .w-levels-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ── Carte niveau ────────────────────────────────────────────── */
.w-level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ap-space-3);
  padding: var(--ap-space-5) var(--ap-space-4);
  background: var(--ap-dark-2);
  border: 2px solid rgba(255,255,255,.08);
  border-radius: var(--ap-r-xl);
  cursor: pointer;
  transition:
    transform     var(--ap-duration-base) var(--ap-ease),
    border-color  var(--ap-duration-base) var(--ap-ease),
    box-shadow    var(--ap-duration-base) var(--ap-ease);
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  contain: layout style;
}

.w-level-card:hover {
  transform: translateY(-4px);
  border-color: var(--level-color, var(--ap-gold));
  box-shadow: 0 8px 32px rgba(0,0,0,.4),
              0 0 16px rgba(var(--level-color-rgb, 255 215 0) / 0.15);
}

.w-level-card:active {
  transform: translateY(-1px);
}

.w-level-emoji {
  font-size: clamp(2rem, 5vw, 2.8rem);
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.5));
}

.w-level-nom {
  font-family: var(--ap-font-display);
  font-size: var(--ap-display-sm);
  letter-spacing: 3px;
  color: var(--level-color, var(--ap-gold));
  text-shadow: 1px 1px 0 #000;
  line-height: 1;
}

.w-level-desc {
  font-family: var(--ap-font-body);
  font-size: var(--ap-text-xs);
  font-weight: 700;
  color: var(--ap-text-dim);
  line-height: 1.4;
}

.w-level-btn {
  font-family: var(--ap-font-display);
  font-size: var(--ap-text-sm);
  letter-spacing: 2px;
  color: var(--level-color, var(--ap-gold));
  border: 1.5px solid var(--level-color, var(--ap-gold));
  border-radius: var(--ap-r-full);
  padding: 4px 14px;
  opacity: 0.7;
  transition: opacity var(--ap-duration-fast) var(--ap-ease);
  min-height: var(--ap-touch-min);
  display: flex;
  align-items: center;
}

.w-level-card:hover .w-level-btn { opacity: 1; }

/* ── Fond animé commun (bg strips) ──────────────────────────── */
.w-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--ap-duration-slow) var(--ap-ease);
  will-change: opacity;
  contain: strict;
}

.w-bg.visible { opacity: 1; }

.w-bg-strip {
  position: absolute;
  top: 0;
  height: 200%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: wBgScroll 32s linear infinite;
  will-change: transform;
}

@keyframes wBgScroll {
  from { transform: translateY(0); }
  to   { transform: translateY(-50%); }
}

.w-bg-strip img {
  width: 100%;
  aspect-ratio: 9 / 13;
  object-fit: cover;
  object-position: top center;
  border-radius: 3px;
  display: block;
  filter: saturate(1.2) brightness(0.4);
  opacity: 0.6;
}

/* ── Quiz header commun ──────────────────────────────────────── */
.w-quiz-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(5,8,16,.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 2px solid rgba(255,255,255,.06);
  padding: var(--ap-space-3) var(--ap-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--ap-space-2);
}

.w-quiz-title {
  font-family: var(--ap-font-display);
  font-size: var(--ap-display-sm);
  letter-spacing: 3px;
  color: var(--ap-gold);
  text-align: center;
  line-height: 1;
}

.w-prog-bar {
  height: 6px;
  background: rgba(255,255,255,.08);
  border-radius: 99px;
  overflow: hidden;
}

.w-prog-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--w-color, var(--ap-gold)), var(--ap-gold));
  transition: width 0.5s var(--ap-ease);
}

.w-prog-lbl {
  font-family: var(--ap-font-body);
  font-size: var(--ap-text-xs);
  font-weight: 800;
  color: var(--ap-text-dim);
  text-align: right;
}

/* ── Cinématique commune ─────────────────────────────────────── */
.w-cine-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.w-cine-inner {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: var(--ap-space-4);
  padding: var(--ap-space-6);
  /* Safe areas PWA */
  padding-top: max(var(--ap-safe-top), 24px);
  padding-bottom: max(var(--ap-safe-bottom), 24px);
  overflow: hidden;
}

.w-cine-char-wrap {
  position: relative;
  flex-shrink: 0;
  width: clamp(140px, 35vw, 280px);
}

.w-cine-char {
  width: 100%;
  object-fit: contain;
  object-position: bottom;
  filter: drop-shadow(0 0 40px currentColor);
  animation: cineHeroIn 0.8s var(--ap-ease-spring) both;
}

@keyframes cineHeroIn {
  from { transform: scale(0.6) translateY(40px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.w-cine-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--ap-space-4);
  max-width: 480px;
}

.w-cine-kanji {
  font-family: var(--ap-font-display);
  font-size: clamp(2rem, 8vw, 4rem);
  letter-spacing: 4px;
  animation: cineKanjiIn 0.6s var(--ap-ease-spring) 0.2s both;
}

@keyframes cineKanjiIn {
  from { transform: translateX(-30px) scale(0.8); opacity: 0; }
  to   { transform: translateX(0) scale(1); opacity: 1; }
}

.w-cine-lines { display: flex; flex-direction: column; gap: var(--ap-space-2); }

.w-cine-line {
  font-family: var(--ap-font-display);
  font-size: clamp(1.2rem, 4vw, 2rem);
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  animation: cineLineIn 0.5s var(--ap-ease-spring) both;
}

.w-cine-line:nth-child(1) { animation-delay: 0.3s; }
.w-cine-line:nth-child(2) { animation-delay: 0.5s; }
.w-cine-line:nth-child(3) { animation-delay: 0.7s; }

@keyframes cineLineIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.w-cine-bubble {
  background: rgba(255,255,255,.96);
  border: 3px solid #000;
  border-radius: var(--ap-r-lg);
  padding: var(--ap-space-4);
  color: var(--ap-text-inverse);
  animation: cineBubbleIn 0.5s var(--ap-ease-spring) 0.8s both;
}

@keyframes cineBubbleIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.w-cine-char-name {
  display: block;
  font-family: var(--ap-font-display);
  font-size: var(--ap-text-lg);
  letter-spacing: 2px;
  margin-bottom: var(--ap-space-2);
}

.w-cine-bubble-text {
  font-family: var(--ap-font-body);
  font-size: var(--ap-text-base);
  font-weight: 700;
  line-height: 1.5;
  color: var(--ap-text-inverse);
}

.w-skip-btn {
  position: absolute;
  bottom: max(var(--ap-safe-bottom), 24px);
  right: max(var(--ap-safe-right), 24px);
  font-family: var(--ap-font-display);
  font-size: var(--ap-text-sm);
  letter-spacing: 2px;
  color: rgba(255,255,255,.5);
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--ap-r-full);
  padding: var(--ap-space-2) var(--ap-space-4);
  cursor: pointer;
  transition: all var(--ap-duration-fast) var(--ap-ease);
  min-height: var(--ap-touch-min);
  min-width: var(--ap-touch-min);
  -webkit-tap-highlight-color: transparent;
}

.w-skip-btn:hover {
  color: rgba(255,255,255,.8);
  border-color: rgba(255,255,255,.4);
  background: rgba(0,0,0,.6);
}

/* ── Message "bientôt disponible" ────────────────────────────── */
.w-coming-soon {
  text-align: center;
  padding: 60px var(--ap-space-6);
  font-family: var(--ap-font-body);
  font-size: var(--ap-text-lg);
  font-weight: 800;
  color: var(--ap-text-dim);
}

/* ── Responsive mobile serré ─────────────────────────────────── */
@media (max-width: 480px) {
  .w-cine-inner {
    flex-direction: column;
    justify-content: center;
    padding: var(--ap-space-4);
    padding-top: max(var(--ap-safe-top), 20px);
  }
  .w-cine-char-wrap { width: clamp(100px, 40vw, 160px); }
  .w-cine-content   { max-width: 100%; }
}

@media (max-width: 380px) {
  .w-islands-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: var(--ap-space-2); }
  .w-isle-name    { font-size: 0.8rem; }
  .w-levels-grid  { grid-template-columns: repeat(2, 1fr); }
}
