/* ==========================================================================
   FUNDER — homepage view isolation
   ==========================================================================
   ONE file decides what each homepage mode shows (ראשי, פיד, מבט מהיר,
   גליונות, and the banner mode). It loads last, so it is the authority.

   WHY IT EXISTS
   -------------
   View visibility had been written five times, once per feature, each time
   by listing the things that particular view wanted hidden:

     12-chrono.css   hid .fn-composed-home and the sidebar for feed/tables/rank
     25-gallery.css  repeated that list for gallery
     28-banner.css   repeated it again for banner

   A list of things to hide is the wrong shape. Every block added to the page
   afterwards is visible in every view by default, and nobody notices until
   it shows up somewhere it does not belong. That is exactly what happened:
   כתבות במוקד moved to .fn-foot-band OUTSIDE the two columns, so none of
   the three lists mentioned it, and it rendered under the feed, under the
   tables, under the daily ranking, under the gallery and under the banner.

   So this is DEFAULT-DENY. Any mode other than ראשי (the main view, key
   "editorial") hides the main view's furniture wholesale, and then the one
   mode that needs a piece of it asks for that piece back by name. A block
   added to the page later is invisible in every other mode until someone
   decides otherwise, which is the safe direction to fail in.

   WHAT IS GLOBAL
   --------------
   Three things appear in every mode, on purpose:
     - the indices strip (.mainindex) — it is market chrome, not content
     - the view switch itself, or there is no way back
     - the header and the footer
   Everything else belongs to a mode.

   ADS
   ---
   Nothing here moves, re-renders or re-parents the ad slot. The homepage
   creative is an <iframe> from pirsum3 with refresh=120 — re-inserting it
   into the document reloads it, and a reload is a second impression. The
   slot stays where the server put it in every mode; only `display` changes,
   and `display` neither unloads an iframe nor re-requests it.
   ========================================================================== */

/* -------------------------------------------------------------- 1. deny */

/* The attribute is ABSENT in the ראשי view — fn-chrono-feed.js removes
   it rather than setting it to "editorial" — so its presence already means
   "not ראשי". The :not() is belt and braces: nothing writes "editorial"
   today, and if something ever does it must still mean the main view. */
html[data-fn-home-view]:not([data-fn-home-view="editorial"]) .fn-ui .fn-composed-home,
html[data-fn-home-view]:not([data-fn-home-view="editorial"]) .fn-ui .fn-foot-band {
  display: none !important;
}

/* The sidebar is denied by the same rule EXCEPT in the banner mode, where
   the advert lives inside it. Written as a second :not() rather than as a
   later "allow" override, because the deny selector carries one more
   compound than any allow could and would simply win: two !important
   declarations are resolved by specificity, and
   `html[a]:not([a=x]) .fn-ui .fn-home-row > .pd-rt-none` (0,5,1) beats
   `html[a=banner] .fn-ui .fn-home-row > .pd-rt-none` (0,4,1). Expressing
   the exception in the deny selector is the only version that cannot be
   lost to a cascade accident. */
html[data-fn-home-view]:not([data-fn-home-view="editorial"]):not([data-fn-home-view="banner"]) .fn-ui .fn-home-row > .pd-rt-none {
  display: none !important;
}

/* The mode containers are hidden unless their own mode is on.
   #fnChronoFeed and #fnGalleryView also carry the `hidden` attribute from
   the server; this is the single place that states the rule. */
.fn-ui #fnChronoFeed,
.fn-ui #fnQuickState,
.fn-ui #fnStockMoversView,
.fn-ui #fnTopTurnoverView,
.fn-ui #fnSectorsView,
.fn-ui #fnRankView,
.fn-ui #fnGalleryView {
  display: none;
}


/* ------------------------------------------------------------- 2. allow */

/* מבט מהיר is five blocks under one mode, in page order: the market-state
   bar, the TA-125 movers, the most traded, the sector breadth, the ranking.
   The state bar and the most-traded block carry `hidden` from the server and
   from fn-home-views.js (no figure yet / no turnover off-hours), so they are
   allowed only while it is absent, as the gallery is. */
html[data-fn-home-view="feed"] .fn-ui #fnChronoFeed,
html[data-fn-home-view="quick"] .fn-ui #fnQuickState:not([hidden]),
html[data-fn-home-view="quick"] .fn-ui #fnStockMoversView,
html[data-fn-home-view="quick"] .fn-ui #fnTopTurnoverView:not([hidden]),
html[data-fn-home-view="quick"] .fn-ui #fnSectorsView,
html[data-fn-home-view="quick"] .fn-ui #fnRankView,
html[data-fn-home-view="gallery"] .fn-ui #fnGalleryView:not([hidden]) {
  display: block !important;
}

/* The article column itself carries every mode but one, so it survives
   everywhere except the banner — where the content lives in the sidebar. */
