/* KBIBLE Special English Study: mobile WebView header and hero readability.
   Scoped to chapter-learning.php; never changes other service pages. */
body.lesson-page:not(.learning-embedded) {
  --kb-chapter-header-height: 64px; /* JS replaces this with rendered header height. */
}

/* The shared header is fixed. Reserve its ACTUAL height, not a magic 64px,
   and give the hero breathing room rather than letting the eyebrow disappear. */
body.lesson-page.kb-has-site-header:not(.learning-embedded) {
  padding-top: calc(var(--kb-chapter-header-height) + env(safe-area-inset-top) + 10px) !important;
}
html:has(body.lesson-page:not(.learning-embedded)) {
  scroll-padding-top: calc(var(--kb-chapter-header-height, 64px) + 18px);
}
body.lesson-page:not(.learning-embedded) :is(
  .learning-hero, .learning-selector, .study-sidebar, .study-main,
  .study-player-host, .speaking-studio, .learning-card, #learning-status
) {
  scroll-margin-top: calc(var(--kb-chapter-header-height, 64px) + 18px);
}
body.lesson-page:not(.learning-embedded) .lesson-app {
  min-width:0;
}
body.lesson-page .learning-hero[data-kb-student-hero="v2"] > div:first-of-type,
body.lesson-page .learning-hero[data-kb-student-hero="v2"] > .hero-note {
  min-width:0 !important;
  max-width:100%;
}
body.lesson-page .learning-hero[data-kb-student-hero="v2"] h1,
body.lesson-page .learning-hero[data-kb-student-hero="v2"] p {
  max-width:100%;
  overflow-wrap:break-word;
  word-break:keep-all;
}
@media (max-width:760px) {
  body.lesson-page:not(.learning-embedded) .lesson-app {
    width:calc(100% - 20px) !important;
    max-width:calc(100% - 20px) !important;
    padding:8px 0 38px !important;
    margin:0 auto !important;
  }
  body.lesson-page:not(.learning-embedded) .learning-hero[data-kb-student-hero="v2"] {
    box-sizing:border-box;
    width:100%;
    height:auto !important;
    min-height:0 !important;
    display:flex !important;
    flex-direction:column !important;
    align-items:stretch !important;
    justify-content:flex-start !important;
    gap:clamp(16px,4vw,21px) !important;
    padding:clamp(18px,5vw,26px) clamp(16px,4.6vw,23px) !important;
    border-radius:22px !important;
    margin:0 0 18px !important;
  }
  body.lesson-page .learning-hero[data-kb-student-hero="v2"] > div:first-of-type {
    flex:0 0 auto !important;
    width:100%;
    padding:0;
  }
  body.lesson-page .learning-hero[data-kb-student-hero="v2"] .eyebrow {
    margin:0 0 12px !important;
    font-size:clamp(10px,2.7vw,12px) !important;
    letter-spacing:.075em !important;
    line-height:1.5 !important;
    white-space:normal !important;
  }
  body.lesson-page .lesson-app .learning-hero[data-kb-student-hero="v2"] h1 {
    display:block;
    margin:0 0 14px !important;
    font-size:clamp(25px,6.7vw,34px) !important;
    font-weight:850 !important;
    line-height:1.32 !important;
    letter-spacing:-.045em !important;
    text-wrap:balance;
    word-break:keep-all !important;
    overflow-wrap:break-word !important;
    text-shadow:0 3px 14px rgba(0,0,0,.48) !important;
  }
  body.lesson-page .learning-hero[data-kb-student-hero="v2"] > div:first-of-type > p:last-child {
    margin:0 !important;
    max-width:100% !important;
    font-size:clamp(13px,3.7vw,15px) !important;
    line-height:1.65 !important;
    text-wrap:pretty;
  }
  body.lesson-page .learning-hero[data-kb-student-hero="v2"] .hero-note {
    position:relative !important;
    flex:0 0 auto !important;
    display:flex !important;
    width:100% !important;
    min-width:0 !important;
    margin:0 !important;
    padding:clamp(14px,3.5vw,18px) clamp(15px,4vw,19px) !important;
    gap:7px !important;
    border-radius:18px !important;
  }
  body.lesson-page .learning-hero[data-kb-student-hero="v2"] .hero-note span {
    font-size:12px !important;
    line-height:1.4;
  }
  body.lesson-page .learning-hero[data-kb-student-hero="v2"] .hero-note strong {
    font-size:clamp(20px,5.5vw,26px) !important;
    line-height:1.38 !important;
    overflow-wrap:anywhere;
  }
  body.lesson-page .learning-hero[data-kb-student-hero="v2"] .hero-note small {
    font-size:11px !important;
    line-height:1.5;
    letter-spacing:.07em !important;
  }
  /* Prevent the sticky learning tabs/audio dock from hiding beneath the fixed global nav. */
  body.lesson-page .study-sidebar {
    top:calc(var(--kb-chapter-header-height, 64px) + 8px) !important;
    scroll-margin-top:calc(var(--kb-chapter-header-height, 64px) + 15px);
  }
  body.lesson-page .understanding-dock {
    top:calc(var(--kb-chapter-header-height, 64px) + 8px) !important;
  }
  body.lesson-page .learning-selector,
  body.lesson-page .card:has(#preview-book) {
    padding:16px !important;
    max-width:100%;
    margin-bottom:16px;
  }
  body.lesson-page .learning-selector .form-row,
  body.lesson-page .card:has(#preview-book) .form-row {
    gap:10px !important;
  }
  body.lesson-page .learning-selector .form-row > *,
  body.lesson-page .card:has(#preview-book) .form-row > * {
    min-width:0;
    max-width:100%;
  }
  body.lesson-page #preview-start,
  body.lesson-page #learning-load {
    min-width:0;
    white-space:normal !important;
    line-height:1.35 !important;
    height:auto !important;
    min-height:50px !important;
  }
}
@media (max-width:360px) {
  body.lesson-page:not(.learning-embedded) .lesson-app {
    width:calc(100% - 16px) !important;
    max-width:calc(100% - 16px) !important;
  }
  body.lesson-page .learning-hero[data-kb-student-hero="v2"] {
    padding:17px 15px !important;
    border-radius:17px !important;
  }
  body.lesson-page .lesson-app .learning-hero[data-kb-student-hero="v2"] h1 {
    font-size:clamp(23px,7.1vw,26px) !important;
    line-height:1.35 !important;
  }
  /* Preserve the logo, account actions and menu on narrow phones. */
  body.lesson-page .header.kb-main-site-header .header-inner {
    padding-inline:8px !important;
    gap:6px !important;
  }
  body.lesson-page .header.kb-main-site-header .header-brand {
    min-width:0 !important;
    flex:1 1 auto !important;
    gap:7px !important;
  }
  body.lesson-page .header.kb-main-site-header .header-wordmark {
    min-width:0 !important;
    overflow:hidden;
  }
  body.lesson-page .header.kb-main-site-header .header-wordmark-top {
    font-size:.95rem !important;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  body.lesson-page .header.kb-main-site-header .kb-main-header-actions {
    flex:0 0 auto !important;
    gap:4px !important;
  }
  body.lesson-page .header.kb-main-site-header .kb-main-header-actions :is(a,button) {
    max-width:100%;
    font-size:.77rem !important;
    padding-inline:.46rem !important;
  }
  body.lesson-page .header.kb-main-site-header .kb-main-header-actions .btn-menu {
    min-width:40px !important;
    padding:0 !important;
  }
}
@media (prefers-reduced-motion:reduce) {
  body.lesson-page .learning-hero[data-kb-student-hero="v2"] { scroll-behavior:auto; }
}
