/* ──────────────────────────────────────────────────────────────────────────
   mobile-layout.css — shared narrow-screen layout guards.

   One common cause sits behind the horizontal overflow seen on the dashboard,
   Theme Evolution, Trend Watch and the game list: flex and grid items default
   to `min-width: auto`, so a long game title or a nowrap badge sets a floor
   under the row and the whole page gets wider than the viewport. Truncation
   (`text-truncate`) never engages, because the box never has to shrink.

   The rules below fix that generically instead of per screen. They are scoped
   so desktop layout is untouched: the only unconditional rules are the
   `.min-w-0` utility (previously defined in game-dna-list.css, therefore dead
   on every other page) and the body overflow guard.
   ────────────────────────────────────────────────────────────────────────── */

/* 1. The utility the markup already asks for, now available site-wide.
      `_feed_game.html` and others carry class="min-w-0" but only the Game DNA
      list shipped the declaration, so elsewhere it resolved to min-width:auto. */
.min-w-0 {
  min-width: 0 !important;
}

/* 2. The page itself must never scroll sideways. Wide content is allowed to
      scroll inside its own container (rule 5), not to drag the layout along.
      `clip`, not `hidden`: hidden on both html and body turns body into its own
      scroll container, so window.scrollY stays 0 and every scroll-driven / sticky
      section of the landing freezes while the page scrolls past it. */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

@media (max-width: 991.98px) {
  /* 3. Let flex/grid children shrink below their content width so that
        text-truncate and ellipsis can do their job. Applied to the content
        area only — the sidebar and navbar keep their own sizing rules. */
  .layout-page .card-body > .d-flex,
  .layout-page .card-body > ul > li.d-flex,
  .layout-page .card-header > .d-flex,
  .layout-page .d-grid > li.d-flex {
    min-width: 0;
  }

  .layout-page .flex-grow-1,
  .layout-page .text-truncate {
    min-width: 0;
  }

  /* 4. Card headers that pair an icon block with a title and a right-hand
        action: allow them to wrap instead of forcing one wide row. This is
        also what stops the icon from sitting on top of the heading, because
        the title block keeps its own line once space runs out. */
  .layout-page .card-header.d-flex {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  .layout-page .card-header .card-title,
  .layout-page .card-header .card-subtitle {
    overflow-wrap: anywhere;
  }

  /* 5. Genuinely wide content scrolls inside its own box. */
  .layout-page .table-responsive,
  .layout-page .season-items,
  .layout-page .chart-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 6. Seasonal Opportunities Timeline: the row of seasons is a flex track
        whose items carry a nowrap "Deadline in N days" pill. With
        min-width:auto each item claimed its full text width and the card was
        pushed off-screen. Give the items a sane floor and let them scroll. */
  .layout-page .season-items {
    justify-content: flex-start;
    gap: 0.75rem;
  }

  .layout-page .season-item {
    min-width: 7.5rem;
    flex: 0 0 auto;
  }

  .layout-page .season-item .badge {
    white-space: normal;
  }

  /* 7. Legend / filter chip rows (Trend Watch "Blue Ocean / Competitive /
        Saturated / Niche") wrap instead of running off the card. */
  .layout-page .card-header .d-flex.gap-2 {
    flex-wrap: wrap;
  }

  /* 8. Pagination: wrap onto several lines, stay inside the container and
        keep breathing room above the end of the page. */
  .layout-page .pagination {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 0.35rem;
    margin-bottom: 1.5rem;
  }

  .layout-page .pagination .page-link {
    min-width: 2rem;
    padding-inline: 0.5rem;
  }
}

/* 9. Icon-beside-heading pattern ("Gap Analysis", "Thinning lanes").
      The round .avatar sits in a flex row next to a text block. The text block
      cannot shrink (min-width:auto), so the flex algorithm takes the space out
      of the avatar instead: a 48px circle was measured at 24.9px and a 40px one
      at 14.4px. Squashed that far the glyph no longer fits its box and prints
      over the heading. The avatar must never shrink; the text block must. */
.layout-page .card .avatar {
  flex-shrink: 0;
}

.layout-page .card-header > .d-flex > div:not(.avatar),
.layout-page .card-body > .d-flex > .d-flex > div:not(.avatar) {
  min-width: 0;
}

/* 10. Icon-inside-heading variant: the icon keeps its own column and never
      overlaps the text when the heading wraps. Narrow screens only, so
      desktop spacing is unchanged. */
@media (max-width: 575.98px) {
  .layout-page .card-title > i,
  .layout-page .card-title > .icon-base,
  .layout-page h5 > i.icon-base {
    flex: 0 0 auto;
    vertical-align: middle;
  }

  .layout-page .card-title {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .layout-page .card-title > i,
  .layout-page .card-title > .icon-base {
    margin-top: 0.15rem;
  }
}
