/* relative.quest -- pop-art aesthetic, organic-flow layout, slab-serif typography
   aurora-gradient palette, lottie/CSS animations, marble-texture imagery,
   retro-pattern motifs, calm-serene tone. */

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

:root {
  /* Aurora palette */
  --aurora-teal:   #2DD4BF;
  --aurora-violet: #8B5CF6;
  --aurora-green:  #34D399;

  /* Marble + pop accents */
  --marble-light:  #F0ECE8;
  --marble-shade:  #C8B8A8;
  --pop-yellow:    #FFE066;
  --retro-orange:  #E87040;

  /* Text */
  --deep-space:    #1A1A2E;

  /* Type scale */
  --font-display: "Zilla Slab", Georgia, serif;
  --font-body:    "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    "Fira Code", ui-monospace, "SF Mono", Menlo, monospace;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: clamp(16px, 1.5vw, 18px);
  line-height: 1.75;
  color: var(--deep-space);
  background: var(--marble-light);
  overflow-x: hidden;
}

/* ---------- Retro pattern viewport frame ----------
   Repeating geometric motifs form a "quantum frame" around the viewport. */

.retro-frame {
  position: fixed;
  z-index: 50;
  pointer-events: none;
}

.retro-frame-top, .retro-frame-bottom {
  left: 0;
  right: 0;
  height: 14px;
  background-image:
    linear-gradient(135deg, var(--retro-orange) 25%, transparent 25%),
    linear-gradient(225deg, var(--retro-orange) 25%, transparent 25%),
    linear-gradient(315deg, var(--retro-orange) 25%, transparent 25%),
    linear-gradient( 45deg, var(--retro-orange) 25%, transparent 25%);
  background-size: 14px 14px;
  background-position: 0 0, 0 0, 0 0, 0 0;
  background-color: var(--deep-space);
}
.retro-frame-top    { top: 0; }
.retro-frame-bottom { bottom: 0; }

.retro-frame-left, .retro-frame-right {
  top: 14px;
  bottom: 14px;
  width: 14px;
  background:
    repeating-linear-gradient(
      0deg,
      var(--retro-orange) 0 7px,
      var(--deep-space)   7px 14px
    );
}
.retro-frame-left  { left: 0; }
.retro-frame-right { right: 0; }

/* ---------- Aurora background ---------- */
.aurora {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(45, 212, 191, 0.55), transparent 60%),
    radial-gradient(ellipse at 80% 30%, rgba(139, 92, 246, 0.50), transparent 60%),
    radial-gradient(ellipse at 50% 90%, rgba(52, 211, 153, 0.45), transparent 60%),
    linear-gradient(135deg, #0E1330 0%, #1A1A2E 50%, #2A1A3E 100%);
  background-size: 200% 200%, 200% 200%, 200% 200%, 100% 100%;
  animation: aurora-drift 22s ease-in-out infinite alternate;
}
.aurora--footer {
  background:
    radial-gradient(ellipse at 30% 30%, rgba(45, 212, 191, 0.45), transparent 60%),
    radial-gradient(ellipse at 70% 70%, rgba(139, 92, 246, 0.40), transparent 60%),
    linear-gradient(135deg, #1A1A2E 0%, #0E1330 100%);
  animation: aurora-drift 30s ease-in-out infinite alternate;
}

@keyframes aurora-drift {
  0%   { background-position:   0% 0%,   0% 0%,   0% 0%, 0% 0%; }
  100% { background-position: 100% 100%, 80% 30%, 30% 80%, 0% 0%; }
}

/* ---------- Hero (Spacetime Opening) ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  padding: 6rem 6vw 4rem;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero__inner {
  position: relative;
  z-index: 2;
  max-width: 820px;
  text-align: center;
  color: var(--marble-light);
  transform: scale(0.96);
  opacity: 0;
  animation: hero-rise 1.4s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s forwards;
}

@keyframes hero-rise {
  to { transform: scale(1); opacity: 1; }
}

.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--pop-yellow);
  margin: 0 0 1rem;
}

.hero__wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(48px, 9vw, 112px);
  line-height: 1;
  margin: 0 0 1.5rem;
  letter-spacing: -0.02em;
  text-shadow: 0 4px 0 var(--retro-orange), 0 8px 30px rgba(0,0,0,0.4);
}
.hero__wordmark .dot { color: var(--pop-yellow); }

.hero__lede {
  font-size: clamp(17px, 1.6vw, 20px);
  line-height: 1.7;
  max-width: 600px;
  margin: 0 auto 2rem;
  color: rgba(240, 236, 232, 0.92);
}

.hero__equation {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 4vw, 44px);
  color: var(--pop-yellow);
  letter-spacing: 0.02em;
  margin: 0;
}
.hero__equation sup { font-size: 0.55em; vertical-align: super; }

/* ---------- Marble mass objects ----------
   Float as gravity wells. JS adds skew to nearby content. */

.marble {
  position: absolute;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, var(--marble-light), var(--marble-shade) 70%, #9A8A7A 100%);
  box-shadow:
    inset -8px -16px 32px rgba(0,0,0,0.18),
    inset  8px  10px 24px rgba(255,255,255,0.5),
    0 18px 40px rgba(0,0,0,0.35);
  left: var(--mx);
  top: var(--my);
  z-index: 1;
  opacity: 0;
  animation: marble-fade 2.2s ease-out 0.4s forwards;
}
/* Subtle veining via overlay */
.marble::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 70% 80%, rgba(26, 26, 46, 0.10), transparent 40%),
    radial-gradient(circle at 20% 70%, rgba(26, 26, 46, 0.08), transparent 50%);
  mix-blend-mode: multiply;
}
.marble--lg { width: 380px; height: 380px; }
.marble--md { width: 240px; height: 240px; }
.marble--sm { width: 140px; height: 140px; }

