/*
 * OGC Blog Mobile V11
 * Corrects the mobile article hero breakout and normalises the reading layout.
 * Loaded after V10 so these rules take precedence over V7–V10.
 */

@media (max-width: 767px) {
  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .ogcb-article-wrap {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 0 36px !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  .ogcb-article-wrap > .container,
  .ogcb-article {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
  }

  /*
   * V7 positions the hero at left:50% with a -50vw margin.
   * V10 reset the margin but did not reset left:50%, leaving half
   * of the hero off-screen on mobile.
   */
  .ogcb-article-header--hero {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 0 24px !important;
    padding: 42px 18px 32px !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .ogcb-article-header--hero .ogcb-article-hero-inner,
  .ogcb-article-header--hero > .container {
    position: relative !important;
    left: auto !important;
    width: 100% !important;
    max-width: 720px !important;
    margin: 0 auto !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }

  .ogcb-article-header--hero h1 {
    width: 100% !important;
    max-width: 100% !important;
    margin: 16px auto 13px !important;
    font-size: clamp(27px, 7.6vw, 38px) !important;
    line-height: 1.12 !important;
    overflow-wrap: anywhere !important;
    text-wrap: balance;
  }

  .ogcb-article-header--hero .ogcb-article-deck {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    font-size: 14px !important;
    line-height: 1.58 !important;
    overflow-wrap: anywhere !important;
  }

  .ogcb-article-header--hero .ogcb-article-byline {
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 9px 12px !important;
    margin-top: 20px !important;
    text-align: left !important;
  }

  .ogcb-article-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: calc(100% - 32px) !important;
    max-width: 760px !important;
    margin: 22px auto 42px !important;
    padding: 0 !important;
    gap: 17px !important;
    box-sizing: border-box !important;
  }

  .ogcb-article-share {
    position: static !important;
    grid-column: 1 !important;
    grid-row: 1 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    gap: 9px !important;
  }

  .ogcb-article-share a {
    flex: 0 0 40px !important;
    width: 40px !important;
    height: 40px !important;
  }

  .ogcb-article-body {
    grid-column: 1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .ogcb-article-body > *,
  .ogcb-rich-content {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .ogcb-rich-content {
    width: 100% !important;
    font-size: 15px !important;
    line-height: 1.78 !important;
    overflow-wrap: anywhere !important;
  }

  .ogcb-rich-content img,
  .ogcb-rich-content video,
  .ogcb-rich-content iframe {
    max-width: 100% !important;
  }

  .ogcb-rich-content table {
    display: block !important;
    max-width: 100% !important;
    overflow-x: auto !important;
  }

  .ogcb-toc {
    width: 100% !important;
    max-width: 100% !important;
    overflow-wrap: anywhere !important;
  }

  .ogcb-article-sidebar {
    position: static !important;
    grid-column: 1 !important;
    grid-row: 3 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 3px 0 0 !important;
    padding: 0 !important;
    gap: 13px !important;
    box-sizing: border-box !important;
  }

  .ogcb-article-sidebar .ogcb-ad-card,
  .ogcb-article-sidebar .ogcb-ad-slot,
  .ogcb-article-sidebar .ogcb-ad-cta {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .ogcb-article-sidebar .ogcb-ad-card {
    padding: 14px !important;
    overflow: hidden !important;
  }

  .ogcb-article-sidebar .ogcb-ad-slot,
  .ogcb-article-sidebar .ogcb-ad-slot--tall {
    min-height: 190px !important;
    height: auto !important;
    aspect-ratio: 16 / 9 !important;
    padding: 24px 12px 12px !important;
  }

  .ogcb-article-sidebar .ogcb-ad-cta {
    min-height: 44px !important;
    white-space: normal !important;
    line-height: 1.35 !important;
  }

  /* Remove any visible breadcrumb trail above the article hero.
     Structured-data breadcrumbs in article.php are retained for SEO. */
  .ogcb-article-wrap .ogcb-breadcrumbs {
    display: none !important;
  }

  .ogcb-related {
    position: static !important;
    left: auto !important;
    transform: none !important;
    width: calc(100% - 32px) !important;
    max-width: 760px !important;
    margin: 38px auto 48px !important;
    box-sizing: border-box !important;
  }

  .ogcb-related-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (max-width: 380px) {
  .ogcb-article-layout,
  .ogcb-related {
    width: calc(100% - 24px) !important;
  }

  .ogcb-article-header--hero {
    padding: 34px 14px 28px !important;
  }

  .ogcb-article-header--hero h1 {
    font-size: clamp(26px, 8vw, 32px) !important;
  }

  .ogcb-article-sidebar .ogcb-ad-card {
    padding: 12px !important;
  }
}
