/* CarDecision motion + chatbot
 * Reveals must NEVER hide content (opacity:0 on tall sections caused blank homepage).
 */
@media (prefers-reduced-motion: no-preference) {
  html.cw-js .cd-reveal {
    /* Soft lift only — content stays readable even if JS/observer fails */
    transform: translateY(10px);
    transition: transform 0.45s ease, box-shadow 0.25s ease;
  }
  html.cw-js .cd-reveal.is-in {
    transform: none;
  }
  .cd-nav {
    transition: box-shadow 0.25s ease, background 0.25s ease;
  }
  .cd-nav.is-scrolled {
    box-shadow: 0 10px 30px rgba(11, 31, 51, 0.08);
  }
  .cw-brand, .result-card, .car-card, .cd-drawer-card, .btn {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  }
  .result-card:hover, .car-card:hover, .cw-brand:hover {
    transform: translateY(-3px);
  }
  .btn:active {
    transform: scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  html.cw-js .cd-reveal,
  html.cw-js .cd-reveal.is-in {
    transform: none;
    transition: none;
  }
}

.cd-chat-root {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--bottom-nav-h, 72px) + 1rem);
  z-index: 95;
  font-family: var(--font-sans, inherit);
}
@media (min-width: 900px) {
  .cd-chat-root { bottom: 1.25rem; right: 1.25rem; }
}

.cd-chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 0;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(145deg, #ff6b1a 0%, #e85d04 55%, #c44d03 100%);
  box-shadow: 0 12px 28px rgba(232, 93, 4, 0.35);
  display: grid;
  place-items: center;
}
.cd-chat-toggle:focus-visible {
  outline: 3px solid rgba(232, 93, 4, 0.45);
  outline-offset: 3px;
}
.cd-chat-toggle svg { width: 26px; height: 26px; }
.cd-chat-toggle[aria-expanded="true"] {
  background: var(--brand-ink, #0B1F33);
  box-shadow: 0 12px 28px rgba(11, 31, 51, 0.28);
}

.cd-chat-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: min(380px, calc(100vw - 2rem));
  max-height: min(560px, 72vh);
  display: flex;
  flex-direction: column;
  background: var(--surface, #fff);
  color: var(--on-surface, #0B1F33);
  border: 1px solid var(--outline, var(--brand-line));
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(11, 31, 51, 0.22);
}
.cd-chat-panel[hidden] { display: none !important; }
html[data-theme="dark"] .cd-chat-panel {
  background: #121a24;
  color: #eef3f7;
  border-color: rgba(255,255,255,0.1);
}

.cd-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.75rem 0.85rem 1rem;
  background: linear-gradient(120deg, #0B1F33, #1E5A7A);
  color: #fff;
}
.cd-chat-head-text { min-width: 0; flex: 1; }
.cd-chat-head strong { display: block; font-family: var(--font-display); font-size: 1rem; }
.cd-chat-head span { display: block; font-size: 0.78rem; opacity: 0.85; line-height: 1.35; margin-top: 0.15rem; }

.cd-chat-close {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  margin: -0.15rem -0.1rem 0 0;
  border: 0;
  border-radius: 12px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.cd-chat-close:hover { background: rgba(255,255,255,0.22); }
.cd-chat-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.cd-chat-log {
  flex: 1;
  overflow: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 160px;
  background: linear-gradient(180deg, rgba(14,118,110,0.05), transparent 40%);
}
.cd-chat-msg {
  max-width: 92%;
  padding: 0.65rem 0.8rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.cd-chat-msg.is-thinking { opacity: 0.75; font-style: italic; }
.cd-chat-msg.user {
  align-self: flex-end;
  background: var(--brand-accent, #E85D04);
  color: #fff;
}
.cd-chat-msg.bot {
  align-self: flex-start;
  background: var(--brand-mist, #E8EEF2);
  color: var(--brand-ink, #0B1F33);
}
html[data-theme="dark"] .cd-chat-msg.bot {
  background: rgba(255,255,255,0.08);
  color: #eef3f7;
}
.cd-chat-meta {
  margin-top: 0.45rem;
  font-size: 0.72rem;
  opacity: 0.8;
}
.cd-chat-sources {
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.cd-chat-sources a {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  background: rgba(30, 90, 122, 0.12);
  color: var(--brand-steel, #1E5A7A);
  text-decoration: none;
}
html[data-theme="dark"] .cd-chat-sources a {
  background: rgba(255,255,255,0.1);
  color: #9ec9e6;
}
.cd-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--outline, var(--brand-line));
  align-items: stretch;
}
.cd-chat-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--outline, var(--brand-line));
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  background: transparent;
  color: inherit;
  min-height: 48px;
}
.cd-chat-form button,
.cd-chat-send {
  border: 0;
  border-radius: 12px;
  padding: 0 1.1rem;
  min-height: 48px;
  background: var(--brand-accent, #E85D04);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  flex: 0 0 auto;
}
.cd-chat-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.cd-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 0.85rem 0.65rem;
}
.cd-chat-chips button {
  border: 1px solid var(--outline, var(--brand-line));
  background: transparent;
  color: inherit;
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  min-height: 36px;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1.2;
}
.cd-chat-chips button:hover {
  border-color: var(--brand-accent, #E85D04);
  color: var(--brand-accent, #E85D04);
}
.cd-chat-chips[aria-busy="true"] button {
  opacity: 0.55;
  pointer-events: none;
}
