/* ============================================================
   Master filter (top-of-dashboard, the only one)
   ============================================================ */
.masterFilter {
  position: relative;
  margin: 0 64px;
  padding: 32px 0 0;
  /* sit just under the hero, before panel 01 */
}
.masterFilter__inner {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 32px;
  padding: 26px 28px 22px;
  background: #FAFAF8;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 1px 0 rgba(31,31,29,0.02), 0 12px 32px -28px rgba(31,31,29,0.18);
  transition: border-color .3s, box-shadow .3s;
}
.masterFilter--filtered .masterFilter__inner {
  border-color: rgba(0,174,213,0.45);
  box-shadow: 0 0 0 1px rgba(0,174,213,0.18) inset, 0 12px 32px -24px rgba(0,137,168,0.30);
}
.masterFilter__lead { display: flex; flex-direction: column; gap: 6px; }
.masterFilter__eyebrow {
  font: 500 10px var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.masterFilter__h {
  font: 500 22px/1.25 var(--serif);
  color: var(--ink);
  letter-spacing: -0.01em;
  max-width: 540px;
}
.masterFilter__h em {
  font-weight: 500;
  color: var(--sbf-cyan-deep);
}

/* Reuse fstrip styling for the master controls but tighten spacing */
.masterFilter__controls.fstrip {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  gap: 18px;
  justify-content: flex-end;
}
.masterFilter__controls .fstrip__cap { display: none; }

.masterFilter__hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-left: 28px;
  font: 500 11px var(--mono);
  letter-spacing: 0.04em;
  color: var(--ink-mute);
}
.masterFilter__hintIcon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,174,213,0.12);
  color: var(--sbf-cyan-deep);
  animation: hintPulse 2.4s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { transform: translateY(0); opacity: 0.85; }
  50%      { transform: translateY(2px); opacity: 1; }
}

@media (max-width: 900px) {
  .masterFilter { margin: 0 24px; }
  .masterFilter__inner {
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: start;
  }
  .masterFilter__controls.fstrip { justify-content: flex-start; }
  .masterFilter__hint { padding-left: 0; }
}

/* ============================================================
   Floating folded filter — pill (collapsed) + panel (unfolded)
   ============================================================ */
.ffilter {
  position: fixed;
  top: 92px;          /* fallback when not docked */
  right: 28px;
  z-index: 60;
  pointer-events: none;
  /* hidden by default — only shown after master scrolls past */
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  transform-origin: top right;
  transition:
    opacity .42s cubic-bezier(.2,.7,.2,1),
    transform .55s cubic-bezier(.2,.7,.2,1);
}
.ffilter--shown {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
/* When docked into the nav banner's right-side slot — sits inline with logo */
.nav__filterSlot .ffilter {
  position: relative;
  top: auto;
  right: auto;
  z-index: 1;
  /* Always "shown" when docked; the slot itself fades with the nav */
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
/* Panel anchors to the bottom edge of the pill — keep paper-fold reveal */
.nav__filterSlot .ffilter__panel {
  right: 0;
  left: auto;
}

/* ---------- The folded pill (icon + summary) ---------- */
.ffilter__pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px 9px 12px;
  background: rgba(255,255,255,0.94);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6) inset,
    0 8px 24px -12px rgba(31,31,29,0.22),
    0 2px 6px -2px rgba(31,31,29,0.10);
  font: 500 12px var(--sans);
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  transition:
    transform .35s cubic-bezier(.2,.7,.2,1),
    border-color .25s, box-shadow .25s, padding .35s, background .25s;
}
.ffilter__pill:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6) inset,
    0 14px 30px -14px rgba(31,31,29,0.30),
    0 4px 8px -2px rgba(31,31,29,0.10);
}
.ffilter--open .ffilter__pill {
  /* When open, the pill itself "lifts" slightly to act as the handle */
  border-color: var(--sbf-cyan);
  background: #fff;
  box-shadow:
    0 0 0 1px rgba(0,174,213,0.20) inset,
    0 14px 30px -14px rgba(0,137,168,0.35),
    0 4px 8px -2px rgba(31,31,29,0.10);
}
.ffilter__pill--filtered {
  border-color: rgba(0,174,213,0.55);
}

/* The little fold marks rendered behind the icon — visually says "folded paper" */
.ffilter__pillFolds {
  display: none;
}
.ffilter__fold {
  width: 14px;
  height: 6px;
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(245,245,242,0.92));
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 3px 3px 0 0;
  transform-origin: bottom center;
  transition: transform .45s cubic-bezier(.4,.05,.2,1.1);
}
.ffilter__fold--1 { transform: rotateX(0deg) translateY(0); }
.ffilter__fold--2 { background: linear-gradient(180deg, rgba(250,250,247,0.95), rgba(238,238,233,0.92)); }
.ffilter__fold--3 { background: linear-gradient(180deg, rgba(244,244,240,0.95), rgba(230,230,224,0.92)); }
.ffilter--open .ffilter__fold--1 { transform: rotateX(-180deg) translateY(-3px); }
.ffilter--open .ffilter__fold--2 { transform: rotateX(-180deg) translateY(-3px); transition-delay: .04s; }
.ffilter--open .ffilter__fold--3 { transform: rotateX(-180deg) translateY(-3px); transition-delay: .08s; }

