/* Key, the site assistant (js/chat.js, js/chat-ui.js). Colours come from the
   site tokens in site.css, so the dark theme needs no extra rules except the
   few brand fills marked below. */

/* ── launcher ─────────────────────────────────────────────────── */
.kc-launch {
  position: fixed; z-index: 95; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; padding: 0; cursor: pointer;
  display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
}
.kc-launch img { width: 34px; height: auto; }
.kc-launch:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.kc-badge {
  position: absolute; right: -2px; bottom: -2px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; background: var(--navy); color: #f6f3ea; border: 2px solid var(--bg);
}
[data-theme="dark"] .kc-badge { background: #2d4c8f; }
.kc-badge svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; }
.kc-label {
  position: absolute; right: calc(100% + 12px); top: 50%; translate: 0 -50%; white-space: nowrap; pointer-events: none;
  padding: 7px 12px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 700;
  opacity: 0; transform: translateX(6px); transition: opacity 0.2s ease, transform 0.2s ease;
}
@media (hover: hover) { .kc-launch:hover .kc-label, .kc-launch:focus-visible .kc-label { opacity: 1; transform: none; } }
.kc-open .kc-launch .kc-label { display: none; }
.menu-open .kc-launch, .menu-open .kc-tease { opacity: 0; pointer-events: none; }
/* the footer's last row ends in the same corner as the button: keep the button's width free */
.footer-bottom { padding-right: 84px; }
/* the desktop chapter rail on the home film sits in the same corner: make room */
@media (min-width: 881px) { .rail { margin-right: 76px; } }

.kc-tease {
  position: fixed; z-index: 95; right: max(20px, env(safe-area-inset-right)); bottom: calc(max(20px, env(safe-area-inset-bottom)) + 74px);
  max-width: min(260px, calc(100vw - 40px)); padding: 12px 16px; text-align: left; cursor: pointer;
  display: grid; gap: 2px; border-radius: 14px 14px 4px 14px;
  background: var(--paper); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 13.5px; line-height: 1.45;
  opacity: 0; transform: translateY(8px); transition: opacity 0.35s ease, transform 0.35s ease;
}
.kc-tease.on { opacity: 1; transform: none; }
.kc-tease b { font-family: var(--serif); font-size: 16px; font-weight: 600; }
.kc-tease span { color: var(--ink-dim); }

