/* LOGO MARK */
.logo-mark {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
}

/* VARIABLES Y PALETA DE COLORES */
:root {
  --gold: #c9a96e;
  --gold-light: #e8d5a8;
  --gold-dark: #8b6f3f;
  --ink: #0a0a0a;
  --cream: #f5f1ea;
  --focus-ring: #c9a96e;

  /* Safe area para iPhone con notch */
  --safe-area-inset-top: env(safe-area-inset-top);
  --safe-area-inset-bottom: env(safe-area-inset-bottom);
  --safe-area-inset-left: env(safe-area-inset-left);
  --safe-area-inset-right: env(safe-area-inset-right);
}

/* RESET GENERAL Y ACCESIBILIDAD */
* {
  box-sizing: border-box;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--cream);
  color: var(--ink);
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;

  /* Safe area para iPhone */
  padding-top: var(--safe-area-inset-top);
  padding-bottom: var(--safe-area-inset-bottom);
  padding-left: var(--safe-area-inset-left);
  padding-right: var(--safe-area-inset-right);

  /* Altura dinámica body */
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

.font-serif {
  font-family: 'Playfair Display', serif;
}

/* ENLACE DE SALTO (SKIP TO CONTENT) WCAG */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: 20px;
  background-color: var(--gold);
  color: #000;
  padding: 12px 24px;
  font-weight: bold;
  border-radius: 4px;
  z-index: 9999;
  transition: top 0.3s ease;
  font-size: 14px;
}

.skip-to-content:focus {
  top: 20px;
  outline: 3px solid #000;
}

/* ACCESIBILIDAD: FOCUS VISIBLE */
.focus-visible-ring:focus {
  outline: none;
}

.focus-visible-ring:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

/* NAVBAR SCROLL GLASSMORPHISM */
.nav-scrolled {
  background: rgba(10, 10, 10, 0.9) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid rgba(201, 169, 110, 0.2);
}

.nav-link-active {
  color: var(--gold) !important;
  font-weight: 700;
  border-bottom: 2px solid var(--gold);
}

/* ANIMACIONES INTERSECTION OBSERVER */
.fade-up {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.25, 1, 0.5, 1), transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
}

.fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

.slide-left {
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity 0.9s cubic-bezier(0.25, 1, 0.5, 1), transform 0.9s cubic-bezier(0.25, 1, 0.5, 1);
}

.slide-left.visible {
  opacity: 1;
  transform: translateX(0);
}

.slide-right {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.9s cubic-bezier(0.25, 1, 0.5, 1), transform 0.9s cubic-bezier(0.25, 1, 0.5, 1);
}

.slide-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* MARQUEE INFINITO */
.marquee {
  overflow: hidden;
  white-space: nowrap;
}

.marquee-content {
  display: inline-block;
  animation: scroll 30s linear infinite;
}

@keyframes scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .marquee-content {
    animation: none;
    overflow-x: auto;
    white-space: normal;
  }
  * {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-delay: 0 !important;
  }
}

/* PARALLAX HERO */
.hero {
  background-attachment: scroll;
}

/* WHATSAPP WIDGET Y BOTÓN FLOTANTE */
.float-wa {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #25D366;
  box-shadow: 0 8px 25px rgba(37, 211, 102, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: pulse-wa 2s infinite;
}

.float-wa:hover {
  transform: scale(1.08);
}

@keyframes pulse-wa {
  0%, 100% { box-shadow: 0 8px 25px rgba(37, 211, 102, 0.4); }
  50% { box-shadow: 0 8px 35px rgba(37, 211, 102, 0.7); }
}

.whatsapp-btn {
  background-color: #25D366;
  transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

.whatsapp-btn:hover {
  background-color: #1ea952;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.3);
}

/* ACABADOS DE MADERA HOVER Y SELECCIÓN */
.wood-card {
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.4s cubic-bezier(0.25, 1, 0.5, 1), border-color 0.3s ease;
  border: 2px solid transparent;
}

.wood-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.3);
}

.wood-card.active-card {
  border-color: var(--gold);
  transform: scale(1.03);
  box-shadow: 0 0 15px rgba(201, 169, 110, 0.4);
}

/* TARJETAS DE MATERIALES */
.material-card {
  transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.5s cubic-bezier(0.25, 1, 0.5, 1);
  overflow: hidden;
}

.material-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}

.material-card:hover .material-img {
  transform: scale(1.06);
}

.material-img {
  transition: transform 0.7s cubic-bezier(0.25, 1, 0.5, 1);
}

