/* =========================================================================
   Componentes: header, mobile menu, footer, hero, portfolio.
   Portado desde los componentes Astro Header/Footer/Hero.
   ========================================================================= */

/* -------------------- Header -------------------- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 998;
  background-color: transparent;
  transition: all 0.3s var(--transition-smooth);
  will-change: transform, background-color;
}
.site-header .nav { display: flex; align-items: center; height: 5rem; }
.site-header .logo-image { width: 240px; height: auto; transition: all 0.3s ease; }
.site-header .logo-image:hover { opacity: 0.8; }

.site-header.header-white-bg {
  background-color: #fff !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.site-header.header-white-bg .logo-image { filter: none; }
.site-header.header-white-bg .menu-line { background-color: var(--color-secondary) !important; }

.site-header.header-inverted .logo-image { filter: brightness(0) invert(1); }
.site-header.header-inverted .menu-line { background-color: #fff; }

/* Home page: logo blanco + líneas blancas */
body.page-home .logo-image { filter: brightness(0) invert(1); }
body.page-home .menu-line { background-color: #fff !important; }

/* Botón hamburguesa */
.menu-toggle {
  position: relative;
  width: 40px; height: 40px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  margin-left: auto;
  background: transparent; border: none; cursor: pointer;
  z-index: 1001;
}
.menu-line {
  width: 28px; height: 2px;
  background-color: var(--color-secondary);
  transition: all 0.3s var(--transition-smooth);
  position: absolute; transform-origin: center;
}
.menu-line.top { transform: translateY(-8px); }
.menu-line.bottom { transform: translateY(8px); }
.menu-open .menu-line { background-color: var(--color-secondary) !important; }
.menu-open .menu-line.top { transform: rotate(45deg) translateY(0); }
.menu-open .menu-line.middle { opacity: 0; transform: scale(0); }
.menu-open .menu-line.bottom { transform: rotate(-45deg) translateY(0); }

.menu-toggle:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; }

/* -------------------- Mobile menu overlay -------------------- */
.mobile-menu {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh; min-height: 100vh;
  background-color: #fff;
  color: var(--color-secondary);
  z-index: 1000;
  transform: translateX(100%);
  opacity: 0; visibility: hidden;
  transition: all 0.4s var(--transition-smooth);
}
.mobile-menu.active { transform: translateX(0); opacity: 1; visibility: visible; }
.mobile-menu-inner {
  width: 100%; height: 100%; min-height: 100vh;
  padding: 5rem 1.5rem;
  display: flex; flex-direction: column; overflow-y: auto;
}
.mobile-menu ul { list-style: none; margin: 0; padding: 0; text-align: center; }
.mobile-menu li + li { margin-top: 1.5rem; }
.mobile-menu-item {
  display: block;
  font-size: 1.5rem;
  color: var(--color-secondary);
  opacity: 0; transform: translateY(30px);
  transition: all 0.6s var(--transition-smooth);
}
.mobile-menu-item:hover { color: var(--color-gold); }
.mobile-menu.active .mobile-menu-item { opacity: 1; transform: translateY(0); }
.mobile-menu.active .mobile-menu-item:nth-child(1) { transition-delay: 0.15s; }
.mobile-menu.active li:nth-child(2) .mobile-menu-item { transition-delay: 0.25s; }
.mobile-menu.active li:nth-child(3) .mobile-menu-item { transition-delay: 0.35s; }
.mobile-menu.active li:nth-child(4) .mobile-menu-item { transition-delay: 0.45s; }
.mobile-menu.active li:nth-child(5) .mobile-menu-item { transition-delay: 0.55s; }
.mobile-menu.active li:nth-child(6) .mobile-menu-item { transition-delay: 0.65s; }