/* ── panel ────────────────────────────────────────────────────── */
.kc {
  position: fixed; z-index: 120; right: max(20px, env(safe-area-inset-right)); bottom: calc(max(20px, env(safe-area-inset-bottom)) + 74px);
  width: min(400px, calc(100vw - 40px)); height: min(640px, calc(100vh - 170px)); height: min(640px, calc(100dvh - 170px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lift);
  font-size: 14.5px; line-height: 1.55;
  animation: kc-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.kc[hidden] { display: none; }
@keyframes kc-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }

.kc-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 10px 12px 14px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.kc-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line); }
.kc-avatar img { width: 26px; height: auto; }
.kc-title { flex: 1; min-width: 0; display: grid; line-height: 1.2; }
.kc-title b { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.kc-sub { font-size: 11.5px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kc-lang { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.kc-lang button { border: 0; background: none; cursor: pointer; padding: 5px 9px; font-size: 12px; font-weight: 700; color: var(--ink-dim); }
.kc-lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.kc-voice {
  flex: none; display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px 0 8px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: none; color: var(--ink-2); font-size: 12px; font-weight: 700;
}
.kc-voice:hover { border-color: var(--gold); color: var(--ink); }
.kc-voice[aria-pressed="true"] { background: linear-gradient(180deg, #275c39, #1e4a2d); border-color: transparent; color: #f6f3ea; }
.kc-voice[hidden] { display: none; }
.kc-voice svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 380px) { .kc-voice span { display: none; } .kc-voice { padding: 0 7px; } }
.kc-icon { flex: none; width: 34px; height: 34px; border: 0; border-radius: 8px; background: none; cursor: pointer; display: grid; place-items: center; color: var(--ink-2); }
.kc-icon:hover { background: var(--chip); }
.kc-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.kc-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; }
.kc-log:focus-visible { outline-offset: -3px; }
.kc-msg { max-width: 92%; animation: kc-msg 0.25s ease; }
@keyframes kc-msg { from { opacity: 0; transform: translateY(6px); } }
.kc-msg p + p, .kc-msg p + ul, .kc-msg ul + p { margin-top: 6px; }
.kc-bot { align-self: flex-start; padding-left: 12px; border-left: 2px solid var(--gold); }
.kc-bot ul { list-style: none; display: grid; gap: 4px; margin-top: 6px; }
.kc-bot li { position: relative; padding-left: 14px; }
.kc-bot li::before { content: ""; position: absolute; left: 0; top: 0.68em; width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.kc-me { align-self: flex-end; padding: 8px 13px; border-radius: 14px 14px 4px 14px; background: var(--chip); color: var(--ink); }
.kc-note { font-size: 12px; color: var(--ink-dim); }
.kc-speaking .kc-bot:last-child { border-left-color: var(--green); }

.kc-acts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; }
.kc-act {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 0; border: 0; background: none; cursor: pointer; text-align: left;
  font-size: 13.5px; font-weight: 700; color: var(--green); border-bottom: 1.5px solid transparent;
}
.kc-act:hover { border-bottom-color: currentColor; }
.kc-act svg { flex: none; width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s ease; }
.kc-act:hover svg { transform: translateX(3px); }

.kc-rel { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.kc-rel span { font-size: 10.5px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-dim); margin-right: 2px; }
.kc-rel button, .kc-sugg button {
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); cursor: pointer;
  padding: 5px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; line-height: 1.35; text-align: left;
}
.kc-rel button:hover, .kc-sugg button:hover { border-color: var(--gold); color: var(--ink); }

.kc-sugg { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 16px 10px; }
.kc-sugg[hidden] { display: none; }

.kc-form { display: flex; align-items: center; gap: 6px; margin: 0 12px; padding: 6px 6px 6px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.kc-form:focus-within { border-color: var(--gold); }
.kc-input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 8px 0; font-size: 15px; color: var(--ink); }
.kc-input::placeholder { color: var(--ink-dim); }
.kc-mic, .kc-send { flex: none; width: 40px; height: 40px; border: 0; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.kc-mic[hidden] { display: none; }
.kc-mic { background: none; color: var(--ink-2); }
.kc-mic:hover { background: var(--chip); }
.kc-send { background: linear-gradient(180deg, #275c39, #1e4a2d); color: #f6f3ea; } /* brand fill: --green-deep is a text colour in the dark */
.kc-mic svg, .kc-send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.kc-listening .kc-mic { background: #b5412f; color: #fff; animation: kc-pulse 1.3s ease-out infinite; }
@keyframes kc-pulse { 0% { box-shadow: 0 0 0 0 rgba(181, 65, 47, 0.45); } 100% { box-shadow: 0 0 0 12px rgba(181, 65, 47, 0); } }
.kc-foot { padding: 8px 16px 12px; font-size: 11px; color: var(--ink-dim); text-align: center; }

/* the product the visitor asked about, on the shelf */
.kc-mark { animation: kc-mark 1.4s ease-in-out 3; outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 12px; }
@keyframes kc-mark { 50% { outline-color: transparent; } }

/* phones: a full-screen sheet */
@media (max-width: 600px) {
  .kc-launch { width: 56px; height: 56px; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); }
  .kc-open .kc-launch { opacity: 0; pointer-events: none; }
  .kc {
    inset: 0; width: auto; height: auto; border: 0; border-radius: 0;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
  }
  .kc-input { font-size: 16px; } /* no iOS zoom on focus */
  .kc-tease { right: max(14px, env(safe-area-inset-right)); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 68px); }
  .footer-bottom { padding-right: 0; padding-bottom: 50px; } /* stacked here: room below instead */
}

@media (prefers-reduced-motion: reduce) {
  .kc, .kc-msg, .kc-listening .kc-mic, .kc-mark { animation: none; }
  .kc-launch, .kc-tease, .kc-label { transition: none; }
}
