/* ============================================================
   W57TH · FRED AI  —  style.css
   Host this on Cloudflare alongside index.html
   ============================================================ */


/* ── 1. DESIGN TOKENS (CSS variables) ─────────────────────── */

:root {
  --grey-dark:   #0e0f11;
  --grey-mid:    #1c1f24;
  --grey-light:  #2e3340;
  --grey-muted:  #6b7280;
  --grey-text:   #c8cdd6;

  --blue-deep:   #0d1f3c;
  --blue-mid:    #1a3a6b;
  --blue-accent: #3b82f6;
  --blue-glow:   #60a5fa;

  --white:       #f0f4ff;

  --font-display: 'Bebas Neue', sans-serif;
  --font-body:    'Playfair Display', serif;
}


/* ── 2. RESET ──────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--grey-dark);
  color: var(--grey-text);
  font-family: var(--font-body);
  overflow: hidden;          /* prevent outer page scroll */
}

/* On short/narrow mobile screens, allow the page to scroll
   rather than clipping the mic controls off the bottom */
@media (max-height: 600px), (max-width: 400px) {
  html, body {
    overflow: auto;
    height: auto;
  }

  #app {
    height: auto;
    min-height: 100vh;
    padding-bottom: 32px;
  }

  /* Give the transcript a fixed height on small screens
     instead of flex-grow (which collapses when body is auto) */
  #transcript-wrap {
    flex: none;
    height: 45vh;
    min-height: 200px;
  }
}


/* ── 3. BACKGROUND LAYERS ──────────────────────────────────── */

/* City photo — dimmed + desaturated */
#bg {
  position: fixed;
  inset: 0;
  z-index: 0;

  background-image: url('https://media.airpg.ai/city%20background.jpg');
  background-size: cover;
  background-position: center;

  opacity: 0.30;
  filter: grayscale(30%) contrast(1.1);
}

/* Dark vignette overlay */
#bg-vignette {
  position: fixed;
  inset: 0;
  z-index: 1;

  background: radial-gradient(
    ellipse at center,
    transparent 30%,
    rgba(10, 12, 18, 0.92) 100%
  );
}


/* ── 4. APP SHELL ──────────────────────────────────────────── */

#app {
  position: relative;
  z-index: 2;

  height: 100vh;

  display: flex;
  flex-direction: column;
  align-items: center;

  padding: 28px 20px 24px;
}


/* ── 5. LOGO / HEADER ──────────────────────────────────────── */

#logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;

  animation: fadeDown 0.8s ease both;
}

#logo-wrap img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(59, 130, 246, 0.35);
}

#brand-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

#brand-w57 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  letter-spacing: 0.06em;
  color: var(--white);
  text-shadow: 0 0 18px rgba(96, 165, 250, 0.5);
}

#brand-fred {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-style: italic;
  color: var(--blue-glow);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

#tagline {
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--grey-muted);
}


/* ── 6. TRANSCRIPT BOX ─────────────────────────────────────── */

/* Outer card — grows to fill available vertical space */
#transcript-wrap {
  flex: 1;

  width: 100%;
  max-width: 680px;

  /* Enough room to show ~500+ words when scrolled */
  min-height: 260px;

  margin: 20px 0 16px;

  background: rgba(14, 17, 22, 0.72);
  border: 1px solid rgba(59, 130, 246, 0.18);
  border-radius: 14px;
  backdrop-filter: blur(12px);

  overflow: hidden;

  display: flex;
  flex-direction: column;

  animation: fadeUp 0.9s 0.2s ease both;
}

/* Header bar inside the transcript card */
#transcript-header {
  padding: 10px 18px;
  border-bottom: 1px solid rgba(59, 130, 246, 0.12);

  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  color: var(--blue-glow);

  display: flex;
  align-items: center;
  gap: 8px;
}

/* Pulsing live dot */
#transcript-header .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue-accent);
  box-shadow: 0 0 8px var(--blue-accent);
  animation: pulse-dot 2s infinite;
}

/* Scrollable message list — THIS is what scrolls */
#transcript-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;

  display: flex;
  flex-direction: column;
  gap: 12px;

  scroll-behavior: smooth;
}

