/* AES Website Styles (responsive, modern, accessible) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
:root {
  --bg: #f7fafb; /* very light bluish gray */
  --bg-alt: #ffffff;
  --text: #334155; /* slate-700 for strong readability */
  --muted: #6b7280; /* slate-500 */
  --primary: #5aa6c9; /* soft calm blue */
  --primary-contrast: #ffffff;
  --accent: #82cbb2; /* soft mint */
  --teal: #7ec8c0; /* pale teal for gradients */
  --teal-2: #8fd3c1;
  --card: #ffffff;
  --border: #e5edf4;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 8px;
  --gradient-hero: transparent;
}
:root.dark {
  --bg: #0f1320;
  --bg-alt: #0c101a;
  --text: #ffffff; /* make base text white in dark mode */
  --muted: #aab7c7;
  --primary: #66c2dd; /* brighten slightly for dark bg contrast */
  --primary-contrast: #0c101a;
  --accent: #86ddc5;
  --card: #11182a;
  --border: #1a2438;
  --shadow: 0 10px 25px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, Ubuntu, Cantarell, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--primary) 85%, #000); outline-offset: 2px; border-radius: 8px; }
button, a, .button { transition: transform .18s ease, box-shadow .18s ease, filter .18s ease, background .2s ease, color .2s ease; }
button:active, .button:active, a:active { transform: translateY(1px); }

.container { width: min(1440px, 92%); margin: 0 auto; }
.section { padding: 64px 0; }
.section--tight { padding-block: 40px; }
.section__title { font-size: clamp(1.8rem, 1.2rem + 1.5vw, 2.6rem); margin: 0 0 14px; font-weight: 800; letter-spacing: .2px; color: var(--primary); text-transform: uppercase; letter-spacing: .4px; }
.section__subtitle { color: var(--muted); margin: 0 0 24px; font-size: 1rem; }

.card__title { font-weight: 600; font-size: 1.05rem; margin: 0; text-transform: uppercase; letter-spacing: .4px; }

