/* ==========================================
   🎨 DYNAMIC ENHANCEMENTS - Sempi Website
   Animazioni fluide e dinamiche
   ========================================== */

/* Fix hero h1 visibility - ensure all text is visible */
.hero h1 {
  background: none !important;
  -webkit-background-clip: unset !important;
  -webkit-text-fill-color: unset !important;
  background-clip: unset !important;
  color: #ffffff !important;
}

.hero h1 .underline-hand {
  color: #f16926 !important;
  font-weight: 900;
  position: relative;
  display: inline-block;
}

/* Logo optimization for all screen sizes */
.navbar-logo img {
  height: 50px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.hero h1 .underline-hand::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  right: 0;
  height: 12px;
  background: linear-gradient(90deg, transparent, rgba(241,105,38,0.4), transparent);
  transform: scaleX(0);
  animation: underlineDraw 1s ease-out 0.8s forwards;
}

@keyframes underlineDraw {
  to { transform: scaleX(1); }
}

/* ==========================================
   🎯 MENU FLUIDO E SMOOTH
   ========================================== */
.navbar {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-links a {
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-links a::before {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--color-primary);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(-50%);
}

.navbar-links a:hover::before {
  width: 100%;
}

.navbar-links a:hover {
  color: var(--color-primary);
  transform: translateY(-2px);
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* ==========================================
   🔄 CICLO CONTINUO - DYNAMIC VISUALIZATION
   Assess → Plan → Execute → Reassess
   ========================================== */
.cycle-container {
  position: relative;
  max-width: 900px;
  margin: 4rem auto;
  padding: 4rem 2rem;
}

.cycle-circle {
  position: relative;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Animated circular path */
.cycle-path {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px dashed rgba(241, 105, 38, 0.3);
  animation: rotatePath 20s linear infinite;
}

@keyframes rotatePath {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Continuous flow arrow */
.cycle-arrow {
  position: absolute;
  width: 40px;
  height: 40px;
  top: 50%;
  left: 50%;
  margin: -20px 0 0 -20px;
  animation: flowArrow 3s ease-in-out infinite;
}

@keyframes flowArrow {
  0%, 100% {
    transform: rotate(0deg) translateX(280px) rotate(0deg);
    opacity: 1;
  }
  25% {
    transform: rotate(90deg) translateX(280px) rotate(-90deg);
    opacity: 0.7;
  }
  50% {
    transform: rotate(180deg) translateX(280px) rotate(-180deg);
    opacity: 1;
  }
  75% {
    transform: rotate(270deg) translateX(280px) rotate(-270deg);
    opacity: 0.7;
  }
}

/* Cycle steps positioned around circle */
.cycle-step {
  position: absolute;
  width: 160px;
  padding: 1.5rem;
  background: linear-gradient(135deg, rgba(241,105,38,0.1) 0%, rgba(0,0,0,0.5) 100%);
  border: 2px solid rgba(241,105,38,0.4);
  border-radius: 16px;
  text-align: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.cycle-step:hover {
  transform: scale(1.1);
  border-color: #f16926;
  background: linear-gradient(135deg, rgba(241,105,38,0.2) 0%, rgba(0,0,0,0.6) 100%);
  box-shadow: 0 20px 60px rgba(241,105,38,0.4);
  z-index: 10;
}

.cycle-step-1 { top: 0; left: 50%; transform: translateX(-50%); }
.cycle-step-2 { right: 0; top: 50%; transform: translateY(-50%); }
.cycle-step-3 { bottom: 0; left: 50%; transform: translateX(-50%); }
.cycle-step-4 { left: 0; top: 50%; transform: translateY(-50%); }

.cycle-step-number {
  display: block;
  width: 40px;
  height: 40px;
  margin: 0 auto 0.75rem;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  color: white;
  animation: pulse 2s ease-in-out infinite;
}

.cycle-step:nth-child(1) .cycle-step-number { animation-delay: 0s; }
.cycle-step:nth-child(2) .cycle-step-number { animation-delay: 0.5s; }
.cycle-step:nth-child(3) .cycle-step-number { animation-delay: 1s; }
.cycle-step:nth-child(4) .cycle-step-number { animation-delay: 1.5s; }

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(241, 105, 38, 0.7);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(241, 105, 38, 0);
  }
}

.cycle-step h4 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: #f16926;
}

.cycle-step p {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.8);
  margin: 0;
}

/* Center icon */
.cycle-center {
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(241,105,38,0.2) 0%, transparent 70%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  animation: glow 3s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(241,105,38,0.5);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 40px rgba(241,105,38,0.8);
    transform: scale(1.05);
  }
}

