/* Repliwave hero: the live demo at the top of the home page (and alone on /lab/hero).
   Palette from the story: a blue night (3 AM) -> copy paper (the lights come on);
   answers are written in ballpoint blue; facts on a page are marked with a highlighter. */
:root {
  --night: #070a14;
  --night-2: #141b31;
  --ink: #0d1222;
  --ink-2: #1e2538;
  --paper: #efe9dc;
  --pencil: #5f6474;
  --night-dim: #9aa1b8;
  --pen: #d6bf8c;
  --pen-soft: #a89a74;
  --marker: #d6bf8c;
  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans: 'Geist', system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;
  --ease: cubic-bezier(.2, .7, .1, 1);
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--night);
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color 1.3s var(--ease), color 1.3s var(--ease);
}
body.lab { overflow: hidden; }
body.locked { overflow: hidden; }
body.day { background: #0b0e1a; color: var(--paper); } /* lights on: a warm lamp in the lobby, never white */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: var(--mono); letter-spacing: .02em; }

/* the hero is one screen; everything in it is positioned inside it */
/* overflow: clip (not hidden): a hidden box can still be scrolled by focus(), which shifted the whole demo */
.hero { position: relative; height: 100vh; height: 100svh; min-height: 560px; overflow: hidden; overflow: clip; color: var(--paper); transition: color 1.3s var(--ease); }
body.day .hero { color: var(--paper); }

/* the 3D layer sits ABOVE the chat card (letters must land on it) but never takes clicks */
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 5; pointer-events: none; }

/* "lights on": a soft white bloom from the top when the shop wakes up */
.lamp {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(70vmax 55vmax at 50% -12%, rgba(214, 191, 140, .30), transparent 62%);
  opacity: 0; transition: opacity 1.6s var(--ease);
}
body.day .lamp { opacity: 1; }
.grain {
  position: absolute; inset: -50%; z-index: 6; pointer-events: none; opacity: .08;
  background-size: 180px; mix-blend-mode: overlay;
  animation: grain 1s steps(6) infinite;
  transition: opacity 1.3s;
}
body.day .grain { opacity: .07; }
@keyframes grain {
  0% { transform: translate(0, 0) } 20% { transform: translate(-3%, 2%) } 40% { transform: translate(2%, -3%) }
  60% { transform: translate(-2%, -1%) } 80% { transform: translate(3%, 3%) } 100% { transform: translate(0, 0) }
}

