/* ═══════════════════════════════════════════
   LOOM & SIGNAL — Living Systems Studio
   ═══════════════════════════════════════════ */

/* ── CSS Custom Properties ── */
:root {
  --bg: #0D0D0B;
  --text: #E8E2D6;
  --copper: #C4956A;
  --sage: #5B7B6A;
  --walnut: #8B7355;
  --text-dim: rgba(232, 226, 214, 0.35);
  --text-muted: rgba(232, 226, 214, 0.12);
  --copper-glow: rgba(196, 149, 106, 0.08);
  --glass: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.06);
  --ease-grow: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

::selection {
  background: var(--sage);
  color: var(--text);
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--copper);
  border-radius: 3px;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  scrollbar-color: var(--copper) transparent;
  scrollbar-width: thin;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', 'Satoshi', sans-serif;
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
  cursor: none;
}

a { color: var(--copper); text-decoration: none; cursor: none; }
a:hover { color: var(--text); }
button { cursor: none; }

/* ── Custom Cursor ── */
.cursor-dot {
  position: fixed;
  top: 0; left: 0;
  width: 12px; height: 12px;
  background: var(--copper);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10000;
  transform: translate(-50%, -50%);
  transition: width 0.3s var(--ease-grow), height 0.3s var(--ease-grow), background 0.3s;
  mix-blend-mode: difference;
}

.cursor-ring {
  position: fixed;
  top: 0; left: 0;
  width: 40px; height: 40px;
  border: 1.5px solid rgba(196, 149, 106, 0.25);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: width 0.4s var(--ease-grow), height 0.4s var(--ease-grow),
              border-color 0.3s, opacity 0.3s;
}

body:has(*:hover) .cursor-ring { /* fallback handled in JS */ }

.cursor-hover .cursor-dot {
  width: 8px; height: 8px;
  background: var(--sage);
}
.cursor-hover .cursor-ring {
  width: 70px; height: 70px;
  border-color: rgba(91, 123, 106, 0.2);
}

