/* rue.html: chat with Rue. Uses site.css for the page, dock and colours */
body.rue-page { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.rue-main { flex: 1; width: 100%; max-width: 780px; margin: 0 auto; padding: 96px 20px 20px; display: flex; flex-direction: column; }

/* The big orb: soft blobs that breathe when idle, swirl when thinking, pulse when answering */
.orb-big { --spd: 1; position: relative; width: 168px; height: 168px; border-radius: 50%; margin: 0 auto 30px; background: #06120f; overflow: hidden; transition: transform .6s cubic-bezier(.2, .7, .2, 1); box-shadow: 0 0 80px -10px rgb(52 211 153 / .45), 0 0 0 1px rgb(255 255 255 / .06); animation: breathe calc(5s / var(--spd)) ease-in-out infinite; }
.orb-big i { position: absolute; width: 75%; height: 75%; border-radius: 50%; filter: blur(22px); mix-blend-mode: screen; animation: swirl calc(9s / var(--spd)) linear infinite; }
.orb-big i:nth-child(1) { background: #34d399; left: -12%; top: -6%; }
.orb-big i:nth-child(2) { background: #22d3ee; right: -14%; top: 18%; animation-duration: calc(11s / var(--spd)); animation-direction: reverse; }
.orb-big i:nth-child(3) { background: #a78bfa; left: 14%; bottom: -18%; animation-duration: calc(13s / var(--spd)); }
.orb-big i:nth-child(4) { background: #f472b6; width: 40%; height: 40%; left: 40%; top: 35%; opacity: .55; animation-duration: calc(7s / var(--spd)); }
.orb-big .gloss { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 30% 25%, rgb(255 255 255 / .55), transparent 30%), radial-gradient(circle at 70% 85%, rgb(0 0 0 / .35), transparent 50%); box-shadow: inset 0 0 30px rgb(255 255 255 / .08); }
@keyframes swirl { from { transform: rotate(0deg) translateX(14%) rotate(0deg); } to { transform: rotate(360deg) translateX(14%) rotate(-360deg); } }
@keyframes breathe { 50% { transform: scale(1.04); } }
[data-state="thinking"] .orb-big, [data-state="thinking"] .orb { --spd: 3.2; }
[data-state="thinking"] .orb-big { box-shadow: 0 0 110px -6px rgb(34 211 238 / .6), 0 0 0 1px rgb(255 255 255 / .08); }
[data-state="speaking"] .orb-big { --spd: 1.8; animation-name: talk; animation-duration: .9s; }
@keyframes talk { 30% { transform: scale(1.07); } 60% { transform: scale(.98); } }
[data-state="thinking"] .orb i { animation-duration: 1.6s; }

/* Empty state */
.rue-empty { margin: auto 0; padding: 30px 0 40px; text-align: center; }
.rue-empty h1 { font-size: clamp(40px, 7vw, 68px); }
.rue-empty > p { color: var(--muted); max-width: 30em; margin: 14px auto 34px; font-size: 17px; }
.sugg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.sugg button { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; cursor: pointer; text-align: left; transition: transform .25s, border-color .25s, background .25s; }
.sugg button:hover { transform: translateY(-3px); border-color: rgb(52 211 153 / .35); background: rgb(52 211 153 / .05); }
.sugg b { font-weight: 600; font-size: 15px; }
.sugg span { color: var(--muted); font-size: 13px; }
.has-chat .rue-empty { display: none; }

/* Conversation */
.rue-bar { position: sticky; top: 78px; z-index: 5; display: none; align-items: center; gap: 12px; margin: 0 -8px 18px; padding: 10px 12px; border-radius: 16px; background: #0b0d12; transition: top .45s cubic-bezier(.2, .7, .2, 1); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
/* Chat text scrolls under the bars, so keep them solid */
.rue-page .dock.scrolled .dock-in { background: #0b0d12; }
/* When the top dock hides on scroll, the Rue bar moves up into its place */
.dock.away ~ .rue-main .rue-bar { top: 14px; }
.has-chat .rue-bar { display: flex; animation: drop-in .5s cubic-bezier(.2, .7, .2, 1); }
@keyframes drop-in { from { opacity: 0; transform: translateY(-10px); } }
.rue-bar .who { flex: 1; line-height: 1.25; }
.rue-bar b { font-weight: 600; }
.rue-bar small { display: block; color: var(--muted); font-size: 12px; transition: color .3s; }
[data-state="thinking"] .rue-bar small { color: var(--cy); }
[data-state="speaking"] .rue-bar small { color: var(--em); }
.ghost-btn { font: 500 13px Geist, sans-serif; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; cursor: pointer; transition: color .2s, border-color .2s; }
.ghost-btn:hover { color: var(--ink); border-color: rgb(255 255 255 / .25); }

.thread { display: flex; flex-direction: column; gap: 22px; padding-bottom: 10px; }
.msg { display: flex; gap: 12px; animation: msg-in .5s cubic-bezier(.2, .7, .2, 1); }
@keyframes msg-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { max-width: 80%; padding: 11px 16px; border-radius: 18px 18px 4px 18px; background: linear-gradient(135deg, #10b981, #0891b2); color: #f0fdfa; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 10px 26px -14px rgb(16 185 129 / .9); }
.msg.rue .orb { width: 30px; height: 30px; margin-top: 2px; }
.msg.rue .body { flex: 1; min-width: 0; }
.text { font-size: 16px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.text a { color: var(--em); }
.text .w { animation: word .45s ease-out both; }
@keyframes word { from { opacity: 0; filter: blur(4px); } }
.text .caret { display: inline-block; width: 8px; height: 1em; margin-left: 2px; vertical-align: -2px; border-radius: 2px; background: var(--em); animation: blink 1s steps(1) infinite; }
.msg.err .text { color: #fda4af; }

/* Live steps from the server while Rue works */
.steps { margin-bottom: 10px; font-size: 14px; color: var(--muted); }
.steps summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; user-select: none; }
.steps summary::-webkit-details-marker { display: none; }
.steps summary::after { content: "›"; transition: transform .2s; }
.steps[open] summary::after { transform: rotate(90deg); }
.steps.live summary { cursor: default; }
.steps.live summary::after { display: none; }
.now { background: linear-gradient(90deg, #6b7585, #e2f6ff 45%, #6b7585 90%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.steps ol { list-style: none; margin: 8px 0 0; padding: 0 0 0 14px; border-left: 1px solid var(--line); }
.steps li { display: flex; align-items: center; gap: 8px; padding: 3px 0; animation: msg-in .35s ease-out; }
.steps li::before { content: ""; width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1.5px solid var(--em); background: radial-gradient(circle, var(--em) 0 3px, transparent 3.5px); }
.steps li.doing::before { border-color: var(--cy) transparent var(--cy) transparent; background: none; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps .reason { margin: 8px 0 0 14px; padding: 8px 12px; border-left: 2px solid var(--line); white-space: pre-wrap; color: var(--faint); max-height: 200px; overflow: auto; }

.actions { display: flex; align-items: center; gap: 6px; margin-top: 10px; opacity: 0; transition: opacity .4s; }
.msg.done .actions { opacity: 1; }
.actions button { display: inline-flex; align-items: center; gap: 5px; font: 12px Geist, sans-serif; color: var(--faint); background: none; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; cursor: pointer; transition: color .2s, border-color .2s; }
.actions button:hover { color: var(--ink); border-color: var(--line); }
.actions svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.actions time { font-size: 12px; color: var(--faint); margin-left: 4px; }
.follow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.follow button { font: 13px Geist, sans-serif; color: #c9d1db; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; cursor: pointer; opacity: 0; transform: translateY(6px); animation: chip-in .4s cubic-bezier(.2, .7, .2, 1) forwards; animation-delay: calc(var(--i) * 90ms + 150ms); transition: border-color .2s, color .2s; }
.follow button:hover { border-color: rgb(52 211 153 / .45); color: var(--ink); }
@keyframes chip-in { to { opacity: 1; transform: none; } }

/* Composer */
.composer-wrap { position: sticky; bottom: 0; z-index: 6; padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.composer { max-width: 740px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 18px; border-radius: 22px; border: 1px solid var(--line); background: rgb(14 16 21 / .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 20px 50px -20px #000; transition: border-color .25s, box-shadow .25s; grid-template-columns: none; }
.composer:focus-within { border-color: rgb(52 211 153 / .45); box-shadow: 0 0 0 4px rgb(52 211 153 / .08), 0 20px 50px -20px #000; }
.composer textarea { flex: 1; min-height: 0; max-height: 160px; resize: none; border: 0; background: none; padding: 9px 0; font: 16px/1.5 Geist, sans-serif; color: var(--ink); box-shadow: none; }
.composer textarea:focus { box-shadow: none; }
.count { align-self: center; font: 11px "Geist Mono", monospace; color: var(--faint); }
.count.warn { color: #fbbf24; }
.send { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 0; border-radius: 14px; cursor: pointer; background: var(--grad); color: #03110b; transition: transform .2s, opacity .2s, background .3s; }
.send:hover { transform: scale(1.06); }
.send:disabled { opacity: .35; cursor: default; transform: none; }
.send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.send .stop { display: none; width: 12px; height: 12px; border-radius: 3px; background: currentColor; }
.busy .send { background: #e2e8f0; opacity: 1; cursor: pointer; }
.busy .send svg { display: none; }
.busy .send .stop { display: block; }
.fine { max-width: 740px; margin: 8px auto 0; text-align: center; font-size: 12px; color: var(--faint); }
.fine kbd { font: 11px "Geist Mono", monospace; padding: 1px 5px; border: 1px solid var(--line); border-radius: 5px; }

@media (max-width: 760px) {
  .rue-main { padding-top: 84px; }
  .rue-bar { top: 70px; }
  .orb-big { width: 128px; height: 128px; }
  .sugg { grid-template-columns: 1fr; }
  .sugg button:nth-child(n+4) { display: none; }
  .fine kbd, .fine .k { display: none; }
}
