/* =============================================================================
   ShiftHawk — Buddy match section (vanilla CSS, no dependencies)
   The "ForeSIGHT finds shifts that put you both on the same day" pitch.
   Shares the visual language of the Team-invite stage (team-invite.css):
   a .stage card with a mono caption, an animation body, and a .stage-foot
   beat. Pairs with assets/js/buddy-match.js, which plays a scroll-triggered
   sequence (IntersectionObserver) and serves a static composed state under
   prefers-reduced-motion. Reuses the design tokens from styles.css.
   ========================================================================== */

/* ---- Section frame ---------------------------------------------------------- */
.buddy-section { position: relative; overflow: hidden; }
.buddy-section .container { position: relative; z-index: 1; }

/* faint pink wash low-left — a warm counterpart to the team-section cyan glow */
.buddy-glow {
  position: absolute; z-index: 0; pointer-events: none;
  width: 520px; height: 520px; left: -160px; bottom: -160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(244,114,182,.10), transparent 70%);
  filter: blur(30px);
}
html[data-theme="dark"] .buddy-glow { background: radial-gradient(circle, rgba(244,114,182,.12), transparent 70%); }

/* ---- Two-up: copy (left) + animation stage (right) -------------------------- */
.buddy-grid {
  display: grid; grid-template-columns: 0.92fr 1.08fr; gap: var(--s-8);
  align-items: center;
}
@media (max-width: 980px) { .buddy-grid { grid-template-columns: 1fr; gap: var(--s-7); } }
.buddy-grid > div { min-width: 0; }

.buddy-lede { font-size: 1.18rem; color: var(--text-2); }

/* numbered story — three short beats, matches .team-steps look */
.buddy-steps { list-style: none; padding: 0; margin: var(--s-5) 0 0; display: grid; gap: var(--s-4); }
.buddy-steps li { display: grid; grid-template-columns: 34px 1fr; gap: var(--s-3); align-items: start; }
.buddy-steps .bs-num {
  width: 34px; height: 34px; border-radius: var(--r-2); flex: none;
  display: grid; place-items: center; font-family: var(--font-mono); font-weight: 700; font-size: .95rem;
  background: var(--primary-soft); color: var(--primary-deep); border: 1px solid var(--primary-tint);
}
.buddy-steps li p { margin: 0; font-size: .98rem; color: var(--text-2); }
.buddy-steps li strong { color: var(--text-1); }

/* a single pill calling out the Pro lookout that powers it */
.buddy-perks { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-6); }

/* ---- Right column: the animation stage (reuses .team-stage conventions) ----- */
.buddy-stage {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-4); box-shadow: var(--shadow-md);
  padding: var(--s-6) var(--s-5) var(--s-5);
  min-height: 420px;
  display: grid; grid-template-rows: auto 1fr auto;
  gap: var(--s-4);
  overflow: hidden;
}

.buddy-stage .stage-body { display: grid; place-items: center; }

/* the two people + their two calendars converging on one shared day */
.buddy-net {
  position: relative; width: 100%; max-width: 420px; margin: 0 auto; align-self: center;
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4) var(--s-3);
  align-items: start;
}

/* the two avatars sit above their own calendar */
.buddy-person {
  grid-row: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.buddy-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.buddy-avatar i { font-size: 1.35rem; }
.buddy-person.is-you   .buddy-avatar { border-color: var(--primary); color: var(--primary-deep); background: var(--primary-soft); }
.buddy-person.is-buddy .buddy-avatar { border-color: var(--pink); color: var(--pink); background: rgba(244,114,182,.10); }
.buddy-name {
  font-family: var(--font-mono); font-size: .68rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3);
}

/* each mini calendar — a small grid of day cells */
.buddy-cal {
  grid-row: 2; align-self: start;
  border-radius: var(--r-2); padding: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
}
html[data-theme="dark"] .buddy-cal { background: rgba(255,255,255,.04); }
.buddy-cal-head {
  font-family: var(--font-mono); font-size: .52rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3); padding: 0 1px 5px;
}
.buddy-cal-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.bc-cell {
  aspect-ratio: 1 / 1; border-radius: var(--r-1);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: .54rem; font-weight: 600;
  color: var(--text-3);
  background: var(--surface); border: 1px solid var(--border);
}
html[data-theme="dark"] .bc-cell { background: var(--surface-2); }
/* an "off"/free day — soft, available */
.bc-cell.is-free { color: var(--text-2); }
/* the shared target day — the cell ForeSIGHT lands you both on */
.bc-cell.is-target {
  color: var(--text-1); font-weight: 700;
  border-color: var(--border-strong);
}

/* the connector beam that links the two target cells once they match */
.buddy-beam {
  grid-row: 2; grid-column: 1 / -1; position: relative;
  height: 0; pointer-events: none; z-index: 2;
}
/* a center "match" badge that pops over the beam */
.buddy-spark {
  position: absolute; left: 50%; top: 0; transform: translate(-50%, -50%) scale(.4);
  z-index: 5; opacity: 0;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-display); font-weight: 700; font-size: .72rem;
  padding: 5px 11px; border-radius: var(--r-pill);
  background: var(--primary); color: #fff;
  box-shadow: var(--shadow-md); white-space: nowrap;
}
.buddy-spark i { font-size: .95rem; }

