/* Pulsar guest home — ink / paper / cobalt chat landing */

:root {
  --paper: #f3f4f7;
  --paper-raised: #ffffff;
  --ink: #14161c;
  --ink-soft: #2a2e38;
  --muted: #5f6675;
  --muted-soft: #8b92a1;
  --line: rgba(20, 22, 28, 0.1);
  --line-strong: rgba(20, 22, 28, 0.16);
  --cobalt: #1f4fd8;
  --cobalt-deep: #163db0;
  --cobalt-soft: rgba(31, 79, 216, 0.1);
  --cobalt-ring: rgba(31, 79, 216, 0.28);
  --user-bubble: #e8ebf2;
  --shadow: 0 10px 36px rgba(20, 22, 28, 0.08);
  --radius: 1.15rem;
  --radius-sm: 0.65rem;
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --display: "Bricolage Grotesque", "Source Sans 3", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --composer-max: 44rem;
  --thread-max: 44rem;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { color-scheme: light; }

body.guest-body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

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

.guest-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 45% at 70% 18%, var(--cobalt-soft), transparent 58%),
    radial-gradient(ellipse 50% 35% at 12% 88%, rgba(31, 79, 216, 0.06), transparent 55%),
    linear-gradient(180deg, #eef0f5 0%, var(--paper) 42%, #eef1f6 100%);
}
.guest-bg::before {
  content: "";
  position: absolute;
  inset: -20%;
  background-image:
    radial-gradient(circle at center, transparent 0, transparent 46%, rgba(31, 79, 216, 0.07) 47%, transparent 48%),
    radial-gradient(circle at center, transparent 0, transparent 62%, rgba(31, 79, 216, 0.045) 63%, transparent 64%);
  background-position: 68% 28%;
  animation: guest-rings 8s ease-in-out infinite;
}
@keyframes guest-rings {
  0%, 100% { transform: scale(1); opacity: 0.75; }
  50% { transform: scale(1.04); opacity: 1; }
}

.guest-top,
.guest-stage,
.guest-footer {
  position: relative;
  z-index: 1;
}

.guest-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem clamp(1rem, 3vw, 1.75rem);
  padding-top: max(0.85rem, env(safe-area-inset-top, 0px));
}

.guest-brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--ink);
}
.guest-brand-lockup:hover { text-decoration: none; }
.guest-brand-word {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
}
.guest-mark {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, var(--cobalt) 0%, var(--cobalt-deep) 78%);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}
.guest-pulse {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.55);
  animation: guest-pulse 2.6s var(--ease) infinite;
}
@keyframes guest-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.68); opacity: 0.75; }
}

.guest-top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.guest-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.14s var(--ease), background 0.16s, border-color 0.16s;
}
.guest-btn:hover { transform: translateY(-1px); text-decoration: none; }
.guest-btn-primary { background: var(--cobalt); color: #fff; }
.guest-btn-primary:hover { background: var(--cobalt-deep); }
.guest-btn-ghost {
  color: var(--ink);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
}
.guest-btn-ghost:hover { border-color: var(--cobalt-ring); }

/* ——— Stage: empty (centered) → chatting (thread + docked composer) ——— */
.guest-stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 0 clamp(0.85rem, 3vw, 1.5rem);
  transition: padding 0.55s var(--ease);
}

.guest-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.55rem;
  padding: 0 1rem;
  flex-shrink: 0;
  transform-origin: center top;
  transition:
    opacity 0.45s var(--ease),
    transform 0.55s var(--ease),
    max-height 0.55s var(--ease),
    margin 0.55s var(--ease),
    padding 0.55s var(--ease);
  max-height: 12rem;
  margin-bottom: 1.25rem;
}
.guest-hero-brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.75rem, 9vw, 4.6rem);
  letter-spacing: -0.045em;
  line-height: 0.95;
  margin: 0;
  color: var(--ink);
}
.guest-tagline {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  line-height: 1.45;
  max-width: 28ch;
}

