/**
 * Book-plan (learner work panel) pages — full-viewport app shell.
 * The document itself does not scroll; only inner panes (day list, workspace) do.
 *
 * Exception: A1 normal and A2 intensive (body.bd-book-plan-page-scroll) grow
 * with content so the window scrollbar moves the whole platform.
 */

html:has(body.bd-book-plan-page) {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

body.bd-book-plan-page {
  display: flex;
  flex-direction: column;
  margin: 0;
  background: #f3f4f6;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
}

body.bd-book-plan-page .site-header,
body.bd-book-plan-page header.site-header,
body.bd-book-plan-page #masthead,
body.bd-book-plan-page .site-footer,
body.bd-book-plan-page #colophon,
body.bd-book-plan-page footer.site-footer,
body.bd-book-plan-page .elementor-location-header,
body.bd-book-plan-page .elementor-location-footer,
body.bd-book-plan-page .bd-theme-mobile-drawer {
  display: none !important;
}

body.bd-book-plan-page.admin-bar {
  height: calc(100vh - var(--wp-admin--admin-bar--height, 32px));
  height: calc(100dvh - var(--wp-admin--admin-bar--height, 32px));
  max-height: calc(100vh - var(--wp-admin--admin-bar--height, 32px));
  max-height: calc(100dvh - var(--wp-admin--admin-bar--height, 32px));
}

@media (max-width: 782px) {
  body.bd-book-plan-page.admin-bar {
    height: calc(100vh - var(--wp-admin--admin-bar--height, 46px));
    height: calc(100dvh - var(--wp-admin--admin-bar--height, 46px));
    max-height: calc(100vh - var(--wp-admin--admin-bar--height, 46px));
    max-height: calc(100dvh - var(--wp-admin--admin-bar--height, 46px));
  }
}

/* Collapse Elementor full-viewport spacers that would otherwise force page scroll. */
body.bd-book-plan-page .elementor-location-single .elementor-section,
body.bd-book-plan-page .elementor-location-single .elementor-top-section,
body.bd-book-plan-page .elementor-location-single .e-con {
  min-height: 0 !important;
  height: auto !important;
}

body.bd-book-plan-page .elementor-section.elementor-section-height-full,
body.bd-book-plan-page .elementor-section.elementor-section-height-min-height,
body.bd-book-plan-page .e-con.e-parent[style*="min-height"] {
  min-height: 0 !important;
  height: auto !important;
}

body.bd-book-plan-page .elementor-widget-theme-post-title,
body.bd-book-plan-page .elementor-widget-theme-post-excerpt,
body.bd-book-plan-page .entry-header,
body.bd-book-plan-page .page-header,
body.bd-book-plan-page.bahndeutsch-theme .entry-header,
body.bd-book-plan-page.bahndeutsch-theme .bd-theme-breadcrumbs {
  display: none !important;
}

body.bd-book-plan-page .elementor-location-footer .elementor-section,
body.bd-book-plan-page .elementor-location-footer .e-con {
  min-height: 0 !important;
  height: auto !important;
}

/* Stretch WP/theme/Elementor wrappers so the plan app fills the locked viewport. */
body.bd-book-plan-page #page,
body.bd-book-plan-page .site,
body.bd-book-plan-page #content,
body.bd-book-plan-page .site-content,
body.bd-book-plan-page #primary,
body.bd-book-plan-page .content-area,
body.bd-book-plan-page .site-main,
body.bd-book-plan-page .inside-article,
body.bd-book-plan-page .entry-content,
body.bd-book-plan-page .bd-theme-content,
body.bd-book-plan-page .bd-theme-content__inner,
body.bd-book-plan-page .bd-theme-article,
body.bd-book-plan-page .elementor,
body.bd-book-plan-page .elementor-location-single,
body.bd-book-plan-page .elementor-section,
body.bd-book-plan-page .elementor-container,
body.bd-book-plan-page .elementor-widget-wrap,
body.bd-book-plan-page .elementor-widget-theme-post-content,
body.bd-book-plan-page .elementor-widget-container,
body.bd-book-plan-page .e-con {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

body.bd-book-plan-page .bd-book-plan-rescue-mount,
body.bd-book-plan-page .bd-a1-plan-app,
body.bd-book-plan-page .bd-a2-plan-app,
body.bd-book-plan-page .bd-b1-plan-app,
body.bd-book-plan-page .bd-b2-plan-app {
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  margin: 0;
  min-height: 0;
  height: 100%;
  max-height: none;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  box-shadow: none;
}

body.bd-book-plan-page .app-shell {
  height: 100% !important;
  max-height: none !important;
}

body.bd-book-plan-page .bd-book-plan-rescue-mount:empty {
  display: none;
}

/* Guests on a locked plan page see the paywall, not the app shell. An empty
   rescue mount with min-height 92vh used to push the CTA under the related
   links and below the fold. */
html:has(body.bd-book-plan-page.bd-access-preview),
html:has(body.bd-book-plan-page.bd-access-locked) {
  display: block;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
}

body.bd-book-plan-page.bd-access-preview,
body.bd-book-plan-page.bd-access-locked {
  display: block;
  height: auto;
  max-height: none;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: visible;
}

body.bd-book-plan-page.bd-access-preview .bd-book-plan-rescue-mount,
body.bd-book-plan-page.bd-access-locked .bd-book-plan-rescue-mount,
body.bd-book-plan-page.bd-access-preview .bd-plan-rescue-app,
body.bd-book-plan-page.bd-access-locked .bd-plan-rescue-app {
  display: none !important;
}

body.bd-book-plan-page.bd-access-preview #page,
body.bd-book-plan-page.bd-access-locked #page,
body.bd-book-plan-page.bd-access-preview .site,
body.bd-book-plan-page.bd-access-locked .site,
body.bd-book-plan-page.bd-access-preview #content,
body.bd-book-plan-page.bd-access-locked #content,
body.bd-book-plan-page.bd-access-preview .site-content,
body.bd-book-plan-page.bd-access-locked .site-content,
body.bd-book-plan-page.bd-access-preview #primary,
body.bd-book-plan-page.bd-access-locked #primary,
body.bd-book-plan-page.bd-access-preview .content-area,
body.bd-book-plan-page.bd-access-locked .content-area,
body.bd-book-plan-page.bd-access-preview .site-main,
body.bd-book-plan-page.bd-access-locked .site-main,
body.bd-book-plan-page.bd-access-preview .bd-theme-content,
body.bd-book-plan-page.bd-access-locked .bd-theme-content,
body.bd-book-plan-page.bd-access-preview .entry-content,
body.bd-book-plan-page.bd-access-locked .entry-content {
  display: block;
  flex: none;
  height: auto;
  max-height: none;
  overflow: visible;
}

/* Document scroll: A1 normal + A2 intensive. The platform grows with the
   day card so the page scrollbar moves topbar, workspace, sidebar, and the
   SEO "ادامه مسیر" block (a sibling after the shortcode) together.
   Nested overflow stays on the day list (sticky on desktop) and on modals. */
html:has(body.bd-book-plan-page.bd-book-plan-page-scroll) {
  display: block;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
}

body.bd-book-plan-page.bd-book-plan-page-scroll {
  height: auto;
  max-height: none;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: visible;
}

body.bd-book-plan-page.bd-book-plan-page-scroll.admin-bar {
  height: auto;
  max-height: none;
  min-height: calc(100vh - var(--wp-admin--admin-bar--height, 32px));
  min-height: calc(100dvh - var(--wp-admin--admin-bar--height, 32px));
}

@media (max-width: 782px) {
  body.bd-book-plan-page.bd-book-plan-page-scroll.admin-bar {
    height: auto;
    max-height: none;
    min-height: calc(100vh - var(--wp-admin--admin-bar--height, 46px));
    min-height: calc(100dvh - var(--wp-admin--admin-bar--height, 46px));
  }
}

body.bd-book-plan-page.bd-book-plan-page-scroll #page,
body.bd-book-plan-page.bd-book-plan-page-scroll .site,
body.bd-book-plan-page.bd-book-plan-page-scroll #content,
body.bd-book-plan-page.bd-book-plan-page-scroll .site-content,
body.bd-book-plan-page.bd-book-plan-page-scroll #primary,
body.bd-book-plan-page.bd-book-plan-page-scroll .content-area,
body.bd-book-plan-page.bd-book-plan-page-scroll .site-main,
body.bd-book-plan-page.bd-book-plan-page-scroll .inside-article,
body.bd-book-plan-page.bd-book-plan-page-scroll .entry-content,
body.bd-book-plan-page.bd-book-plan-page-scroll .bd-theme-content,
body.bd-book-plan-page.bd-book-plan-page-scroll .bd-theme-content__inner,
body.bd-book-plan-page.bd-book-plan-page-scroll .bd-theme-article,
body.bd-book-plan-page.bd-book-plan-page-scroll .elementor,
body.bd-book-plan-page.bd-book-plan-page-scroll .elementor-location-single,
body.bd-book-plan-page.bd-book-plan-page-scroll .elementor-section,
body.bd-book-plan-page.bd-book-plan-page-scroll .elementor-container,
body.bd-book-plan-page.bd-book-plan-page-scroll .elementor-widget-wrap,
body.bd-book-plan-page.bd-book-plan-page-scroll .elementor-widget-theme-post-content,
body.bd-book-plan-page.bd-book-plan-page-scroll .elementor-widget-container,
body.bd-book-plan-page.bd-book-plan-page-scroll .e-con {
  flex: 1 0 auto;
  height: auto;
  max-height: none;
  overflow: visible;
}

body.bd-book-plan-page.bd-book-plan-page-scroll .bd-book-plan-rescue-mount,
body.bd-book-plan-page.bd-book-plan-page-scroll .bd-a1-plan-app,
body.bd-book-plan-page.bd-book-plan-page-scroll .bd-a2-plan-app,
body.bd-book-plan-page.bd-book-plan-page-scroll .bd-b1-plan-app,
body.bd-book-plan-page.bd-book-plan-page-scroll .bd-b2-plan-app {
  flex: 0 0 auto;
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
}

body.bd-book-plan-page.bd-book-plan-page-scroll .app-shell {
  height: auto !important;
  min-height: 0;
  max-height: none !important;
  overflow: visible;
}

body.bd-book-plan-page.bd-book-plan-page-scroll .main,
body.bd-book-plan-page.bd-book-plan-page-scroll .workspace,
body.bd-book-plan-page.bd-book-plan-page-scroll .main-scroll,
body.bd-book-plan-page.bd-book-plan-page-scroll .content-panel,
body.bd-book-plan-page.bd-book-plan-page-scroll .panel-body {
  overflow: visible;
  min-height: auto;
  max-height: none;
}

body.bd-book-plan-page.bd-book-plan-page-scroll .main-scroll {
  overflow-y: visible;
  flex: 1 1 auto;
}

@media (min-width: 1025px) {
  body.bd-book-plan-page.bd-book-plan-page-scroll .app-shell {
    align-items: flex-start;
  }

  body.bd-book-plan-page.bd-book-plan-page-scroll .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
  }

  body.bd-book-plan-page.bd-book-plan-page-scroll.admin-bar .sidebar {
    top: var(--wp-admin--admin-bar--height, 32px);
    height: calc(100vh - var(--wp-admin--admin-bar--height, 32px));
    height: calc(100dvh - var(--wp-admin--admin-bar--height, 32px));
    max-height: calc(100vh - var(--wp-admin--admin-bar--height, 32px));
    max-height: calc(100dvh - var(--wp-admin--admin-bar--height, 32px));
  }

  body.bd-book-plan-page.bd-book-plan-page-scroll .main {
    flex: 1 1 auto;
    min-width: 0;
  }

  body.bd-book-plan-page.bd-book-plan-page-scroll .days-list {
    min-height: 0;
    overflow-y: auto;
  }
}

/* Related-links nav is appended after the plan shortcode. Keep it in
   document flow so it scrolls with the day card instead of shrinking
   into a clipped strip under the 100vh shell. */
body.bd-book-plan-page.bd-book-plan-page-scroll .bd-seo-related-links,
body.bd-book-plan-page.bd-book-plan-page-scroll .bd-seo-cluster-links,
body.bd-book-plan-page.bd-book-plan-page-scroll .bd-seo-auto-links {
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 1.1rem 1rem calc(5.75rem + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  overflow: visible;
  position: relative;
  z-index: 1;
}

body.bd-book-plan-page.bd-book-plan-page-scroll .bd-seo-related-links-list,
body.bd-book-plan-page.bd-book-plan-page-scroll .bd-seo-cluster-links-list {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0.45rem;
}
