/* layout.css — grid, containers and responsive utilities */

/* Grid systems */
.grid {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-large {
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: var(--space-xl);
}

.video-grid {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.media-gallery {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

/* ============================================
   HEADER ULTRA PREMIUM
   ============================================ */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.header-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, 
    rgba(15, 15, 35, 0.98) 0%, 
    rgba(15, 15, 35, 0.95) 100%);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.header-glow {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(102, 126, 234, 0.5) 20%,
    rgba(118, 75, 162, 0.8) 50%,
    rgba(102, 126, 234, 0.5) 80%,
    transparent 100%);
  opacity: 0.6;
}

.header-particles {
  position: absolute;
  inset: 0;
  background-image: 
    radial-gradient(1px 1px at 10% 50%, rgba(102, 126, 234, 0.4) 50%, transparent 50%),
    radial-gradient(1px 1px at 30% 30%, rgba(118, 75, 162, 0.3) 50%, transparent 50%),
    radial-gradient(1px 1px at 70% 60%, rgba(102, 126, 234, 0.3) 50%, transparent 50%),
    radial-gradient(1px 1px at 90% 40%, rgba(118, 75, 162, 0.4) 50%, transparent 50%);
  opacity: 0.5;
}

.header-scrolled .header-gradient {
  background: linear-gradient(180deg, 
    rgba(10, 10, 28, 0.99) 0%, 
    rgba(10, 10, 28, 0.97) 100%);
}

.header-scrolled .header-glow {
  opacity: 1;
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

.header-hidden {
  transform: translateY(-100%);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  gap: var(--space-md);
  position: relative;
}

/* Logos Institucionales */
.institutional-logos {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.institutional-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  padding: 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.institutional-logo:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(102, 126, 234, 0.4);
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.2);
}

.institutional-logo img {
  height: 45px;
  width: auto;
  object-fit: contain;
  filter: brightness(1.1);
}

/* Logo Ultra Premium */
.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  z-index: 10;
}

.logo:hover {
  transform: scale(1.03);
  text-decoration: none;
}