/* Thin custom scrollbar */
#transcript-scroll::-webkit-scrollbar       { width: 4px; }
#transcript-scroll::-webkit-scrollbar-thumb { background: var(--grey-light); border-radius: 2px; }


/* ── 7. MESSAGE BUBBLES ────────────────────────────────────── */

.msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: msgIn 0.35s ease both;
}

.msg-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--grey-muted);
}

/* User label = blue, AI label = purple */
.msg.user .msg-label { color: var(--blue-glow); }
.msg.ai  .msg-label  { color: #a78bfa; }

.msg-text {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--grey-text);

  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid transparent;
  padding: 7px 12px;
  border-radius: 0 8px 8px 0;
}

.msg.user .msg-text { border-left-color: var(--blue-accent); }
.msg.ai  .msg-text  { border-left-color: #7c3aed; }


/* ── 8. TYPING / THINKING INDICATOR ───────────────────────── */

#typing {
  display: none;          /* hidden until .active is added */
  gap: 5px;
  align-items: center;
  padding: 6px 14px;
}

#typing.active { display: flex; }

/* Three bouncing dots */
#typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue-accent);
  animation: bounce 1.2s infinite;
}

#typing span:nth-child(2) { animation-delay: 0.2s; }
#typing span:nth-child(3) { animation-delay: 0.4s; }


/* ── 9. BOTTOM CONTROLS AREA ───────────────────────────────── */

#controls {
  width: 100%;
  max-width: 680px;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;

  animation: fadeUp 1s 0.4s ease both;
}


/* ── 10. WAVEFORM BARS ─────────────────────────────────────── */

#waveform {
  width: 100%;
  height: 38px;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

/* Individual bar — idle state */
.bar {
  width: 3px;
  border-radius: 2px;
  background: var(--blue-accent);
  height: 6px;
  opacity: 0.3;
  transition: height 0.08s ease, opacity 0.08s ease;
}

/* When user is recording — blue animated bars */
body.listening .bar {
  opacity: 0.85;
  animation: waveAnim 0.6s ease-in-out infinite alternate;
}

/* When Fred is speaking — purple animated bars */
body.speaking .bar {
  background: #a78bfa;
  opacity: 0.75;
  animation: waveAnim 0.4s ease-in-out infinite alternate;
}


/* ── 11. MIC BUTTON ────────────────────────────────────────── */

#mic-btn {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 2px solid var(--blue-accent);
  background: rgba(13, 31, 60, 0.7);
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition: all 0.25s ease;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.25);
}

#mic-btn:hover {
  border-color: var(--blue-glow);
  box-shadow: 0 0 32px rgba(59, 130, 246, 0.5);
}

/* Red pulsing ring while recording */
body.listening #mic-btn {
  border-color: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: ringPulse 1.4s infinite;
}

/* Purple glow while Fred speaks */
body.speaking #mic-btn {
  border-color: #a78bfa;
  box-shadow: 0 0 30px rgba(167, 139, 250, 0.45);
}

#mic-btn svg { pointer-events: none; }


/* ── 12. STATUS TEXT ───────────────────────────────────────── */

#status-text {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  color: var(--grey-muted);
  transition: color 0.3s;
  text-align: center;
}

body.listening #status-text { color: #ef4444; }
body.speaking  #status-text { color: #a78bfa; }


/* ── 13. FOOTER ────────────────────────────────────────────── */

#footer {
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  color: rgba(107, 114, 128, 0.5);
  text-align: center;
  animation: fadeUp 1s 0.6s ease both;
}


/* ── 14. KEYFRAME ANIMATIONS ───────────────────────────────── */

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-18px); }
  to   { opacity: 1; transform: none; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

@keyframes msgIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

@keyframes ringPulse {
  0%   { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0.6); }
  70%  { box-shadow: 0 0 0 18px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0); }
}

@keyframes bounce {
  0%, 100% { transform: scaleY(1); }
  50%       { transform: scaleY(2.2); }
}

@keyframes waveAnim {
  from { height: 4px; }
  to   { height: 28px; }
}