/* Thème & Reset */
:root{
  --violet: #9f5ed8;
  --violet-dark: #7e45b9;
  --violet-verylight: #f6f0ff;
  --ink: #333;
  --muted: #777;
  --bg: #faf7fc;
  --shadow: 0 4px 12px rgba(0,0,0,.12);
  --radius: 12px;
  --gap: 14px;
}

*{ box-sizing:border-box; }
html,body{ padding:0; margin:0; }
img{ max-width:100%; height:auto; display:block; }

body{
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  padding: 24px 6vw 56px;
}

/*  En-tête */
header{
  background: var(--violet);
  color:#fff;
  padding: 28px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 28px;
}

.title-with-kawaii {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.kawaii {
  width: 100px;
  height: auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.18));
  animation: floaty 3s ease-in-out infinite;
  transition: transform .2s ease;
  order: -1;
}
.kawaii:hover{ transform: translateY(-2px) scale(1.03); }

@keyframes floaty{
  0% { transform: translateY(0) }
  50%{ transform: translateY(-6px) }
  100%{ transform: translateY(0) }
}
@media (prefers-reduced-motion: reduce){
  .kawaii{ animation: none; }
}

header h1{
  margin: 0 0 6px;
  font-size: clamp(1.8rem, 3vw, 2.8rem); /* taille du titre */
  text-align: center;
}
header p{ margin: 0 0 10px; opacity:.95; }

/*  Sections génériques  */
main section{
  background:#fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 24px;
}
h2{
  color: var(--violet);
  font-size: 1.25rem;
  margin: 0 0 10px;
}
.instruction{
  margin: 6px 0 14px;
  color: #000;
  font-weight: 600;
}

/*  Exercice 1 : Grille Thymio  */
#thymio-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(120px,1fr));
  gap: var(--gap);
  margin-bottom: 16px;
}
.thymio{
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.thymio:hover,
.thymio:focus{
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  outline: 3px solid transparent;
}

/* Cartes individuelles version utilisée */
.thymio-card {
  text-align: center;
  cursor: pointer;
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  background: #fff;
  transition: transform .15s ease;
}
.thymio-card:hover { transform: translateY(-2px); }
.thymio-card img { width: 100px; height: auto; margin: 0 auto 6px; }
.thymio-card .label { font-weight: 700; }

/* Panneau d'émotion la couleur de fond est pilotée par JS */
#emotion-panel{
  background: var(--violet-verylight);
  border-left: 6px solid var(--violet);
  border-radius: var(--radius);
  padding: 12px 14px;
}
#emotionName{
  margin:0 0 4px;
  font-size:1.05rem;
  color: var(--violet-dark);
}
#emotionDesc{ margin:0; color:#000; }

/* Exercice 2 : Storybook histoire à compléter */
#storybook .page{
  background:#fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 18px 0;
}

/* Image + légende */
#storybook .scene{
  display:flex;
  flex-direction: column;
  align-items:center;
  gap:8px;
  margin: 6px 0 10px;
}
#storybook .scene img{
  max-width: 380px;
  width: 90%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
}
#storybook .scene figcaption{
  font-weight: 700;
  color: var(--violet-dark);
  text-align: center;
}

/* Banque de mots (par page) */
#storybook .word-bank{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content: center;
  margin: 8px 0 12px;
}
#storybook .word-bank .word{
  padding: 10px 16px;
  border:1px solid #ddd;
  border-radius:999px;
  background:#fff;
  cursor:pointer;
  font-weight:700;
  font-size: 1.25rem;     /* taille plus grande  */
  box-shadow: var(--shadow);
  transition: transform .15s ease, background .15s ease;
}
#storybook .word-bank .word:hover{ transform: translateY(-2px); }

/* Bouton de mot sélectionné */
#storybook .word.selected,
#storybook .word[aria-pressed="true"]{
  background: var(--violet);
  color: #fff;
  border-color: transparent;
  outline: 3px solid rgba(159, 94, 216, .35);
  outline-offset: 2px;
  animation: pulse 0.6s ease-in-out infinite;
}
@keyframes pulse {
  0% { transform: scale(1); }
  50%{ transform: scale(1.1); }
  100%{ transform: scale(1); }
}
@media (prefers-reduced-motion: reduce){
  #storybook .word.selected{ animation: none; }
}

/* Texte à trous */
#storybook .story-text{ text-align:center; margin-top:10px; }
#storybook .story-text p{
  margin: 0 auto 10px;
  max-width: 700px;
  font-size: 1.3rem;   /* plus grand pour le texte de phrase */
  line-height: 1.8;    /* plus aéré */
}

/* Blanks (trous à remplir) */
#storybook .blank{
  display:inline-block;
  min-width:3ch;
  padding:0 6px 2px;
  border-bottom:3px solid #bbb;   /* trait plein sous le mot */
  border-radius:6px;
  cursor:pointer;
  transition: background .15s ease, border-color .15s ease;
}
#storybook .blank:hover,
#storybook .blank:focus{
  background:#f2ecff;
  border-bottom-color: var(--violet);
  outline: none;
}
#storybook .blank.ok{
  background:#e8f8ec;
  border-bottom-color:#49a062;
  color:#2e8b57;
  font-weight:700;
}
#storybook .blank.ko{
  background:#fdeeee;
  border-bottom-color:#d07070;
  color:#d62828;
  font-weight:700;
}

/* Guidage : quand un mot est sélectionné, les blanks s’illuminent */
#storybook .page.has-selected .blank{
  background:#f8f2ff;
  border-bottom-color: var(--violet);
}

/* Petit flash quand on pose un mot */
#storybook .blank.flash{
  background:#e8ffe8;
  border-color:#2e8b57;
}

/* Feedback + actions */
#storybook .page-actions{
  margin-top:10px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:center;
}
#storybook .feedback{
  font-weight:600;
  text-align:center;
}
.feedback{
  transition: all .3s ease;
  font-weight:600;
  text-align:center;
  margin-top:8px;
}
.feedback.success{
  color:#2e8b57;
  background:#e8f8ec;
  border-radius: 10px;
  padding: 8px 12px;
  display:inline-block;
  animation: glow 1.2s ease-in-out;
}
@keyframes glow{ 50%{ text-shadow:0 0 12px rgba(46,139,87,.6); } }

/* Footer centré */
.foot {
  text-align: center;
  margin-top: 30px;
  padding-top: 22px;
  border-top: 2px solid #e0d0f5;
  display: flex;
  flex-direction: column;   /* groupe boutons puis texte */
  align-items: center;
  gap: 14px;
}
.foot .btn-group{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:10px;
}
.foot .btn{
  background-color: var(--violet);
  color:#fff;
  text-decoration:none;
  font-weight:600;
  padding:10px 16px;
  border-radius: 8px;
  transition:.2s ease;
  box-shadow: var(--shadow);
}
.foot .btn:hover{
  background-color: var(--violet-dark);
  transform: translateY(-2px);
}
.footer-text{
  color: var(--muted);
  font-size: .95rem;
  text-align: center;
  margin-top: 4px;
}

/* Responsive */
@media (max-width: 720px){
  body{ padding: 18px 4vw 40px; }
  header{ padding: 22px 16px; }
  main section{ padding: 16px; }
}
