/* ==========================================================================
   Mobile sticky header (compact) — site-local stylesheet
   --------------------------------------------------------------------------
   Loaded via ResolveUrl("~/...") so it always comes from the same host as the
   page (temp1), NOT from cndjscss/CDN. The sticky JS is a NEW file; serving it
   (and these rules) through editableFileUrl/CDN caused a silent 404 on iPhone
   while the rest of the redesigned header (already on CDN) still looked fine.
   ========================================================================== */

/* Compact sticky mark — hidden until scrolled state.
   Never let the round mark sit on top of the wordmark. */
.fn-ui .fn-logo-mark,
.fn-ui .navbar-brand .fn-logo-mark,
.fn-ui .fn-navbar .navbar-brand img.fn-logo-mark {
  display: none !important;
}

/* Sentinel for IntersectionObserver (iOS-reliable compact trigger). */
.fn-ui .fn-header-sticky-sentinel {
  display: block;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
}

@media (max-width: 767px) {
  /* Breath under the pinned bar. The bar's own height is measured
     (--fn-sticky-offset); this is only the gap beneath it. When the
     floating home/top tools are on screen they sit below that bar
     (8px gap + 40px button) and the jump must clear them too.
     The numbers are the page-chrome tokens (01-tokens.css). */
  :root {
    --fn-anchor-breath: var(--fn-chrome-breath);
    --fn-scroll-tools-clearance: 0px;
  }

  html {
    scroll-padding-top: calc(var(--fn-chrome-bar) + var(--fn-scroll-tools-clearance) + var(--fn-anchor-breath));
  }

  html:has(body.fn-scrolled) {
    --fn-scroll-tools-clearance: var(--fn-chrome-tools-bottom);
  }

  /* The offset probe adds the compact class for one measurement. That must
     not play the drop-in animation. */
  .fn-ui.fn-header--measuring .fn-navband,
  body.fn-ui.fn-header--measuring > .fn-navband {
    animation: none !important;
    -webkit-animation: none !important;
  }

  /* Matches whether navband is still in .header or portaled under body. */
  /* The compact bar is the SAME bar, pinned — so it takes the same surface
     token as the in-flow nav band (--fn-nav-bg) rather than a colour of its
     own. It previously read --fn-bg-canvas, so on the ירקרק wallpaper a
     rectangle of plain background slid over a textured one, and in Light it
     was a different white from the header it replaced. The only thing the
     pinned state adds is the hairline and the lift that say it is floating. */
  .fn-ui.fn-header--compact .fn-navband,
  body.fn-ui.fn-header--compact > .fn-navband {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: var(--fn-z-header, 1030);
    background: var(--fn-nav-bg, #fff);
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    border-top: 0;
    border-bottom: 1px solid var(--fn-header-border, var(--fn-border));
    box-shadow: 0 2px 8px rgba(22, 28, 23, 0.06);
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-animation: fn-header-drop 190ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
    animation: fn-header-drop 190ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
  }

  /* Fading the last third of the slide removes the hard edge that made the
     bar look like it was being stamped onto the page rather than arriving. */
  @-webkit-keyframes fn-header-drop {
    from { -webkit-transform: translate3d(0, -100%, 0); opacity: 0; }
    60%  { opacity: 1; }
    to   { -webkit-transform: translate3d(0, 0, 0); opacity: 1; }
  }

  @keyframes fn-header-drop {
    from { transform: translate3d(0, -100%, 0); opacity: 0; }
    60%  { opacity: 1; }
    to   { transform: translate3d(0, 0, 0); opacity: 1; }
  }

  /* Dark gets no drop shadow — a shadow on near-black is a smudge, and the
     hairline above already does the separating. The surface itself needs no
     restatement: --fn-nav-bg is a theme token. */
  :root[data-fn-theme="dark"] .fn-ui.fn-header--compact .fn-navband,
  :root[data-fn-theme="dark"] body.fn-ui.fn-header--compact > .fn-navband {
    box-shadow: none;
  }

  .fn-ui .fn-header-spacer {
    display: none;
  }

  /* Height is set inline by fn-header-sticky.js to the full in-flow bar. */
  .fn-ui.fn-header--compact .fn-header-spacer {
    display: block;
    width: 100%;
    pointer-events: none;
  }

  .fn-ui.fn-header--compact .fn-navbar {
    min-height: 48px;
    padding: 4px 0;
  }

  .fn-ui.fn-header--compact .fn-navbar .navbar-header {
    height: 48px;
    /* The in-flow bar shifts the wordmark 15px into the looser gap.
       The compact mark is a 34px circle and belongs on the true centre. */
    transform: translateX(-50%);
  }

  .fn-ui.fn-header--compact .fn-navbar .navbar-brand {
    width: 34px;
    height: 34px;
    overflow: visible;
    border-radius: 0;
    display: block;
  }

  .fn-ui.fn-header--compact .fn-navbar .navbar-brand img.fn-logo--light,
  .fn-ui.fn-header--compact .fn-navbar .navbar-brand img.fn-logo--dark {
    display: none !important;
  }

  /* The wordmark is display:none in compact and the round mark takes its
     place, which is a swap no transition can reach — the element appears
     already at its final state. A short entrance animation is the one thing
     that CAN run on an element that has just come into the layout, so the
     mark arrives instead of being stamped. 180ms, opacity and scale only,
     and the bar's height is unaffected either way, so nothing waits on it. */
  .fn-ui.fn-header--compact .fn-navbar .navbar-brand .fn-logo-mark,
  .fn-ui.fn-header--compact .fn-navbar .navbar-brand img.fn-logo-mark {
    display: block !important;
    width: 34px;
    height: 34px;
    max-width: 34px;
    max-height: 34px;
    margin: 0 auto;
    transform: none;
    border-radius: 50%;
    animation: fn-mark-in 180ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
  }

  @keyframes fn-mark-in {
    from { opacity: 0; transform: scale(0.82); }
    to   { opacity: 1; transform: none; }
  }

  .fn-ui.fn-header--compact .fn-navbar .fn-bar-end .fn-fund-filter-open,
  .fn-ui.fn-header--compact .fn-navbar .fn-bar-end .fn-theme-toggle--bar,
  .fn-ui.fn-header--compact .fn-navbar .fn-bar-end .mobile-search-toggle,
  .fn-ui.fn-header--compact .fn-navbar .navbar-toggle {
    height: 40px;
    min-height: 40px;
  }

  .fn-ui.fn-header--compact .fn-navbar > .mobile-search-row:not(.mobile-search-row--collapsed) {
    margin-top: 2px;
    padding-bottom: 4px;
  }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  .fn-ui.fn-header--compact .fn-navband,
  body.fn-ui.fn-header--compact > .fn-navband,
  .fn-ui.fn-header--compact .fn-navbar .navbar-brand .fn-logo-mark,
  .fn-ui.fn-header--compact .fn-navbar .navbar-brand img.fn-logo-mark {
    -webkit-animation: none;
    animation: none;
  }
}

/* Home + back-to-top: appear after the page has been scrolled. Live outside
   .header so position:fixed is not trapped in a containing block. */
.fn-ui .fn-scroll-tools {
  position: fixed;
  top: var(--fn-chrome-tools-inset);
  inset-inline-start: var(--fn-chrome-tools-inset);
  z-index: calc(var(--fn-z-header, 1030) + 2);
  display: none;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.fn-ui.fn-scrolled .fn-scroll-tools {
  display: flex;
}

.fn-ui.fn-nav-open .fn-scroll-tools {
  display: none !important;
}

.fn-ui .fn-scroll-tools__btn {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--fn-chrome-tools-size);
  height: var(--fn-chrome-tools-size);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: var(--fn-bubble-bg, var(--fn-bg-surface));
  background-clip: padding-box;
  box-shadow:
    inset 0 0 0 1px var(--fn-bubble-border, var(--fn-border)),
    var(--fn-shadow-sm, 0 1px 2px rgba(22, 28, 23, 0.06));
  color: var(--fn-text-2);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.fn-ui .fn-scroll-tools__btn:hover,
.fn-ui .fn-scroll-tools__btn:focus {
  color: var(--fn-text-1);
  outline: none;
}

.fn-ui .fn-scroll-tools__btn:focus-visible {
  outline: var(--fn-focus-width, 2px) solid var(--fn-focus);
  outline-offset: 2px;
}

.fn-ui .fn-scroll-tools__btn:active {
  background-color: var(--fn-bubble-bg-press, var(--fn-bg-sunken));
}

.fn-ui .fn-scroll-tools__ico {
  display: block;
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}

.fn-ui .fn-scroll-tools__ico--home {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 3 2 12h3v8h6v-6h2v6h6v-8h3L12 3z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 3 2 12h3v8h6v-6h2v6h6v-8h3L12 3z'/%3E%3C/svg%3E");
}

.fn-ui .fn-scroll-tools__ico--top {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M11 20V7.8l-5.6 5.6L4 12l8-8 8 8-1.4 1.4L13 7.8V20h-2z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M11 20V7.8l-5.6 5.6L4 12l8-8 8 8-1.4 1.4L13 7.8V20h-2z'/%3E%3C/svg%3E");
}

@media (max-width: 767px) {
  .fn-ui.fn-header--compact .fn-scroll-tools {
    /* --fn-chrome-bar is the same measured height as --fn-compact-header-h
       (fn-header-sticky.js publishes both at once). */
    top: calc(var(--fn-chrome-bar) + var(--fn-chrome-tools-top));
  }
}

@media print {
  .fn-ui .fn-scroll-tools {
    display: none !important;
  }
}
