/* =============================================================
   Scenes 6-10: Geometry → Kinetic → Grid → Goo → Calm
   ============================================================= */

/* ====== ACT 6 — GEOMETRY GARDEN ====== */
.act--geometry {
  background: var(--lw-paper);
  min-height: 150vh;
  padding: 180px 0;
  position: relative;
  overflow: hidden;
}
.geo-intro {
  max-width: 720px;
  margin: 0 auto 220px;
  text-align: center;
  padding: 0 24px;
}
.geo-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  width: min(100% - 48px, 1400px);
  margin: 0 auto;
  perspective: 1400px;
}
.geo-card {
  position: relative;
  aspect-ratio: 3 / 4;
  background: var(--lw-bg-elev);
  border: 1px solid var(--lw-border);
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 600ms var(--lw-ease), border-color 300ms;
  animation: geo-card-in linear both;
  animation-timeline: view();
  animation-range: entry 0% cover 40%;
}
.geo-card:hover {
  transform: rotateY(8deg) rotateX(-6deg) translateZ(20px);
  border-color: var(--lw-terra);
  z-index: 2;
}
@keyframes geo-card-in {
  from { opacity: 0; transform: translateY(80px) rotateX(20deg); }
  to   { opacity: 1; transform: translateY(0)    rotateX(0); }
}
/* Stagger via margin-top so it doesn't fight the entry keyframe */
.geo-card:nth-child(1)  { grid-column: 1 / span 3;  margin-top: 60px; }
.geo-card:nth-child(2)  { grid-column: 4 / span 3;  margin-top: 0; }
.geo-card:nth-child(3)  { grid-column: 7 / span 3;  margin-top: 40px; }
.geo-card:nth-child(4)  { grid-column: 10 / span 3; margin-top: 0; }
.geo-card:nth-child(5)  { grid-column: 2 / span 3;  margin-top: 30px; }
.geo-card:nth-child(6)  { grid-column: 5 / span 4;  aspect-ratio: 4/3; margin-top: 50px; }
.geo-card:nth-child(7)  { grid-column: 9 / span 3;  margin-top: 10px; }

.geo-card .shape { position: absolute; inset: 0; }
.geo-card .label {
  position: absolute;
  bottom: 16px; left: 16px; right: 16px;
  font-family: var(--lw-font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--lw-ink-3);
  z-index: 2;
  display: flex;
  justify-content: space-between;
}