/* SKELETON LOADER ANIMATION */
.skeleton-loader {
  background: linear-gradient(90deg, #1f1f1f 25%, #2a2a2a 50%, #1f1f1f 75%);
  background-size: 200% 100%;
  animation: loading-skeleton 1.5s infinite;
}

@keyframes loading-skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* EFECTOS DE OFICINAS */
.office-card {
  background: white;
  border-top: 4px solid var(--gold);
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.office-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

/* INPUTS DE FORMULARIO ANIMADOS (FLOATING LABELS) */
.form-input:focus ~ .form-label,
.form-input:not(:placeholder-shown) ~ .form-label {
  transform: translateY(-1.4rem) scale(0.85);
  color: var(--gold-dark);
  font-weight: 600;
  background-color: transparent;
  padding: 0 4px;
}

.form-label {
  transform-origin: left top;
  transition: transform 0.2s ease, color 0.2s ease;
  z-index: 10;
}

/* EFECTO HOVER EN LISTA DE SOLUCIONES */
.solution-item {
  transition: background-color 0.3s ease, transform 0.3s ease;
}

.solution-item:hover {
  background: rgba(201, 169, 110, 0.07);
  transform: translateX(6px);
}

/* PERSONALIZACIÓN DE SCROLLBAR */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--cream);
}

::-webkit-scrollbar-thumb {
  background: var(--gold-dark);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

/* ==============================================================================
   OPTIMIZACIONES MÓVILES Y RESPONSIVE (MOBILE-FIRST & TOUCH-FRIENDLY)
   ============================================================================== */

/* FUENTE PARA CHINO SIMPLIFICADO CONDICIONAL */
[lang="zh-CN"] body {
  font-family: 'Noto Sans SC', 'Inter', sans-serif;
  line-height: 1.8;
}

/* PREVENCIÓN DE SCROLL EN BODY CUANDO EL MENÚ ESTÁ ABIERTO */
.mobile-menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
  height: 100%;
}

/* BOTÓN DE LLAMADA FLOTANTE MÓVIL */
#float-call-btn {
  background-color: var(--gold);
  color: #000000;
  box-shadow: 0 8px 25px rgba(201, 169, 110, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: pulse-call 2s infinite;
}

#float-call-btn:hover {
  transform: scale(1.08);
}

@keyframes pulse-call {
  0%, 100% { box-shadow: 0 8px 25px rgba(201, 169, 110, 0.4); }
  50% { box-shadow: 0 8px 35px rgba(201, 169, 110, 0.7); }
}

/* AJUSTES RESPONSIVE Y TOUCH-FRIENDLY EN MÓVIL */
@media (max-width: 768px) {
  /* WCAG 2.1 AA: Área táctil mínima de 44x44px */
  a, button, select, input, textarea {
    min-height: 44px;
  }

  /* Formulario con inputs grandes y espaciados */
  .form-input {
    min-height: 48px;
    font-size: 16px !important; /* Previene el zoom automático de iOS */
  }
  
  /* Enlaces del panel móvil (drawer) */
  #mobileMenu a {
    min-height: 48px;
    display: flex;
    align-items: center;
  }

  /* Botones del selector de idioma móvil */
  #btn-lang-es-mobile, #btn-lang-en-mobile, #btn-lang-zh-mobile {
    min-height: 44px;
    min-width: 65px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* WhatsApp widget agentes más grandes */
  #wa-agents-list a {
    min-height: 52px;
    padding: 12px !important;
  }

  /* Galería de acabados */
  .wood-card {
    min-height: 100px;
  }

  /* Tipografía y legibilidad bajo el sol (contraste alto) */
  body {
    font-size: 16px;
    line-height: 1.6;
  }

  /* Escalar encabezados del Hero */
  .hero h1 {
    font-size: 2.75rem !important;
    line-height: 1.1 !important;
  }

  .hero p {
    font-size: 1.05rem !important;
    line-height: 1.6 !important;
  }

  /* Modal Lightbox a pantalla completa en móvil */
  #material-lightbox > div {
    max-height: 100vh !important;
    max-height: 100dvh !important;
    max-height: -webkit-fill-available !important;
    height: 100% !important;
    width: 100% !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 1.5rem !important;
  }
}

/* AJUSTES DE GRID POR BREAKPOINTS */
@media (max-width: 1024px) {
  /* Oficinas y materiales a 1 columna */
  #oficinas .grid, #materiales .grid {
    grid-template-columns: 1fr !important;
  }

  /* Footer en columnas apiladas */
  footer .grid {
    grid-template-columns: 1fr !important;
    gap: 3rem !important;
  }
}

/* MENÚ MÓVIL DRAWER Y OVERLAY */
#mobileMenuOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 40;
  transition: opacity 0.3s ease;
}

#mobileMenu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 300px;
  max-width: 85vw;
  background-color: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(201, 169, 110, 0.2);
  z-index: 50;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}

/* Modificadores de estado del menú móvil */
#mobileMenuOverlay.hidden {
  display: none;
}

