/* PartsFisher Live. Every rule is scoped under .pfl-root so the widget cannot restyle the host theme. */

.pfl-root {
  /* The layout answers to the widget's own width, not the screen's: a theme may place it in a narrow column. */
  container-type: inline-size;
  container-name: pfl;
  --pfl-ink: #0f172a;
  --pfl-muted: #64748b;
  --pfl-panel: #ffffff;
  --pfl-line: #e2e8f0;
  --pfl-land: #e8eef7;
  --pfl-border: #ffffff;
  --pfl-blue: #0d6efd;
  --pfl-navy: #1e293b;
  --pfl-seller: #f59e0b;
  --pfl-green: #059669;

  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--pfl-ink);
  background: linear-gradient(135deg, #f8fafc 0%, #eef4ff 100%);
  border: 1px solid var(--pfl-line);
  border-radius: 12px;
  padding: 24px;
  max-width: 1280px;
  margin: 0 auto;
  line-height: 1.4;
}

.pfl-root *,
.pfl-root *::before,
.pfl-root *::after { box-sizing: border-box; }

.pfl-root .pfl-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.pfl-root .pfl-title { display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 700; color: var(--pfl-navy); }
.pfl-root .pfl-controls { display: flex; align-items: center; gap: 10px; }

/* A theme styles buttons its own way, so every button in the widget starts from nothing. */
.pfl-root .pfl-icon-button {
  all: unset;
  box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--pfl-line); background: var(--pfl-panel); color: var(--pfl-muted);
  cursor: pointer; transition: color 0.2s ease, border-color 0.2s ease;
}
.pfl-root .pfl-icon-button:hover { color: var(--pfl-blue); border-color: var(--pfl-blue); }
.pfl-root .pfl-icon-button:focus-visible { outline: 2px solid var(--pfl-blue); outline-offset: 2px; }
.pfl-root .pfl-icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pfl-root .pfl-refreshing svg { animation: pfl-spin 0.8s linear; }
@keyframes pfl-spin { to { transform: rotate(360deg); } }

/*
 * The Buyers / Sellers switch: two equal buttons in one pill, with a filled thumb that slides
 * behind the one in force.
 */
.pfl-root .pfl-views {
  position: relative; display: inline-grid; grid-template-columns: 1fr 1fr;
  border: 1px solid var(--pfl-line); border-radius: 17px; background: var(--pfl-panel); overflow: hidden;
}
.pfl-root .pfl-views-thumb {
  position: absolute; top: 0; bottom: 0; left: 0; width: 50%;
  border-radius: 16px; background: var(--pfl-navy);
  transition: transform 0.3s ease;
}
.pfl-root .pfl-views-seller .pfl-views-thumb { transform: translateX(100%); }
.pfl-root .pfl-view {
  all: unset;
  box-sizing: border-box;
  position: relative;
  height: 32px; padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: var(--pfl-muted);
  cursor: pointer; transition: color 0.3s ease;
}
.pfl-root .pfl-view:hover { color: var(--pfl-blue); }
.pfl-root .pfl-view:focus-visible { outline: 2px solid var(--pfl-blue); outline-offset: -2px; }
.pfl-root .pfl-view[aria-pressed="true"] { color: #ffffff; }

.pfl-root .pfl-live-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: pfl-live 2s infinite;
}
@keyframes pfl-live {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
/* Data that is no longer fresh is not called live: the dot goes grey and still. */
.pfl-root.pfl-stale .pfl-live-dot { background: var(--pfl-muted); box-shadow: none; animation: none; }

.pfl-root .pfl-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: stretch; }

