@import url("https://fonts.googleapis.com/css2?family=Caveat:wght@400;700&family=Ma+Shan+Zheng&family=Noto+Serif+SC:wght@400;700&display=swap");

.wuxia-bg {
  background:
    linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.9)),
    url("https://d4804za1f1gw.cloudfront.net/wp-content/uploads/sites/102/2022/06/chinese-mountains-scaled.jpg");
  background-size: cover;
  background-position: center;
}

/* Toolbar buttons (zoom, prev, next, rotate) */
.viewer-toolbar li {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 215, 0, 0.8);
  border-radius: 8px;
  margin: 0 5px;
  transition: all 0.3s ease;
  cursor: pointer;
}

/* Hover effect */
.viewer-toolbar li:hover {
  background-color: #ffd700;
  transform: scale(1.2);
  box-shadow: 0 0 7px rgba(255, 215, 0, 0.6);
}

.viewer-toolbar {
  padding-bottom: 30px;
}

html {
  scrollbar-gutter: stable;
}

body.viewer-open {
  padding-right: 0 !important;
}

html,
body {
  overflow-x: hidden;
}

.scroll-parchment {
  background: linear-gradient(to right, #c7b288 0%, #f1e4c3 10%, #f5ebd0 20%, #f5ebd0 80%, #f1e4c3 90%, #c7b288 100%);
  border: 4px solid #b39b70;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.15), 0 20px 40px rgba(0,0,0,0.5);
}
.font-handwritten {
  font-family: 'Caveat', cursive;
  font-size: 1.35rem;
}
.seal-btn {
  background-color: #a8201a;
  color: #f5ebd0;
  border: 2px solid #851611;
  font-family: 'Noto Serif SC', serif;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}
.seal-btn:hover {
  background-color: #8f1b16;
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 12px rgba(168,32,26,0.4);
}

/* Dantian Core Chamber Styles */
:root {
  --inner-r: 120px;
  --middle-r: 240px;
  --outer-r: 360px;
}
@media (max-width: 768px) {
  :root {
    --inner-r: 60px;
    --middle-r: 110px;
    --outer-r: 160px;
  }
}

.dantian-path-inner {
  position: absolute;
  width: calc(var(--inner-r) * 2);
  height: calc(var(--inner-r) * 2);
  border: 1px dashed rgba(234, 179, 8, 0.2);
  border-radius: 50%;
  pointer-events: none;
}
.dantian-path-middle {
  position: absolute;
  width: calc(var(--middle-r) * 2);
  height: calc(var(--middle-r) * 2);
  border: 1px dashed rgba(234, 179, 8, 0.2);
  border-radius: 50%;
  pointer-events: none;
}
.dantian-path-outer {
  position: absolute;
  width: calc(var(--outer-r) * 2);
  height: calc(var(--outer-r) * 2);
  border: 1px dashed rgba(234, 179, 8, 0.2);
  border-radius: 50%;
  pointer-events: none;
}

.orbit-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -48px; /* half of wrapper size to center it */
  margin-left: -48px;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.orbit-wrapper:hover {
  animation-play-state: paused;
}
.orbit-wrapper.dragging {
  animation: none !important;
  z-index: 100;
  cursor: grabbing !important;
}
.orbit-wrapper.returning {
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1) !important;
  animation-play-state: paused !important;
}

.orbit-inner {
  animation: orbit-inner-anim 20s infinite linear;
}
.orbit-middle {
  animation: orbit-middle-anim 32s infinite linear;
}
.orbit-outer {
  animation: orbit-outer-anim 44s infinite linear;
}

@keyframes orbit-inner-anim {
  from { transform: rotate(0deg) translateX(var(--inner-r)) rotate(0deg); }
  to { transform: rotate(360deg) translateX(var(--inner-r)) rotate(-360deg); }
}
@keyframes orbit-middle-anim {
  from { transform: rotate(0deg) translateX(var(--middle-r)) rotate(0deg); }
  to { transform: rotate(-360deg) translateX(var(--middle-r)) rotate(360deg); }
}
@keyframes orbit-outer-anim {
  from { transform: rotate(0deg) translateX(var(--outer-r)) rotate(0deg); }
  to { transform: rotate(360deg) translateX(var(--outer-r)) rotate(-360deg); }
}

/* Chakra Orb Styles */
.chakra-orb {
  pointer-events: auto;
  position: relative;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: grab;
  user-select: none;
}
.chakra-orb:active {
  cursor: grabbing;
}
.chakra-orb:hover {
  transform: scale(1.18);
  z-index: 40;
}

