/* ddchat.css — DD Chat: the floating page-aware Didi bar on case-study pages.
 * -------------------------------------------------------------------------
 * Stamped by partials/ddchat.html onto the seven live /projects/ pages. The
 * chat itself is the standard .dgpt-term markup (terminal.css does the TUI);
 * this file only docks it: a fixed pill bar at the bottom-centre of the
 * viewport that expands the chat window upward, Intercom-style but in the
 * site's own glass + terminal material.
 *
 * GOTCHAS baked in:
 * - NO transform on .ddchat, ever. On phones the open chat goes
 *   position:fixed (terminal.css bottom sheet) and a transformed ancestor
 *   would become its containing block — the sheet would pin to the pill
 *   instead of the viewport. Centring is left/right + margin-inline auto,
 *   and the entrance is opacity-only.
 * - The pill's .glass-effect-tint needs its OWN tint rule: theme.css only
 *   enumerates hero tiles (html.theme-core.home …), so without the rules
 *   below the tint layer renders transparent on case pages.
 */

.ddchat {
  position: fixed;
  left: 0; right: 0;
  margin-inline: auto;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  /* an assistant, not a takeover: a slim bar that reads as a footnote */
  width: min(480px, calc(100vw - 32px));
  /* over page content + the footer wordmark, under the nav island (1400000) */
  z-index: 900000;
}
@media (prefers-reduced-motion: no-preference) {
  .ddchat { animation: ddchat-in 0.55s ease-out 0.35s backwards; }
}
@keyframes ddchat-in { from { opacity: 0; } }

/* The bar retires as the visitor reaches the Next Case Study block (the
   bootstrap watches .next-project and toggles is-away ~120px early, owner:
   "it should disappear right before that"). Opacity only — NO transform
   (see the containing-block gotcha above) — and never while the chat is
   open: :has keeps a running conversation on screen until it is closed. */
.ddchat { transition: opacity 0.3s ease; }
.ddchat.is-away:not(:has(.dgpt-term.open)) { opacity: 0; pointer-events: none; }

/* Collapsed pill = the home hero's liquid-glass recipe, un-gated from
   html.home (terminal.css scopes that rule to the homepage). */
.ddchat .dgpt-term:not(.open) .dgpt-term__prompt {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
html.day-mode .ddchat .dgpt-term:not(.open) .dgpt-term__prompt {
  border-color: rgba(0, 0, 0, 0.1);
}
/* the glass tint layer (same material as the nav island / hero tiles) */
.ddchat .dgpt-term__prompt > .glass-effect-tint {
  background-color: var(--glass-tint, rgba(14, 14, 18, 0.6)) !important;
}
html.day-mode .ddchat .dgpt-term__prompt > .glass-effect-tint {
  background-color: rgba(255, 255, 255, 0.44) !important;
}
/* collapsed pill hides the disclaimer + idle cursor exactly like home does */
.ddchat .dgpt-term:not(.open) .dgpt-term__note { display: none; }

/* Open window: a compact side-assistant panel, not the hero's 56vh sheet */
.ddchat .dgpt-term__window { height: clamp(300px, 46vh, 460px); }
.ddchat .dgpt-ascii-img { height: clamp(80px, 12vh, 120px); }

@media (max-width: 767px) {
  .ddchat {
    width: calc(100vw - 24px);
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  /* the open chat is terminal.css's fixed bottom sheet; the wrapper keeps
     out of the way (no transform, so the sheet positions to the viewport) */
}
