/* ── Chat Panel ── */
/* ── Chat backdrop blur ── */
.zp-chat-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100dvh;
  z-index: 199;
  backdrop-filter: blur(4px) brightness(0.7);
  -webkit-backdrop-filter: blur(4px) brightness(0.7);
  pointer-events: none;
  transition: opacity 0.3s ease;
  opacity: 0;
}
.zp-chat-backdrop.open {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.zp-chat-panel {
  position: fixed;
  bottom: 145px;
  left: 50%;
  transform: translateX(-50%) translateY(20px) scale(0.95);
  width: 800px;
  min-height: 330px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 200px);
  background: linear-gradient(160deg,
                oklch(20% 0.035 220 / 0.55),
                oklch(16% 0.03 290 / 0.6) 55%,
                oklch(15% 0.02 260 / 0.7));
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid oklch(var(--brand-teal) / 0.25);
  border-radius: 18px;
  box-shadow: 0 8px 40px oklch(var(--space-oled) / 0.6),
              0 0 60px oklch(var(--brand-purple) / 0.12),
              0 0 90px oklch(var(--brand-teal) / 0.06),
              inset 0 1px 0 oklch(var(--brand-teal) / 0.12);
  display: flex;
  flex-direction: column;
  z-index: 200;
  opacity: 0;
  transform-origin: center bottom;
  pointer-events: none;
  transition: all 0.25s ease;
  overflow: hidden;
}

.zp-chat-panel.open {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  pointer-events: all;
}

@media (max-width: 480px) {
  .zp-chat-panel {
    width: 380px;
    max-height: calc(100vh - 180px);
  }
  .zp-chat-panel.open {
    max-width: calc(100vw - 20px);
  }
}

.zp-chat-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 14px 16px;
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg,
                  oklch(var(--brand-teal) / 0.35),
                  oklch(var(--brand-purple) / 0.3),
                  oklch(var(--brand-green) / 0.25)) 1;
  background: linear-gradient(180deg,
                oklch(18% 0.04 250 / 0.55),
                oklch(15% 0.03 260 / 0.35));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
}

.zp-chat-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-main);
  font-family: 'Fugaz One', 'Braah One', system-ui, sans-serif;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.02em;
  position: absolute;
  left: 50%;
  transform: translateX(calc(-50% - 10px));
  white-space: nowrap;
}

/* Toggle emoji ↔ glyph when panel opens */
.zp-chat-icon-glyph {
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}
.zp-chat-icon-glyph svg {
  width: 100%;
  height: 100%;
  display: block;
}
.zp-chat-panel.open .zp-chat-icon-emoji {
  display: none;
}
.zp-chat-panel.open .zp-chat-icon-glyph {
  display: inline-flex !important;
}

.zp-chat-name {
  background: linear-gradient(135deg,
    oklch(var(--brand-teal)) 0%,
    oklch(var(--brand-purple)) 50%,
    oklch(var(--brand-green)) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.zp-model-badge {
  font-size: 0.6rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: oklch(var(--brand-teal) / 0.12);
  border: 1px solid oklch(var(--brand-teal) / 0.2);
  color: oklch(var(--brand-teal));
  letter-spacing: 0.3px;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.zp-model-badge.fallback {
  background: oklch(50% 0.05 80 / 0.15);
  border-color: oklch(50% 0.05 80 / 0.3);
  color: oklch(70% 0.08 80);
}

.zp-chat-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.zp-chat-refresh {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s ease;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
}
.zp-chat-refresh:hover {
  background: oklch(30% 0.05 0 / 0.2);
  color: oklch(var(--brand-teal));
}

.zp-chat-close:hover {
  background: oklch(30% 0.05 0 / 0.2);
  color: var(--text-main);
}

.zp-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 200px;
  max-height: 420px;
  scroll-behavior: smooth;
}

.zp-chat-msg {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  max-width: 90%;
  word-wrap: break-word;
  animation: zp-chat-fadein 0.2s ease;
}

.zp-chat-msg-bot {
  align-self: flex-start;
  background: linear-gradient(135deg,
                oklch(24% 0.05 230 / 0.5),
                oklch(19% 0.04 270 / 0.55));
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  border: 1px solid oklch(var(--brand-teal) / 0.18);
  box-shadow: 0 2px 16px oklch(var(--space-oled) / 0.25),
              inset 0 1px 0 oklch(var(--brand-teal) / 0.1);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.zp-chat-msg-doshus {
  align-self: flex-start;
  background: oklch(20% 0.04 260 / 0.6);
  border: 2px solid oklch(var(--brand-gold) / 0.8);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  box-shadow: 0 0 12px oklch(var(--brand-gold) / 0.3);
}

.zp-chat-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg,
                oklch(var(--brand-teal) / 0.22),
                oklch(var(--brand-purple) / 0.16));
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid oklch(var(--brand-teal) / 0.28);
  box-shadow: 0 2px 16px oklch(var(--brand-teal) / 0.08),
              inset 0 1px 0 oklch(var(--brand-teal) / 0.18);
  color: var(--text-main);
  border-bottom-right-radius: 4px;
}

.zp-chat-msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
  opacity: 0.7;
}

