/* Demo AI sandbox — /demo/ai (viewport-adaptive) */

.page-demo-ai {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.page-demo-ai .site-header {
  background: rgba(11, 11, 11, 0.88);
  backdrop-filter: blur(10px);
}

.page-demo-ai .site-footer {
  margin-top: 0;
}

.page-demo-ai .cta-block {
  padding-top: 28px;
  padding-bottom: 20px;
}

.page-demo-ai .cta-block__title {
  font-size: clamp(22px, 4vw, 36px);
}

.demo-ai {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding:
    calc(76px + env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
  background:
    radial-gradient(ellipse 70% 50% at 10% 0%, rgba(255, 150, 100, 0.1), transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 20%, rgba(220, 235, 255, 0.06), transparent 50%),
    var(--color-void);
}

.demo-ai__shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(240px, 34%) minmax(0, 1fr);
  gap: clamp(12px, 1.6vw, 20px);
  align-items: stretch;
  min-height: 0;
  height: calc(100dvh - 96px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100dvh - 96px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}

.demo-ai__side {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.5vw, 18px);
  padding: clamp(14px, 2vw, 22px) clamp(14px, 1.8vw, 20px);
  border: 1px solid var(--color-line);
  border-radius: clamp(16px, 2vw, 24px);
  background: linear-gradient(165deg, #161616 0%, #101010 100%);
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.demo-ai__title {
  margin: 0;
  font-family: var(--font-display, "Fraunces", Georgia, serif);
  font-size: clamp(24px, 2.8vw, 36px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--color-ink);
}

.demo-ai__lead {
  margin: 0;
  color: var(--color-ink-soft);
  font-size: clamp(13px, 1.4vw, 15px);
  line-height: 1.45;
  max-width: 36ch;
}

.demo-ai__lead strong {
  color: var(--color-ink);
  font-weight: 500;
}

.demo-ai__block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.demo-ai__block-label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #c48a62;
}

.demo-ai__chips,
.demo-ai__prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.demo-ai__chip,
.demo-ai__prompt {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-pill);
  background: transparent;
  color: rgba(243, 243, 243, 0.88);
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.demo-ai__chip:hover,
.demo-ai__prompt:hover {
  border-color: rgba(255, 200, 170, 0.45);
  color: #fff;
}

.demo-ai__chip.is-on {
  background: #f3f3f3;
  border-color: #f3f3f3;
  color: #0b0b0b;
}

.demo-ai__prompt {
  text-align: left;
  line-height: 1.35;
}

.demo-ai__prompt:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.demo-ai__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 8px;
  color: var(--color-ink-soft);
  font-size: 13px;
}

.demo-ai__cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 14px;
}

.demo-ai__cta .btn-pill {
  font-size: 12px;
  padding-inline: 16px;
}

.demo-ai__lead {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  padding: 14px;
  border: 1px solid rgba(255, 180, 140, 0.28);
  border-radius: 16px;
  background: #121212;
}

.demo-ai__lead.is-on {
  display: flex;
  animation: demo-ai-lead-in 0.22s ease;
}

@keyframes demo-ai-lead-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.demo-ai__lead-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.demo-ai__lead-hint {
  margin: 0 0 2px;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(243, 243, 243, 0.55);
}

.demo-ai__lead input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #161616;
  color: #fff;
  font: inherit;
  font-size: 16px;
  outline: none;
}

.demo-ai__lead input:focus {
  border-color: rgba(255, 180, 150, 0.55);
}

.demo-ai__lead-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.demo-ai__lead-actions button {
  flex: 1;
  padding: 11px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.demo-ai__lead-actions button[type="submit"] {
  background: #f3f3f3;
  border-color: #f3f3f3;
  color: #0b0b0b;
  font-weight: 600;
}

.demo-ai__lead-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.demo-ai__lead-status {
  display: none;
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: #e0894a;
}

.demo-ai__lead-status.is-on {
  display: block;
}

.demo-ai__lead-status.is-ok {
  color: #7dcea0;
}

.demo-ai__chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: clamp(16px, 2vw, 24px);
  overflow: hidden;
  background: rgba(14, 14, 14, 0.96);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.4);
}

.demo-ai__chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: #111;
  flex-shrink: 0;
}

.demo-ai__chat-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.demo-ai__chat-identity > div {
  min-width: 0;
}

