@tailwind base;
@tailwind components;
@tailwind utilities;

/* ── DreamForge Theme Variables (aligned with DreamServer Dashboard) ── */
:root {
  --theme-card: #18181b;
  --theme-border: #27272a;
  --theme-accent: #9d00ff;
  --liquid-card-fill: linear-gradient(#18181b, #18181b);
  --liquid-soft-fill: linear-gradient(#18181b, #18181b);
  --liquid-nav-fill: linear-gradient(135deg, rgba(157,0,255,0.92), rgba(123,31,228,0.92));
  --liquid-button-fill: linear-gradient(135deg, rgba(157,0,255,0.95), rgba(123,31,228,0.92));
  --liquid-progress-track: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f13;
}

/* ── Scrollbar (matches Dashboard) ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #18181b; }
::-webkit-scrollbar-thumb { background: #3f3f46; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #52525b; }

/* ── Markdown code blocks ── */
pre code {
  display: block;
  padding: 0.75rem 1rem;
  background: #1e1e2e;
  border-radius: 0.5rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.5;
}

code {
  background: #374151;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
}

pre code code {
  background: none;
  padding: 0;
}

/* ── Thinking animation ── */
@keyframes thinking-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}
.thinking-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9d00ff;
  animation: thinking-pulse 1.4s ease-in-out infinite;
}
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Pulsing status dot ── */
@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.status-pulse {
  animation: status-pulse 1.5s ease-in-out infinite;
}

/* ══════════════════════════════════════════════════════════════════════
   Liquid Metal Animation System (from DreamServer Dashboard)
   ══════════════════════════════════════════════════════════════════════ */

@property --liquid-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 220deg;
}

@keyframes liquidMetalOrbit {
  from { --liquid-angle: 220deg; }
  to { --liquid-angle: 580deg; }
}

@keyframes liquidMetalFlow {
  from { background-position: 0px 50%; }
  to { background-position: -132px 50%; }
}

@keyframes liquidBorderOrbit {
  from { background-position: 180% 0%; }
  to { background-position: -60% 100%; }
}

@keyframes liquidBorderSequence {
  0% {
    background-position: 180% 0%;
    opacity: 0;
  }
  3.5% { opacity: 0.54; }
  8.5% {
    background-position: -60% 100%;
    opacity: 0;
  }
  100% {
    background-position: -60% 100%;
    opacity: 0;
  }
}

/* ── Base frame, nav, button ── */
.liquid-metal-frame,
.liquid-metal-nav,
.liquid-metal-button {
  position: relative;
  isolation: isolate;
  border: 1px solid color-mix(in srgb, var(--theme-border) 82%, white 18%) !important;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 -14px 24px rgba(0,0,0,0.14);
}

.liquid-metal-frame {
  background: var(--liquid-card-fill);
}

.liquid-metal-frame::before,
.liquid-metal-nav::before,
.liquid-metal-button::before {
  content: none;
}

.liquid-metal-frame::after,
.liquid-metal-nav::after,
.liquid-metal-button::after {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(
      115deg,
      transparent 24%,
      rgba(255,255,255,0.015) 34%,
      rgba(255,255,255,0.96) 45%,
      rgba(255,220,152,0.78) 49%,
      rgba(157,0,255,0.22) 54%,
      transparent 66%
    );
  background-size: 240% 240%;
  background-repeat: no-repeat;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: liquidBorderOrbit 11s linear infinite;
  opacity: 0.28;
  z-index: 0;
  transition:
    opacity 180ms ease,
    filter 180ms ease,
    background-size 220ms ease;
}

.liquid-metal-frame > *,
.liquid-metal-nav > *,
.liquid-metal-button > * {
  position: relative;
  z-index: 1;
}

/* ── Frame hover ── */
.liquid-metal-frame:hover {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    0 0 0 1px rgba(255,255,255,0.04),
    0 18px 36px rgba(0,0,0,0.22);
}

.liquid-metal-frame:hover::after {
  animation-name: liquidBorderOrbit;
  animation-duration: 3.6s;
  animation-delay: -1.15s;
  opacity: 0.92;
  background-size: 190% 190%;
  filter: saturate(1.2) brightness(1.08);
}

/* ── Soft variant ── */
.liquid-metal-frame--soft {
  background: var(--liquid-soft-fill);
}

.liquid-metal-frame--soft::after {
  animation-duration: 12.8s;
  opacity: 0.2;
}

/* ── Nav active state ── */
.liquid-metal-nav {
  background: var(--liquid-nav-fill) !important;
}

.liquid-metal-nav::after {
  animation-duration: 3.2s;
  opacity: 0.88;
}

/* ── Button ── */
.liquid-metal-button {
  background: var(--liquid-button-fill) !important;
  box-shadow: 0 14px 30px rgba(94, 24, 178, 0.28);
}

.liquid-metal-button::after {
  animation-duration: 5.8s;
  opacity: 0.9;
}

.liquid-metal-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 36px rgba(94, 24, 178, 0.28);
}

/* ── Sequence grid (staggered animations) ── */
.liquid-metal-sequence-grid {
  --liquid-sequence-step: 3.4s;
}

.liquid-metal-sequence-grid--sessions {
  --liquid-sequence-duration: 42s;
}

.liquid-metal-sequence-grid > *:nth-child(1) { --liquid-sequence-delay: 0s; }
.liquid-metal-sequence-grid > *:nth-child(2) { --liquid-sequence-delay: calc(var(--liquid-sequence-step) * 1); }
.liquid-metal-sequence-grid > *:nth-child(3) { --liquid-sequence-delay: calc(var(--liquid-sequence-step) * 2); }
.liquid-metal-sequence-grid > *:nth-child(4) { --liquid-sequence-delay: calc(var(--liquid-sequence-step) * 3); }
.liquid-metal-sequence-grid > *:nth-child(5) { --liquid-sequence-delay: calc(var(--liquid-sequence-step) * 4); }
.liquid-metal-sequence-grid > *:nth-child(6) { --liquid-sequence-delay: calc(var(--liquid-sequence-step) * 5); }
.liquid-metal-sequence-grid > *:nth-child(7) { --liquid-sequence-delay: calc(var(--liquid-sequence-step) * 6); }
.liquid-metal-sequence-grid > *:nth-child(8) { --liquid-sequence-delay: calc(var(--liquid-sequence-step) * 7); }
.liquid-metal-sequence-grid > *:nth-child(9) { --liquid-sequence-delay: calc(var(--liquid-sequence-step) * 8); }
.liquid-metal-sequence-grid > *:nth-child(10) { --liquid-sequence-delay: calc(var(--liquid-sequence-step) * 9); }

.liquid-metal-sequence-card::after {
  animation-name: liquidBorderSequence;
  animation-duration: var(--liquid-sequence-duration, 12.8s);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-delay: var(--liquid-sequence-delay, 0s);
  opacity: 0;
}

.liquid-metal-sequence-card:hover::after {
  animation-name: liquidBorderOrbit;
  animation-duration: 3.6s;
  animation-delay: -1.15s;
  opacity: 0.96;
  background-size: 190% 190%;
  filter: saturate(1.24) brightness(1.08);
}

.liquid-metal-sequence-card:hover {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 0 1px rgba(255,255,255,0.05),
    0 20px 38px rgba(0,0,0,0.24);
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .liquid-metal-frame::after,
  .liquid-metal-nav::after,
  .liquid-metal-button::after,
  .liquid-metal-sequence-card::after {
    animation: none !important;
    opacity: 0 !important;
  }
  .liquid-metal-button:hover {
    transform: none;
  }
  .thinking-dot {
    animation: none;
    opacity: 1;
  }
}
