/*##############################################################################
# Script:        chat.css           (stylesheet, loaded by the public pages: index.html, about, gallery, greatgallery,
#                                    wisdom, patreon, bookoffaces, portals, privacy and 404)
# Created by:    Matthew Boucher
# Start date:    2026-10-16
# Location:      <project root>/frontend/css/chat.css   (main script: <project root>/aiacolyte.py; subscripts: <project root>/subscripts/aiacolyte/)
# Description:   The look of the "Ask the Acolyte" chat widget: the round button in the bottom-right corner,
#                the chat panel (header with the "admins only (testing)" tag, the conversation, the typing
#                indicator, the message box with its character counter and the privacy notice) in the site's
#                dark arcane style: candlelit ink, conjured gold and the arcane blue of the AI half of the
#                magic. On small screens the panel fills the width (and most of the height); with
#                prefers-reduced-motion every animation and transition is switched off. Every class starts
#                with lchat- so it cannot clash with a page's own styles. Works with chat.js (which builds
#                the widget) and uses the colour tokens and fonts from styles.css, with fallbacks.
# Reads:         the colour tokens and fonts from styles.css
# Writes:        nothing
# Sensitive:     none needed
# Arguments:     none (a stylesheet cannot take flags); aiacolyte.py --checkup confirms it is in place
##############################################################################*/