/* ── Typography ── */
h1, h2, h3, .headline {
  font-family: 'Playfair Display', 'Georgia', serif;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.mono {
  font-family: 'JetBrains Mono', 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Reveal Animations ── */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.9s var(--ease-grow), transform 0.9s var(--ease-grow);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-left {
  opacity: 0;
  transform: translateX(-60px);
  transition: opacity 0.9s var(--ease-grow), transform 0.9s var(--ease-grow);
}
.reveal-left.visible {
  opacity: 1;
  transform: translateX(0);
}
.reveal-right {
  opacity: 0;
  transform: translateX(60px);
  transition: opacity 0.9s var(--ease-grow), transform 0.9s var(--ease-grow);
}
.reveal-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* ── Background Contours ── */
.bg-contours {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-contours svg {
  position: absolute;
  top: -20%; left: -10%;
  width: 120%; height: 140%;
  opacity: 0.035;
  animation: contour-drift 80s linear infinite;
}

@keyframes contour-drift {
  0% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(30px, -20px) rotate(1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* ── Section Base ── */
section {
  position: relative;
  z-index: 1;
}

/* ═══════════════════════════════════
   HERO
   ═══════════════════════════════════ */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 8vw;
  position: relative;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 4vw;
  align-items: center;
  max-width: 1400px;
}

.hero-logo-wrap {
  position: relative;
}

.hero-logo svg {
  width: 100%;
  max-width: 320px;
}

.hero-logo .logo-path {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: draw-logo 3.5s var(--ease-grow) 0.5s forwards;
}

@keyframes draw-logo {
  to { stroke-dashoffset: 0; }
}

.hero-tagline {
  font-size: clamp(2.8rem, 6vw, 7rem);
  max-width: 700px;
  opacity: 0;
  animation: fade-up 1.2s var(--ease-grow) 2s forwards;
}

.hero-tagline em {
  font-style: italic;
  color: var(--copper);
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-scroll-hint {
  position: absolute;
  bottom: 6vh;
  left: 8vw;
  opacity: 0;
  animation: fade-up 0.8s var(--ease-grow) 3.5s forwards;
}

.hero-scroll-hint span {
  color: var(--text-dim);
}

.hero-mycelium {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: -1;
}

.hero-mycelium .branch {
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  animation: draw-branch 4s var(--ease-grow) forwards;
}

.hero-mycelium .branch:nth-child(2) { animation-delay: 1.5s; }
.hero-mycelium .branch:nth-child(3) { animation-delay: 2.2s; }
.hero-mycelium .branch:nth-child(4) { animation-delay: 2.8s; }
.hero-mycelium .branch:nth-child(5) { animation-delay: 3.2s; }

@keyframes draw-branch {
  to { stroke-dashoffset: 0; }
}

.node-pulse {
  animation: pulse-node 3s ease-in-out infinite;
  transform-origin: center;
}
.node-pulse:nth-child(2) { animation-delay: 0.5s; }
.node-pulse:nth-child(3) { animation-delay: 1.2s; }
.node-pulse:nth-child(4) { animation-delay: 1.8s; }

@keyframes pulse-node {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; }
}

/* ═══════════════════════════════════
   PHILOSOPHY
   ═══════════════════════════════════ */
.philosophy {
  padding: 16vh 8vw 20vh;
  max-width: 1400px;
  margin: 0 auto;
}

.philosophy-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 6vw;
  align-items: start;
}

.philosophy-text {
  max-width: 480px;
  padding-top: 4vh;
}

.philosophy-text p {
  margin-bottom: 1.6em;
  color: rgba(232, 226, 214, 0.75);
  font-size: 1.05rem;
}

.philosophy-visual {
  position: relative;
  min-height: 500px;
}

.philosophy-visual svg {
  width: 100%;
  height: auto;
}

.pull-quote {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 3.5vw, 3.5rem);
  font-style: italic;
  color: var(--copper);
  margin: 3rem 0 2rem -4vw;
  line-height: 1.2;
  max-width: 110%;
}

/* ── Section Divider (Root System) ── */
.root-divider {
  width: 100%;
  height: 120px;
  position: relative;
  overflow: visible;
}

.root-divider svg {
  width: 100%;
  height: 100%;
}

.root-divider .root-line {
  stroke-dasharray: 800;
  stroke-dashoffset: 800;
  transition: stroke-dashoffset 1.5s var(--ease-grow);
}

.root-divider.visible .root-line {
  stroke-dashoffset: 0;
}

/* ═══════════════════════════════════
   INFINITE TICKER
   ═══════════════════════════════════ */
.ticker-section {
  padding: 12vh 0;
  overflow: hidden;
  position: relative;
}

.ticker-section h2 {
  font-size: clamp(2.5rem, 5vw, 5.5rem);
  padding: 0 8vw;
  margin-bottom: 6vh;
}

.ticker-wrap {
  overflow: hidden;
  position: relative;
  padding: 3rem 0;
}

.ticker-wrap::before,
.ticker-wrap::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 120px;
  z-index: 2;
  pointer-events: none;
}
.ticker-wrap::before {
  left: 0;
  background: linear-gradient(90deg, var(--bg), transparent);
}
.ticker-wrap::after {
  right: 0;
  background: linear-gradient(-90deg, var(--bg), transparent);
}

.ticker-track {
  display: flex;
  gap: 3rem;
  animation: ticker-scroll 40s linear infinite;
  width: max-content;
}

.ticker-track:hover {
  animation-play-state: paused;
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0.6em 1.4em;
  border: 1px solid var(--text-muted);
  border-radius: 100px;
  transition: color 0.5s, border-color 0.5s, background 0.5s;
  flex-shrink: 0;
}

.ticker-item:hover {
  color: var(--text);
  border-color: var(--copper);
  background: var(--copper-glow);
}

/* Second row, opposite direction */
.ticker-track-reverse {
  animation-direction: reverse;
  margin-top: 1.5rem;
}

/* ═══════════════════════════════════
   CASE STUDIES
   ═══════════════════════════════════ */
.cases {
  padding: 10vh 8vw 16vh;
  max-width: 1400px;
  margin: 0 auto;
}

.cases h2 {
  font-size: clamp(2.5rem, 5vw, 5.5rem);
  margin-bottom: 10vh;
}

.case-card {
  display: grid;
  grid-template-columns: 1fr 0.8fr;
  gap: 4vw;
  align-items: center;
  padding: 3.5rem 4rem;
  margin-bottom: 6vh;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.6s var(--ease-grow), transform 0.6s var(--ease-grow);
  position: relative;
  overflow: hidden;
}

.case-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at var(--mx, 50%) var(--my, 50%),
    rgba(196, 149, 106, 0.04) 0%, transparent 60%);
  pointer-events: none;
  transition: opacity 0.4s;
  opacity: 0;
}

