/* Design System Tokens: Hermes Vibe */
:root {
  --bg-primary: #050505;
  --bg-secondary: #0a0a0a;
  --bg-card: rgba(255, 255, 255, 0.02);
  --border-color: rgba(255, 255, 255, 0.08);
  
  --text-primary: #f2f2f2;
  --text-secondary: #888888;
  --text-muted: #555555;
  --accent-color: #e5e5e5;
  
  --font-sans: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;
  
  --space-2: 0.5rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-24: 6rem;
  --space-32: 10rem;
  
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-full: 9999px;
  
  --transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Lenis smooth scrolling requirement */
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 {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Background Grid variables to reuse */
:root {
  --grid-pattern: linear-gradient(to right, rgba(255,255,255,0.15) 1px, transparent 1px),
                  linear-gradient(to bottom, rgba(255,255,255,0.15) 1px, transparent 1px);
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  animation: twinkle 4s infinite ease-in-out;
  pointer-events: none;
  z-index: 1; /* Stay behind text but in main-content */
}
@keyframes twinkle {
  0%, 100% { opacity: 0.1; }
  50% { opacity: 1; }
}

/* Typography */
h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

h2 {
  font-size: clamp(2.5rem, 4vw, 3.5rem);
  margin-bottom: var(--space-4);
}

p {
  color: var(--text-secondary);
  font-size: 1.125rem;
  max-width: 65ch;
}

a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition);
}

/* Layout */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

.section-padding {
  padding: var(--space-24) 0;
}

.overflow-hidden {
  overflow: hidden;
}

/* Header & Nav */
.nav-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 80px;
  z-index: 1100;
  display: flex;
  align-items: center;
  background-color: rgba(5, 5, 5, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo a {
  font-family: var(--font-serif);
  font-size: 2rem;
  color: #fff;
  letter-spacing: -0.05em;
}

.hamburger-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: 32px;
  height: 32px;
  z-index: 1100;
}

.hamburger-btn span {
  display: block;
  width: 100%;
  height: 1px;
  background-color: #fff;
  transition: transform var(--transition);
}

/* Buttons (Magnetic) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 2rem;
  border-radius: var(--radius-full);
  font-weight: 500;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background-color var(--transition), border-color var(--transition);
  cursor: pointer;
}

.btn-primary {
  background-color: var(--text-primary);
  color: var(--bg-primary);
}

.btn-primary:hover {
  background-color: #ccc;
}

.btn-secondary {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  border-color: var(--text-primary);
}

.magnetic-btn {
  position: relative;
  /* GSAP handles transform */
}
.magnetic-text {
  display: inline-block;
  pointer-events: none;
}

/* Hero Section */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding-top: 80px;
}

.hero-content {
  width: 100%;
  max-width: 900px;
  min-width: 0;
}

.hero-label {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
}

.hero-title {
  font-size: clamp(4rem, 10vw, 8rem);
  margin-bottom: var(--space-8);
}

.hero-title-line {
  display: inline-block;
}

.hero-dot {
  color: var(--text-secondary);
}

.hero-desc {
  font-size: clamp(1.125rem, 2vw, 1.5rem);
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-8);
}

/* Section Headers */
.section-header {
  margin-bottom: var(--space-12);
}

.section-line {
  height: 1px;
  background-color: var(--border-color);
  width: 100%;
  margin-top: var(--space-4);
  transform-origin: left;
}

/* Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-8);
}

.project-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  /* Hover effect handled by GSAP or CSS */
  transition: border-color var(--transition);
}

.project-card:hover {
  border-color: rgba(255,255,255,0.2);
}

.project-image {
  width: 100%;
  height: 300px;
  overflow: hidden;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.project-image img {
  width: 100%;
  height: 120%; /* Extra height for parallax */
  object-fit: cover;
  object-position: center;
  position: absolute;
  top: -10%;
  left: 0;
  filter: grayscale(100%) brightness(0.7) contrast(1.2);
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), filter 0.6s ease;
}

.project-card:hover .project-image img {
  filter: grayscale(0%) brightness(1) contrast(1);
}

.project-content {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.project-content h3 {
  font-family: var(--font-serif);
  font-size: 2rem;
  margin-bottom: var(--space-2);
}

.project-tagline {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.tags {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  margin-bottom: var(--space-6);
}

.tag {
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
}

.project-links {
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-4);
  display: flex;
  gap: 1rem;
}

.project-link {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.project-link:hover {
  color: #fff;
}

/* Archive List (Table Style) */
.archive-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-color);
}