/* Clickable links in chat messages */
.zp-chat-msg a {
  color: oklch(var(--brand-teal));
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.zp-chat-msg a:hover {
  color: var(--text-main);
}

/* Generated images in chat */
.zp-chat-img-link {
  display: block;
  text-decoration: none !important;
}
.zp-chat-img-link:hover img {
  outline: 2px solid oklch(var(--brand-teal) / 0.5);
  border-radius: 10px;
}

.zp-chat-msg-user a {
  color: var(--text-main);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Session ended banner */
.zp-chat-ended {
  padding: 10px 16px;
  margin: 8px 12px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: oklch(var(--brand-teal) / 0.05);
  border: 1px solid oklch(var(--brand-teal) / 0.1);
  border-radius: 8px;
  opacity: 0.85;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

@keyframes zp-chat-fadein {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.zp-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid transparent;
  border-image: linear-gradient(90deg,
                  oklch(var(--brand-teal) / 0.25),
                  oklch(var(--brand-purple) / 0.2),
                  oklch(var(--brand-green) / 0.18)) 1;
  background: linear-gradient(0deg,
                oklch(16% 0.04 250 / 0.55),
                oklch(15% 0.03 260 / 0.3));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.zp-chat-input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid oklch(var(--brand-teal) / 0.18);
  border-radius: 10px;
  background: oklch(20% 0.03 260 / 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.zp-chat-input-area input:focus {
  border-color: oklch(var(--brand-teal) / 0.5);
  box-shadow: 0 0 0 3px oklch(var(--brand-teal) / 0.1),
              0 0 20px oklch(var(--brand-purple) / 0.1);
}

.zp-chat-input-area input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.zp-chat-input-area.zp-input-disabled input,
.zp-chat-input-area.zp-input-disabled .zp-chat-send {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.zp-chat-send {
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, oklch(var(--brand-teal)), oklch(var(--brand-purple)) 60%, oklch(var(--brand-green)));
  color: oklch(var(--space-oled));
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 2px 12px oklch(var(--brand-teal) / 0.25);
  transition: all 0.18s ease;
  white-space: nowrap;
}

.zp-chat-send:hover:not(:disabled) {
  box-shadow: 0 4px 20px oklch(var(--brand-teal) / 0.4),
              0 0 30px oklch(var(--brand-purple) / 0.2);
  transform: translateY(-1px);
}

.zp-chat-send:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 12px oklch(var(--brand-teal) / 0.3);
}

.zp-chat-send:active {
  transform: scale(0.97);
}

.zp-chat-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}


/* ── Quick-reply buttons ── */
.zp-qr-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid oklch(var(--brand-teal) / 0.3);
  background: oklch(18% 0.04 260 / 0.6);
  color: var(--text-main);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}
.zp-qr-btn:hover {
  background: oklch(var(--brand-teal) / 0.2);
  border-color: oklch(var(--brand-teal) / 0.5);
  transform: scale(1.03);
}
.zp-qr-btn:active {
  transform: scale(0.97);
}
/* ── Chat image lightbox ── */
.zp-chat-img-card {
  margin: 0.55rem 0 0.35rem;
  max-width: min(100%, 420px);
}
.zp-chat-img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  object-fit: contain;
  cursor: pointer;
}
.zp-chat-img-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.45rem;
  color: oklch(var(--text-muted) / 0.78);
  font: 500 0.72rem/1.2 'JetBrains Mono', 'Fira Code', monospace;
}
.zp-chat-img-copy {
  border: 1px solid oklch(var(--brand-teal) / 0.38);
  background: oklch(var(--space-oled) / 0.34);
  color: oklch(var(--brand-teal));
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.zp-chat-img-copy:hover {
  border-color: oklch(var(--brand-teal) / 0.72);
  background: oklch(var(--brand-teal) / 0.13);
}
.zp-lightbox {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0;
  transition: opacity 0.2s ease;
}
.zp-lightbox--open {
  pointer-events: auto; opacity: 1;
}
.zp-lightbox-bg {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.85);
  cursor: pointer;
}
.zp-lightbox-close {
  position: absolute; top: 16px; right: 20px;
  font-size: 2rem; color: #fff; cursor: pointer;
  z-index: 1; line-height: 1;
}
.zp-lightbox-close:hover { color: oklch(var(--brand-teal)); }
.zp-lightbox-download {
  position: absolute; top: 18px; right: 64px; z-index: 1;
  border: 1px solid oklch(var(--brand-teal) / 0.55);
  background: oklch(var(--space-oled) / 0.72);
  color: #fff;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  font: 600 0.78rem/1 'JetBrains Mono', 'Fira Code', monospace;
  cursor: pointer;
  backdrop-filter: blur(12px);
}
.zp-lightbox-download:hover {
  color: oklch(var(--brand-teal));
  border-color: oklch(var(--brand-teal));
}
.zp-lightbox-img {
  position: relative; z-index: 1;
  max-width: 90vw; max-height: 90vh;
  border-radius: 10px; object-fit: contain;
}

