/* ===================================
   CSS CUSTOM PROPERTIES (Variables)
   =================================== */
:root {
  /* Color Palette */
  --ts-acid: #A6C238;
  --ts-meadow: #79AC32;
  --ts-fern: #457B32;
  --ts-forest: #285128;
  --ts-night: #1D2D1A;
  --ts-dark: #2D2C24;
  --ts-pearl: #C5C9BF;
  --ts-indigo: #4A4A8F;
  
  /* Neutral Colors */
  --bg-primary: #F8F9FA;
  --text-primary: #2D2C24;
  --glass-bg: rgba(255, 255, 255, 0.95);
  --glass-border: rgba(45, 44, 36, 0.2);
  --glass-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.12);
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s cubic-bezier(0.19, 1, 0.22, 1);
  
  /* Z-index Scale */
  --z-under-stripes: 0;
  --z-stripes: 2;
  --z-content: 3;
  --z-glass: 5;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* ===================================
   BASE STYLES & RESETS
   =================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html.lenis {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

.lenis.lenis-scrolling iframe {
  pointer-events: none;
}

body {
  background: transparent;
  color: var(--text-primary);
  font-weight: 500;
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Content layering: stripes = background (z 2), content above stripes (z 3), nav on top (z 10) */
nav {
  position: relative;
  z-index: 10;
}

/* Tutto il contenuto (header, section, main) sopra le parallax-stripes così glass e card restano sopra le diagonali */
header,
section,
main {
  position: relative;
  z-index: var(--z-content);
}

/* Performance: skip layout/paint when section is off-screen (no visual change) */
.content-visibility-auto {
  content-visibility: auto;
  contain-intrinsic-size: auto 400px;
}

/* Hero e testate sotto le stripes: le diagonali passano sopra per effetto grafico */
header.under-stripes,
section.under-stripes {
  z-index: var(--z-under-stripes);
}

.text-balance {
  text-wrap: balance;
}

/* Preloader hero: infinite zoom animation (600ms) */
@keyframes preloader-zoom {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

#hero-fallback {
  animation: preloader-zoom 600ms ease-in-out infinite;
}

/* CTA Disciplines: horizontal scroll (slow, constant, infinite seamless, Montserrat light, big) */
.disciplines-scroll-mask {
  overflow: hidden;
}

.disciplines-scroll-track {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  width: max-content;
  animation: disciplines-scroll 50s linear infinite;
  will-change: transform;
}

.disciplines-scroll-gap {
  flex: 0 0 4rem;
  width: 4rem;
}

.disciplines-scroll-group {
  display: flex;
  align-items: center;
  gap: 4rem;
  flex: 0 0 auto;
  width: max-content;
  white-space: nowrap;
  font-family: "Montserrat", sans-serif;
  font-weight: 300;
  font-size: clamp(2.5rem, 8vw, 6rem);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(197, 201, 191, 0.6);
}

.disciplines-scroll-group span {
  white-space: nowrap;
}

@keyframes disciplines-scroll {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-50%, 0, 0); }
}

/* Focus styles for accessibility */
*:focus-visible {
  outline: 2px solid var(--ts-acid);
  outline-offset: 2px;
}

/* ===================================
   UI COMPONENTS
   =================================== */

/* Buttons */
.btn-luxury {
  position: relative;
  overflow: hidden;
  display: inline-block;
  transition: var(--transition-fast);
}

.btn-luxury::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--transition-slow);
}

.btn-luxury:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* Images & Media */
.img-reveal-container {
  overflow: hidden;
  position: relative;
}

.img-reveal {
  transform: scale(1.15);
  transition: transform 1.5s cubic-bezier(0.19, 1, 0.22, 1);
  will-change: transform;
}

.img-reveal.active {
  transform: scale(1);
}

/* Glass Effect: sopra le stripes, blur visibile su ciò che sta dietro (stripes/sfondo sezione) */
.glass {
  position: relative;
  z-index: var(--z-glass);
  isolation: isolate; /* stacking context per backdrop-filter affidabile */
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(8px) saturate(180%);
  -webkit-backdrop-filter: blur(8px) saturate(180%);
  border: 1px solid rgba(197, 201, 191, 0.5);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  transition: var(--transition-base);
}

.glass:hover {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(166, 194, 56, 0.55);
  box-shadow: 0 10px 26px rgba(166, 194, 56, 0.2);
  backdrop-filter: blur(12px) saturate(170%);
  -webkit-backdrop-filter: blur(12px) saturate(170%);
}

