/*
 * PVG-Widget (Preisvergleich im Artikel) — gemeinsame Basis aller Varianten.
 * Tokens nach DESIGN.md §1, Tabellen §4.3, Buttons §4.1, Status §1.3, Ribbon wie heatmap.css.
 * Dark Mode über die Body-Klasse der Seite (.theme-dark, Cookie „hwldark“).
 * Keine festen Farben in den Komponenten, nur Tokens. Radien nur an Schaltflächen.
 */

.hxpv {
  --hxpv-flaeche: #ffffff;
  --hxpv-kasten: #f1f1f1;
  --hxpv-kopf: #e9e9e9;
  --hxpv-text: #333333;
  --hxpv-text-sekundaer: #4b4b4b;
  --hxpv-linie: #e2e2e2;
  --hxpv-linie-stark: #cccccc;
  --hxpv-rot: #ae0000;
  --hxpv-rot-hover: #620000;
  --hxpv-rot-flaeche: #ae0000;
  --hxpv-rot-flaeche-hover: #7b0000;
  --hxpv-rot-hauch: rgba(174, 0, 0, 0.08);
  --hxpv-gruen: #2f8f3d;
  --hxpv-gelb: #a66a00;
  --hxpv-grau: #6b6b6b;
  --hxpv-schatten: 0 2px 14px rgba(0, 0, 0, 0.08);
  --hxpv-radius-knopf: 4px;

  container: hxpv / inline-size;
  position: relative;
  box-sizing: border-box;
  margin: 28px 0 24px;
  padding: 24px 16px 12px;
  background: var(--hxpv-flaeche);
  color: var(--hxpv-text);
  box-shadow: var(--hxpv-schatten);
  border-radius: 0;
  font-family: 'Open Sans', 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
}

.theme-dark .hxpv {
  --hxpv-flaeche: #1f1f1f;
  --hxpv-kasten: #272727;
  --hxpv-kopf: #313134;
  --hxpv-text: #e2e2e2;
  --hxpv-text-sekundaer: #a0a0a0;
  --hxpv-linie: rgba(255, 255, 255, 0.1);
  --hxpv-linie-stark: rgba(255, 255, 255, 0.2);
  --hxpv-rot: #f37575;
  --hxpv-rot-hover: #ee4a4a;
  --hxpv-rot-flaeche: #b93232;
  --hxpv-rot-flaeche-hover: #e03d3d;
  --hxpv-rot-hauch: rgba(243, 117, 117, 0.12);
  --hxpv-gruen: #4caf58;
  --hxpv-gelb: #e0a930;
  --hxpv-grau: #a0a0a0;
  --hxpv-schatten: 0 2px 14px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

.hxpv *,
.hxpv *::before,
.hxpv *::after {
  box-sizing: border-box;
}

.hxpv [hidden] {
  display: none !important;
}

.hxpv :focus-visible {
  outline: 2px solid var(--hxpv-rot);
  outline-offset: 2px;
}

/* Nur für Screenreader */
.hxpv-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Ribbon „Anzeige“ (heatmap.css .hxat-ribbon), erstes Element des Widgets */
.hxpv-ribbon {
  position: absolute;
  top: -12px;
  left: -8px;
  padding: 3px 14px;
  background: var(--hxpv-rot-flaeche);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

.hxpv-oberzeile {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--hxpv-text-sekundaer);
}

.hxpv-titel {
  margin: 2px 0 2px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--hxpv-text);
  overflow-wrap: anywhere;
}

.hxpv-meta {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--hxpv-text-sekundaer);
}

