/* ============================================================================
   SAFE AMORX - ESTILOS PRINCIPALES
   ============================================================================
   
   Estructura del archivo:
   1. Importación de fuentes
   2. Reset y estilos base
   3. Layout principal (grid home)
   4. Elementos del grid (celdas, tuberías)
   5. Logo section
   6. Contenido dinámico (páginas internas)
   7. Responsive (mobile y tablet)
   
   ============================================================================ */

/* ============================================================================
   1. IMPORTACIÓN DE FUENTES
   ============================================================================ */
@import url("https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700&family=Montserrat:wght@400;500;600;700&family=Work+Sans:wght@400;500;600;700&family=Roboto+Condensed:wght@400;700&display=swap");

/* ============================================================================
   2. RESET Y ESTILOS BASE
   ============================================================================ */

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

/* HTML y body base */
html {
  width: 100%;
  height: 100%;
}

body {
  font-family: Helvetica, Arial, sans-serif;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  z-index: 0;
}

/* Prevenir scroll cuando lightbox está abierto */
body.lightbox-open {
  overflow: hidden;
}

/* Fondo fijo siempre en la capa inferior */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("../assets/images/background.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Home: sin scroll, altura fija */
body.home-page {
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  overflow: hidden;
}

/* ============================================================================
   3. LAYOUT PRINCIPAL (HOME - GRID 70% / 30%)
   ============================================================================ */

.container {
  width: 100%;
  height: 100%;
  display: flex;
}

/* Desktop: layout horizontal (70% grid - 30% logo) */
@media (min-width: 769px) {
  .container {
    flex-direction: row;
  }

  .grid-section {
    width: 70%;
    height: 100%;
  }

  .logo-section {
    width: 30%;
    height: 100%;
  }
}

/* Mobile: layout vertical (65% grid - 40% logo) */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }

  .grid-section {
    width: 100%;
    height: 65%;
  }

  .logo-section {
    width: 100%;
    height: 40%;
  }
}

/* ============================================================================
   4. GRID SECTION (MAPA DE NAVEGACIÓN)
   ============================================================================ */

.grid-section {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.grid-container {
  display: grid;
  gap: 0;
  width: 100%;
  height: 100%;
  contain: layout style paint;
}

/* ============================================================================
   5. CELDAS BASE DEL GRID
   ============================================================================ */

.grid-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  overflow: visible;
  contain: layout style;
}

/* ============================================================================
   6. CELDAS ESPECIALES: HOME Y DESTINOS
   ============================================================================ */

/* Celda HOME - completamente transparente */
.grid-cell.home {
  background-color: transparent;
  border: none;
  z-index: 100;
}

.grid-cell.home .section-label {
  color: var(--map-text-color);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  z-index: 101;
}

/* Celdas DESTINOS - completamente transparentes */
.grid-cell.destination {
  background-color: transparent;
  border: none;
  z-index: 100;
}

.grid-cell.destination a {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--map-text-color);
  font-family: Helvetica, Arial, sans-serif;
  font-size: clamp(0.7rem, 1.5vw, 1.1rem);
  font-weight: 700;
  text-transform: uppercase;
  transition: all 0.3s ease;
  z-index: 101;
}

.grid-cell.destination a:hover {
  transform: scale(1.1);
}

/* ============================================================================
   7. TUBERÍAS - CONFIGURACIÓN GENERAL
   ============================================================================ */

.grid-cell.pipe {
  --pipe-stroke: var(--map-stroke);
  --pipe-color: var(--map-line-color);
  --pipe-fill: linear-gradient(var(--pipe-color), var(--pipe-color));
  /* Usar opacity en vez de rgba evita superposición de alpha en cruces */
  opacity: 0.85;
  background-repeat: no-repeat;
}

/* ============================================================================
   8. TUBERÍAS - RECTAS
   ============================================================================ */

/* Recta horizontal (centrada) */
.pipe-straight-h {
  background: var(--pipe-fill) center / 100% var(--pipe-stroke);
}

