/* The compact top bar already identifies the book and current page. */
.carousel-wrap {
  padding-top: clamp(9px, 1.5vw, 15px);
}

.reading-feedback {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font: 400 clamp(14px, 1.7vw, 17px)/1.5 system-ui, sans-serif;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.reading-feedback small { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.reading-feedback .recognised-wrong { color: #ad2525; text-decoration: underline; text-decoration-color: #ad2525; }
.reading-feedback .recognised-pending { color: var(--muted); }

.story-page {
  scroll-snap-stop: always;
}

.story-topbar .brand {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  padding: 0;
}

.story-topbar .brand::before {
  content: none;
  display: none;
}

.leggi-brand img {
  display: block;
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 12px;
}

.story-topbar > .main-menu-shell {
  position: relative;
  display: block;
  justify-self: end;
  text-align: left;
}

.menu-toggle {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 10px;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  cursor: pointer;
}

.menu-toggle i {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}

.main-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 9px);
  right: 0;
  width: min(290px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 18px 45px rgba(24, 58, 56, .22);
}

.main-menu > a,
.settings-menu > summary {
  display: block;
  padding: 12px 13px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}

.main-menu > a:hover,
.settings-menu > summary:hover {
  background: #f2eee2;
}

.settings-menu > summary {
  list-style: none;
}

.settings-menu > summary::-webkit-details-marker {
  display: none;
}

.settings-menu > summary::after {
  content: '›';
  float: right;
  font-size: 19px;
  line-height: 14px;
  transition: transform .2s;
}

.settings-menu[open] > summary::after {
  transform: rotate(90deg);
}

.settings-panel {
  padding: 7px 13px 13px;
  border-top: 1px solid #eee8d8;
}

.settings-panel strong {
  display: block;
  margin: 4px 0 9px;
  font-size: 11px;
}

.level-options,
.language-options {
  display: grid;
  gap: 7px;
}

.level-options {
  grid-template-columns: repeat(3, 1fr);
}

.language-options {
  grid-template-columns: repeat(2, 1fr);
}

.settings-panel #languageLabel {
  margin-top: 16px;
}

.level-options button,
.language-options button {
  min-height: 40px;
  border: 1px solid #cbd8d1;
  border-radius: 10px;
  color: var(--teal);
  background: #edf5f0;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.level-options button.is-selected,
.language-options button.is-selected {
  border-color: var(--orange);
  color: #fff;
  background: var(--orange);
}

@media (max-width: 600px) {
  .story-topbar .brand {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
  }

  .leggi-brand img {
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }

  .menu-toggle {
    width: 39px;
    height: 39px;
  }
}

.cover-page .page-actions {
  display: flex;
}

.cover-page .page-image {
  aspect-ratio: 3 / 2;
  background: none;
}

.cover-page .page-copy {
  padding: clamp(28px, 5vw, 48px);
  text-align: center;
}

.cover-page .page-copy h2 {
  font-size: clamp(42px, 6vw, 68px);
}

.cover-page .page-copy p {
  color: var(--muted);
  font-size: clamp(18px, 2.4vw, 25px);
}

.cover-start {
  display: block;
  width: calc(100% - clamp(38px, 8vw, 86px));
  min-height: 62px;
  margin: 0 auto clamp(24px, 5vw, 42px);
  border: 0;
  border-radius: 17px;
  color: #fff;
  background: var(--orange);
  box-shadow: 0 7px 0 var(--orange-dark);
  font-size: clamp(18px, 3vw, 24px);
  font-weight: 950;
  letter-spacing: .4px;
  cursor: pointer;
}

.cover-start:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 var(--orange-dark);
}

.story-page .page-image {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: none;
}

.story-page .page-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-copy .needs-help {
  padding: 0 3px;
  border-bottom-color: var(--orange);
  border-radius: 4px;
  background: #fff0c9;
}

.page-copy .needs-help.is-speaking {
  color: #fff;
  background: var(--orange);
  box-shadow: 0 0 0 5px rgba(231, 111, 61, .2);
  animation: spoken-word-focus 1s ease-in-out infinite;
}

.page-copy .narrated-word.is-speaking {
  margin: 0 -2px;
  padding: 1px 2px;
  border-radius: 4px;
  color: #fff;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(23, 111, 104, .15);
}

@keyframes spoken-word-focus {
  50% {
    box-shadow: 0 0 0 10px rgba(231, 111, 61, .08);
  }
}

.story-page.is-listening .page-image::after {
  content: '👂';
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: clamp(82px, 17vw, 132px);
  height: clamp(82px, 17vw, 132px);
  place-items: center;
  border: 4px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  color: #183a38;
  background: rgba(223, 243, 235, .94);
  box-shadow: 0 0 0 12px rgba(223, 243, 235, .3), 0 12px 28px rgba(24, 58, 56, .3);
  font-size: clamp(40px, 9vw, 72px);
  transform: translate(-50%, -50%);
  animation: listening-invitation 1.9s ease-in-out infinite;
}

@keyframes listening-invitation {
  50% {
    transform: translate(-50%, -50%) scale(1.09);
    box-shadow: 0 0 0 21px rgba(223, 243, 235, .16), 0 14px 32px rgba(24, 58, 56, .34);
  }
}

/* Longer scenes retain dialogue paragraphs without widening the page. */
.page-copy p { white-space: pre-wrap; overflow-wrap: anywhere; }
.story-location { min-width: 0; }
.story-location b { overflow-wrap: anywhere; }
.page-carousel { align-items: flex-start; overflow-y: hidden; }
