@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Geist:wght@400;500&display=swap");

:root {
  --bg: #0f0f16;
  --bg-deep: #08080c;
  --text: #f5f5f7;
  --text-dim: #a0a0b0;
  --text-mute: #606070;
  --accent: #ff4d6d;
  --accent-hover: #ff6680;
  --gold: #d4a574;
  --display: "Fraunces", ui-serif, Georgia, serif;
  --body: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  position: relative;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a1320 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -25%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 25% 30%, rgba(255, 77, 109, 0.18), transparent 60%),
    radial-gradient(35% 30% at 75% 70%, rgba(212, 165, 116, 0.10), transparent 60%);
  filter: blur(20px);
  animation: aurora 22s ease-in-out infinite alternate;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

main, footer { position: relative; z-index: 1; }

/* === Main: hero left, demo right (desktop) === */
main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(2rem, 5vw, 5rem);
  padding: 2rem clamp(1.5rem, 4vw, 4rem);
}

.hero {
  flex: 0 1 480px;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.demo {
  flex: 0 1 380px;
  display: flex;
  justify-content: center;
}

/* === Hero text === */
.wordmark {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.75rem, 6.5vw, 4.5rem);
  letter-spacing: -0.04em;
  line-height: 1;
}
.wordmark .dot {
  color: var(--accent);
  display: inline-block;
  animation: pulse 2.6s ease-in-out infinite;
}

.tagline {
  margin-top: 1rem;
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  color: var(--text-dim);
  max-width: 22ch;
}

.sub {
  margin-top: 0.85rem;
  font-size: clamp(0.9rem, 1.4vw, 1rem);
  color: var(--text-mute);
  max-width: 38ch;
  line-height: 1.6;
}

.downloads {
  margin-top: 1.75rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.download {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-family: var(--body);
  font-weight: 500;
  font-size: 1rem;
  text-decoration: none;
  padding: 0.85rem 1.7rem;
  border-radius: 999px;
  transition: transform 160ms ease, background 160ms ease, box-shadow 240ms ease;
  box-shadow: 0 8px 30px rgba(255, 77, 109, 0.25);
}
.download:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(255, 77, 109, 0.45);
}
.download:active { transform: translateY(0); }

.caption {
  margin-top: 0.7rem;
  font-size: 0.82rem;
  color: var(--text-mute);
  letter-spacing: 0.02em;
}

/* === Window mockup === */
.window {
  width: 100%;
  max-width: 380px;
  background: var(--bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 60px rgba(255, 77, 109, 0.08);
}

.window-bar {
  position: relative;
  background: #1a1a26;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.tdot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.tdot-r { background: #ff5f57; }
.tdot-y { background: #febc2e; }
.tdot-g { background: #28c840; }
.window-title {
  position: absolute;
  left: 0; right: 0;
  text-align: center;
  font-family: var(--display);
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: -0.01em;
  pointer-events: none;
}

.chat-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  color: var(--bg-deep);
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 0; padding: 0;
  cursor: pointer;
  overflow: hidden;
  outline: none;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.avatar:hover {
  transform: scale(1.04);
  box-shadow: 0 0 0 3px rgba(255, 77, 109, 0.2);
}
.avatar:focus-visible {
  box-shadow: 0 0 0 3px rgba(255, 77, 109, 0.45);
}
.avatar-letter { position: relative; z-index: 1; }
.avatar-img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
  z-index: 2;
}
.avatar.has-image .avatar-img { display: block; }
.avatar.has-image .avatar-letter { display: none; }
.avatar-edit {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 160ms ease;
  z-index: 3;
}
.avatar:hover .avatar-edit { opacity: 1; }

.who { min-width: 0; flex: 1; }
.who .name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
  outline: none;
  cursor: text;
  border-radius: 5px;
  padding: 1px 5px;
  margin: 0 -5px;
  display: inline-block;
  transition: background 160ms ease;
  word-break: break-word;
}
.who .name:hover, .who .name:focus {
  background: rgba(255, 255, 255, 0.06);
}
.who .name:empty::before {
  content: "Mara";
  color: var(--text-mute);
}
.who .status {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 2px;
  padding: 0 1px;
}

/* === Chat body — tighter and clean === */
.chat-body {
  height: 240px;
  padding: 14px 14px 10px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 9px;
  overflow: hidden;
  /* Top fade so any clipped overflow disappears smoothly. */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 28px);
          mask-image: linear-gradient(to bottom, transparent 0, black 28px);
}

.msg {
  display: flex;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 360ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 360ms cubic-bezier(0.22, 1, 0.36, 1);
}
.msg.visible { opacity: 1; transform: translateY(0); }
.msg-char { justify-content: flex-start; }
.msg-user { justify-content: flex-end; }

.bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
}
.msg-char .bubble {
  background: #16161f;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.msg-user .bubble {
  background: var(--accent);
  color: #fff;
}

.bubble-typing {
  padding: 11px 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.bubble-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  opacity: 0.4;
  animation: bounce 1.2s ease-in-out infinite;
}
.bubble-typing span:nth-child(2) { animation-delay: 0.15s; }
.bubble-typing span:nth-child(3) { animation-delay: 0.30s; }

.composer {
  padding: 9px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: #0c0c12;
}
.composer-input {
  flex: 1;
  font-size: 13px;
  color: var(--text-mute);
  padding: 8px 12px;
  background: #16161f;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
}
.composer-send {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}

/* === Footer === */
footer {
  flex-shrink: 0;
  padding: 0.9rem 2rem;
  display: flex;
  justify-content: flex-end;
}
footer a {
  color: var(--text-mute);
  text-decoration: none;
  font-size: 0.82rem;
  transition: color 120ms ease;
}
footer a:hover { color: var(--text-dim); }

/* === Entrance: stagger fade + rise === */
.window,
.wordmark, .tagline, .sub, .download, .caption,
footer a {
  opacity: 0;
  animation: rise 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.wordmark  { animation-delay: 0.05s; }
.tagline   { animation-delay: 0.20s; }
.sub       { animation-delay: 0.34s; }
.download {
  animation:
    rise 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) 0.48s forwards,
    glow 3.4s ease-in-out 1.6s infinite;
}
.caption   { animation-delay: 0.62s; }
.window    { animation-delay: 0.20s; animation-duration: 0.95s; }
footer a   { animation-delay: 0.85s; }

/* === Keyframes === */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.92); }
}
@keyframes glow {
  0%, 100% { box-shadow: 0 8px 30px rgba(255, 77, 109, 0.25); }
  50%      { box-shadow: 0 12px 44px rgba(255, 77, 109, 0.5); }
}
@keyframes aurora {
  0%   { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(4%, -3%) rotate(8deg); }
}
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* === Lock to one viewport on tall enough screens === */
@media (min-height: 720px) and (min-width: 900px) {
  body { overflow: hidden; height: 100vh; }
}

/* === Mobile: stack, demo on top === */
@media (max-width: 900px) {
  main {
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem 1.25rem 0.5rem;
  }
  .hero {
    order: 2;
    text-align: center;
    align-items: center;
    flex: 0 0 auto;
  }
  .demo {
    order: 1;
    flex: 0 0 auto;
  }
  .tagline, .sub { max-width: 32ch; }
  .chat-body { height: 220px; }
  footer { justify-content: center; padding: 0.75rem 1rem 1rem; }
}

/* Respect reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .window, .wordmark, .tagline, .sub, .download, .caption,
  footer a, .wordmark .dot, body::before {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .bubble-typing span { animation: none !important; }
}