.case-card:hover::before { opacity: 1; }

.case-card:hover {
  border-color: rgba(196, 149, 106, 0.15);
  transform: translateY(-4px);
}

.case-card:nth-child(even) {
  grid-template-columns: 0.8fr 1fr;
  margin-left: 8vw;
  margin-right: -2vw;
}
.case-card:nth-child(even) .case-visual { order: -1; }

.case-card:nth-child(odd) {
  margin-right: 6vw;
  margin-left: -2vw;
}

.case-tag {
  display: inline-block;
  margin-bottom: 1rem;
}

.case-name {
  font-size: clamp(1.8rem, 3vw, 3rem);
  margin-bottom: 1rem;
}

.case-desc {
  color: rgba(232, 226, 214, 0.6);
  font-size: 1.05rem;
  max-width: 440px;
  line-height: 1.75;
}

.case-visual {
  display: flex;
  justify-content: center;
  align-items: center;
}

.case-visual svg {
  width: 100%;
  max-width: 280px;
  height: auto;
}

/* ═══════════════════════════════════
   PROCESS
   ═══════════════════════════════════ */
.process {
  padding: 12vh 8vw 16vh;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

.process h2 {
  font-size: clamp(2.5rem, 5vw, 5.5rem);
  margin-bottom: 10vh;
}

.process-timeline {
  position: relative;
  padding-left: 80px;
}

.process-stem {
  position: absolute;
  left: 30px;
  top: 0;
  bottom: 0;
  width: 2px;
}

.process-stem svg {
  width: 100%;
  height: 100%;
}

.process-stem .stem-path {
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  transition: stroke-dashoffset 2s var(--ease-grow);
}

.process-stem.visible .stem-path {
  stroke-dashoffset: 0;
}

.process-step {
  position: relative;
  padding: 3rem 0 5rem;
}

.process-node {
  position: absolute;
  left: -58px;
  top: 3.2rem;
  width: 20px;
  height: 20px;
  background: var(--bg);
  border: 2px solid var(--copper);
  border-radius: 50%;
  z-index: 2;
  transition: background 0.4s, transform 0.4s var(--ease-spring);
}

.process-step:hover .process-node {
  background: var(--copper);
  transform: scale(1.3);
}

.process-step h3 {
  font-size: 1.8rem;
  margin-bottom: 0.8rem;
  transition: color 0.4s;
}

.process-step:hover h3 {
  color: var(--copper);
}

.process-step p {
  color: rgba(232, 226, 214, 0.55);
  max-width: 500px;
  font-size: 1.02rem;
  line-height: 1.8;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.6s var(--ease-grow), opacity 0.5s, margin 0.4s;
}

.process-step:hover p,
.process-step.active p {
  max-height: 200px;
  opacity: 1;
  margin-top: 0.5rem;
}

/* ═══════════════════════════════════
   CONTACT / SIGNAL
   ═══════════════════════════════════ */
.signal {
  padding: 14vh 8vw 10vh;
  max-width: 1400px;
  margin: 0 auto;
}

.signal-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8vw;
  align-items: center;
}

.signal h2 {
  font-size: clamp(2.5rem, 5vw, 5rem);
  margin-bottom: 3rem;
}

.signal-form {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.signal-field {
  position: relative;
}

.signal-field input,
.signal-field textarea {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--text-muted);
  padding: 1rem 0;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.4s;
  resize: none;
  cursor: none;
}

.signal-field input:focus,
.signal-field textarea:focus {
  border-color: var(--copper);
}

.signal-field label {
  position: absolute;
  top: 1rem;
  left: 0;
  color: var(--text-dim);
  font-size: 0.95rem;
  pointer-events: none;
  transition: all 0.3s var(--ease-grow);
}

.signal-field input:focus ~ label,
.signal-field input:not(:placeholder-shown) ~ label,
.signal-field textarea:focus ~ label,
.signal-field textarea:not(:placeholder-shown) ~ label {
  top: -0.7rem;
  font-size: 0.75rem;
  color: var(--copper);
}