/* Recta vertical (centrada) */
.pipe-straight-v {
  background: var(--pipe-fill) center / var(--pipe-stroke) 100%;
}

/* ============================================================================
   9. TUBERÍAS - ESQUINAS (L)
   ============================================================================ */

/* Esquina top-right: conecta right + down */
.pipe-curve-tr {
  background: var(--pipe-fill) right center / 50% var(--pipe-stroke),
    var(--pipe-fill) center bottom / var(--pipe-stroke) 50%;
}

/* Esquina bottom-right: conecta up + right */
.pipe-curve-br {
  background: var(--pipe-fill) right center / 50% var(--pipe-stroke),
    var(--pipe-fill) center top / var(--pipe-stroke) 50%;
}

/* Esquina top-left: conecta left + down */
.pipe-curve-tl {
  background: var(--pipe-fill) left center / 50% var(--pipe-stroke),
    var(--pipe-fill) center bottom / var(--pipe-stroke) 50%;
}

/* Esquina bottom-left: conecta up + left */
.pipe-curve-bl {
  background: var(--pipe-fill) left center / 50% var(--pipe-stroke),
    var(--pipe-fill) center top / var(--pipe-stroke) 50%;
}

/* ============================================================================
   10. TUBERÍAS - FORMA T
   ============================================================================ */

/* T hacia arriba (sin conexión abajo) */
.pipe-t-up {
  background: var(--pipe-fill) center / 100% var(--pipe-stroke),
    var(--pipe-fill) center top / var(--pipe-stroke) 50%;
}

/* T hacia abajo (sin conexión arriba) */
.pipe-t-down {
  background: var(--pipe-fill) center / 100% var(--pipe-stroke),
    var(--pipe-fill) center bottom / var(--pipe-stroke) 50%;
}

/* T hacia izquierda (sin conexión derecha) */
.pipe-t-left {
  background: var(--pipe-fill) center / var(--pipe-stroke) 100%,
    var(--pipe-fill) left center / 50% var(--pipe-stroke);
}

/* T hacia derecha (sin conexión izquierda) */
.pipe-t-right {
  background: var(--pipe-fill) center / var(--pipe-stroke) 100%,
    var(--pipe-fill) right center / 50% var(--pipe-stroke);
}

/* ============================================================================
   11. TUBERÍAS - CRUZ (+)
   ============================================================================ */

.pipe-cross {
  background: var(--pipe-fill) center / 100% var(--pipe-stroke),
    var(--pipe-fill) center / var(--pipe-stroke) 100%;
}

/* ============================================================================
   12. TUBERÍAS - PUNTAS (END CAPS)
   ============================================================================ */

/* Punta hacia derecha */
.pipe-end-right {
  background: var(--pipe-fill) right center / 50% var(--pipe-stroke);
}

/* Punta hacia izquierda */
.pipe-end-left {
  background: var(--pipe-fill) left center / 50% var(--pipe-stroke);
}

/* Punta hacia abajo */
.pipe-end-down {
  background: var(--pipe-fill) center bottom / var(--pipe-stroke) 50%;
}

/* Punta hacia arriba */
.pipe-end-up {
  background: var(--pipe-fill) center top / var(--pipe-stroke) 50%;
}

/* ============================================================================
   13. LOGO SECTION
   ============================================================================ */

.logo-section {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.logo {
  width: 100%;
  height: 100%;
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
  filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.3));
}

/* ============================================================================
   14. VARIABLES CSS PARA CONTENIDO DINÁMICO
   ============================================================================ */

:root {
  /* Fuentes */
  --font-headings: "Roboto Condensed", "Roboto", Arial, sans-serif;
  --font-paragraphs: Helvetica, Arial, sans-serif;

  /* Colores de texto */
  --color-text-primary: #fff;
  --color-text-secondary: #ccc;

  /* Colores del mapa (home) */
  --map-text-color: #00ff88;
  --map-line-color: #111;
  --map-stroke: 5px;

  /* Espaciado de contenido */
  --spacing-section: 6rem;
  --spacing-paragraph: 1.1rem;
  --spacing-paragraph-break: 2rem;
}