/* ── Chat thinking indicator ── */
.zp-chat-thinking {
  min-width: 100px;
}

.zp-thinking-dots {
  display: flex;
  gap: 3px;
  font-size: 0.85rem;
  color: oklch(var(--brand-teal) / 0.7);
}

.zp-thinking-text {
  margin-left: 4px;
  font-size: 0.8rem;
  animation: zp-think-pulse 1.5s ease-in-out infinite;
}

.zp-dot {
  font-weight: bold;
  animation: zp-dot-bounce 1.4s ease-in-out infinite;
}

.zp-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.zp-dot:nth-child(3) {
  animation-delay: 0.4s;
}

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

@keyframes zp-think-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ── Chat accessibility & motion ── */
body.zp-motion-throttled .zp-chat-panel::before {
  animation-play-state: paused;
}
@media (prefers-reduced-motion: reduce) {
  #zp-chat-thinking .zp-dot {
    animation: none !important;
  }
}

/* Chat icon glyph — hidden until voice/audio feature is wired */
.zp-chat-icon-glyph { display: none; }

/* ════════════════════════════════════════════════
   CHAT ORB — polish layer (2026-07-12)
   Springy origin-aware open, aurora top strip,
   delivery ticks, typing/seen states.
   ════════════════════════════════════════════════ */

/* Origin-aware springy open — rises from the orb with a gentle overshoot
   (transitions.dev "origin-aware open/close" pattern) */