.lchat {
  --lchat-gold: var(--gold, #e3b04b);
  --lchat-gold-bright: var(--gold-bright, #f6d88b);
  --lchat-arcane: var(--arcane, #8cc8ff);
  --lchat-ink: var(--ink-1, #110e0b);
  --lchat-ink-2: var(--ink-2, #1a1511);
  --lchat-indigo: var(--indigo-deep, #16143a);
  --lchat-text: var(--text, #efe6d2);
  --lchat-dim: var(--text-dim, #bfb196);
  --lchat-faint: var(--text-faint, #8f836d);
  --lchat-line: var(--line, rgba(227, 176, 75, 0.22));
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: var(--font-body, "Cormorant Garamond", Georgia, serif);
  color: var(--lchat-text);
}

.lchat-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- the round button ---------- */

.lchat-launch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  padding: 0;
  border: 1px solid var(--lchat-gold);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2b2766, var(--lchat-indigo) 70%);
  color: var(--lchat-gold-bright);
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(227, 176, 75, 0.12), 0 8px 26px rgba(0, 0, 0, 0.6), 0 0 22px rgba(140, 200, 255, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.lchat-launch:hover { transform: translateY(-2px); box-shadow: 0 0 0 4px rgba(227, 176, 75, 0.22), 0 10px 30px rgba(0, 0, 0, 0.65), 0 0 30px rgba(140, 200, 255, 0.4); }
.lchat-launch:focus-visible { outline: 2px solid var(--lchat-arcane); outline-offset: 4px; }
.lchat-launch__icon { font-size: 26px; line-height: 1; animation: lchat-glow 3.2s ease-in-out infinite; }
.lchat-launch__label {   /* the name shows as a small tooltip-like plaque on hover and focus */
  position: absolute;
  right: 74px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  padding: 6px 12px;
  border: 1px solid var(--lchat-line);
  border-radius: 999px;
  background: var(--lchat-ink);
  color: var(--lchat-gold-bright);
  font-family: var(--font-display, "Cinzel", serif);
  font-size: 13px;
  letter-spacing: 0.06em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.lchat-launch:hover .lchat-launch__label,
.lchat-launch:focus-visible .lchat-launch__label { opacity: 1; }
.lchat--open .lchat-launch__label { opacity: 0 !important; }

@keyframes lchat-glow {
  0%, 100% { text-shadow: 0 0 6px rgba(246, 216, 139, 0.5); }
  50% { text-shadow: 0 0 14px rgba(140, 200, 255, 0.85); }
}

/* ---------- the panel ---------- */

.lchat-panel {
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 110px));
  border: 1px solid var(--lchat-line);
  border-radius: 16px;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(43, 39, 102, 0.55), transparent 60%),
    linear-gradient(180deg, var(--lchat-ink-2), var(--lchat-ink));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  animation: lchat-rise 0.22s ease-out;
}
.lchat-panel[hidden] { display: none; }

@keyframes lchat-rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.lchat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 6px 16px;
}
.lchat-title {
  flex: 1;
  margin: 0;
  font-family: var(--font-display, "Cinzel", serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--lchat-gold-bright);
}
.lchat-tag {
  padding: 2px 8px;
  border: 1px solid var(--lchat-arcane);
  border-radius: 999px;
  color: var(--lchat-arcane);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 10.5px;
  white-space: nowrap;
}
.lchat-iconbtn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--lchat-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.lchat-iconbtn:hover { color: var(--lchat-gold-bright); border-color: var(--lchat-line); }
.lchat-iconbtn:focus-visible { outline: 2px solid var(--lchat-arcane); outline-offset: 1px; }

.lchat-sub {
  margin: 0;
  padding: 0 16px 10px;
  border-bottom: 1px solid var(--lchat-line);
  color: var(--lchat-faint);
  font-size: 14px;
  font-style: italic;
}

/* ---------- the conversation ---------- */

.lchat-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
.lchat-log:focus-visible { outline: 2px solid var(--lchat-arcane); outline-offset: -2px; }

.lchat-msg {
  max-width: 86%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 17px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.lchat-msg--assistant {
  align-self: flex-start;
  border: 1px solid rgba(140, 200, 255, 0.22);
  border-bottom-left-radius: 4px;
  background: rgba(22, 20, 58, 0.75);
}
.lchat-msg--user {
  align-self: flex-end;
  border: 1px solid rgba(227, 176, 75, 0.35);
  border-bottom-right-radius: 4px;
  background: rgba(168, 121, 42, 0.18);
}
.lchat-msg--greeting { color: var(--lchat-dim); }
.lchat-msg--notice {
  border-color: rgba(227, 176, 75, 0.45);
  background: rgba(26, 21, 17, 0.9);
  color: var(--lchat-gold-bright);
}
.lchat-link { color: var(--lchat-arcane); text-decoration: underline; text-underline-offset: 3px; }
.lchat-link:hover { color: #c3e2ff; }

.lchat-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 12px 14px;
  border: 1px solid rgba(140, 200, 255, 0.22);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  background: rgba(22, 20, 58, 0.75);
}
.lchat-typing[hidden] { display: none; }
.lchat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lchat-arcane);
  opacity: 0.35;
  animation: lchat-dot 1.2s infinite ease-in-out;
}
.lchat-typing span:nth-child(2) { animation-delay: 0.2s; }
.lchat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes lchat-dot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- the message box ---------- */

.lchat-form {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--lchat-line);
  background: rgba(10, 8, 7, 0.55);
}
.lchat-row { display: flex; gap: 8px; align-items: flex-end; }
.lchat-input {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  padding: 9px 11px;
  border: 1px solid var(--lchat-line);
  border-radius: 10px;
  background: var(--lchat-ink);
  color: var(--lchat-text);
  font: inherit;
  font-size: 16px;   /* 16px keeps phones from zooming in */
  line-height: 1.35;
  resize: vertical;
}
.lchat-input::placeholder { color: var(--lchat-faint); }
.lchat-input:focus { outline: none; border-color: var(--lchat-arcane); box-shadow: 0 0 0 2px rgba(140, 200, 255, 0.25); }
.lchat-send {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--lchat-gold);
  border-radius: 10px;
  background: linear-gradient(180deg, var(--lchat-gold-bright), var(--lchat-gold));
  color: var(--parchment-ink, #2b2016);
  font-family: var(--font-display, "Cinzel", serif);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
}
.lchat-send:hover:not(:disabled) { filter: brightness(1.08); }
.lchat-send:focus-visible { outline: 2px solid var(--lchat-arcane); outline-offset: 2px; }
.lchat-send:disabled { opacity: 0.45; cursor: not-allowed; }

.lchat-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 6px; }
.lchat-notice { margin: 0; color: var(--lchat-faint); font-size: 13.5px; }
.lchat-count { flex: none; color: var(--lchat-faint); font-family: var(--font-mono, ui-monospace, monospace); font-size: 11px; }
.lchat-count--near { color: var(--lchat-gold-bright); }
.lchat-turnstile:empty { display: none; }
.lchat-turnstile { margin-top: 8px; }

/* ---------- small screens: the panel takes the full width ---------- */

@media (max-width: 560px) {
  .lchat { right: 12px; bottom: 12px; }
  .lchat--open { left: 0; right: 0; bottom: 0; top: 0; align-items: stretch; gap: 0; }
  .lchat--open .lchat-launch { display: none; }
  .lchat-panel { width: 100%; height: 100%; border-radius: 0; border-left: 0; border-right: 0; }
  .lchat-launch { width: 56px; height: 56px; }
  .lchat-launch__label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .lchat *, .lchat *::before, .lchat *::after { animation: none !important; transition: none !important; }
  .lchat-log { scroll-behavior: auto; }
  .lchat-typing span { opacity: 0.7; }
}

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

/*##############################################################################
# End of chat.css
##############################################################################*/
