/* hilfe.css – KI-Assistent und WhatsApp für den Stuckdiscount-Entwurf.
   Lädt NACH css/entwurf.css. Alle Elemente erzeugt js/hilfe.js; ohne Skript bleibt die Seite, wie sie ist.
   Regeln des Auftrags: Schrift mind. 17 px, Klickflächen mind. 44 px, hohe Kontraste,
   nichts Schwebendes über Hauptknopf, Handy-Leiste, Fußbereich-Text oder geöffneten Dialogen.
   Ebenen: Handy-Leiste 40 < schwebende Knöpfe 45 < Kopfzeile 50/51 < Chat-Fenster 60 < <dialog> der Seiten (oberster Stapel). */

/* 1. Handy-Leiste mit vier Zielen (Anrufen · WhatsApp · Katalog · Anfrage).
      hilfe.js setzt die Klasse actionbar--4; die Spalten richten sich nach der Wortlänge. */
@media (max-width: 639px) {
  .actionbar.actionbar--4 { grid-auto-flow: row; grid-template-columns: repeat(4, auto); gap: 6px; padding-inline: 12px; }
  .actionbar.actionbar--4 .btn { min-width: 0; padding-inline: 6px; font-size: 17px; }
}
@media (max-width: 389px) {
  .actionbar.actionbar--4 { padding-inline: 8px; }
  .actionbar.actionbar--4 .btn { padding-inline: 4px; font-size: 16px; }
}
@media (max-width: 349px) {
  .actionbar.actionbar--4 { gap: 4px; padding-inline: 6px; }
  .actionbar.actionbar--4 .btn { padding-inline: 2px; font-size: 15px; }
}

/* 2. Ecke unten rechts: Startknopf des Assistenten, am PC darunter der WhatsApp-Knopf.
      --hilfe-hub hebt die Ecke am PC über den Text des Fußbereichs (setzt hilfe.js beim Scrollen). */
.hilfe-ecke {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 45;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
  pointer-events: none; transition: opacity 200ms ease, visibility 0s;
}
.hilfe-ecke > * { pointer-events: auto; }
.hilfe-ecke.is-weg { opacity: 0; visibility: hidden; transition: opacity 200ms ease, visibility 0s 200ms; }
/* offenes Menü der Kopfzeile, offenes Chat-Fenster: keine schwebenden Knöpfe */
:root:has(.nav.is-open) .hilfe-ecke, .hilfe-ecke.is-offen { display: none; }
/* Handy: über der festen Leiste, sobald sie zu sehen ist */
@media (max-width: 639px) {
  body:has(> nav.actionbar:is([data-bar="shown"], [data-bar="always"])) .hilfe-ecke { bottom: calc(64px + 12px + env(safe-area-inset-bottom)); }
}
@media (min-width: 1024px) {
  .hilfe-ecke { right: 24px; bottom: calc(24px + var(--hilfe-hub, 0px)); transition: opacity 160ms ease, visibility 0s; }
}

