/* ==========================================================================
   FUNDER — full-width handover
   --------------------------------------------------------------------------
   Udi: when the sidebar ends, the rest of the page must not keep running at
   two-thirds width with empty space beside it.

   THE PROBLEM WITH THE OBVIOUS FIXES
   ----------------------------------
   The page is a Bootstrap 3 float grid: an 8/12 article column and a 4/12
   sidebar. Content inside a float cannot escape its own column, so making
   the tail of the article column go full width means one of:

     a. measuring the sidebar in JavaScript and repositioning — which moves
        the page after a late-loading banner, i.e. exactly the layout shift
        the brief forbids;
     b. floating the sidebar inside one full-width column and letting blocks
        flow past it — self-measuring and elegant, but section headings would
        wrap around the float and the green rule would run under the sidebar;
     c. grid.

   (c). The row becomes a two-column grid. The article column and the
   sidebar sit in row 1; the tail run sits in row 2 and spans both columns:

       ┌──────────────────────┬────────────┐
       │  narrow run  (row 1) │  sidebar   │
       ├──────────────────────┴────────────┤
       │  wide run    (row 2, 1 / -1)      │
       └───────────────────────────────────┘

   Grid rows cannot overlap and the second cannot start before both cells of
   the first have ended. That gives three properties for free, none of which
   needed a number:

     - no overlap is possible, whatever the two columns turn out to measure
     - an ad or a table that arrives late simply grows row 1; it cannot push
       the wide run sideways, so there is no cumulative layout shift
     - nothing is measured in JavaScript, so there is nothing to re-measure

   The band is a CHILD OF THE ROW rather than a descendant of the article
   column, which is what keeps this to pure placement: no `display: contents`
   on Bootstrap columns (it would silently drop their padding), and nothing
   between the grid and its item. Grid placement ignores DOM order, so the
   band can sit between the two columns in the markup — where the phone needs
   it, since the phone has no grid and renders source order — and still land
   on the row below them on desktop.

   Below the lg breakpoint the whole thing is a single column anyway and none
   of this applies; the grid is scoped so a phone never enters it.
   ========================================================================== */