/* ============================================================================
   15. PÁGINAS INTERNAS - LAYOUT
   ============================================================================ */

body.content-page {
  overflow-y: auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.page-content {
  width: 100%;
  max-width: 980px;
  margin: 50dvh auto 70dvh;
  padding: clamp(2rem, 4vw, 3.2rem) clamp(1rem, 3vw, 2.2rem) 1.6rem;
  text-align: left;
  position: relative;
}

.page-content h1 {
  font-family: var(--font-headings);
  font-size: clamp(2.4rem, 7vw, 4rem);
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 24px;
}

/* ============================================================================
   16. SECCIONES DE CONTENIDO
   ============================================================================ */

.content-section {
  margin-bottom: var(--spacing-section);
}

.content-section:last-child {
  margin-bottom: 0;
}

.content-section.is-empty {
  text-align: center;
}

body.content-page[data-category="blog"] .content-section {
  margin-bottom: calc(var(--spacing-section) * 1.9);
}

body.content-page[data-category="blog"] .content-section:last-child {
  margin-bottom: 0;
}

.content-section h2 {
  font-family: var(--font-headings);
  font-size: 4rem;
  font-weight: 300;
  color: var(--color-text-primary);
  margin-bottom: 1.5rem;
  text-align: left;
  text-transform: uppercase;
  line-height: 1.2;
}

.content-section h3 {
  font-family: var(--font-headings);
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 1.2rem;
  line-height: 1.3;
}

.content-section p {
  font-family: var(--font-paragraphs);
  font-size: clamp(1rem, 2vw, 1.15rem);
  font-weight: 400;
  color: var(--color-text-secondary);
  line-height: 1.7;
  margin-bottom: var(--spacing-paragraph);
}

.content-section p:last-child {
  margin-bottom: 0;
}

.content-section p + :not(p) {
  margin-top: var(--spacing-paragraph-break);
}

/* ============================================================================
   17. BLOQUES DE CONTENIDO
   ============================================================================ */

.content-block {
  --block-paragraph-indent: 0;
}

.content-block + .content-block {
  margin-top: var(--spacing-paragraph-break);
}

.content-block-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.content-block-header h3 {
  margin-bottom: 0;
}

/* ============================================================================
   18. PÁRRAFOS DESPLEGABLES (COLLAPSIBLE)
   ============================================================================ */

/* Botón de toggle */
.block-toggle {
  border: none;
  background: transparent;
  color: #ffffff;
  font-family: var(--font-paragraphs);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  transform: rotate(-90deg);
}

.content-block:not(.is-collapsed) .block-toggle {
  transform: rotate(90deg);
}

.block-toggle:hover {
  opacity: 0.85;
}

.block-toggle:focus-visible {
  outline: 2px solid var(--map-text-color);
  outline-offset: 2px;
}

/* Contenedor de párrafos con animación mejorada */
.content-paragraphs {
  max-height: var(--content-max-height, 9999px);
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease,
    transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.content-block.is-collapsed .content-paragraphs {
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

/* Sangría de párrafos (solo desktop) */
.content-paragraphs p {
  margin-left: var(--block-paragraph-indent);
}

.content-paragraphs a {
  color: var(--map-text-color);
  text-decoration: none;
}

.content-paragraphs a:hover {
  opacity: 0.85;
}

/* ============================================================================
   19. IMÁGENES
   ============================================================================ */

.images-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.2rem;
  margin-top: 2rem;
}

.image-item {
  border: none;
  background: transparent;
  padding: 0;
  cursor: zoom-in;
}

.image-item:focus-visible {
  outline: 2px solid var(--map-text-color);
  outline-offset: 4px;
}

.image-thumb {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* ============================================================================
   20. LIGHTBOX (MODAL DE IMÁGENES)
   ============================================================================ */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1000;
}

.lightbox.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-image {
  max-width: min(92vw, 1200px);
  max-height: 90vh;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* ============================================================================
   21. LOGOS
   ============================================================================ */

.logos-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 2rem;
  align-items: center;
  justify-content: flex-start;
}

.logos-container a {
  display: inline-block;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.logos-container a:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

.logo-item {
  max-width: 200px;
  max-height: 100px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

/* ============================================================================
   22. ENLACES DE NAVEGACIÓN
   ============================================================================ */

.back-link {
  font-family: var(--font-paragraphs);
  font-size: clamp(1.2rem, 2.8vw, 1.7rem);
  color: var(--map-text-color);
  text-decoration: none;
  padding: 0 0 5rem;
  position: absolute;
  left: 50%;
  bottom: -70dvh;
  --home-shift: 0px;
  transform: translate(-50%, 0) translateX(var(--home-shift));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  transition: transform 0.35s ease;
}

.back-link-logo {
  max-width: 420px;
  max-height: 200px;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

.back-link:focus-visible {
  --home-shift: 8px;
  outline: 2px solid var(--map-text-color);
  outline-offset: 4px;
}

.about-web-link {
  position: absolute;
  right: 50%;
  bottom: -70dvh;
  transform: translate(50%, 0);
  padding: 0 0 3rem;
  font-family: var(--font-paragraphs);
  font-size: clamp(0.75rem, 1.8vw, 0.95rem);
  color: white;
  text-decoration: none;
  letter-spacing: 0.02em;
  opacity: 0.8;
  transition: opacity 0.3s ease;
}

.about-web-link:hover {
  opacity: 1;
}

.about-web-link:focus-visible {
  outline: 2px solid var(--map-line-color);
  outline-offset: 3px;
}

.load-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 2.5rem auto 0;
  padding: 0.7rem 1.6rem;
  border: 1px solid var(--map-text-color);
  border-radius: 999px;
  background: transparent;
  color: var(--map-text-color);
  font-family: var(--font-paragraphs);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.load-more-btn:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.load-more-btn:focus-visible {
  outline: 2px solid var(--map-text-color);
  outline-offset: 3px;
}

/* ============================================================================
   23. RESPONSIVE - MÓVIL
   ============================================================================ */

@media (max-width: 768px) {
  /* Ajustar variables de espaciado */
  :root {
    --spacing-section: 2.7rem;
    --spacing-paragraph: 0.95rem;
    --spacing-paragraph-break: 1.6rem;
    --map-stroke: 3px;
  }

  /* Ajustar grid section */
  .grid-section {
    padding: 6px;
  }

  .grid-cell.home .section-label,
  .grid-cell.destination a {
    font-size: 1rem;
  }

  /* Ajustar contenido */
  .page-content {
    max-width: 100%;
    padding: 1rem 0.8rem 1.2rem;
  }

  .page-content h1 {
    margin-bottom: 18px;
  }

  .content-section h3 {
    margin-bottom: 0.9rem;
  }

  .content-block-header {
    margin-bottom: 0.9rem;
  }

  /* Ajustar logos */
  .logos-container {
    gap: 1rem;
    margin-top: 1.5rem;
  }

  .logo-item {
    max-width: 120px;
    max-height: 70px;
  }

  /* Ajustar imágenes */
  .images-container {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.9rem;
    margin-top: 1.5rem;
  }

  /* Ajustar enlaces */
  .back-link {
    margin-top: 0;
    margin-bottom: 0;
  }

  /* ========================================================================
       OCULTAR SANGRÍA EN MÓVIL
       ======================================================================== */
  .content-paragraphs p {
    margin-left: 0 !important;
  }

  .content-block {
    --block-paragraph-indent: 0 !important;
  }
}

/* ============================================================================
   24. ACCESIBILIDAD - REDUCCIÓN DE MOVIMIENTO
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  .content-paragraphs,
  .block-toggle,
  .back-link {
    transition: none;
    animation: none;
  }
}
