/* ============================================================
   What's Good? — cinematic, minimal, late-night reflection
   Deep black · off-white text · mustard accent · teal glow
   ============================================================ */

:root {
  --background: #050505;
  --surface: #101010;
  --surface-soft: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.12);
  --text: #F5F5F5;
  --muted: #B4B4B4;
  --yellow: #EFCE42;
  --green: #77C58C;          /* Grab Your Y accent — ties to the site's green Y */
  --teal: #1F6E76;
  --dark-teal: #103438;

  --font-display: "Archivo", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --max: 760px;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* ---------- Splash ---------- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;            /* clip the logo's black margins off-screen */
  background: #000;            /* pure black so the logo's black merges seamlessly */
  opacity: 1;
  transition: opacity 900ms ease;
}
.splash.is-hiding { opacity: 0; }

/* Logo intro. Tightly-cropped transparent PNG, centered both axes by the
   flex parent. Width-driven so the wordmark never crops on mobile. */
.splash__logo {
  display: block;
  width: min(640px, 86vw);
  height: auto;
  opacity: 0;
  transform: translateY(6px) scale(0.985);
  filter: drop-shadow(0 0 30px rgba(239, 206, 66, 0.14))
          drop-shadow(0 0 70px rgba(31, 110, 118, 0.18));
  animation: splashIn 1500ms ease forwards;
}
@keyframes splashIn {
  0%   { opacity: 0; transform: translateY(8px) scale(0.985); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- App shell ---------- */
.app {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  opacity: 0;
  animation: appIn 900ms ease 60ms forwards;
}
@keyframes appIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Radial mustard glow behind the card */
.app__glow {
  position: absolute;
  top: -18%;
  left: 50%;
  width: min(900px, 120vw);
  height: 560px;
  transform: translateX(-50%);
  background: radial-gradient(
    ellipse at center,
    rgba(239, 206, 66, 0.10) 0%,
    rgba(31, 110, 118, 0.08) 38%,
    rgba(5, 5, 5, 0) 70%
  );
  filter: blur(8px);
  pointer-events: none;
  z-index: 0;
}

/* Faint vertical "signal" line — spectrum motif */
.app__signal {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 1px;
  background: linear-gradient(
    to bottom,
    rgba(239, 206, 66, 0) 0%,
    rgba(239, 206, 66, 0.14) 22%,
    rgba(31, 110, 118, 0.14) 55%,
    rgba(255, 255, 255, 0) 100%
  );
  pointer-events: none;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(2.5rem, 8vh, 5rem) 1.25rem 3rem;
}

/* ---------- Masthead ---------- */
.masthead { text-align: center; margin-bottom: 2rem; }

.title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 10vw, 4.2rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
  margin: 0 0 0.9rem;
  color: #FBFBF3;
}
/* "Good?" in the Grab Your Y green, with a subtle right-tilt on hover
   echoing the site's Y interaction. */
.title-good {
  display: inline-block;
  color: var(--green);
  transition: transform 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.title-good:hover { transform: rotate(4deg); }

.byline {
  margin: 0.28rem 0 0;
  color: #8a8a8a;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.byline:first-of-type { margin-top: 0.1rem; }

.rule {
  width: 64px;
  height: 1px;
  border: 0;
  margin: 1.15rem auto;
  background: linear-gradient(
    to right,
    rgba(239, 206, 66, 0) 0%,
    rgba(239, 206, 66, 0.5) 50%,
    rgba(239, 206, 66, 0) 100%
  );
}

.subcopy {
  margin: 0;
  color: var(--yellow);
  font-size: clamp(0.98rem, 2.6vw, 1.1rem);
}

/* ---------- Intake ---------- */
.intake { margin-bottom: 1.5rem; }

.field-wrap { position: relative; }

.field {
  width: 100%;
  resize: vertical;
  min-height: 128px;
  padding: 1.1rem 3.4rem 1.1rem 1.15rem;  /* right room for mic */
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.55;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 220ms ease, box-shadow 220ms ease, background 220ms ease;
}
.field::placeholder { color: #7d7d7d; }
.field:focus {
  border-color: rgba(239, 206, 66, 0.55);
  background: rgba(255, 255, 255, 0.055);
  box-shadow:
    0 0 0 3px rgba(239, 206, 66, 0.12),
    0 0 40px rgba(31, 110, 118, 0.16);
}

/* Mic / dictation button */
.mic {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: color 200ms ease, border-color 200ms ease, background 200ms ease, box-shadow 200ms ease;
}
.mic:hover { color: var(--text); border-color: rgba(239, 206, 66, 0.5); }
.mic:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(239, 206, 66, 0.45); }
.mic.is-listening {
  color: #0b0b0b;
  background: var(--yellow);
  border-color: var(--yellow);
  animation: micPulse 1.4s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 206, 66, 0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(239, 206, 66, 0); }
}

.intake__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

.mic-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  flex: 1 1 200px;
  min-height: 1em;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 140ms ease, background 200ms ease, color 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(239, 206, 66, 0.45);
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--yellow);
  color: #0b0b0b;
  padding: 0.8rem 1.5rem;
  font-size: 0.98rem;
  box-shadow: 0 6px 30px rgba(239, 206, 66, 0.18);
}
.btn--primary:hover { background: #f5d95a; box-shadow: 0 8px 36px rgba(239, 206, 66, 0.28); }
.btn--primary:disabled { opacity: 0.55; cursor: default; box-shadow: none; }

/* "Look underneath" — the single optional inward move.
   Green-accented (inward) to contrast the yellow primary (say it). */
.btn--underneath {
  background: rgba(119, 197, 140, 0.08);
  color: var(--green);
  border: 1px solid rgba(119, 197, 140, 0.4);
  padding: 0.55rem 1.15rem;
  font-size: 0.9rem;
}
.btn--underneath:hover {
  background: rgba(119, 197, 140, 0.16);
  border-color: var(--green);
}
.btn--underneath:focus-visible { box-shadow: 0 0 0 3px rgba(119, 197, 140, 0.45); }

/* Understated "Start Fresh" — must not compete with the primary button */
.btn--ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0.4rem 0.95rem;
  font-size: 0.8rem;
  font-weight: 500;
}
.btn--ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.34); }

