/* Laag: framework. De rangorde staat in skeleton/templates/page.php:
 *   @layer framework, site, theme, type, item;
 * Alles wat het framework meestuurt zit in de onderste laag, zodat site-CSS en CMS-opmaak
 * ervan winnen zonder specificiteits-trucs. Binnen deze laag telt specificiteit gewoon, dus
 * de onderlinge verhouding tussen framework-bestanden verandert er niet door.
 *
 * Een bestand dat deze wikkel MIST staat buiten elke laag en wint daarmee van ALLES —
 * ook van het CMS. `tests/Framework/CodeStyle/ModuleCssIsLayeredTest.php` bewaakt dat. */
@layer framework {
/* Drijvende WhatsApp-chatwidget (rechtsonder): ronde knop + optionele label-pill die
   een chatpopup opent. Thema-onafhankelijk met var()-fallbacks; de merk-kleur komt via
   --wa-color (inline op de root), met WhatsApp-groen als terugval. De popup-achtergrond
   is nooit transparant. */

.wa-chat {
  --wa-color: var(--color-accent, var(--accent, #25d366));
  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right, 0px));
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  z-index: 190; /* onder de edit-FAB (200), boven de content */
  font-family: inherit;
}

/* Scroll-gated widgets starten onzichtbaar en schuiven in beeld zodra zichtbaar. */
.wa-chat[data-scroll-gated] {
  transform: translateY(200%);
  transform-origin: right bottom;
  transition: transform .4s ease;
}
.wa-chat[data-scroll-gated][data-visible] {
  transform: none;
}

/* ── Launcher: label-pill + ronde knop ─────────────────────────────────── */
.wa-chat__launcher {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .6rem;
}

.wa-chat__label {
  all: unset;
  cursor: pointer;
  background: var(--wa-color);
  color: #fff;
  border-radius: 25px;
  padding: .55rem 1rem;
  font-size: .9rem;
  line-height: 1.2;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
  white-space: nowrap;
}

.wa-chat__button {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--wa-color);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22), 0 2px 6px rgba(0, 0, 0, .14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.wa-chat__button:hover,
.wa-chat__button:focus-visible {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .28), 0 3px 8px rgba(0, 0, 0, .16);
}
.wa-chat__button:focus-visible,
.wa-chat__label:focus-visible {
  outline: 3px solid rgba(255, 255, 255, .7);
  outline-offset: 3px;
}
.wa-chat__button-icon {
  display: block;
  width: 2.1rem;
  height: 2.1rem;
  pointer-events: none;
}

/* ── Popup-paneel ──────────────────────────────────────────────────────── */
.wa-chat__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 95vw;
  max-width: 350px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff; /* nooit transparant */
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
  transform: scale(0);
  transform-origin: right bottom;
  transition: transform .25s ease, opacity .25s ease;
  opacity: 0;
  pointer-events: none;
}
.wa-chat[data-open] .wa-chat__panel {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.wa-chat__header {
  position: relative;
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: 1rem 1.1rem;
  color: #fff;
  background: linear-gradient(
    290deg,
    color-mix(in srgb, var(--wa-color) 88%, #000) 0%,
    color-mix(in srgb, var(--wa-color) 88%, #fff) 100%
  );
}
/* Terugval voor browsers zonder color-mix. */
@supports not (background: color-mix(in srgb, red, blue)) {
  .wa-chat__header { background: var(--wa-color); }
}

.wa-chat__avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, .25);
}
.wa-chat__titles { flex: 1 1 auto; min-width: 0; }
.wa-chat__title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
}
.wa-chat__subtitle {
  font-size: .82rem;
  opacity: .85;
  margin-top: .1rem;
}

.wa-chat__close {
  all: unset;
  cursor: pointer;
  position: absolute;
  top: .55rem;
  right: .6rem;
  width: 1.6rem;
  height: 1.6rem;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.wa-chat__close:hover { background: rgba(255, 255, 255, .18); }
.wa-chat__close:focus-visible { outline: 2px solid rgba(255, 255, 255, .8); }
.wa-chat__close-icon { width: .8rem; height: .8rem; display: block; }

.wa-chat__body {
  background: #efe7de; /* WhatsApp-achtige chat-achtergrond, niet transparant */
  padding: 1.1rem;
  min-height: 130px;
}
.wa-chat__bubble {
  display: inline-block;
  max-width: 85%;
  background: #fff;
  padding: .55rem .8rem .35rem;
  border-radius: 0 10px 10px 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.wa-chat__bubble-text {
  font-size: .93rem;
  line-height: 1.5;
  color: #1a1a1a;
}
.wa-chat__time {
  font-size: .72rem;
  color: #888;
  text-align: right;
  margin-top: .15rem;
}

.wa-chat__footer {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem;
  background: #f4f4f4;
}
.wa-chat__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: .7rem .9rem;
  border: 0;
  border-radius: 22px;
  outline: 0;
  font-size: .95rem;
  background: #fff;
  color: #1a1a1a;
}
.wa-chat__input:focus-visible {
  box-shadow: 0 0 0 2px var(--wa-color);
}
.wa-chat__send {
  flex: 0 0 auto;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: var(--wa-color);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.wa-chat__send:hover { filter: brightness(1.06); }
.wa-chat__send:focus-visible { outline: 3px solid rgba(0, 0, 0, .25); outline-offset: 2px; }
.wa-chat__send-icon { width: 1.3rem; height: 1.3rem; display: block; }

@media (max-width: 480px) {
  .wa-chat {
    right: max(1rem, env(safe-area-inset-right, 0px));
    bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  }
  .wa-chat__button { width: 3.25rem; height: 3.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .wa-chat[data-scroll-gated],
  .wa-chat__panel,
  .wa-chat__button {
    transition: none;
  }
}
}
