/* ════════════════════════════════════════
   Aurora Studio — wizard chat panel
   The panel IS the aurora: layered drifting gradients behind a frosted veil,
   feathered seam (no border), breathing orb, bubble-free messages.
   Tokens come from campaigns.css.
════════════════════════════════════════ */

.wizard-shell {
  display: flex;
  align-items: stretch;
  height: 100vh;
  overflow: hidden;
}

.wizard-shell__main {
  flex: 1 1 auto;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: clip;
  /* Reserve room for the fixed wizard-footer so scrolled content doesn't
     hide behind it. */
  padding-bottom: 80px;
}

/* Sticky chain: turbo-frame and the inner header wrapper must participate
   in normal block flow with a clean containing chain, otherwise the
   step-track inside loses its pin point. */
.wizard-shell__main > turbo-frame#wizard,
turbo-frame#wizard {
  display: block;
  position: relative;
}

#wizard-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--canvas, var(--surface-strong));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

body:has(.wizard-shell) {
  padding-bottom: 0;
  overflow: hidden;
}

/* Mobile: restore scroll. */
@media (max-width: 900px) {
  .wizard-shell {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  body:has(.wizard-shell) { overflow: auto; padding-bottom: 80px; }
  .wizard-shell__main {
    height: auto;
    overflow: visible;
    flex: 0 0 auto;
    padding-bottom: 0;
  }
}

/* ════════════════════════════════════════
   The panel itself
════════════════════════════════════════ */
.wizard-chat {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--surface-strong);
  isolation: isolate;
  overflow: hidden;

  /* Feathered seam — the aurora bleeds into the canvas for the first 60px. */
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 60px);
          mask-image: linear-gradient(to right, transparent 0, black 60px);
}

/* Aurora layer A — peach blob drifting from upper-left */
.wizard-chat::before {
  content: '';
  position: absolute;
  inset: -10%;
  background-image: var(--gradient-aurora-a), var(--gradient-aurora-c);
  z-index: -2;
  pointer-events: none;
  animation: aurora-drift-a 14s ease-in-out infinite alternate;
  will-change: transform, opacity;
}

/* Aurora layer B — lavender wash drifting from lower-right */
.wizard-chat::after {
  content: '';
  position: absolute;
  inset: -10%;
  background-image: var(--gradient-aurora-b);
  z-index: -1;
  pointer-events: none;
  animation: aurora-drift-b 22s ease-in-out infinite alternate;
  opacity: 0.8;
  will-change: transform, opacity;
}

@keyframes aurora-drift-a {
  0%   { transform: translate3d(-2%, -2%, 0) scale(1.0); opacity: 0.85; }
  100% { transform: translate3d( 4%,  3%, 0) scale(1.06); opacity: 1.0; }
}

@keyframes aurora-drift-b {
  0%   { transform: translate3d( 3%,  2%, 0) scale(1.04); opacity: 0.7; }
  100% { transform: translate3d(-3%, -3%, 0) scale(1.0); opacity: 0.95; }
}

/* Thinking state — aurora intensifies and quickens */
.wizard-chat.is-thinking::before {
  animation-duration: 4s;
  filter: saturate(1.3);
}

.wizard-chat.is-thinking::after {
  animation-duration: 6s;
  opacity: 1;
  filter: saturate(1.3);
}

/* Mobile: drop the mask seam (panel is stacked, not adjacent) */
@media (max-width: 900px) {
  .wizard-chat {
    -webkit-mask-image: none;
            mask-image: none;
  }
}

/* ════════════════════════════════════════
   Header — breathing orb + state word
════════════════════════════════════════ */
.wizard-chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 14px 80px;  /* extra left padding because seam is masked */
  position: relative;
  z-index: 1;
}

.wizard-chat__orb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background:
    radial-gradient(circle at 30% 30%, var(--accent-peach) 0%, transparent 50%),
    radial-gradient(circle at 70% 70%, var(--accent-lavender) 0%, transparent 55%),
    radial-gradient(circle at 50% 50%, var(--accent-mint) 0%, transparent 60%),
    linear-gradient(135deg, var(--accent-peach), var(--accent-lavender));
  box-shadow:
    0 0 16px rgba(255, 155, 122, 0.35),
    inset 0 1px 2px rgba(255, 255, 255, 0.5);
  animation: orb-breathe 3s ease-in-out infinite alternate;
  will-change: transform, box-shadow;
}

.wizard-chat.is-thinking .wizard-chat__orb {
  animation-duration: 1.2s;
  box-shadow:
    0 0 24px rgba(255, 155, 122, 0.55),
    0 0 40px rgba(201, 184, 255, 0.35),
    inset 0 1px 2px rgba(255, 255, 255, 0.55);
}

@keyframes orb-breathe {
  0%   { transform: scale(1.0);  opacity: 0.92; }
  100% { transform: scale(1.06); opacity: 1.0; }
}

.wizard-chat__state {
  font-family: var(--font-display);
  font-size: 16px;
  font-style: italic;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.01em;
  transition: opacity 0.18s;
}

.wizard-chat__state[data-state="thinking"] { color: var(--accent-coral-deep); }

/* ════════════════════════════════════════
   Messages stream
════════════════════════════════════════ */
.wizard-chat__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 20px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}

.wizard-chat__messages::-webkit-scrollbar       { width: 6px; }
.wizard-chat__messages::-webkit-scrollbar-track { background: transparent; }
.wizard-chat__messages::-webkit-scrollbar-thumb {
  background: var(--border-mid);
  border-radius: 3px;
}