.zp-chat-panel {
  transform-origin: center bottom;
  transition: opacity 0.22s ease,
              transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Aurora strip — paper-design mesh-gradient vibe in pure CSS.
   Clipped to the panel top by the panel's overflow:hidden. */
.zp-chat-panel::before {
  content: '';
  position: absolute;
  top: -45px;
  left: -15%;
  right: -15%;
  height: 110px;
  background:
    radial-gradient(42% 85% at 18% 62%, oklch(var(--brand-teal) / 0.26), transparent 70%),
    radial-gradient(36% 72% at 52% 38%, oklch(var(--brand-purple) / 0.24), transparent 70%),
    radial-gradient(30% 62% at 86% 58%, oklch(var(--brand-green) / 0.14), transparent 70%);
  filter: blur(20px);
  opacity: 0.75;
  animation: zp-aurora-drift 16s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes zp-aurora-drift {
  from { transform: translateX(-5%) scaleY(1); }
  to   { transform: translateX(5%)  scaleY(1.3); }
}

/* Delivery tick states on visitor messages */
.zp-tick {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.62rem;
  color: var(--text-muted);
  opacity: 0.55;
  transition: color 0.3s ease, opacity 0.3s ease;
}
.zp-tick.zp-delivered {
  color: oklch(var(--brand-teal));
  opacity: 0.85;
}
.zp-tick.zp-seen {
  color: oklch(var(--brand-teal));
  opacity: 1;
  text-shadow: 0 0 6px oklch(var(--brand-teal) / 0.55);
}
.zp-tick.zp-failed {
  color: oklch(65% 0.24 25);
  opacity: 1;
}

/* Keyboard focus ring for the orb (now tabbable) */
#zp-orb-demo:focus-visible {
  outline: 2px solid oklch(var(--brand-teal) / 0.7);
  outline-offset: 4px;
  border-radius: 50%;
}

@media (prefers-reduced-motion: reduce) {
  .zp-chat-panel { transition: opacity 0.2s ease; }
  .zp-chat-panel::before { animation: none; }
  .zp-tick { transition: none; }
}

@media (prefers-reduced-motion: no-preference) {
  #zp-chat-send {
    transition: transform 0.16s cubic-bezier(0.34, 1.6, 0.4, 1);
  }
  #zp-chat-send:active {
    transform: scale(0.9);
  }

  /* Chat: each message eases in as it lands */
  .zp-chat-msg {
    animation: zp-msg-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  @keyframes zp-msg-in {
    from { opacity: 0; transform: translateY(8px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
  }

}

/* ── Orb whorl glyph (injected by zephyy-chat.js into #zp-orb-demo on every
   chat page — moved here from zephyy.css so the sitewide embed gets it too) ── */
.zp-orb-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  pointer-events: none;
  filter: drop-shadow(0 0 3px oklch(var(--space-oled) / 0.35));
}

.zp-orb-glyph svg {
  width: 100%;
  height: 100%;
}

.whorl-outer,
.whorl-mid,
.whorl-inner {
  transform-origin: 32px 32px;
}

.whorl-outer { animation: whorlSpin 16s linear infinite; }
.whorl-mid   { animation: whorlSpin 11s linear infinite; }
.whorl-inner { animation: whorlSpin 7s linear infinite; }
.whorl-center { animation: whorlPulse 2.5s ease-in-out infinite; }

@keyframes whorlSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes whorlPulse {
  0%, 100% { opacity: 0.5; transform: scale(0.85); }
  50%       { opacity: 1;   transform: scale(1.15); }
}

body.zp-motion-throttled .whorl-outer,
body.zp-motion-throttled .whorl-mid,
body.zp-motion-throttled .whorl-inner,
body.zp-motion-throttled .whorl-center {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .whorl-outer, .whorl-mid, .whorl-inner, .whorl-center { animation: none; }
}

/* ── Header name → profile link ── */
.zp-chat-name-link {
  text-decoration: none;
  border-radius: 4px;
  transition: filter 0.2s ease;
}
.zp-chat-name-link:hover .zp-chat-name,
.zp-chat-name-link:focus-visible .zp-chat-name {
  filter: brightness(1.35) drop-shadow(0 0 6px oklch(var(--brand-teal) / 0.5));
}
.zp-chat-name-link:focus-visible {
  outline: 2px solid oklch(var(--brand-teal) / 0.6);
  outline-offset: 2px;
}

/* ── Refresh two-tap confirm state ── */
.zp-chat-refresh.confirming {
  color: oklch(70% 0.19 35);
  background: oklch(70% 0.19 35 / 0.14);
  animation: zp-refresh-arm 0.3s ease;
}
@keyframes zp-refresh-arm {
  0% { transform: translateY(-50%) scale(1); }
  50% { transform: translateY(-50%) scale(1.25); }
  100% { transform: translateY(-50%) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .zp-chat-refresh.confirming { animation: none; }
}
