/* ===========================================================================
   price-insights.css — the price-persuasion strip + price-history modal
   Release 2 of the price logger. Component styles lifted from the approved
   mockup (docs/plans/price-insight-mockup.html); demo-only chrome (phone
   frames, states gallery, callouts) dropped.

   THEMING NOTE — deliberately light-only.
   The mockup ships light + dark, but nopturnia.com has *no* dark mode: there
   is not one `prefers-color-scheme` or `data-theme` rule in css/. Honouring
   the mockup's dark block here would render a dark strip inside a permanently
   light card. So every surface colour derives from the site's own `--v2-*`
   tokens (with fallbacks, for legacy pages that only load style.css), and the
   semantic status colours — which the site doesn't define — are declared once
   below. The day blog-v2.css gains dark tokens, the strip follows on its own;
   the staged dark block at the bottom is all that needs uncommenting.

   Everything is namespaced `pi-` / `pi-modal-`: this file loads on pages that
   already own generic names like .modal and .stat.
   ========================================================================= */

:root {
  /* Semantic status — always paired with a dot + words, never colour alone. */
  --pi-good: #15803D;
  --pi-good-soft: #DCFCE7;
  --pi-good-ink: #166534;
  --pi-warn: #B45309;
  --pi-warn-soft: #FEF6E6;
  --pi-warn-ink: #92400E;
  --pi-neutral-soft: #F1F5F9;
  --pi-muted: #94A3B8;

  /* Chart */
  --pi-chart-line: var(--v2-brand, #1D4ED8);
  --pi-chart-fill: rgba(29, 78, 216, .12);
  --pi-grid: rgba(15, 23, 42, .07);
  --pi-shadow: 0 8px 40px rgba(15, 23, 42, .08);

  /* Surfaces — inherited from the V2 system wherever it is loaded. */
  --pi-ink: var(--v2-ink, #0F172A);
  --pi-ink-soft: var(--v2-ink-soft, #64748B);
  --pi-card: var(--v2-card, #FFFFFF);
  --pi-secondary: var(--v2-secondary, #F1F5F9);
  --pi-hairline: var(--v2-hairline, #E2E8F0);
  --pi-brand: var(--v2-brand, #1D4ED8);
  --pi-brand-soft: var(--v2-brand-soft, #3B82F6);
  --pi-mono: var(--v2-mono, 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace);
  --pi-sans: var(--v2-sans, 'Inter', ui-sans-serif, system-ui, sans-serif);
  --pi-display: var(--v2-display, 'Space Grotesk', ui-sans-serif, system-ui, sans-serif);
}

/* ------------------------------- the strip ------------------------------- */

.pi {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  min-height: 44px;             /* touch target */
  padding: 10px 12px;
  border: 1px solid var(--pi-hairline);
  border-radius: 12px;
  background: var(--pi-secondary);
  font-family: var(--pi-sans);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.pi:hover { border-color: var(--pi-brand-soft); transform: translateY(-1px); }
.pi:focus-visible { outline: 2px solid var(--pi-brand-soft); outline-offset: 2px; }

.pi-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pi-pill .pi-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

.pi-good { color: var(--pi-good-ink); background: var(--pi-good-soft); }
.pi-good .pi-dot { background: var(--pi-good); }
.pi-warn { color: var(--pi-warn-ink); background: var(--pi-warn-soft); }
.pi-warn .pi-dot { background: var(--pi-warn); }
.pi-neutral { color: var(--pi-ink-soft); background: var(--pi-neutral-soft); }
.pi-neutral .pi-dot { background: var(--pi-muted); }

.pi-delta {
  font-family: var(--pi-mono);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--pi-ink-soft);
}
.pi-delta.pi-up { color: var(--pi-warn); }
.pi-delta.pi-down { color: var(--pi-good); }

.pi-spark { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pi-spark svg { display: block; overflow: visible; }

.pi-cue {
  font-family: var(--pi-mono);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--pi-ink-soft);
  white-space: nowrap;
}

/* Out of stock / dropped from the catalog: frozen last-known price, dimmed,
   and genuinely non-interactive — never present a stale price as live. */
.pi[data-pi-unavailable] { cursor: default; opacity: .85; }
.pi[data-pi-unavailable]:hover { transform: none; border-color: var(--pi-hairline); }

/* On chat cards the strip is a sibling of the card anchor, so it needs the
   card's own margin discipline rather than the grid gap. */
.pi-chat-wrap { display: flex; flex-direction: column; }
.pi-chat-wrap > .pi { margin-top: 8px; border-radius: 10px; }

/* Legacy pages (style.css) have no flex-gap card body — give the strip air. */
.pi-legacy { margin: 10px 0 14px; }

/* --------------------------- the history modal --------------------------- */

.pi-modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 2147483000;          /* above the chat widget */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(3px);
}
.pi-modal-scrim.pi-open { display: flex; }

.pi-modal {
  width: min(560px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px;
  background: var(--pi-card);
  border: 1px solid var(--pi-hairline);
  border-radius: 18px;
  box-shadow: var(--pi-shadow);
  font-family: var(--pi-sans);
  color: var(--pi-ink);
  animation: pi-pop .2s ease;
}
@keyframes pi-pop {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to { opacity: 1; transform: none; }
}

.pi-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pi-modal-title { font-family: var(--pi-display); font-size: 17px; font-weight: 600; color: var(--pi-ink); }
.pi-modal-sub { margin-top: 3px; font-size: 12.5px; color: var(--pi-ink-soft); }
.pi-modal-close {
  flex: none;
  width: 32px; height: 32px;
  min-height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--pi-secondary);
  color: var(--pi-ink-soft);
  font-size: 16px;
  cursor: pointer;
}
.pi-modal-close:focus-visible { outline: 2px solid var(--pi-brand-soft); outline-offset: 2px; }

.pi-stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 6px; }
.pi-stat {
  flex: 1;
  min-width: 96px;
  padding: 9px 11px;
  background: var(--pi-secondary);
  border: 1px solid var(--pi-hairline);
  border-radius: 10px;
}
.pi-stat .pi-k {
  font-family: var(--pi-mono);
  font-size: 9.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--pi-ink-soft);
}
.pi-stat .pi-v {
  margin-top: 3px;
  font-family: var(--pi-mono);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--pi-ink);
}

.pi-chart-box { position: relative; margin-top: 12px; }
.pi-chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }

.pi-tt {
  position: absolute;
  pointer-events: none;
  padding: 5px 8px;
  background: var(--pi-ink);
  color: var(--pi-card);
  border-radius: 7px;
  font-family: var(--pi-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transform: translate(-50%, -130%);
  opacity: 0;
  transition: opacity .1s;
}

.pi-modal-foot { display: flex; gap: 8px; margin-top: 16px; }

/* The CTA is an <a>, and blog-v2.css sets `body.blog-v2 a { color: inherit }`
   (specificity 0,1,1) which beats a lone `.pi-amz-btn` — the label would render
   ink-on-ink and vanish. Scoped here to outrank it without depending on load
   order; blog-v2.css:476 uses the same workaround for its breadcrumbs. */
.pi-modal a.pi-amz-btn,
.pi-amz-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 16px;
  background: var(--pi-ink);
  color: var(--pi-card);
  border: none;
  border-radius: 10px;
  font-family: var(--pi-sans);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.pi-amz-btn:hover { opacity: .92; }
.pi-amz-btn svg { width: 15px; height: 15px; flex: none; }

.pi-modal-note { margin-top: 10px; font-size: 11.5px; color: var(--pi-ink-soft); line-height: 1.5; }
.pi-modal-empty { padding: 26px 4px; text-align: center; font-size: 13.5px; color: var(--pi-ink-soft); }

/* ------------ mobile / installed-PWA bottom sheet + safe area ------------ */
@media (max-width: 560px) {
  .pi-modal-scrim { align-items: flex-end; padding: 0; }
  .pi-modal {
    width: 100%;
    max-width: none;
    max-height: 88vh;
    border-radius: 20px 20px 0 0;
    padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    animation: pi-sheet-up .28s ease;
  }
  .pi-stat { min-width: 0; padding: 8px 9px; }
  .pi-stat .pi-v { font-size: 13px; }
}
@keyframes pi-sheet-up {
  from { transform: translateY(100%); }
  to { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pi, .pi-modal, .pi-tt { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------------------
   STAGED DARK MODE — intentionally inert. Uncomment only when the rest of the
   site (blog-v2.css) actually ships dark tokens, or the strip will be the one
   dark element on a light page. Values are the mockup's dark palette.
   ---------------------------------------------------------------------------
@media (prefers-color-scheme: dark) {
  :root {
    --pi-good:#4ADE80; --pi-good-soft:rgba(34,197,94,.14); --pi-good-ink:#86EFAC;
    --pi-warn:#FBBF24; --pi-warn-soft:rgba(245,158,11,.14); --pi-warn-ink:#FCD34D;
    --pi-neutral-soft:rgba(148,163,184,.12); --pi-muted:#5C6B87;
    --pi-chart-fill:rgba(96,165,250,.18); --pi-grid:rgba(255,255,255,.08);
    --pi-shadow:0 12px 48px rgba(0,0,0,.5);
  }
}
--------------------------------------------------------------------------- */
