/* ==========================================================================
   FUNDER — the desktop surface
   ==========================================================================
   Everything here is behind `@media (min-width: 768px)`, so the phone layer
   (21-mobile.css) and this file cannot both apply to the same pixel.

   WHAT THIS IS FOR
   ----------------
   The phone grew a design language over the last rounds — a branded canvas
   with the FUNDER wallpaper, one radius, one hairline, one shadow — and the
   desktop had none of it. Udi asked for the same identity at both sizes.

   WHAT IT IS NOT FOR
   ------------------
   It is a visual upgrade, not a second licence to move things. The approved
   structural changes live in index.aspx and 24-wide.css. Nothing in this
   file changes a column, an order, a position or a size: it is radius,
   border, shadow, surface and hover only.

   That constraint is the reason the hairlines here are drawn with
   `box-shadow: inset 0 0 0 1px` rather than with `border`. A border is a
   box-model change — it grows the element or, under `box-sizing: border-box`,
   eats a pixel of the content inside it, and on a 50-row table that is the
   difference between six and a half rows and six. An inset shadow paints on
   the same pixel and costs the layout nothing, so "add a subtle border" and
   "do not move anything" stop being in tension.

   Density is preserved for the same reason: no padding is added to a
   container that did not already have some. The modules look contained
   because they have an edge, not because they have been inflated.
   ========================================================================== */

@media (min-width: 768px) {

  /* ======================================================== 1. THE CANVAS */

  /* Same construction as the phone: the colour moves to <html>, <body> goes
     transparent, and the fixed wallpaper layer paints between the two.
     `position: fixed` makes it a static compositor layer — painted once and
     never repainted on scroll, which on a 7000px homepage matters more than
     it does on a phone. */
  html {
    background-color: var(--fn-canvas-color, var(--fn-bubble-canvas, var(--fn-bg-canvas)));
  }

  body.fn-ui {
    background-color: transparent;
  }

  /* Same wallpaper as the phone, tiled at the desktop size so the marks
     stay small on a wide window instead of stretching with `cover`. */
  body.fn-ui::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-color: var(--fn-canvas-color);
    background-image: var(--fn-canvas-image);
    background-size: var(--fn-canvas-tile-size-desktop) auto;
    background-position: 0 0;
    background-repeat: repeat;
    background-blend-mode: var(--fn-canvas-blend, normal);
  }

  /* The accessibility high-contrast modes own the surface completely. */
  body.fn-ui.darkCont::before,
  body.fn-ui.brightCont::before {
    display: none;
  }


  /* ====================================================== 2. THE CONTAINER */

  /* One shape for every module that already had a container of its own:
     the data tables, the two boards, the magazine plate, the hero frame and
     the banner slot. Each of these already painted a surface — they are
     getting a consistent edge, not a new box.

     `background-clip: padding-box` matters here: these modules have tables
     and images that run to their edge, and without it a child's background
     paints over the rounded corner. */
  .fn-ui .fn-data-module,
  .fn-ui .fn-board,
  .fn-ui .fn-magazine,
  .fn-ui .fn-gallery__cover,
  .fn-ui .index_bnrid3 {
    border-radius: var(--fn-radius-lg);
    background-clip: padding-box;
  }

  .fn-ui .fn-data-module,
  .fn-ui .fn-board,
  .fn-ui .fn-magazine {
    background-color: var(--fn-bubble-bg, var(--fn-bg-surface));
    /* The hairline and the lift, neither of which touches the box model. */
    box-shadow:
      inset 0 0 0 1px var(--fn-bubble-border, var(--fn-border)),
      var(--fn-bubble-lift);
    overflow: hidden;
  }

  /* The magazine is the one sidebar module whose markup has no inner
     toolbar/body to carry padding, so it is given some here. Without it
     the cover and the issue list sit against the bubble's edge and the
     plate reads as a hole in the column rather than as a module. */
  .fn-ui .fn-magazine {
    padding: var(--fn-space-4);
  }

  .fn-ui .fn-magazine .fn-section-header {
    margin-bottom: var(--fn-space-3);
  }

  /* The hero keeps its own radius scale — it is the largest object on the
     page and the small radius looks like a mistake at that size. */
  .fn-ui .fn-hero__frame {
    border-radius: var(--fn-radius-lg);
    overflow: hidden;
  }

  /* The index cards in the strip: same family, smaller shape. They sit in a
     scroller, so the shadow has to stay inside their own box or it clips
     against the mask at the strip's edge. */
  .fn-ui #mdlFrame .fn-index-card {
    border-radius: var(--fn-radius-md);
    background-clip: padding-box;
  }

  /* The banner slot gets the shape but NOT a surface, a shadow or a crop:
     whatever the ad server returns owns its own pixels, and clipping a
     creative or painting behind it is how an impression stops matching what
     was sold. Radius only, and only on the slot. */
  .fn-ui .index_bnrid3 {
    overflow: visible;
  }
}

