/* ─────────────────────────────────────────────────────────────────────────────
   Julia Krantz — AI Chat widget styles
   Aesthetic reference: periodic element grid on juliakrantz.com
   Each cell: atomic number · symbol · label — mirrored in chat UI
───────────────────────────────────────────────────────────────────────────── */


@font-face {
  font-family: 'ClashDisplay-Variable';
  src: url('/fonts/ClashDisplay-Variable.woff2') format('woff2'),
       url('/fonts/ClashDisplay-Variable.woff')  format('woff'),
       url('/fonts/ClashDisplay-Variable.ttf')   format('truetype');
  font-weight: 200 700;
  font-style: normal;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
#aiChatApp *,
#aiChatApp *::before,
#aiChatApp *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

#aiChatApp {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  cursor: auto;
}

/* ── Backdrop ──────────────────────────────────────────────────────────────── */
#aiChatApp .ac-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9998;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.4s ease;
}
#aiChatApp .ac-backdrop--open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Launcher (hidden — opened via click on page element) ──────────────────── */
#aiChatApp .ac-launcher {
  display: none;
}

/* ── Chat window ───────────────────────────────────────────────────────────── */
#aiChatApp .ac-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 680px;
  height: 660px;
  background: #080808;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.95);
}
#aiChatApp .ac-window.ac-window--open {
  display: flex;
}

/* ── Intro screen — styled as a periodic element card ─────────────────────── */
#aiChatApp .ac-intro {
  flex: 1;
  background: #080808;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Diffusion canvas behind content */
#aiChatApp .ac-diffusion {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#aiChatApp .ac-intro-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.3);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.1em;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  z-index: 2;
  transition: color 0.2s;
}
#aiChatApp .ac-intro-close:hover { color: rgba(255, 255, 255, 0.8); }

/* Element card — the centrepiece of the intro */
#aiChatApp .ac-intro-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0;
  text-align: center;
}

/* Liquid metal blob canvas */
#aiChatApp .ac-face {
  display: block;
  width: 180px;
  max-width: 100%;
  height: 180px;
  margin-bottom: 0.8rem;
}

/* Element card: number + symbol + name + divider + description */
#aiChatApp .ac-element-card {
  border: none;
  padding: 1rem 2rem 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 220px;
  position: relative;
}

#aiChatApp .ac-element-number {
  font-size: 10px;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.3);
  letter-spacing: 0.15em;
  align-self: flex-start;
}

#aiChatApp .ac-element-symbol {
  font-size: 60px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0.15rem 0 0.4rem;
}

#aiChatApp .ac-element-name {
  font-size: 11px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

#aiChatApp .ac-element-divider {
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0.9rem 0 0.8rem;
}

#aiChatApp .ac-intro-sub {
  font-family: 'Switzer', sans-serif;
  font-size: 11px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.35);
  line-height: 1.4;
  max-width: 340px;
  letter-spacing: 0.03em;
}

/* Consent */
#aiChatApp .ac-consent {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: 'Switzer', sans-serif;
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.3);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  letter-spacing: 0.03em;
  margin-top: 1.6rem;
  width: 100%;
}
#aiChatApp .ac-consent input[type="checkbox"] {
  flex-shrink: 0;
  accent-color: #fff;
  width: 11px;
  height: 11px;
  cursor: pointer;
}
#aiChatApp .ac-consent a {
  color: rgba(255, 255, 255, 0.45);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(255, 255, 255, 0.15);
}
#aiChatApp .ac-consent a:hover { color: rgba(255, 255, 255, 0.8); }

/* Hide default theme elements */
#aiChatApp .ac-intro-title         { display: none; }
#aiChatApp .ac-intro-sub--default  { display: none; }

/* Start button */
#aiChatApp .ac-start-btn {
  background: transparent;
  border: none;
  padding: 0.65rem 2rem;
  font-family: 'Switzer', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, opacity 0.2s;
  margin-top: 1rem;
  width: 100%;
}
#aiChatApp .ac-start-btn:hover:not(:disabled) {
  border-color: #fff;
  color: #fff;
}
#aiChatApp .ac-start-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* ── Chat screen ───────────────────────────────────────────────────────────── */
#aiChatApp .ac-chat {
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Header — avatar/text hidden, only close button shown */
#aiChatApp .ac-header {
  display: flex;
  justify-content: flex-end;
  padding: 0.6rem 0.8rem 0;
  flex-shrink: 0;
}
#aiChatApp .ac-header-text {
  display: none;
}
#aiChatApp .ac-header-avatar {
  display: none;
}
#aiChatApp .ac-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#aiChatApp .ac-header-text { flex: 1; }
#aiChatApp .ac-header-name {
  font-family: 'ClashDisplay-Variable', 'Clash Display', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
