/* Bouton Accueil partagé — à inclure dans les pages ateliers */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@600&display=swap');

.kids-home-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 3rem;
  padding: 0.55rem 1.1rem;
  border: 3px solid #c4b5fd;
  border-radius: 999px;
  background: #fff;
  color: #6d28d9;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 0 #a78bfa, 0 8px 20px rgba(109, 40, 217, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kids-home-link:hover,
.kids-home-link:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #a78bfa, 0 12px 24px rgba(109, 40, 217, 0.2);
  outline: none;
}

.kids-home-link:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #a78bfa;
}

/* Numéro du jeu — coin haut droit dans chaque atelier */
.kids-game-num.kids-game-num--page {
  position: fixed;
  top: 1rem;
  right: 1rem;
  left: auto;
  z-index: 300;
  min-width: 2.75rem;
  height: 2.75rem;
  padding: 0 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
  border: 3px solid;
  box-shadow: 0 4px 0 rgba(15, 23, 42, 0.15), 0 8px 24px rgba(15, 23, 42, 0.12);
  pointer-events: none;
}

.kids-game-num--page.kids-game-num--fr {
  background: #f3e8ff;
  color: #6d28d9;
  border-color: #c4b5fd;
  box-shadow: 0 4px 0 #a78bfa, 0 8px 20px rgba(109, 40, 217, 0.12);
}

.kids-game-num--page.kids-game-num--math {
  background: #fff7ed;
  color: #d97706;
  border-color: #fdba74;
  box-shadow: 0 4px 0 #fb923c, 0 8px 20px rgba(217, 119, 6, 0.12);
}

.kids-game-num--page.kids-game-num--sci {
  background: #ecfdf5;
  color: #059669;
  border-color: #6ee7b7;
  box-shadow: 0 4px 0 #34d399, 0 8px 20px rgba(5, 150, 105, 0.12);
}

@media (prefers-reduced-motion: reduce) {
  .kids-home-link { transition: none; }
}

/* ─── Tablette Apple (iPad) — mode paysage ─── */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  -webkit-overflow-scrolling: touch;
}

@media (orientation: landscape) and (max-height: 820px) {
  body {
    overflow-x: auto;
    overflow-y: auto;
  }

  body:has(> .kids-home-link):not(:has(.wrap)) {
    padding-top: max(3rem, calc(env(safe-area-inset-top, 0px) + 2.75rem));
    padding-left: max(0.5rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.5rem, env(safe-area-inset-right, 0px));
  }

  .wrap,
  main.wrap {
    padding-top: max(3rem, calc(env(safe-area-inset-top, 0px) + 2.5rem)) !important;
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px)) !important;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px)) !important;
  }

  .kids-home-link {
    top: max(0.4rem, env(safe-area-inset-top, 0px));
    left: max(0.4rem, env(safe-area-inset-left, 0px));
    min-height: 2.5rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
  }

  .kids-game-num.kids-game-num--page {
    top: max(0.4rem, env(safe-area-inset-top, 0px));
    right: max(0.4rem, env(safe-area-inset-right, 0px));
    min-width: 2.15rem;
    height: 2.15rem;
    font-size: 0.9rem;
  }

  h1 {
    font-size: clamp(1.15rem, 3vw, 1.6rem) !important;
  }

  .lead {
    font-size: 0.85rem !important;
    margin-bottom: 0.35rem !important;
  }

  .mode-bar {
    margin: 0.5rem 0 !important;
    gap: 0.35rem !important;
  }

  .mode-btn,
  .tab {
    min-height: 2.35rem !important;
    padding: 0.3rem 0.65rem !important;
    font-size: 0.78rem !important;
  }

  .chips {
    margin: 0.4rem 0 0.65rem !important;
  }

  .chip {
    padding: 0.35rem 0.7rem !important;
    font-size: 0.85rem !important;
  }

  .card,
  .game-card {
    padding: 0.85rem !important;
  }

  .scene {
    font-size: 2.2rem !important;
    margin: 0.25rem 0 !important;
  }

  .choice,
  .pool-item,
  .btn {
    min-height: 2.75rem;
  }

  .grid {
    grid-template-columns: repeat(5, minmax(2.2rem, 2.5rem)) !important;
    grid-template-rows: repeat(5, minmax(2.2rem, 2.5rem)) !important;
  }

  .cell {
    font-size: 1.35rem !important;
  }

  .mode-group {
    margin: 0.4rem 0 0.2rem !important;
  }

  .mode-group-label {
    font-size: 0.68rem !important;
    margin-bottom: 0.25rem !important;
  }

  .equation {
    font-size: clamp(1.5rem, 5vw, 2rem) !important;
    margin: 0.15rem 0 0.5rem !important;
  }

  .visual {
    min-height: 3rem !important;
    margin: 0.35rem 0 !important;
  }

  .chain-zone,
  .hand-zone {
    min-height: 4rem !important;
    padding: 0.5rem !important;
  }

  .tile {
    width: 6.5rem !important;
    height: 3.2rem !important;
  }

  .tile .half {
    font-size: 1.5rem !important;
  }

  .bins {
    grid-template-columns: 1fr 1fr !important;
  }

  #game-container {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 0.75rem !important;
  }

  #board {
    grid-template-columns: repeat(4, 56px) !important;
    grid-template-rows: repeat(5, 56px) !important;
  }

  #board .cell {
    width: 56px !important;
    height: 56px !important;
    font-size: 1.25rem !important;
  }
}