.chakra-ring {
  position: absolute;
  inset: -6px; /* float slightly outside */
  border-radius: 50%;
  border: 2px dashed var(--chakra-color, #ffd700);
  animation: spin-chakra 10s infinite linear;
}
/* Hovering the parent wrapper pauses the spin animation of the ring */
.orbit-wrapper:hover .chakra-ring {
  animation-play-state: paused;
}

@keyframes spin-chakra {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.chakra-core {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 calc(var(--size) * 0.25) #fff,
              inset calc(var(--size) * 0.1) 0 calc(var(--size) * 0.4) var(--color1),
              inset calc(var(--size) * -0.1) 0 calc(var(--size) * 0.4) var(--color2),
              inset calc(var(--size) * 0.1) 0 calc(var(--size) * 1.5) var(--color1),
              inset calc(var(--size) * -0.1) 0 calc(var(--size) * 1.5) var(--color2),
              0 0 calc(var(--size) * 0.25) #fff,
              calc(var(--size) * -0.05) 0 calc(var(--size) * 0.4) var(--color1),
              calc(var(--size) * 0.05) 0 calc(var(--size) * 0.4) var(--color3);
  opacity: 0.9;
  animation: pulse-core 3s infinite ease-in-out;
}
@keyframes pulse-core {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.04); opacity: 0.98; }
}

/* Floating Tooltip scroll styling */
.scroll-tooltip {
  position: fixed;
  display: none;
  z-index: 9999;
  pointer-events: none;
  background: linear-gradient(to right, #c7b288 0%, #f1e4c3 10%, #f5ebd0 20%, #f5ebd0 80%, #f1e4c3 90%, #c7b288 100%);
  border: 3px solid #b39b70;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.15), 0 10px 25px rgba(0,0,0,0.5);
  padding: 16px 20px;
  border-radius: 4px;
  width: 320px;
  color: #2d2214;
  transition: opacity 0.2s ease;
  opacity: 0;
}
.scroll-tooltip.visible {
  display: block;
  opacity: 1;
}

/* Chatbot trigger button glow */
#chat-trigger {
  box-shadow: 0 0 15px rgba(217, 119, 6, 0.4);
}
#chat-trigger:hover {
  box-shadow: 0 0 25px rgba(217, 119, 6, 0.8);
}

/* === Chatbot Avatar + Bubble System === */

/* Old Demon avatar - circular, glowing purple ring from the image */
.chat-avatar-bot {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2.5px solid #9b59b6;
  box-shadow: 0 0 12px rgba(155, 89, 182, 0.8), 0 0 24px rgba(155, 89, 182, 0.4);
  flex-shrink: 0;
}

/* User avatar - gold initial badge */
.chat-avatar-user {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #92400e, #d97706);
  border: 2px solid rgba(217, 119, 6, 0.6);
  color: #fef3c7;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(217, 119, 6, 0.4);
}

/* Shared bubble base */
.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.82rem;
  line-height: 1.55;
  word-break: break-word;
}

/* Old Demon bubble — parchment scroll style */
.chat-bubble-bot {
  background: linear-gradient(135deg, #e8d5a3 0%, #f5ebd0 40%, #faf3e0 60%, #e8d5a3 100%);
  border: 2px solid #b8996a;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.08), 0 3px 8px rgba(0,0,0,0.4);
  color: #1a0e05;
  border-radius: 4px 16px 16px 16px; /* flat top-left corner near avatar */
}

/* User bubble — deep indigo-dark glassmorphic with gold accent */
.chat-bubble-user {
  background: linear-gradient(135deg, #1a0a2e 0%, #2d1052 50%, #1a0a2e 100%);
  border: 1.5px solid rgba(217, 119, 6, 0.7);
  box-shadow: 0 0 14px rgba(217, 119, 6, 0.2), 0 4px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
  color: #fde68a;
  border-radius: 16px 4px 16px 16px; /* flat top-right corner near avatar */
}

/* Custom Scrollbar for Chat Messages */
#chat-messages::-webkit-scrollbar {
  width: 6px;
}
#chat-messages::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
#chat-messages::-webkit-scrollbar-thumb {
  background: rgba(217, 119, 6, 0.4);
  border-radius: 3px;
}
#chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(217, 119, 6, 0.7);
}

/* Typing Indicator Animation */
.typing-dot {
  animation: typing-bounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}
