/* orbita:hilfe-chat - the help button at the bottom right, its panel and the
   open card of a new team message (components/hilfe_chat.html,
   static/js/hilfe-chat.js, docs/orbita/HILFE-CHAT.md).

   Colours only through the tokens, so the dark theme follows by itself.
   Below the overlays (--z-overlay 800): a dialog or the tour always covers it.
   Open and close: fade + zoom from 95 %, 200 ms. */

.hc {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 700;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
  font-family: var(--font-sans);
}
.hc[hidden] { display: none; }
.hc > * { pointer-events: auto; }

/* -- the button ------------------------------------------------------------ */
.hc-knopf {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  /* fixed blues: in the dark theme --blue-700 turns light */
  background: linear-gradient(140deg, #4A74FF, #2A5BFF 55%, #1F49D9);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 26px -8px rgba(42, 91, 255, 0.6), 0 2px 6px rgba(15, 27, 61, 0.18);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.hc-knopf:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -8px rgba(42, 91, 255, 0.7), 0 2px 6px rgba(15, 27, 61, 0.18); }
.hc-knopf:active { transform: scale(0.96); }
.hc-knopf:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring), 0 10px 26px -8px rgba(42, 91, 255, 0.6); }
.hc-knopf svg {
  grid-area: 1 / 1;
  width: 26px;
  height: 26px;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.hc-knopf-zu { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.hc.is-offen .hc-knopf-auf { opacity: 0; transform: rotate(90deg) scale(0.6); }
.hc.is-offen .hc-knopf-zu { opacity: 1; transform: none; }
.hc-punkt {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--error);
  border: 2px solid var(--card);
}
.hc-punkt[hidden] { display: none; }

/* -- the small round buttons in the head and on the card ------------------- */
.hc-x {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.hc-x svg { width: 16px; height: 16px; }
.hc-x:hover { background: var(--menu-hover); color: var(--text); }
.hc-x:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.hc-x[hidden] { display: none; }

/* -- the panel ------------------------------------------------------------- */
@keyframes hc-auf { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes hc-zu  { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(0.95); } }

.hc-panel {
  width: 380px;
  height: min(600px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform-origin: bottom right;
  animation: hc-auf 200ms var(--ease-out) both;
}
.hc-panel[hidden] { display: none; }
.hc-panel.is-zu, .hc-team.is-zu { animation: hc-zu 200ms var(--ease-out) both; }

.hc-kopf {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px 14px 16px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(260px 120px at 100% 0%, rgba(34, 195, 240, 0.14), transparent 70%),
    linear-gradient(120deg, var(--blue-50), var(--card) 80%);
}
.hc-kopf h2 {
  flex: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.hc-kopf-ico {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
}
.hc-kopf-ico svg { width: 18px; height: 18px; }

.hc-koerper {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px 16px;
}
.hc-ansicht[hidden] { display: none; }

/* -- the list of guides ---------------------------------------------------- */
.hc-liste-kopf {
  margin: 2px 2px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.hc-treffer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 10px;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
}
.hc-treffer:hover, .hc-treffer:focus-visible {
  border-color: var(--blue-200);
  background: var(--hover-row);
  outline: none;
}
.hc-treffer > :not(.hc-treffer-pfeil) { grid-column: 1; }
.hc-treffer strong { font-size: 0.9rem; font-weight: 600; line-height: 1.35; }
.hc-art {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 2px;
}
.hc-art-faq { color: var(--success); }
.hc-art-seite { color: var(--text-muted); }
.hc-auszug {
  margin-top: 3px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hc-treffer-pfeil {
  grid-column: 2;
  grid-row: 1 / span 3;
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}
.hc-treffer:hover .hc-treffer-pfeil { color: var(--primary); }
.hc-leer { margin: 6px 2px; font-size: 0.86rem; color: var(--text-muted); }

/* -- the conversation ------------------------------------------------------ */
@keyframes hc-blase { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.hc-blase {
  max-width: 88%;
  margin-bottom: 10px;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  animation: hc-blase 200ms var(--ease-out) both;
}
.hc-blase p { margin: 0; color: inherit; font-size: inherit; line-height: inherit; white-space: pre-line; overflow-wrap: anywhere; }
.hc-frage {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.hc-antwort {
  background: var(--bg-inset);
  color: var(--text);
  border-bottom-left-radius: 5px;
}
.hc-fehler { background: var(--error-soft); color: var(--error-foreground); }
.hc-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.hc-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 11px 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--card);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.hc-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-link svg { width: 14px; height: 14px; flex-shrink: 0; }
.hc-link:hover, .hc-link:focus-visible { border-color: var(--primary); background: var(--blue-50); outline: none; }
.hc-blase-team { margin-top: 10px; }
.hc-denkt p { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.hc-punkte { display: inline-flex; gap: 3px; }
.hc-punkte i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: hc-punkt 1s var(--ease-inout) infinite;
}
.hc-punkte i:nth-child(2) { animation-delay: 0.15s; }
.hc-punkte i:nth-child(3) { animation-delay: 0.3s; }
@keyframes hc-punkt { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* -- talk to the team, and done -------------------------------------------- */
.hc-teamform { display: grid; gap: 10px; }
.hc-teamform .form-label { margin: 0; }
.hc-teamform textarea.form-control { min-height: 110px; }
/* P45: the screenshots for the team, compact inside the panel */
.hc-teamform .file-drop { padding: 14px 16px; min-height: 0; }
.hc-teamform-knoepfe { display: flex; justify-content: space-between; gap: 8px; }
.hc-fertig {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 36px 8px 12px;
  text-align: center;
  font-size: 0.95rem;
}
.hc-fertig[hidden] { display: none; }
.hc-fertig-ico {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--success-soft);
  color: var(--success);
  animation: hc-auf 200ms var(--ease-out) both;
}
.hc-fertig-ico svg { width: 26px; height: 26px; }

/* -- the field at the bottom ----------------------------------------------- */
.hc-fuss {
  padding: 10px 12px 10px;
  border-top: 1px solid var(--border);
  background: var(--card);
}
.hc-fuss[hidden] { display: none; }
.hc-eingabe {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--bg-input);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.hc-eingabe:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.hc-eingabe-ico { display: grid; color: var(--text-dim); }
.hc-eingabe-ico svg { width: 16px; height: 16px; }
.hc-feld {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}
.hc-feld::placeholder { color: var(--text-dim); }
.hc-senden {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 0;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: background var(--dur-fast), opacity var(--dur-fast);
}
.hc-senden svg { width: 18px; height: 18px; }
.hc-senden:hover:not(:disabled) { background: var(--primary-hover); }
.hc-senden:disabled { background: var(--slate-200); color: var(--slate-400); cursor: default; }
.hc-teamlink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0 2px;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.hc-teamlink svg { width: 14px; height: 14px; }
.hc-teamlink:hover { color: var(--primary); }
.hc-teamlink:focus-visible { outline: none; color: var(--primary); text-decoration: underline; }

/* -- the open card of a new team message ----------------------------------- */
.hc-team {
  position: relative;
  width: 340px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 44px 14px 14px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform-origin: bottom right;
  animation: hc-auf 200ms var(--ease-out) both;
}
.hc-team[hidden] { display: none; }
.hc-team > .hc-x { position: absolute; top: 8px; right: 8px; }
.hc-team-ico {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--blue-50);
  color: var(--primary);
}
.hc-team-ico svg { width: 18px; height: 18px; }
.hc-team-text { min-width: 0; font-size: 0.86rem; line-height: 1.45; }
.hc-team-text strong { display: block; font-size: 0.9rem; font-weight: 600; }
.hc-team-betreff { display: block; margin-top: 1px; color: var(--text-muted); font-weight: 600; font-size: 0.8rem; overflow-wrap: anywhere; }
.hc-team-vorschau {
  margin: 8px 0 12px;
  color: var(--text);
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hc-team-vorschau:empty { display: none; }

/* -- room for the button on the page --------------------------------------- */
body.hat-hilfe .main-content > footer { padding-bottom: 90px; }
body.hat-hilfe .toast-container { bottom: calc(92px + env(safe-area-inset-bottom)); }

@media (max-width: 640px) {
  .hc { right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); }
  /* a bottom sheet: the whole width, from the bottom edge up */
  .hc-panel {
    position: fixed;
    left: 0;
    right: 0;
    /* Q37: --hc-unten and --hc-sicht come from the visual viewport (hilfe-chat.js): with the
       keyboard up the sheet stands on it and takes the visible height, never more */
    bottom: var(--hc-unten, 0px);
    width: auto;
    height: min(86dvh, 640px, calc(var(--hc-sicht, 100dvh) - 12px));
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    transform-origin: bottom center;
  }
  .hc-fuss { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  /* the keyboard covers the home indicator: no safe-area gap above it */
  .hc-tastatur .hc-fuss { padding-bottom: 10px; }
  /* while typing the conversation gets the room: a slimmer head, the team link comes back
     with the keyboard down */
  .hc-tastatur .hc-kopf { padding-block: 8px; }
  .hc-tastatur .hc-teamlink { display: none; }
  .hc-feld { font-size: 16px; }  /* below 16px iOS zooms into the field */
  .hc.is-offen .hc-knopf { visibility: hidden; }
  /* the page behind the sheet dims; a tap on it closes the sheet (hilfe-chat.js) */
  .hc.is-offen::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(15, 27, 61, 0.32);
    pointer-events: auto;
    animation: fadeIn 200ms var(--ease-out) both;
  }
  .hc-team { width: calc(100vw - 32px); }
  body.hat-hilfe .toast-container { bottom: calc(84px + env(safe-area-inset-bottom)); }
  body.hat-hilfe .sammelleiste { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .hc-panel, .hc-team, .hc-blase, .hc-fertig-ico, .hc-panel.is-zu, .hc-team.is-zu { animation-duration: 1ms; }
  .hc-punkte i { animation: none; opacity: 0.6; }
}

@media print { .hc { display: none !important; } }
