/* ==========================================================================
   TREE.css — Immersive Digital Transformation Section
   Scroll-Driven Sticky System | ProntoCore Optimized
   ========================================================================== */

:root {
  --tree-bg:         #020810;
  --tree-blue:       #4f8cff;
  --tree-teal:       #38f0c0;
  --tree-purple:     #a855f7;
  --tree-gold:       #ffd700;
  --tree-gold-warm:  #ff9500;
  --tree-text:       #e2e8f8;
  --tree-muted:      #4a5a7a;
  --tree-surface:    rgba(10, 22, 50, 0.75);
  --tree-border:     rgba(79, 140, 255, 0.18);
  --tree-progress-h: 360px;
}

/* ── TRACK CONTAINER ──
   Defines total scroll runway duration (600vh = 6 steps)
   ───────────────────────────────────────────────────────────────────────── */
.tree-track {
  position: relative;
  height: 600vh;
  background: var(--tree-bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(79, 140, 255, 0.06) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 20% 100%, rgba(168, 85, 247, 0.05) 0%, transparent 60%);
  box-sizing: border-box;
}

/* ── STICKY VIEWPORT CONTAINER ──
   Stays perfectly locked in viewport while parent tracks scroll depth
   ───────────────────────────────────────────────────────────────────────── */
.tree-stage {
  position: sticky;
  top: 0;
  left: 0;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* ── CANVAS BACKGROUND PARTICLES ── */
.tree-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}

/* ── BACKGROUND AMBIENT ORB ── */
.tree-orb {
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    circle,
    rgba(79, 140, 255, 0.04) 0%,
    rgba(168, 85, 247, 0.03) 40%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
  transition: background 0.4s ease, transform 0.6s ease-out;
  will-change: background, transform;
}

/* ── MAIN INTERACTIVE GRID ── */
.tree-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  width: 100%;
  max-width: 1280px;
  height: 100%;
  padding: 0 2rem;
  box-sizing: border-box;
  align-items: center;
}

/* Divider line between viewports */
.tree-grid::after {
  content: '';
  position: absolute;
  top: 10%;
  bottom: 10%;
  left: 50%;
  width: 1px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(79, 140, 255, 0.15) 20%,
    rgba(79, 140, 255, 0.25) 50%,
    rgba(79, 140, 255, 0.15) 80%,
    transparent 100%
  );
  pointer-events: none;
}

/* ── LEFT VERTICAL AXIS: VISUAL SVG GRAPHICS ── */
.tree-visual-col {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.tree-svg {
  width: 100%;
  max-width: 440px;
  height: auto;
  max-height: 80vh;
  will-change: transform;
  filter: drop-shadow(0 0 40px rgba(79, 140, 255, 0.08));
}

/* ── PERFORMANCE PROGRESS TRACKER ── */
.tree-progress-track {
  position: absolute;
  left: 0;
  top: 10%;
  height: 80%;
  width: 3px;
  background: rgba(79, 140, 255, 0.1);
  border-radius: 2px;
  overflow: visible;
}

.tree-progress-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(
    to top,
    var(--tree-purple) 0%,
    var(--tree-blue) 50%,
    var(--tree-teal) 100%
  );
  border-radius: 2px;
  will-change: height;
}

.tree-progress-glow {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tree-blue);
  box-shadow: 0 0 12px 4px var(--tree-blue);
  will-change: bottom, background, box-shadow;
}

/* ── METRIC COUNTER ── */
.tree-counter {
  position: absolute;
  bottom: 8%;
  left: 0;
  font-family: 'Syne', 'Inter', sans-serif;
  font-size: clamp(0.75rem, 1.2vw, 0.9rem);
  font-weight: 700;
  color: var(--tree-blue);
  letter-spacing: 0.05em;
  display: flex;
  align-items: baseline;
  gap: 1px;
  will-change: opacity, color;
}

#treeCounterNum {
  font-size: clamp(1.1rem, 1.8vw, 1.4rem);
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
}