.guest-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease) 0.08s;
  -webkit-overflow-scrolling: touch;
}
.guest-thread-inner {
  width: min(100%, var(--thread-max));
  margin: 0 auto;
  padding: 0.5rem 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.guest-composer-slot {
  width: min(100%, var(--composer-max));
  margin: 0 auto;
  flex-shrink: 0;
  padding-bottom: max(0.85rem, var(--safe-b));
  transition: transform 0.55s var(--ease), margin 0.55s var(--ease);
}

.guest-stage[data-state="empty"] {
  justify-content: center;
  padding-bottom: 2.5rem;
}
.guest-stage[data-state="empty"] .guest-thread {
  display: none;
}
.guest-stage[data-state="empty"] .guest-composer-slot {
  /* sits under brand in the vertical center composition */
}

.guest-stage[data-state="chatting"] {
  justify-content: flex-start;
  padding-top: 0.25rem;
}
.guest-stage[data-state="chatting"] .guest-empty {
  opacity: 0;
  transform: translateY(-12px) scale(0.96);
  max-height: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
  overflow: hidden;
}
.guest-stage[data-state="chatting"] .guest-thread {
  opacity: 1;
  pointer-events: auto;
}
.guest-stage[data-state="chatting"] .guest-composer-slot {
  margin-top: auto;
}
.guest-stage[data-state="chatting"] .guest-hint {
  opacity: 0;
  max-height: 0;
  margin: 0;
  overflow: hidden;
}

.guest-composer {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  padding: 0.7rem 0.75rem 0.7rem 1rem;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.guest-composer:focus-within {
  border-color: var(--cobalt-ring);
  box-shadow: 0 0 0 3px var(--cobalt-soft), var(--shadow);
}
.guest-composer textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  color: var(--ink);
  line-height: 1.45;
  max-height: 9rem;
  padding: 0.35rem 0;
  field-sizing: content;
}
.guest-composer textarea::placeholder { color: var(--muted-soft); }

.guest-send {
  width: 2.35rem;
  height: 2.35rem;
  border: 0;
  border-radius: 50%;
  background: var(--cobalt);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.14s var(--ease), opacity 0.15s;
}
.guest-send svg { width: 1.1rem; height: 1.1rem; }
.guest-send:hover:not(:disabled) { background: var(--cobalt-deep); transform: translateY(-1px); }
.guest-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.guest-hint {
  margin: 0.65rem 0 0;
  text-align: center;
  color: var(--muted-soft);
  font-size: 0.82rem;
  transition: opacity 0.35s var(--ease), max-height 0.45s var(--ease), margin 0.45s var(--ease);
  max-height: 2rem;
}

/* Messages */
.guest-msg {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  animation: guest-msg-in 0.4s var(--ease) both;
}
@keyframes guest-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.guest-msg-user { align-items: flex-end; }
.guest-msg-assistant { align-items: flex-start; }

.guest-bubble {
  max-width: min(100%, 36rem);
  padding: 0.75rem 1rem;
  border-radius: 1.05rem;
  line-height: 1.55;
  font-size: 0.98rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.guest-msg-user .guest-bubble {
  background: var(--user-bubble);
  color: var(--ink);
  border-bottom-right-radius: 0.35rem;
}
.guest-msg-assistant .guest-bubble {
  background: transparent;
  padding-left: 0.15rem;
  color: var(--ink-soft);
}
.guest-msg-assistant .guest-bubble :is(p, ul, ol) { margin: 0 0 0.65rem; }
.guest-msg-assistant .guest-bubble :is(p, ul, ol):last-child { margin-bottom: 0; }
.guest-msg-assistant .guest-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: rgba(20, 22, 28, 0.06);
  padding: 0.1em 0.35em;
  border-radius: 0.3rem;
}
.guest-msg-assistant .guest-bubble pre {
  overflow-x: auto;
  background: rgba(20, 22, 28, 0.06);
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  margin: 0.5rem 0;
}
.guest-msg-assistant .guest-bubble pre code {
  background: none;
  padding: 0;
}

.guest-streaming::after {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-left: 0.2rem;
  border-radius: 50%;
  background: var(--cobalt);
  vertical-align: middle;
  animation: guest-caret 1s ease-in-out infinite;
}
@keyframes guest-caret {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

.guest-err {
  color: #b42318;
  font-size: 0.9rem;
  padding: 0.35rem 0.15rem;
}

.guest-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 1rem max(0.65rem, var(--safe-b));
  font-size: 0.78rem;
  color: var(--muted-soft);
}
.guest-footer a {
  color: var(--muted);
  text-decoration: none;
}
.guest-footer a:hover { color: var(--ink); }
.guest-footer-sep { opacity: 0.5; }

/* Soft gate modal */
.guest-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(20, 22, 28, 0.42);
  backdrop-filter: blur(6px);
  animation: guest-gate-in 0.28s var(--ease) both;
}
.guest-gate[hidden] { display: none; }
@keyframes guest-gate-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.guest-gate-card {
  width: min(100%, 24rem);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  padding: 1.6rem 1.45rem 1.25rem;
  box-shadow: 0 24px 60px rgba(20, 22, 28, 0.2);
  text-align: center;
  animation: guest-card-in 0.4s var(--ease) both;
}
@keyframes guest-card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.guest-gate-card h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
  margin: 0 0 0.55rem;
}
.guest-gate-card p {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}
.guest-gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
}
.guest-gate-dismiss {
  margin-top: 0.9rem;
  border: 0;
  background: none;
  color: var(--muted-soft);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.guest-gate-dismiss[hidden] { display: none; }
.guest-gate-dismiss:hover { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .guest-bg::before,
  .guest-pulse,
  .guest-streaming::after { animation: none; }
  .guest-empty,
  .guest-thread,
  .guest-composer-slot,
  .guest-msg,
  .guest-gate,
  .guest-gate-card { transition: none; animation: none; }
}

@media (max-width: 520px) {
  .guest-top-actions .guest-btn-ghost { padding-inline: 0.85rem; }
  .guest-hero-brand { font-size: clamp(2.4rem, 12vw, 3.4rem); }
}
