/* ==========================================================================
   Zack KI — Test-Pill und Popup
   Uebernommen aus archive/website-drafts/zack-ki-website-v9. Ergaenzt um die Regeln des
   Auswahl-Werkzeugs, die dort noch im grossen Site-Stylesheet lagen.
   ========================================================================== */

/* ============================================================================
   Zack KI Website V9 — Test-Feature: „Zack KI testen“-Pill (wie khint.app)
   Pill unten rechts + App-Popup. Baut ausschließlich auf den V6-Stilen auf
   (site.css/appshot.css Variablen und Klassen); V6 selbst bleibt unberührt.
   ========================================================================== */

/* ------------------------------------------------------------------ */
/* Pill unten rechts                                                   */
/* ------------------------------------------------------------------ */
.zack-pill {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1420;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 13px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--bg);
  color: var(--fg);
  font: 600 0.9rem/1 "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.10),
    0 8px 24px rgba(0, 0, 0, 0.14);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.zack-pill:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.10),
    0 14px 34px rgba(0, 0, 0, 0.20),
    0 0 0 4px var(--accent-soft);
}

.zack-pill:active {
  transform: translateY(0);
  border-color: var(--accent);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    0 6px 18px rgba(0, 0, 0, 0.16),
    0 0 0 4px var(--accent-soft-strong);
}

.zack-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.zack-pill-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.zack-pill-icon svg {
  width: 15px;
  height: 15px;
}

.zack-pill-icon .zack-pill-bolt {
  fill: var(--accent);
}

.zack-pill-label {
  white-space: nowrap;
}

.zack-pill-label .brand-ki {
  color: var(--accent-text);
}

/* Tastatur-Hinweis in der Pill (wie „Try the khint palette“ + Shortcut) */
.zack-pill-keys {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border: 1px solid var(--edge);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--edge);
}

.zack-pill-keys kbd {
  font: 700 0.7rem/1 "Cascadia Code", "Consolas", ui-monospace, monospace;
  color: var(--fg-muted);
  letter-spacing: 0.02em;
}

/* Das Plus steht zwischen den Tasten, nicht in der „1“-Taste — wie man
   „Alt + 1“ auf einer echten Tastatur auch schreiben würde. */
.zack-pill-keys .zack-pill-plus {
  color: var(--fg-subtle);
  font: 600 0.7rem/1 "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}

/* Dezenter Aufmerksamkeits-Puls bis zur ersten Öffnung (wie bei khint) */
@keyframes zack-pill-glow {
  0%, 100% {
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.10),
      0 8px 24px rgba(0, 0, 0, 0.14);
  }
  50% {
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.10),
      0 8px 24px rgba(0, 0, 0, 0.14),
      0 0 0 6px var(--accent-soft);
  }
}

.zack-pill.is-attention {
  animation: zack-pill-glow 2.2s ease-in-out 3;
}

/* ------------------------------------------------------------------ */
/* Popup: Scrim + App-Fenster                                          */
/* ------------------------------------------------------------------ */
.zack-popup {
  position: fixed;
  inset: 0;
  z-index: 1440;
}

.zack-popup[hidden] {
  display: none;
}

.zack-popup-scrim {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 13, 0.42);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.zack-popup.is-open .zack-popup-scrim {
  opacity: 1;
}

.zack-popup-window {
  position: absolute;
  right: 20px;
  bottom: 86px;
  width: min(420px, calc(100vw - 32px));
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transform-origin: bottom right;
  transition:
    opacity 0.24s cubic-bezier(0.2, 0.8, 0.3, 1.1),
    transform 0.24s cubic-bezier(0.2, 0.8, 0.3, 1.1);
}

.zack-popup.is-open .zack-popup-window {
  opacity: 1;
  transform: none;
}

/* Das App-Fenster selbst: gleiche Optik wie die Hero-Demo (appshot.css).
   Kante und Radius aus den App-Tokens (--ca-*), damit Hell/Dunkel exakt
   dem Fenster der echten App entsprechen. */
.zack-popup-window .appshot {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: min(560px, calc(100dvh - 116px));
  border: 1px solid rgb(var(--ca-edge, 218 220 224));
  border-radius: var(--ca-r-window, 10px);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.16),
    0 28px 70px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

/* Das Popup ist ein echtes Bedienelement, keine Animations-Deko. Die globale
   Sperre für Nachbildungen (.appshot * { pointer-events: none } in stage.css)
   würde hier Eingabefeld, Chips und Titelleiste unbedienbar machen — deshalb
   bewusst wieder freigeben (höhere Spezifität, unabhängig von der
   Ladenreihenfolge). */
