/* sorbae.ai marketing site — motion design components.
 *
 * Everything here is CSS keyframes + a small vanilla driver in js/site.js.
 * No animation libraries, no build step — same constraints as the app.
 *
 * Rules followed throughout:
 *   - slow and few: 200-450ms, ease-out, fades and small rises only
 *   - nothing bounces; the only fast-moving thing on the page should be her
 *   - every looping animation stops dead under prefers-reduced-motion,
 *     leaving a legible static end-state (see the block at the bottom) */

/* ---------- scroll reveal ---------- */

.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity var(--dur-3) var(--ease),
    transform var(--dur-3) var(--ease);
  will-change: opacity, transform;
}
.js .reveal.is-in {
  opacity: 1;
  transform: none;
}
/* stagger children of a revealed group */
.reveal-group > * {
  transition-delay: calc(var(--i, 0) * 70ms);
}

/* ================================================================
   1. TEXTING ANIMATION  —  the iMessage-style thread
   Driven by js/site.js: it adds .is-shown to each .msg in sequence,
   parks a typing indicator before each inbound message, then resets.
   ================================================================ */

.phone {
  --phone-w: 330px;
  width: min(100%, var(--phone-w));
  margin-inline: auto;
  background: var(--surface);
  border: var(--hairline-w) solid var(--hairline);
  border-radius: 26px;
  box-shadow: var(--shadow-float);
  overflow: hidden;
}

.phone__bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-bottom: var(--hairline-w) solid var(--hairline);
  background: var(--stage);
}

.phone__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 34% 30%,
    var(--accent-hi),
    var(--accent-dim) 72%
  );
  flex: none;
  position: relative;
}
.phone__avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--online);
  border: 2px solid var(--stage);
}

.phone__who {
  font-size: 0.875rem;
  color: var(--text-1);
  line-height: 1.2;
}
.phone__who small {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-3);
}

.phone__thread {
  padding: 0.9rem;
  min-height: 340px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--run-gap, 2px);
}

.msg {
  max-width: 78%;
  padding: 8px 13px;
  font-size: 15px;
  line-height: 1.35;
  border-radius: 18px;
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  transition: opacity 260ms var(--ease), transform 260ms var(--ease);
  margin-bottom: 8px;
}
.msg.is-shown {
  opacity: 1;
  transform: none;
}

.msg--in {
  align-self: flex-start;
  background: var(--bubble-in);
  color: var(--text-1);
  border-bottom-left-radius: 6px;
}
.msg--out {
  align-self: flex-end;
  background: var(--accent);
  color: var(--on-accent);
  border-bottom-right-radius: 6px;
}

/* typing indicator — three dots, staggered */
.typing {
  align-self: flex-start;
  display: none;
  gap: 4px;
  align-items: center;
  background: var(--bubble-in);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  padding: 11px 14px;
  margin-bottom: 8px;
}
.typing.is-shown {
  display: inline-flex;
}
.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: dot 1.25s ease-in-out infinite;
}
.typing i:nth-child(2) {
  animation-delay: 0.16s;
}
.typing i:nth-child(3) {
  animation-delay: 0.32s;
}
@keyframes dot {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* the little camera glyph that rides the typing indicator when she is
   composing a photo — mirrors the app's photo.consider event */
.typing__cam {
  font-size: 12px;
  margin-left: 2px;
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease);
}
.typing.is-photo .typing__cam {
  opacity: 1;
}

/* a photo message: placeholder frame that "develops" in */
.msg--photo {
  padding: 5px;
  background: var(--bubble-in);
  max-width: 62%;
}
.msg--photo .ph {
  border-radius: 14px;
  aspect-ratio: 3 / 4;
  width: 168px;
  max-width: 100%;
}

/* ================================================================
   2. VOICE  —  waveform + audio-note player
   ================================================================ */

.wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 40px;
}
.wave i {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  height: 22%;
  transform-origin: center;
  animation: waveBar 1.15s ease-in-out infinite;
}
.wave i:nth-child(6n + 1) {
  animation-duration: 1.4s;
}
.wave i:nth-child(6n + 2) {
  animation-duration: 0.95s;
}
.wave i:nth-child(6n + 3) {
  animation-duration: 1.6s;
}
.wave i:nth-child(6n + 4) {
  animation-duration: 1.1s;
}
.wave i:nth-child(6n + 5) {
  animation-duration: 1.3s;
}
@keyframes waveBar {
  0%,
  100% {
    height: 18%;
    opacity: 0.55;
  }
  50% {
    height: 92%;
    opacity: 1;
  }
}

/* static (already-recorded) waveform used inside the audio note */
.wave--still i {
  animation: none;
  background: var(--accent-disc);
  opacity: 1;
}
.wave--still i.is-played {
  background: var(--accent);
}

.note {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--bubble-in);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  padding: 0.6rem 0.85rem;
  max-width: 300px;
}
.note__play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  flex: none;
  cursor: pointer;
  font-size: 11px;
}
.note__time {
  font-size: 0.75rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  flex: none;
}

