/* ==========================================================================
   Variables et base
   ========================================================================== */

:root {
  --color-bg: #f5f7fb;
  --color-surface: #ffffff;
  --color-text: #22223b;
  --color-text-light: #4a4a68;
  --color-primary: #4361ee;
  --color-primary-dark: #2f3fb0;
  --color-success: #2ecc71;
  --color-success-dark: #1f9d57;
  --color-hint: #f4a261;
  --color-hint-dark: #c97a3d;
  --color-border: #dfe3f0;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 6px 20px rgba(34, 34, 59, 0.08);
  --shadow-target: 0 6px 16px rgba(34, 34, 59, 0.25);
  --font-base: 1.15rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--font-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  cursor: pointer;
}

button:focus-visible,
.exercise-card:focus-visible,
.footer-social-link:focus-visible {
  outline: 4px solid var(--color-primary);
  outline-offset: 3px;
}

/* ==========================================================================
   En-tête et pied de page
   ========================================================================== */

.app-header {
  text-align: center;
  padding: 2rem 1.25rem 1rem;
}

.app-header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  color: var(--color-primary-dark);
}

.app-subtitle {
  margin: 0 auto;
  max-width: 640px;
  color: var(--color-text-light);
  font-size: 1.05rem;
}

.app-footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  color: var(--color-text-light);
  font-size: 0.95rem;
}

.app-footer p {
  margin: 0 0 0.75rem;
}

.footer-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.footer-credit-name {
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.footer-social {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.footer-social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--color-text-light);
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.footer-social-link:hover,
.footer-social-link:focus-visible {
  background: #eef1fb;
  color: var(--color-primary-dark);
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
}

/* ==========================================================================
   Écran menu
   ========================================================================== */

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
}

.exercise-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem 1.25rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 190px;
}

.exercise-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(34, 34, 59, 0.14);
}

.exercise-card .card-icon {
  font-size: 2.6rem;
  line-height: 1;
}

.exercise-card h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--color-text);
}

.exercise-card p {
  margin: 0;
  color: var(--color-text-light);
  font-size: 0.98rem;
  flex-grow: 1;
}

.card-hint {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.85rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: #eef1fb;
  color: var(--color-primary-dark);
}

.card-cta {
  align-self: flex-start;
  margin-top: 0.3rem;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  font-size: 1rem;
  font-weight: 600;
  pointer-events: none;
}

/* ==========================================================================
   Écran exercice
   ========================================================================== */

.exercise-screen {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
}