.tree-counter-pct {
  font-size: 0.8em;
  opacity: 0.7;
}

/* ── SVG ENGINE INITIALIZERS ── */
.root-path { stroke-dasharray: 200; stroke-dashoffset: 200; will-change: stroke-dashoffset; }
#trunk-path, #trunk-core { stroke-dasharray: 300; stroke-dashoffset: 300; will-change: stroke-dashoffset; }
.branch-path { stroke-dasharray: 160; stroke-dashoffset: 160; will-change: stroke-dashoffset; }
.pcb-path { stroke-dasharray: 120; stroke-dashoffset: 120; will-change: stroke-dashoffset; }

.leaf-hex {
  transform-origin: center;
  transform-box: fill-box;
  transform: scale(0);
  opacity: 0;
  will-change: transform, opacity;
}

.root-node, .pcb-node, #node-L1, #node-R1 {
  transform-origin: center;
  transform-box: fill-box;
  transform: scale(0);
  will-change: transform;
}

.fruit-icon {
  transform-origin: center;
  transform-box: fill-box;
  transform: scale(0);
  opacity: 0;
  will-change: transform, opacity;
}

.fruit-line { stroke-dasharray: 160; stroke-dashoffset: 160; will-change: stroke-dashoffset; }
.data-line { will-change: opacity; }

/* ── RIGHT COLUMN: DYNAMIC TEXT VIEWPORTS ── */
.tree-content-col {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem 1.5rem 2rem 3rem;
  box-sizing: border-box;
}

.tree-step {
  position: absolute;
  top: 50%;
  left: 3rem;
  right: 1.5rem;
  transform: translateY(-50%) translateY(30px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: transform 0.6s cubic-bezier(0.215, 0.61, 0.355, 1), 
              opacity 0.5s linear, 
              visibility 0.5s linear;
  will-change: transform, opacity;
}

.tree-step.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateY(0);
  pointer-events: auto;
}

/* Content Aesthetics */
.tree-step-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tree-step-num {
  font-family: 'Inter', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--tree-muted);
  letter-spacing: 0.1em;
}

.tree-step-tag {
  font-family: 'Syne', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--tree-blue);
  background: rgba(79, 140, 255, 0.1);
  border: 1px solid rgba(79, 140, 255, 0.25);
  border-radius: 4px;
  padding: 0.2em 0.6em;
  text-transform: uppercase;
}

.tree-step-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
  font-weight: 800;
  line-height: 1.15;
  color: var(--tree-text);
  margin: 0 0 1.1rem;
  letter-spacing: -0.02em;
}

.tree-step-title--gold {
  background: linear-gradient(135deg, var(--tree-gold) 0%, var(--tree-gold-warm) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tree-step-body {
  font-family: 'Inter', sans-serif;
  font-size: clamp(0.9rem, 1.2vw, 1.05rem);
  line-height: 1.75;
  color: rgba(226, 232, 248, 0.7);
  margin: 0 0 1.5rem;
  max-width: 480px;
}

.tree-step-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-chip {
  font-family: 'Syne', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--tree-teal);
  background: rgba(56, 240, 192, 0.06);
  border: 1px solid rgba(56, 240, 192, 0.2);
  border-radius: 20px;
  padding: 0.3em 0.8em;
}

.tag-chip--gold {
  color: var(--tree-gold);
  background: rgba(255, 215, 0, 0.06);
  border-color: rgba(255, 215, 0, 0.25);
}

/* ── CALL TO ACTION HOVER MATRIX ── */
.tree-cta-wrap {
  position: absolute;
  bottom: 1%;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s linear;
  will-change: transform, opacity;
}

.tree-cta-wrap.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.tree-cta-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-family: 'Syne', sans-serif;
  font-size: clamp(0.85rem, 1.1vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #000;
  background: linear-gradient(135deg, var(--tree-gold) 0%, var(--tree-gold-warm) 100%);
  border: none;
  border-radius: 50px;
  padding: 0.9em 2em;
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.3), 0 4px 20px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.3s ease, transform 0.2s ease;
}

