/* Byte the cat: companion + chat widget. Shared by index.html and extras.html */
:root { --cat-eye: #ffffff; --cat-pupil: #101828; --cat-mouth: #0a0a0f; }
html[data-theme="light"] { --cat-mouth: #101828; }

.scroll-top { bottom: 7.5rem; }

.cat-companion { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 600; display: flex; align-items: flex-end; gap: .4rem; animation: catBob 4.5s ease-in-out infinite; }
@keyframes catBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.cat-companion.hidden { display: none; }

.cat-figure { position: relative; width: 74px; height: 74px; padding: 0; border: none; background: transparent; cursor: pointer; transform-origin: 50% 100%; transition: transform .18s cubic-bezier(.34,1.56,.64,1); filter: drop-shadow(0 8px 18px rgba(0,0,0,.28)); }
.cat-figure:hover { transform: translateY(-3px) scale(1.04); }
.cat-figure:active { transform: scale(.97); }
.cat-figure:focus-visible, .cat-hide-btn:focus-visible, .cat-chat button:focus-visible, .cat-chat input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cat-figure.pounce { animation: catPounce .5s cubic-bezier(.34,1.56,.64,1); }
@keyframes catPounce { 0% { transform: translateY(0) scale(1); } 30% { transform: translateY(-14px) scale(1.06) rotate(-4deg); } 55% { transform: translateY(2px) scale(.97) rotate(3deg); } 100% { transform: none; } }

.cat-body-fill { fill: var(--accent); }
.cat-eye-white { fill: var(--cat-eye); }
.cat-pupil { fill: var(--cat-pupil); }
.cat-mouth, .cat-nose { stroke: var(--cat-mouth); }
.cat-nose { fill: var(--cat-mouth); }
.cat-ear { transform-origin: 50% 100%; transition: transform .25s cubic-bezier(.34,1.56,.64,1); }
.cat-tail { transform-origin: 78% 82%; animation: catTailIdle 3.6s ease-in-out infinite; }
@keyframes catTailIdle { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(10deg); } }
@keyframes catTailFast { 0%,100% { transform: rotate(-14deg); } 50% { transform: rotate(16deg); } }
.cat-lid { fill: var(--bg-card); opacity: 0; }
.cat-figure.blink .cat-lid { opacity: 1; }
.cat-figure.notice .cat-ear { transform: scaleY(1.12); }
.cat-figure.scrolling .cat-tail { animation: catTailFast .55s ease-in-out infinite; }
.cat-shadow { position: absolute; bottom: -7px; left: 50%; width: 64%; height: 12px; transform: translateX(-50%); background: radial-gradient(ellipse at center, rgba(0,0,0,.38) 0%, transparent 70%); border-radius: 50%; pointer-events: none; }

.cat-bubble { max-width: 168px; padding: .5rem .7rem; margin-bottom: .35rem; background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 12px 12px 4px 12px; color: var(--text); font-size: .74rem; font-weight: 500; line-height: 1.4; box-shadow: 0 10px 30px rgba(0,0,0,.24); opacity: 0; transform: translateY(6px) scale(.96); transition: opacity .2s ease, transform .2s ease; pointer-events: none; }
.cat-bubble.show { opacity: 1; transform: none; }

.cat-hide-btn { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-dim); font-size: .65rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; align-self: flex-start; margin-top: -4px; transition: all .2s ease; }
.cat-hide-btn:hover { color: var(--text); border-color: var(--accent); }

.cat-restore-btn { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 600; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card); color: var(--accent); font-size: 1.15rem; cursor: pointer; display: none; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(0,0,0,.24); }
.cat-restore-btn.show { display: flex; }
.cat-restore-btn:hover { border-color: var(--accent); }

/* ---- chat panel ---- */
.cat-chat { position: fixed; right: 1.25rem; bottom: 6.6rem; z-index: 650; width: min(350px, calc(100vw - 1.5rem)); max-height: min(520px, calc(100svh - 8.5rem)); display: flex; flex-direction: column; background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: hidden; opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(10px) scale(.97); transform-origin: bottom right; transition: opacity .2s ease, transform .2s ease, visibility .2s; }
.cat-chat.open { opacity: 1; visibility: visible; pointer-events: auto; transform: none; }
.cat-chat-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem .9rem; border-bottom: 1px solid var(--border); background: linear-gradient(135deg, var(--accent-glow), transparent); }
.cat-chat-head strong { display: block; font-size: .9rem; color: var(--text); }
.cat-chat-head small { display: block; font-size: .7rem; color: var(--text-dim); }
.cat-chat-close { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text-muted); cursor: pointer; }
.cat-chat-close:hover { border-color: var(--accent); color: var(--accent); }
.cat-chat-log { flex: 1; min-height: 140px; overflow-y: auto; padding: .85rem; display: flex; flex-direction: column; gap: .55rem; }
.cat-msg { max-width: 90%; padding: .5rem .7rem; border-radius: 12px; font-size: .8rem; line-height: 1.5; }
.cat-msg p { margin: 0; }
.cat-msg.bot { align-self: flex-start; background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); border-bottom-left-radius: 4px; }
.cat-msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--g1), var(--g2)); color: var(--bg); font-weight: 500; border-bottom-right-radius: 4px; }
.cat-links { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.cat-links a { font-size: .72rem; font-weight: 600; text-decoration: none; color: var(--accent); background: var(--accent-glow); border: 1px solid var(--accent-dim); border-radius: 100px; padding: .2rem .6rem; }
.cat-links a:hover { background: var(--accent-dim); }
.cat-typing { display: inline-flex; gap: 4px; padding: .2rem 0; }
.cat-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); animation: catDot 1s infinite ease-in-out; }
.cat-typing i:nth-child(2) { animation-delay: .15s; }
.cat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes catDot { 0%,80%,100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.cat-chat-chips { display: flex; flex-wrap: wrap; gap: .35rem; padding: 0 .85rem .7rem; }
.cat-chat-chips:empty { display: none; }
.cat-chat-chips button { font: 600 .72rem/1 inherit; color: var(--text-muted); background: var(--bg); border: 1px solid var(--border); border-radius: 100px; padding: .38rem .7rem; cursor: pointer; transition: all .2s; }
.cat-chat-chips button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.cat-chat-form { display: flex; gap: .5rem; padding: .7rem; border-top: 1px solid var(--border); }
.cat-chat-form input { flex: 1; min-width: 0; padding: .55rem .75rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: 500 .85rem inherit; }
.cat-chat-form input::placeholder { color: var(--text-dim); }
.cat-chat-form button { width: 40px; border-radius: 10px; border: none; background: linear-gradient(135deg, var(--g1), var(--g2)); color: var(--bg); font-size: 1rem; cursor: pointer; }

@media (max-width: 700px) {
    .cat-companion { right: .75rem; bottom: .85rem; }
    .cat-figure { width: 58px; height: 58px; }
    .cat-bubble { max-width: 128px; font-size: .68rem; }
    .cat-restore-btn { right: .75rem; bottom: .85rem; width: 38px; height: 38px; }
    .scroll-top { right: .75rem; bottom: 5.75rem; width: 38px; height: 38px; font-size: 1rem; }
    .cat-chat { right: .75rem; bottom: 5.4rem; }
    .cat-chat-form input { font-size: 16px; } /* stops iOS zoom on focus */
}
@media (prefers-reduced-motion: reduce) {
    .cat-companion, .cat-tail, .cat-figure.pounce, .cat-figure.scrolling .cat-tail, .cat-typing i { animation: none !important; }
    .cat-figure, .cat-ear, .cat-chat, .cat-bubble { transition: none !important; }
}
