/* ============================
   speak.css — Mobile-First Base
   ============================ */

/* ----- Base ----- */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  color: #f4e8d5;
  font-family: Georgia, serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: #000;

  /* page scrolls normally */
  overflow-x: hidden;
  overflow-y: auto;
}


/* ----- Background layers ----- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(to bottom, rgba(0,0,0,0.25), rgba(0,0,0,0.35)),
    url("../images/stage_background.jpg") center / cover no-repeat;
}


body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: url("../images/clara_on_stage.png") center top / auto 100vh no-repeat;

  /* strong feather at the edges */
  -webkit-mask-image: radial-gradient(
    circle at center,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 1) 55%,
    rgba(0, 0, 0, 0) 90%
  );
  mask-image: radial-gradient(
    circle at center,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 1) 55%,
    rgba(0, 0, 0, 0) 90%
  );
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;

  /* start invisible so the fade actually happens */
  opacity: 0;

  /* Entrance + one-time shimmer */
  animation:
    claraSlowFadeIn 4s ease-out forwards,
    shimmerOnce 5s ease-out 4s;
}



/* ----- Embers: non-text glowing particles ----- */
.embers {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2; /* behind UI, above foreground, above fog */
  overflow: hidden;
}


/* Individual ember particle (no text color at all) */
.ember {
  position: absolute;
  width: 5px;
  height: 10px;
  border-radius: 50%;

  /* soft warm glow */
  background: radial-gradient(
    circle at 30% 10%,
    rgba(255, 220, 160, 1) 0%,
    rgba(255, 150, 60, 0.9) 40%,
    rgba(120, 40, 0, 0) 70%
  );
  box-shadow:
    0 0 8px rgba(255, 160, 80, 0.8),
    0 0 16px rgba(255, 120, 40, 0.6);

  opacity: 0;
  transform: translate3d(0, 0, 0);

  /* default drift so it still works even if JS fails */
  --drift-x: 6vw;

  animation-name: emberFloat;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

/* Vertical + sideways drift, with a little easing */
@keyframes emberFloat {
  0% {
    transform: translate3d(0, 20vh, 0) scale(0.4);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  45% {
    transform: translate3d(calc(var(--drift-x) * 0.4), -30vh, 0) scale(0.7);
    opacity: 1;
  }
  80% {
    transform: translate3d(calc(var(--drift-x) * 0.8), -80vh, 0) scale(0.9);
    opacity: 0.8;
  }
  100% {
    transform: translate3d(var(--drift-x), -120vh, 0) scale(1);
    opacity: 0;
  }
}



/* === Fog (smoke) layer === */
.fog-layer {
  position: fixed;
  inset: 0;
  background: url('/images/fog.png') repeat;
  background-size: cover;
  opacity: 0.28;        /* adjust for strength */
  pointer-events: none;
  z-index: 1;           /* above background, below embers */
  animation: fogDrift 55s ease-in-out infinite;
}

/* Drift animation */
@keyframes fogDrift {
  0%   { transform: translateX(0) translateY(0); }
  50%  { transform: translateX(-50px) translateY(-30px); }
  100% { transform: translateX(0) translateY(0); }
}


/* Keyframes glow */
@keyframes glow {
  0%   { opacity: 0.05; }
  100% { opacity: 0.12; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .chat-page::after,
  .ember,
  .fog-layer {
    animation: none !important;
  }
}



/* --- Clara entrance --- */
@keyframes claraSlowFadeIn {
  0% {
    opacity: 0;
    transform: translateY(-30px) scale(0.97);
  }
  50% {
    opacity: 0.5;
    transform: translateY(-10px) scale(0.985);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shimmerOnce {
  0% {
    filter: brightness(1) saturate(1);
  }
  50% {
    filter: brightness(1.6) saturate(1.2);
  }
  100% {
    filter: brightness(1) saturate(1);
  }
}


/* ----- Page scaffold ----- */
.chat-page {
  position: relative;
  z-index: 5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* no clipping here */
}


/* ----- Header ----- */
.chat-header {
  padding: 1rem 1.25rem 0.5rem;
  text-align: left;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  margin-top: 5rem;
}

.chat-header .title {
  font-size: 1.25rem;
  letter-spacing: 0.04em;
}

.chat-header .tagline {
  margin-top: 0.25rem;
  font-style: italic;
  opacity: 0.9;
}

/* ----- Chat log (scrollable area) ----- */
.chat-dialogue {
  /* just a vertical stack; the PAGE scrolls */
  display: flex;
  flex-direction: column;
  gap: 0.5rem;

  padding: 1rem 1.25rem;
  box-sizing: border-box;

  /* reserve space so last lines don't hide under the input bar */
  padding-bottom: calc(9rem + env(safe-area-inset-bottom));
}

@media (min-width: 900px) {
  .chat-dialogue {
    padding-bottom: calc(11rem + env(safe-area-inset-bottom));
  }
}


.message {
  margin: 0.5rem 0;
  line-height: 1.6;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
}

.message .meta {
  font-size: 0.75rem;
  opacity: 0.75;
  margin-left: 0.5rem;
}

/* ----- Fixed input bar (mobile) ----- */
.input-area {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 0.9rem calc(0.8rem + env(safe-area-inset-bottom));
  box-sizing: border-box;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255,255,255,0.06);
}

#input-box {
  flex: 1;
  font: inherit;
  padding: 0.8rem 1rem;
  border: none;
  outline: none;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  color: #f4e8d5;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}

#send-btn {
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  background: rgba(255,255,255,0.16);
  color: #f4e8d5;
  cursor: pointer;
}

input, button {
  -webkit-tap-highlight-color: transparent;
}
