/* FW Popovers (Lieferkette/Partner/Patterns)
 * Styling-Fokus: Single-Firmen Header (Chips) + Popover-Karten.
 * - Theme-Primary aware (var(--color-primary))
 * - Gute Lesbarkeit auf hellen/dunklen Hintergründen
 * - Mobile: "Bottom Sheet"-Feeling
 */

:root{
  /* Neve Theme: nutzt vorrangig Neve CSS-Variablen (mit Fallbacks) */
  --fw-pop-primary: var(--nv-primary-accent, var(--color-primary, #2f5daa));
  --fw-pop-text: var(--nv-text-color, #141414);
  --fw-pop-muted: color-mix(in srgb, var(--fw-pop-text) 62%, transparent);
  --fw-pop-border: color-mix(in srgb, var(--fw-pop-text) 12%, transparent);
  --fw-pop-shadow: 0 22px 70px rgba(0,0,0,.22);
  --fw-pop-radius: 18px;
  --fw-pop-radius-sm: 14px;
  --fw-pop-bg: color-mix(in srgb, var(--nv-site-bg, #ffffff) 88%, transparent);
  --fw-pop-bg-2: color-mix(in srgb, var(--nv-site-bg, #ffffff) 76%, transparent);
}

/* Fallback wenn color-mix nicht verfügbar */
@supports not (color-mix(in srgb, #000 50%, #fff)){
  :root{
    --fw-pop-muted: rgba(0,0,0,.62);
    --fw-pop-border: rgba(0,0,0,.10);
    --fw-pop-bg: rgba(255,255,255,.92);
    --fw-pop-bg-2: rgba(255,255,255,.78);
  }
}

/* ---------------- Chips row ---------------- */
.fw-profile-modules{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  margin:12px 0 18px 0;
  align-items:center;
}

.fw-popover-host{ position:relative; display:inline-flex; }

.fw-module-chip{
  appearance:none;
  border:1px solid var(--fw-pop-border);
  background: var(--fw-pop-bg);
  color: var(--fw-pop-text);
  border-radius: 999px;
  padding: 11px 14px;
  font: inherit;
  cursor: pointer;
  display:inline-flex;
  align-items:center;
  gap:10px;
  line-height:1;
  font-weight: 800;
  letter-spacing: .01em;
  box-shadow: 0 10px 26px rgba(0,0,0,.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translateZ(0);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}

.fw-module-chip i{
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.06);
  color: var(--fw-pop-primary);
  flex: 0 0 auto;
}

.fw-chip-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .02em;
  background: rgba(0,0,0,.08);
  color: rgba(0,0,0,.72);
}

.fw-module-chip[aria-expanded="true"] .fw-chip-badge{
  background: rgba(255,255,255,.25);
  color: rgba(255,255,255,.95);
}

.fw-module-chip .fw-chip-meta{
  font-size: 12px;
  font-weight: 900;
  color: rgba(0,0,0,.55);
}

.fw-module-chip .fw-chip-caret{
  margin-left: 6px;
  opacity: .55;
  font-weight: 900;
  transform: translateY(-1px);
}

.fw-module-chip:hover{
  background: rgba(255,255,255,.92);
  border-color: rgba(0,0,0,.14);
  box-shadow: 0 14px 34px rgba(0,0,0,.12);
  transform: translateY(-1px);
}

.fw-module-chip:focus{
  outline: 3px solid color-mix(in srgb, var(--fw-pop-primary) 28%, transparent);
  outline-offset: 2px;
}

@supports not (color-mix(in srgb, #000 50%, #fff)){
  .fw-module-chip:focus{ outline: 3px solid rgba(47,93,170,.28); }
}

.fw-module-chip[aria-expanded="true"]{
  background: color-mix(in srgb, var(--fw-pop-primary) 14%, transparent);
  border-color: color-mix(in srgb, var(--fw-pop-primary) 35%, transparent);
}

.fw-module-chip[aria-expanded="true"] i{
  background: color-mix(in srgb, var(--fw-pop-primary) 14%, transparent);
}

/* Backwards compatibility: older templates sometimes set --light */
.fw-module-chip--light{ }

/* ---------------- Popover panel ---------------- */
.fw-popover{
  position:absolute;
  top: calc(100% + 12px);
  left: 50%;
  transform: translateX(calc(-50% + var(--fw-pop-shift, 0px))) translateY(6px) scale(.98);
  z-index: 9999;
  width: min(540px, calc(100vw - 32px));
  max-width: 540px;
  background: var(--fw-pop-bg);
  color: var(--fw-pop-text);
  border: 1px solid rgba(0,0,0,.10);
  border-radius: var(--fw-pop-radius);
  box-shadow: var(--fw-pop-shadow);
  padding: 14px 14px 12px 14px;
  display:none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.fw-popover.is-open{
  display:block;
  animation: fwPopIn .16s ease-out forwards;
}

@keyframes fwPopIn{
  from{ opacity:0; transform: translateX(calc(-50% + var(--fw-pop-shift, 0px))) translateY(8px) scale(.98); }
  to{ opacity:1; transform: translateX(calc(-50% + var(--fw-pop-shift, 0px))) translateY(0) scale(1); }
}

/* Arrow */
.fw-popover::after{
  content:"";
  position:absolute;
  top:-8px;
  left: calc(50% - var(--fw-pop-shift, 0px));
  width: 16px;
  height: 16px;
  background: var(--fw-pop-bg);
  border-left: 1px solid rgba(0,0,0,.10);
  border-top: 1px solid rgba(0,0,0,.10);
  transform: translateX(-50%) rotate(45deg);
}

/* subtle background grid */
.fw-popover::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius: var(--fw-pop-radius);
  background-image:
    linear-gradient(90deg, rgba(0,0,0,.03) 1px, transparent 1px),
    linear-gradient(rgba(0,0,0,.03) 1px, transparent 1px);
  background-size: 16px 16px;
  opacity: .55;
  pointer-events:none;
}

.fw-popover > *{ position:relative; }

.fw-popover-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom: 8px;
}

.fw-popover-title{
  font-size: 15px;
  font-weight: 900;
  margin:0;
  letter-spacing: .01em;
}

.fw-popover-close{
  appearance:none;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.75);
  color: var(--fw-pop-text);
  cursor:pointer;
  font:inherit;
  padding: 6px 10px;
  border-radius: 12px;
  line-height: 1;
}

.fw-popover-close:hover{ background: rgba(0,0,0,.05); }

.fw-popover-body{
  font-size: 14px;
  line-height: 1.55;
  color: rgba(0,0,0,.78);
}

.fw-popover-body p{ margin: 0 0 10px 0; }
.fw-popover-body p:last-child{ margin-bottom: 0; }

.fw-popover-body .fw-mini-meta{
  font-size: 12px;
  color: rgba(0,0,0,.55);
  margin: 2px 0 10px 0;
}

.fw-popover ul{ margin:0; padding-left: 18px; }
.fw-popover a{ color: inherit; text-decoration: underline; text-decoration-color: rgba(0,0,0,.25); }
.fw-popover a:hover{ text-decoration-color: rgba(0,0,0,.65); }

/* ---------------- Patterns compact cards ---------------- */
.fw-popover .fw-patterns{ margin:0; }
.fw-popover .fw-patterns .fw-section-title{ display:none; }
.fw-popover .fw-pattern-grid{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }

.fw-popover .fw-pattern-card{
  background: rgba(255,255,255,.86);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: var(--fw-pop-radius-sm);
  overflow:hidden;
  box-shadow: 0 10px 24px rgba(0,0,0,.06);
}

.fw-popover .fw-pattern-media img,
.fw-popover .fw-pattern-thumb{
  display:block;
  width:100%;
  height:120px;
  object-fit:cover;
}

.fw-popover .fw-pattern-body{ padding:10px; }
.fw-popover .fw-pattern-title{ font-size: 13px; margin:0 0 6px 0; line-height:1.25; }
.fw-popover .fw-pattern-meta{ font-size: 12px; color: rgba(0,0,0,.55); margin-bottom: 8px; }

/* ---------------- Supplychain compact view ---------------- */
.fw-popover .fw-sc-compact{ display:grid; gap:12px; }
.fw-popover .fw-sc-compact-chain{
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(255,255,255,.70);
  border-radius: var(--fw-pop-radius-sm);
  padding: 10px;
}
.fw-popover .fw-sc-compact-title{ font-weight: 900; font-size: 13px; margin:0 0 8px 0; }
.fw-popover .fw-sc-compact-list{ margin:0; padding-left: 18px; }
.fw-popover .fw-sc-compact-list li{ margin:0 0 6px 0; line-height: 1.35; }
.fw-popover .fw-sc-step{ font-weight: 900; }
.fw-popover .fw-sc-sep{ opacity:.55; margin:0 6px; }
.fw-popover .fw-sc-link{ text-decoration: none; font-weight: 800; }
.fw-popover .fw-sc-link:hover{ text-decoration: underline; }
.fw-popover .fw-sc-more{ color: rgba(0,0,0,.55); font-size: 12px; list-style: disc; }

.fw-popover .fw-sc-full-toggle{
  margin-top: 12px;
  border-top: 1px solid rgba(0,0,0,.08);
  padding-top: 10px;
}

.fw-popover .fw-sc-full-toggle summary{
  cursor:pointer;
  font-weight: 900;
  color: var(--fw-pop-primary);
  list-style: none;
}
.fw-popover .fw-sc-full-toggle summary::-webkit-details-marker{ display:none; }
.fw-popover .fw-sc-full-toggle summary:after{
  content:"›";
  float:right;
  transform: rotate(90deg);
  opacity:.65;
}
details[open] > .fw-sc-full-toggle summary:after{ transform: rotate(-90deg); }

.fw-popover .fw-sc-full-body{ margin-top: 10px; }

.fw-popover .fw-btn{
  display:inline-block;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  text-decoration:none;
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(255,255,255,.85);
}
.fw-popover .fw-btn:hover{ background: rgba(0,0,0,.04); }

/* ---------------- Mobile (bottom sheet) ---------------- */
@media (max-width: 782px){
  .fw-profile-modules{ gap:10px; }
  .fw-module-chip{ width: 100%; justify-content: flex-start; }
  .fw-popover{
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    max-width: none;
    transform: translateY(10px);
    border-radius: 22px;
    padding: 14px;
  }
  .fw-popover.is-open{ animation: fwPopUp .18s ease-out forwards; }
  .fw-popover::after{ display:none; }
  @keyframes fwPopUp{
    from{ opacity:0; transform: translateY(18px); }
    to{ opacity:1; transform: translateY(0); }
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  .fw-module-chip{ transition: none; }
  .fw-popover.is-open{ animation: none; }
}