.logo-icon {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.logo-ring {
  position: absolute;
  inset: -4px;
  border: 2px dashed rgba(102, 126, 234, 0.3);
  border-radius: 50%;
  animation: logoRingSpin 12s linear infinite;
}

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

.logo-icon svg {
  width: 100%;
  height: 100%;
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  filter: drop-shadow(0 0 10px rgba(102, 126, 234, 0.4));
}

.logo:hover .logo-icon svg {
  transform: rotate(15deg) scale(1.1);
  filter: drop-shadow(0 0 20px rgba(102, 126, 234, 0.6));
}

.logo-text-group {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.logo-text {
  font-size: 1.6rem;
  font-weight: 900;
  background: linear-gradient(135deg, #667eea 0%, #a78bfa 50%, #f093fb 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  animation: logoGradient 6s ease infinite;
}

@keyframes logoGradient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.logo-subtitle {
  font-size: 0.7rem;
  color: #94a3b8;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Navigation Premium */
.nav-main {
  display: flex;
  align-items: center;
  position: relative;
}

.nav-list {
  display: flex;
  list-style: none;
  gap: 2px;
  align-items: center;
  margin: 0;
  padding: 0;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.88rem;
  color: #cbd5e1;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.nav-icon {
  width: 16px;
  height: 16px;
  opacity: 0.6;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.nav-link::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.12) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: inherit;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 24px;
  height: 2px;
  background: linear-gradient(90deg, #667eea, #a78bfa);
  border-radius: 2px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover, .nav-link:focus {
  text-decoration: none;
  color: #f1f5f9;
}

.nav-link:hover .nav-icon {
  opacity: 1;
  color: #a78bfa;
}

.nav-link:hover::before {
  opacity: 1;
}

.nav-link:hover::after,
.nav-link.is-active::after {
  transform: translateX(-50%) scaleX(1);
}

.nav-link.is-active {
  color: #f1f5f9;
  font-weight: 600;
}

.nav-link.is-active .nav-icon {
  opacity: 1;
  color: #667eea;
}

.nav-link.is-active::before {
  opacity: 1;
}

/* Featured Nav Link */
.nav-featured {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
  border: 1px solid rgba(102, 126, 234, 0.2);
}

.nav-featured:hover {
  border-color: rgba(102, 126, 234, 0.4);
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.2);
}

.nav-badge {
  padding: 2px 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.nav-link span {
  position: relative;
  z-index: 1;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Search Button */
.header-search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  cursor: pointer;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.3s ease;
  position: relative;
}

.header-search-btn:hover {
  background: rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.3);
  transform: scale(1.05);
}

.header-search-btn svg {
  width: 20px;
  height: 20px;
  stroke: #94a3b8;
  transition: stroke 0.3s ease;
}

.header-search-btn:hover svg {
  stroke: #a78bfa;
}

.search-kbd {
  position: absolute;
  bottom: -6px;
  right: -6px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  font-size: 0.6rem;
  font-family: system-ui, sans-serif;
  color: #94a3b8;
}

/* UNAM Button */
.header-unam-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.3s ease;
}

.header-unam-btn:hover {
  background: rgba(0, 104, 71, 0.15);
  border-color: rgba(0, 104, 71, 0.4);
  color: #22c55e;
  text-decoration: none;
  transform: translateY(-2px);
}

.header-unam-btn svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.header-unam-btn:hover svg {
  opacity: 1;
}

.unam-text {
  font-weight: 700;
  letter-spacing: 1px;
}

/* CTA Button */
.header-cta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 12px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  position: relative;
  overflow: hidden;
}

.header-cta::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.header-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
  text-decoration: none;
  color: white;
}

.header-cta:hover::before {
  left: 100%;
}

.header-cta svg {
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease;
}

.header-cta:hover svg {
  transform: translateX(4px);
}

/* Search Modal */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.search-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.search-modal-content {
  width: 100%;
  max-width: 600px;
  padding: 0 20px;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.search-modal.is-open .search-modal-content {
  transform: translateY(0);
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: rgba(30, 30, 60, 0.95);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.search-input-icon {
  width: 24px;
  height: 24px;
  stroke: #667eea;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 1.2rem;
  color: #f1f5f9;
  font-family: inherit;
}

.search-input::placeholder {
  color: #64748b;
}

.search-close {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.search-close:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
}

.search-close svg {
  width: 20px;
  height: 20px;
  stroke: #94a3b8;
}

.search-close:hover svg {
  stroke: #f43f5e;
}

.search-suggestions {
  margin-top: 20px;
  padding: 20px;
  background: rgba(30, 30, 60, 0.8);
  border-radius: 12px;
}

.search-label {
  display: block;
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 12px;
}

.search-tags {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.search-tag {
  padding: 8px 16px;
  background: rgba(102, 126, 234, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 100px;
  color: #a78bfa;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.3s ease;
}

.search-tag:hover {
  background: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.4);
  color: #c4b5fd;
  text-decoration: none;
  transform: translateY(-2px);
}

/* Mobile Menu Toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  z-index: 100;
}

.nav-toggle:hover {
  background: rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.3);
}

.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: linear-gradient(90deg, #667eea, #a78bfa);
  border-radius: 2px;
  transition: all 0.3s ease;
  transform-origin: center;
}

.nav-toggle[aria-expanded="true"] .hamburger span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle[aria-expanded="true"] .hamburger span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.nav-toggle[aria-expanded="true"] .hamburger span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ============================================
   SECTIONS
   ============================================ */
.section {
  padding: var(--space-2xl) 0;
}

.section:nth-child(even) {
  background-color: var(--card);
}

.section-title {
  margin-bottom: var(--space-lg);
  text-align: center;
}

.section-intro {
  text-align: center;
  font-size: 1.125rem;
  color: var(--muted);
  margin-bottom: var(--space-2xl);
  max-width: none;
}

/* Hero section */
.hero {
  background: linear-gradient(135deg, var(--bg) 0%, var(--card) 100%);
  padding: var(--space-3xl) 0;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
}

.hero-title {
  margin-bottom: var(--space-lg);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-hover) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--muted);
  margin-bottom: var(--space-2xl);
  max-width: none;
}

/* ============================================
   RESPONSIVE HEADER
   ============================================ */
@media (max-width: 1200px) {
  .nav-link {
    padding: 8px 10px;
    font-size: 0.82rem;
  }
  
  .nav-icon {
    display: none;
  }
  
  .header-unam-btn {
    padding: 8px 12px;
  }
  
  .header-cta {
    padding: 10px 16px;
    font-size: 0.85rem;
  }
}

@media (max-width: 1024px) {
  .nav-toggle {
    display: flex;
    order: 3;
  }
  
  .nav-main {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(15, 15, 35, 0.99) 0%, rgba(10, 10, 28, 0.99) 100%);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    padding: 100px 30px 30px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    z-index: 50;
  }
  
  .nav-main.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  
  .nav-list {
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
  }
  
  .nav-link {
    padding: 18px 24px;
    font-size: 1.15rem;
    justify-content: flex-start;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
  }
  
  .nav-icon {
    display: block;
    width: 22px;
    height: 22px;
  }
  
  .nav-link::after {
    display: none;
  }
  
  .nav-featured {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    border: 1px solid rgba(102, 126, 234, 0.3);
  }
  
  .nav-badge {
    margin-left: auto;
  }
  
  .header-actions {
    order: 2;
  }
  
  .header-unam-btn {
    display: none;
  }
  
  .header-cta {
    display: none;
  }
  
  body.nav-open {
    overflow: hidden;
  }
}

@media (max-width: 768px) {
  .header-content {
    min-height: 70px;
  }
  
  .institutional-logos {
    gap: 10px;
  }
  
  .institutional-logo {
    padding: 4px;
  }
  
  .institutional-logo img {
    height: 35px;
  }
  
  .logo-icon {
    width: 42px;
    height: 42px;
  }
  
  .logo-ring {
    display: none;
  }
  
  .logo-text {
    font-size: 1.35rem;
  }
  
  .logo-subtitle {
    font-size: 0.6rem;
    letter-spacing: 1px;
  }
  
  .header-search-btn {
    width: 40px;
    height: 40px;
  }
  
  .search-kbd {
    display: none;
  }
  
  .nav-toggle {
    width: 44px;
    height: 44px;
  }
  
  .search-modal {
    padding-top: 10vh;
  }
  
  .search-input-wrapper {
    padding: 16px 20px;
  }
  
  .search-input {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .header-content {
    min-height: 60px;
    gap: 8px;
  }
  
  .institutional-logos {
    gap: 6px;
  }
  
  .institutional-logo {
    padding: 3px;
  }
  
  .institutional-logo img {
    height: 28px;
  }
  
  .logo-icon {
    width: 36px;
    height: 36px;
  }
  
  .logo-text {
    font-size: 1.2rem;
  }
  
  .logo-subtitle {
    display: none;
  }
  
  .nav-main {
    padding: 80px 20px 20px;
  }
  
  .nav-link {
    padding: 16px 20px;
    font-size: 1rem;
  }
}
  
  h1 { font-size: 2.25rem; }
  h2 { font-size: 1.875rem; }
  h3 { font-size: 1.5rem; }
  
  .grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .grid-large {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
}