.exercise-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.back-button {
  background: #eef1fb;
  color: var(--color-primary-dark);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.1rem;
  font-size: 1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.back-button:hover {
  background: #dfe6fb;
}

.exercise-title {
  margin: 0;
  font-size: 1.4rem;
  color: var(--color-text);
}

.exercise-progress {
  font-weight: 700;
  color: var(--color-primary-dark);
  background: #eef1fb;
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  font-size: 1rem;
}

.exercise-instructions {
  color: var(--color-text-light);
  margin: 0 0 1rem;
}

.feedback {
  min-height: 1.6em;
  margin-bottom: 0.75rem;
  font-weight: 700;
  font-size: 1.05rem;
  border-radius: var(--radius-sm);
  padding: 0;
  transition: opacity 0.15s ease;
}

.feedback:empty {
  padding: 0;
}

.feedback--success {
  color: var(--color-success-dark);
}

.feedback--hint {
  color: var(--color-hint-dark);
}

.feedback--info {
  color: var(--color-text-light);
}

.feedback--pop {
  animation: feedbackPop 0.25s ease;
}

@keyframes feedbackPop {
  from {
    transform: scale(0.92);
    opacity: 0.4;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.game-area {
  position: relative;
  width: 100%;
  height: 380px;
  background: #f8f9fd;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  touch-action: none;
}

.game-area.game-area--scroll {
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  height: 320px;
}

/* ==========================================================================
   Éléments réutilisables dans les exercices
   ========================================================================== */

.target {
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: none;
  box-shadow: var(--shadow-target);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: white;
  transform: scale(0);
  animation: targetPopIn 0.2s ease forwards;
  user-select: none;
  -webkit-user-select: none;
}

.target:active {
  filter: brightness(0.92);
}

@keyframes targetPopIn {
  to {
    transform: scale(1);
  }
}

.target--hit {
  animation: targetHit 0.28s ease forwards;
  pointer-events: none;
}

@keyframes targetHit {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.target--shake {
  animation: targetShake 0.3s ease;
}

@keyframes targetShake {
  0%, 100% { transform: translateX(0) scale(1); }
  25% { transform: translateX(-6px) scale(1); }
  75% { transform: translateX(6px) scale(1); }
}

.completion-panel {
  text-align: center;
  padding: 2.5rem 1rem;
}

.completion-panel .completion-emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}

.completion-panel h3 {
  margin: 0 0 0.5rem;
  color: var(--color-success-dark);
}

.completion-panel p {
  color: var(--color-text-light);
  margin: 0 0 1.25rem;
}

.primary-button {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.4rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--color-primary-dark);
}

.secondary-button {
  background: #eef1fb;
  color: var(--color-primary-dark);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  margin-left: 0.6rem;
}

.secondary-button:hover {
  background: #dfe6fb;
}

.fallback-panel {
  text-align: center;
  padding: 2.5rem 1.25rem;
  background: #fff7ee;
  border: 2px solid #ffe1bd;
  border-radius: var(--radius-md);
}

.fallback-panel .fallback-emoji {
  font-size: 2.6rem;
  display: block;
  margin-bottom: 0.5rem;
}

.fallback-panel p {
  color: var(--color-text-light);
  margin: 0 0 1rem;
}

/* ---- Glisser-déposer ---- */

.drag-item {
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: var(--shadow-target);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: white;
  touch-action: none;
  cursor: grab;
  transition: left 0.3s ease, top 0.3s ease, filter 0.15s ease;
}

.drag-item.dragging {
  cursor: grabbing;
  transition: none;
  filter: brightness(1.05);
}

.drop-zone {
  position: absolute;
  width: 130px;
  height: 130px;
  border-radius: var(--radius-md);
  border: 3px dashed var(--color-hint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: var(--color-hint-dark);
  background: rgba(244, 162, 97, 0.08);
}

.drop-zone.drop-zone--active {
  border-color: var(--color-success);
  background: rgba(46, 204, 113, 0.12);
  color: var(--color-success-dark);
}

/* ---- Gestes tactiles ---- */

.swipe-arrow {
  position: absolute;
  font-size: 2.4rem;
  animation: arrowPulse 1.1s ease-in-out infinite;
}

@keyframes arrowPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.pinch-shape {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 100px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  transform: translate(-50%, -50%) scale(1);
  transition: transform 0.05s linear;
}

/* ---- Défilement ---- */

.scroll-content {
  padding: 1rem;
  min-height: 900px;
}

.scroll-filler {
  padding: 1.1rem 0.9rem;
  margin-bottom: 0.75rem;
  background: #eef1fb;
  border-radius: var(--radius-sm);
  color: var(--color-text-light);
}

.scroll-target {
  margin-top: 1rem;
  padding: 1.5rem;
  text-align: center;
  font-size: 2.4rem;
  background: #fff7ee;
  border: 3px dashed var(--color-hint);
  border-radius: var(--radius-md);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

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

@media (max-width: 560px) {
  .app-header h1 {
    font-size: 1.4rem;
  }

  .exercise-screen {
    padding: 1rem;
  }

  .game-area {
    height: 320px;
  }

  .target {
    width: 90px;
    height: 90px;
    font-size: 1.6rem;
  }

  .drag-item {
    width: 74px;
    height: 74px;
  }

  .drop-zone {
    width: 104px;
    height: 104px;
  }
}
