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

@layer components {
  /* Markdown-formatted question text */
  .question-text > * + * { @apply mt-2; }
  .question-text ul { @apply list-disc pl-5; }
  .question-text ol { @apply list-decimal pl-5; }
  .question-text li + li { @apply mt-1; }
  .question-text strong { @apply font-bold; }
  .question-text a { @apply underline text-purple-600; }

  /* Markdown editor: transparent textarea over a highlight layer with identical metrics */
  .markdown-editor-highlight {
    position: absolute;
    inset: 0;
    border-style: solid;
    border-color: transparent;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    overflow: hidden;
    pointer-events: none;
    @apply text-gray-900;
  }
  .markdown-editor-input {
    position: relative;
    color: transparent;
    caret-color: theme('colors.gray.900');
    white-space: pre-wrap;
    overflow-wrap: break-word;
  }
  .markdown-editor-input::selection { color: transparent; background: theme('colors.purple.200 / 60%'); }
  .markdown-editor-input::placeholder { color: theme('colors.gray.400'); }
  .markdown-editor-highlight .md-syntax { @apply text-gray-400; }
  .markdown-editor-highlight .md-list-marker { @apply text-purple-600; }
  /* Fake bold/italic keep glyph widths identical so the caret stays aligned */
  .markdown-editor-highlight .md-bold { -webkit-text-stroke: 0.55px currentColor; }
  .markdown-editor-highlight .md-italic { font-style: italic; }

  /* AI Chat optimized for mobile - no body scroll */
  [data-controller="survey-taker--ai-text-question"] [data-survey-taker--ai-text-question-target="chatContainer"] {
    max-height: 60vh;
    display: flex;
    flex-direction: column;
  }

  /* ...but still hideable (voice mode hides it until the first message). */
  [data-controller="survey-taker--ai-text-question"] [data-survey-taker--ai-text-question-target="chatContainer"].hidden {
    display: none;
  }

  [data-controller="survey-taker--ai-text-question"] [data-survey-taker--ai-text-question-target="chatMessages"] {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
  }
}
/* Audio mode (AI questions answered by talking). A call-style stage: the orb, live captions
   under it, and one action at a time. The stage has a fixed minimum height so nothing jumps
   between states.

   The orb is a glass sphere with colour swirling inside it and a soft aura behind. Its motion
   comes from one animation loop in JS, so it eases between states instead of jumping:
     --level  0..1, how loud whoever is speaking is
     --spin   degrees the colour inside has turned
     --scale  size of the sphere (breathing, and swelling with the voice)
     --glow   0..1, strength of the aura
   It takes the survey's brand colour when the survey is whitelabelled. */
