/**
 * Shared lender-page polish — Phase C of /root/COMAU_AWARD_DESIGN_PLAN.md.
 *
 * Loaded only on /lenders/* routes (motion.php detects URI). Operates on
 * the existing lender-page markup without editing per-lender files:
 *   - .breadcrumb     — first nav inside .lender-wrap
 *   - .versus-row     — the 12 round cards
 *   - .four-way       — 4-cell comparison grids inside each round
 *   - .lender-card    — directory cards on /lenders/
 *
 * Choreography starting states (GSAP timelines run from lender.js):
 *   .versus-row       — translate-y on viewport entry
 *   .lender-progress  — sticky pill, ticks up as rounds pass
 *   .breadcrumb       — auto-hides on scroll-down, shows on scroll-up
 *   .four-way mobile  — 2×2 grid with tap-highlight cell
 *
 * IMPORTANT: per-lender pages each declare their own brand colour via
 * a `:root` block (--anz, --nab, --cba etc.). This file uses only
 * site-level tokens (--sage-600, --paper, --ink) so it doesn't fight
 * the per-page colour identity.
 */

/* ===== Sticky breadcrumb =====
   Sits below the (also sticky) site-header. Header height ranges from
   ~52px (mobile) to ~62px (desktop) depending on viewport — `top` value
   uses a CSS variable so per-viewport JS can override at runtime if the
   visual gap drifts. Default 56 covers most desktop renders. */
.breadcrumb {
  position: sticky;
  top: var(--lender-bc-top, 56px);
  z-index: 8;
  background: var(--paper);
  padding: 8px 0;
  margin-left: -8px;
  margin-right: -8px;
  padding-left: 8px;
  padding-right: 8px;
  transition: transform 280ms var(--ease-default), opacity 200ms var(--ease-default);
  will-change: transform, opacity;
}
@media (max-width: 540px) {
  .breadcrumb { top: var(--lender-bc-top, 50px); }
}
.breadcrumb[data-hide="1"] {
  transform: translateY(-130%);
  opacity: 0;
}

/* ===== Round reveal — starting state for GSAP ===== */
.versus-row[data-reveal="pending"] {
  opacity: 0;
  transform: translateY(18px);
}

/* ===== Round-progress sticky pill ===== */
.lender-progress {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 12;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 10px 18px;
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  box-shadow: 0 8px 24px rgba(14, 20, 17, 0.18);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 240ms var(--ease-default), transform 240ms var(--ease-default);
  pointer-events: none;          /* informational, not interactive */
}
.lender-progress[data-active="1"] {
  opacity: 1;
  transform: translateY(0);
}
.lender-progress .progress-count {
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--sage-200);
}
.lender-progress .progress-track {
  width: 60px;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
}
.lender-progress .progress-fill {
  height: 100%;
  background: var(--sage-200);
  width: 0%;
  transition: width 360ms var(--ease-default);
}

@media (max-width: 600px) {
  .lender-progress {
    bottom: 14px;
    right: 14px;
    padding: 8px 14px;
    font-size: 0.8rem;
  }
  .lender-progress .progress-track { width: 48px; }
}

/* ===== Mobile 4-cell → 2×2 grid + tap-to-compare ===== */
@media (max-width: 540px) {
  .four-way {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .four-way .cell {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition:
      background 180ms var(--ease-default),
      border-color 180ms var(--ease-default),
      transform 120ms var(--ease-default);
  }
  /* Tap-to-compare: the cell the user has tapped becomes the focus.
     Sibling cells dim slightly so the diff is obvious at a glance. */
  .four-way[data-focus] .cell:not([data-focus="1"]) {
    opacity: 0.55;
  }
  .four-way .cell[data-focus="1"] {
    border-color: var(--sage-600);
    background: var(--sage-50);
    transform: translateY(-1px);
  }
  .four-way .cell[data-focus="1"] .val {
    color: var(--sage-800);
  }
  .four-way .cell[data-focus="1"] .lbl::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--sage-600);
    vertical-align: middle;
  }
}

/* ===== Lender-directory card weight animate hint =====
   Cards on /lenders/ get the variable-font hover. The actual transition
   is wired in JS (Motion.weightAnimate) but we lock the cursor + remove
   default link decoration here so the affordance reads. */
.lender-card[data-weight-wired="1"] {
  cursor: pointer;
}