/* ==========================================
   🛤️ PERCORSO - DYNAMIC JOURNEY PATH
   ========================================== */
.journey-path {
  position: relative;
  padding: 4rem 0;
  margin: 4rem 0;
}

/* Animated path line */
.journey-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg,
    transparent 0%,
    rgba(241,105,38,0.3) 10%,
    rgba(241,105,38,0.6) 50%,
    rgba(241,105,38,0.3) 90%,
    transparent 100%
  );
  transform: translateX(-50%);
}

.journey-line::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(180deg, #f16926 0%, transparent 100%);
  animation: flowDown 3s ease-in-out infinite;
}

@keyframes flowDown {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateY(100%);
    opacity: 0;
  }
}

.journey-step {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 3rem;
  align-items: center;
  margin: 4rem 0;
  opacity: 0;
  animation: fadeInJourney 0.8s ease-out forwards;
}

.journey-step:nth-child(1) { animation-delay: 0.2s; }
.journey-step:nth-child(2) { animation-delay: 0.4s; }
.journey-step:nth-child(3) { animation-delay: 0.6s; }
.journey-step:nth-child(4) { animation-delay: 0.8s; }

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

.journey-step:nth-child(even) .journey-content {
  order: 3;
}

.journey-step:nth-child(even) .journey-image {
  order: 1;
}

.journey-content {
  padding: 2rem;
  background: linear-gradient(135deg, rgba(241,105,38,0.1) 0%, rgba(0,0,0,0.3) 100%);
  border-radius: 20px;
  border: 2px solid rgba(241,105,38,0.2);
  transition: all 0.4s ease;
}

.journey-content:hover {
  transform: translateY(-5px);
  border-color: #f16926;
  box-shadow: 0 20px 60px rgba(241,105,38,0.3);
}

.journey-icon {
  width: 100px;
  height: 100px;
  margin: 0 auto;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 40px rgba(241,105,38,0.4);
  position: relative;
  transition: all 0.4s ease;
}

.journey-icon:hover {
  transform: scale(1.1) rotate(5deg);
}

.journey-icon::after {
  content: '';
  position: absolute;
  width: 120%;
  height: 120%;
  border-radius: 50%;
  border: 2px dashed rgba(241,105,38,0.5);
  animation: rotateIcon 10s linear infinite;
}

@keyframes rotateIcon {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.journey-number {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 40px;
  height: 40px;
  background: #f16926;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: white;
  font-size: 1.2rem;
  box-shadow: 0 4px 15px rgba(241,105,38,0.5);
}

.journey-image {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(241,105,38,0.2), rgba(255,255,255,0.05));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  position: relative;
  overflow: hidden;
}

.journey-image::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.2), transparent);
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 0.5; transform: rotate(0deg); }
  50% { opacity: 1; transform: rotate(180deg); }
}

/* ==========================================
   🌐 ECOSISTEMA - DYNAMIC NETWORK VISUALIZATION
   ========================================== */
.ecosystem-container {
  position: relative;
  padding: 4rem 2rem;
  margin: 4rem 0;
}

.ecosystem-hub {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem;
  text-align: center;
}

.ecosystem-center {
  width: 200px;
  height: 200px;
  margin: 0 auto 4rem;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 20px 60px rgba(241,105,38,0.5);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.ecosystem-center::before {
  content: '';
  position: absolute;
  width: 120%;
  height: 120%;
  border-radius: 50%;
  border: 3px solid rgba(241,105,38,0.3);
  animation: ripple 2s ease-out infinite;
}

@keyframes ripple {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.ecosystem-nodes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  position: relative;
}

.ecosystem-node {
  padding: 2rem;
  background: linear-gradient(135deg, rgba(241,105,38,0.1), rgba(0,0,0,0.4));
  border: 2px solid rgba(241,105,38,0.3);
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.ecosystem-node::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(241,105,38,0.3), transparent);
  transform: translate(-50%, -50%);
  transition: all 0.6s ease;
}

.ecosystem-node:hover::before {
  width: 400px;
  height: 400px;
}

.ecosystem-node:hover {
  transform: translateY(-10px) scale(1.05);
  border-color: #f16926;
  box-shadow: 0 30px 80px rgba(241,105,38,0.4);
  z-index: 10;
}