.header { position: sticky; top: 0; z-index: 50; background: linear-gradient(90deg, rgba(36,90,155,0.9), rgba(61,185,167,0.9)); border-bottom: none; }
.header__content { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 0; }
.brand { display: flex; align-items: center; gap: .75rem; font-weight: 800; letter-spacing: .3px; color: #fff; }
.brand__logo { height: 44px; width: auto; }
.brand__name { white-space: nowrap; max-width: 62vw; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.nav { display: flex; gap: .25rem; align-items: center; }
.nav a { position: relative; padding: .6rem .9rem; border-radius: 8px; color: #fff; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; min-height: 44px; display: inline-flex; align-items: center; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a[aria-current="page"] { background: rgba(255,255,255,.08); color: #fff; }
.nav a::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 6px; height: 2px; background: rgba(255,255,255,.95); opacity: 0; transform: scaleX(0); transform-origin: left; transition: transform .2s ease, opacity .2s ease; }
.nav a:hover::after, .nav a[aria-current="page"]::after { opacity: 1; transform: scaleX(1); }
.nav #themeToggle { margin-left: .4rem; }
.theme-toggle { position: relative; width: 80px; height: 40px; background: #4cc2af; border-radius: 50px; cursor: pointer; padding: 5px; display: inline-flex; align-items: center; border: 1px solid rgba(255,255,255,.5); color: #fff; box-shadow: none; backdrop-filter: saturate(120%) blur(2px); overflow: hidden; }
/* Theme toggle stays within header on desktop; fixed only on mobile */
.theme-toggle .theme-toggle__text { display: none; }
.theme-toggle__circle { width: 30px; height: 30px; background: #fff; border-radius: 50%; position: absolute; left: 5px; display: flex; align-items: center; justify-content: center; transition: transform .4s ease; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { fill: #f1c40f; }
.theme-toggle .moon { fill: #2c3e50; display: none; }
.theme-toggle.is-active .theme-toggle__circle { transform: translateX(40px); }
.theme-toggle.is-active .sun { display: none; }
.theme-toggle.is-active .moon { display: block; }

.menu-toggle { display: none; align-items: center; gap: .5rem; border: 1px solid rgba(255,255,255,.5); background: rgba(255,255,255,.2); color: #fff; padding: .45rem .7rem; border-radius: 10px; cursor: pointer; box-shadow: none; backdrop-filter: saturate(120%) blur(2px); }
.menu-toggle:hover { background: rgba(255,255,255,.28); }
.menu-toggle__icon { font-size: 1.1rem; line-height: 1; }
.menu-toggle.is-open { background: rgba(255,255,255,.35); }

.hero { position: relative; overflow: hidden; border-bottom: none; background: var(--gradient-hero); background-size: 200% 200%; animation: gradientShift 12s ease-in-out infinite; }
.carousel { position: relative; width: 100%; }
.carousel--natural { height: clamp(48vh, 56.25vw, 90vh); }
.carousel__track { display: flex; height: 100%; transition: transform .6s ease; }
.carousel__slide { position: relative; width: 100%; height: 100%; flex: 0 0 100%; display: grid; place-items: center; }
.carousel__slide img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
/* For the "natural" hero carousel, do not crop images; keep full image visible */
.carousel--natural .carousel__slide { padding: 1.5vw; }
.carousel--natural .carousel__slide img {
  /* Preserve natural size, don't upscale beyond intrinsic dimensions */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: var(--bg-alt);
  border-radius: 10px;
}
:root.dark .carousel--natural .carousel__slide img { background: #0f172a; }
.carousel__caption { position: absolute; inset: 0; display: grid; grid-template-rows: 1fr auto; align-items: center; justify-items: center; text-align: center; color: #fff; padding: 1rem; z-index: 3; pointer-events: none; }
.carousel__text { font-size: clamp(1.7rem, 1.2rem + 2.6vw, 3.2rem); font-weight: 900; letter-spacing: .3px; max-width: min(92%, 1200px); margin: 0 auto; padding: .2rem .6rem; border-radius: 6px; text-shadow: 0 10px 36px rgba(0,0,0,.5), 0 0 1px rgba(0,0,0,.6); }
.carousel__cta { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: auto; display: grid; place-items: center; z-index: 5; }
.carousel__cta .button { padding: 14px 28px; font-size: 1.05rem; }
.carousel__cta .button { background: var(--primary); border-color: var(--primary); color: #fff; border-radius: 999px; box-shadow: 0 14px 40px rgba(90,166,201,.28); animation: heroCtaIn .8s ease-out both, heroCtaPulse 3.6s ease-in-out 1.2s infinite; }
.carousel__cta .button:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 18px 56px rgba(90,166,201,.38); }
/* Only scale the button; parent handles centering */
@keyframes heroCtaIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
@keyframes heroCtaPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) {
  .carousel__cta .button { animation: none; }
}
.carousel__dots { position: absolute; inset: auto 0 14px; display: flex; gap: 8px; justify-content: center; }
.carousel__dot { width: 10px; height: 10px; border-radius: 999px; background: color-mix(in srgb, #fff 50%, transparent); border: 1px solid rgba(255,255,255,.6); cursor: pointer; opacity: .7; transition: transform .15s ease, opacity .15s ease; }
.carousel__dot.is-active { width: 26px; background: var(--accent); opacity: 1; }

.grid { display: grid; gap: 22px; }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1000px) { .grid--4 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px) { .grid--4, .grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid--4, .grid--3 { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .grid--2 { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: 0 4px 24px rgba(0,0,0,.05); transition: transform .2s ease, box-shadow .2s ease; }
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.card__media { position: relative; aspect-ratio: 16/10; overflow: hidden; }
.card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.card:hover .card__media img { transform: scale(1.05); }
.card__body { padding: 16px; display: grid; gap: 8px; }
.card__title { font-weight: 600; font-size: 1.05rem; margin: 0; }
.card__meta { display: flex; flex-wrap: wrap; gap: 10px 16px; color: var(--muted); font-size: .95rem; }
.badge { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-alt); border: 1px solid var(--border); padding: 6px 10px; border-radius: 999px; font-size: .85rem; color: var(--text); }
.price { font-weight: 700; font-size: 1.05rem; }

.about { display: grid; gap: 18px; }
.about__lead { font-size: 1.05rem; color: var(--muted); }
.about__stack { display: grid; gap: 20px; }
.about__row { display: grid; grid-template-columns: 1fr 1.5fr; gap: 18px; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); }
.about__media { aspect-ratio: 1/1; border-radius: 12px; overflow: hidden; background: #ffffff; border: 1px solid var(--border); display: grid; place-items: center; padding: 12px; justify-self: center; width: min(100%, 520px); }
.about__media img { width: 100%; height: 100%; object-fit: contain; }
.about__media--tight { padding: 8px; }
.about__content { display: grid; gap: 10px; }
.about__content p { margin: 0; line-height: 1.7; }
.about__content ul { margin: 0; padding-left: 18px; color: var(--muted); }
.about__content li { margin: 4px 0; }
.about__row:nth-child(even) .about__media { order: 2; }

/* Constrain width of About blocks so they don't span full container unnecessarily */
.page-about .about__stack { max-width: 980px; margin-inline: auto; }
.page-about .about__row { grid-template-columns: auto minmax(0, 640px); justify-content: center; }
.page-about .about__content { max-width: 640px; }
.about__row:nth-child(even) .about__content { order: 1; }
@media (max-width: 900px) { .about__row { grid-template-columns: 1fr; gap: 16px; } .about__row:nth-child(even) .about__media, .about__row:nth-child(even) .about__content { order: initial; } .about__media { aspect-ratio: 4/3; width: 100%; } }

.contact { display: grid; grid-template-columns: 1.2fr .8fr; gap: 22px; }
@media (max-width: 1000px) { .contact { grid-template-columns: 1fr; } }
.map { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); height: 420px; }
.partners .partner { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: grid; grid-template-rows: auto 1fr; }
/* Show partner logos at natural size with a theme-aware background */
.partner__media { background: #ffffff; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; padding: 16px; }
/* Make both brand banners visually the same length */
.partner__media img { width: 92%; height: auto; max-height: clamp(140px, 24vh, 220px); object-fit: contain; display: block; margin: 0 auto; }
@media (max-width: 720px){
  .partner__media img { width: 96%; max-height: 180px; }
}
/* In dark mode, force white background behind logos for contrast */
body.dark .partner__media { background: #ffffff; border: 1px solid var(--border); }
.partner__content { padding: 14px 16px 18px; display: grid; gap: 8px; }
.map iframe { width: 100%; height: 100%; display: block; border: 0; }
.form { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; }
.input { display: grid; gap: 6px; }
.input label { font-weight: 600; font-size: .9rem; }
.input input, .input textarea { border: 1px solid var(--border); background: var(--bg); color: var(--text); padding: 12px 14px; border-radius: 10px; font: inherit; }
.input input:focus, .input textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); border-color: var(--accent); }
.input textarea { min-height: 120px; resize: vertical; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .55rem; border: 1px solid var(--primary); background: var(--primary); color: var(--primary-contrast); padding: 12px 18px; border-radius: 999px; cursor: pointer; font-weight: 700; letter-spacing: .3px; min-height: 44px; box-shadow: 0 8px 24px rgba(90,166,201,.22); position: relative; overflow: hidden; }
.button:hover { background: color-mix(in srgb, var(--primary) 85%, #000); border-color: color-mix(in srgb, var(--primary) 85%, #000); }
.button::after { content: ""; position: absolute; inset: 0; background: radial-gradient(600px circle at var(--x,50%) var(--y,50%), rgba(255,255,255,.15), transparent 40%); opacity: 0; transition: opacity .2s ease; }
.button:hover::after { opacity: 1; }

.contact__info { display: grid; gap: 10px; color: var(--muted); }
.contact__row { display: flex; align-items: center; gap: 10px; }
.icon { width: 20px; height: 20px; display: inline-block; }

.footer { margin-top: 40px; border-top: 1px solid var(--border); background: var(--bg-alt); }
.footer__inner { display: grid; gap: 14px; padding: 24px 0; }
.footer__menu { display: flex; flex-wrap: wrap; gap: 10px 16px; color: var(--muted); }
.footer__social { display: flex; gap: 10px; }
.social__link { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--card); padding: 8px 12px; border-radius: 999px; }
.social-links { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.social-links a { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; background: #f5f5f5; border: 1px solid var(--border); transition: transform .15s ease, filter .15s ease; }
.social-links a:hover { transform: translateY(-2px); filter: brightness(1.02); }
.social-links img { display: block; width: 24px; height: 24px; object-fit: contain; }

/* Page-specific overrides: show project images at natural size on proyectos.php */
.page-projects .card__media {
  aspect-ratio: auto; /* override default 16/10 to avoid forced cropping */
}
.page-projects .card__media img {
  width: auto;            /* use the image's intrinsic width */
  height: auto;           /* use the image's intrinsic height */
  max-width: 100%;        /* prevent overflow */
  max-height: none;       /* allow full natural height */
  object-fit: contain;    /* ensure no cropping if constrained */
  margin-inline: auto;    /* center horizontally when smaller */
  display: block;
  background: transparent;
}

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

@media (max-width: 900px) { .brand__name { max-width: 50vw; } }
@media (max-width: 720px) {
  .header__content { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
  .brand { order: 1; }
  .nav { order: 3; width: 100%; display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin-inline: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 20px 40px rgba(0,0,0,.12); padding: 8px; gap: .25rem; z-index: 60; flex-wrap: wrap; }
  .nav.is-open { display: flex; }
  /* Mobile menu links must be visible on light background */
  .nav a { flex: 0 0 auto; font-size: .82rem; padding: .55rem .7rem; color: var(--text); background: transparent; }
  .nav a:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); }
  .nav a[aria-current="page"] { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
  /* Preserve white links in dark mode */
  :root.dark .nav a { color: #fff; }
  :root.dark .nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
  :root.dark .nav a[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; }
  .controls-wrapper { order: 2; display: flex; align-items: center; gap: 8px; }
  .theme-toggle { order: 2; }
  .theme-toggle#themeToggle { position: fixed; top: 8px; right: 8px; z-index: 1000; }
  .menu-toggle { display: inline-flex; order: 1; }
  .brand__logo { height: 36px; }
  .brand__name { max-width: 45%; font-size: .85rem; }
  .carousel__slide { padding: 0; }
  .carousel--natural { height: 90vh; }
@media (max-width: 900px){ .carousel--natural { height: clamp(50vh, 62vw, 78vh); } .carousel--natural .carousel__slide { padding: 2.5vw; } }
@media (max-width: 600px){ .carousel--natural { height: clamp(50vh, 78vw, 72vh); } .carousel--natural .carousel__slide { padding: 3.5vw; } }
}
@media (max-width: 480px) {
  .carousel__text { font-size: clamp(1.05rem, 3.8vw, 1.35rem); padding: .45rem .7rem; border-radius: 10px; }
  .social-links a { width: 40px; height: 40px; }
  .social-links img { width: 22px; height: 22px; }
}

/* About page: make media match text column height */
.page-about .about__row { align-items: center; }
/* Non-square, flexible media box without cropping */
.page-about .about__media { 
  width: 130px; 
  height: 130px; 
  max-width: 130px; 
  max-height: 130px; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  padding: 10px; 
  border-radius: 12px; 
  background: var(--bg-alt); 
  border: 1px solid var(--border); 
}
.page-about .about__media img, 
.page-about .about__media svg { 
  width: 110px; 
  height: 110px; 
  object-fit: contain; 
}
.page-about .about__stack { gap: 14px; max-width: 1080px; margin-inline: auto; }
.page-about .about__row { padding: 12px; }
/* Minimalist gray icon tones */
.page-about .about-icon svg { stroke: #6b7785; fill: none; stroke-width: 2.4; color: #6b7785; }
.page-about .about-icon.valores svg { fill: #6b7785; stroke: none; }
.page-about .about__media:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0,0,0,.08); transition: transform .2s ease, box-shadow .2s ease; }
/* Dark mode adjustments */
body.dark .page-about .about__media { background: #1f2a36; border-color: #2a3a4a; box-shadow: 0 6px 14px rgba(0,0,0,.45); }
body.dark .page-about .about-icon svg { stroke: #d0d7e2; color: #d0d7e2; }
body.dark .page-about .about-icon.valores svg { fill: #d0d7e2; }

/* Approximate tint of icon images to match muted text color */
/* Tuned to closely match --muted tone */
.page-about .about__media.about-icon img { 
  filter: brightness(0) saturate(100%) invert(44%) sepia(9%) saturate(520%) hue-rotate(182deg) brightness(92%) contrast(88%);
}
/* Dark theme: closer to #aab7c7 */
body.dark .page-about .about__media.about-icon img { 
  filter: brightness(0) saturate(100%) invert(82%) sepia(7%) saturate(235%) hue-rotate(174deg) brightness(95%) contrast(90%);
}

/* Services section: match icon size to text content height */
#servicios .about__media { width: auto; height: auto; max-width: clamp(80px, 15vw, 120px); aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center; padding: 8px; }
#servicios .about__media img { width: 100%; height: 100%; object-fit: contain; }
#servicios .about__content { flex: 1; }
#servicios .about__row { align-items: flex-start; gap: 16px; }
#servicios .about__stack { max-width: 980px; margin-inline: auto; }
#servicios .about__row { grid-template-columns: auto minmax(0, 640px); justify-content: center; }
#servicios .about__content { max-width: 640px; }

/* Premium fluid animations with blur and scale (ENABLED) */
.animate-on-scroll {
  opacity: 0;
  filter: blur(6px);
  transform: translateY(28px) scale(0.98);
  transition: opacity .9s ease, transform .9s ease, filter .9s ease;
}
.animate-on-scroll.is-visible {
  opacity: 1;
  filter: none;
  transform: none;
}

/* Support elements marked by JS with .will-reveal */
.will-reveal {
  opacity: 0;
  filter: blur(6px);
  transform: translateY(28px) scale(0.98);
  transition: opacity .9s ease, transform .9s ease, filter .9s ease;
}
.will-reveal.is-visible {
  opacity: 1;
  filter: none;
  transform: none;
}

/* Sequential staggered delays for fluid appearance */
.animate-on-scroll:nth-child(1), .will-reveal:nth-child(1) { transition-delay: 0.4s; }
.animate-on-scroll:nth-child(2), .will-reveal:nth-child(2) { transition-delay: 0.9s; }
.animate-on-scroll:nth-child(3), .will-reveal:nth-child(3) { transition-delay: 1.4s; }
.animate-on-scroll:nth-child(4), .will-reveal:nth-child(4) { transition-delay: 1.9s; }
.animate-on-scroll:nth-child(5), .will-reveal:nth-child(5) { transition-delay: 2.4s; }

/* Premium section titles with blur effect */
.section__title {
  opacity: 0;
  filter: blur(6px);
  transform: translateY(18px);
  transition: opacity .9s ease, transform .9s ease, filter .9s ease;
}
.section__title.is-visible {
  opacity: 1;
  filter: none;
  transform: none;
}

/* Page load animations - ENABLED */
.fade-in-page {
  opacity: 0;
  animation: fadeUp .9s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); filter: blur(3px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* Sequential page load delays */
.fade-in-page:nth-child(1) { animation-delay: 0.2s; }
.fade-in-page:nth-child(2) { animation-delay: 0.4s; }
.fade-in-page:nth-child(3) { animation-delay: 0.6s; }
.fade-in-page:nth-child(4) { animation-delay: 0.8s; }
.fade-in-page:nth-child(5) { animation-delay: 1.0s; }

/* Bounce effect for partner cards */
#colaboradores .animate-on-scroll {
  transform: translateY(60px) scale(0.9) rotateX(15deg);
  transition: opacity 0.9s cubic-bezier(0.34, 1.56, 0.64, 1), 
              transform 0.9s cubic-bezier(0.34, 1.56, 0.64, 1),
              filter 0.6s ease;
}
#colaboradores .animate-on-scroll.is-visible {
  transform: translateY(0) scale(1) rotateX(0deg);
}

/* Loading spinner with AES logo */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.loading-overlay.is-active {
  opacity: 1;
  visibility: visible;
}
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.loading-logo {
  width: 120px;
  height: 120px;
  filter: drop-shadow(0 4px 12px rgba(46, 92, 153, 0.3));
}
.loading-text {
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Dark mode loading overlay */
body.dark .loading-overlay {
  background: rgba(15, 19, 32, 0.95);
}
body.dark .loading-text {
  color: var(--accent);
}

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

/* Project detail page styles */
.page-project .project-header {
  text-align: center;
  margin-bottom: 2rem;
}
.back-link {
  display: inline-flex;
  align-items: center;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 1rem;
  transition: color 0.2s ease;
}
.back-link:hover {
  color: var(--accent);
}
.project-hero {
  margin: 2rem 0;
  display: grid;
  place-items: center;
}
.project-hero__image {
  /* Fill width (stretched to sides) while preserving aspect ratio */
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: none;
  object-fit: contain;
  display: block;
  margin-inline: auto;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  background: var(--bg-alt);
}
:root.dark .project-hero__image { background: #0f172a; }
.project-info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
  margin: 3rem 0;
  align-items: start;
}
.page-project .project-info { grid-template-columns: 1fr; justify-items: center; }
.project-stats {
  display: flex;
  gap: 2rem;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}
.stat {
  text-align: center;
  padding: 1rem;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  min-width: 120px;
}
.stat__number {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}
.stat--prefixed-plus .stat__number::before {
  content: "+";
  margin-right: 2px;
  color: var(--primary);
}
.stat__label {
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Department layout */
.dept-section {
  margin: 2rem 0;
  padding: 1.2rem;
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.dept-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin-top: 1.5rem;
}

/* Virtual tour container */
.dept-tour-container {
  position: relative;
}
.dept-tour {
  aspect-ratio: 4/3;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  position: relative;
}
.virtual-tour {
  width: 100%;
  height: 100%;
  border: none;
}

/* Gallery indicator */
.gallery-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  z-index: 10;
}
.gallery-indicator:hover {
  background: rgba(0, 0, 0, 0.9);
}
.gallery-indicator svg {
  width: 18px;
  height: 18px;
}

/* PDF Gallery overlay */
.dept-pdf-gallery {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  border-radius: 12px;
  padding: 1rem;
  z-index: 20;
  transition: opacity 0.3s ease;
}
.dept-pdf-gallery.hidden {
  display: none;
}
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  color: white;
}
.gallery-header h4 {
  margin: 0;
  font-size: 1.1rem;
}
.gallery-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}
.gallery-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* PDF Carousel styles */
.pdf-carousel {
  position: relative;
  height: calc(100% - 60px);
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
}
.pdf-carousel__track {
  display: flex;
  height: 100%;
  transition: transform 0.3s ease;
}
.pdf-slide {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
}
.pdf-slide canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.pdf-carousel__btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  z-index: 10;
}
.pdf-carousel__btn:hover {
  background: rgba(0, 0, 0, 0.9);
}
.pdf-carousel__btn.prev {
  left: 10px;
}
.pdf-carousel__btn.next {
  right: 10px;
}
.pdf-carousel__dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.pdf-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.pdf-dot.is-active {
  background: white;
}
.pdf-dot:hover {
  background: rgba(255, 255, 255, 0.8);
}

/* Department info */
.dept-info {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.dept-specs {
  display: flex;
  gap: 1rem;
}
.spec {
  display: flex;
  flex-direction: column;
  text-align: center;
  padding: 0.75rem;
  background: var(--bg-alt);
  border-radius: 8px;
  flex: 1;
}
.spec__label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.spec__value {
  font-weight: 600;
  color: var(--primary);
  font-size: 1.1rem;
}
.dept-description-section h4,
.dept-features h4 {
  margin: 0 0 0.75rem 0;
  color: var(--primary);
  font-size: 1.1rem;
}
.dept-description {
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
}
.dept-features ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}
.dept-features li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

/* Secondary button (used for Ver plano) */
.button.button--secondary {
  background: #ffffff;
  color: var(--primary);
  border-color: var(--primary);
}
.button.button--secondary:hover {
  background: color-mix(in srgb, var(--primary) 10%, #fff);
}

/* Image modal */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-modal.hidden {
  display: none;
}
.image-modal__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(4px);
}
.image-modal__content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.image-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 10;
  transition: background-color 0.2s ease;
}
.image-modal__close:hover {
  background: rgba(0, 0, 0, 0.9);
}
.image-modal__image {
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}
.image-modal__caption {
  padding: 1rem;
  margin: 0;
  color: var(--muted);
  text-align: center;
  background: var(--card);
}

/* Responsive design */
@media (max-width: 900px) {
  .project-info {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .project-stats {
    flex-direction: row;
    justify-content: center;
  }
  .dept-layout {
    grid-template-columns: 1fr;
  }
  .dept-tour-container {
    max-width: 400px;
    margin: 0 auto;
  }
  .dept-specs {
    flex-wrap: wrap;
  }
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 900px) {
  .page-about .about__row { align-items: start; }
  .page-about .about__media { width: 100%; }
  .page-about .about__media img, .page-about .about__media svg { width: 100%; height: auto; max-height: none; }
}
@media (min-width: 901px) {
  .page-about .about__row { 
    grid-template-columns: 1fr 2fr;
  }
  .page-about .about__media svg {
    width: 60px;
    height: 60px;
  }
}

/* Modal (projects) */
.modal { position: fixed; inset: 0; display: none; z-index: 1000; }
.modal[aria-hidden="false"] { display: block; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }
.modal__dialog { position: relative; background: var(--card); color: var(--text); width: min(1100px, 92%); max-height: 86vh; margin: 6vh auto; border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 24px 60px rgba(0,0,0,.25); display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.modal__header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal__title { margin: 0; font-weight: 800; color: var(--primary); }
.modal__close { position: absolute; top: 10px; right: 10px; border: 1px solid var(--border); background: var(--card); color: var(--text); width: 36px; height: 36px; border-radius: 999px; cursor: pointer; }
.modal__body { padding: 12px 16px; overflow: auto; }
.modal__footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

/* Tabs */
.tabs { display: inline-flex; gap: 6px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 999px; padding: 4px; }
.tab { border: 0; background: transparent; color: var(--text); padding: 8px 12px; border-radius: 999px; cursor: pointer; font-weight: 600; }
.tab.is-active { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary-contrast); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* Lists inside modal */
.list { display: grid; gap: 12px; }
.list__item { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.list__item a { color: var(--primary); word-break: break-all; }
.video-embed { aspect-ratio: 16/9; width: 100%; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #000; height: 60vh; }
.pdf-embed { width: 100%; height: 60vh; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.tour-embed { width: 100%; height: 60vh; border: 1px solid var(--border); border-radius: 10px; }

/* Embed section layout (proyectos.php) */
.embed-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, 1fr); }
.embed-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.embed-card--full { grid-column: 1 / -1; }
@media (max-width: 900px){ .embed-grid { grid-template-columns: 1fr; } }

/* Department selector (pills) */
.dept-toc { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 18px; position: static; z-index: auto; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: none; padding: 10px; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.06); }
.dept-toc .dept-toc-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.dept-toc .pill.is-active { background: linear-gradient(90deg, var(--primary) 0%, var(--teal) 100%); color: #fff; border-color: transparent; }
@media (max-width: 720px){ .dept-toc { top: 58px; padding: 8px; } }
/* Dark mode: container and pill defaults for department index */
/* support when .dark is applied on <html> or <body> */
:root.dark .dept-toc, html.dark .dept-toc, body.dark .dept-toc { background: #0f172a; border-color: #263247; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
:root.dark .dept-toc .pill, html.dark .dept-toc .pill, body.dark .dept-toc .pill { background: #1f2a36; color: #e5eef6; border-color: #2a3a4a; box-shadow: none; }
:root.dark .dept-toc .pill:hover, html.dark .dept-toc .pill:hover, body.dark .dept-toc .pill:hover { background: color-mix(in srgb, var(--primary) 18%, #1f2a36); color: #ffffff; border-color: color-mix(in srgb, var(--primary) 60%, #2a3a4a); }
.pill { display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--text); font-weight: 700; letter-spacing: .2px; box-shadow: 0 2px 8px rgba(0,0,0,.04); transition: background .2s ease, color .2s ease, border-color .2s ease, transform .12s ease; }
.pill:hover { background: color-mix(in srgb, var(--primary) 8%, #fff); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); color: var(--primary); }
.pill:active { transform: translateY(1px); }
.pill.is-active { background: linear-gradient(90deg, #2e5c99 0%, #1bb2a9 100%); color: #fff; border-color: transparent; box-shadow: 0 4px 14px rgba(30, 100, 140, .25); }
.pill:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, #000); outline-offset: 2px; }

/* Dark mode for pills */
:root.dark .pill { background: #1f2a36; color: #e5eef6; border-color: #2a3a4a; box-shadow: none; }
:root.dark .pill:hover { background: color-mix(in srgb, var(--primary) 18%, #1f2a36); color: #ffffff; border-color: color-mix(in srgb, var(--primary) 60%, #2a3a4a); }
:root.dark .pill.is-active { background: linear-gradient(90deg, var(--primary) 0%, var(--teal) 100%); color: #fff; border-color: transparent; }

/* Dark mode: stronger readability for key headings and values */
body.dark .section__title { color: #fff; }
body.dark .dept-description-section h4 { color: #fff; }
body.dark .spec__value { color: #fff; }
/* Improve secondary text legibility in dark */
body.dark .section__subtitle,
body.dark .muted { color: #c9d3df; }

/* Ensure header links and brand name remain white in dark */
body.dark .nav a { color: #fff; }
body.dark .brand__name { color: #fff; }

/* Dark mode: secondary button (e.g., Ver plano) improved contrast */
body.dark .button.button--secondary {
  background: #1a2438;
  color: #fff;
  border-color: #3a83ff;
}
body.dark .button.button--secondary:hover {
  background: #223150;
}

/* Dark mode: active dept pill within the index with subtle emphasis */
body.dark .dept-toc .pill.is-active {
  background: color-mix(in srgb, #ffffff 14%, transparent);
  color: #fff;
  border-color: color-mix(in srgb, #ffffff 24%, transparent);
}
body.dark .dept-toc .pill:hover {
  background: color-mix(in srgb, #ffffff 10%, transparent);
}

/* Footer readability tweaks in dark mode */
body.dark .footer-contact { background: rgba(255, 255, 255, 0.10); border: 1px solid color-mix(in srgb, #ffffff 12%, transparent); }
body.dark .social-icons a { color: #fff; }
body.dark .social-icons a:hover { color: #ffd700; }

/* Micro responsive tweaks */
@media (max-width: 720px) {
  .dept-section { margin: 1.2rem 0; padding: 1rem; }
  .virtual-tour { height: auto; min-height: 240px; }
}

/* Prevent overly tall tours on large screens */
.dept-tour { max-height: 60vh; }

/* Slightly reduce stagger for better perceived performance */
.animate-on-scroll:nth-child(2) { transition-delay: 0.6s; }
.animate-on-scroll:nth-child(3) { transition-delay: 0.9s; }
.animate-on-scroll:nth-child(4) { transition-delay: 1.2s; }
/* PDF carousel */
.pdf-carousel { position: relative; border: 1px solid var(--border); border-radius: 12px; padding: 8px; background: var(--bg); }
.pdf-carousel { height: 60vh; overflow: hidden; box-sizing: border-box; }
.pdf-carousel__viewport { overflow: hidden; border-radius: 8px; }
.pdf-carousel__track { display: flex; transition: transform .5s ease; will-change: transform; }
.pdf-slide { min-width: 100%; display: grid; place-items: center; background: #fff; }
.pdf-slide canvas { max-width: 100%; max-height: 100%; display: block; }
.pdf-carousel__btn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; border: 0; width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; cursor: pointer; color: var(--text); background: color-mix(in srgb, var(--primary) 16%, #ffffff); box-shadow: var(--shadow); }
.pdf-carousel__btn:hover { filter: brightness(0.98); }
.pdf-carousel__btn.prev { left: 8px; }
.pdf-carousel__btn.next { right: 8px; }
.pdf-carousel__dots { display: flex; justify-content: center; gap: 8px; padding: 8px 0 0; }
.pdf-dot { width: 10px; height: 10px; border-radius: 999px; background: #d9e1ea; border: 1px solid var(--border); cursor: pointer; }
.pdf-dot.is-active { background: var(--accent); }
.dept-desc { display: grid; gap: 6px; color: var(--text); }

/* Modern Footer (shared) */
.footer-modern { 
  position: relative; 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  gap: 20px; 
  padding: 50px clamp(16px, 6vw, 80px); 
  color: #fff; 
  background: transparent; /* remove old background image */
}
.footer-modern::before { 
  content: ""; position: absolute; inset: 0; 
  background: linear-gradient(90deg, rgba(36,90,155,0.9), rgba(61,185,167,0.9)); 
  z-index: 0; 
}
.footer-modern::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url('https://aes-srl.com/360/edificios-altos-silueta-aislados-sobre-fondo-blanco_146105-25922-Photoroom.png') no-repeat center center / 55% auto;
  opacity: 0.12; /* highly subtle by default */
  filter: sepia(1) saturate(350%) hue-rotate(130deg) brightness(0.9);
  z-index: 0;
  pointer-events: none;
}
.footer-modern > * { position: relative; z-index: 1; }
.footer-logo { text-align: center; max-width: 250px; }
.footer-logo img { width: 160px; height: auto; display: block; margin: 0 auto 12px; }
.footer-logo p { margin: 0; font-size: 14px; }
.footer-center { flex: 1; text-align: center; }
.footer-phrase { 
  font-family: 'Great Vibes', cursive; 
  font-size: clamp(24px, 4.2vw, 34px); 
  font-weight: 500; line-height: 1.6; color: #fff; 
  text-shadow: none; 
}
.social-icons { display: flex; gap: 16px; justify-content: center; margin-top: 10px; }
.social-icons a { color: #fff; font-size: 30px; transition: color .25s ease, transform .2s ease; }
.social-icons a:hover { color: #ffd700; transform: translateY(-2px); }
.footer-contact { background: rgba(255, 255, 255, 0.12); padding: 18px 22px; border-radius: 14px; max-width: 320px; }
.footer-contact p { margin: 12px 0; font-size: 15px; display: flex; align-items: center; gap: 12px; }
.footer-contact i { font-size: 18px; color: #fff; }
@media (max-width: 900px){
  .footer-modern { flex-direction: column; align-items: stretch; text-align: center; }
  .footer-logo { margin-inline: auto; }
  .footer-contact { margin-inline: auto; }
}

/* Slightly reduce skyline on very small screens */
@media (max-width: 900px){ /* tablets */
  .footer-modern::after { background-size: 70% auto; opacity: 0.16; }
}
@media (max-width: 600px){ /* phones */
  .footer-modern::after { background-size: 82% auto; opacity: 0.18; }
}
@media (min-width: 1500px){ /* very large screens */
  .footer-modern::after { background-size: 45% auto; opacity: 0.10; }
}
