/* Hero stage: the character, the speech bubble and the holographic assistant. */
:root {
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --holo-glass: rgb(46 31 22 / .9);
  --holo-edge: rgb(212 154 97 / .5);
  --holo-light: #f2c58a;
  --holo-text: #f1e4d2;
  --holo-muted: #d4bc9d;
  --holo-faint: #b89c7e;
}

.hero-visual,
.hero-visual.hero-visual { padding: 0; align-self: stretch; max-width: none; margin-left: 0; }
.stage { position: relative; height: 100%; min-height: 640px; }
.stage::before {
  content: '';
  position: absolute;
  left: -6%;
  right: -4%;
  bottom: 0;
  height: 62%;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  background: radial-gradient(ellipse at 50% 100%, #e7cfb1 0%, #e7cfb100 70%);
  opacity: .55;
  pointer-events: none;
}

.avatar {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 64%;
  max-width: 352px;
  aspect-ratio: 320 / 560;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  transform-origin: 30% 100%;
  transition: transform .7s var(--ease-out), filter .4s;
  -webkit-tap-highlight-color: transparent;
}
.avatar:hover { filter: drop-shadow(0 18px 22px rgb(46 31 22 / .16)); }
.avatar:active .figure { scale: 1.02 .975; }
.figure { transform-origin: 50% 100%; transition: scale .12s var(--ease-out); }
.avatar:focus-visible { outline: 3px solid var(--rust); outline-offset: 12px; border-radius: 150px 150px 14px 14px; }
.figure { display: block; width: 100%; height: 100%; overflow: visible; }

/* Idle life. */
.body, .head, .eye, .arm, .forearm, .finger, .speech { transform-box: view-box; }
.body { transform-origin: 160px 500px; }
.head { transform-origin: 160px 150px; }
.eye-left { transform-origin: 144px 97px; }
.eye-right { transform-origin: 176px 97px; }
.motion-ready .body { animation: breathe 4.4s ease-in-out infinite; }
.motion-ready .head { animation: head-bob 4.4s ease-in-out infinite; }
.motion-ready .speech { animation: speech-bob 3.4s ease-in-out infinite; }
.stage.is-offscreen .body,
.stage.is-offscreen .head,
.stage.is-offscreen .speech { animation-play-state: paused; }

/* Arms: rest pose, hover wave, and the watch-tap pose. */
#arm-watch { transform-origin: 100px 182px; }
#forearm-watch { transform-origin: 95px 252px; }
#arm-tap { transform-origin: 220px 182px; }
#forearm-tap { transform-origin: 225px 252px; }
#finger { transform-origin: 225px 330px; transform: scaleY(.25); }
.arm, .finger { transition: transform .4s var(--ease-out); }
.forearm { transition: transform .45s cubic-bezier(.34, 1.22, .64, 1); }
/* Anticipation: a small counter-movement right before the tap. */
.stage.is-winding #arm-watch { transform: rotate(6deg); transition-duration: .14s; }
.stage.is-winding #arm-tap { transform: rotate(5deg); transition-duration: .14s; }
/* Idle glance at the watch, a hint toward the interaction. */
.stage.is-glancing #arm-watch { transform: rotate(-24deg); transition: transform .5s var(--ease-out); }
.stage.is-glancing #forearm-watch { transform: rotate(-56deg); transition: transform .55s cubic-bezier(.34, 1.22, .64, 1) .04s; }
.stage.is-glancing .head { transform: rotate(6deg); transition: transform .45s var(--ease-out) .1s; animation: none; }
.stage:not(.is-open) .avatar:hover #arm-tap,
.stage:not(.is-open) .avatar:focus-visible #arm-tap { transform: rotate(-22deg); }
.stage:not(.is-open) .avatar:hover #forearm-tap,
.stage:not(.is-open) .avatar:focus-visible #forearm-tap { transform: rotate(-70deg); transition-delay: .06s; }

.stage.is-open .avatar { transform: translateX(-3%) scale(.7); }
.stage.is-open #arm-watch { transform: rotate(-40deg); transition: transform .6s var(--ease-out); }
.stage.is-open #forearm-watch { transform: rotate(-52deg); transition: transform .7s cubic-bezier(.34, 1.18, .64, 1) .05s; }
.stage.is-open .head { transform: rotate(8deg); transition: transform .5s var(--ease-out) .15s; animation: none; }
.stage.is-open #arm-tap { transform: rotate(-56deg); transition: transform .5s var(--ease-out) .35s; }
.stage.is-open #forearm-tap { transform: rotate(128deg); transition: transform .6s cubic-bezier(.34, 1.16, .64, 1) .42s; }
.stage.is-open #finger { transform: scaleY(1); transition: transform .3s var(--ease-out) .45s; }
.stage.is-open #watch-face { animation: watch-flash .9s ease-out .9s both; }
.stage.is-open #watch-screen { animation: watch-screen .9s ease-out .9s both; }

/* Speech bubble. */
.speech {
  position: absolute;
  left: 66%;
  top: -5%;
  display: block;
  padding: 11px 15px 12px;
  background: #fcf7ef;
  border: 1px solid #ddc7ab;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 14px 28px -14px rgb(98 66 35 / .45);
  font: 600 15px/1.25 var(--sans);
  color: var(--espresso);
  text-align: left;
  white-space: nowrap;
  width: max-content;
  transform: rotate(2deg);
  transition: opacity .25s, transform .4s var(--ease-out);
}
.speech small { display: block; margin-top: 3px; font-size: 12px; font-weight: 400; color: var(--muted); }
.speech::after {
  content: '';
  position: absolute;
  left: -1px;
  bottom: -9px;
  width: 14px;
  height: 14px;
  background: #fcf7ef;
  border-left: 1px solid #ddc7ab;
  border-bottom: 1px solid #ddc7ab;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.avatar:hover .speech { transform: rotate(0) translateY(-3px); }
.stage.is-open .speech { opacity: 0; transform: translateY(8px) scale(.9); pointer-events: none; }

/* Light from the watch to the panel. */
.holo-beam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s;
}
.stage.is-open.has-beam .holo-beam { opacity: 1; transition: opacity .7s var(--ease-out) .1s; }
.holo-beam polygon { fill: url(#beam-grad); filter: blur(4px); }
.holo-beam circle { fill: #f2b56b; filter: blur(8px); opacity: .85; }

/* The panel. */
.holo {
  position: absolute;
  top: -3%;
  right: max(-10%, -44px);
  bottom: 21%;
  width: 62%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  color: var(--holo-text);
  background: var(--holo-glass);
  border: 1px solid var(--holo-edge);
  border-radius: 18px;
  box-shadow: 0 40px 70px -34px rgb(46 31 22 / .7), -18px 22px 70px -28px rgb(196 129 63 / .6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transform-origin: 0 82%;
  visibility: hidden;
  opacity: 0;
  transform: translate(-18px, 10px) scale(.82);
  filter: blur(12px);
  overflow: hidden;
  z-index: 3;
  transition: opacity .3s, transform .35s var(--ease-out), filter .3s, visibility 0s .35s;
}
.stage.is-open .holo {
  visibility: visible;
  opacity: 1;
  transform: none;
  filter: none;
  transition: opacity .55s var(--ease-out) 1s, transform .7s var(--ease-out) 1s, filter .55s var(--ease-out) 1s, visibility 0s 1s;
}
.holo::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(180deg, rgb(255 226 184 / .055) 0 1px, transparent 1px 4px);
  mix-blend-mode: screen;
}
.holo::after {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--holo-light), transparent);
  opacity: .9;
}
.holo ::selection { background: #d9a56d; color: #24170e; }

.holo-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 16px 14px 22px; border-bottom: 1px solid rgb(212 154 97 / .25); }
.holo-head h2 { margin: 0; font: 500 25px/1.1 var(--serif); letter-spacing: -.6px; color: #fbf1e3; }
.holo-head p { margin: 5px 0 0; font-size: 12.5px; color: var(--holo-muted); }
.holo-close {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(212 154 97 / .35);
  border-radius: 50%;
  background: transparent;
  color: var(--holo-muted);
  transition: background .2s, color .2s, transform .2s;
}
.holo-close:hover { background: rgb(212 154 97 / .18); color: #fff3e2; }
.holo-close .icon { width: 16px; height: 16px; }

.holo-log {
  flex: 1;
  margin: 0;
  padding: 16px 20px 6px 22px;
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgb(212 154 97 / .45) transparent;
  overscroll-behavior: contain;
}
.holo-msg { max-width: 94%; font-size: 14.5px; line-height: 1.6; }
.holo-msg.user {
  align-self: flex-end;
  padding: 9px 14px;
  background: rgb(196 129 63 / .22);
  border: 1px solid rgb(212 154 97 / .35);
  border-radius: 14px 14px 4px 14px;
  color: #fbf1e3;
}
.holo-msg.assistant { align-self: flex-start; display: grid; grid-template-columns: 26px 1fr; gap: 11px; }
.holo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--caramel);
  color: #24170e;
  --khanda-ring: #24170e;
}
.holo-mark .khanda { width: 16px; height: 16px; }
.holo-text { margin: 2px 0 0; color: var(--holo-text); }
.holo-text:empty::after,
.is-thinking .holo-log::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 2px;
  border-radius: 50%;
  background: var(--caramel);
  animation: pulse 1s ease-in-out infinite;
}
.is-thinking .holo-log::after { margin: 0 0 0 37px; }
.holo-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.holo-links a {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border: 1px solid rgb(212 154 97 / .5);
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--holo-light);
  transition: background .2s, color .2s;
}
.holo-links a:hover { background: rgb(212 154 97 / .18); color: #fff3e2; }

.holo-chips { display: flex; gap: 6px; padding: 6px 44px 10px 22px; overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); }
.holo-chips::-webkit-scrollbar { display: none; }
.holo-chips button {
  flex-shrink: 0;
  padding: 7px 12px;
  border: 1px solid rgb(212 154 97 / .35);
  border-radius: 20px;
  background: rgb(255 255 255 / .04);
  color: #ead9c2;
  font-size: 12.5px;
  transition: background .2s, border-color .2s;
}
.holo-chips button:hover { background: rgb(212 154 97 / .16); border-color: rgb(212 154 97 / .6); }