.signal-submit {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text);
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  padding: 0.5rem 0;
  position: relative;
  letter-spacing: 0.02em;
}

.signal-submit::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--copper);
  transition: width 0.5s var(--ease-grow);
}

.signal-submit:hover::after {
  width: 100%;
}

.signal-status {
  color: var(--text-dim);
  margin-top: -0.5rem;
}

.signal-visual {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.signal-orb {
  width: 200px;
  height: 200px;
  position: relative;
}

.signal-orb .orb-ring {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid;
  animation: orb-breathe 4s ease-in-out infinite;
}

.signal-orb .orb-ring:nth-child(1) {
  width: 60px; height: 60px;
  border-color: var(--copper);
  animation-delay: 0s;
}
.signal-orb .orb-ring:nth-child(2) {
  width: 110px; height: 110px;
  border-color: rgba(196, 149, 106, 0.4);
  animation-delay: 0.5s;
}
.signal-orb .orb-ring:nth-child(3) {
  width: 170px; height: 170px;
  border-color: rgba(196, 149, 106, 0.15);
  animation-delay: 1s;
}
.signal-orb .orb-ring:nth-child(4) {
  width: 240px; height: 240px;
  border-color: rgba(196, 149, 106, 0.06);
  animation-delay: 1.5s;
}

.signal-orb .orb-core {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 16px; height: 16px;
  background: var(--copper);
  border-radius: 50%;
  box-shadow: 0 0 30px rgba(196, 149, 106, 0.3);
  animation: orb-core-pulse 3s ease-in-out infinite;
}

@keyframes orb-breathe {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.08); opacity: 0.7; }
}

@keyframes orb-core-pulse {
  0%, 100% { box-shadow: 0 0 30px rgba(196, 149, 106, 0.3); }
  50% { box-shadow: 0 0 50px rgba(196, 149, 106, 0.5); }
}

.signal-accepting {
  margin-top: 3rem;
  color: var(--text-dim);
}

/* ═══════════════════════════════════
   FOOTER
   ═══════════════════════════════════ */
.site-footer {
  padding: 6vh 8vw 4vh;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.footer-line {
  position: absolute;
  top: 0;
  left: 8vw;
  right: 8vw;
  height: 1px;
}

.footer-line svg {
  width: 100%;
  height: 40px;
  overflow: visible;
}

.footer-logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  color: var(--text-dim);
}

.footer-copy {
  color: rgba(232, 226, 214, 0.2);
  font-size: 0.8rem;
}

/* ═══════════════════════════════════
   PARALLAX LAYERS
   ═══════════════════════════════════ */
.parallax-layer {
  will-change: transform;
  transition: transform 0.1s linear;
}

/* ═══════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════ */
@media (max-width: 900px) {
  .hero-inner {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .hero-logo svg { max-width: 200px; }
  .hero-tagline { font-size: clamp(2rem, 8vw, 3.5rem); }

  .philosophy-grid {
    grid-template-columns: 1fr;
    gap: 4vh;
  }
  .philosophy-visual { min-height: 300px; }

  .case-card,
  .case-card:nth-child(even),
  .case-card:nth-child(odd) {
    grid-template-columns: 1fr;
    margin-left: 0;
    margin-right: 0;
    padding: 2rem;
  }
  .case-card:nth-child(even) .case-visual { order: 0; }
  .case-visual svg { max-width: 200px; }

  .signal-grid {
    grid-template-columns: 1fr;
    gap: 6vh;
  }
  .signal-visual { order: -1; }

  .pull-quote {
    margin-left: 0;
    font-size: clamp(1.4rem, 5vw, 2.2rem);
  }

  .cursor-dot, .cursor-ring { display: none; }
  body { cursor: auto; }
  a, button { cursor: pointer; }

  .process-timeline { padding-left: 50px; }
  .process-node { left: -38px; }
}

@media (max-width: 600px) {
  section { padding-left: 6vw !important; padding-right: 6vw !important; }
  .site-footer { flex-direction: column; gap: 1rem; text-align: center; }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .ticker-track { animation: none; }
  .reveal, .reveal-left, .reveal-right {
    opacity: 1;
    transform: none;
  }
}
