/* PricePilot: the parts Caligrafy's layout has no class for - the price track, the item picture, the price,
 * the distance to the target, the price-hit rows and the live alert. Colors come from Caligrafy's tokens;
 * green (--design-success) only means "your price". */

:root {
  --pp-hit: var(--design-success, #1f7a4d);
  --pp-hit-soft: color-mix(in srgb, var(--pp-hit) 12%, transparent);
  --pp-close: #8a5300;
  --pp-close-soft: #fbf0dc;
}

.pp-num { font-variant-numeric: tabular-nums; }

/* the picture of an item */
.pp-thumb { flex: none; width: 64px; height: 64px; border-radius: var(--cq-radius-control, 4px); background: var(--cq-color-surface); object-fit: contain; }
.pp-thumb--empty { display: grid; place-items: center; color: var(--cq-color-text-muted); font-size: 22px; }
.pp-thumb--lg { width: 120px; height: 120px; }

/* the price and the distance to the target */
.pp-price { margin: 0; font-size: 20px; font-weight: 500; color: var(--cq-color-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pp-was { margin-left: 6px; font-size: 14px; font-weight: 400; color: var(--cq-color-text-muted); text-decoration: line-through; }
.pp-gap { display: inline-block; padding: 3px 8px; border-radius: var(--cq-radius-control, 4px); background: var(--cq-color-surface); color: var(--cq-color-text-muted); font-size: 12px; font-weight: 500; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pp-gap--close { background: var(--pp-close-soft); color: var(--pp-close); }
.pp-gap--hit { background: var(--pp-hit-soft); color: var(--pp-hit); }
.pp-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

/* the price track: grey = today's prices across shops, ticks = past best prices, dot = best now, green = your price */
.pp-track { position: relative; height: 38px; margin-top: 10px; max-width: 520px; }
.pp-track-rail { position: absolute; left: 0; right: 0; top: 13px; height: 2px; background: var(--cq-color-border); }
.pp-track-zone { position: absolute; top: 6px; height: 16px; background: var(--pp-hit-soft); border-right: 2px solid var(--pp-hit); }
.pp-track-range { position: absolute; top: 11px; height: 6px; border-radius: 3px; background: var(--design-hairline-strong, #d0d1d2); }
.pp-track-tick { position: absolute; top: 10px; width: 2px; height: 8px; margin-left: -1px; background: var(--cq-color-text-muted); opacity: .35; }
.pp-track-now { position: absolute; top: 7px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--cq-color-ink); border: 2px solid var(--cq-color-canvas, #fff); transition: left .8s cubic-bezier(.2, .8, .2, 1); }
.pp-track-now.is-hit { background: var(--pp-hit); }
.pp-track-label { position: absolute; top: 24px; transform: translateX(-50%); font-size: 11px; color: var(--cq-color-text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pp-track-label--target { color: var(--pp-hit); font-weight: 500; }
.pp-track-label--start { transform: none; }
.pp-track-label--end { transform: translateX(-100%); }

/* items that hit their price: first, green, with the buy button */
.pp-hits { margin: 0 0 32px; padding: 0; list-style: none; }
.pp-hit { display: flex; align-items: center; gap: 16px; padding: 20px; border: 2px solid var(--pp-hit); border-radius: var(--cq-radius-control, 4px); background: var(--pp-hit-soft); }
.pp-hit + .pp-hit { margin-top: 12px; }
.pp-hit.is-new { animation: pp-arrive .6s ease-out; }
.pp-hit-label { margin: 0 0 2px; color: var(--pp-hit); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.pp-hit .pp-price { font-size: 28px; color: var(--pp-hit); }
.pp-buy { background: var(--pp-hit) !important; border-color: var(--pp-hit) !important; color: #fff !important; }
@keyframes pp-arrive { from { transform: translateY(-8px); box-shadow: 0 0 0 6px var(--pp-hit-soft); } to { transform: none; box-shadow: none; } }

/* the live line under the title */
.pp-live { display: inline-flex; align-items: center; gap: 8px; }
.pp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pp-hit); animation: pp-pulse 2s infinite; }
.pp-dot.is-off { background: var(--cq-color-text-muted); animation: none; }
@keyframes pp-pulse { 0% { box-shadow: 0 0 0 0 var(--pp-hit-soft); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* the alert that drops in when a price hits while the page is open */
.pp-flash { position: fixed; z-index: 1050; top: calc(12px + env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: min(400px, calc(100vw - 24px)); padding: 16px; border-radius: 12px; background: var(--cq-color-canvas, #fff); border: 2px solid var(--pp-hit); box-shadow: 0 12px 32px rgba(0, 0, 0, .18); animation: pp-drop .4s ease-out; }
.pp-flash p { margin: 0 0 10px; color: var(--cq-color-ink); }
@keyframes pp-drop { from { transform: translateY(-20px); opacity: .3; } to { transform: none; opacity: 1; } }

/* the add page */
.pp-step[hidden] { display: none !important; }
.pp-preview { display: block; max-width: 100%; max-height: 320px; margin: 16px 0 0; border-radius: var(--cq-radius-control, 4px); }
.pp-reader { width: 100%; max-width: 420px; margin: 16px 0 0; }
.pp-bookmarklet { display: inline-block; padding: 8px 14px; border: 1px dashed var(--cq-color-ink); border-radius: var(--cq-radius-control, 4px); color: var(--cq-color-ink); font-weight: 500; text-decoration: none; cursor: grab; }
.pp-choice { flex: none; width: 20px; height: 20px; margin: 0; }
.pp-confidence { color: var(--pp-hit); font-size: 13px; font-weight: 500; white-space: nowrap; }
.pp-confidence.is-low { color: var(--pp-close); }
.pp-note { margin: 12px 0 0; padding: 12px 14px; border-radius: var(--cq-radius-control, 4px); background: var(--pp-close-soft); color: var(--pp-close); font-size: 14px; }
.pp-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 24px; }
.pp-busy { display: flex; align-items: center; gap: 12px; color: var(--cq-color-text-muted); }
.pp-spinner { width: 18px; height: 18px; border: 2px solid var(--cq-color-border); border-top-color: var(--cq-color-ink); border-radius: 50%; animation: pp-spin .8s linear infinite; }
@keyframes pp-spin { to { transform: rotate(360deg); } }

/* the price history of an item */
.pp-chart { width: 100%; max-width: 760px; height: auto; margin-top: 16px; display: block; }
.pp-chart text { fill: var(--cq-color-text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }

@media (max-width: 575px) {
  .cq-row.pp-row { flex-wrap: wrap; }
  .pp-row .cq-row-main { flex-basis: calc(100% - 80px); }
  .pp-row .pp-side { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .pp-thumb { width: 52px; height: 52px; }
  .pp-hit { flex-wrap: wrap; padding: 16px; }
  .pp-hit .cq-row-main { flex-basis: calc(100% - 70px); }
  .pp-hit .cq-row-actions { width: 100%; justify-content: stretch; }
  .pp-hit .cq-row-actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .pp-dot, .pp-hit.is-new, .pp-flash, .pp-spinner { animation: none; } .pp-track-now { transition: none; } }

.pp-space { margin-top: 32px; }
/* a button that reads as a link, inside a sentence (Send the link again) */
.pp-link { background: none; border: 0; padding: 0; font: inherit; color: var(--cq-color-ink, inherit); text-decoration: underline; cursor: pointer; }
.pp-link:disabled { opacity: .5; cursor: default; }