.ecosystem-node-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 1rem;
  background: rgba(241,105,38,0.2);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  transition: all 0.4s ease;
}

.ecosystem-node:hover .ecosystem-node-icon {
  transform: rotateY(360deg);
  background: var(--gradient-primary);
}

/* Connecting lines animation */
.ecosystem-line {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(241,105,38,0.5) 50%,
    transparent 100%
  );
  transform-origin: left center;
}

.ecosystem-line::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
    transparent 0%,
    #f16926 50%,
    transparent 100%
  );
  animation: flowLine 2s ease-in-out infinite;
}

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

/* ==========================================
   📱 RESPONSIVE OPTIMIZATIONS - MOBILE FIRST
   ========================================== */

/* ==========================================
   📱 SMALL MOBILE (max-width: 480px)
   ========================================== */
@media (max-width: 480px) {
  /* LOGO - Smaller on tiny screens */
  .navbar-logo img {
    height: 40px !important;
  }

  .navbar {
    padding: 0.875rem 1rem !important;
  }

  /* HERO - Ultra compact */
  .hero h1 {
    font-size: 1.75rem !important;
    line-height: 1.2;
  }

  .hero h1 .underline-hand {
    display: block;
    margin-top: 0.5rem;
  }

  /* CICLO CONTINUO - Vertical list */
  .cycle-container {
    padding: 2rem 1rem;
    margin: 2rem 0;
  }

  .cycle-container h3 {
    font-size: 1.5rem !important;
  }

  .cycle-container p {
    font-size: 0.95rem !important;
  }

  .cycle-circle {
    display: flex;
    flex-direction: column;
    aspect-ratio: auto;
    gap: 1rem;
  }

  .cycle-path,
  .cycle-arrow,
  .cycle-center {
    display: none;
  }

  .cycle-step {
    position: static !important;
    width: 100% !important;
    margin: 0.75rem 0 !important;
    transform: none !important;
    padding: 1.25rem !important;
  }

  .cycle-step-number {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  .cycle-step h4 {
    font-size: 1.1rem !important;
  }

  .cycle-step p {
    font-size: 0.85rem !important;
  }

  /* JOURNEY PATH - Compact mobile */
  .journey-path {
    padding: 2rem 0;
    margin: 2rem 0;
  }

  .journey-step {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
    margin: 2rem 0 !important;
  }

  .journey-icon,
  .journey-image {
    display: none;
  }

  .journey-line {
    left: 15px;
    width: 2px;
  }

  .journey-content {
    padding: 1.25rem !important;
    margin-left: 2rem;
  }

  .journey-content h3 {
    font-size: 1.3rem !important;
  }

  .journey-content p {
    font-size: 0.9rem !important;
  }

  .journey-step:nth-child(even) .journey-content,
  .journey-step:nth-child(even) .journey-image {
    order: initial;
  }

  /* ECOSISTEMA - Single column */
  .ecosystem-container {
    padding: 2rem 1rem;
    margin: 2rem 0;
  }

  .ecosystem-hub {
    padding: 1.5rem;
  }

  .ecosystem-center {
    width: 140px;
    height: 140px;
    margin: 0 auto 2rem;
  }

  .ecosystem-center strong {
    font-size: 1.1rem !important;
  }

  .ecosystem-center span {
    font-size: 0.8rem !important;
  }

  .ecosystem-nodes {
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
  }

  .ecosystem-node {
    padding: 1.5rem !important;
  }

  .ecosystem-node h3 {
    font-size: 1.3rem !important;
  }

  .ecosystem-node p {
    font-size: 0.9rem !important;
  }

  .ecosystem-node-icon {
    width: 60px !important;
    height: 60px !important;
    font-size: 2rem !important;
  }
}

/* ==========================================
   📱 MOBILE & TABLET (max-width: 768px)
   ========================================== */
@media (max-width: 768px) {
  /* GENERAL - Reduce animations for performance */
  .cycle-path {
    animation: none;
  }

  .journey-line::before {
    animation-duration: 4s;
  }

  /* Disable complex hover effects on touch devices */
  .cycle-step:hover,
  .journey-content:hover,
  .ecosystem-node:hover {
    transform: none !important;
    box-shadow: 0 10px 30px rgba(241,105,38,0.2) !important;
  }

  /* MENU - Ensure smooth transitions */
  .navbar-links a::before {
    display: none;
  }

  /* CICLO CONTINUO - Tablet layout */
  .cycle-container {
    padding: 3rem 1.5rem;
    margin: 3rem 0;
  }

  .cycle-circle {
    display: flex;
    flex-direction: column;
    aspect-ratio: auto;
    gap: 1.25rem;
  }

  .cycle-path,
  .cycle-arrow {
    display: none;
  }

  .cycle-center {
    position: relative;
    margin: 0 auto 2rem;
  }

  .cycle-step {
    position: static !important;
    width: 100% !important;
    margin: 1rem 0 !important;
    transform: none !important;
    max-width: 500px;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* JOURNEY PATH - Mobile optimized */
  .journey-path {
    padding: 3rem 0;
  }

  .journey-step {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin: 3rem 0;
  }

  .journey-step:nth-child(even) .journey-content,
  .journey-step:nth-child(even) .journey-image {
    order: initial;
  }

  .journey-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto;
  }

  .journey-icon span {
    font-size: 2.5rem;
  }

  .journey-number {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  .journey-image {
    width: 150px;
    height: 150px;
    margin: 0 auto;
    font-size: 3rem;
  }

  .journey-line {
    left: 20px;
  }

  .journey-content {
    margin-left: 0;
  }

  /* ECOSISTEMA - Mobile friendly */
  .ecosystem-container {
    padding: 3rem 1.5rem;
  }

  .ecosystem-hub {
    padding: 2rem;
  }

  .ecosystem-center {
    width: 160px;
    height: 160px;
  }

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

  .ecosystem-node::before {
    animation: none;
  }

  /* Touch targets - Ensure minimum 44x44px */
  .cycle-step,
  .ecosystem-node .btn {
    min-height: 44px;
  }

  /* Reduce motion for better performance */
  @media (prefers-reduced-motion: reduce) {
    .cycle-step-number,
    .journey-icon,
    .ecosystem-center {
      animation: none !important;
    }
  }
}

/* ==========================================
   💻 TABLET (481px - 768px)
   ========================================== */
@media (min-width: 481px) and (max-width: 768px) {
  /* CICLO CONTINUO - 2 columns */
  .cycle-circle {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
  }

  .cycle-center {
    grid-column: 1 / -1;
    margin: 1rem auto;
  }

  /* ECOSISTEMA - 2 columns for better use of space */
  .ecosystem-nodes {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================
   🖥️ DESKTOP OPTIMIZATION (min-width: 1025px)
   ========================================== */
@media (min-width: 1025px) {
  /* Ensure animations are smooth on desktop */
  .cycle-step:hover {
    transform: scale(1.1);
  }

  .journey-content:hover {
    transform: translateY(-5px);
  }

  .ecosystem-node:hover {
    transform: translateY(-10px) scale(1.05);
  }
}

/* ==========================================
   🌓 LANDSCAPE MOBILE OPTIMIZATION
   ========================================== */
@media (max-width: 768px) and (orientation: landscape) {
  .cycle-container,
  .journey-path,
  .ecosystem-container {
    padding-top: 2rem;
    padding-bottom: 2rem;
  }

  .cycle-center {
    width: 100px;
    height: 100px;
  }

  .hero h1 {
    font-size: 1.75rem !important;
  }
}

/* ==========================================
   🎯 TOUCH DEVICE OPTIMIZATIONS
   ========================================== */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices for better performance */
  .cycle-step:hover,
  .journey-content:hover,
  .journey-icon:hover,
  .ecosystem-node:hover,
  .ecosystem-node-icon:hover {
    transform: none !important;
  }

  /* Larger tap targets */
  .cycle-step,
  .journey-content,
  .ecosystem-node {
    padding: 1.5rem;
  }

  /* Disable resource-intensive animations */
  .cycle-path,
  .cycle-arrow,
  .journey-line::before,
  .journey-icon::after,
  .ecosystem-center::before,
  .ecosystem-line::after {
    animation: none;
  }
}

/* ==========================================
   ⚡ PERFORMANCE - Reduce complexity on older devices
   ========================================== */
@media (max-width: 768px) {
  /* Simplify gradients */
  .cycle-step,
  .journey-content,
  .ecosystem-node {
    background: rgba(241,105,38,0.05);
  }

  /* Remove backdrop filters on mobile for performance */
  .cycle-step,
  .ecosystem-node {
    backdrop-filter: none;
  }

  /* Reduce shadow complexity */
  .cycle-step:hover,
  .journey-content:hover,
  .ecosystem-node:hover {
    box-shadow: 0 10px 30px rgba(241,105,38,0.2);
  }
}
