/* candy.css — CANDY, the trading AI in the corner (candy.js), and her boot-up intro. */
/* Her dock: a bar of its own right above the status bar (layout.js reserves its height in --ui-bottom), so
   she never covers anything and nothing covers her. Fixed height: talking never moves the layout.
   When she talks the line leaves the dock: her face jumps up and the line pops out as a speech bubble
   that rises over the bottom of the screen (user, 2026-10-16: a static strip was easy to miss). */
:root { --candy-h: 52px; }
.candy { position: fixed; left: 0; right: 0; bottom: var(--dock-at, 36px); z-index: 24; height: var(--candy-h); box-sizing: border-box; display: flex; align-items: center; gap: 10px; padding: 0 8px 0 6px; background: rgb(8, 6, 20); border-top: 1px solid rgba(255, 111, 181, 0.3); }
.candy[hidden] { display: none; }
.candy.talking { border-top-color: #ff6fb5; }
.candy-face { flex: none; width: 48px; height: 48px; padding: 0; border: 0; background: transparent; cursor: pointer; position: relative; }
.candy-face:focus-visible { outline: 2px solid #ff6fb5; outline-offset: 1px; }
.candy-sprite { display: block; width: 72px; height: 72px; background: url("assets/pixel/claude/candy/candy.png") no-repeat; background-size: 504px 72px; background-position: calc(var(--f, 0) * -72px) 0; image-rendering: pixelated; }
.candy-face .candy-sprite { width: 48px; height: 48px; background-size: 336px 48px; background-position: calc(var(--f, 0) * -48px) 0; }   /* 1:1 pixels */
.candy.talking .candy-face .candy-sprite { animation: candyBob 0.7s steps(2) infinite; }
@keyframes candyBob { 50% { transform: translateY(-2px); } }
.candy-pip { position: absolute; top: 0; right: 0; width: 8px; height: 8px; background: #ff6fb5; border: 2px solid #14102a; }
.candy-bubble { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; gap: 12px; color: var(--ink, #eaf0ff); font-size: 13px; line-height: 1.35; }
.candy-top { flex: none; display: flex; flex-direction: column; gap: 1px; font-size: 11px; letter-spacing: 1px; color: #ff9fd1; line-height: 1.2; }
.candy-lvl { color: var(--ink-3, #6f7fa6); white-space: nowrap; }
.candy-say { flex: 1; min-width: 0; max-height: calc(var(--candy-h) - 8px); overflow-y: auto; scrollbar-width: thin; }
.candy-text { margin: 0; }
.candy.idle .candy-text { color: var(--ink-3, #6f7fa6); }
.candy-menu { display: none; }
.candy.menu-on .candy-say { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.candy.menu-on .candy-text { flex: none; white-space: nowrap; }
.candy.menu-on .candy-menu { display: flex; gap: 6px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.candy-menu .btn { flex: none; white-space: nowrap; }
/* the tour (candytour.js): her line wraps, the buttons sit at the end of the dock */
.candy.tour-on .candy-say { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.candy.tour-on .candy-text { flex: 1; min-width: 0; max-height: calc(var(--candy-h) - 8px); overflow-y: auto; }
.candy.tour-on .candy-menu { display: flex; flex: none; gap: 6px; }
/* a question (candytalk.js): her line, then the answers */
.candy.ask-on .candy-say { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.candy.ask-on .candy-text { flex: 1; min-width: 0; max-height: calc(var(--candy-h) - 8px); overflow-y: auto; }
.candy.ask-on .candy-menu { display: flex; flex: none; gap: 6px; max-width: 60%; overflow-x: auto; scrollbar-width: none; }
.candy.ask-on .candy-face .candy-pip { display: none; }
.candy-x { flex: none; background: none; border: 0; color: #ff9fd1; cursor: pointer; font: inherit; font-size: 18px; line-height: 1; padding: 4px 6px; }
.candy-x[hidden] { display: none; }
/* ---------- her voice: the face jumps, the line pops out as a bubble ---------- */
/* The dock keeps its reserved height; the face and the bubble rise out of it (overflow, not layout),
   so a line is impossible to miss but never moves the screens. The bubble sits on the left, by her face. */
.candy { overflow: visible; }
.candy-face { align-self: flex-end; margin-bottom: 2px; transition: width 0.18s ease, height 0.18s ease; }
.candy-face .candy-sprite { transform-origin: 50% 100%; }
.candy.talking .candy-face { width: 72px; height: 72px; margin-top: -24px; }
.candy.talking .candy-face .candy-sprite { width: 72px; height: 72px; background-size: 504px 72px; background-position: calc(var(--f, 0) * -72px) 0; filter: drop-shadow(0 0 8px rgba(255, 111, 181, 0.55)); }
.candy.talking .candy-bubble { position: absolute; left: 86px; bottom: 6px; height: auto; max-width: min(620px, calc(100vw - 110px)); min-height: 40px; box-sizing: border-box;
  flex-direction: column; align-items: stretch; gap: 4px; padding: 9px 14px 10px; background: #160d2c; border: 2px solid #ff6fb5; border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.6), 0 0 22px rgba(255, 111, 181, 0.28); font-size: 14.5px; z-index: 1; }
.candy.talking .candy-bubble::before { content: ""; position: absolute; left: -11px; bottom: 14px; border: 9px solid transparent; border-right: 11px solid #ff6fb5; border-left: 0; }
.candy.talking .candy-bubble::after { content: ""; position: absolute; left: -7px; bottom: 16px; border: 7px solid transparent; border-right: 8px solid #160d2c; border-left: 0; }
.candy.talking .candy-top { flex-direction: row; gap: 8px; align-items: baseline; }
.candy.talking .candy-say { max-height: min(38vh, 260px); overflow-y: auto; }
.candy.talking .candy-text { color: var(--ink, #eaf0ff); }
/* answers and menus wrap under the line instead of scrolling sideways */
.candy.talking.menu-on .candy-say, .candy.talking.ask-on .candy-say, .candy.talking.tour-on .candy-say { flex-direction: column; align-items: stretch; overflow-y: auto; gap: 8px; }
.candy.talking.menu-on .candy-text, .candy.talking.ask-on .candy-text, .candy.talking.tour-on .candy-text { flex: none; white-space: normal; max-height: none; }
.candy.talking .candy-menu { flex-wrap: wrap; max-width: none; overflow: visible; }
.candy.talking.ask-on .candy-menu, .candy.talking.tour-on .candy-menu { flex-direction: row; }
.candy.talking .candy-bubble { padding-right: 34px; }
.candy.talking .candy-x { position: absolute; top: 3px; right: 4px; }
/* a new line: the face jumps, the bubble pops from her mouth, a pink ring pulses twice */
.candy.pop .candy-face .candy-sprite { animation: candyJump 0.5s cubic-bezier(.3, 1.6, .5, 1) both; }
.candy.pop .candy-bubble { animation: candyBubble 0.32s cubic-bezier(.2, 1.4, .4, 1) both; transform-origin: 0 100%; }
.candy.pop .candy-face::after { content: ""; position: absolute; inset: -6px; border: 2px solid #ff6fb5; border-radius: 50%; animation: candyRing 0.9s ease-out 2; pointer-events: none; }
@keyframes candyJump { 0% { transform: translateY(14px) scale(0.8); } 55% { transform: translateY(-10px) scale(1.06); } 100% { transform: none; } }
@keyframes candyBubble { from { opacity: 0; transform: scale(0.6) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes candyRing { from { opacity: 0.9; transform: scale(0.7); } to { opacity: 0; transform: scale(1.5); } }
/* a big moment (a wedding, eviction, the hospital, a level-up): a bigger face and a bigger voice */
.candy.big .candy-face { width: 96px; height: 96px; margin-top: -48px; }
.candy.big .candy-face .candy-sprite { width: 96px; height: 96px; background-size: 672px 96px; background-position: calc(var(--f, 0) * -96px) 0; }
.candy.big .candy-bubble { left: 110px; max-width: min(680px, calc(100vw - 134px)); font-size: 16px; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.65), 0 0 34px rgba(255, 111, 181, 0.45); }
/* lines you missed: the pip stays until you open her menu */
.candy-pip { border-radius: 50%; }
.candy:not(.talking) .candy-pip:not([hidden]) { animation: candyPip 1.6s ease-in-out infinite; }
@keyframes candyPip { 50% { transform: scale(1.35); box-shadow: 0 0 8px #ff6fb5; } }
/* between lines she breathes, so the dock never looks dead */
.candy.idle .candy-face .candy-sprite { animation: candyBreathe 3.2s ease-in-out infinite; }
@keyframes candyBreathe { 50% { transform: translateY(-1px) scaleY(1.02); } }
.candy.idle .candy-face:hover .candy-sprite { animation: candyBob 0.7s steps(2) infinite; }
@media (prefers-reduced-motion: reduce) {
  .candy.pop .candy-face .candy-sprite, .candy.pop .candy-bubble, .candy.pop .candy-face::after, .candy.idle .candy-face .candy-sprite, .candy-pip, .candy.talking .candy-face .candy-sprite { animation: none !important; }
}

html.pc98 .candy { background: #000011; border-top: 2px solid #5a2d6e; }
html.pc98 .candy.talking .candy-bubble { background: #000011; border-radius: 0; box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.8); font-size: 17px; }
html.pc98 .candy.talking .candy-bubble::after { border-right-color: #000011; }
html.pc98 .candy.pop .candy-face::after, html.pc98 .candy-pip { border-radius: 0; }
html.pc98 .candy.talking { border-top-color: #ff6fb5; }
html.pc98 .candy-bubble { font-size: 16px; line-height: 1.25; }
html.pc98 .candy-top { font-size: 14px; letter-spacing: 0; }


/* the boot-up intro */
.candy-boot { position: fixed; inset: 0; z-index: 200; background: rgba(4, 5, 16, 0.94); display: grid; place-items: center; padding: 16px; }
.cb-win { width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: #0b1022; border: 2px solid #ff6fb5; box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.7); }
.cb-head { display: flex; justify-content: space-between; align-items: center; background: #ff6fb5; color: #14102a; padding: 4px 10px; font-size: 13px; letter-spacing: 1px; }
.cb-skip { background: none; border: 0; color: #14102a; text-decoration: underline; cursor: pointer; font: inherit; }
.cb-body { display: flex; gap: 18px; padding: 18px; min-height: 300px; overflow: hidden; }
.cb-face { flex: none; }
.cb-face .candy-sprite { width: 144px; height: 144px; background-size: 1008px 144px; background-position: calc(var(--f, 0) * -144px) 0; animation: candyBob 0.9s steps(2) infinite; }
.cb-log { flex: 1; overflow-y: auto; max-height: 52vh; font-size: 15px; line-height: 1.5; padding-right: 4px; }
.cb-log p { margin: 0 0 10px; }
.cb-sys { color: #6f7aa6; font-size: 12px; }
.cb-candy { color: #ffd6ec; }
.cb-you { color: #53f5b0; text-align: right; }
.cb-you::before { content: "> "; }
.cb-perk { text-align: right; }
.cb-tag { display: inline-block; border: 1px solid rgba(83, 245, 176, 0.4); color: #a9f5d6; padding: 3px 8px; font-size: 12px; text-align: left; max-width: 460px; }
.cb-input { padding: 12px 18px 18px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid rgba(255, 111, 181, 0.25); }
.cb-input:empty { display: none; }
.cb-opt { text-align: left; white-space: normal; }
.cb-name { display: flex; gap: 8px; }
.cb-name input { flex: 1; }

@media (max-width: 760px) {
  :root, html.pc98 { --candy-h: 60px; }
  .candy { gap: 8px; padding: 0 4px 0 4px; }
  .candy-top { display: none; }
  .candy.talking .candy-face { width: 56px; height: 56px; margin-top: -10px; }
  .candy.talking .candy-face .candy-sprite { width: 56px; height: 56px; background-size: 392px 56px; background-position: calc(var(--f, 0) * -56px) 0; }
  .candy.big .candy-face { width: 72px; height: 72px; margin-top: -26px; }
  .candy.big .candy-face .candy-sprite { width: 72px; height: 72px; background-size: 504px 72px; background-position: calc(var(--f, 0) * -72px) 0; }
  .candy.talking .candy-bubble, .candy.big .candy-bubble { left: 68px; right: 8px; max-width: none; font-size: 13px; padding: 8px 10px; }
  .candy.big .candy-bubble { left: 84px; }
  .candy.talking .candy-top { display: none; }
  .candy.talking .candy-menu .btn { padding: 4px 9px; font-size: 12px; }
  .candy-bubble, html.pc98 .candy-bubble { font-size: 12px; line-height: 1.3; }
  .cb-body { flex-direction: column; align-items: center; min-height: 0; }
  .cb-face .candy-sprite { width: 96px; height: 96px; background-size: 672px 96px; background-position: calc(var(--f, 0) * -96px) 0; }
  .cb-log { max-height: 40vh; width: 100%; }
}

/* Touch: answers big enough to tap; the bubble wraps them. */
@media (pointer: coarse) {
  .candy.talking .candy-menu .btn { min-height: 34px; padding: 4px 10px; font-size: 12.5px; }
}