.tree-cta-btn:hover {
  box-shadow: 0 0 50px rgba(255, 215, 0, 0.55), 0 8px 30px rgba(0, 0, 0, 0.6);
  transform: translateY(-2px);
}

.tree-cta-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  transform: translateX(-100%);
  animation: ctaShine 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes ctaShine {
  0%   { transform: translateX(-100%); }
  60%  { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

/* ── PERSISTENT SYSTEM ANIMATIONS (GPU ACCELERATED) ── */
@keyframes nodePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.root-node.pulsing { animation: nodePulse 2s ease-in-out infinite; }
.pcb-node.pulsing { animation: nodePulse 1.5s ease-in-out infinite; }

@keyframes dataFlow {
  0%   { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -20; }
}
.data-line.flowing { opacity: 0.6; animation: dataFlow 0.8s linear infinite; }

@keyframes fruitPulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255,215,0,0.4)); }
  50%       { filter: drop-shadow(0 0 14px rgba(255,215,0,0.8)); }
}
#fruit-dash.pulsing { animation: fruitPulse 2s ease-in-out infinite; }

/* ── RESPONSIVE ADAPTATION INTERFACE ── */
@media (max-width: 768px) {
  .tree-track { height: 750vh; }
  .tree-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    padding: 0 1rem;
    align-items: start;
    padding-top: 5vh;
    gap: 0;
  }
  .tree-visual-col { height: 40vh; justify-content: center; }
  .tree-svg { max-width: 260px; max-height: 38vh; }
  .tree-progress-track, .tree-grid::after { display: none !important; }
  .tree-counter { left: 50%; transform: translateX(-50%); bottom: 0; }
  .tree-content-col { height: 45vh; padding: 0 0.5rem; align-items: flex-start; }
  .tree-step { left: 0.5rem; right: 0.5rem; top: 10%; transform: translateY(20px); }
  .tree-step.is-active { transform: translateY(0); }
  .tree-step-title { font-size: clamp(1.3rem, 5vw, 1.8rem); margin-bottom: 0.5rem; }
  .tree-step-body { font-size: 0.85rem; line-height: 1.6; margin-bottom: 1rem; }
  .tree-cta-wrap { bottom: 2%; width: 90%; text-align: center; }
  .tree-cta-btn { width: 100%; justify-content: center; font-size: 0.85rem; padding: 0.8em 1.5em; }
}

@media (max-width: 480px) {
  .tree-svg { max-width: 220px; }
  .tree-step-tags { display: none; }
}



/* ==========================================================================
   WSPANIAŁY INTERAKTYWNY PIEŃ - PODWÓJNA HELISA CYBER-ENERGY
   ========================================================================== */

#tree-trunk-gold {
  opacity: 0; /* Ukryty przed aktywacją scrolla */
  transform-origin: 200px 140px; /* Punkt startowy u góry pnia */
  transform: scaleY(0); /* Efekt rozwijania w dół */
  transition: opacity 0.7s cubic-bezier(0.25, 1, 0.5, 1), 
              transform 1.0s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Stan aktywny wywoływany przez JS na odpowiednim etapie scrolla (p >= 0.80) */
#tree-trunk-gold.is-active {
  opacity: 1;
  transform: scaleY(1);
}

/* Globalne ustawienia dla linii wewnątrz helisy */
.trunk-strand {
  fill: none;
  stroke-linecap: round;
  transition: stroke-width 0.4s ease, stroke 0.4s ease;
}