html[data-fn-home-view="banner"] .fn-ui .fn-home-row > .indexArticles {
  display: none !important;
}

html[data-fn-home-view="banner"] .fn-ui .fn-home-row > .pd-rt-none {
  float: none;
  width: 100%;
  max-width: 100%;
}

/* …and inside the sidebar, only the ad.
   ---------------------------------------------------------------------
   THE SPECIFICITY TRAP, written out because it cost a round.

   The class-only version of this rule,

     html[data-fn-home-view="banner"] .fn-ui .fn-home-row > .pd-rt-none > *:not(.index_bnrid3)

   is (0,5,1) — five classes, one attribute, no id. It lost. index.aspx
   loads recently-viewed.css and recently-viewed-funds.css from the FOOTER,
   after the whole head stylesheet block, and each of them carries:

     #recentlyViewedPanel.recently-viewed-panel.is-visible { display: block !important }

   which is (1,2,0). One id beats any number of classes, so the two "נצפו
   לאחרונה" tables rendered on top of the banner view, full width, in a
   mode that is supposed to contain one advert.

   It only bit the BANNER mode, which is why it survived a 108-render
   sweep: every other mode hides `.pd-rt-none` itself, and a child cannot
   out-display a hidden parent. The banner mode is the one that keeps the
   sidebar — because the advert lives inside it — and hides the siblings
   one by one. That is the only place a child's own `display` matters.

   Anchoring on `#mainContent` — a real element on this page, not an id
   invented for the fight — makes this (1,4,1): same id count, more
   classes, so it wins. It stays general: still `:not()` on the slot rather
   than a list of panels, so a module added to the sidebar tomorrow is
   still hidden here by default.
   --------------------------------------------------------------------- */
html[data-fn-home-view="banner"] #mainContent .fn-home-row > .pd-rt-none > *:not(.index_bnrid3) {
  display: none !important;
}

/* Belt and braces for a future stylesheet that out-specifies even that:
   the sidebar in banner mode lays its children out as a single centred
   column, so anything that does slip through cannot sit beside the advert
   or stretch across the page. */
html[data-fn-home-view="banner"] #mainContent .fn-home-row > .pd-rt-none {
  display: flex;
  flex-direction: column;
  align-items: center;
}


/* ------------------------------------------------- 3. the one-column modes */

/* With the sidebar gone the article column is the page. Bootstrap still
   floats it at two thirds between 768px and 991px (col-sm-8), which left a
   third of a tablet empty beside the content. */
html[data-fn-home-view]:not([data-fn-home-view="editorial"]) .fn-ui .fn-home-row > .indexArticles {
  width: 100%;
  max-width: 100%;
}

/* 24-wide.css makes the row a two-column grid at >= 992px. A mode with no
   sidebar has nothing to sit beside, and `width: 100%` inside a grid means
   100% of a 2fr TRACK — which is how the gallery came out at 760px and the
   banner at 380px instead of the full measure. */
@media (min-width: 992px) {
  html[data-fn-home-view]:not([data-fn-home-view="editorial"]) .fn-ui .fn-home-row {
    grid-template-columns: minmax(0, 1fr);
  }

  html[data-fn-home-view]:not([data-fn-home-view="editorial"]) .fn-ui .fn-home-row > .indexArticles,
  html[data-fn-home-view]:not([data-fn-home-view="editorial"]) .fn-ui .fn-home-row > .pd-rt-none {
    grid-column: 1;
    grid-row: 1;
  }
}


/* -------------------------------------------------------- 4. מבט מהיר */

/* Two blocks, one reading measure. The movers cards are drawn for two
   columns of about 450px; the ranking under them takes the same measure so
   the two share their edges, instead of a centred block sitting on a table
   that runs the full width of the page. */
.fn-ui .fn-quick-block {
  max-width: 920px;
  margin-inline: auto;

  /* How tall the ranking may grow before it scrolls inside its board
     (.fn-board__pane, 12-chrono.css). 122 rows in normal flow made this
     "quick look" 6,800px long. On a phone or tablet it takes most of the
     screen but never all of it, so there is always page left to grab and
     scroll past it; `svh` so a mobile browser's collapsing bars do not
     change it mid-scroll. The 640px cap keeps the pane shorter than the
     shortest list that gets the sticky header (FnStickyHead.MIN_ROWS + 1
     rows is about 710px), so such a list always really scrolls. */
  --fn-quick-table-share: 60vh;
  --fn-quick-table-max: min(var(--fn-quick-table-share), 640px);
}

@supports (height: 1svh) {
  .fn-ui .fn-quick-block {
    --fn-quick-table-share: 60svh;
  }
}

/* Beside a mouse the page is not the scroller of choice: the header and
   eleven and a half rows, the half row saying that the list goes on. */
@media (min-width: 992px) {
  .fn-ui .fn-quick-block {
    --fn-quick-table-max: 520px;
  }
}