.holo-form { display: flex; gap: 8px; padding: 10px 16px 6px 22px; border-top: 1px solid rgb(212 154 97 / .25); }
.holo-form input {
  flex: 1;
  min-width: 0;
  width: auto;
  padding: 11px 13px;
  background: rgb(255 255 255 / .06);
  border: 1px solid rgb(212 154 97 / .35);
  border-radius: 10px;
  color: #fbf1e3;
  font-size: 14.5px;
  line-height: 1.4;
  caret-color: var(--caramel);
}
.holo-form input::placeholder { color: var(--holo-faint); font-size: 14px; }
.holo-form input:focus { border-color: var(--caramel); }
.holo-form input:focus-visible { outline: 2px solid var(--holo-light); outline-offset: 2px; }
.holo-form button {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: var(--caramel);
  color: #24170e;
  transition: background .2s, transform .2s;
}
.holo-form button:hover { background: #d4935a; }
.holo-form button:active { transform: scale(.95); }
.holo-form button .icon { width: 18px; height: 18px; }
.holo-note { margin: 0; padding: 2px 22px 14px; font-size: 12px; color: var(--holo-faint); }

/* Backdrop, used only when the panel becomes a sheet on narrow screens. */
.holo-backdrop { display: none; }

@keyframes breathe { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.012); } }
@keyframes head-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes blink { 0%, 2.4%, 4.6%, 55%, 57%, 59.2%, 100% { transform: scaleY(1); } 3.5%, 58% { transform: scaleY(.08); } }
@keyframes speech-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@keyframes watch-flash {
  0% { fill: #1d1916; filter: drop-shadow(0 0 0 #f2c58a00); }
  35% { fill: #f6d6a8; filter: drop-shadow(0 0 10px #f2c58a); }
  100% { fill: #3a2d22; filter: drop-shadow(0 0 5px #f2c58a99); }
}
@keyframes watch-screen { 0% { opacity: .8; } 35% { opacity: 1; fill: #fff1d8; } 100% { opacity: 1; fill: #f2c58a; } }
@keyframes pulse { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }

@media (max-width: 1100px) {
  .stage { min-height: 580px; }
  .holo { right: -24px; width: 66%; }
  .holo-head h2 { font-size: 22px; }
}

/* Below 960px the panel becomes a sheet over the page. */
@media (max-width: 960px) {
  .stage { min-height: 520px; }
  .avatar { left: 4%; width: 66%; max-width: 300px; }
  .speech { left: 70%; }
  .holo-beam { display: none; }
  .stage.is-open .avatar { transform: none; }
  .holo {
    position: fixed;
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-width: 520px;
    margin-inline: auto;
    height: min(600px, calc(100dvh - 24px));
    transform-origin: 50% 100%;
    transform: translateY(24px) scale(.96);
    z-index: 80;
    background: rgb(46 31 22 / .985);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .stage.is-open .holo { transition-delay: .9s, .9s, .9s, .9s; }
  .holo-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgb(46 31 22 / .38);
    opacity: 0;
    visibility: hidden;
    z-index: 75;
    transition: opacity .35s, visibility 0s .35s;
  }
  body.holo-sheet .holo-backdrop { opacity: 1; visibility: visible; transition: opacity .5s .9s, visibility 0s .9s; }
  .holo-form input { font-size: 16px; }
}
/* The companion opens the panel as a sheet at any width. */
body.holo-forced .holo-beam { display: none; }
body.holo-forced .stage.is-open .avatar { transform: none; }
body.holo-forced .holo {
  position: fixed;
  top: auto;
  right: 12px;
  bottom: 12px;
  left: 12px;
  width: auto;
  max-width: 520px;
  margin-inline: auto;
  height: min(600px, calc(100dvh - 24px));
  transform-origin: 50% 100%;
  transform: translateY(24px) scale(.96);
  z-index: 80;
  background: rgb(46 31 22 / .985);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.holo-forced .stage.is-open .holo { transition-delay: .1s, .1s, .1s, .1s; }
body.holo-forced .holo-backdrop { display: block; position: fixed; inset: 0; background: rgb(46 31 22 / .38); opacity: 1; visibility: visible; z-index: 75; transition: opacity .35s; }
@media (max-width: 700px) {
  .hero-visual.hero-visual { width: 100%; max-width: none; margin-top: 28px; align-self: stretch; }
  .stage { min-height: 540px; }
  .avatar { left: 50%; width: 70%; max-width: 300px; transform: translateX(-62%); transform-origin: 50% 100%; }
  .stage.is-open .avatar { transform: translateX(-62%); }
  .speech { left: 64%; top: -3%; max-width: 42vw; white-space: normal; font-size: 14px; }
  .stage::before { left: 0; right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .motion-ready .body, .motion-ready .head, .motion-ready .eye, .motion-ready .speech { animation: none; }
  .stage.is-open #watch-face { fill: #3a2d22; filter: drop-shadow(0 0 5px #f2c58a99); }
  .stage.is-open #watch-screen { fill: #f2c58a; opacity: 1; }
}
@media print {
  .holo, .holo-beam, .speech { display: none; }
}

/* Life: the eyes and head follow the pointer, blinks are timed by script, the brows and mouth react to hover. */
.pupil { translate: calc(var(--look-x, 0) * 2.4px) calc(var(--look-y, 0) * 1.6px); transition: translate .12s linear; }
.stage:not(.is-open):not(.is-glancing) .head {
  rotate: calc(var(--look-x, 0) * 5deg);
  translate: calc(var(--look-x, 0) * 2.5px) calc(var(--look-y, 0) * 1.5px);
  transition: rotate .2s linear, translate .2s linear;
}
.eye { transition: transform .07s ease-in-out; }
.stage.is-blinking .eye { transform: scaleY(.08); }
.brow, .mouth { transform-box: fill-box; transform-origin: center; transition: translate .25s var(--ease-out), transform .25s var(--ease-out); }
.avatar:hover .brow, .avatar:focus-visible .brow { translate: 0 -2px; }
.avatar:hover .mouth, .avatar:focus-visible .mouth { transform: scaleX(1.2) translateY(.5px); }
.speech small { transition: opacity .2s; }
.speech small.is-swapping { opacity: 0; }

/* Panel extras: boot sweep, clock, voice controls, status line. */
.holo-sweep {
  position: absolute;
  top: -44px;
  left: 0;
  right: 0;
  height: 44px;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(180deg, transparent, rgb(242 197 138 / .32), transparent);
}
.stage.is-open .holo-sweep { animation: holo-sweep 1s ease-out 1.05s both; }
.holo-clock { margin: 6px 0 0; font-size: 12px; color: var(--holo-faint); font-variant-numeric: tabular-nums; }
.holo-controls { display: flex; gap: 6px; flex-shrink: 0; }
.holo-voice {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(212 154 97 / .35);
  border-radius: 50%;
  background: transparent;
  color: var(--holo-muted);
  transition: background .2s, color .2s;
}
.holo-voice:hover { background: rgb(212 154 97 / .18); color: #fff3e2; }
.holo-voice[aria-pressed="true"] { background: var(--caramel); border-color: var(--caramel); color: #24170e; }
.holo-voice .icon { width: 17px; height: 17px; }
.holo-mic {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(212 154 97 / .35);
  border-radius: 10px;
  background: transparent;
  color: var(--holo-muted);
  transition: background .2s, color .2s, border-color .2s;
}
.holo-mic:hover { background: rgb(212 154 97 / .16); color: #fff3e2; }
.holo-mic[aria-pressed="true"] { color: #fff3e2; border-color: var(--holo-light); animation: listening 1.2s ease-in-out infinite; }
.holo-mic .icon { width: 18px; height: 18px; }
.holo-status { margin: 0; padding: 0 22px; font-size: 12px; color: var(--holo-light); min-height: 0; }
.holo-status:empty { position: absolute; width: 1px; height: 1px; padding: 0; margin: 0; overflow: hidden; clip-path: inset(50%); }
.holo-status:not(:empty) { padding-bottom: 6px; }

@keyframes holo-sweep { 0% { opacity: 0; transform: translateY(0); } 12% { opacity: 1; } 100% { opacity: 0; transform: translateY(620px); } }
@keyframes listening { 0%, 100% { box-shadow: 0 0 0 0 rgb(242 197 138 / .45); } 50% { box-shadow: 0 0 0 6px rgb(242 197 138 / 0); } }

@media (prefers-reduced-motion: reduce) {
  .pupil, .stage:not(.is-open):not(.is-glancing) .head { translate: 0 0; rotate: 0deg; }
  .stage.is-blinking .eye { transform: none; }
  .holo-mic[aria-pressed="true"] { animation: none; box-shadow: 0 0 0 2px rgb(242 197 138 / .45); }
  .stage.is-open .holo-sweep { animation: none; }
}
