/* ============================================================
   Rayer Studio — Landing Page
   "Render Timeline" design: noise → clarity as you scroll
   ============================================================ */

/* --- Fonts --- */
@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/jetbrains-mono-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* --- Custom properties --- */
:root {
  --c-bg: #0a0a0f;
  --c-text: #e8e4df;
  --c-text-dim: #8a8680;
  --c-amber: #c49a3c;
  --c-blue: #4a7fb5;
  --c-green: #7dcea0;
  --c-border: #1e1e28;
  --c-surface: #12121a;

  --f-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --f-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --noise-opacity: 0.35;
  --hero-blur: 2px;
  --grid-opacity: 0.02;
  --glow-opacity: 0;
}

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--f-sans);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Utility --- */
.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;
}

/* --- Dot grid background --- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--c-text-dim) 0.5px, transparent 0.5px);
  background-size: 32px 32px;
  opacity: var(--grid-opacity);
  pointer-events: none;
  z-index: 0;
}

/* --- Noise overlay --- */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: var(--noise-opacity);
  background:
    repeating-conic-gradient(var(--c-text-dim) 0% 25%, transparent 0% 50%) 0 0 / 4px 4px;
  mix-blend-mode: overlay;
  transition: opacity 0.1s linear;
}

/* --- HUD --- */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  pointer-events: none;
}

.hud__brand {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--c-text-dim);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.hud__brand.visible {
  opacity: 1;
}

.hud__progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hud__bar {
  width: 120px;
  height: 2px;
  background: var(--c-border);
  border-radius: 1px;
  overflow: hidden;
}

.hud__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--c-blue), var(--c-amber));
  border-radius: 1px;
  transition: width 0.1s linear;
}

.hud__spp {
  font-family: var(--f-mono);
  font-size: 0.65rem;
  color: var(--c-text-dim);
  min-width: 5ch;
  text-align: right;
}

/* --- Sections (shared) --- */
.section {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6rem 1.5rem;
}

/* --- Reveal animation --- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
.reveal:nth-child(2) { transition-delay: 0.1s; }
.reveal:nth-child(3) { transition-delay: 0.2s; }
.reveal:nth-child(4) { transition-delay: 0.3s; }

/* --- Section 1: Hero --- */
.section--hero {
  min-height: 100vh;
  padding: 0;
}

.hero__content {
  text-align: center;
  filter: blur(var(--hero-blur));
  transition: filter 0.1s linear;
}

.hero__title {
  font-family: var(--f-mono);
  font-size: clamp(2rem, 8vw, 5rem);
  font-weight: 400;
  letter-spacing: 0.15em;
  color: var(--c-text);
  margin-bottom: 1rem;
}

.hero__tagline {
  font-size: clamp(0.9rem, 2.5vw, 1.2rem);
  color: var(--c-text-dim);
  font-weight: 300;
  letter-spacing: 0.05em;
}

/* --- Section 2: Agent Chat --- */
.section--agent {
  min-height: auto;
  padding: 8rem 1.5rem;
}