.mobile-menu-footer {
  border-top: 1px solid rgba(40,38,35,0.2);
  padding-top: 1.5rem; margin-top: 1.5rem;
}
.mobile-menu-social { display: flex; gap: 0.75rem; justify-content: center; }
.mobile-menu-social a {
  width: 2rem; height: 2rem; border: 1px solid rgba(40,38,35,0.3);
  border-radius: 9999px; display: flex; align-items: center; justify-content: center;
  transition: all 0.3s ease;
}
.mobile-menu-social a:hover { background: var(--color-secondary); color: #fff; }

.mobile-menu-backdrop {
  position: fixed; inset: 0; z-index: 999;
  background-color: rgba(0,0,0,0.5);
  opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.mobile-menu-backdrop.active { opacity: 1; visibility: visible; }

/* -------------------- Footer -------------------- */
.site-footer { background: #fff; color: var(--color-secondary); }
.site-footer .footer-social { display: flex; gap: 1rem; justify-content: center; }
.site-footer .footer-social a {
  width: 2.5rem; height: 2.5rem; border: 1px solid rgba(40,38,35,0.3);
  border-radius: 9999px; display: flex; align-items: center; justify-content: center;
  transition: all 0.3s ease;
}
.site-footer .footer-social a:hover { background: var(--color-secondary); color: #fff; }
.site-footer .footer-bottom { border-top: 1px solid rgba(40,38,35,0.1); }
.site-footer .footer-bottom a { position: relative; }
.site-footer .footer-bottom a:hover { color: var(--color-secondary); }

/* -------------------- Hero (home) -------------------- */
.hero-section {
  position: relative; overflow: hidden;
  min-height: 100vh;
  display: flex; align-items: center;
}
.hero-section .video-background { position: absolute; inset: 0; z-index: 0; }
.hero-section .hero-video-element {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
}
.hero-section .video-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.30); z-index: 1; }
.hero-text-bottom-left {
  position: absolute; bottom: 3rem; left: 3rem; z-index: 20;
  color: #fff;
}
.hero-text-bottom-left * { color: #fff; }
.hero-text-bottom-left h1 {
  color: rgba(255,255,255,0.9);
  font-weight: 300; letter-spacing: 0.1em; text-transform: uppercase;
  font-size: 1.125rem; line-height: 1.4; margin: 0;
}
@media (max-width: 768px) {
  .hero-text-bottom-left { bottom: 2rem; left: 2rem; }
  .hero-text-bottom-left h1 { font-size: 1rem; }
}
.scroll-indicator {
  position: absolute; bottom: 2rem; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.6); background: transparent; border: none; cursor: pointer; z-index: 2;
}

/* -------------------- Portfolio grid + cards -------------------- */
.portfolio-grid { display: grid; gap: 2px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .portfolio-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .portfolio-grid { grid-template-columns: repeat(3, 1fr); } }

/* Media de tarjeta de proyecto: fuerza recorte 4:3 sin depender de la clase
   arbitraria aspect-[4/3] de Tailwind (que puede no compilarse/desplegarse). */
/* Ficha de proyecto: descripción centrada + galería a todo el ancho (como el Astro). */
.mg-project-content { max-width: none; }
.mg-proj-body { max-width: 52rem; margin: 0 auto; }
.mg-proj-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 2.5rem; }
.mg-proj-gallery a { display: block; overflow: hidden; }
.mg-proj-gallery img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 3 / 2; display: block; transition: transform .5s ease; }
.mg-proj-gallery a:hover img { transform: scale(1.03); }
@media (max-width: 640px) { .mg-proj-gallery { grid-template-columns: 1fr; } }