/* individual shape treatments */
.shape-circle {
  background: radial-gradient(circle at 30% 30%, var(--lw-terra-soft), var(--lw-terra) 70%);
  border-radius: 50%;
  width: 70%; aspect-ratio: 1; margin: auto; inset: 0;
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: shape-pulse 5s ease-in-out infinite alternate;
  filter: url(#grain);
}
@keyframes shape-pulse {
  from { transform: translate(-50%, -50%) scale(0.85); }
  to   { transform: translate(-50%, -50%) scale(1.05); }
}
.shape-blob {
  width: 80%; height: 80%;
  background: var(--lw-forest);
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: blob-morph 8s ease-in-out infinite;
}
@keyframes blob-morph {
  0%,100% { border-radius: 60% 40% 30% 70% / 50% 60% 30% 60%; }
  33%     { border-radius: 30% 60% 70% 40% / 40% 30% 70% 60%; }
  66%     { border-radius: 50% 60% 40% 60% / 60% 30% 70% 40%; }
}
.shape-stripes {
  background: repeating-linear-gradient(45deg, var(--lw-ink) 0 8px, var(--lw-paper) 8px 16px);
  inset: 0;
  animation: stripes-slide 6s linear infinite;
}
@keyframes stripes-slide {
  from { background-position: 0 0; }
  to   { background-position: 45px 0; }
}
.shape-grid {
  background-image:
    linear-gradient(var(--lw-ink-4) 1px, transparent 1px),
    linear-gradient(90deg, var(--lw-ink-4) 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0.5;
  inset: 0;
}
.shape-grid::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, var(--lw-terra), transparent 40%);
  mix-blend-mode: multiply;
  animation: grid-pulse 4s ease-in-out infinite alternate;
}
@keyframes grid-pulse {
  from { transform: scale(0.5); opacity: 0.5; }
  to   { transform: scale(1.2); opacity: 1; }
}
.shape-conic {
  inset: 0;
  background: conic-gradient(from var(--rainbow-angle), #c65d3a, #d89945, #7ba05b, #3a5a78, #4a2d5a, #c65d3a);
  animation: conic-spin 10s linear infinite;
  filter: blur(0.5px);
}
@keyframes conic-spin {
  from { --rainbow-angle: 0deg; }
  to   { --rainbow-angle: 360deg; }
}
.shape-triangles {
  inset: 0;
  background:
    conic-gradient(from 0deg at 50% 100%, var(--lw-terra) 0 60deg, transparent 60deg 360deg),
    conic-gradient(from 180deg at 50% 0%, var(--lw-forest) 0 60deg, transparent 60deg 360deg);
  animation: tri-shift 5s ease-in-out infinite alternate;
}
@keyframes tri-shift {
  from { transform: rotate(0); }
  to   { transform: rotate(15deg); }
}
.shape-cross {
  inset: 0;
  background:
    linear-gradient(90deg, transparent 45%, var(--lw-ink) 45% 55%, transparent 55%),
    linear-gradient(0deg,  transparent 45%, var(--lw-ink) 45% 55%, transparent 55%);
  animation: cross-spin 12s linear infinite;
}
@keyframes cross-spin {
  from { transform: rotate(0); }
  to   { transform: rotate(360deg); }
}

/* ====== ACT 7 — KINETIC TYPOGRAPHY ====== */
.act--kinetic {
  background: var(--lw-ink);
  color: var(--lw-paper);
  min-height: 200vh;
  padding: 120px 0;
  overflow: hidden;
  position: relative;
  view-timeline-name: --kinetic;
}
.kinetic-stack { position: relative; }
.kinetic-marquee {
  display: flex;
  gap: 60px;
  white-space: nowrap;
  font-family: var(--lw-font-serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(100px, 18vw, 280px);
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--lw-paper);
  animation: marquee-scroll 40s linear infinite;
}
.kinetic-marquee-2 {
  animation-direction: reverse;
  animation-duration: 55s;
  color: transparent;
  -webkit-text-stroke: 1px var(--lw-paper);
}
@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.kinetic-marquee span { display: inline-flex; align-items: center; gap: 60px; }
.kinetic-marquee .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--lw-terra); display: inline-block; flex-shrink: 0; }

