/* ==========================================================================
   Tailark Dusk - Pure CSS Stylesheet & Theme System
   ========================================================================== */

:root {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #121215;
  --card-foreground: #fafafa;
  --popover: #121215;
  --popover-foreground: #fafafa;
  --primary: #fafafa;
  --primary-foreground: #09090b;
  --secondary: #27272a;
  --secondary-foreground: #fafafa;
  --muted: #18181b;
  --muted-foreground: #a1a1aa;
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --border: #27272a;
  --radius: 0.75rem;
  --bg-light: #0c0d10;
  --text-dark: #fafafa;
  --text-dark-muted: #a1a1aa;
  --tech-blue: #00A3FF;
}

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Glassmorphism panel */
.glass-panel {
  background: rgba(18, 18, 21, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* GPU hardware acceleration */
.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Infinite Marquee Slider */
@keyframes marquee {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-50%, 0, 0); }
}

.animate-marquee {
  display: flex;
  width: max-content;
  animation: marquee 45s linear infinite;
  will-change: transform;
}

.animate-marquee-smooth {
  display: flex;
  width: max-content;
  animation: marquee 36s linear infinite;
  will-change: transform;
}

.animate-marquee:hover,
.animate-marquee-smooth:hover,
.marquee-wrapper:hover .animate-marquee,
.marquee-wrapper:hover .animate-marquee-smooth {
  animation-play-state: paused;
}

/* Skip to content link for WCAG 2.2 AA Accessibility */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.75rem 1.5rem;
  background: #fafafa;
  color: #09090b;
  font-weight: 600;
  border-radius: 0.5rem;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 1rem;
}

/* Keyboard Focus Ring */
:focus-visible {
  outline: 2px solid #fafafa;
  outline-offset: 2px;
}

/* Flow Art / Story Scroll Effect */
.flow-art-container {
  transform-origin: bottom left;
  will-change: transform;
}

/* Respect user preferences for reduced motion */
@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;
  }
  .animate-marquee {
    animation: none !important;
    width: 100% !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
  }
  .flow-art-container {
    transform: none !important;
  }
}

/* ==========================================================================
   Recent Projects Section (Sticky Title & Staggered Scroll Layout)
   ========================================================================== */

