/* ============================================================
   Watchlist Earnings Release Panel
   Floating, draggable. Collapsed: small chip (flashes when a
   watchlist ticker is reporting today). Expanded: ~20vw wide
   summary of today's results + next-2-days upcoming strip.
   ============================================================ */

.wl-er-panel {
  position: fixed;
  z-index: 1200;
  /* Initial position set by JS — centred horizontally to chart,
     near the top of the chart area. */
  top: 20vh;
  left: 50%;
  transform: translateX(-50%);
  /* drag is applied via JS by swapping transform + left/top */
  font-family: inherit;
  user-select: none;
  pointer-events: auto;
  /* Iter 9i — grey/off-white text colours below routed onto design tokens.
     #e6edf3 / #d7e2ef → var(--text)
     #b9c4d1 / #c8d2df / #8a9bae → var(--text-muted)
     #6c7a8a → var(--text-faint)
     Semantic colours (beat/miss/raised/withdrawn pills, flash/has-results
     chip states, #fff on coloured backgrounds) are kept as-is. */
  color: var(--text);
}

/* ── COLLAPSED (small chip) ── */
.wl-er-panel.is-collapsed {
  width: auto;
}
.wl-er-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px 7px 12px;
  background: rgba(20, 28, 40, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  cursor: grab;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  font-weight: 600;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 200ms ease, transform 160ms ease;
}
.wl-er-chip:hover { background: rgba(26, 36, 52, 0.96); border-color: rgba(255,255,255,0.22); transform: translateY(-1px); }
.wl-er-chip.is-dragging { cursor: grabbing; }
.wl-er-chip-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #485a70;
  flex: 0 0 auto;
}
.wl-er-chip-label {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.wl-er-chip-badge {
  display: none;
  background: #223145;
  color: var(--text);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 2px;
  min-width: 20px;
  text-align: center;
}
.wl-er-chip.has-results .wl-er-chip-badge { display: inline-block; }

/* ──────────────────────────────────────────────────────────
   HIGH-VISIBILITY STATES when earnings exist today
   ────────────────────────────────────────────────────────── */

/* Flashing: reporters today but none have released yet — bright red pulse,
   scaled up, clearly attention-grabbing. */
.wl-er-chip.is-flashing {
  background: linear-gradient(135deg, rgba(255, 91, 91, 0.22), rgba(255, 91, 91, 0.08));
  border-color: rgba(255, 120, 120, 0.75);
  color: #ffd6d6;
  box-shadow:
    0 0 0 1px rgba(255, 91, 91, 0.35),
    0 6px 20px rgba(255, 91, 91, 0.35),
    0 0 26px rgba(255, 91, 91, 0.18);
  animation: wlErChipPulse 1.8s ease-in-out infinite;
}
.wl-er-chip.is-flashing .wl-er-chip-label { color: #ffe0e0; }
.wl-er-chip.is-flashing .wl-er-chip-dot {
  background: #ff5b5b;
  box-shadow: 0 0 0 0 rgba(255, 91, 91, 0.65);
  animation: wlErDotPulse 1.6s ease-in-out infinite;
}
.wl-er-chip.is-flashing .wl-er-chip-badge {
  background: #ff5b5b;
  color: #fff;
  box-shadow: 0 0 12px rgba(255, 91, 91, 0.6);
}
@keyframes wlErChipPulse {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(255, 91, 91, 0.35),
      0 6px 20px rgba(255, 91, 91, 0.35),
      0 0 26px rgba(255, 91, 91, 0.18);
  }
  50% {
    box-shadow:
      0 0 0 2px rgba(255, 91, 91, 0.55),
      0 8px 28px rgba(255, 91, 91, 0.55),
      0 0 42px rgba(255, 91, 91, 0.35);
  }
}
@keyframes wlErDotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 91, 91, 0.55); transform: scale(1); }
  50%      { box-shadow: 0 0 0 8px rgba(255, 91, 91, 0); transform: scale(1.25); }
}