.ffilter__pillIcon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(0,174,213,0.10);
  color: var(--sbf-cyan-deep);
  transition: transform .35s cubic-bezier(.2,.7,.2,1), background .25s;
}
.ffilter--open .ffilter__pillIcon {
  background: var(--sbf-cyan);
  color: white;
  transform: rotate(-90deg);
}

.ffilter__pillBody {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.1;
  min-width: 0;
}
.ffilter__pillCap {
  font: 500 9px var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.ffilter__pillState {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ffilter__pillCaret {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  color: var(--ink-mute);
  transition: transform .35s cubic-bezier(.2,.7,.2,1);
}
.ffilter--open .ffilter__pillCaret { transform: rotate(-180deg); color: var(--sbf-cyan-deep); }

/* ---------- The unfolded panel (paper-fold reveal) ---------- */
.ffilter__panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 56px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6) inset,
    0 30px 80px -30px rgba(31,31,29,0.32),
    0 6px 16px -6px rgba(31,31,29,0.10);
  overflow: hidden;

  /* Fold-down origin from the top edge (paper unfolding) */
  transform-origin: top center;
  transform: perspective(1200px) rotateX(-92deg) translateY(-4px);
  opacity: 0;
  pointer-events: none;
  transition:
    transform .55s cubic-bezier(.2,.7,.2,1.05),
    opacity   .35s ease;
}
.ffilter--open .ffilter__panel {
  transform: perspective(1200px) rotateX(0deg) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Subtle "crease" line at the top of the panel — sells the fold */
.ffilter__panel::before {
  content: "";
  position: absolute;
  top: -1px; left: 14px; right: 14px;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(31,31,29,0.10) 20%,
    rgba(31,31,29,0.18) 50%,
    rgba(31,31,29,0.10) 80%,
    transparent 100%
  );
  border-radius: 2px;
  pointer-events: none;
}
/* Connector tab pointing up to the pill */
.ffilter__panel::after {
  content: "";
  position: absolute;
  top: -7px;
  right: 38px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  transform: rotate(45deg);
  border-radius: 2px 0 0 0;
}

.ffilter__panelTop {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px 16px;
  background: #FAFAF8;
  border-bottom: 1px solid var(--line);
}
.ffilter__panelTitle { display: flex; flex-direction: column; gap: 6px; }
.ffilter__panelEyebrow {
  font: 600 15px var(--sans);
  color: var(--ink);
  letter-spacing: -0.01em;
}
.ffilter__panelHint {
  font: 500 12px var(--sans);
  color: var(--ink-mute);
  letter-spacing: 0;
  text-transform: none;
}
.ffilter__close {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .18s;
  flex-shrink: 0;
}
.ffilter__close:hover { background: var(--ink); color: white; border-color: var(--ink); }

/* Override fstrip styles entirely for the panel — render as labelled rows */
.ffilter__controls.fstrip {
  margin: 0;
  padding: 4px 28px 16px;
  background: transparent;
  border: none;
  border-radius: 0;
  gap: 0;
  flex-direction: column;
  align-items: stretch;
}
.ffilter__controls.fstrip > .fstrip__cap,
.ffilter__controls .fstrip__cap {
  display: none !important; /* the panel header already says "Filter the data" */
}
.ffilter__controls .fstrip__sep { display: none; }
.ffilter__controls .fstrip__group {
  width: 100%;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 12px 0;
  position: relative;
}
.ffilter__controls .fstrip__group:last-of-type { border-bottom: none; }
.ffilter__controls .fstrip__group::before {
  content: attr(data-label);
  font: 600 10px var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.ffilter__controls .fstrip__chips { width: auto; gap: 6px; align-self: flex-start; }
.ffilter__controls .fstrip__chips .chip {
  flex: 0 0 auto;
  text-align: center;
  padding: 9px 16px;
  font-size: 12px;
  border-radius: 8px;
}

.ffilter__panelFoot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  border-top: 1px solid var(--line);
  background: #FAFAF8;
}
.ffilter__reset, .ffilter__jump {
  background: none;
  border: none;
  font: 500 12px var(--sans);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: color .18s, background .18s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ffilter__reset:hover { color: var(--sbf-red-deep); background: rgba(165,12,32,0.08); }
.ffilter__jump:hover  { color: var(--sbf-cyan-deep); background: rgba(0,174,213,0.08); }

/* Mobile — pill drops to bottom-right, panel anchors above it */
@media (max-width: 720px) {
  .ffilter {
    top: auto;
    bottom: 20px;
    right: 16px;
    transform-origin: bottom right;
  }
  .ffilter__pillBody { display: none; }
  .ffilter__pill { padding: 10px 12px; }
  .ffilter__panel {
    position: absolute;
    top: auto;
    bottom: calc(100% + 10px);
    right: 0;
    width: min(360px, calc(100vw - 32px));
    transform-origin: bottom center;
    transform: perspective(1200px) rotateX(92deg) translateY(4px);
  }
  .ffilter--open .ffilter__panel {
    transform: perspective(1200px) rotateX(0deg) translateY(0);
  }
  .ffilter__panel::before { top: auto; bottom: -1px; }
  .ffilter__panel::after {
    top: auto;
    bottom: -7px;
    border-top: none;
    border-left: none;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-radius: 0 0 2px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ffilter, .ffilter__pill, .ffilter__pillIcon, .ffilter__pillCaret,
  .ffilter__panel, .ffilter__fold, .masterFilter__hintIcon {
    transition-duration: 0.15s !important;
    animation: none !important;
  }
  .ffilter__panel { transform: none; }
}


