/* Kid-friendly controls: subject tiles and the read-aloud button. */

.subject-picker {
  grid-column: 1 / -1;
  margin: 0 0 18px;
}

.subject-picker__title {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 9px;
}

/* Two wide "mode" tiles on top, three theme tiles below: fits the narrow side panel. */
.subject-picker__tiles {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.subject-tile {
  grid-column: span 2;
}

.subject-tile:nth-child(-n + 2) {
  grid-column: span 3;
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
}

.subject-tile:nth-child(-n + 2) .subject-tile__name {
  font-size: 13px;
}

.subject-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 9px 2px 7px;
  min-height: 68px;
  border-radius: 16px;
  background: #f3f5ec;
  border: 2px solid #e2e7d7;
  box-shadow: 0 3px 0 #e2e7d7;
  color: #6f8170;
}

.subject-tile__icon {
  font-size: 26px;
  line-height: 1;
  transition: transform .2s;
}

.subject-tile__name {
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}

.subject-tile:hover .subject-tile__icon {
  transform: scale(1.12) rotate(-6deg);
}

.subject-tile--active {
  background: #fff3cd;
  border-color: #ecc66d;
  box-shadow: 0 3px 0 #e3ae43;
  color: #654c26;
}

.subject-tile--active .subject-tile__icon {
  transform: scale(1.12);
}

/* The native select stays in the DOM for app.js but is never shown. */
.subject-picker__native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 800px) {
  .subject-tile {
    min-height: 76px;
  }

  .subject-tile:nth-child(-n + 2) {
    min-height: 58px;
  }

  .subject-tile__icon {
    font-size: 30px;
  }

  .subject-tile__name {
    font-size: 12px;
  }
}

/* Read-aloud: a clear, friendly button instead of a tiny grey text link. */
.tool-button--listen {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  background: #e3f3fb;
  color: #2f6f8f;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 3px 0 #b8dcec;
}

.tool-button--speaking {
  background: #ffd576;
  color: #654c26;
  box-shadow: 0 3px 0 #e3ae43;
  animation: listen-pulse 1s ease-in-out infinite;
}

/* The answer being read lights up, so the child links the voice to the button. */
.answer-button--speaking {
  outline: 4px solid #ffc847;
  outline-offset: 2px;
  transform: scale(1.03);
  background: #fff6d8;
}

@keyframes listen-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .tool-button--speaking,
  .subject-tile__icon {
    animation: none;
    transition: none;
  }
}

/* Star pocket: one slot per question, filled by a flying star on each right answer. */
.star-pocket {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: -10px 0 14px;
}

.star-pocket__slot {
  font-size: 22px;
  line-height: 1;
  filter: grayscale(1) opacity(.25);
  transition: filter .3s;
}

.star-pocket__slot--won {
  filter: none;
  animation: pocket-pop .45s ease;
}

.star-pocket__slot--missed {
  filter: grayscale(1) opacity(.15);
}

.flying-star {
  position: fixed;
  z-index: 10;
  font-size: 34px;
  pointer-events: none;
  translate: -50% -50%;
  transition: transform .7s cubic-bezier(.5, -0.3, .3, 1);
}

.answer-burst {
  position: fixed;
  z-index: 9;
  pointer-events: none;
}

.answer-burst span {
  position: absolute;
  font-size: 20px;
  translate: -50% -50%;
  animation: answer-burst .9s ease-out forwards;
}

/* Right answer: the button jumps with joy. Wrong answer: a soft "no" wobble. */
.answer-button--win {
  animation: answer-win .55s cubic-bezier(.3, 1.6, .5, 1);
}

.answer-button--oops {
  animation: answer-oops .45s ease;
}

.feedback-hero {
  animation: feedback-hero-jump .6s ease 2;
}

@keyframes answer-burst {
  0% { transform: translate(0, 0) scale(.3); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(160deg); opacity: 0; }
}

@keyframes pocket-pop {
  0% { transform: scale(.4); }
  60% { transform: scale(1.5); }
  100% { transform: scale(1); }
}

@keyframes answer-win {
  0% { transform: scale(1); }
  40% { transform: scale(1.12) rotate(-2deg); }
  100% { transform: scale(1); }
}

@keyframes answer-oops {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(7px); }
  75% { transform: translateX(-4px); }
}

@keyframes feedback-hero-jump {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-14px) rotate(-4deg); }
}

@media (prefers-reduced-motion: reduce) {
  .answer-button--win,
  .answer-button--oops,
  .feedback-hero,
  .star-pocket__slot--won {
    animation: none;
  }
}

/* Character picker: the "C'est parti !" button stays pinned at the bottom of the window,
   so a child never has to discover that the dialog scrolls. */
#profile-form button[type="submit"] {
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 4px 0 #e3ae43, inset 0 2px 0 #fff0b3, 0 -16px 18px 4px #fffef7;
}

.profile-dialog {
  padding-bottom: 14px;
}

/* Two-step hero choice: worlds first, then boy or girl. */
.hero-steps__question {
  margin: 4px 0 12px;
  font-size: 17px;
  font-weight: 850;
}

.hero-steps__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-steps__back {
  background: #eef2e5;
  color: #4f7a52;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 800;
}

#profile-form[data-hero-step="theme"] .hero-steps__gender,
#profile-form[data-hero-step="gender"] .hero-steps__themes {
  display: none;
}

/* The level and "C'est parti !" only come once a hero is picked. */
#profile-form[data-hero-step="theme"] > :not(.hero-steps) {
  display: none;
}

.theme-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.theme-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px 14px;
  border-radius: 22px;
  background: #f4f5eb;
  border: 2px solid #e2e7d7;
  box-shadow: 0 4px 0 #e2e7d7;
}

.theme-tile:hover,
.theme-tile:focus-visible {
  background: #fff3cd;
  border-color: #ecc66d;
  box-shadow: 0 4px 0 #e3ae43;
}

.theme-tile__pair {
  display: flex;
  justify-content: center;
}

.theme-tile__pair img {
  width: 50%;
  max-width: 96px;
  aspect-ratio: 1;
  object-fit: contain;
}

.theme-tile__pair img + img {
  margin-left: -14%;
}

.theme-tile__name {
  font-size: 17px;
  font-weight: 850;
}

/* Step 2: only two big cards, side by side. */
.hero-steps__gender .avatar-choices {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hero-steps__gender .avatar-choice img {
  height: 150px;
}

.hero-steps__gender .avatar-choice strong {
  font-size: 18px;
}

.hero-steps__gender .avatar-choice small {
  display: block;
  font-size: 12px;
}

@media (max-width: 480px) {
  .hero-steps__gender .avatar-choice img {
    height: 130px;
  }
}