/* --------------------------------------------------------------------------
   The tablet band, where the ad is wider than the column it lives in
   --------------------------------------------------------------------------
   Between 768 and 991 the sidebar is Bootstrap's `col-sm-4`, which is 236px
   at 768 and only reaches 300px at about 940. A 300x250 creative therefore
   does not fit, and the page gains 41px of horizontal scroll at 768 —
   measured, and present before any of this round's work: nothing here sets
   the creative's width.

   A page that scrolls sideways on a tablet because of an advert is worse
   for the advertiser than a creative shown at 79% — the whole layout shifts
   under the reader, and on a touch device the page can be dragged away from
   the ad entirely. So the creative is allowed to scale, and ONLY in the band
   where it cannot fit: at 992 and up the grid gives the sidebar 380px and
   this rule stops applying, so a 300px creative is never scaled on a desktop.

   Nothing about the ad mechanism changes. This is `max-width`, the same
   thing `img-responsive` does to every other image on the site. The slot,
   the markup, the href, the impression and the click are untouched, and if
   the creative is already fluid the rule is a no-op.
   -------------------------------------------------------------------------- */

@media (min-width: 768px) and (max-width: 991px) {
  .fn-ui .index_bnrid3 img,
  .fn-ui .index_bnrid3 iframe {
    max-width: 100%;
  }

  .fn-ui .index_bnrid3 img {
    height: auto;
  }
}


/* ==========================================================================
   Back inside the DESKTOP query.
   --------------------------------------------------------------------------
   The tablet rule above was inserted here in a hurry and it closed the main
   `@media (min-width: 768px)` block instead of opening its own. Everything
   that followed — the card, the hover response, the sidebar rhythm and the
   table rules — silently became tablet-only, 768 to 991. At 1280 and 1440
   none of it applied, which is why the desktop article cards had no bubble
   however many times the selectors were corrected.

   No test caught it. Every suite that touched these rules measured at
   1280 and asserted the TOKENS resolved, never that a card had a surface.
   `desktop-cards.js` now asserts the painted result instead.
   ========================================================================== */