/* header (shared with the site; site.css adds the nav) */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center; gap: 24px;
  padding: 22px clamp(20px, 5vw, 64px);
  color: var(--paper); transition: color .4s, background-color .4s;
}
body.day .top { color: var(--paper); }
.logo { font-family: var(--serif); font-size: 26px; letter-spacing: .01em; color: inherit; text-decoration: none; }
.clock { font-size: 13px; opacity: .7; }
.clock::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--marker); margin-right: 8px; vertical-align: 1px; }
.top-right { display: flex; align-items: center; gap: 16px; }
.try {
  border: 0; background: var(--pen); color: #fff; text-decoration: none;
  border-radius: 99px; padding: 10px 18px; font: 500 14px var(--sans); cursor: pointer;
  transition: background-color .2s, transform .2s var(--ease);
}
button.try { opacity: 0; transform: translateY(-6px); transition: opacity .6s var(--ease), transform .6s var(--ease), background-color .2s; }
button.try.on { opacity: 1; transform: none; }
.try:hover { background: #1b31b5; }
.try[hidden] { display: none; }

/* ------------------------------------------------ intro */
.intro {
  position: absolute; z-index: 3; left: clamp(20px, 8vw, 128px); right: clamp(20px, 8vw, 128px);
  top: 50%; transform: translateY(-50%);
  max-width: 980px; pointer-events: none;
  transition: opacity .7s var(--ease), transform 1s var(--ease), filter .7s;
}
.intro > * { pointer-events: auto; }
.intro.gone { opacity: 0; transform: translateY(-56%); filter: blur(6px); }
.intro.gone > * { pointer-events: none; }
.eyebrow { font-size: 13px; color: var(--night-dim); margin-bottom: 26px; }
.hero h1 {
  font-family: 'Bodoni Moda', 'Didot', serif; font-weight: 400;
  font-size: clamp(42px, 6.6vw, 104px); line-height: .94; letter-spacing: -.035em;
}
.hero h1 em { font-style: italic; color: #d6bf8c; }

.read {
  margin-top: 48px; display: flex; align-items: center;
  max-width: 620px; border-bottom: 1px solid rgba(245, 245, 240, .3);
  transition: border-color .3s;
}
.read:focus-within, .read:hover { border-color: var(--marker); }
.read input {
  flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--paper);
  font: 400 clamp(18px, 2vw, 22px) var(--sans); padding: 16px 0;
}
.read input::placeholder { color: rgba(245, 245, 240, .45); }
.read button {
  background: var(--marker); border: 0; color: var(--night); cursor: pointer; border-radius: 99px;
  font: 500 15px var(--sans); padding: 10px 20px; margin-left: 12px; white-space: nowrap;
}
.note { margin-top: 16px; font-size: 13px; color: rgba(245, 245, 240, .5); line-height: 1.6; max-width: 60ch; }
.note .err { color: var(--marker); }

/* ------------------------------------------------ whispers: unanswered questions in the dark (tap one) */
.whispers { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; transition: opacity .8s; }
.whispers.gone { opacity: 0; }
.whispers.gone .whisper { pointer-events: none; }
.whisper {
  position: absolute; max-width: 260px; pointer-events: auto; cursor: pointer; text-align: start;
  font: 13px/1.4 var(--sans); color: rgba(245, 245, 240, .6);
  padding: 9px 13px; border-radius: 14px 14px 14px 4px;
  background: rgba(245, 245, 240, .05); border: 1px solid rgba(245, 245, 240, .1);
  opacity: 0; transform: translateY(8px);
  transition: opacity 1.2s var(--ease), transform 1.2s var(--ease), color .25s, border-color .25s, background-color .25s;
}
.whisper small { display: block; font-family: var(--mono); font-size: 10px; color: rgba(245, 245, 240, .35); margin-top: 4px; }
.whisper:hover, .whisper:focus-visible { color: var(--night); border-color: var(--marker); background: var(--marker); outline: 0; }
.whisper:hover small, .whisper:focus-visible small { color: rgba(10, 15, 31, .6); }
.whisper.on { opacity: 1; transform: none; }
.whisper.off { opacity: 0; transform: translateY(-6px); pointer-events: none; }
.whisper.picked { opacity: 1; color: var(--night); background: var(--marker); transform: scale(1.06); }

/* ------------------------------------------------ status line */
.status {
  position: absolute; z-index: 7; left: 50%; bottom: 30px; transform: translateX(-50%);
  font-size: 13px; letter-spacing: .03em; color: var(--night-dim); white-space: nowrap; transition: opacity .6s;
}
.status b { color: var(--pen); font-weight: 500; }

/* ------------------------------------------------ chat (ink card on paper) */
.chat {
  position: absolute; z-index: 4;
  right: clamp(20px, 6vw, 96px); top: 52%; transform: translateY(-50%);
  width: min(430px, 38vw); height: min(620px, 78vh);
  display: flex; flex-direction: column;
  background: rgba(13, 18, 34, .92); color: var(--paper);
  border-radius: 20px; border: 0.5px solid rgba(214, 191, 140, .35);
  box-shadow: 0 60px 110px -40px rgba(0, 0, 0, .85);
  opacity: 0; transition: opacity .9s var(--ease);
}
.chat[hidden] { display: none; }
.chat.in { opacity: 1; }
.chat-head { display: flex; gap: 12px; align-items: center; padding: 18px 20px 14px; border-bottom: 1px solid rgba(245, 245, 240, .1); }
.chat-head b { display: block; font-family: 'Bodoni Moda', serif; font-style: italic; font-weight: 400; font-size: 22px; line-height: 1; }
.chat-head small { display: block; font-size: 12px; color: var(--night-dim); margin-top: 4px; }
.chat-head > div { flex: 1; min-width: 0; }
.chat-head small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share { flex: none; border: 1px solid rgba(245, 245, 240, .3); background: transparent; color: var(--paper); border-radius: 99px; padding: 7px 14px; font: 500 13px var(--sans); cursor: pointer; }
.share:hover { background: var(--marker); color: var(--night); border-color: var(--marker); }
.share[hidden] { display: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--marker); flex: none; }

