/* Heart of the Homily - quick-find guide. Uses the app.css palette tokens with fallbacks. */
.hoth-asst {
  --a-bg: var(--bg, #f6f1e7);
  --a-surface: var(--surface, #fffdf7);
  --a-ink: var(--ink, #1e3327);
  --a-muted: var(--muted, #5f5d52);
  --a-green: var(--green, #1c4633);
  --a-gold: var(--gold, #b08a3c);
  --a-gold-text: var(--gold-text, #7a5c14);
  --a-line: var(--line, rgba(28, 70, 51, 0.16));
  --a-faint: var(--gold-faint, rgba(176, 138, 60, 0.32));
  --a-serif: var(--serif, "Cormorant Garamond", Georgia, serif);
  --a-sans: var(--sans, "Jost", system-ui, sans-serif);
  font-family: var(--a-sans);
  color: var(--a-ink);
}
.hoth-asst *, .hoth-asst *::before, .hoth-asst *::after { box-sizing: border-box; }

/* ---------- launcher ---------- */
.hoth-asst-launcher {
  position: fixed; right: 24px; z-index: 48;
  bottom: calc(var(--hoth-asst-bottom, 16px) + env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 0;
  height: 56px; min-width: 56px; padding: 0; border: 0; border-radius: 999px;
  background: var(--a-green); color: var(--a-bg);
  font: 500 0.92rem/1 var(--a-sans); letter-spacing: 0.02em; cursor: pointer;
  box-shadow: 0 0 0 3px var(--a-surface), 0 0 0 4.5px var(--a-gold), var(--shadow-md, 0 14px 30px -12px rgba(20, 51, 37, 0.35));
  transition: bottom 0.3s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.hoth-asst-launcher:hover { transform: translateY(-1px); }
.hoth-asst-launcher:focus-visible { outline: 3px solid var(--a-gold); outline-offset: 6px; }
.hoth-asst-ico { display: grid; place-items: center; width: 56px; height: 56px; flex: none; }
.hoth-asst-ico svg { width: 26px; height: 26px; }
.hoth-asst-label { padding-left: 20px; white-space: nowrap; }
.hoth-asst.hide-label .hoth-asst-label { display: none; }
.hoth-asst.is-open .hoth-asst-launcher { box-shadow: 0 0 0 3px var(--a-surface), 0 0 0 4.5px var(--a-gold); }

/* ---------- panel ---------- */
.hoth-asst-panel {
  position: fixed; right: 24px; z-index: 80;
  bottom: calc(var(--hoth-asst-bottom, 16px) + 68px + env(safe-area-inset-bottom));
  width: 380px; max-width: calc(100vw - 32px); max-height: min(600px, calc(100vh - 140px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--a-surface); color: var(--a-ink);
  border: 1px solid var(--a-faint); border-radius: 20px;
  box-shadow: var(--shadow-lg, 0 30px 60px -18px rgba(20, 51, 37, 0.35));
  opacity: 0; transform: translateY(10px) scale(0.98); transform-origin: bottom right; visibility: hidden;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0.22s;
}
.hoth-asst.is-open .hoth-asst-panel { opacity: 1; transform: none; visibility: visible; transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s; }

.hoth-asst-head {
  display: flex; align-items: flex-start; gap: 10px; padding: 16px 16px 14px 20px;
  background: var(--a-green); color: var(--a-bg); border-bottom: 2px solid var(--a-gold);
}
.hoth-asst-head-t { flex: 1; min-width: 0; }
.hoth-asst-title { margin: 0; font: 600 1.35rem/1.15 var(--a-serif); outline: none; }
.hoth-asst-sub { margin: 4px 0 0; font-size: 0.82rem; line-height: 1.4; opacity: 0.92; }
.hoth-asst-draft { margin: 4px 0 0; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.8; }
.hoth-asst-x {
  flex: none; width: 44px; height: 44px; margin: -6px -6px 0 0; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer;
}
.hoth-asst-x svg { width: 18px; height: 18px; }
.hoth-asst-x:hover { background: rgba(128, 128, 128, 0.22); }
.hoth-asst-x:focus-visible, .hoth-asst-clear:focus-visible, .hoth-asst-chip:focus-visible, .hoth-asst-send:focus-visible, .hoth-asst-link:focus-visible { outline: 3px solid var(--a-gold); outline-offset: 2px; }

.hoth-asst-log { flex: 1 1 auto; min-height: 120px; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.hoth-asst-msg { display: flex; }
.hoth-asst-msg.is-user { justify-content: flex-end; }
.hoth-asst-bubble { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 0.95rem; line-height: 1.45; overflow-wrap: anywhere; }
.is-bot .hoth-asst-bubble { background: var(--bg-soft, #efe8d8); color: var(--a-ink); border-bottom-left-radius: 5px; }
.is-user .hoth-asst-bubble { background: var(--a-green); color: var(--a-bg); border-bottom-right-radius: 5px; }
.hoth-asst-text { margin: 0; }
.hoth-asst-link {
  display: inline-block; margin-top: 8px; padding: 8px 14px; border-radius: 999px;
  background: var(--a-green); color: var(--a-bg); font-weight: 500; font-size: 0.88rem; text-decoration: none;
}
.hoth-asst-link:hover { filter: brightness(1.12); }

.hoth-asst-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 16px 12px; border-top: 1px solid var(--a-line); }
.hoth-asst-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--a-faint); border-radius: 999px; background: transparent; color: var(--a-green);
  font: 500 0.86rem/1.2 var(--a-sans); text-decoration: none; cursor: pointer;
}
.hoth-asst-chip svg { width: 16px; height: 16px; flex: none; }
.hoth-asst-chip:hover { background: var(--a-faint); }

.hoth-asst-form { display: flex; gap: 8px; padding: 0 16px; }
.hoth-asst-input {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 14px; border: 1px solid var(--a-line); border-radius: 999px;
  background: var(--a-bg); color: var(--a-ink); font: 400 16px/1 var(--a-sans);
}
.hoth-asst-input:focus-visible { outline: 3px solid var(--a-gold); outline-offset: 1px; }
.hoth-asst-send { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--a-green); color: var(--a-bg); cursor: pointer; }
.hoth-asst-send svg { width: 18px; height: 18px; }
.hoth-asst-foot { display: flex; align-items: flex-start; gap: 10px; padding: 8px 16px 14px; }
.hoth-asst-note { margin: 0; flex: 1; font-size: 0.74rem; line-height: 1.4; color: var(--a-muted); }
.hoth-asst-clear { flex: none; padding: 6px 4px; border: 0; background: transparent; color: var(--a-gold-text); font: 500 0.8rem var(--a-sans); text-decoration: underline; cursor: pointer; min-height: 44px; padding: 6px 8px; }

/* ---------- mobile: bottom sheet ---------- */
@media (max-width: 640px) {
  .hoth-asst-launcher { right: 14px; }
  .hoth-asst-panel {
    left: 10px; right: 10px; width: auto; max-width: none;
    /* sits above the mini player / consent bar / end card (via --hoth-asst-bottom), never over them */
    bottom: calc(var(--hoth-asst-bottom, 10px) + env(safe-area-inset-bottom));
    max-height: min(70vh, calc(100vh - var(--hoth-asst-bottom, 10px) - 24px));
    max-height: min(70dvh, calc(100dvh - var(--hoth-asst-bottom, 10px) - 24px));
    transform-origin: bottom center;
  }
  .hoth-asst.is-open .hoth-asst-launcher { visibility: hidden; }
  .hoth-asst-bubble { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  .hoth-asst-launcher, .hoth-asst-panel, .hoth-asst.is-open .hoth-asst-panel { transition: none; }
  .hoth-asst-launcher:hover { transform: none; }
}
@media print { .hoth-asst { display: none; } }


/* ===== R4 polish ===== (frosted chat panel + spring presses) */
.hoth-asst-panel {
  background: var(--glass-bg, var(--a-surface));
  -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%);
  border-color: var(--glass-border, var(--a-faint));
  box-shadow: var(--shadow-lg, 0 30px 60px -18px rgba(20, 51, 37, 0.35)), var(--glass-hi, none);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .hoth-asst-panel { background: var(--glass-solid, var(--a-surface)); }
}
.hoth-asst-launcher, .hoth-asst-send, .hoth-asst-chip, .hoth-asst-link { transition: transform 0.28s var(--spring, ease), background-color 0.2s ease, filter 0.2s ease; }
.hoth-asst-launcher:active, .hoth-asst-send:active, .hoth-asst-chip:active, .hoth-asst-link:active { transform: scale(0.96); }
@media (prefers-reduced-motion: reduce) {
  .hoth-asst-launcher, .hoth-asst-send, .hoth-asst-chip, .hoth-asst-link { transition: none; }
  .hoth-asst-launcher:active, .hoth-asst-send:active, .hoth-asst-chip:active, .hoth-asst-link:active { transform: none; }
}

/* ===== R4 polish: phone fit + video clearance ===== */
.hoth-asst-form, .hoth-asst-foot, .hoth-asst-head { flex: none; }
.hoth-asst-draft { color: inherit; opacity: 0.85; }
.hoth-asst-launcher { transition: bottom 0.3s ease, transform 0.28s var(--spring, ease), opacity 0.25s ease; }
body.hoth-video-playing .hoth-asst:not(.is-open) .hoth-asst-launcher { opacity: 0; pointer-events: none; }
@media (max-width: 640px) {
  .hoth-asst-log { min-height: 96px; padding-top: 12px; }
  /* chips become one compact horizontally-scrolling row so the message log gets the room */
  .hoth-asst-chips { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding: 6px 16px 8px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .hoth-asst-chips::-webkit-scrollbar { display: none; }
  .hoth-asst-chip { flex: none; white-space: nowrap; }
  .hoth-asst-note { font-size: 0.72rem; }
  .hoth-asst-foot { padding-bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) { .hoth-asst-launcher { transition: none; } }

/* Phones: keep the hero clean. The chat launcher appears once the hero play button has scrolled away
   (same moment as the sticky mini player), or whenever the panel is open. */
@media (max-width: 720px) {
  body:not(.hero-out) .hoth-asst:not(.is-open) .hoth-asst-launcher { opacity: 0; pointer-events: none; transform: translateY(8px); }
}


/* ===== R5 fixes ===== (panel always fits the viewport; cream-glass header; stronger note contrast) */
.hoth-asst-panel {
  max-height: min(680px, calc(100vh - var(--hoth-asst-bottom, 16px) - 68px - 16px));
  max-height: min(680px, calc(100dvh - var(--hoth-asst-bottom, 16px) - 68px - 16px - env(safe-area-inset-bottom)));
}
.hoth-asst-log { min-height: 0; }
.hoth-asst-chips, .hoth-asst-form, .hoth-asst-foot, .hoth-asst-head { flex: none; }
@media (max-width: 640px) {
  .hoth-asst-panel { max-height: min(70vh, calc(100vh - var(--hoth-asst-bottom, 10px) - 24px)); max-height: min(70dvh, calc(100dvh - var(--hoth-asst-bottom, 10px) - 24px)); }
  .hoth-asst-log { min-height: 0; }
}
:root:not([data-theme="green"]) .hoth-asst-panel { background: rgba(255, 253, 247, 0.94); }
:root:not([data-theme="green"]) .hoth-asst-head {
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.98), rgba(247, 241, 227, 0.96));
  color: var(--a-green); border-bottom: 1px solid var(--a-gold);
}
:root:not([data-theme="green"]) .hoth-asst-title { color: var(--a-green); }
:root:not([data-theme="green"]) .hoth-asst-sub, :root:not([data-theme="green"]) .hoth-asst-draft { color: #3d4f45; opacity: 1; }
:root:not([data-theme="green"]) .hoth-asst-x { color: var(--a-green); }
:root:not([data-theme="green"]) .hoth-asst-x:hover { background: rgba(28, 70, 51, 0.1); }
:root:not([data-theme="green"]) .hoth-asst-note { color: #4a483f; }
/* chips scroll instead of pushing the footer out; the log keeps a usable minimum */
.hoth-asst-chips { flex: 0 1 auto; min-height: 0; max-height: clamp(64px, 26dvh, 280px); overflow-y: auto; overscroll-behavior: contain; }
.hoth-asst-log { min-height: 72px; }
@media (max-width: 640px) { .hoth-asst-chips { max-height: none; overflow-y: hidden; flex: none; } .hoth-asst-log { min-height: 0; } }