/* ================================================================
   3. VIDEO CALL FRAME  —  wraps the (placeholder) render loop
   ================================================================ */

.callframe {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  background: var(--stage);
  border: var(--hairline-w) solid var(--hairline);
  box-shadow: var(--shadow-float);
  aspect-ratio: 3 / 4;
  max-width: 420px;
  margin-inline: auto;
}
@media (min-width: 900px) {
  .callframe {
    max-width: none;
  }
}

.callframe > video,
.callframe > .ph {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

/* film grain + vignette tie renders into the page */
.callframe::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at 50% 40%,
    transparent 52%,
    rgba(0, 0, 0, 0.42) 100%
  );
}

.callframe__chrome {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.9rem;
  z-index: 2;
  pointer-events: none;
}

.callframe__top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(12, 14, 17, 0.62);
  backdrop-filter: blur(8px);
  border: var(--hairline-w) solid var(--hairline);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}
.pill--live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--online);
  animation: livePulse 2.4s ease-in-out infinite;
}
@keyframes livePulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--online) 45%, transparent);
  }
  50% {
    opacity: 0.65;
    box-shadow: 0 0 0 5px transparent;
  }
}

.callframe__bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.ctrl {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(12, 14, 17, 0.62);
  backdrop-filter: blur(8px);
  border: var(--hairline-w) solid var(--hairline);
  display: grid;
  place-items: center;
  color: var(--text-1);
  font-size: 14px;
}
.ctrl--end {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
}

/* the caption line that mirrors word-timestamp lipsync */
.callframe__cap {
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  bottom: 4.2rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-1);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
  z-index: 2;
  pointer-events: none;
}
.callframe__cap b {
  font-weight: 400;
  opacity: 0.35;
  transition: opacity 140ms linear;
}
.callframe__cap b.is-said {
  opacity: 1;
}

/* ================================================================
   4. MEMORY GRAPH
   ================================================================ */

.memgraph {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-width: 520px;
  margin-inline: auto;
}

.memgraph .edge {
  stroke: var(--hairline);
  stroke-width: 1;
  fill: none;
  stroke-dasharray: 3 5;
  animation: edgeDrift 9s linear infinite;
}
.memgraph .edge--hot {
  stroke: var(--accent-dim);
}
@keyframes edgeDrift {
  to {
    stroke-dashoffset: -64;
  }
}

.memgraph .node {
  fill: var(--surface-2);
  stroke: var(--hairline);
  stroke-width: 1;
  animation: nodeFloat 11s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}
.memgraph .node--hot {
  fill: color-mix(in srgb, var(--accent) 22%, var(--surface));
  stroke: var(--accent-dim);
}
.memgraph .node:nth-of-type(2n) {
  animation-duration: 13s;
  animation-delay: -3s;
}
.memgraph .node:nth-of-type(3n) {
  animation-duration: 15s;
  animation-delay: -6s;
}
@keyframes nodeFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.memgraph text {
  fill: var(--text-2);
  font-size: 9px;
  font-family: var(--font-sans);
}
.memgraph .lbl--hot {
  fill: var(--text-1);
}

/* a recall pulse travelling the graph */
.memgraph .pulse {
  fill: var(--accent);
  opacity: 0;
  animation: recall 6s ease-in-out infinite;
}
@keyframes recall {
  0%,
  70%,
  100% {
    opacity: 0;
  }
  12%,
  46% {
    opacity: 0.95;
  }
}

/* ================================================================
   5. MEDIA PLACEHOLDER
   Anywhere a real asset is still missing, .ph renders an obviously
   intentional slate instead of a broken image. Each one names the asset that replaces it.
   ================================================================ */

.ph {
  position: relative;
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(
      -45deg,
      transparent 0 11px,
      color-mix(in srgb, var(--hairline) 55%, transparent) 11px 12px
    ),
    var(--stage);
  border: var(--hairline-w) dashed var(--hairline);
  border-radius: var(--radius-lg);
  color: var(--text-3);
  text-align: center;
  overflow: hidden;
}

.ph__label {
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.7;
  padding: 0.75rem;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(3px);
  border-radius: var(--radius-sm);
  max-width: 88%;
}
.ph__label b {
  display: block;
  color: var(--text-2);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  font-size: 0.8125rem;
}

/* a slow sheen so placeholders don't read as broken/static */
.ph::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 38%,
    color-mix(in srgb, var(--accent) 6%, transparent) 50%,
    transparent 62%
  );
  transform: translateX(-100%);
  animation: sheen 5.5s ease-in-out infinite;
}
@keyframes sheen {
  0%,
  62% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ================================================================
   6. REDUCED MOTION
   Kill every loop. Leave a readable static end-state, never a blank.
   ================================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  .msg {
    opacity: 1;
    transform: none;
  }

  .typing {
    display: none !important;
  }

  .wave i {
    height: 55%;
  }

  .ph::after {
    display: none;
  }
}