.chat-log { flex: 1; overflow-y: auto; padding: 18px 20px 6px; display: flex; flex-direction: column; gap: 12px; }
.msg { font-size: 16px; line-height: 1.5; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bot { color: var(--paper); }
.msg.me {
  align-self: flex-end; max-width: 85%;
  background: var(--pen); color: var(--night);
  padding: 9px 14px; border-radius: 16px 16px 4px 16px; font-size: 15px;
}
.msg.new { animation: rise .6s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); filter: blur(3px) } to { opacity: 1; transform: none; filter: none } }
.msg.pending { opacity: 0; transition: opacity .35s linear; }
.msg.pending.shown { opacity: 1; }
.typing { display: inline-flex; gap: 5px; padding: 6px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--night-dim); animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s } .typing i:nth-child(3) { animation-delay: .3s }
@keyframes blink { 0%, 80%, 100% { opacity: .25 } 40% { opacity: 1 } }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 20px 4px; opacity: 0; transition: opacity .6s .2s; }
.chat.ready .chips { opacity: 1; }
.chips button {
  border: 1px solid rgba(245, 245, 240, .22); background: transparent; color: var(--paper);
  border-radius: 99px; padding: 7px 12px; font: 13px var(--sans); cursor: pointer;
  transition: background-color .2s, border-color .2s, color .2s;
}
.chips button:hover { border-color: var(--paper); }
.chips .lie-label { font-size: 12px; color: var(--marker); margin: 4px 2px 0 0; width: 100%; }
.chips button.lie { border-style: dashed; border-color: rgba(242, 222, 74, .6); }
.chips button.lie:hover { background: var(--marker); color: var(--night); border-color: var(--marker); }

.ask { display: flex; gap: 8px; padding: 12px 14px 14px; }
.ask input {
  flex: 1; min-width: 0; border: 1px solid rgba(245, 245, 240, .14); border-radius: 12px;
  padding: 12px 14px; font: 16px var(--sans); color: var(--paper); background: var(--ink-2); outline: 0; /* 16px: below that, iPhones zoom the page on focus */
}
.ask input::placeholder { color: rgba(245, 245, 240, .4); }
.ask input:focus { border-color: var(--pen-soft); }
.ask button { width: 46px; border: 0; border-radius: 12px; background: var(--pen); color: var(--night); font-size: 18px; cursor: pointer; }
.ask button:disabled { opacity: .4; cursor: default; }

/* "try it on your site" form inside the card */
.site { padding: 14px 20px 16px; border-top: 1px solid rgba(245, 245, 240, .1); }
.site[hidden] { display: none; }
.site-q { font-family: 'Bodoni Moda', serif; font-style: italic; font-size: 21px; line-height: 1.2; margin-bottom: 12px; }
.site-row { display: flex; gap: 8px; }
.site input {
  flex: 1; min-width: 0; border: 1px solid rgba(245, 245, 240, .25); border-radius: 12px;
  padding: 12px 14px; font: 16px var(--sans); color: var(--paper); background: var(--ink-2); outline: 0;
}
.site input:focus { border-color: var(--marker); }
.site input::placeholder { color: rgba(245, 245, 240, .4); }
.site button { border: 0; border-radius: 12px; padding: 0 16px; background: var(--marker); color: var(--night); font: 500 14px var(--sans); cursor: pointer; white-space: nowrap; }
.site-note { margin-top: 10px; font-size: 12px; color: var(--night-dim); }
.chat.site-mode .chips, .chat.site-mode .ask { display: none; }

.scroll-cue {
  position: absolute; z-index: 7; left: clamp(20px, 8vw, 128px); bottom: 28px;
  font-size: 14px; color: inherit; opacity: .55; text-decoration: none;
}
.scroll-cue:hover { opacity: 1; }
body.playing .scroll-cue { opacity: 0; pointer-events: none; }

/* ------------------------------------------------ phones */
@media (max-width: 760px) {
  .intro { top: auto; bottom: 12vh; transform: none; }
  .intro.gone { transform: translateY(-4%); }
  .read { margin-top: 28px; }
  .chat {
    left: 10px; right: 10px; width: auto; top: auto; bottom: 10px; transform: none;
    height: 56%;
  }
  .status { bottom: calc(56% + 22px); font-size: 12px; }
  .whisper { max-width: 200px; font-size: 12px; }
  .top-right { gap: 10px; }
  .top-right .clock { display: none; }
  .try { padding: 8px 13px; font-size: 13px; }
  .site-q { font-size: 19px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chips button { flex: none; }
  .chips .lie-label { width: auto; flex: none; margin: 0 0 0 6px; }
  .scroll-cue { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* hover states ease instead of snapping */
.whisper small { transition: color .25s; }
.share { transition: background-color .2s, color .2s, border-color .2s; }
.scroll-cue { transition: opacity .3s; }
.chips button.lie { transition: background-color .2s, color .2s, border-color .2s; }