/* ── ZŁOTA WSTĘGA (GOLD STRAND) ── */
.strand-gold-core {
  stroke: var(--tree-gold, #ffd700);
  stroke-width: 3.5px;
}
.strand-gold-glow {
  stroke: var(--tree-gold, #ffd700);
  stroke-width: 9px;
  opacity: 0.35;
  filter: blur(4px) url(#glowGold);
}

/* ── FIOLETOWA WSTĘGA (PURPLE STRAND - ZGODNA Z KORZENIAMI) ── */
.strand-purple-core {
  stroke: var(--tree-purple, #a855f7);
  stroke-width: 3.5px;
}
.strand-purple-glow {
  stroke: var(--tree-purple, #a855f7);
  stroke-width: 9px;
  opacity: 0.35;
  filter: blur(4px);
}

/* ── SZYBKIE IMPULSY DANYCH (FIBER-OPTIC PULSES) ── */
.strand-pulse-fast-1,
.strand-pulse-fast-2 {
  stroke: #ffffff;
  stroke-width: 1.8px;
  stroke-dasharray: 25 140; /* Długość impulsu i przerwy */
  opacity: 0;
}

/* Uruchomienie nieskończonych animacji przepływu po aktywacji sekcji */
#tree-trunk-gold.is-active .strand-pulse-fast-1 {
  opacity: 0.95;
  animation: helixFlowRotation 2s linear infinite;
}

#tree-trunk-gold.is-active .strand-pulse-fast-2 {
  opacity: 0.95;
  animation: helixFlowRotation 2s linear infinite reverse; /* Ruch w przeciwnym kierunku tworzy złudzenie obrotu 3D */
}

#tree-trunk-gold.is-active .strand-gold-glow,
#tree-trunk-gold.is-active .strand-purple-glow {
  animation: organicHelixPulse 2.5s ease-in-out infinite alternate;
}

/* Efekt najechania myszą na owoce - pogrubienie rdzeni energetycznych pnia */
#fruits:hover #tree-trunk-gold.is-active .strand-gold-core,
#fruits:hover #tree-trunk-gold.is-active .strand-purple-core {
  stroke-width: 5px;
}
#fruits:hover #tree-trunk-gold.is-active .strand-gold-glow {
  stroke: #fffb00;
  stroke-width: 13px;
}
#fruits:hover #tree-trunk-gold.is-active .strand-purple-glow {
  stroke: #c077ff;
  stroke-width: 13px;
}

/* ── ANIMACJE KLUCZOWE ── */

/* Przepływ fotonów wzdłuż helisy tworzący iluzję trójwymiarowego wirowania */
@keyframes helixFlowRotation {
  0% {
    stroke-dashoffset: 0;
  }
  100% {
    stroke-dashoffset: -330; /* Odpowiada całkowitej długości zakrzywionej ścieżki pnia */
  }
}

/* Organiczne, głębokie pulsowanie neonowej poświaty pnia */
@keyframes organicHelixPulse {
  0% {
    opacity: 0.25;
    filter: blur(3px) drop-shadow(0 0 2px rgba(168, 85, 247, 0.2));
  }
  50% {
    opacity: 0.55;
    filter: blur(5px) drop-shadow(0 0 8px rgba(255, 215, 0, 0.4));
  }
  100% {
    opacity: 0.35;
    filter: blur(4px) drop-shadow(0 0 4px rgba(168, 85, 247, 0.3));
  }
}

/* ── MOBILNA OPTYMALIZACJA (RESPONSIVENESS) ── */
@media (max-width: 768px) {
  .strand-gold-core, 
  .strand-purple-core {
    stroke-width: 2.2px;
  }
  .strand-gold-glow, 
  .strand-purple-glow {
    stroke-width: 6px;
    filter: blur(2px);
  }
  .strand-pulse-fast-1,
  .strand-pulse-fast-2 {
    stroke-width: 1.2px;
  }
}



/* Sekcja drzewa – widoczna tylko na desktopie (≥1024px) */
@media (max-width: 1023px) {
  .tree-track,
  #tree-section {
    display: none !important;
  }
}
/* Poprawka dla mechanizmu sticky na stronie głównej */
html, body {
  overflow-x: clip !important;
  overflow-y: visible !important; /* Wymuszenie domyślnego przewijania w pionie */
}