.mg-card-media { aspect-ratio: 4 / 3; background: var(--color-sand); }
.mg-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Media de tarjeta de artículo (blog): 16:9. */
.mg-post-media { aspect-ratio: 16 / 9; background: var(--color-sand); overflow: hidden; }
.mg-post-media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.portfolio-card { position: relative; }
.portfolio-card .card-media {
  display: block; position: relative; overflow: hidden;
  background: var(--color-sand); aspect-ratio: 16/10;
}
.portfolio-card .card-media img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.7s var(--transition-smooth);
}
.portfolio-card:hover .card-media img { transform: scale(1.05); }
.portfolio-card .card-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8), transparent 60%);
  opacity: 0; transition: opacity 0.3s ease;
  display: flex; align-items: flex-end; padding: 1.5rem; color: #fff;
}
.portfolio-card:hover .card-overlay { opacity: 1; }
.portfolio-card .card-overlay h3 { color: #fff; margin-bottom: 0.5rem; }
.portfolio-card .card-meta { display: flex; gap: 1rem; font-size: 0.8rem; opacity: 0.9; }

/* Page hero genérico (archivos, páginas legales, servicios) */
.page-hero {
  padding-top: calc(var(--header-height) + 4rem);
  padding-bottom: 3rem;
  background: var(--color-cream);
  text-align: center;
}
.page-hero .eyebrow {
  text-transform: uppercase; letter-spacing: 0.2em; font-size: 0.75rem;
  color: var(--color-primary); margin-bottom: 1rem;
}

/* ===================================================================== */
/* Proyecto (single-proyecto): réplica de portfolio/[slug].astro          */
/* ===================================================================== */
.project-hero-section { position: relative; width: 100%; min-height: 100vh; height: 100vh; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.project-hero-section .hero-background { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }
.project-hero-section .hero-image { width: 100%; height: 100%; object-fit: cover; object-position: center; transform: translateZ(0); position: absolute; top: 0; left: 0; z-index: 2; }
.mg-hero-shade { position: absolute; inset: 0; z-index: 5; pointer-events: none; background: linear-gradient(to bottom, transparent, rgba(0,0,0,.2), rgba(0,0,0,.6)); }
.hero-text-bottom { position: absolute; bottom: 5rem; left: 0; right: 0; z-index: 20; }
.hero-text-bottom h1 { font-size: 2.5rem; line-height: 1.2; margin-bottom: .5rem; }
.hero-text-bottom p { font-size: 1.125rem; line-height: 1.4; }
@media (max-width: 768px) {
  .hero-text-bottom { bottom: 4rem; }
  .hero-text-bottom h1 { font-size: 2rem; }
  .hero-text-bottom p { font-size: 1rem; }
}
@media (max-width: 480px) {
  .hero-text-bottom { bottom: 3rem; }
  .hero-text-bottom h1 { font-size: 1.75rem; }
  .hero-text-bottom p { font-size: .875rem; }
}
.mg-fade-in { animation: mg-fade-in-scale 1s ease-out forwards; opacity: 0; animation-fill-mode: both; }
@keyframes mg-fade-in-scale { 0% { opacity: 0; transform: scale(.9) translateY(20px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
.hero-cursor { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='20' r='18' fill='none' stroke='white' stroke-width='2'/%3E%3Cpath d='M20 12v16m-6-6l6 6 6-6' stroke='white' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 20 20, pointer; }
.hero-cursor * { cursor: inherit !important; }
.mg-scroll-indicator { position: absolute; bottom: 2rem; left: 50%; transform: translateX(-50%); z-index: 20; color: rgba(255,255,255,.6); cursor: pointer; transition: opacity .3s ease; }
.mg-scroll-indicator:hover { opacity: 1; }
.mg-bounce { display: flex; flex-direction: column; align-items: center; animation: mg-bounce 1s infinite; }
.mg-bounce span { font-size: .75rem; line-height: 1rem; text-transform: uppercase; letter-spacing: .1em; margin-bottom: .5rem; }
@keyframes mg-bounce { 0%, 100% { transform: translateY(-25%); animation-timing-function: cubic-bezier(.8,0,1,1); } 50% { transform: none; animation-timing-function: cubic-bezier(0,0,.2,1); } }

/* Texto: el original no aplica el plugin typography al contenido (set:html), así que
   queda con el cuerpo base: 14px, interlineado 1.6, color carbón y párrafos sin margen. */
.mg-prose .mg-proj-body { max-width: none !important; }  /* el HTML guardado lleva 52rem en línea; el original usa 56rem (max-w-4xl) */
.mg-prose p { margin: 0; }
.mg-prose h3 { margin: 2rem 0 1rem; font-family: var(--font-sans); color: var(--color-secondary); }

/* Galería: 1 columna, 2 desde 768px, hueco de 2rem, 16:10 */
.mg-gallery { display: grid; grid-template-columns: 1fr; gap: 2rem; }
@media (min-width: 768px) { .mg-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mg-gallery-item { cursor: pointer; transition: transform .3s ease, box-shadow .3s ease, opacity .6s ease; }
.mg-gallery-item:hover { transform: translateY(-4px); box-shadow: 0 20px 40px rgba(0,0,0,.15); }
.mg-gallery-frame { position: relative; overflow: hidden; border-radius: .5rem; box-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1); aspect-ratio: 16 / 10; width: 100%; }
.mg-gallery-frame img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s ease; }
.mg-gallery-item:hover .mg-gallery-frame img { transform: scale(1.05); }
.mg-gallery-veil { position: absolute; inset: 0; border-radius: .5rem; pointer-events: none; opacity: 0; transition: opacity .3s ease; display: flex; flex-direction: column; justify-content: flex-end; padding: 1.5rem; color: #fff; background: linear-gradient(to top, rgba(0,0,0,.6), transparent 50%); }
.mg-gallery-item:hover .mg-gallery-veil { opacity: 1; }
.mg-gallery-veil p { font-size: .875rem; line-height: 1.25rem; margin: 0 0 .5rem; color: #fff; }
.mg-gallery-veil div { display: flex; align-items: center; gap: .5rem; }
.mg-gallery-veil span { font-size: .75rem; line-height: 1rem; text-transform: uppercase; letter-spacing: .05em; }

/* Visor a pantalla completa */
.lightbox { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .3s ease, visibility .3s ease; }
.lightbox.active { opacity: 1; visibility: visible; z-index: 2000; pointer-events: auto; }
.lightbox-backdrop { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,.95); cursor: pointer; }
.lightbox-container { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.lightbox-content { position: relative; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; align-items: center; }
.lightbox-image-wrapper { position: relative; display: flex; align-items: center; justify-content: center; max-width: 100%; max-height: calc(90vh - 80px); }
.lightbox-image { max-width: 100%; max-height: calc(90vh - 80px); object-fit: contain; opacity: 0; transition: opacity .3s ease; }
.lightbox-image.loaded { opacity: 1; }
.lightbox-loader { position: absolute; display: none; }
.lightbox-loader.active { display: block; }
.mg-spinner { width: 3rem; height: 3rem; border-radius: 9999px; border-bottom: 2px solid #fff; animation: mg-spin 1s linear infinite; }
@keyframes mg-spin { to { transform: rotate(360deg); } }
.lightbox-close, .lightbox-nav { position: absolute; z-index: 2010; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background-color: rgba(0,0,0,.5); border: none; border-radius: 50%; color: #fff; cursor: pointer; transition: background-color .2s ease; padding: 0; }
.lightbox-close { top: 1rem; right: 1rem; }
.lightbox-nav { top: 50%; transform: translateY(-50%); }
.lightbox-close:hover, .lightbox-nav:hover { background-color: rgba(0,0,0,.8); }
.lightbox-close:focus, .lightbox-nav:focus { outline: 2px solid #fff; outline-offset: 2px; }
.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }
.lightbox-info { position: absolute; bottom: 0; left: 0; right: 0; padding: 1.5rem; text-align: center; color: #fff; }
.lightbox-caption { margin: 0 0 .5rem; font-size: 1rem; font-weight: 300; color: #fff; }
.lightbox-counter { margin: 0; font-size: .875rem; opacity: .8; color: #fff; }
@media (max-width: 768px) {
  .lightbox-container { padding: 0; }
  .lightbox-nav { width: 40px; height: 40px; }
  .lightbox-prev { left: .5rem; }
  .lightbox-next { right: .5rem; }
  .lightbox-info { padding: 1rem; }
}

/* Botones de compartir del blog (ShareButtons.astro) */
.mg-share-title { margin: 0 0 .75rem; font-size: .875rem; line-height: 1.25rem; font-weight: 500; text-transform: uppercase; letter-spacing: normal; color: #6b7280; }
.mg-share { display: flex; gap: .75rem; }
.mg-share a { display: flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 9999px; background: #e5e7eb; color: #4b5563; transition: color .15s, background-color .15s; }
.mg-share a:hover { background: var(--color-primary); color: #fff; }
.mg-share svg { width: 1rem; height: 1rem; fill: currentColor; }

/* Columnas opcionales del pie (menús «Footer — Servicios» y «Footer — Empresa») */
.site-footer .footer-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 2rem; max-width: 40rem; margin: 0 auto 2rem; text-align: center; }
.site-footer .footer-columns-title { margin: 0 0 .75rem; font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; color: rgba(40,38,35,.6); }
.site-footer .footer-columns-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; font-size: .875rem; }
.site-footer .footer-columns-list a:hover { color: var(--color-primary); }

/* Tablas dentro del contenido (p. ej. cookies): legibles y sin desbordar */
.entry-content table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.5rem; font-size: .8125rem; display: block; overflow-x: auto; }
.entry-content th { text-align: left; font-weight: 400; padding: .75rem 1rem; border-bottom: 1px solid var(--color-stone, #d6d3d1); white-space: nowrap; }
.entry-content td { padding: .75rem 1rem; border-bottom: 1px solid rgba(40,38,35,.1); vertical-align: top; }
.entry-content td code { font-size: .75rem; background: rgba(40,38,35,.06); padding: .125rem .5rem; border-radius: .25rem; }
