/* FluencyLab UX refinements
 * Keeps scrolling fully functional while removing visual scrollbar chrome.
 * Loaded after the primary design system so these rules stay intentionally surgical.
 */

/* Hidden scrollbar system: retain mouse wheel, trackpad, touch and keyboard scrolling. */
.section-nav,
.slide-card,
.intro-screen,
.finished-screen,
.intro-footer {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.section-nav::-webkit-scrollbar,
.slide-card::-webkit-scrollbar,
.intro-screen::-webkit-scrollbar,
.finished-screen::-webkit-scrollbar,
.intro-footer::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* Make nested scrolling feel deliberate instead of letting the whole page bounce around. */
.slide-card,
.intro-screen,
.finished-screen {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.section-nav,
.intro-footer {
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 16px;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.section-nav > button,
.intro-footer > span {
  scroll-snap-align: center;
}

/* Use the canonical student artwork from Supabase on the lesson home. */
.intro-art .scene-art {
  background:
    linear-gradient(180deg, rgba(31, 35, 38, 0.02), rgba(31, 35, 38, 0.12)),
    url("https://hbzkznfceeoncctmthoe.supabase.co/storage/v1/object/public/STUDENTS%20IMAGES/KERCIA%20-%20LARISSA/klg-1.svg") center 50% / cover no-repeat;
}

.intro-art .scene-art svg,
.intro-art .scene-art .scene-stamp {
  display: none;
}

/* Remove decorative lines that were visually floating around the home composition. */
.intro-copy::after,
.intro-mantra i {
  display: none;
}

/* Story slides 1–9: language is primary, full story is available on demand. */
.story-slide .story-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  margin-top: clamp(26px, 4vh, 46px);
}

.story-slide .language-panel {
  grid-row: 1;
  width: min(100%, 1080px);
  border-top-width: 5px;
  padding-top: 18px;
}

.story-slide .language-panel .micro-label {
  font-size: clamp(0.72rem, 0.9vw, 0.86rem);
  letter-spacing: 0.22em;
}

.story-slide .chunk-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
  border-top: 0;
}

.story-slide .chunk-list span {
  min-height: 66px;
  align-items: center;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.38);
  padding: 14px 16px;
  font-size: clamp(0.92rem, 1.25vw, 1.08rem);
  line-height: 1.45;
}

.story-slide .chunk-list b {
  font-size: 0.68rem;
}

.story-toggle {
  grid-row: 2;
  width: fit-content;
  min-height: 44px;
  margin-top: 22px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--charcoal);
  cursor: pointer;
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 10px;
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.story-toggle::after {
  content: "+";
  grid-column: 2;
  grid-row: 1 / span 2;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--teal-dark);
  transition: transform 0.18s ease;
}

.story-toggle[aria-expanded="true"]::after {
  content: "−";
}

.story-toggle:hover {
  border-color: var(--teal);
  background: rgba(0, 179, 182, 0.06);
}

.story-toggle__label {
  grid-column: 1;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.story-toggle__hint {
  grid-column: 1;
  margin-top: 2px;
  color: var(--muted-foreground);
  font-size: 0.68rem;
  line-height: 1.35;
}

.story-slide .story-copy {
  grid-row: 3;
  width: min(100%, 920px);
  margin-top: 18px;
  padding: 20px 22px;
  border-left: 4px solid var(--teal);
  background: rgba(212, 209, 200, 0.22);
}

.story-slide .story-copy[hidden] {
  display: none;
}

.story-slide.is-story-open .story-copy {
  animation: storyReveal 0.2s ease-out;
}

@keyframes storyReveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Keep controls comfortably tappable on tablets and phones. */
button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.section-nav button,
.nav-button,
.icon-button,
.control-button,
.repair-reveal-button,
.true-false-row button,
.story-toggle {
  min-height: 44px;
}

/* A slightly clearer focus ring for keyboard users without disturbing the visual system. */
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(0, 179, 182, 0.5);
  outline-offset: 3px;
}

/* Prevent long language chunks or unusual strings from creating horizontal overflow. */
.slide-card,
.story-copy,
.language-panel,
.reading-copy,
.feedback-panel,
.correction-panel,
.recycle-item,
.example-card {
  overflow-wrap: anywhere;
}

/* Small rendering hints for the only elements that animate continuously during use. */
.global-progress span {
  will-change: width;
}

.listen-wave.is-speaking span {
  will-change: transform, opacity;
}

/* Respect notches and home indicators without changing the desktop composition. */
.lesson-header {
  padding-top: max(12px, env(safe-area-inset-top));
  padding-left: max(clamp(16px, 3vw, 42px), env(safe-area-inset-left));
  padding-right: max(clamp(16px, 3vw, 42px), env(safe-area-inset-right));
}

.lesson-footer {
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  padding-left: max(clamp(14px, 2.4vw, 34px), env(safe-area-inset-left));
  padding-right: max(clamp(14px, 2.4vw, 34px), env(safe-area-inset-right));
}

.intro-brandbar,
.intro-footer {
  padding-left: max(clamp(22px, 4vw, 64px), env(safe-area-inset-left));
  padding-right: max(clamp(22px, 4vw, 64px), env(safe-area-inset-right));
}

.intro-footer {
  padding-bottom: env(safe-area-inset-bottom);
}

/* Hover movement is useful with a mouse and pointless on touch screens. */
@media (hover: none) {
  .hero-button:hover {
    transform: none;
    box-shadow: 8px 8px 0 var(--charcoal);
    background: var(--teal);
  }

  .option-button:hover {
    transform: none;
  }

  .story-toggle:hover {
    border-color: var(--border);
    background: transparent;
  }
}

@media (max-width: 820px) {
  .section-nav {
    padding-inline: 2px;
    scroll-padding-inline: 12px;
  }

  .slide-card {
    overscroll-behavior-y: contain;
  }

  .intro-art .scene-art {
    background-position: center 48%;
  }

  .story-slide .chunk-list {
    grid-template-columns: 1fr;
  }

  .story-toggle {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .intro-art .scene-art {
    background-position: center 45%;
  }

  .intro-footer {
    scroll-padding-inline: 18px;
  }

  .lesson-footer {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .story-slide .story-copy {
    padding: 17px;
  }
}

/* Motion should never be compulsory. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