/* Actions bar under the input: Look underneath (+ authority-preserving hint)
   on the left, quiet Start Fresh on the right. */
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.25rem 0 0.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.actions__left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

/* ---------- Conversation thread ----------
   Newest exchange sits at the top (closest to the input). Each exchange
   is a grouped pair: user message, then tool reflection below it.
   Message-inspired, but kept premium and minimal — not a texting clone. */
.stream { display: flex; flex-direction: column; gap: 0; }

/* One exchange = user turn + tool turn, kept visually grouped. */
.exchange {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.4rem 0;
}
.exchange + .exchange,
.thread-label + .exchange { border-top: 1px solid rgba(255, 255, 255, 0.06); }

.turn {
  opacity: 0;
  transform: translateY(8px);
  animation: turnIn 520ms ease forwards;
  max-width: 100%;
}
@keyframes turnIn { to { opacity: 1; transform: translateY(0); } }

/* User message — right-aligned, slightly narrower bubble */
.turn--user {
  align-self: flex-end;
  max-width: 82%;
  padding: 0.8rem 1.05rem;
  background: rgba(239, 206, 66, 0.10);
  border: 1px solid rgba(239, 206, 66, 0.28);
  border-radius: 16px 16px 4px 16px;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
}

/* Tool reflection — left-aligned, wider, soft teal edge */
.turn--tool {
  align-self: flex-start;
  max-width: 92%;
  padding: 1.15rem 1.3rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.025));
  border: 1px solid var(--border);
  border-left: 3px solid rgba(31, 110, 118, 0.9);
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}
.turn--tool p { margin: 0 0 0.8rem; line-height: 1.62; font-size: 1.04rem; }
.turn--tool p:last-child { margin-bottom: 0; }

/* "Previous reflections" divider before older exchanges */
.thread-label {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0.4rem 0 0;
  padding-top: 1.1rem;
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.thread-label::before,
.thread-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

/* loading state — "Breaking it down…" with a soft pulse */
.loading {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--muted);
  font-size: 0.98rem;
}
.loading__text {
  animation: loadingGlow 1.8s ease-in-out infinite;
}
@keyframes loadingGlow {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* thinking dots */
.thinking { display: inline-flex; gap: 6px; align-items: center; }
.thinking span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: pulse 1.2s infinite ease-in-out;
}
.thinking span:nth-child(2) { animation-delay: 0.18s; }
.thinking span:nth-child(3) { animation-delay: 0.36s; }
@keyframes pulse {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- Bridge cards (Per My Last Message / Say Less) ---------- */
.bridge {
  margin-top: 0.9rem;
  padding: 1rem 1.15rem;
  background: var(--dark-teal);
  border: 1px solid rgba(31, 110, 118, 0.7);
  border-radius: 12px;
}
.bridge__tag {
  display: inline-block;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--yellow);
  margin-bottom: 0.4rem;
}
.bridge__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0 0 0.3rem;
}
.bridge__desc { margin: 0 0 0.7rem; color: #d6e4e5; font-size: 0.92rem; line-height: 1.5; }
.bridge__soon {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
}

/* ---------- Footer ---------- */
.foot {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}
.foot p { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .intake__row { flex-direction: column; align-items: stretch; }
  .btn--primary { width: 100%; }
  .mic-status { text-align: center; }
  .turn--user { max-width: 92%; }
  .turn--tool { max-width: 100%; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .splash__logo,
  .app,
  .turn,
  .thinking span { animation: none !important; }
  .splash { transition: none; }
  .app { opacity: 1; }
  .turn { opacity: 1; transform: none; }
  .splash__logo { opacity: 1; transform: none; }
  * { scroll-behavior: auto !important; }
}

/* Home button — back to the Grab Your Y site (added for the integrated build) */
.home-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: "Archivo", system-ui, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
}
.home-link:hover { color: #F2C300; transform: translateX(-1px); }
.home-link svg { display: block; }
