/* =============================================================================
   ShiftHawk — hero chip hover popups
   Self-contained "Swap detail" calendar popups for the three floating hero
   chips (Mirror / Simple / Triple). Prefix: .hcp-
   Tokens come from styles.css (--banana, --lilac, --r-2, --shadow-lg, fonts…).
   The popup card is always a LIGHT "app screen" (dark-on-light) in both themes,
   so we set explicit colors inside the card — never inherit page text color.
   ========================================================================== */

/* ---- Local palette (independent of page theme; the card is always a light
        "app screen", matching the in-app Swap-detail look) ---- */
.hcp-pop {
  --hcp-card: #FFFEF8;            /* cream/white app card */
  --hcp-card-edge: #ECE7D4;
  --hcp-ink: #1E293B;            /* slate month header / dark text */
  --hcp-ink-2: #64748B;          /* muted captions */
  --hcp-grid-line: #EFEAD8;
  --hcp-faded: #FACC15;          /* banana — working-day context tiles */
  --hcp-tileA: #FACC15;          /* banana — participant A solid */
  --hcp-tileA-ink: #7C5E00;
  --hcp-tileA-edge: #D9A800;
  --hcp-tileB: #C4B5FD;          /* lilac — participant B solid */
  --hcp-tileB-ink: #4C3A8C;
  --hcp-tileB-edge: #9F86F0;
  --hcp-tileC: #6EE7B7;          /* mint — participant C (triple) */
  --hcp-tileC-ink: #0F6B4B;
  --hcp-tileC-edge: #34C998;
  --hcp-out: #B8BBC4;            /* out-of-month / faded day numbers */

  position: fixed;               /* positioned in JS relative to viewport */
  z-index: 9999;
  top: 0; left: 0;               /* JS overrides via transform/left/top */
  width: max-content;
  max-width: 340px;
  padding: 0;
  background: var(--hcp-card);
  color: var(--hcp-ink);
  border: 1px solid var(--hcp-card-edge);
  border-radius: 18px;
  box-shadow:
    0 24px 60px rgba(15, 23, 42, .28),
    0 8px 18px rgba(15, 23, 42, .16),
    0 0 0 1px rgba(255, 255, 255, .5) inset;
  font-family: var(--font-display, system-ui, sans-serif);
  opacity: 0;
  transform: translateY(6px) scale(.98);
  transform-origin: center top;
  transition: opacity .16s ease, transform .16s ease;
  pointer-events: none;          /* not interactive until shown */
  -webkit-font-smoothing: antialiased;
}
.hcp-pop.hcp-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
/* wide variant for the two-month Triple grid */
.hcp-pop.hcp-wide { max-width: 520px; }

/* ---- inner card padding ---- */
.hcp-inner { padding: 14px 14px 12px; }

/* ---- header line: swap-type name + refresh glyph ---- */
.hcp-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.hcp-title {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-display, system-ui, sans-serif);
  font-weight: 800; font-size: .96rem; letter-spacing: -.01em;
  color: var(--hcp-ink); line-height: 1.1;
}
.hcp-title .hcp-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--primary, #0891B2);
}
.hcp-refresh {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  background: #F1F5F9; color: #0891B2; border: 1px solid #E2E8F0;
  font-size: 1rem;
}

/* ---- months wrapper (Triple shows two) ---- */
.hcp-months { display: flex; gap: 14px; align-items: stretch; }
.hcp-months.hcp-stack { flex-direction: column; }

/* ---- one month block ---- */
.hcp-month { flex: 1 1 0; min-width: 0; }
.hcp-month-label {
  font-family: var(--font-display, system-ui, sans-serif);
  font-weight: 700; font-size: .82rem; color: var(--hcp-ink);
  margin: 0 2px 6px; letter-spacing: -.01em;
}

/* ---- weekday header row ---- */
.hcp-dow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; margin-bottom: 4px;
}
.hcp-dow span {
  text-align: center; font-family: var(--font-mono, monospace);
  font-size: .58rem; font-weight: 700; color: var(--hcp-ink-2);
  text-transform: uppercase; letter-spacing: .04em;
}