.demo-ai__chat-identity strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.demo-ai__chat-identity span {
  display: block;
  font-size: 12px;
  color: rgba(243, 243, 243, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-ai__pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #7dcea0;
  box-shadow: 0 0 0 0 rgba(125, 206, 160, 0.55);
  animation: demo-ai-pulse 2s ease infinite;
  flex-shrink: 0;
}

@keyframes demo-ai-pulse {
  0% { box-shadow: 0 0 0 0 rgba(125, 206, 160, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(125, 206, 160, 0); }
  100% { box-shadow: 0 0 0 0 rgba(125, 206, 160, 0); }
}

.demo-ai__badge {
  flex-shrink: 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #c48a62;
  border: 1px solid rgba(196, 138, 98, 0.35);
  border-radius: var(--radius-pill);
  padding: 6px 10px;
  white-space: nowrap;
}

.demo-ai__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.demo-ai__msg {
  max-width: min(88%, 42ch);
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.demo-ai__msg--bot {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(243, 243, 243, 0.92);
}

.demo-ai__msg-body {
  display: block;
}

.demo-ai__msg-note {
  display: block;
  color: #e0894a;
  font-size: 12.5px;
  font-style: italic;
  line-height: 1.4;
  letter-spacing: 0.01em;
  opacity: 0.95;
}

.demo-ai__msg--user {
  align-self: flex-end;
  background: #f3f3f3;
  color: #0b0b0b;
}

.demo-ai__msg--system {
  align-self: center;
  max-width: 95%;
  text-align: center;
  background: transparent;
  color: rgba(243, 243, 243, 0.5);
  font-size: 13px;
  padding: 6px 10px;
}

.demo-ai__typing {
  display: none;
  gap: 5px;
  padding: 0 18px 10px;
  flex-shrink: 0;
}

.demo-ai__typing.is-on {
  display: flex;
}

.demo-ai__typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  animation: demo-ai-dot 1.1s ease infinite;
}

.demo-ai__typing span:nth-child(2) { animation-delay: 0.15s; }
.demo-ai__typing span:nth-child(3) { animation-delay: 0.3s; }

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

.demo-ai__composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: #0f0f0f;
  flex-shrink: 0;
}

.demo-ai__composer input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-pill);
  background: #151515;
  color: #fff;
  font: inherit;
  font-size: 16px; /* iOS: avoid zoom on focus */
  padding: 12px 16px;
  outline: none;
}

.demo-ai__composer input:focus {
  border-color: rgba(255, 200, 170, 0.45);
}

.demo-ai__composer input:disabled {
  opacity: 0.5;
}

.demo-ai__send {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: #f3f3f3;
  color: #0b0b0b;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.demo-ai__send:hover:not(:disabled) {
  transform: scale(1.04);
}

.demo-ai__send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.demo-ai__send svg {
  width: 20px;
  height: 20px;
}

/* Tablet: slightly tighter sidebar */
@media (max-width: 1100px) {
  .demo-ai__shell {
    grid-template-columns: minmax(220px, 38%) minmax(0, 1fr);
  }
}

/* Mobile / narrow: chat first, settings below, fill viewport */
@media (max-width: 900px) {
  .page-demo-ai .site-footer .cta-dual,
  .page-demo-ai .site-footer .footer-grid {
    display: none;
  }

  .page-demo-ai .cta-block {
    padding-top: 18px;
    padding-bottom: 12px;
  }

  .demo-ai {
    padding-top: calc(68px + env(safe-area-inset-top, 0px));
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  }

  .demo-ai__shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    height: auto;
    max-height: none;
    min-height: calc(100dvh - 78px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .demo-ai__chat {
    order: 0;
    min-height: min(58dvh, 520px);
    height: min(58dvh, 520px);
  }

  .demo-ai__side {
    order: 1;
    max-height: none;
    overflow: visible;
  }

  .demo-ai__lead {
    max-width: none;
  }

  .demo-ai__chip,
  .demo-ai__prompt {
    font-size: 12px;
    padding: 7px 12px;
  }

  .demo-ai__msg {
    max-width: 92%;
    font-size: 14px;
  }
}

/* Small phones */
@media (max-width: 560px) {
  .demo-ai__shell {
    gap: 10px;
  }

  .demo-ai__side {
    padding: 14px 12px;
    border-radius: 18px;
    gap: 12px;
  }

  .demo-ai__title {
    font-size: 22px;
  }

  .demo-ai__lead {
    font-size: 13px;
  }

  .demo-ai__chat {
    border-radius: 18px;
    min-height: min(52dvh, 480px);
    height: min(54dvh, 500px);
  }

  .demo-ai__chat-head {
    padding: 10px 12px;
  }

  .demo-ai__badge {
    font-size: 10px;
    padding: 5px 8px;
  }

  .demo-ai__composer {
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .demo-ai__send {
    width: 44px;
    height: 44px;
  }

  .demo-ai__cta .btn-pill {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
}

/* Short viewports (landscape phones / short laptop) */
@media (max-height: 700px) {
  .demo-ai__shell {
    height: calc(100dvh - 84px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 84px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }

  .demo-ai__title {
    font-size: clamp(20px, 4vh, 28px);
  }

  .demo-ai__lead {
    display: none;
  }

  .demo-ai__side .label {
    display: none;
  }
}

@media (max-width: 900px) and (max-height: 700px) {
  .demo-ai__chat {
    min-height: 42dvh;
    height: 48dvh;
  }
}

/* Wide desktop: keep shell filling available height without footer crowding */
@media (min-width: 901px) {
  .page-demo-ai .site-footer {
    display: none;
  }

  .demo-ai {
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  }
}