@keyframes marble-fade {
  to { opacity: 1; }
}

@media (max-width: 720px) {
  .marble--lg { width: 220px; height: 220px; }
  .marble--md { width: 150px; height: 150px; }
  .marble--sm { width: 90px;  height: 90px;  }
}

/* ---------- Curved content path ----------
   Sections alternate margins to form a meandering S-curve. */
.path {
  position: relative;
  padding: 6rem 0 8rem;
  background:
    linear-gradient(180deg, var(--marble-light) 0%, #FAF6F0 50%, var(--marble-light) 100%);
}

.curve-section {
  position: relative;
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  align-items: center;
  gap: 3rem;
  max-width: 60vw;
  padding: 3rem 0;
  transition: transform 0.6s ease-out;
}

.curve-section.is-warped { transform: skew(0.5deg, 0); }

.curve-left  { margin-left: 10vw; }
.curve-right { margin-left: 30vw; }
.curve-right .curve-section__art { order: 2; }
.curve-right .curve-section__body { order: 1; text-align: right; }

@media (max-width: 900px) {
  .curve-section {
    grid-template-columns: 1fr;
    max-width: 84vw;
    gap: 1.5rem;
  }
  .curve-left  { margin-left: 6vw; }
  .curve-right { margin-left: 10vw; }
  .curve-right .curve-section__body { text-align: left; order: 2; }
  .curve-right .curve-section__art  { order: 1; }
}

.curve-section__art {
  position: relative;
  border: 4px solid var(--deep-space);
  border-radius: 18px;
  background: var(--marble-light);
  padding: 1rem;
  box-shadow: 6px 6px 0 var(--retro-orange);
}

.lottie-svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Animated SVG bits */
.clock-hands { transform-origin: 100px 100px; animation: tick 14s linear infinite; }
@keyframes tick { to { transform: rotate(360deg); } }

.lens-rays path {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: lens-trace 4s ease-in-out infinite alternate;
}
.lens-rays path:nth-child(2) { animation-delay: 0.4s; }
.lens-rays path:nth-child(3) { animation-delay: 0.8s; }
@keyframes lens-trace { to { stroke-dashoffset: 0; } }

.fabric-grid path { animation: fabric-flex 8s ease-in-out infinite alternate; }
@keyframes fabric-flex {
  0%   { transform: translateY(0); }
  100% { transform: translateY(2px); }
}

.frame-outer { animation: frame-spin 30s linear infinite; transform-origin: 100px 100px; }
.frame-mid   { animation: frame-spin 18s linear infinite reverse; transform-origin: 100px 100px; }
@keyframes frame-spin { to { transform: rotate(360deg); } }

/* Pattern accent strip on each section body */
.curve-section__body {
  position: relative;
  padding: 1rem 0;
}
.curve-section__body::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 80px;
  height: 6px;
  background:
    repeating-linear-gradient(90deg,
      var(--retro-orange) 0 10px,
      var(--deep-space)   10px 16px);
}
.curve-right .curve-section__body::before {
  left: auto;
  right: 0;
}

.curve-section__chapter {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.3em;
  color: var(--retro-orange);
  margin: 1rem 0 0.5rem;
  text-transform: uppercase;
}

.curve-section__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(32px, 5vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0 0 1.25rem;
  color: var(--deep-space);
}

.curve-section__title::after {
  content: "";
  display: block;
  width: 64px;
  height: 4px;
  margin-top: 0.75rem;
  background: var(--aurora-violet);
}
.curve-right .curve-section__title::after { margin-left: auto; }

.curve-section__body p {
  margin: 0 0 1rem;
  font-size: clamp(16px, 1.4vw, 18px);
  max-width: 56ch;
}
.curve-right .curve-section__body p { margin-left: auto; }

.curve-section__data {
  font-family: var(--font-mono);
  font-size: 14px;
  display: inline-block;
  background: var(--pop-yellow);
  color: var(--deep-space);
  padding: 0.5rem 0.85rem;
  border: 2px solid var(--deep-space);
  box-shadow: 4px 4px 0 var(--retro-orange);
  border-radius: 4px;
  margin-top: 0.5rem;
}

/* ---------- Cosmic footer ---------- */
.cosmic-footer {
  position: relative;
  padding: 6rem 6vw 5rem;
  overflow: hidden;
  isolation: isolate;
  color: var(--marble-light);
}

.cosmic-footer__inner {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}

.cosmic-footer__mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(36px, 5vw, 56px);
  margin: 0 0 1rem;
  text-shadow: 0 3px 0 var(--retro-orange);
}
.cosmic-footer__mark .dot { color: var(--pop-yellow); }

.cosmic-footer__line {
  font-size: clamp(15px, 1.4vw, 17px);
  margin: 0 0 2rem;
  color: rgba(240, 236, 232, 0.92);
  font-style: italic;
}

.cosmic-footer__nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 1.2rem;
  margin-bottom: 2rem;
}

.cosmic-footer__nav a {
  color: var(--pop-yellow);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.4rem 0.6rem;
  border-bottom: 2px solid transparent;
  transition: border-color 0.25s ease, color 0.25s ease;
}
.cosmic-footer__nav a:hover,
.cosmic-footer__nav a:focus-visible {
  border-color: var(--aurora-teal);
  color: var(--aurora-teal);
  outline: none;
}

.cosmic-footer__sig {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: rgba(240, 236, 232, 0.55);
  margin: 0;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .hero__inner { transform: none; opacity: 1; }
  .marble { opacity: 1; }
}