.hxpv-preis {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.hxpv-preis--leer {
  font-weight: 400;
  color: var(--hxpv-text-sekundaer);
  white-space: normal;
}

/* Neutrale Hervorhebung des niedrigsten Preises: Text + Rahmen, keine Signalfarbe */
.hxpv-niedrigster {
  display: inline-block;
  margin-top: 2px;
  padding: 0 6px;
  border: 1px solid var(--hxpv-linie-stark);
  border-radius: 0;
  background: var(--hxpv-kasten);
  color: var(--hxpv-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

/* Lieferstatus: Symbol (Form) + Text, Farbe nur am Symbol */
.hxpv-status {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--hxpv-text);
}

.hxpv-status-symbol {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.hxpv-status--erfolg .hxpv-status-symbol { color: var(--hxpv-gruen); }
.hxpv-status--achtung .hxpv-status-symbol { color: var(--hxpv-gelb); }
.hxpv-status--neutral .hxpv-status-symbol { color: var(--hxpv-grau); }

.hxpv-status-text {
  display: flex;
  flex-direction: column;
}

.hxpv-status-detail {
  font-size: 12px;
  color: var(--hxpv-text-sekundaer);
}

/* Partnerlink als Schaltfläche (Ghost, §4.1). Alle Händler gleich gewichtet. */
/* inline-block statt flex: das Sternchen bricht nie allein in eine eigene Spalte */
.hxpv-knopf {
  display: inline-block;
  vertical-align: middle;
  min-height: 44px;
  min-width: 44px;
  padding: 12px 14px;
  border: 1px solid var(--hxpv-rot);
  border-radius: var(--hxpv-radius-knopf);
  background: transparent;
  color: var(--hxpv-rot);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere; /* lange Shopnamen ohne Leerzeichen brechen um statt überzulaufen */
  cursor: pointer;
}

.hxpv-knopf:hover {
  background: var(--hxpv-rot-hauch);
  color: var(--hxpv-rot-hover);
  text-decoration: none;
}

.hxpv-knopf--sekundaer {
  border-color: var(--hxpv-linie-stark);
  background: var(--hxpv-kopf);
  color: var(--hxpv-text);
}

.hxpv-knopf--sekundaer:hover {
  background: var(--hxpv-linie-stark);
  color: var(--hxpv-text);
}

.hxpv-stern {
  margin-left: 2px;
  font-weight: 700;
}

.hxpv-pfeil {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  margin-left: 6px;
  vertical-align: -1px;
}

.hxpv-umschalter .hxpv-pfeil {
  transition: transform 200ms ease;
}

.hxpv-umschalter[aria-expanded='true'] .hxpv-pfeil {
  transform: rotate(180deg);
}

/* Fußzeile: Kennzeichnung, MwSt., Stand, Preisänderung */
.hxpv-fuss {
  margin: 12px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--hxpv-linie);
  font-size: 12px;
  line-height: 1.5;
  color: var(--hxpv-text-sekundaer);
}

.hxpv-fuss a {
  color: var(--hxpv-rot);
  font-weight: 600;
}

.hxpv-fuss a:hover {
  color: var(--hxpv-rot-hover);
}

/* Tabellen (§4.3) — gemeinsame Grundregeln */
.hxpv-tabelle {
  width: 100%;
  margin: 0;
  border: 0;
  border-collapse: collapse;
  font-size: 14px;
  color: var(--hxpv-text);
}

.hxpv-tabelle th,
.hxpv-tabelle td {
  padding: 8px 10px;
  border: 0;
  border-top: 1px solid var(--hxpv-linie);
  background: var(--hxpv-flaeche);
  color: var(--hxpv-text);
  text-align: left;
  vertical-align: middle;
}

.hxpv-tabelle thead th {
  background: var(--hxpv-kopf);
  border-top: 0;
  font-size: 12px;
  font-weight: 600;
}

.hxpv-tabelle tbody tr:nth-child(even) > * {
  background: var(--hxpv-kasten);
}

@media (prefers-reduced-motion: reduce) {
  .hxpv * {
    transition: none !important;
  }
}

/* Variante B — Händlerkarten */

.hxpv-b-karten {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Gemeinsame Zeilen für Logo, Preis, Preishinweis, Status und Aktion. */
.hxpv-b-karte {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 5;
  align-items: start;
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--hxpv-linie);
  background: var(--hxpv-kasten);
}

/* Niedrigster Preis: Dezenter Rahmen und Kennzeichnung */
.hxpv-b-karte--niedrigster {
  border-color: var(--hxpv-linie-stark);
}

.hxpv-b-kopf p {
  margin: 0;
}

/* Logo-Feld: wie im Ist-Template ohne eigene Fläche; NBB und Geizhals bringen ihren Grund mit,
   Caseking hat im Dunkelmodus eine helle Logo-Datei (caseking_dark.png) */
.hxpv-b-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 38px;
  min-width: 0;
  margin: 0;
}

.hxpv-b-kopf { grid-row: 1; min-width: 0; }

.hxpv-b-logo img {
  display: block;
  width: auto;
  min-width: 0;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
}


.hxpv-b-name {
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.hxpv .hxpv-b-zusatz {
  font-size: 12px;
  line-height: 1.25;
  color: var(--hxpv-text-sekundaer);
}

.hxpv .hxpv-b-preiszeile {
  grid-row: 2;
  margin: 5px 0 0;
  line-height: 1.3;
  align-self: baseline;
}

.hxpv-b-preis {
  font-size: 19px;
  line-height: 1.3;
}

.hxpv-b-preis.hxpv-preis--leer {
  font-size: 14px;
}

.hxpv-b-karte > .hxpv-niedrigster {
  grid-row: 3;
  justify-self: start;
  margin-top: 4px;
  white-space: normal;
}

.hxpv-b-status {
  grid-row: 4;
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.4;
}

.hxpv-b-aktion {
  grid-row: 5;
  align-self: stretch;
  display: grid;
  padding-top: 9px;
}

.hxpv-b-aktion .hxpv-knopf {
  display: block;
  align-content: center;
  width: 100%;
  padding: 7px 8px;
}

.hxpv-b-alle {
  margin-top: 14px;
}

.hxpv-b-alle-titel {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--hxpv-text-sekundaer);
}

.hxpv-b-angebote {
  margin: 0;
  padding: 0;
  list-style: none;
}

.hxpv-b-angebot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) 92px 210px;
  grid-template-areas: 'shop status preis aktion';
  align-items: center;
  gap: 4px 16px;
  padding: 10px 8px;
  border-top: 1px solid var(--hxpv-linie);
}