#aiChatApp .ac-header-status {
  font-size: 10px;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.25);
  letter-spacing: 0.08em;
  margin-top: 2px;
}
#aiChatApp .ac-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  font-size: 14px;
  letter-spacing: 0.05em;
  padding: 10px;
  line-height: 1;
  transition: color 0.2s;
}
#aiChatApp .ac-close-btn:hover { color: rgba(255, 255, 255, 0.8); }

/* Messages */
#aiChatApp .ac-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.6rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
#aiChatApp .ac-messages::-webkit-scrollbar { width: 2px; }
#aiChatApp .ac-messages::-webkit-scrollbar-track { background: transparent; }
#aiChatApp .ac-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.07);
}

#aiChatApp .ac-msg-row {
  display: flex;
  gap: 0.8rem;
  align-items: flex-end;
}
#aiChatApp .ac-msg-row--user { flex-direction: row-reverse; }

/* Blob avatar canvas */
#aiChatApp .ac-blob-av {
  display: block;
  width: 100%;
  height: 100%;
}

/* Avatar: square cell with two-letter symbol, like an element */
#aiChatApp .ac-msg-av {
  width: 32px;
  height: 32px;
  border: none;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#aiChatApp .ac-msg-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Message bubbles — straight-edged to match the grid aesthetic */
#aiChatApp .ac-msg {
  max-width: 68%;
  padding: 0.75rem 1rem;
  font-family: 'Switzer', sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: 0.015em;
}
#aiChatApp .ac-msg--bot {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.88);
}
#aiChatApp .ac-msg--user {
  background: #fff;
  border: none;
  color: #080808;
}

/* Typing indicator */
#aiChatApp .ac-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
}
#aiChatApp .ac-typing span {
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  animation: acBlink 1.2s infinite;
}
#aiChatApp .ac-typing span:nth-child(2) { animation-delay: 0.2s; }
#aiChatApp .ac-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes acBlink {
  0%, 80%, 100% { opacity: 0.2; }
  40%           { opacity: 1; }
}

/* Input area */
#aiChatApp .ac-input-area {
  border-top: none;
  padding: 0.85rem 1.2rem;
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-shrink: 0;
}
#aiChatApp .ac-input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.4rem 0;
  color: #fff;
  font-family: 'Switzer', sans-serif;
  font-size: 13px;
  font-weight: 300;
  letter-spacing: 0.02em;
  outline: none;
  transition: border-color 0.2s;
}
#aiChatApp .ac-input::placeholder { color: rgba(255, 255, 255, 0.2); }
#aiChatApp .ac-input:focus { border-color: rgba(255, 255, 255, 0.45); }
#aiChatApp .ac-input:disabled { opacity: 0.35; cursor: not-allowed; }

#aiChatApp .ac-send-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 4px;
  transition: opacity 0.2s;
  opacity: 0.35;
}
#aiChatApp .ac-send-btn:hover  { opacity: 1; }
#aiChatApp .ac-send-btn:disabled { opacity: 0.15; cursor: not-allowed; }
#aiChatApp .ac-send-btn svg {
  width: 13px;
  height: 13px;
  fill: #fff;
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  #aiChatApp .ac-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    transform: none;
    border: none;
    overscroll-behavior: none;
  }
  #aiChatApp .ac-chat {
    height: 100%;
  }
  #aiChatApp .ac-messages {
    overscroll-behavior: contain;
    min-height: 0;
  }
  #aiChatApp .ac-input-area {
    flex-shrink: 0;
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
  }
  #aiChatApp .ac-header {
    display: flex;
    flex-shrink: 0;
    padding-top: max(0.6rem, env(safe-area-inset-top));
  }
  #aiChatApp .ac-close-btn {
    display: block;
    padding: 12px;
  }
  #aiChatApp .ac-element-symbol {
    font-size: 42px;
  }
}