.kinetic-title {
  text-align: center;
  padding: 120px 24px;
  font-family: var(--lw-font-serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(80px, 13vw, 200px);
  line-height: 1;
  letter-spacing: -0.04em;
  animation: kinetic-zoom linear both;
  animation-timeline: view();
  animation-range: entry 0% cover 80%;
}
@keyframes kinetic-zoom {
  from { transform: scale(0.6) skewY(8deg); opacity: 0; }
  to   { transform: scale(1.2) skewY(0);    opacity: 1; }
}
.kinetic-title em { color: var(--lw-terra); }

.text-on-path {
  display: block;
  margin: 120px auto;
  width: min(100%, 900px);
  animation: path-rotate linear both;
  animation-timeline: view();
  animation-range: entry 0% cover 100%;
}
@keyframes path-rotate {
  from { transform: rotate(-15deg); }
  to   { transform: rotate(15deg); }
}
.text-on-path text {
  font-family: var(--lw-font-serif);
  font-style: italic;
  font-size: 42px;
  fill: var(--lw-paper);
  letter-spacing: 0.05em;
}

/* ====== ACT 8 — THE GRID (cursor-reactive + :has) ====== */
.act--grid {
  background: var(--lw-paper);
  min-height: 120vh;
  padding: 180px 0;
  position: relative;
  overflow: hidden;
}
.grid-wrap {
  width: min(100% - 48px, 1240px);
  margin: 0 auto;
}
.grid-tiles {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  margin-top: 80px;
  --mx: 50%;
  --my: 50%;
}
.grid-tile {
  aspect-ratio: 1;
  background: var(--lw-bg-elev);
  border: 1px solid var(--lw-border);
  position: relative;
  transition: background 400ms var(--lw-ease), transform 400ms var(--lw-ease), border-color 400ms;
}
.grid-tile::before {
  content: "";
  position: absolute;
  inset: 30%;
  background: var(--lw-terra);
  border-radius: 50%;
  transform: scale(0);
  transition: transform 400ms var(--lw-ease);
}
/* cursor-driven intensity via --mx --my distance */
.grid-tile {
  --d: 1;
  transform: scale(calc(1 - var(--d) * 0.03));
}
.grid-tile.hot {
  background: var(--lw-terra-tint);
  border-color: var(--lw-terra);
}
.grid-tile.hot::before { transform: scale(1.2); }
.grid-tile.warm {
  background: var(--lw-paper-2);
}

.grid-container-query {
  container-type: inline-size;
  margin-top: 100px;
}
.cq-card {
  background: var(--lw-bg-elev);
  border: 1px solid var(--lw-border);
  padding: 32px;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
@container (min-width: 600px) {
  .cq-card { grid-template-columns: 1fr 1fr; padding: 48px; }
}
@container (min-width: 900px) {
  .cq-card { grid-template-columns: 2fr 3fr 2fr; padding: 64px; }
  .cq-card::before { content: "expanded"; }
}

/* :has() magic — if any tile is hot, title italicizes */
.grid-wrap:has(.grid-tile.hot) .grid-title em {
  font-style: italic;
  color: var(--lw-terra);
  transform: skewX(-8deg);
}
.grid-title em {
  display: inline-block;
  transition: transform 400ms var(--lw-ease), color 400ms;
  font-style: italic;
}

/* ====== ACT 9 — THE GOO (SVG filters + blend) ====== */
.act--goo {
  background: #0d1620;
  color: var(--lw-paper);
  min-height: 120vh;
  padding: 180px 0;
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.goo-stage {
  position: relative;
  width: 100%;
  height: 80vh;
  filter: url(#goo);
}
.goo-blob {
  position: absolute;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: var(--lw-terra);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
.goo-blob.b1 { animation: goo-orbit 8s ease-in-out infinite; }
.goo-blob.b2 { animation: goo-orbit 9s ease-in-out infinite reverse; background: #d89945; animation-delay: -1s; }
.goo-blob.b3 { animation: goo-orbit2 10s ease-in-out infinite; background: var(--lw-forest); animation-delay: -3s; }
.goo-blob.b4 { animation: goo-orbit2 11s ease-in-out infinite reverse; background: var(--lw-terra-soft); }
.goo-blob.b5 { animation: goo-orbit 13s ease-in-out infinite; background: #9c3a70; animation-delay: -5s; width: 100px; height: 100px; }
.goo-cursor { /* big blob that follows cursor */
  position: absolute;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: var(--lw-paper);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  transition: top 200ms linear, left 200ms linear;
}
@keyframes goo-orbit {
  0%   { transform: translate(-50%, -50%) translate(-200px, -100px); }
  25%  { transform: translate(-50%, -50%) translate(300px, -200px); }
  50%  { transform: translate(-50%, -50%) translate(200px, 150px); }
  75%  { transform: translate(-50%, -50%) translate(-250px, 200px); }
  100% { transform: translate(-50%, -50%) translate(-200px, -100px); }
}
@keyframes goo-orbit2 {
  0%   { transform: translate(-50%, -50%) translate(150px, 100px); }
  25%  { transform: translate(-50%, -50%) translate(-200px, 150px); }
  50%  { transform: translate(-50%, -50%) translate(-150px, -200px); }
  75%  { transform: translate(-50%, -50%) translate(250px, -150px); }
  100% { transform: translate(-50%, -50%) translate(150px, 100px); }
}
.goo-caption {
  position: absolute;
  bottom: 40px; left: 0; right: 0;
  text-align: center;
  font-family: var(--lw-font-mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  z-index: 3;
}
.goo-title {
  position: absolute;
  top: 40px; left: 0; right: 0;
  text-align: center;
  z-index: 3;
}

/* ====== ACT 10 — CALM AFTER ====== */
.act--calm {
  background: var(--lw-paper);
  min-height: 100vh;
  padding: 180px 0 80px;
  text-align: center;
  position: relative;
}
.calm-wrap { max-width: 700px; margin: 0 auto; padding: 0 24px; }
.calm-title em { color: var(--lw-terra); font-style: italic; }
.calm-rule {
  width: 100px;
  height: 1px;
  background: var(--lw-ink-3);
  margin: 48px auto;
  position: relative;
}
.calm-rule::after {
  content: "";
  position: absolute;
  right: -6px; top: 50%;
  transform: translateY(-50%);
  width: 10px; height: 10px;
  background: var(--lw-terra);
  border-radius: 50%;
}

/* Footer */
.footer {
  background: var(--lw-ink);
  color: var(--lw-paper);
  padding: 120px 0 48px;
  position: relative;
}
.footer-wrap {
  width: min(100% - 48px, var(--lw-container));
  margin: 0 auto;
}
.footer-wordmark {
  font-family: var(--lw-font-serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(80px, 16vw, 220px);
  line-height: 0.9;
  letter-spacing: -0.04em;
  margin: 0 0 64px;
}
.footer-wordmark .dot { color: var(--lw-terra); }
.footer-cols {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 48px;
  padding-top: 48px;
  border-top: 1px solid rgba(255,255,255,0.12);
}
.footer-cols h4 {
  font-family: var(--lw-font-sans);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  margin: 0 0 16px;
}
.footer-cols a {
  display: block;
  color: var(--lw-paper);
  text-decoration: none;
  padding: 6px 0;
  font-size: 14px;
}
.footer-cols a:hover { color: var(--lw-terra); }
.footer-sig {
  margin-top: 64px;
  font-family: var(--lw-font-serif);
  font-style: italic;
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  display: flex;
  justify-content: space-between;
}

/* ---------- Tweaks panel ---------- */
#tweaks-panel {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 500;
  background: var(--lw-bg-elev);
  border: 1px solid var(--lw-border-strong);
  box-shadow: var(--lw-shadow-3);
  border-radius: 8px;
  padding: 20px;
  width: 280px;
  font-family: var(--lw-font-sans);
  font-size: 13px;
  color: var(--lw-ink-2);
  display: none;
}
#tweaks-panel.visible { display: block; }
#tweaks-panel h3 {
  font-family: var(--lw-font-serif);
  font-style: italic;
  font-weight: 300;
  font-size: 18px;
  margin: 0 0 12px;
  color: var(--lw-ink);
}
#tweaks-panel label {
  display: block;
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lw-ink-3);
}
#tweaks-panel input[type="range"] { width: 100%; }
#tweaks-panel .swatch-row {
  display: flex; gap: 6px; margin-top: 6px;
}
#tweaks-panel .swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--lw-border-strong);
  cursor: pointer;
}
#tweaks-panel .swatch.active { outline: 2px solid var(--lw-ink); outline-offset: 2px; }
#tweaks-panel .toggle {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px;
}
#tweaks-panel button.toggle-btn {
  background: transparent;
  border: 1px solid var(--lw-border-strong);
  padding: 4px 10px;
  font-family: var(--lw-font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border-radius: 2px;
  cursor: pointer;
  color: var(--lw-ink-2);
}
#tweaks-panel button.toggle-btn.on {
  background: var(--lw-terra);
  border-color: var(--lw-terra);
  color: var(--lw-paper);
}

/* Grain overlay */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0 0.07 0 0 0 0.5 0'/></filter><rect width='200' height='200' filter='url(%23n)' opacity='0.6'/></svg>");
  mix-blend-mode: multiply;
  opacity: var(--grain-strength, 0.08);
  z-index: 300;
}

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