.pfl-root .pfl-map { background: var(--pfl-panel); border: 1px solid var(--pfl-line); border-radius: 10px; padding: 12px; }
.pfl-root .pfl-map svg { display: block; width: 100%; height: auto; }
.pfl-root .pfl-state { fill: var(--pfl-land); transition: fill 1.2s ease; }
/* A state with at least one PartsFisher dealer. */
.pfl-root .pfl-state-active { fill: #d6e2f5; }
.pfl-root .pfl-borders { fill: none; stroke: var(--pfl-border); stroke-width: 1.2; stroke-linejoin: round; }

/* One group per match; --pfl-fade, set per match, lightens the older ones. */
.pfl-root .pfl-match { opacity: var(--pfl-fade, 1); transition: opacity 0.25s ease; }
.pfl-root .pfl-arc { fill: none; stroke: var(--pfl-blue); stroke-width: 2; stroke-linecap: round; }
.pfl-root .pfl-match-newest .pfl-arc { stroke-width: 3; }
/*
 * A restocking order: every seller's arc in navy, drawn in like any other and then turned into a
 * dashed line whose dashes flow on into the buyer, so the order reads as parts converging on one
 * dealer.
 */
.pfl-root .pfl-match-package .pfl-arc { stroke: var(--pfl-navy); }
.pfl-root .pfl-arc-flow { stroke-dasharray: 6 8; animation: pfl-flow 1s linear infinite; }
@keyframes pfl-flow {
  from { stroke-dashoffset: 14; }
  to { stroke-dashoffset: 0; }
}
.pfl-root .pfl-dot { stroke: #ffffff; stroke-width: 1.5; }
.pfl-root .pfl-dot-seller { fill: var(--pfl-seller); }
.pfl-root .pfl-dot-buyer { fill: var(--pfl-blue); }
.pfl-root .pfl-pulse { fill: none; stroke: var(--pfl-blue); stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: pfl-pulse 2s ease-out infinite; }
.pfl-root .pfl-pulse-seller { stroke: var(--pfl-seller); }
/* Every live dealer, a quiet backdrop beneath the matches. */
.pfl-root .pfl-node { fill: #9fb4d6; opacity: 0.55; transform-box: fill-box; transform-origin: center; }
/*
 * The opening wave: each dot waits for the wave to reach it (its own --pfl-wave-delay), pops up
 * highlighted with a soft ring, and settles to the quiet dot. Hidden until its turn comes.
 */
.pfl-root .pfl-waving .pfl-node { animation: pfl-wave 1.2s ease-out var(--pfl-wave-delay, 0ms) both; }
@keyframes pfl-wave {
  0% { opacity: 0; transform: scale(0.3); fill: var(--pfl-blue); stroke: rgba(13, 110, 253, 0.35); stroke-width: 0; }
  30% { opacity: 1; transform: scale(2.6); fill: var(--pfl-blue); stroke: rgba(13, 110, 253, 0.35); stroke-width: 3; }
  100% { opacity: 0.55; transform: scale(1); fill: #9fb4d6; stroke: rgba(13, 110, 253, 0); stroke-width: 0; }
}
@keyframes pfl-pulse {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(4); opacity: 0; }
}

/* A selected match stands out and every other one steps back. */
.pfl-root.pfl-has-selection .pfl-match { opacity: 0.12; }
.pfl-root.pfl-has-selection .pfl-match.pfl-selected { opacity: 1; }
.pfl-root .pfl-match.pfl-selected .pfl-arc { stroke: var(--pfl-green); stroke-width: 4; }
.pfl-root .pfl-match.pfl-selected .pfl-dot { r: 7px; }

.pfl-root .pfl-legend { display: flex; gap: 18px; padding: 6px 4px 0; font-size: 13px; color: var(--pfl-muted); }
.pfl-root .pfl-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.pfl-root .pfl-swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.pfl-root .pfl-swatch-seller { background: var(--pfl-seller); }
.pfl-root .pfl-swatch-buyer { background: var(--pfl-blue); }
.pfl-root .pfl-swatch-network { background: #9fb4d6; }
.pfl-root .pfl-swatch-flow { width: 18px; height: 0; display: inline-block; border-top: 2px dashed var(--pfl-navy); }
.pfl-root .pfl-legend-item[hidden] { display: none; }

/*
 * The side column is exactly as tall as the map: as a size container it adds no height of its own,
 * so the grid row takes the map's height, and the totals and the cards share that height out
 * proportionally. Text is sized against the column's height (cqh) so it still fits a shorter map.
 * The totals are never smaller than their own content; the cards take what is left, and the script
 * leaves out a card that would be cut off.
 */
.pfl-root .pfl-side { container-type: size; min-height: 0; }
.pfl-root .pfl-side-inner { height: 100%; display: flex; flex-direction: column; gap: 1.6cqh; }
.pfl-root .pfl-totals {
  flex: 2.6 1 0; min-height: auto;
  display: flex; flex-direction: column; justify-content: center;
  background: linear-gradient(135deg, var(--pfl-navy) 0%, #1a4fa0 60%, var(--pfl-blue) 100%);
  color: #ffffff; border-radius: 10px; padding: 1cqh 20px;
}
.pfl-root .pfl-total + .pfl-total { margin-top: 1.8cqh; padding-top: 1.6cqh; border-top: 1px solid rgba(255, 255, 255, 0.2); }
.pfl-root .pfl-total-label { font-size: clamp(10px, 2.2cqh, 13px); color: #c7d7fe; text-transform: uppercase; letter-spacing: 0.06em; }
.pfl-root .pfl-total-value { font-size: clamp(20px, 6.4cqh, 38px); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.pfl-root .pfl-total-value-small { font-size: clamp(16px, 4.4cqh, 26px); }
.pfl-root .pfl-total-percent { font-size: clamp(11px, 2.4cqh, 14px); color: #c7d7fe; font-variant-numeric: tabular-nums; }
.pfl-root .pfl-total-percent:empty { display: none; }
.pfl-root .pfl-total-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }

.pfl-root .pfl-list-title { flex: 0 0 auto; font-size: clamp(10px, 2.2cqh, 13px); font-weight: 700; color: var(--pfl-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.pfl-root .pfl-list { flex: 5 1 0; min-height: 0; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.3cqh; }
/* A list item holds one card, a button; a card the column has no room for is hidden whole. */
.pfl-root .pfl-card { flex: 1 1 0; min-height: 0; display: flex; margin: 0; padding: 0; }
.pfl-root .pfl-card[hidden] { display: none; }
.pfl-root .pfl-item {
  all: unset;
  box-sizing: border-box;
  flex: 1 1 auto; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; justify-content: center;
  background: var(--pfl-panel); border: 1px solid var(--pfl-line); border-left: 4px solid var(--pfl-blue); border-radius: 8px;
  padding: 0 12px; overflow: hidden; cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.pfl-root .pfl-item:hover { box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12); }
.pfl-root .pfl-item:focus-visible { outline: 2px solid var(--pfl-blue); outline-offset: 2px; }
.pfl-root .pfl-item-selected { border-color: var(--pfl-green); border-left-color: var(--pfl-green); background: #ecfdf5; }
.pfl-root .pfl-card-new { animation: pfl-arrive 0.6s ease-out; }
@keyframes pfl-arrive {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
.pfl-root .pfl-item-top, .pfl-root .pfl-item-bottom { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.pfl-root .pfl-item-bottom { margin-top: 0.6cqh; }
.pfl-root .pfl-part { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: clamp(12px, 2.6cqh, 15px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pfl-root .pfl-when { font-size: clamp(10px, 2.1cqh, 12px); color: var(--pfl-muted); white-space: nowrap; }
.pfl-root .pfl-detail { flex: 1 1 auto; display: inline-flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; }
/* The figure is never shortened; a long make gives way to it. */
.pfl-root .pfl-oem {
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
  font-size: clamp(10px, 2.1cqh, 12px); font-weight: 700; color: var(--pfl-navy);
  background: #e8eef7; border-radius: 4px; padding: 1px 7px; letter-spacing: 0.02em;
}
.pfl-root .pfl-figure { flex: none; white-space: nowrap; }
.pfl-root .pfl-saved { font-size: clamp(12px, 2.6cqh, 15px); font-weight: 700; color: var(--pfl-green); font-variant-numeric: tabular-nums; }
.pfl-root .pfl-matched { font-size: clamp(11px, 2.3cqh, 13px); color: var(--pfl-muted); }

/* Stacked under the map in a narrow space, the column and its cards size to their own content again. */
@container pfl (max-width: 760px) {
  .pfl-root .pfl-body { grid-template-columns: minmax(0, 1fr); }
  .pfl-root .pfl-totals, .pfl-root .pfl-list, .pfl-root .pfl-card { flex: none; }
  .pfl-root .pfl-side { container-type: normal; }
  .pfl-root .pfl-side-inner { height: auto; gap: 10px; }
  .pfl-root .pfl-totals { padding: 16px 20px; }
  .pfl-root .pfl-total + .pfl-total { margin-top: 12px; padding-top: 10px; }
  .pfl-root .pfl-total-label, .pfl-root .pfl-list-title { font-size: 12px; }
  .pfl-root .pfl-total-value { font-size: 32px; }
  .pfl-root .pfl-total-value-small { font-size: 24px; }
  .pfl-root .pfl-list { gap: 8px; }
  .pfl-root .pfl-item { padding: 10px 12px; }
  .pfl-root .pfl-item-bottom { margin-top: 4px; }
  .pfl-root .pfl-part, .pfl-root .pfl-saved { font-size: 15px; }
  .pfl-root .pfl-when { font-size: 12px; }
  .pfl-root .pfl-oem { font-size: 12px; }
  .pfl-root .pfl-matched { font-size: 13px; }
}

/*
 * The makes matched most: one line of logos, one neutral grey and one height, as many as fit; a
 * make with no logo is shown by name in the same grey.
 */
.pfl-root .pfl-brands {
  display: flex; align-items: center; justify-content: center; gap: 28px;
  margin-top: 16px; padding: 12px 8px 0; border-top: 1px solid var(--pfl-line);
  height: 46px; overflow: hidden; flex-wrap: wrap; row-gap: 40px;
}
.pfl-root .pfl-brands[hidden] { display: none; }
/* Logos drawn in colour are greyed to match the rest, so no make stands out from the others. */
.pfl-root .pfl-brand-logo { height: 24px; width: auto; display: block; opacity: 0.7; filter: grayscale(1); }
.pfl-root .pfl-brand-name { font-size: 14px; font-weight: 700; color: var(--pfl-muted); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; line-height: 24px; }

.pfl-root .pfl-status:empty { display: none; }
.pfl-root .pfl-status { margin-top: 12px; font-size: 14px; color: var(--pfl-muted); text-align: center; }

/* Read by a screen reader when a match arrives, and never seen. */
.pfl-root .pfl-announce {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/*
 * Full screen, for a display across a room. The widget fills the screen, the map takes the height
 * left under the header, and the side column widens with the screen. The side column's text drops
 * the caps it has on a page and follows the column's height and width, whichever is the tighter.
 * :is() takes the class as well as the state, so a browser that knows only a prefixed full-screen
 * state still gets the layout.
 */
.pfl-root:is(:fullscreen, .pfl-fullscreen) {
  max-width: none; width: 100%; height: 100%; margin: 0;
  border: 0; border-radius: 0; padding: 2.5vh 2vw;
  display: flex; flex-direction: column; overflow: auto;
}
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-head { flex: none; margin-bottom: 2vh; }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-title { font-size: clamp(26px, 3.4vh, 54px); }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-body {
  flex: 1 1 auto; min-height: 0;
  grid-template-columns: minmax(0, 1fr) clamp(340px, 26vw, 520px);
  grid-template-rows: minmax(0, 1fr);
}
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-map { display: flex; flex-direction: column; min-height: 0; }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-map svg { flex: 1 1 auto; min-height: 0; height: 100%; }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-legend { flex: none; font-size: clamp(13px, 1.7vh, 24px); }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-totals { padding: 1cqh 4cqw; }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-total-label,
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-list-title { font-size: min(2.2cqh, 4.4cqw); }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-total-value { font-size: min(6.4cqh, 13cqw); }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-total-value-small { font-size: min(4.4cqh, 9cqw); }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-item { padding: 0 3cqw; }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-part,
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-saved { font-size: min(2.6cqh, 5.2cqw); }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-when,
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-oem { font-size: min(2.1cqh, 4.2cqw); }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-matched { font-size: min(2.3cqh, 4.6cqw); }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-brands {
  flex: none; margin-top: 2vh; padding-top: 1.5vh; gap: 3vw;
  height: calc(clamp(24px, 3.6vh, 48px) + 1.5vh); row-gap: 10vh;
}
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-brand-logo { height: clamp(24px, 3.6vh, 48px); }
.pfl-root:is(:fullscreen, .pfl-fullscreen) .pfl-brand-name { font-size: clamp(14px, 2vh, 26px); line-height: clamp(24px, 3.6vh, 48px); }

@media (max-width: 600px) {
  .pfl-root { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .pfl-root .pfl-live-dot, .pfl-root .pfl-pulse, .pfl-root .pfl-card-new, .pfl-root .pfl-refreshing svg,
  .pfl-root .pfl-waving .pfl-node, .pfl-root .pfl-arc-flow { animation: none; }
  .pfl-root .pfl-state, .pfl-root .pfl-views-thumb, .pfl-root .pfl-view { transition: none; }
}
