/* Website chat assistant (src/assets/chat.js). Always dark, on every page theme.
   Square corners, no gradients, champagne accents (Brand Guidelines v2). */
.chat-launch { position: fixed; z-index: 55; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  width: 56px; height: 56px; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--obsidian); color: var(--champagne); border: 1px solid var(--champagne); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.35); transition: background-color .2s ease, transform .2s ease; }
.chat-launch:hover { background: #1d1d1d; }
.chat-launch:hover .chat-launch-ivy { transform: translateY(-2px); }
.chat-launch:focus-visible, .chat-panel button:focus-visible, .chat-panel a:focus-visible, .chat-input:focus-visible { outline: 2px solid var(--ivory); outline-offset: 2px; }
.chat-launch-ivy { width: 42px; height: 42px; transition: transform .2s ease; }
.chat-head-ivy { flex: none; width: 36px; height: 36px; }
.chat-pose { align-self: flex-start; line-height: 0; }
.chat-pose-ivy { width: 72px; height: 72px; animation: ivy-pop .28s ease-out both; }
.chat-open .chat-launch { display: none; }

.chat-panel { position: fixed; z-index: 70; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  width: min(380px, calc(100vw - 32px)); height: min(580px, calc(100svh - 32px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--obsidian); color: var(--ivory); border: 1px solid var(--champagne); border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0,0,0,.5); font-family: var(--sans); }
.chat-panel[hidden] { display: none; }

.chat-head { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--charcoal); }
.chat-title { flex: 1 1 auto; min-width: 0; margin: 0; }
.chat-title strong { display: block; font-family: var(--display); font-weight: 700; font-size: .82rem; letter-spacing: 2px; text-transform: uppercase; color: var(--champagne); }
.chat-title span { display: block; font-size: .8rem; color: #b5aea4; }
.chat-close { flex: none; width: 44px; height: 44px; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: none; border: 0; color: var(--ivory); border-radius: var(--radius); }
.chat-close:hover { color: var(--champagne); }
.chat-close svg { width: 20px; height: 20px; }

.chat-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 88%; padding: 10px 13px; border-radius: var(--radius); font-size: 1rem; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-msg.bot { align-self: flex-start; background: #1d1d1d; border: 1px solid var(--charcoal); }
.chat-msg.me { align-self: flex-end; background: var(--champagne); color: var(--obsidian); }
.chat-msg a { color: var(--champagne); text-decoration: underline; display: inline-block; padding-block: 6px; margin-block: -6px; }
.chat-msg.typing { color: #b5aea4; }
.chat-msg.typing i { display: inline-block; width: 6px; height: 6px; margin-right: 4px; background: currentColor; animation: chat-blink 1.2s infinite both; }
.chat-msg.typing i:nth-child(2) { animation-delay: .2s; }
.chat-msg.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes chat-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-msg.typing i { animation: none; opacity: .6; } .chat-launch, .chat-launch-ivy { transition: none; } }

.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chat-chip { min-height: 44px; padding: 8px 12px; cursor: pointer; font: inherit; font-size: .9rem; text-align: left;
  background: none; color: var(--ivory); border: 1px solid var(--champagne); border-radius: var(--radius); }
.chat-chip:hover { background: var(--champagne); color: var(--obsidian); }

.chat-form { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 10px; border-top: 1px solid var(--charcoal); }
.chat-input { flex: 1 1 auto; min-width: 0; min-height: 44px; max-height: 120px; padding: 10px 12px; resize: none;
  font: inherit; font-size: 16px; line-height: 1.4; color: var(--ivory); background: #1d1d1d; border: 1px solid var(--charcoal); border-radius: var(--radius); }
.chat-input::placeholder { color: #8f887f; }
.chat-send { flex: none; width: 44px; height: 44px; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--champagne); color: var(--obsidian); border: 0; border-radius: var(--radius); }
.chat-send:disabled { opacity: .45; cursor: default; }
.chat-send svg { width: 20px; height: 20px; }
.chat-note { flex: none; margin: 0; padding: 0 12px 10px; font-size: .75rem; line-height: 1.4; color: #8f887f; }
.chat-note a { color: inherit; text-decoration: underline; }

/* Phones: the panel becomes a full-screen sheet, and the page behind stops scrolling */
@media (max-width: 560px) {
  .chat-panel { inset: 0; width: auto; height: auto; max-height: 100dvh; border: 0; border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  html.chat-open, html.chat-open body { overflow: hidden; }
}
/* Phone sideways: short screens keep the log usable */
@media (max-height: 460px) { .chat-panel { height: calc(100svh - 16px); bottom: 8px; } .chat-note { display: none; } }
/* Tablet and up: an open chat sits beside the cookie notice instead of on top of it */
@media (min-width: 561px) { html.chat-open .cookie-notice { margin-left: 0; max-width: min(560px, calc(100vw - 444px)); } }

/* "Meet Ivy" section (3D Ivy beside a short intro; the button opens the chat) */
.meet-ivy-grid { display: grid; grid-template-columns: minmax(0, 370px) minmax(0, 1fr); gap: clamp(28px, 6vw, 80px); align-items: center; }
.meet-ivy-art { width: 100%; max-width: 370px; justify-self: center; }
.meet-ivy-grid h2 { text-wrap: balance; }
@media (max-width: 960px) { .meet-ivy-grid { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); } }
@media (max-width: 700px) {
  .meet-ivy-grid { grid-template-columns: 1fr; }
  .meet-ivy-art { max-width: 240px; }
}

/* Ivy in motion: antenna wiggle and blink. Numbers are measured from the art in /assets/ivy/:
   --cut = where the antenna meets the head, --l/--r = the strip holding the antenna, --ox = the stem's base. */
.ivy { position: relative; display: block; line-height: 0; }
.ivy img { position: absolute; inset: 0; width: 100%; height: 100%; }
.ivy-body { clip-path: polygon(0 0, var(--l) 0, var(--l) var(--cut), var(--r) var(--cut), var(--r) 0, 100% 0, 100% 100%, 0 100%); }
.ivy-ant { clip-path: inset(0 calc(100% - var(--r)) calc(100% - var(--cut)) var(--l)); transform-origin: var(--ox) var(--cut); animation: ivy-wiggle 3.6s ease-in-out infinite; }
.ivy-head { --cut: 39.7%; --l: 40%; --r: 80%; --ox: 50.3%; --lid: #cca763; }
.ivy-hello { --cut: 25.6%; --l: 45%; --r: 72%; --ox: 53.1%; --lid: #cca869; }
.ivy-thinking { --cut: 25.6%; --l: 45%; --r: 72%; --ox: 53.5%; }
.ivy-gotit { --cut: 25.6%; --l: 46%; --r: 70%; --ox: 52.5%; }
.ivy-thinking .ivy-ant { animation: ivy-sway .8s ease-in-out infinite; }
.chat-head-ivy .ivy-ant { animation: none; }
.ivy-lid { position: absolute; background: var(--lid); border-radius: 50%; transform: scaleY(0); transform-origin: 50% 0; animation: ivy-blink 3s linear infinite; }
.ivy-head .ivy-lid { top: 59.2%; width: 12.2%; height: 12.2%; }
.ivy-head .ivy-lid.l { left: 27.3%; } .ivy-head .ivy-lid.r { left: 60.5%; }
.ivy-hello .ivy-lid { top: 39.8%; width: 7.4%; height: 7.4%; }
.ivy-hello .ivy-lid.l { left: 38.6%; } .ivy-hello .ivy-lid.r { left: 60.2%; }
@keyframes ivy-wiggle { 0%, 78%, 100% { transform: rotate(0); } 83% { transform: rotate(12deg); } 88% { transform: rotate(-9deg); } 93% { transform: rotate(5deg); } 97% { transform: rotate(-1deg); } }
@keyframes ivy-sway { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
@keyframes ivy-blink { 0%, 94%, 100% { transform: scaleY(0); } 96%, 98% { transform: scaleY(1); } }
@keyframes ivy-pop { from { opacity: 0; transform: translateY(6px) scale(.9); } }
@media (prefers-reduced-motion: reduce) { .ivy-ant, .ivy-lid, .chat-pose-ivy { animation: none; } }

/* 3D Ivy on /ai-systems/: a WebGL model (ivy3d.js) drawn over a still image, which stays as the fallback */
.ivy3d { position: relative; display: block; aspect-ratio: 482 / 720; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ivy3d:focus-visible { outline: 1px solid var(--champagne); outline-offset: 6px; }
.ivy3d img, .ivy3d-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.ivy3d img { object-fit: contain; transition: opacity .3s ease; }
.ivy3d.is-live img { opacity: 0; }