/* ---- day grid ---- */
.hcp-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; position: relative;
}
.hcp-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-family: var(--font-mono, monospace);
  font-size: .66rem; font-weight: 600;
  color: var(--hcp-ink);
  background: transparent;
  border: 1px solid transparent;
  min-width: 0;
}
.hcp-cell.hcp-empty { background: transparent; border-color: transparent; }
.hcp-cell.hcp-out { color: var(--hcp-out); opacity: .55; }

/* faded working-day context tiles (banana, low opacity) */
.hcp-cell.hcp-work {
  background: rgba(250, 204, 21, .35);
  color: #7a6312;
}

/* solid participant tiles being traded */
.hcp-cell.hcp-tile {
  font-weight: 800;
  border-width: 1.5px;
  box-shadow: 0 1px 2px rgba(15,23,42,.12);
}
.hcp-cell.hcp-a { background: var(--hcp-tileA); color: var(--hcp-tileA-ink); border-color: var(--hcp-tileA-edge); }
.hcp-cell.hcp-b { background: var(--hcp-tileB); color: var(--hcp-tileB-ink); border-color: var(--hcp-tileB-edge); }
.hcp-cell.hcp-c { background: var(--hcp-tileC); color: var(--hcp-tileC-ink); border-color: var(--hcp-tileC-edge); }

/* the "21 / AT" stacked label inside a trading tile */
.hcp-tilelab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1.02; gap: 0;
}
.hcp-tilelab .hcp-day { font-size: .66rem; }
.hcp-tilelab .hcp-ini { font-size: .5rem; font-weight: 700; opacity: .85; letter-spacing: .02em; }

/* tiny up/down chevron marker corner of a trading tile */
.hcp-cell .hcp-chev {
  position: absolute; top: 1px; right: 2px;
  font-size: .6rem; line-height: 1; opacity: .9;
}

/* ---- SVG arrow overlay (sits above the grid, ignores pointer) ---- */
.hcp-arrows {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; overflow: visible;
}
.hcp-arrow-path {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hcp-arrow-a { stroke: var(--hcp-tileA-edge); }
.hcp-arrow-b { stroke: var(--hcp-tileB-edge); }
.hcp-arrow-c { stroke: var(--hcp-tileC-edge); }

/* travelling dash animation along the trade paths */
.hcp-arrow-path.hcp-animate {
  stroke-dasharray: 7 9;
  animation: hcp-flow 1.5s linear infinite;
}
@keyframes hcp-flow { to { stroke-dashoffset: -32; } }

/* arrowheads */
.hcp-arrows marker path { stroke: none; }

/* cross-month connector (triple) — drawn in its own full-popup overlay */
.hcp-cross {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; overflow: visible;
}

/* ---- legend caption (wraps cleanly, stays inside card) ---- */
.hcp-legend {
  margin-top: 10px;
  font-family: var(--font-display, system-ui, sans-serif);
  font-size: .64rem; line-height: 1.45;
  color: var(--hcp-ink-2);
  overflow-wrap: anywhere;
  word-break: normal;
}
.hcp-legend b { color: var(--hcp-ink); font-weight: 700; }

/* ---- pointer arrow toward the chip (optional flourish) ---- */
.hcp-beak {
  position: absolute;
  width: 14px; height: 14px;
  background: var(--hcp-card);
  border: 1px solid var(--hcp-card-edge);
  transform: rotate(45deg);
  z-index: -1;
}

/* ---- reduced motion: arrows static, no popup motion ---- */
@media (prefers-reduced-motion: reduce) {
  .hcp-pop { transition: opacity .12s linear; transform: none; }
  .hcp-pop.hcp-open { transform: none; }
  .hcp-arrow-path.hcp-animate { animation: none; stroke-dasharray: none; }
}

/* ---- mobile / narrow: chips become inline labels; popups disabled ---- */
@media (max-width: 920px) {
  .hcp-pop { display: none !important; }
}