/* Post-release (has-results, not flashing) — green glow, solid, more
   prominent than the neutral chip but not as loud as flashing. */
.wl-er-chip.has-results:not(.is-flashing) {
  background: linear-gradient(135deg, rgba(46, 160, 67, 0.22), rgba(46, 160, 67, 0.08));
  border-color: rgba(46, 200, 90, 0.60);
  color: #d4f4dd;
  box-shadow:
    0 0 0 1px rgba(46, 160, 67, 0.35),
    0 4px 16px rgba(46, 160, 67, 0.30),
    0 0 22px rgba(46, 160, 67, 0.14);
}
.wl-er-chip.has-results:not(.is-flashing) .wl-er-chip-label { color: #d8f5e1; }
.wl-er-chip.has-results:not(.is-flashing) .wl-er-chip-dot {
  background: #2ea043;
  box-shadow: 0 0 10px rgba(46, 200, 90, 0.70);
}
.wl-er-chip.has-results:not(.is-flashing) .wl-er-chip-badge {
  background: #2ea043;
  color: #fff;
  box-shadow: 0 0 8px rgba(46, 200, 90, 0.45);
}

/* Whenever earnings exist today (any state), make the chip visibly larger
   so users notice it. */
.wl-er-chip.is-flashing,
.wl-er-chip.has-results {
  padding: 8px 14px;
  font-size: 13px;
}
.wl-er-chip.is-flashing .wl-er-chip-dot,
.wl-er-chip.has-results .wl-er-chip-dot {
  width: 10px; height: 10px;
}

/* ── EXPANDED (card) ── */
.wl-er-panel.is-expanded .wl-er-chip { display: none; }
.wl-er-card {
  display: none;
  width: 20vw;
  min-width: 280px;
  max-width: 380px;
  max-height: 70vh;
  overflow: hidden;
  background: rgba(18, 25, 37, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;                 /* becomes visible only when parent .is-expanded */
  flex-direction: column;
  font-size: 12px;
}
.wl-er-panel:not(.is-expanded) .wl-er-card { display: none; }

.wl-er-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: grab;
}
.wl-er-card-header.is-dragging { cursor: grabbing; }
.wl-er-card-title {
  font-weight: 600;
  letter-spacing: 0.03em;
  font-size: 12px;
  color: var(--text);
}
.wl-er-card-date {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 2px;
}
.wl-er-card-spacer { flex: 1; }
.wl-er-card-refresh,
.wl-er-card-close {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wl-er-card-refresh:hover,
.wl-er-card-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.wl-er-card-body {
  padding: 6px 0;
  overflow-y: auto;
  flex: 1 1 auto;
}

.wl-er-empty {
  padding: 18px 14px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.wl-er-row {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.wl-er-row:last-child { border-bottom: 0; }

/* Clickable rows open the matching chart on the watchlist page.
   Subtle hover treatment + pointer cursor signal interactivity. The
   .wl-er-pill chips inside still get pointer:default so users don't
   confuse them with a clickable row action. */
.wl-er-row--clickable {
  cursor: pointer;
  transition: background-color 120ms ease;
}
.wl-er-row--clickable:hover,
.wl-er-row--clickable:focus-visible {
  background-color: rgba(255, 255, 255, 0.04);
}
.wl-er-row--clickable:focus-visible {
  outline: 1px solid rgba(80, 160, 255, 0.55);
  outline-offset: -1px;
}
.wl-er-row--clickable .wl-er-pill { cursor: default; }
.wl-er-row-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.wl-er-sym {
  font-weight: 700;
  color: var(--text);
  font-size: 12.5px;
}
.wl-er-name {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
.wl-er-session {
  color: var(--text-muted);
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: auto;
}
.wl-er-row-head .wl-er-session { margin-left: auto; }

.wl-er-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 4px 0;
}
.wl-er-pill {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: #223145;
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.wl-er-pill.beat      { background: rgba(46, 160, 67, 0.18);  border-color: rgba(46, 160, 67, 0.5);  color: #7ee787; }
.wl-er-pill.miss      { background: rgba(248, 81, 73, 0.16);  border-color: rgba(248, 81, 73, 0.5);  color: #ff8b80; }
.wl-er-pill.inline    { background: rgba(128, 128, 128, 0.14); border-color: rgba(180, 180, 180, 0.35); color: #c2cbd4; }
.wl-er-pill.raised    { background: rgba(46, 160, 67, 0.18);  border-color: rgba(46, 160, 67, 0.5);  color: #7ee787; }
.wl-er-pill.reduced   { background: rgba(248, 81, 73, 0.16);  border-color: rgba(248, 81, 73, 0.5);  color: #ff8b80; }
.wl-er-pill.withdrawn { background: rgba(230, 138, 0, 0.18);  border-color: rgba(230, 138, 0, 0.5);  color: #ffb454; }
.wl-er-pill.pending, .wl-er-pill.pre-release, .wl-er-pill.unknown, .wl-er-pill.none {
  color: var(--text-muted);
}

.wl-er-liner {
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.38;
  margin: 4px 0 2px;
}
.wl-er-bullets {
  margin: 4px 0 0;
  padding: 0 0 0 16px;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.38;
}
.wl-er-bullets li { margin-bottom: 2px; }

.wl-er-excerpt {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: italic;
  border-left: 2px solid rgba(255,255,255,0.1);
  padding-left: 6px;
}

.wl-er-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 8px 12px 3px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.wl-er-section-title:first-child { border-top: 0; }

.wl-er-upcoming-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.wl-er-upcoming-row .wl-er-sym { font-size: 11.5px; }
.wl-er-upcoming-row .wl-er-session { font-size: 9.5px; }
.wl-er-upcoming-date {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 10.5px;
}

/* Hidden when Watchlists tab is not active (kept in DOM for drag-pos persistence) */
.wl-er-panel[hidden] { display: none !important; }

/* Hide the earnings pill entirely while the chart is in expanded/modal mode
   (body.wl-chart-modal-open is toggled in dashboard.js expandChartModal/collapseChartModal). */
body.wl-chart-modal-open .wl-er-panel { display: none !important; }

/* Mobile: pin to bottom-right; no free drag (too cramped) */
@media (max-width: 640px) {
  .wl-er-panel {
    top: auto !important;
    left: auto !important;
    right: 12px !important;
    bottom: 84px !important;
    transform: none !important;
  }
  .wl-er-card { width: 88vw; max-width: 88vw; }
}

/* Tablet / iPad (portrait & landscape): larger touch targets and
   wider card because 20vw is too narrow on iPad. Still draggable. */
@media (min-width: 641px) and (max-width: 1024px) {
  .wl-er-chip {
    padding: 9px 14px;
    font-size: 13px;
    gap: 8px;
  }
  .wl-er-chip-dot { width: 10px; height: 10px; }
  .wl-er-chip-badge { font-size: 12px; padding: 2px 9px; }
  .wl-er-card {
    width: 46vw;
    min-width: 340px;
    max-width: 520px;
    max-height: 72vh;
    font-size: 13px;
  }
  .wl-er-card-header { padding: 10px 12px; }
  .wl-er-card-title { font-size: 13px; }
  .wl-er-card-date  { font-size: 12px; }
  .wl-er-card-close, .wl-er-card-refresh {
    width: 32px; height: 32px;
  }
  .wl-er-today-row, .wl-er-upcoming-row { padding: 8px 12px; }
  .wl-er-section-title { padding: 10px 12px 4px; font-size: 11px; }
}

/* Any touch-primary device (iPad, iPad Pro, Surface): disable hover
   tooltips on the chip and give the drag handle more generous hit area. */
@media (hover: none) and (pointer: coarse) {
  .wl-er-chip {
    /* Make the hit area comfortable for a fingertip without changing look */
    min-height: 36px;
  }
  .wl-er-card-close, .wl-er-card-refresh { min-width: 36px; min-height: 36px; }
}