.serif-italic {
  font-style: italic;
  font-weight: 600;
  color: var(--tech-blue, #00A3FF);
}

/* Sezione Contenitore */
.recent-projects-section {
  padding: 8rem 5%;
  background-color: var(--bg-light, #0c0d10);
  position: relative;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Grid a 3 Colonne: Sinistra - Centro (Sticky) - Destra */
.recent-projects-container {
  display: grid;
  grid-template-columns: 1fr 350px 1fr;
  gap: 4rem;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  align-items: flex-start;
}

.projects-col {
  display: flex;
  flex-direction: column;
  gap: 8rem;
}

/* Colonna destra sfalsata per creare dinamismo */
.right-col {
  margin-top: 8rem;
}

/* IL CUORE DELL'EFFETTO: Colonna centrale incollata a centro schermo durante lo scroll */
.center-col {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

.sticky-title-wrapper {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.sticky-title-wrapper h2 {
  font-size: 5rem;
  line-height: 1.1;
  color: var(--text-dark, #fafafa);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.scroll-down-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: var(--text-dark-muted, #a1a1aa);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  font-weight: 600;
}

.arrow-down-icon {
  width: 28px;
  height: 28px;
  color: var(--tech-blue, #00A3FF);
  animation: bounceSlow 2s infinite ease-in-out;
}

@keyframes bounceSlow {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}

/* Card Progetti con hover */
.project-card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  pointer-events: auto;
}

.project-image {
  width: 100%;
  aspect-ratio: 4/5;
  background-color: #18181b;
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease, border-color 0.4s ease;
}

.project-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-card:hover .project-image {
  transform: translateY(-10px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  border-color: rgba(194, 248, 79, 0.3);
}

.project-card:hover .project-image img {
  transform: scale(1.02);
}

.project-card h3 {
  font-size: 1.8rem;
  margin: 0;
  color: var(--text-dark, #fafafa);
  font-weight: 600;
  letter-spacing: -0.02em;
  transition: color 0.3s ease;
}

.project-card:hover h3 {
  color: var(--tech-blue, #00A3FF);
}

.project-card p {
  font-size: 1.1rem;
  color: var(--text-dark-muted, #a1a1aa);
  margin: 0;
  font-weight: 400;
  line-height: 1.6;
}

/* Adattamento Mobile e Tablet */
@media (max-width: 1024px) {
  .recent-projects-container {
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
  }
  
  .center-col {
    position: relative;
    height: auto;
    grid-column: 1 / -1;
    margin-bottom: 4rem;
  }
  
  .sticky-title-wrapper h2 {
    font-size: 3.5rem;
  }
  
  .right-col {
    margin-top: 4rem;
  }

  .projects-col {
    gap: 5rem;
  }
}

@media (max-width: 768px) {
  .recent-projects-container {
    grid-template-columns: 1fr;
    gap: 4rem;
  }
  
  .right-col {
    margin-top: 0;
  }
  
  .projects-col {
    gap: 4rem;
  }

  .sticky-title-wrapper h2 {
    font-size: 2.75rem;
  }

  .recent-projects-section {
    padding: 5rem 6%;
  }
}

/* ==========================================================================
   Project Modal
   ========================================================================== */
.project-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.project-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.project-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.project-modal-content {
  position: relative;
  background: #121215;
  color: #fafafa;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  border-radius: 20px;
  overflow-y: auto;
  z-index: 1;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 2.5rem;
}

.project-modal.active .project-modal-content {
  transform: translateY(0);
}

.project-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  z-index: 100;
  transition: background 0.2s, transform 0.2s;
}

.project-modal-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.project-modal-body h2 {
  font-size: 1.85rem;
  font-weight: 600;
  margin: 1.5rem 0 1rem 0;
  color: #fafafa;
}

.project-modal-body p {
  font-size: 1rem;
  line-height: 1.7;
  color: #a1a1aa;
  margin-bottom: 1rem;
}

.modal-project-image,
.modal-project-video {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: 14px;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-project-iframe-wrap {
  width: 100%;
  border-radius: 16px;
  background: #0b0f19;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

@media (max-width: 640px) {
  .project-modal-content {
    width: 95%;
    padding: 1.25rem;
    max-height: 94vh;
  }
  .modal-project-iframe-wrap iframe {
    height: 720px !important;
  }
}

/* ==========================================================================
   Background Paths Floating Curves Animation (from background-paths.tsx)
   ========================================================================== */
@keyframes floatPath {
  0% {
    stroke-dashoffset: 0;
    stroke-dasharray: 25 100;
    opacity: var(--base-op, 0.2);
  }
  50% {
    stroke-dashoffset: -50;
    stroke-dasharray: 75 100;
    opacity: calc(var(--base-op, 0.2) * 2.2);
  }
  100% {
    stroke-dashoffset: -100;
    stroke-dasharray: 25 100;
    opacity: var(--base-op, 0.2);
  }
}

.floating-path {
  animation: floatPath var(--duration, 25s) linear infinite;
  animation-delay: var(--delay, 0s);
  will-change: stroke-dashoffset, stroke-dasharray, opacity;
}

/* ==========================================================================
   Text Reveal on Scroll (Editorial Word-by-Word Scrub Effect)
   ========================================================================== */
.scroll-reveal-container {
  position: relative;
}

.reveal-text {
  color: #a1a1aa;
  transition: opacity 0.3s ease;
}

.reveal-text.is-ready .reveal-word {
  display: inline-block;
  color: rgba(255, 255, 255, 0.18);
  will-change: color;
}

.reveal-text.is-ready .reveal-word.highlight {
  color: rgba(0, 163, 255, 0.25);
  font-weight: 500;
}

/* Fallback & prefers-reduced-motion: text fully illuminated */
.reveal-text.is-revealed,
.reveal-text.is-revealed .reveal-word {
  color: #fafafa !important;
}

.reveal-text.is-revealed .reveal-word.highlight {
  color: #00A3FF !important;
}

/* ==========================================================================
   Orbiting Circles (Magic UI Vanilla Implementation)
   ========================================================================== */
@keyframes orbit {
  0% {
    transform: rotate(calc(var(--angle) * 1deg)) translateY(calc(var(--radius) * 1px)) rotate(calc(var(--angle) * -1deg));
  }
  100% {
    transform: rotate(calc(var(--angle) * 1deg + 360deg)) translateY(calc(var(--radius) * 1px)) rotate(calc(var(--angle) * -1deg - 360deg));
  }
}

@keyframes orbit-reverse {
  0% {
    transform: rotate(calc(var(--angle) * 1deg)) translateY(calc(var(--radius) * 1px)) rotate(calc(var(--angle) * -1deg));
  }
  100% {
    transform: rotate(calc(var(--angle) * 1deg - 360deg)) translateY(calc(var(--radius) * 1px)) rotate(calc(var(--angle) * -1deg + 360deg));
  }
}

.orbit-item {
  position: absolute;
  inset: 0;
  margin: auto;
  animation: orbit var(--duration, 20s) linear infinite;
  will-change: transform;
}

.orbit-item.reverse {
  animation-name: orbit-reverse;
}

@media (prefers-reduced-motion: reduce) {
  .orbit-item {
    animation: none !important;
  }
}