/* Startknopf: am Handy/Tablet rund mit Sprechblase, am PC beschriftet mit Bild */
.hilfe-start {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 52px; height: 52px; padding: 0; border: 2px solid var(--p-bg); border-radius: 999px;
  background: var(--p-ink); color: var(--p-bg); font: 500 17px/1.2 var(--font-text); cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in oklab, var(--p-ink) 28%, transparent);
}
.hilfe-start:hover { background: color-mix(in oklab, var(--p-ink) 88%, var(--p-bg)); }
.hilfe-start:focus-visible, .hilfe-wa:focus-visible { outline: 3px solid var(--p-ink); outline-offset: 3px; }
.hilfe-start__bild { display: none; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; background: var(--p-surface); }
.hilfe-start__blase { width: 26px; height: 26px; flex: none; }
.hilfe-start__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (min-width: 1024px) {
  .hilfe-start { width: auto; height: 56px; padding: 0 22px 0 8px; }
  .hilfe-start__bild { display: block; }
  .hilfe-start__bild + .hilfe-start__blase { display: none; }
  .hilfe-start:not(:has(.hilfe-start__bild)) { padding-left: 18px; }
  .hilfe-start__text { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
}

/* PC bis 1699 px: Der Seitenrand ist schmaler als der beschriftete Knopf – er würde Produktkarten
   verdecken. Dort deshalb rund im Rand (56 px, Bild), Beschriftung erst beim Überfahren/Fokus. */
@media (min-width: 1024px) and (max-width: 1699px) {
  .hilfe-start { position: relative; width: 56px; padding: 0; }
  .hilfe-start__text {
    position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    width: auto; height: auto; overflow: visible; clip-path: none;
    padding: 8px 12px; border-radius: var(--r-btn, 8px); background: var(--p-ink); color: var(--p-bg);
    white-space: nowrap; opacity: 0; visibility: hidden; pointer-events: none;
  }
  .hilfe-start:hover .hilfe-start__text, .hilfe-start:focus-visible .hilfe-start__text { opacity: 1; visibility: visible; }
  .hilfe-start:not(:has(.hilfe-start__bild)) { padding-left: 0; }
}

/* WhatsApp-Knopf: nur am PC; am Handy steht WhatsApp in der Leiste */
.hilfe-wa { display: none; }
@media (min-width: 1024px) {
  .hilfe-wa {
    position: relative; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
    background: #25d366; color: #fff; border: 2px solid var(--p-bg);
    box-shadow: 0 6px 18px color-mix(in oklab, var(--p-ink) 28%, transparent);
  }
  .hilfe-wa:hover { background: #1fbe5a; }
  .hilfe-wa svg { width: 32px; height: 32px; display: block; }
  .hilfe-wa__text {
    position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    padding: 8px 12px; border-radius: var(--r-btn, 8px); background: var(--p-ink); color: var(--p-bg);
    font: 500 17px/1.2 var(--font-text); white-space: nowrap; opacity: 0; visibility: hidden; pointer-events: none;
  }
  .hilfe-wa:hover .hilfe-wa__text, .hilfe-wa:focus-visible .hilfe-wa__text { opacity: 1; visibility: visible; }
}

/* 3. Chat-Fenster: Handy als Vollbild-Blatt, ab 640 px als Tafel unten rechts */
.hilfe-fenster {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column;
  background: var(--p-bg); color: var(--p-ink); font: 400 17px/1.5 var(--font-text); overflow: hidden;
}
.hilfe-fenster[hidden] { display: none; }
.hilfe-fenster:focus { outline: none; }
@media (max-width: 639px) { html.hilfe-offen { overflow: hidden; } }
@media (min-width: 640px) {
  .hilfe-fenster {
    inset: auto 24px 24px auto; width: 400px; max-width: calc(100vw - 48px);
    height: 620px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
    border: 1px solid color-mix(in oklab, var(--p-ink) 35%, transparent); border-radius: var(--r-lg, 20px);
    box-shadow: 0 18px 48px color-mix(in oklab, var(--p-ink) 30%, transparent);
  }
}
.hilfe-kopf { flex: none; display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); background: var(--p-ink); color: var(--p-inv-ink, #faf7f2); }
.hilfe-kopf__bild { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; background: var(--p-surface); }
.hilfe-kopf h2 { flex: 1; min-width: 0; margin: 0; font: 500 19px/1.25 var(--font-text); letter-spacing: 0; color: inherit; }
.hilfe-zu {
  flex: none; min-height: 44px; padding: 0 14px; border: 1px solid color-mix(in oklab, var(--p-inv-ink, #faf7f2) 70%, transparent);
  border-radius: var(--r-btn, 8px); background: transparent; color: inherit; font: 500 17px/1.2 var(--font-text); cursor: pointer;
}
.hilfe-zu:hover { background: color-mix(in oklab, var(--p-inv-ink, #faf7f2) 14%, transparent); }
.hilfe-zu:focus-visible { outline: 3px solid var(--p-inv-ink, #faf7f2); outline-offset: 2px; }
.hilfe-hinweis { flex: none; margin: 0; padding: 8px 16px; background: var(--p-surface); color: var(--p-ink); font-size: 17px; line-height: 1.4; border-bottom: 1px solid color-mix(in oklab, var(--p-ink) 14%, transparent); }

.hilfe-verlauf { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
.hilfe-msg { max-width: 90%; padding: 10px 14px; border-radius: 14px; overflow-wrap: anywhere; }
.hilfe-msg p { margin: 0; }
.hilfe-msg p + p { margin-top: 8px; }
.hilfe-msg--bot { background: var(--p-surface); border-bottom-left-radius: 4px; }
.hilfe-msg--ich { align-self: flex-end; background: var(--p-ink); color: var(--p-bg); border-bottom-right-radius: 4px; }
.hilfe-msg--meldung { max-width: 100%; align-self: stretch; background: var(--p-bg); border: 1px solid color-mix(in oklab, var(--p-ink) 55%, transparent); border-radius: var(--r-md, 12px); font-weight: 500; }
.hilfe-msg--meldung .hilfe-auswege { padding: 12px 0 2px; }
.hilfe-schreibt { color: var(--p-muted); font-style: normal; }

.hilfe-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hilfe-chip {
  min-height: 44px; padding: 8px 16px; border: 1px solid color-mix(in oklab, var(--p-ink) 55%, transparent); border-radius: 999px;
  background: var(--p-bg); color: var(--p-ink); font: 500 17px/1.3 var(--font-text); text-align: left; cursor: pointer;
}
.hilfe-chip:hover { background: var(--p-surface); }
.hilfe-produkt { align-self: stretch; display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 8px; border: 1px solid color-mix(in oklab, var(--p-ink) 30%, transparent); border-radius: var(--r-md, 12px); background: var(--p-bg); color: var(--p-ink); text-decoration: none; }
.hilfe-produkt:hover { border-color: var(--p-ink); }
.hilfe-produkt img { width: 64px; height: 64px; flex: none; object-fit: contain; border-radius: var(--r-sm, 8px); background: var(--p-surface); }
.hilfe-produkt__text { min-width: 0; display: grid; gap: 2px; line-height: 1.35; }
.hilfe-produkt__nr { font-weight: 500; text-decoration: underline; text-underline-offset: 4px; }
.hilfe-produkt__neben { color: var(--p-muted); }
.hilfe-produkt__preis { font-weight: 500; }
.hilfe-fenster .hilfe-knopf { height: auto; min-height: 48px; padding-block: 8px; white-space: normal; text-align: center; font-size: 17px; line-height: 1.25; }

.hilfe-form { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 12px 16px 8px; border-top: 1px solid color-mix(in oklab, var(--p-ink) 14%, transparent); }
.hilfe-form textarea {
  flex: 1; min-width: 0; min-height: 48px; max-height: 120px; padding: 11px 12px; resize: none;
  border: 1px solid color-mix(in oklab, var(--p-ink) 55%, transparent); border-radius: var(--r-btn, 8px);
  background: color-mix(in oklab, var(--p-bg) 40%, white); color: var(--p-ink); font: 400 17px/1.4 var(--font-text);
}
.hilfe-form textarea::placeholder { color: var(--p-muted); opacity: 1; }
.hilfe-form textarea:focus-visible { outline: 3px solid var(--p-ink); outline-offset: 1px; }
.hilfe-form .btn { flex: none; font-size: 17px; padding-inline: 16px; }
.hilfe-form .btn:disabled { opacity: .55; cursor: default; }
.hilfe-falle { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.hilfe-nur-vorlesen { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* die drei Auswege: Anfrage stellen · Anrufen · WhatsApp */
.hilfe-auswege { flex: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px calc(12px + env(safe-area-inset-bottom)); }
.hilfe-auswege .btn { flex: 1 1 auto; height: 44px; padding-inline: 10px; font-size: 17px; }

@media (prefers-reduced-motion: reduce) { .hilfe-ecke, .hilfe-ecke.is-weg { transition: none; } }
@media print { .hilfe-ecke, .hilfe-fenster { display: none !important; } }