.archive-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-6) 0;
  border-bottom: 1px solid var(--border-color);
  transition: background-color var(--transition), padding-left var(--transition);
}

.archive-item:hover {
  background-color: var(--bg-card);
  padding-left: var(--space-4);
}

.archive-info h3 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.archive-type {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.archive-links {
  display: flex;
  gap: 1.5rem;
}

.archive-link {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.archive-link:hover {
  color: #fff;
}

/* Contact */
.contact-box {
  text-align: center;
  padding: var(--space-24) 0;
}

.contact-box h2 {
  font-size: clamp(3rem, 6vw, 5rem);
}

.contact-box p {
  margin: 0 auto var(--space-8);
  font-size: 1.25rem;
}

.contact-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
}

/* Footer */
footer {
  padding: var(--space-8) 0;
  border-top: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: var(--space-4);
}

/* Media queries movidas al final del archivo para asegurar precedencia */

/* ====== NUEVOS ESTILOS FASE 2 ====== */

/* --- Tech Stack --- */
.tech-stack-container {
  margin-top: var(--space-6);
  margin-bottom: var(--space-8);
}
.tech-stack {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}
.tech-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  transition: all var(--transition);
}
.tech-item:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.2);
}

/* --- Menu Nav Panel --- */
.nav-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background-color: rgba(5, 5, 5, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.nav-panel.open {
  opacity: 1;
  pointer-events: all;
}
.nav-menu {
  list-style: none;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}
.nav-menu-link {
  font-family: var(--font-serif);
  font-size: 3rem;
  color: var(--text-primary);
  display: inline-block;
  transition: transform var(--transition), color var(--transition);
}
.nav-menu-link:hover {
  color: var(--text-secondary);
  transform: scale(1.05);
}
.hamburger-btn.active span:nth-child(1) {
  transform: translateY(3px) rotate(45deg);
}
.hamburger-btn.active span:nth-child(2) {
  transform: translateY(-4px) rotate(-45deg);
}

/* --- Archive Grid --- */
.archive-list {
  display: none; /* Hide old list */
}
.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-6);
}
.archive-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition);
}
.archive-card:hover {
  border-color: rgba(255,255,255,0.2);
}
.archive-img {
  width: 100%;
  height: 180px;
  overflow: hidden;
  border-bottom: 1px solid var(--border-color);
}
.archive-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(100%) brightness(0.7) contrast(1.2);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), filter 0.6s ease;
}
.archive-card:hover .archive-img img {
  transform: scale(1.08);
  filter: grayscale(0%) brightness(1) contrast(1);
}
.archive-info {
  padding: var(--space-4);
}
.archive-info h4 {
  font-size: 1.25rem;
  margin-bottom: var(--space-2);
}
.archive-info a {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.archive-info a:hover {
  color: #fff;
}

/* --- Footer Reveal (Cortina) --- */
.main-content {
  position: relative;
  z-index: 2;
  background-color: var(--bg-primary); /* Needs solid background to cover footer */
  background-image: var(--grid-pattern);
  background-size: 100px 100px;
  box-shadow: 0 40px 100px rgba(0,0,0,1), 0 5px 20px rgba(255,255,255,0.02); /* Strong shadow dropping onto the footer */
  border-bottom: 1px solid rgba(255, 255, 255, 0.05); /* Sharp edge */
  /* margin-bottom will be set by JS based on footer height */
}
.footer-wrapper {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 1;
  background: radial-gradient(circle at top, #111111 0%, #000000 100%);
}
/* Ensure the grid overlay covers both by being in body, but body scroll might affect it. 
   Grid overlay is position: fixed so it's fine. */

/* --- TECH MARQUEE --- */
.tech-marquee-wrapper {
  margin-top: var(--space-12);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.5rem 0;
  mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}
.tech-marquee {
  display: flex;
  width: max-content;
  animation: marquee 25s linear infinite;
}
.tech-marquee-group {
  display: flex;
  gap: var(--space-4);
  padding-right: var(--space-4);
}
.tech-badge {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.05);
  white-space: nowrap;
  transition: all 0.3s ease;
}
.tech-badge:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}
@keyframes marquee {
  to {
    transform: translateX(-50%);
  }
}