/* Glass blur forest green (CTA disciplines) */
.glass-forest {
  background: rgba(40, 81, 40, 0.4);
  backdrop-filter: blur(12px) saturate(300%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  border: 1px solid rgba(40, 81, 40, 0.5);
}

/* Glass blur night (ts-night #1D2D1A) */
.glass-night {
  background: rgba(29, 45, 26, 0.8);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(29, 45, 26, 0.5);
}

/* Outline pulse – evidenzia link con bordo pulsante (color: Fence / ts-fern) */
.outline-pulse-fence {
  outline: 2px solid var(--ts-fern);
  outline-offset: 4px;
  border-radius: 4px;
  animation: outline-pulse-fence 2s ease-in-out infinite;
}

@keyframes outline-pulse-fence {
  0%, 100% {
    outline-color: var(--ts-fern);
    box-shadow: 0 0 0 0 rgba(69, 123, 50, 0.4);
  }
  50% {
    outline-color: var(--ts-meadow);
    box-shadow: 0 0 12px 2px rgba(69, 123, 50, 0.35);
  }
}

/* Background ts-fern */
.bg-ts-fern {
  background-color: var(--ts-fern);
}

/* Accordion Components */
.accordion-button {
  transition: var(--transition-base);
  cursor: pointer;
}

.accordion-button:hover {
  background: rgba(166, 194, 56, 0.1);
}

.accordion-button[aria-expanded="true"] {
  background: rgba(166, 194, 56, 0.15);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.accordion-content.open {
  max-height: 2000px;
}

/* Color selector — Release palette: max 5 swatches per row */
[data-color-selector-release] {
  display: grid !important;
  grid-template-columns: repeat(5, 2rem) !important;
  gap: 0.5rem !important;
  flex-wrap: unset !important;
}

/* Color selector swatch active state */
.color-swatch.is-active {
  box-shadow: 0 0 0 2px var(--ts-night);
}
.color-swatch.is-active::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 9999px;
  border: 2px solid var(--ts-meadow);
  pointer-events: none;
}
.color-swatch {
  position: relative;
}

/* Links */
.contact-link {
  transition: color var(--transition-fast);
}

.contact-link:hover {
  color: var(--ts-acid);
}

/* ===================================
   HERO & ANIMATIONS
   =================================== */

/* Hero overlay */
.glass-overlay {
  background: linear-gradient(
    to top,
    rgba(29, 45, 26, 0.9) 0%,
    rgba(29, 45, 26, 0.2) 100%
  );
}

/* Ken Burns effect */
.hero-kenburns {
  animation: kenburns 18s ease-in-out infinite alternate;
  transform-origin: center;
}

@keyframes kenburns {
  from {
    transform: scale(1.05) translate(-2%, -2%);
  }
  to {
    transform: scale(1.2) translate(2%, 2%);
  }
}

/* Text underline accent */
.underline-indigo {
  border-bottom: 3px solid var(--ts-indigo);
  display: inline-block;
  padding-bottom: 0.1em;
}

/* ===================================
   NAVIGATION & MENU
   =================================== */

/* Hamburger */
#hamburger {
  z-index: 80 !important;
}

.hamburger-line {
  transition: all var(--transition-base);
  transform-origin: center;
  background: var(--ts-acid);
}

#hamburger.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
  background-color: var(--ts-acid) !important;
}

#hamburger.active .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: translateX(10px);
}

#hamburger.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
  background-color: var(--ts-acid) !important;
}

/* Menu overlay */
#menu-overlay.active {
  opacity: 1;
  pointer-events: all;
}


/* ===================================
   PARALLAX STRIPES
   =================================== */
.parallax-stripes {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: var(--z-stripes);
  overflow: hidden;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.stripe {
  position: absolute;
  width: 150%;
  height: 400px;
  transform: rotate(-40deg) translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

/* Stripe colors using CSS variables */
.stripe-1 {
  top: 10%;
  left: -25%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(166, 194, 56, 0.08) 20%,
    rgba(166, 194, 56, 0.08) 50%,
    rgba(166, 194, 56, 0.08) 80%,
    transparent 100%
  );
}

.stripe-2 {
  top: 25%;
  left: -25%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(121, 172, 50, 0.08) 20%,
    rgba(121, 172, 50, 0.08) 50%,
    rgba(121, 172, 50, 0.08) 80%,
    transparent 100%
  );
}

.stripe-3 {
  top: 40%;
  left: -25%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(69, 123, 50, 0.08) 20%,
    rgba(69, 123, 50, 0.08) 50%,
    rgba(69, 123, 50, 0.08) 80%,
    transparent 100%
  );
}

.stripe-4 {
  top: 55%;
  left: -25%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(40, 81, 40, 0.08) 20%,
    rgba(40, 81, 40, 0.08) 50%,
    rgba(40, 81, 40, 0.08) 80%,
    transparent 100%
  );
}

.stripe-5 {
  top: 70%;
  left: -25%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(29, 45, 26, 0.08) 20%,
    rgba(29, 45, 26, 0.08) 50%,
    rgba(29, 45, 26, 0.08) 80%,
    transparent 100%
  );
}

/* ===================================
   CLOUDFLARE TURNSTILE (footer form) — responsive
   =================================== */
/* Contiene il widget e forza l'iframe a rispettare la larghezza del contenitore */
.turnstile-responsive {
  display: block;
  width: 100%;
  max-width: 100%;
}
.turnstile-responsive iframe {
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box;
}
/* Su viewport molto stretti (mobile) ridimensiona il widget per evitare overflow */
@media (max-width: 380px) {
  .turnstile-responsive {
    transform: scale(0.9);
    transform-origin: left center;
  }
}
@media (max-width: 340px) {
  .turnstile-responsive {
    transform: scale(0.8);
    transform-origin: left center;
  }
}

/* ===================================
   PERFORMANCE OPTIMIZATIONS
   =================================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .glass {
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid var(--text-primary);
  }
}