.voice-stage {
  --voice-primary: var(--wl-primary, #7c3aed);
  --voice-light: color-mix(in oklch, var(--voice-primary) 55%, #f0abfc);
  --voice-cool: color-mix(in oklch, var(--voice-primary) 60%, #60a5fa);
  --voice-deep: color-mix(in oklch, var(--voice-primary) 70%, #1e1b4b);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 26rem;
  padding-top: 2.75rem;
}

.voice-orb {
  --level: 0;
  --spin: 0;
  --scale: 1;
  --glow: 0.4;
  position: relative;
  width: 8.5rem;
  height: 8.5rem;
  flex-shrink: 0;
  border-radius: 9999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: filter 600ms ease;
}
.voice-orb:focus-visible {
  outline: none;
}
.voice-orb:focus-visible .voice-orb__core {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--voice-primary);
}

/* The aura: the same colours, heavily blurred, swelling with the voice. */
.voice-orb__glow {
  position: absolute;
  inset: -14%;
  border-radius: 9999px;
  background: conic-gradient(from calc(var(--spin) * -0.6deg),
    var(--voice-primary), var(--voice-light), var(--voice-cool), var(--voice-primary));
  filter: blur(26px);
  opacity: calc(0.18 + var(--glow) * 0.5);
  transform: scale(calc(0.82 + var(--glow) * 0.3));
}

/* A thin ring that drifts out while the orb waits for you. */
.voice-orb__ripple {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  border: 1px solid color-mix(in srgb, var(--voice-primary) 40%, transparent);
  opacity: 0;
}
.voice-orb[data-state="idle"] .voice-orb__ripple,
.voice-orb[data-state="listening"]:not([data-talking]) .voice-orb__ripple {
  animation: voice-orb-ripple 3.2s cubic-bezier(0.2, 0.6, 0.35, 1) infinite;
}
.voice-orb__ripple--late {
  animation-delay: 1.6s !important;
}

/* The sphere: colour fields turning against each other under a glassy highlight. */
.voice-orb__core {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 9999px;
  color: #fff;
  background: var(--voice-deep);
  box-shadow: 0 22px 44px -18px color-mix(in srgb, var(--voice-deep) 75%, transparent);
  transform: scale(var(--scale));
  isolation: isolate;
}
.voice-orb__swirl {
  position: absolute;
  inset: -35%;
  background: conic-gradient(from 0deg,
    var(--voice-primary), var(--voice-light), var(--voice-primary), var(--voice-cool), var(--voice-primary));
  filter: blur(14px);
  transform: rotate(calc(var(--spin) * 1deg));
}
.voice-orb__swirl--counter {
  inset: -20%;
  background:
    radial-gradient(circle at 30% 35%, color-mix(in srgb, var(--voice-light) 90%, transparent) 0 18%, transparent 42%),
    radial-gradient(circle at 72% 68%, color-mix(in srgb, var(--voice-cool) 85%, transparent) 0 16%, transparent 40%);
  filter: blur(10px);
  mix-blend-mode: screen;
  opacity: calc(0.55 + var(--level) * 0.45);
  transform: rotate(calc(var(--spin) * -1.7deg)) scale(calc(1 + var(--level) * 0.25));
}
.voice-orb__gloss {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 38%),
    radial-gradient(circle at 50% 120%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 45%);
  box-shadow: inset 0 -14px 28px rgba(15, 10, 40, 0.28), inset 0 1px 1px rgba(255, 255, 255, 0.45);
}

/* What's inside the orb: a mic to tap at the start, a crossed-out mic when it's blocked,
   nothing at all once the conversation is going. */
.voice-orb__icon {
  position: relative;
  display: none;
  width: 2.4rem;
  height: 2.4rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}
.voice-orb[data-state="idle"] .voice-orb__icon--mic,
.voice-orb[data-state="starting"] .voice-orb__icon--mic,
.voice-orb[data-state="blocked"] .voice-orb__icon--off,
.voice-orb[data-state="error"] .voice-orb__icon--off {
  display: block;
  animation: voice-fade-in 400ms ease both;
}

/* Blocked, failed or paused: drained of colour (and the loop lets the spin wind down). */
.voice-orb[data-state="blocked"],
.voice-orb[data-state="error"],
.voice-orb[data-state="paused"] {
  filter: grayscale(1) brightness(1.12) contrast(0.85);
}

@keyframes voice-orb-ripple {
  0% { transform: scale(1.02); opacity: 0; }
  18% { opacity: 0.75; }
  100% { transform: scale(1.65); opacity: 0; }
}
@keyframes voice-fade-in {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: none; }
}

/* Captions: what's being said, large, like subtitles. */
.voice-captions {
  position: relative;
  z-index: 1;
  margin-top: 2.75rem;
  width: 100%;
  max-width: 26rem;
  min-height: 9.5rem;
  padding: 0 0.5rem;
}
.voice-caption {
  font-size: 1.25rem;
  line-height: 1.5;
  letter-spacing: -0.011em;
  font-weight: 600;
  color: #111827;
  text-wrap: balance;
  transition: color 300ms ease;
}
.voice-caption[data-tone="muted"] {
  color: #6b7280;
  font-weight: 500;
}
/* Who's speaking, as a small label above the line. */
.voice-caption[data-speaker]::before {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
}
.voice-caption[data-speaker="ai"]::before {
  content: "Interviewer";
  color: var(--voice-primary);
}
.voice-caption[data-speaker="you"]::before {
  content: "You";
  color: #9ca3af;
}
/* Words still being said: softer grey, each new word fading up, and an ellipsis that keeps
   moving until they stop. */
.voice-caption[data-live] {
  color: #4b5563;
  font-weight: 500;
}
.voice-caption__word {
  animation: voice-word-in 420ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes voice-word-in {
  from { opacity: 0; filter: blur(3px); }
  to { opacity: 1; filter: blur(0); }
}
.voice-caption[data-live]::after {
  content: "";
  display: inline-block;
  width: 0.24em;
  height: 0.24em;
  margin: 0 0.95em 0 0.4em;
  vertical-align: 0.06em;
  border-radius: 9999px;
  background: rgba(75, 85, 99, 0.6);
  box-shadow: 0.45em 0 rgba(75, 85, 99, 0.6), 0.9em 0 rgba(75, 85, 99, 0.6);
  animation: voice-caption-ellipsis 1.3s ease-in-out infinite;
}
@keyframes voice-caption-ellipsis {
  0%, 100% {
    background: rgba(75, 85, 99, 0.85);
    box-shadow: 0.45em 0 rgba(75, 85, 99, 0.2), 0.9em 0 rgba(75, 85, 99, 0.2);
  }
  33% {
    background: rgba(75, 85, 99, 0.2);
    box-shadow: 0.45em 0 rgba(75, 85, 99, 0.85), 0.9em 0 rgba(75, 85, 99, 0.2);
  }
  66% {
    background: rgba(75, 85, 99, 0.2);
    box-shadow: 0.45em 0 rgba(75, 85, 99, 0.2), 0.9em 0 rgba(75, 85, 99, 0.85);
  }
}
.voice-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: #6b7280;
  text-wrap: balance;
}
/* The mic is open: a small live dot beside the hint. */
.voice-hint[data-mic-live]::before {
  content: "";
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--voice-primary);
  animation: voice-mic-dot 1.8s ease-in-out infinite;
}
@keyframes voice-mic-dot {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--voice-primary) 45%, transparent); }
  50% { box-shadow: 0 0 0 0.3rem color-mix(in srgb, var(--voice-primary) 0%, transparent); }
}

/* One quiet action at a time, thumb-sized. */
.voice-actions {
  margin-top: 1.25rem;
  min-height: 2.75rem;
}
.voice-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.75rem;
  padding: 0 1.25rem 0 1.05rem;
  border-radius: 9999px;
  background: #f3f4f6;
  color: #374151;
  font-size: 0.9375rem;
  font-weight: 600;
  transition: background 150ms ease, transform 150ms ease;
  animation: voice-fade-in 300ms ease both;
}
.voice-action.hidden {
  display: none;
}
.voice-action svg {
  width: 1rem;
  height: 1rem;
}
.voice-action:hover {
  background: #e5e7eb;
}
.voice-action:active {
  transform: scale(0.97);
}
.voice-action--primary {
  background: var(--voice-primary);
  color: #fff;
  box-shadow: 0 8px 20px -10px var(--voice-primary);
}
.voice-action--primary:hover {
  background: var(--voice-primary);
  filter: brightness(0.92);
}

@media (prefers-reduced-motion: reduce) {
  .voice-stage *, .voice-stage *::before, .voice-stage *::after {
    animation: none !important;
    transition: none !important;
  }
}
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *


 */