.hxpv-b-angebot:nth-child(even) {
  background: var(--hxpv-kasten);
}

.hxpv-b-angebot-shop { grid-area: shop; font-weight: 600; overflow-wrap: anywhere; }
.hxpv-b-angebot-status { grid-area: status; font-size: 14px; }
.hxpv-b-angebot-preis { grid-area: preis; text-align: right; }
.hxpv-b-angebot-aktion { grid-area: aktion; }

.hxpv-b-angebot-aktion .hxpv-knopf {
  width: 100%;
  min-width: 0;
  max-width: none;
}

/* Mittel: Karten zweispaltig, Geizhals-Karte über die ganze Breite */
@container hxpv (max-width: 600px) {
  .hxpv-b-karten {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hxpv-b-karte:last-child {
    grid-column: 1 / -1;
    margin-top: 8px;
  }

  /* Angebotszeilen: unter 600 px zu schmal für vier Spalten, daher gestapelt (Name | Preis, Status, Knopf) */
  .hxpv-b-angebot {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'shop preis'
      'status status'
      'aktion aktion';
  }
}

/* Schmal: Karten untereinander, Name links und Preis rechts */
@container hxpv (max-width: 440px) {
  .hxpv-b-karten {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .hxpv-b-karte {
    grid-row: auto;
    grid-template-rows: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'kopf preis'
      'hinweis hinweis'
      'status status'
      'aktion aktion';
    gap: 4px 10px;
    padding: 10px;
  }

  .hxpv-b-karte:last-child { margin-top: 0; }
  .hxpv-b-kopf { grid-area: kopf; }
  .hxpv-b-logo { justify-content: flex-start; }
  .hxpv .hxpv-b-preiszeile { grid-area: preis; text-align: right; }
  .hxpv-b-karte > .hxpv-niedrigster { grid-area: hinweis; }
  .hxpv-b-status { grid-area: status; }
  .hxpv-b-aktion { grid-area: aktion; padding-top: 4px; }

  .hxpv-b-preis {
    font-size: 17px;
  }

  .hxpv-b-angebot {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'shop preis'
      'status status'
      'aktion aktion';
    padding: 10px 4px;
  }

  .hxpv-b-angebot-aktion .hxpv-knopf {
    width: 100%;
    max-width: none;
  }
}
/* Dunkelmodus: Logo-Dateien sind für hellen Grund gemacht */
.theme-dark .hxpv-b-logo img {
  padding: 3px 8px;
  background: #ffffff;
}


/* Hinweistext als Mouseover: kurze Kennzeichnung bleibt sichtbar, der lange Text erscheint bei Hover, Fokus und Tipp */
.hxpv-fuss-kurz {
  margin-right: 6px;
}

.hxpv-hinweis {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.hxpv-hinweis-knopf {
  box-sizing: border-box;
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--hxpv-linie-stark);
  border-radius: 50%;
  background: var(--hxpv-kasten);
  color: var(--hxpv-text);
  font: italic 700 13px/1 Georgia, 'Times New Roman', serif;
  cursor: help;
}

.hxpv-hinweis-knopf:hover,
.hxpv-hinweis-knopf:focus-visible {
  border-color: var(--hxpv-rot);
  color: var(--hxpv-rot);
}

.hxpv-hinweis-text {
  position: absolute;
  z-index: 5;
  bottom: calc(100% + 8px);
  left: 0;
  box-sizing: border-box;
  width: min(420px, calc(100cqw - 32px));
  padding: 10px 12px;
  border: 1px solid var(--hxpv-linie-stark);
  background: var(--hxpv-flaeche);
  box-shadow: var(--hxpv-schatten);
  color: var(--hxpv-text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.12s;
}

.hxpv-hinweis:hover .hxpv-hinweis-text,
.hxpv-hinweis-knopf:focus-visible + .hxpv-hinweis-text,
.hxpv-hinweis.is-offen .hxpv-hinweis-text {
  visibility: visible;
  opacity: 1;
}