#mobileMenuOverlay.opacity-0 {
  opacity: 0;
}

#mobileMenuOverlay.opacity-100 {
  opacity: 1;
}

#mobileMenu.menu-closed {
  transform: translateX(100%);
}

#mobileMenu.menu-open {
  transform: translateX(0);
}

/* ESTILOS DEL BOTÓN FLOTANTE "LLAMAR AHORA" */
#float-call-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 90;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--gold);
  color: #000000;
  box-shadow: 0 8px 25px rgba(201, 169, 110, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: pulse-call 2s infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}

#float-call-btn:hover {
  transform: scale(1.08);
}

@keyframes pulse-call {
  0%, 100% { box-shadow: 0 8px 25px rgba(201, 169, 110, 0.4); }
  50% { box-shadow: 0 8px 35px rgba(201, 169, 110, 0.7); }
}

/* Ocultar botón de llamada flotante en pantallas grandes */
@media (min-width: 1025px) {
  #float-call-btn {
    display: none !important;
  }
}

/* RESPETAR SALTOS DE LÍNEA DE TRADUCCIÓN EN TEXTO PLANO PARA TODOS LOS ELEMENTOS CON \n */
[data-i18n="hero_new_title"],
[data-i18n="about_title"],
[data-i18n="woods_title"],
[data-i18n="solutions_title"],
[data-i18n="materials_title"],
[data-i18n="com_title"],
[data-i18n^="off_address"] {
  white-space: pre-line;
}

/* Ocultar botón hamburguesa en desktop */
@media (min-width: 1025px) {
  #menuBtn {
    display: none !important;
  }
}

/* Mostrar botón hamburguesa solo en móvil/tablet */
@media (max-width: 1024px) {
  #menuBtn {
    display: flex !important;
  }
}

/* Forzar renderizado de fuentes en iOS Safari y adaptaciones de layout */
@supports (-webkit-touch-callout: none) {
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  /* Sticky position en iOS Safari */
  #navbar {
    position: -webkit-sticky;
    position: sticky;
  }
  
  #float-call-btn,
  .float-call-btn,
  .float-wa {
    position: -webkit-sticky;
    position: sticky;
  }
  
  /* Asegurar que la fuente china se cargue en iOS */
  [lang="zh-CN"] body,
  [lang="zh-CN"] * {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Heiti SC', sans-serif !important;
    -webkit-font-smoothing: antialiased;
  }
  
  /* Fix para white-space en iOS */
  [data-i18n^="off_address"] {
    white-space: pre-line !important;
    word-wrap: break-word;
  }
}

/* Altura de inicio dinámica */
#inicio {
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

/* Ajustar header fijo para safe area */
#navbar {
  top: var(--safe-area-inset-top);
}

/* Ajustar botones flotantes para safe area inferior */
#float-call-btn,
.float-call-btn,
.float-wa {
  bottom: calc(20px + var(--safe-area-inset-bottom)) !important;
}

/* Prevenir overscroll bounce en iOS */
html {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

body {
  overscroll-behavior: none;
}

/* Asegurar contraste en iOS (modo oscuro/claro) */
@media (prefers-color-scheme: dark) {
  body {
    color-scheme: dark;
  }
}

@media (prefers-color-scheme: light) {
  body {
    color-scheme: light;
  }
}

/* Fallback de backdrop-filter para iOS Safari */
#navbar.nav-scrolled {
  background: rgba(10, 10, 10, 0.95);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

#mobileMenu {
  background: rgba(0, 0, 0, 0.95);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* Forzar visibilidad de textos en iOS */
[data-i18n] {
  visibility: visible !important;
  opacity: 1 !important;
}

/* --- SECCIÓN ESTRATÉGICA DE MARCA (LEGADO) --- */
#legacy {
  scroll-margin-top: 80px;
}

.legacy-grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}
@media (min-width: 768px) {
  .legacy-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.legacy-card {
  background-color: var(--cream);
  border: 1px solid rgba(201, 169, 110, 0.3);
  padding: 2.5rem;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}
.legacy-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}
.legacy-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.05);
  border-color: var(--gold);
}
.legacy-card:hover::before {
  transform: scaleX(1);
}

.division-card {
  background: #0d0d0d;
  border: 1px solid rgba(201, 169, 110, 0.15);
  padding: 2rem;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.division-card:hover {
  border-color: var(--gold);
  background: #121212;
  transform: scale(1.02);
}

.const-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}
@media (min-width: 768px) {
  .const-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

.const-item {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.const-number {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
  opacity: 0.8;
}

[data-i18n="legacy_philo_highlight"],
[data-i18n="legacy_code_highlight"],
[data-i18n="legacy_cause_highlight"] {
  white-space: pre-line;
}