.zack-popup .appshot,
.zack-popup .appshot * {
  pointer-events: auto;
}

.zack-popup .appshot .select-text,
.zack-popup .appshot .composer-input {
  user-select: text;
  -webkit-user-select: text;
}

/* Minimieren: das Fenster kollabiert stärker Richtung unterer rechter Ecke
   (transform-origin bottom right) als beim normalen Schließen. */
.zack-popup.is-minimizing .zack-popup-window {
  opacity: 0;
  transform: translateY(48px) scale(0.5);
}

@supports not (height: 1dvh) {
  .zack-popup-window .appshot {
    height: min(560px, calc(100vh - 116px));
  }
}

/* Status-Zeile (z. B. „Screenshot wird erstellt …“, Fehler) — nur sichtbar,
   wenn das JavaScript sie mit Text füllt. */
.zack-hint {
  display: none;
  padding: 3px var(--ca-chat-gutter, 0.625rem) 0;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--fg-muted);
  text-align: center;
}

.zack-hint:not([hidden]) {
  display: block;
}

.zack-hint.is-error {
  color: var(--danger);
}

/* ------------------------------------------------------------------ */
/* Kleinere Screens                                                    */
/* ------------------------------------------------------------------ */
@media (max-width: 560px) {
  .zack-pill {
    right: 12px;
    bottom: 12px;
    padding: 9px 12px;
    font-size: 0.85rem;
  }

  .zack-pill-keys {
    display: none;
  }

  .zack-popup-window {
    right: 12px;
    left: 12px;
    bottom: 70px;
    width: auto;
  }

  .zack-popup-window .appshot {
    height: min(560px, calc(100dvh - 96px));
  }
}

/* ------------------------------------------------------------------ */
/* Reduzierte Bewegung                                                 */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .zack-pill,
  .zack-pill:hover {
    transition: none;
    transform: none;
  }

  .zack-pill.is-attention {
    animation: none;
  }

  .zack-popup-scrim,
  .zack-popup-window,
  .zack-popup.is-open .zack-popup-window {
    transition: none;
  }
}


/* --- Auswahl-Werkzeug (Bereich aufziehen) -------------------------------- */

/* Auswahl-Overlay: nur WÄHREND des Aufziehens fixiert, danach wieder weg. */
.try-select-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  cursor: crosshair;
}

.try-select-overlay[hidden] { display: none; }

.try-select-shade {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 13, 0.55);
}

.try-select-box {
  position: absolute;
  display: none;
  box-sizing: border-box;
  border: 2px solid #2f9bff;
  border-radius: 4px;
  background: rgba(0, 138, 254, 0.12);
  box-shadow: 0 0 0 9999px rgba(8, 10, 13, 0.55);
  pointer-events: none;
}

.try-select-size {
  position: absolute;
  left: 50%;
  top: -30px;
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: 8px;
  background: #2f9bff;
  color: #101216;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

/* Der Hinweis-Kasten ist reine Ansage: Klicks und Züge gehen durch ihn
   hindurch (Auswahl aufziehen statt versehentlich neuer Auswahlrahmen) —
   nur der Abbrechen-Knopf bleibt selbst klickbar. */
.try-select-toolbar {
  pointer-events: none;
}

.try-select-toolbar .btn {
  pointer-events: auto;
}

/* Die Anweisung steht klar im oberen Mittelbereich: groß, dunkel und mit
   Akzent-Symbol — der einzige Blickfang im Auswahl-Modus. */
.try-select-toolbar {
  position: fixed;
  left: 50%;
  top: 34%;
  z-index: 3;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: calc(100vw - 28px);
  padding: 20px 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  background: #101216;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.55),
    0 4px 14px rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.25;
  cursor: default;
}

.try-select-toolbar > span {
  display: flex;
  align-items: center;
  gap: 12px;
}

.try-select-toolbar > span::before {
  content: "";
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 2px solid #2f9bff;
  border-radius: 9px;
  background:
    linear-gradient(#2f9bff, #2f9bff) 15px 0 / 2px 100% no-repeat,
    linear-gradient(#2f9bff, #2f9bff) 0 15px / 100% 2px no-repeat;
  box-shadow: 0 0 0 5px rgba(47, 155, 255, 0.18);
}

.try-select-toolbar .btn {
  padding: 10px 18px;
  border-color: #fff;
  background: #fff;
  color: #101216;
  font-size: 1rem;
  font-weight: 700;
}

.try-select-toolbar .btn:hover {
  border-color: #d8e9ff;
  background: #d8e9ff;
  color: #101216;
}

body.try-selecting { overflow: hidden; user-select: none; }