.agent-chat {
  max-width: 640px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.chat-block {
  width: 100%;
}

.chat-prompt {
  font-family: var(--f-mono);
  font-size: 0.95rem;
  color: var(--c-amber);
  padding-left: 0;
}

.chat-response {
  padding-left: 1rem;
  border-left: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.chat-response p {
  font-size: 0.95rem;
  color: var(--c-text);
  line-height: 1.7;
}

.chat-cmd {
  font-family: var(--f-mono);
  font-size: 0.85rem;
  color: var(--c-green);
}

.chat-yaml {
  font-family: var(--f-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
}

.chat-yaml code {
  font-family: inherit;
}

.chat-result {
  font-family: var(--f-mono);
  font-size: 0.85rem;
  color: var(--c-green);
  opacity: 0.7;
}

/* YAML syntax colors */
.y-key { color: var(--c-amber); }
.y-val { color: var(--c-text); }
.y-str { color: var(--c-green); }
.y-num { color: var(--c-blue); }
.y-comment { color: var(--c-text-dim); }

/* --- Section 3: Pipeline --- */
.section--pipeline {
  flex-direction: column;
  gap: 4rem;
  min-height: auto;
  padding: 6rem 1.5rem;
}

.pipeline {
  width: 100%;
  max-width: 900px;
}

.pipeline__svg {
  width: 100%;
  height: auto;
}

.pipeline__line {
  stroke: var(--c-border);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  stroke-dashoffset: 40;
  transition: stroke-dashoffset 2s ease;
}

.pipeline.animate .pipeline__line {
  animation: dash-flow 2s linear infinite;
}

@keyframes dash-flow {
  to { stroke-dashoffset: 0; }
}

.pipeline__node rect {
  fill: var(--c-surface);
  stroke: var(--c-border);
  stroke-width: 1;
  transition: stroke 0.3s ease;
}

.pipeline__node text {
  fill: var(--c-text);
  font-family: var(--f-mono);
  font-size: 14px;
  text-anchor: middle;
  dominant-baseline: central;
}

.pipeline.animate .pipeline__node rect {
  stroke: var(--c-amber);
  stroke-width: 1;
}

/* Agent cards */
.agent-cards {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  max-width: 640px;
  width: 100%;
}

.agent-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  position: relative;
}

/* Stagger cards with different offsets */
.agent-card:nth-child(1) { align-self: flex-start; }
.agent-card:nth-child(2) { align-self: center; }
.agent-card:nth-child(3) { align-self: flex-end; }

.agent-card__label {
  font-family: var(--f-mono);
  font-size: 0.65rem;
  color: var(--c-text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.agent-card__prompt {
  font-size: 0.85rem;
  color: var(--c-amber);
  font-style: italic;
  margin-bottom: 0.75rem;
}

.agent-card__result {
  display: flex;
  justify-content: center;
}

.agent-card__result--text code {
  font-family: var(--f-mono);
  font-size: 0.75rem;
  color: var(--c-green);
  line-height: 1.8;
  word-break: break-word;
}

.agent-card__svg {
  width: 120px;
  height: auto;
}

.agent-card__svg--wide {
  width: 200px;
}

/* --- Section 4: Format --- */
.section--format {
  min-height: auto;
  padding: 6rem 1.5rem;
}

.format {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  max-width: 900px;
  width: 100%;
  align-items: center;
}

.format__yaml {
  font-family: var(--f-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
}

.format__yaml code {
  font-family: inherit;
}

.format__text {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.format__text p {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--c-text);
}

.format__text strong {
  color: var(--c-amber);
}

/* --- Section 5: Stack --- */
.section--stack {
  min-height: auto;
  padding: 6rem 1.5rem;
}

.stack {
  max-width: 640px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
}

.stack__line {
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: var(--c-text);
}

.stack__rule {
  width: 60px;
  border: none;
  border-top: 1px solid var(--c-border);
  margin: 1rem 0;
}

.stack__cta {
  font-size: 1rem;
  color: var(--c-text);
}

.stack__cta strong {
  color: var(--c-amber);
}

/* --- Section 6: Join --- */
.section--join {
  min-height: auto;
  padding: 8rem 1.5rem 4rem;
}

.join {
  max-width: 640px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.join__form {
  margin-top: 1rem;
}

.join__input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--f-mono);
}

.join__prompt {
  color: var(--c-amber);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.join__input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
  font-family: var(--f-mono);
  font-size: 0.9rem;
  padding: 0.5rem 0;
  outline: none;
  caret-color: var(--c-amber);
  transition: border-color 0.2s ease;
}

.join__input:focus {
  border-bottom-color: var(--c-amber);
}

.join__input::placeholder {
  color: var(--c-text-dim);
  opacity: 0.5;
}

.join__submit {
  font-family: var(--f-mono);
  font-size: 0.8rem;
  color: var(--c-bg);
  background: var(--c-amber);
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 2px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
}

.join__submit:hover {
  opacity: 0.85;
}

.join__submit:focus-visible {
  outline: 2px solid var(--c-amber);
  outline-offset: 2px;
}

.join__status {
  font-family: var(--f-mono);
  font-size: 0.8rem;
  color: var(--c-green);
  margin-top: 0.75rem;
  padding-left: 1.2rem;
  min-height: 1.2em;
}

.join__status--error {
  color: #c44;
}

/* --- Converged glow (section 6 background) --- */
.section--join::before {
  content: '';
  position: absolute;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(ellipse, var(--c-amber) 0%, transparent 70%);
  opacity: var(--glow-opacity);
  pointer-events: none;
  z-index: -1;
}

/* --- Footer --- */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem 1.5rem 3rem;
  font-family: var(--f-mono);
  font-size: 0.7rem;
  color: var(--c-text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.footer__link {
  color: var(--c-text-dim);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer__link:hover {
  color: var(--c-text);
}

.footer__sep {
  opacity: 0.3;
}

/* --- Mobile --- */
@media (max-width: 768px) {
  .section {
    padding: 4rem 1.5rem;
  }

  .section--hero {
    padding: 0;
  }

  .section--agent {
    padding: 4rem 1.5rem;
  }

  /* Vertical pipeline on mobile */
  .pipeline__svg {
    display: none;
  }

  .pipeline::after {
    content: 'Layout → Animate → Light → Render → Comp';
    display: block;
    font-family: var(--f-mono);
    font-size: 0.8rem;
    color: var(--c-text-dim);
    text-align: center;
    padding: 1rem;
    border: 1px solid var(--c-border);
    border-radius: 4px;
    background: var(--c-surface);
    word-spacing: 0.3em;
  }

  .agent-card:nth-child(1),
  .agent-card:nth-child(2),
  .agent-card:nth-child(3) {
    align-self: stretch;
  }

  .format {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hud {
    padding: 0.75rem 1rem;
  }

  .hud__bar {
    width: 60px;
  }

  .agent-card__svg--wide {
    width: 160px;
  }
}

@media (max-width: 480px) {
  .hero__title {
    letter-spacing: 0.08em;
  }

  .join__input-row {
    flex-wrap: wrap;
  }

  .join__input {
    width: 100%;
  }

  .join__submit {
    width: 100%;
    padding: 0.6rem 1rem;
    margin-top: 0.5rem;
  }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .noise-overlay {
    display: none;
  }

  .hero__content {
    filter: none !important;
  }

  .pipeline__line {
    animation: none;
    stroke-dashoffset: 0;
  }

  * {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}

/* --- Light mode override --- */
@media (prefers-color-scheme: light) {
  :root {
    --c-bg: #f5f3f0;
    --c-text: #1a1a1f;
    --c-text-dim: #6a6660;
    --c-border: #d8d4cf;
    --c-surface: #eae7e3;
  }

  .noise-overlay {
    display: none;
  }

  .hero__content {
    filter: none !important;
  }
}