.buddy-stage .stage-caption {
  font-family: var(--font-mono); font-size: .74rem; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase; color: var(--text-3);
  display: flex; align-items: center; gap: 8px; min-height: 18px;
}
.buddy-stage .stage-caption i { color: var(--primary); font-size: 1.1rem; }
.buddy-stage .stage-foot {
  font-size: .9rem; color: var(--text-2); text-align: center;
  min-height: 1.4em; line-height: 1.4;
}
.buddy-stage .stage-foot strong { color: var(--text-1); }

/* replay affordance — identical behaviour + 44px tap target as the team stage */
.buddy-stage .stage-replay {
  position: absolute; right: var(--s-3); top: var(--s-3); z-index: 7;
  display: none; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  border-radius: var(--r-pill); padding: 0 var(--s-4); cursor: pointer;
  font-family: var(--font-mono); font-size: .7rem; font-weight: 600;
  min-height: 44px;
}
.buddy-stage .stage-replay:hover { background: var(--surface); color: var(--text-1); border-color: var(--border-strong); }
.buddy-stage .stage-replay.show { display: inline-flex; }
.buddy-stage .stage-replay i { font-size: .95rem; }

/* =============================================================================
   ANIMATION — disabled under prefers-reduced-motion (media query at the
   bottom). The JS adds the .anim-* classes step-by-step; with reduced motion
   the JS drops the stage straight into its composed state instead.
   ========================================================================== */

/* 1. the two people + their calendars settle in */
.buddy-person, .buddy-cal { opacity: 0; transform: translateY(6px); transition: opacity .4s ease, transform .4s ease; }
.buddy-net.anim-in .buddy-person.is-you,  .buddy-net.anim-in .buddy-cal.cal-you  { opacity: 1; transform: none; transition-delay: 0s; }
.buddy-net.anim-in .buddy-person.is-buddy,.buddy-net.anim-in .buddy-cal.cal-buddy{ opacity: 1; transform: none; transition-delay: .14s; }

/* 2. ForeSIGHT scans — each calendar's cells get a quick left-to-right sweep */
.buddy-net.anim-scan .bc-cell { animation: bc-scan .5s ease both; animation-delay: calc(var(--c, 0) * .05s); }
@keyframes bc-scan {
  0%   { background: var(--surface); }
  45%  { background: var(--primary-soft); border-color: var(--primary-tint); }
  100% { background: var(--surface); }
}

/* 3. the two target cells highlight cyan — the same day, found for both */
.bc-cell.is-target { transition: background .4s ease, border-color .4s ease, color .4s ease, box-shadow .4s ease; }
.buddy-net.anim-match .bc-cell.is-target {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8,145,178,.18);
  animation: target-pulse .6s ease both;
}
@keyframes target-pulse {
  0%   { transform: scale(.8); }
  60%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* 4. a connector beam draws between the two matched cells, then the spark pops */
.buddy-beam::before {
  content: ""; position: absolute; left: 12%; right: 12%; top: 0;
  height: 2.5px; border-radius: 2px; transform: translateY(-50%);
  background: linear-gradient(90deg, var(--primary), var(--primary-bright), var(--pink));
  opacity: 0; transform-origin: center; scale: 0 1;
  transition: scale .5s ease, opacity .3s ease;
}
.buddy-net.anim-beam .buddy-beam::before { opacity: 1; scale: 1 1; }
.buddy-net.anim-beam .buddy-spark { animation: spark-pop .55s ease both; animation-delay: .3s; }
@keyframes spark-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  60%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* =============================================================================
   STATIC COMPOSED STATE — applied by the JS (.is-static on the stage/net)
   whenever prefers-reduced-motion is set OR IntersectionObserver is missing.
   ========================================================================== */
.buddy-net.is-static .buddy-person,
.buddy-net.is-static .buddy-cal { opacity: 1; transform: none; transition: none; }
.buddy-net.is-static .bc-cell { animation: none; }
.buddy-net.is-static .bc-cell.is-target {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8,145,178,.18); animation: none;
}
.buddy-net.is-static .buddy-beam::before { opacity: 1; scale: 1 1; transition: none; }
.buddy-net.is-static .buddy-spark { opacity: 1; transform: translate(-50%, -50%) scale(1); animation: none; }

@media (prefers-reduced-motion: reduce) {
  .buddy-person, .buddy-cal { opacity: 1; transform: none; transition: none; }
  .bc-cell { animation: none !important; }
  .bc-cell.is-target {
    background: var(--primary); color: #fff; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(8,145,178,.18); animation: none !important;
  }
  .buddy-beam::before { opacity: 1; scale: 1 1; transition: none; }
  .buddy-spark { opacity: 1; transform: translate(-50%, -50%) scale(1); animation: none !important; }
}