/* ── A single message — bubble-free ── */
.msg {
  max-width: 88%;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: msg-rise 280ms cubic-bezier(.2,.8,.2,1) both;
}

@keyframes msg-rise {
  0%   { opacity: 0; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* User — right-aligned, italic, no chrome */
.msg--user {
  align-self: flex-end;
  text-align: right;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  color: var(--ink);
}

/* Assistant — left-aligned, gradient hairline rail on the left */
.msg--assistant {
  align-self: flex-start;
  padding-left: 14px;
  position: relative;
  font-family: var(--font-ui);
  font-weight: 400;
}

.msg--assistant::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg,
    var(--accent-peach) 0%,
    var(--accent-coral) 35%,
    var(--accent-lavender) 70%,
    var(--accent-mint) 100%);
}

.msg__body p { margin: 0; }
.msg__body p + p { margin-top: 8px; }

/* Speaker turn rhythm: extra space when speaker changes */
.msg[data-speaker="user"] + .msg[data-speaker="assistant"],
.msg[data-speaker="assistant"] + .msg[data-speaker="user"] {
  margin-top: 8px;
}

/* Image attachments */
.msg__image {
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: inline-block;
}

.msg__image img {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-md);
}

/* Transient "thinking…" ghost line */
.wizard-chat__ghost {
  align-self: flex-start;
  padding-left: 14px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-muted);
  opacity: 0.85;
  animation: ghost-pulse 2.4s ease-in-out infinite;
}

@keyframes ghost-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.95; }
}

/* ── Confirmation buttons inside a message ── */
.msg__confirmation {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-aurora-primary,
.btn-aurora-ghost {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: 8px 18px;
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.12s, background 0.18s, color 0.18s;
}

.btn-aurora-primary {
  background: linear-gradient(135deg, var(--accent-coral) 0%, var(--accent-peach) 100%);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(255, 155, 122, 0.32),
              inset 0 1px 0 rgba(255, 255, 255, 0.30);
}

.btn-aurora-primary:hover {
  box-shadow: 0 8px 22px rgba(255, 155, 122, 0.42),
              inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

.btn-aurora-ghost {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--border-mid);
}

.btn-aurora-ghost:hover {
  color: var(--accent-coral-deep);
  border-color: var(--accent-coral);
  background: rgba(255, 201, 168, 0.10);
}

/* ════════════════════════════════════════
   Composer — glass rail at bottom
════════════════════════════════════════ */
.wizard-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 20px 18px 80px;
  background: linear-gradient(to top,
    rgba(255, 248, 241, 0.85) 0%,
    rgba(255, 248, 241, 0.6) 70%,
    transparent 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  z-index: 2;
}

.wizard-chat__form-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  background: var(--surface-solid);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 6px 4px 6px 12px;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.wizard-chat__form-fields:focus-within {
  border-color: rgba(255, 155, 122, 0.5);
  box-shadow: 0 0 0 4px var(--border-focus);
}

.wizard-chat__form textarea {
  width: 100%;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
  padding: 6px 4px;
  line-height: 1.5;
  max-height: 120px;
}

.wizard-chat__form textarea::placeholder {
  color: var(--ink-faint);
  font-style: italic;
}

/* Attach (paperclip) */
.wizard-chat__attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s, color 0.18s, transform 0.12s;
  backdrop-filter: blur(6px);
}

.wizard-chat__attach:hover {
  color: var(--accent-coral-deep);
  background: rgba(255, 201, 168, 0.16);
  transform: scale(1.05);
}

.wizard-chat__attach input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* File preview chip */
.wizard-chat__file-preview {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 201, 168, 0.18);
  border: 1px solid rgba(255, 155, 122, 0.32);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--accent-coral-deep);
  max-width: 100%;
}

.wizard-chat__file-preview[hidden] { display: none; }

.wizard-chat__file-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wizard-chat__file-clear {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--accent-coral-deep);
  padding: 0 2px;
}

/* Send — coral gradient circle with arrow icon */
.wizard-chat__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent-coral) 0%, var(--accent-peach) 100%);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(255, 155, 122, 0.35),
              inset 0 1px 0 rgba(255, 255, 255, 0.30);
  transition: box-shadow 0.18s, transform 0.12s;
}

.wizard-chat__send:hover {
  box-shadow: 0 8px 22px rgba(255, 155, 122, 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transform: translateY(-1px) rotate(-4deg);
}

.wizard-chat__send:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(255, 155, 122, 0.3);
}

.wizard-chat__send svg {
  display: block;
}

/* On mobile, drop the extra left padding (no mask seam to compensate for) */
@media (max-width: 900px) {
  .wizard-chat__header   { padding-left: 20px; }
  .wizard-chat__messages { padding-left: 20px; }
  .wizard-chat__form     { padding-left: 20px; }
}

/* ════════════════════════════════════════
   Reduced motion
════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .wizard-chat::before,
  .wizard-chat::after,
  .wizard-chat__orb,
  .wizard-chat__ghost,
  .msg {
    animation: none !important;
  }
  *, *::before, *::after {
    transition-duration: 0ms !important;
  }
}

/* Chat context pill — non-Aurora accent (slate + amber) */
.wizard-chat__context-pill {
  padding: 0.5rem 0.75rem 0;
}
.wizard-chat__context-pill__chip {
  --pill-bg:     #2a2a35;
  --pill-fg:     #d4a574;
  --pill-border: #3d3d4a;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--pill-bg);
  color: var(--pill-fg);
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}
.wizard-chat__context-pill__label {
  opacity: 0.7;
  font-weight: 500;
}
.wizard-chat__context-pill__value {
  font-weight: 600;
}