/* --- PROJECT MODALS --- */
.project-modal {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  border: none;
  background: transparent;
  z-index: 2000;
  display: none; 
}
.project-modal.open {
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(5, 5, 5, 0.7);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  opacity: 0;
}
.modal-content {
  position: relative;
  background: rgba(15, 15, 15, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: scale(0.95);
  box-shadow: 0 30px 60px rgba(0,0,0,0.5);
  z-index: 2001;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--space-8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.modal-header-text {
  flex: 1;
  padding-right: var(--space-4);
}
.modal-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.modal-links {
  display: flex;
  gap: var(--space-3);
}
.modal-links .btn {
  padding: 0.6rem 1.2rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}
.modal-scroll-area {
  padding: var(--space-8);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}
.modal-scroll-area::-webkit-scrollbar {
  width: 6px;
}
.modal-scroll-area::-webkit-scrollbar-track {
  background: transparent;
}
.modal-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}
.modal-close {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}
.modal-title {
  color: #ffffff;
  font-family: var(--font-serif);
  font-size: 3rem;
  margin-bottom: var(--space-2);
  line-height: 1.1;
}
.modal-subtitle {
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
  font-size: 1.1rem;
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.modal-body {
  line-height: 1.8;
  color: #a1a1aa; /* Muted nice gray */
  font-size: 1.1rem;
}
.modal-text-content p {
  margin-bottom: var(--space-4);
}
.modal-text-content ul {
  margin-bottom: var(--space-4);
  padding-left: 1.5rem;
  color: #a1a1aa;
}
.modal-text-content li {
  margin-bottom: 0.5rem;
}
.modal-text-content strong {
  color: #ffffff;
  font-weight: 500;
}
.modal-tech-stack {
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.modal-tech-stack h3 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-4);
  color: #fff;
}
.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.project-btn-trigger {
  margin-top: var(--space-4);
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.875rem;
  cursor: pointer;
  border-bottom: 1px solid var(--text-primary);
  padding-bottom: 2px;
  transition: opacity 0.3s ease;
}
.project-btn-trigger:hover {
  opacity: 0.6;
}
.project-interactive {
  cursor: pointer;
}

/* ====== MOBILE RESPONSIVE FIXES ====== */
@media (max-width: 768px) {
  /* Prevent horizontal scroll globally on mobile */
  html, body {
    overflow-x: hidden;
    width: 100%;
  }

  /* Hero & Buttons */
  .hero {
    min-height: auto;
    padding-top: 120px;
    padding-bottom: 60px;
  }
  .hero-actions, .contact-actions {
    flex-direction: column;
    width: 100%;
  }
  .hero-actions .btn, .contact-actions .btn {
    width: 100%;
    text-align: center;
  }
  .archive-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }
  .hero-title {
    font-size: clamp(2.5rem, 10vw, 3.5rem); /* Even smaller to be safe */
    word-break: keep-all;
  }
  .tech-marquee-wrapper {
    margin-top: var(--space-6);
  }

  /* Adjust Section Paddings for mobile */
  .section-padding {
    padding: var(--space-12) 0;
  }
  .contact-box {
    padding: var(--space-12) 0;
  }
  .contact-box h2 {
    font-size: 2.5rem;
  }

  /* Grid Layouts - Evitar overflow horizontal */
  .projects-grid {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
  .archive-grid {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  .project-image {
    height: 220px; /* Reduce image height on mobile */
  }

  /* Modal Fixes */
  .modal-content {
    width: 95%;
    max-height: 90vh;
    margin: 0 auto;
  }
  .modal-header {
    flex-direction: column;
    padding: var(--space-4);
    gap: var(--space-4);
  }
  .modal-header-text {
    padding-right: 3rem; /* Dejar espacio para la X absoluta */
  }
  .modal-title {
    font-size: 1.75rem;
  }
  .modal-subtitle {
    font-size: 0.85rem;
  }
  .modal-scroll-area {
    padding: var(--space-4);
  }
  .modal-header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .modal-links {
    flex-direction: column;
    width: 100%;
    gap: var(--space-2);
  }
  .modal-links .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
  .modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
  }

  /* Footer */
  .footer-content {
    flex-direction: column;
    gap: var(--space-4);
    text-align: center;
  }
}