@media (min-width: 768px) {

  /* ======================================================== 3. THE CARD */

  /* The whole article is ONE bubble, exactly as on a phone: a white surface
     with a radius, a hairline, a soft lift, the picture sealed to its own
     edge and the headline and byline padded inside the same box.

     The first attempt here rounded only the PICTURE and left the card
     transparent, on the theory that eight sections of filled boxes would
     read as a wall. That was the wrong call and Motti rejected it: a
     rounded photo with loose text under it is not a card, it is a photo
     with a caption, and it does not match what the phone does. The
     "wall of boxes" worry is answered by the gap between cards and by the
     bands still being different shapes — not by refusing to draw the box.

     The shell goes on .fn-feed__link rather than on .fn-feed__item because
     the link is the pressable element: :hover and :active then answer on
     the same box that draws the card, with no wrapper and no :has(). */
  .fn-ui .fn-feed__link,
  .fn-ui .fn-chrono__link {
    position: relative;
    border-radius: var(--fn-bubble-radius);
    background: var(--fn-bubble-bg, var(--fn-bg-surface));
    background-clip: padding-box;
    /* The hairline is an INSET shadow, not a border: a border is a
       box-model change and would narrow every card by two pixels. The lift
       comes from --fn-bubble-shadow, the same pair the phone uses, so a
       card looks like the same object at both sizes. */
    box-shadow:
      inset 0 0 0 1px var(--fn-bubble-border, var(--fn-border)),
      var(--fn-bubble-lift);
    overflow: hidden;
  }

  /* The picture seals onto the card's edge — it is the card's own roof, not
     a picture resting on a panel. The ring and radius the standalone photo
     used to carry are handed back: inside a bubble they draw a second,
     slightly smaller box one pixel in from the first. */
  .fn-ui .fn-feed__media,
  .fn-ui .fn-chrono__media {
    border-radius: 0;
    box-shadow: none;
    background-color: var(--fn-bubble-media-bg, var(--fn-bg-sunken));
  }

  /* --- vertical cards: picture on top, body beneath ------------------- */
  .fn-ui .fn-feed__band--trio .fn-feed__link,
  .fn-ui .fn-feed__band--duo .fn-feed__link {
    gap: 0;
  }

  .fn-ui .fn-feed__band--trio .fn-feed__body,
  .fn-ui .fn-feed__band--duo .fn-feed__body {
    padding: 14px 16px 16px;
    gap: 8px;
  }

  /* --- side-by-side cards: picture leads, body holds the other column -- */
  .fn-ui .fn-feed__band--lead .fn-feed__link,
  .fn-ui .fn-feed__band--split .fn-feed__link {
    gap: 0;
    align-items: stretch;
  }

  .fn-ui .fn-feed__band--lead .fn-feed__media,
  .fn-ui .fn-feed__band--split .fn-feed__media {
    /* The file is a 3:2 crop. Stretching this box to the text column
       sliced a different window out of every card. The box stays 3:2
       and sits on the top edge; a taller headline does not grow it. */
    aspect-ratio: 3 / 2;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    align-self: start;
  }

  .fn-ui .fn-feed__band--lead .fn-feed__body,
  .fn-ui .fn-feed__band--split .fn-feed__body {
    padding: 24px 26px;
    gap: 10px;
    align-self: center;
  }

  /* Briefs are the tail of a section: a 180px thumbnail beside the
     headline. The thumbnail is 3:2 (120px tall at 180px wide), which is the floor —
     a longer headline can grow the card, the picture is not stretched. */
  .fn-ui .fn-feed__band--briefs {
    gap: var(--fn-bubble-gap, 14px);
  }

  .fn-ui .fn-feed__band--briefs .fn-feed__item {
    border-top: 0;
    padding: 0;
  }

  .fn-ui .fn-feed__band--briefs .fn-feed__link {
    gap: 0;
    align-items: stretch;
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .fn-ui .fn-feed__band--briefs .fn-feed__media {
    aspect-ratio: 3 / 2;
    width: 100%;
    height: auto;
    align-self: center;
  }

  .fn-ui .fn-feed__band--briefs .fn-feed__body {
    padding: 18px 22px;
    gap: 8px;
    align-self: center;
  }

  /* A brief with no photograph is the same card without the first column. */
  .fn-ui .fn-feed__band--briefs .fn-feed__item--noimg .fn-feed__link {
    grid-template-columns: minmax(0, 1fr);
  }

  /* A card with no photo still has to be a card, and inside a bubble it
     needs neither of the two devices it used when it was a bare block:

       - the 2px green rule above the headline was standing in for an edge.
         The bubble is the edge now, and a full-width rule across the middle
         of a card reads as a divider between two things that are one thing.
       - `align-content: center` on the grid did not actually centre it,
         because the body's own padding grows the single row it is centring.
         A flex column with justify-content does, and it does not care what
         the body is padded by.

     Without this the headline sat at the bottom of a card as tall as its
     photographed neighbours, with a third of the bubble empty above it. */
  .fn-ui .fn-feed__item--noimg .fn-feed__link {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .fn-ui .fn-feed__item--noimg .fn-feed__body {
    padding: 18px 16px;
    padding-top: 18px;
    border-top: 0;
  }

  /* The chronological feed (פיד) is the same object at a different size. */
  .fn-ui .fn-chrono__item {
    border-bottom: 0;
  }

  .fn-ui .fn-chrono__list {
    gap: var(--fn-bubble-gap, 14px);
  }

  .fn-ui .fn-chrono__link {
    gap: 0;
    align-items: stretch;
    padding: 0;
  }

  .fn-ui .fn-chrono__media {
    aspect-ratio: 3 / 2;
    width: 100%;
    height: auto;
    align-self: center;
  }

  .fn-ui .fn-chrono__body {
    padding: 14px 18px;
    align-self: center;
  }

  /* --- equal height across a row ---------------------------------------
     07-feed.css sets `align-items: start` on the band. That was right when
     a card was a photo with text under it: a short item simply ended
     sooner and nothing showed. With a surface it is immediately wrong —
     three bubbles in a row, each a different height, because one headline
     wrapped to two lines and its neighbours to three.

     Stretch is the whole fix, plus two consequences of it:
       - the ITEM must pass the stretched height down to the link, which is
         the element that actually draws the card;
       - the BODY must take the leftover height (`1fr`), or the card grows
         while the white it contains does not, and the extra appears as a
         gap under the text instead of around it.

     No fixed heights anywhere: a four-line headline makes its whole ROW
     taller, which is what a grid is for. */
  .fn-ui .fn-feed__band {
    align-items: stretch;
  }

  .fn-ui .fn-feed__item {
    display: flex;
    align-self: stretch;
  }

  .fn-ui .fn-feed__link {
    width: 100%;
  }

  .fn-ui .fn-feed__band--trio .fn-feed__link,
  .fn-ui .fn-feed__band--duo .fn-feed__link {
    grid-template-rows: auto minmax(0, 1fr);
  }

  /* The date is the last line of every card, so pinning it to the bottom is
     what makes a row of cards share one baseline for their secondary
     information instead of three. */
  .fn-ui .fn-feed__band--trio .fn-feed__meta,
  .fn-ui .fn-feed__band--duo .fn-feed__meta {
    margin-top: auto;
    padding-top: 8px;
  }

  /* The 3:2 picture is the floor. A longer headline may grow the card;
     the picture stays at the top instead of being stretched over it. */

  /* Cards need room to read as separate objects. The bands were spaced for
     objects with no edges; with an edge, 10px looks like a seam. */
  .fn-ui .fn-feed__band {
    gap: var(--fn-bubble-gap, 14px);
  }

  .fn-ui .fn-feed__band + .fn-feed__band {
    margin-top: var(--fn-bubble-gap, 14px);
  }

  /* ====================================================== 4. THE RESPONSE */

  /* Hover and press, on everything that is a destination. The colour comes
     from the interaction tokens, so it is the approved green here exactly as
     it is on the view switch and in the rail. */
  .fn-ui .fn-feed__link,
  .fn-ui .fn-chrono__link {
    transition:
      transform var(--fn-dur-fast) var(--fn-ease),
      opacity var(--fn-dur-fast) var(--fn-ease);
  }

  .fn-ui .fn-feed__link:active,
  .fn-ui .fn-chrono__link:active {
    transform: scale(0.995);
  }

  .fn-ui .fn-data-module,
  .fn-ui .fn-board {
    transition: box-shadow var(--fn-dur-base) var(--fn-ease);
  }

  /* A card lifts on hover; a MODULE answers with its edge only. These are
     tables, and moving a table under a reader tracking a row is unhelpful. */
  .fn-ui .fn-feed__link:hover,
  .fn-ui .fn-chrono__link:hover {
    box-shadow:
      inset 0 0 0 1px var(--fn-interactive-line),
      var(--fn-shadow-md);
  }

  .fn-ui .fn-data-module:hover,
  .fn-ui .fn-board:hover {
    box-shadow:
      inset 0 0 0 1px var(--fn-interactive-line),
      var(--fn-shadow-md);
  }

  /* Table rows already have a hover; it just needs to agree with the rest
     of the interaction language instead of being a grey wash. */
  .fn-ui .fn-data-table tbody tr:hover > td {
    background-color: var(--fn-interactive-wash);
  }


  /* ====================================================== 5. THE RHYTHM */

  /* ONE distance between sidebar modules, owned in one place.
     ---------------------------------------------------------------------
     index.aspx separates SOME of the seven sidebar modules with
     `<div class="col-*">&nbsp;</div>` and others with nothing. Measured,
     that produced 20px between adjacent modules and 60px wherever a spacer
     fell — the spacer's own ~20px line box plus a margin on each side. A
     third of the sidebar at triple the spacing of the rest.

     The previous attempt here used `:empty`, which does not match those
     divs: `&nbsp;` is a TEXT NODE, so the div is not empty. It silently did
     nothing, which is why the gaps survived.

     `:not(:has(*))` means "a div with no ELEMENT children", which is
     exactly what a spacer is and exactly what a module is not. On an engine
     without :has() the whole rule is dropped and the spacers simply stay —
     the old look, never a broken one.

     The column then owns the rhythm with a flex `gap`, and the children's
     own margins are zeroed so there is one number rather than a sum. */
  .fn-ui .fn-home-row > .pd-rt-none {
    display: flex;
    flex-direction: column;
    gap: var(--fn-space-5);
  }

  /* The ad slot is excluded BY NAME. If a campaign is not running the slot
     has no element children, so it would match the spacer rule and be
     hidden — collapsing a live advertising position to save 20px, which is
     not a trade this stylesheet gets to make. Its reserved height stays. */
  .fn-ui .fn-home-row > .pd-rt-none > div:not(:has(*)):not(.index_bnrid3) {
    display: none;
  }

  /* Margins off, everywhere the modules bring their own: the gap is the
     only spacing left, so the rhythm cannot drift again by someone adding
     a margin to one module. */
  .fn-ui .fn-home-row > .pd-rt-none > * {
    margin-top: 0;
    margin-bottom: 0;
  }

  .fn-ui .fn-home-row > .pd-rt-none .fn-data-module,
  .fn-ui .fn-home-row > .pd-rt-none .recently-viewed-module,
  .fn-ui .fn-home-row > .pd-rt-none .rv-funds-module,
  .fn-ui .fn-home-row > .pd-rt-none .fn-magazine-slot,
  .fn-ui .fn-home-row > .pd-rt-none .fn-magazine {
    margin-top: 0;
    margin-bottom: 0;
  }


  /* ====================================================== 6. THE TABLES */

  /* Tables stay tables: no stripes, no pills, no rounded cells. The
     container is rounded and the table inside it is not, which is the
     point — a financial table reads by alignment, and anything that softens
     a row edge costs that.

     The two jobs here are to stop the table's own chrome from painting over
     the container's corners, and to keep the header legible now that there
     is an edge above it. */
  .fn-ui .fn-data-module .fn-data-table,
  .fn-ui .fn-board .fn-board__table {
    border-radius: 0;
  }

  .fn-ui .fn-data-module .fn-data-table thead th {
    background-clip: padding-box;
  }

  /* The last row's bottom border sat on the container's rounded corner and
     drew a straight line across it. */
  .fn-ui .fn-data-module .fn-data-table tbody tr:last-child > td {
    border-bottom: 0;
  }
}


/* The wide run (24-wide.css) puts a feed across the full page measure. Its
   cards are the same cards; they just have more room, so nothing here
   changes for them except that the lead's radius is already the large one. */
@media (min-width: 1600px) {
  .fn-ui {
    /* A wider window shows more of the wallpaper, so the tile grows with it
       rather than repeating more often. */
    --fn-canvas-pattern-size-desktop: 300px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fn-ui .fn-feed__link,
  .fn-ui .fn-chrono__link,
  .fn-ui .fn-data-module,
  .fn-ui .fn-board {
    transition: none;
  }

  .fn-ui .fn-feed__link:active,
  .fn-ui .fn-chrono__link:active {
    transform: none;
  }
}