@media (min-width: 992px) {

  .fn-ui .fn-home-row {
    display: grid;
    /* The 8/12 and 4/12 of the float grid this replaces, to the pixel:
       Bootstrap's columns are 66.666% / 33.333% of the row, and the row's
       negative margins plus the columns' padding produce the 30px gutter. */
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    column-gap: var(--fn-col-gap);
    align-items: start;
    /* Fill the column content box. Every track is minmax(0, fr), so the
       grid's min-content size is 0, and width:auto inside the floated
       Bootstrap column collapses to that 0 once the negative row margins
       are gone. 100% is the content box — the same edge as the header. */
    width: 100%;
    /* The row sits in the parent column, which is already the content box.
       Bootstrap's negative row margin would pull this grid out to the
       container's border edge, 15px past the header and the indices. */
    margin-left: 0;
    margin-right: 0;
  }

  .fn-ui .fn-view-switch-row,
  .fn-ui .fn-foot-band {
    margin-left: 0;
    margin-right: 0;
  }

  .fn-ui .fn-home-row::before,
  .fn-ui .fn-home-row::after,
  .fn-ui .fn-view-switch-row::before,
  .fn-ui .fn-view-switch-row::after,
  .fn-ui .fn-foot-band::before,
  .fn-ui .fn-foot-band::after {
    content: none;
    display: none;
  }

  /* The article cell is the content edge. The inner Bootstrap column was
     a second 15px inset, so the hero sat in from the indices and the banner. */
  .fn-ui .fn-home-row > .indexArticles > [class*="col-"] {
    padding-left: 0;
    padding-right: 0;
  }

  /* Bootstrap's float/width/padding on the two columns would fight the grid;
     the grid now owns placement, so they are handed back. */
  .fn-ui .fn-home-row > .indexArticles,
  .fn-ui .fn-home-row > .pd-rt-none {
    float: none;
    width: auto;
    max-width: none;
    padding-left: 0;
    padding-right: 0;
  }

  .fn-ui .fn-home-row > .indexArticles { grid-column: 1; grid-row: 1; }
  .fn-ui .fn-home-row > .pd-rt-none    { grid-column: 2; grid-row: 1; }

  /* The handover: full measure, on the row below both columns. `1 / -1` and
     `2` are the whole mechanism — everything else in this file is cleanup. */
  .fn-ui .fn-home-row > .fn-wide-run {
    grid-column: 1 / -1;
    grid-row: 2;
    float: none;
    width: auto;
    max-width: none;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
  }

  /* The band that closes the page (כתבות במוקד) is outside the row entirely
     and is already full width; it only needs the top rhythm. */
  .fn-ui .fn-foot-band {
    margin-top: var(--fn-section-gap);
  }

  /* The sections inside the band are still Bootstrap columns; they were
     sized against the 8/12 parent and now have a 12/12 one. */
  .fn-ui .fn-home-row > .fn-wide-run > .col-sm-12 {
    float: none;
    width: auto;
    padding-left: 0;
    padding-right: 0;
  }

  /* A trio band holds exactly THREE items, so asking for four columns
     across the wide measure would have left an empty fourth slot on every
     row — the hole this feed system is built to avoid. The cards simply get
     wider instead. Four-across would need the SERVER to emit four-item
     bands, which is a composition change, not a width change.

     The briefs row is the one thing that does want a wider thumbnail: it
     was sized against a 760px column and looks undersized against 1366. */
  .fn-ui .fn-wide-run .fn-feed__band--briefs .fn-feed__link {
    grid-template-columns: 240px minmax(0, 1fr);
  }


  /* Width may grow in the wide run; the ratio does not. It stays 3:2,
     the same crop the CDN sends. Briefs use that ratio too, at their
     own fixed thumbnail width. */
  .fn-ui .fn-wide-run .fn-feed__band--lead .fn-feed__media,
  .fn-ui .fn-wide-run .fn-feed__band--split .fn-feed__media,
  .fn-ui .fn-wide-run .fn-feed__band--trio .fn-feed__media {
    aspect-ratio: 3 / 2;
    width: 100%;
    height: auto;
    min-height: 0;
    align-self: start;
  }

  /* The trio's body was the other half of its height. Small trims only —
     the headline keeps its 15px, because that is the size at which a
     three-line Hebrew headline is still comfortable at 446px and the brief
     was explicitly not to hurt readability. */
  .fn-ui .fn-wide-run .fn-feed__band--trio .fn-feed__body {
    padding: 15px 14px 14px;
    gap: 7px;
  }

  .fn-ui .fn-wide-run .fn-feed__band--trio .fn-feed__meta {
    padding-top: 6px;
  }

  /* The floors from 26-desktop.css were set for the NARROW column, where a
     short headline could leave a 150px strip. In the wide run the picture
     alone is past them, so they do nothing — except on a section whose
     pictures are all missing, where they would hold a card open at 280px
     for no reason. */
  .fn-ui .fn-wide-run .fn-feed__band--lead .fn-feed__link,
  .fn-ui .fn-wide-run .fn-feed__band--split .fn-feed__link {
    min-height: 0;
  }
}

/* Below the grid the wide run is a plain block inside a Bootstrap .row, and
   unlike the article column it is not a .col-*, so it never received the
   15px column padding. Its sections are .pad_none, so their bubbles ran to
   the row's negative margin — edge to edge — while every bubble above sat
   inside the column gutter. Same gutter here, and all cards share one width. */
@media (max-width: 991px) {
  .fn-ui .fn-home-row > .fn-wide-run {
    padding-left: 15px;
    padding-right: 15px;
  }
}

/* The one-column modes used to be handled here with a list of view names,
   which went stale the moment a sixth view arrived. 29-views.css now owns
   that for every mode under one default-deny rule — including collapsing
   this grid, because a grid TRACK beats `width: 100%` and that is how the
   gallery came out at 760px and the banner at 380px. */

/* No grid support (very old engines): everything stays exactly as it was —
   a float grid with a narrow tail. Worse, never broken. */
@supports not (display: grid) {
  .fn-ui .fn-home-row { display: block; }
}
