/* Base resets and typography */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background-image: url('../images/backgrounds/bg_3.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Prevent horizontal scrolling */
html, body { max-width: 100%; overflow-x: hidden; }

/* Header and navigation */
.site-header { padding: 1rem 1rem 0.5rem; }
#title_div_1 { text-align: center; }
#buttons_div_1 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.5rem 1rem 1rem;
}

/* Mobile menu toggle */
.nav-toggle { display: none; }
.nav-toggle-label {
    display: none;
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    position: relative;
}
.nav-toggle-label span,
.nav-toggle-label::before,
.nav-toggle-label::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: #333;
    border-radius: 2px;
}
.nav-toggle-label span { top: 50%; transform: translateY(-50%); }
.nav-toggle-label::before { top: 6px; }
.nav-toggle-label::after { bottom: 6px; }

.nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Title slight styling */
#title_1 {
    letter-spacing: 1px;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.08);
}

/* Buttons attributes */
.button {
    padding: 10px 20px;
    margin: 0 5px;
    border: none;
    cursor: pointer;
    background-color: #ccc;
    border-radius: 5px;
    transition: 0.3s;
}
.button:hover { background-color: #666; color: #fff; }

/* Gallery items */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding: 20px;
    max-width: 1000px;
    width: 100%;
}
.gallery-item {
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}
.gallery-item:hover {
    transform: scale(1.05);
}
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#button_10 {
    img {
        width: 200px;
        height: 200px;
        margin-right: 10px;
    }
    span {
       display: inline-block;
    }
}

#body1 {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Galería */
.gallery-container {
  max-width: 1200px;
  margin: auto;
  padding: 20px;
}

.gallery-filters {
  text-align: center;
  margin-bottom: 20px;
}

.filter-btn {
  padding: 10px 20px;
  margin: 0 5px;
  border: none;
  cursor: pointer;
  background-color: #ccc;
  border-radius: 5px;
  transition: 0.3s;
}

.filter-btn.active,
.filter-btn:hover {
  background-color: #666;
  color: #fff;
}

/* --- Extra spacing for buttons inside content tables --- */
#content_table_1 td .button,
#content_table_2 td .button,
body > table td .button {
  margin: 6px 0;            /* separa un poco los botones dentro de tablas */
  display: inline-block;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
}

/* Ajuste para que todas las imágenes se vean iguales */
.gallery-grid img {
  width: 100%;
  height: 200px;           /* Altura fija para todas */
  object-fit: cover;       /* Recorta sin deformar */
  cursor: pointer;
  transition: transform 0.3s;
  border-radius: 5px;
}

.gallery-grid img:hover {
  transform: scale(1.05);
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  z-index: 9999;
  padding-top: 60px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.9);
}

.lightbox-img {
  margin: auto;
  display: block;
  max-width: 90%;
  max-height: 80%;
  border-radius: 5px;
}

.close {
  position: absolute;
  top: 30px;
  right: 40px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.3s;
}

.close:hover {
  color: #bbb;
}

.prev,
.next {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  margin-top: -22px;
  padding: 16px;
  color: #fff;
  font-weight: bold;
  font-size: 30px;
  transition: 0.3s;
  user-select: none;
}

.prev { left: 0; }
.next { right: 0; }

.prev:hover, .next:hover {
  color: #bbb;
}

/* ----------------------------------------------
   Responsive: mobile and small screens
   These rules only adjust layout for small widths
   without altering desktop appearance
-----------------------------------------------*/

/* Tablets and small devices */
@media (max-width: 768px) {
  /* Header spacing */
  .site-header { padding: 0.5rem; }
  #buttons_div_1 { justify-content: space-between; }

  /* Show hamburger */
  .nav-toggle-label { display: block; }

  /* Stack title and menu */
  #title_div_1 { margin-bottom: 0.25rem; }

  /* Hide nav by default on small screens */
  .nav { display: none; width: 100%; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
  /* Reveal nav when hamburger checked */
  .nav-toggle:checked ~ .nav { display: flex; }

  /* --- Mobile adjustments for tables and images --- */
  /* Ensure sections with a text table and an image stack vertically
     with the table first and the image below, without changing desktop. */

  /* Common containers used across pages */
  #content_table_1,
  #content_table_2 {
    /* If any page used flex for side-by-side, force column on mobile */
    display: block; /* safe default for wrappers */
  }

  /* Tables: full width and horizontally scrollable if overflow */
  #content_table_1 table,
  #content_table_2 table,
  body > table {
    width: 100%;
    display: block;            /* allow horizontal scroll */
    overflow-x: auto;          /* horizontal scroll when needed */
    -webkit-overflow-scrolling: touch; /* smooth scroll on iOS */
    table-layout: fixed;       /* keep cells contained */
  }

  /* Stack table cells so text appears above image on mobile */
  #content_table_1 table td,
  #content_table_2 table td,
  body > table td {
    display: block;
    width: 100% !important;
    box-sizing: border-box;
    margin-bottom: 0;          /* unify spacing using the next-sibling gap */
    padding: 0;                /* avoid unexpected overflow from padding */
  }

  /* Images: centered, responsive, and placed after the table */
  #content_table_1 img,
  #content_table_2 img,
  body > table img {
    display: block;
    margin: 0 auto;            /* centered without duplicating outer spacing */
    max-width: 100%;
    height: auto;              /* keep aspect ratio */
  }

  /* Extra spacing specifically for the image cell when stacked */
  #content_table_1 table td + td,
  #content_table_2 table td + td,
  body > table td + td {
    margin-top: 1.25rem;       /* single, consistent gap between text and image */
  }

  /* Example hook if a page uses a flex container for table+image */
  .section-container {
    display: flex;
    flex-direction: column;    /* stack on mobile */
  }
  .section-container table {
    width: 100%;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .section-container img {
    max-width: 100%;
    height: auto;
    margin-top: 1rem;
    align-self: center;
  }

  /* General spacing adjustments */
  body {
    background-size: cover;
  }

  /* Navigation buttons: better spacing on mobile */
  .button {
    padding: 8px 12px; /* responsive tweak */
    font-size: 14px;   /* responsive tweak */
    margin: 4px 2px;   /* responsive tweak */
    width: 100%;       /* full-width tap targets in mobile nav */
  }

  /* Headings scale down slightly */
  #title_1 {
    font-size: 24px; /* responsive tweak for small screens */
    text-align: center;
    margin: 10px 0;
  }

  /* Content tables: stack columns vertically */
  #content_table_1 table,
  #content_table_2 table {
    width: 100%;
    table-layout: fixed;
  }
  #content_table_1 table td,
  #content_table_2 table td,
  table td {
    display: block;        /* stack cells */
    width: 100% !important;
    box-sizing: border-box;
    margin-bottom: 12px;   /* space between blocks */
  }

  /* Images inside content: scale to container */
  #content_table_1 img,
  #content_table_2 img,
  td img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 8px; /* subtle rounding for mobile aesthetics */
  }

  /* Iframes (e.g., map): make responsive */
  iframe {
    width: 100% !important;
    height: 320px; /* reasonable height on mobile */
  }

  /* Gallery grid: tighter gaps and adaptive row height */
  .gallery-container {
    padding: 12px; /* reduce side padding */
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
  }
  .gallery-grid img {
    height: 160px; /* reduce fixed height for small screens */
  }

  /* Lightbox overlay adjustments for mobile usability */
  .lightbox {
    padding-top: 0;                    /* remove top offset */
    display: none;                     /* default stays hidden */
    align-items: center;               /* center vertically when shown */
    justify-content: center;           /* center horizontally */
    overflow: auto;                    /* allow scrolling if needed */
    overscroll-behavior: contain;      /* prevent background scroll chaining */
  }
  /* Ensure flex centering when JS sets display:block */
  .lightbox[style*="display: block"] {
    display: flex !important;
  }
  .lightbox-img {
    max-width: 95%;
    max-height: 70%;
    border-radius: 10px;               /* rounded corners for modal content */
  }
  .close {
    top: 12px;
    right: 16px;
    font-size: 28px;                   /* smaller close icon for mobile */
  }
  .prev,
  .next {
    font-size: 24px;                   /* smaller arrows */
    padding: 10px;
  }
}

/* Phones: very small screens */
@media (max-width: 480px) {
  .button {
    padding: 8px 10px; /* compact */
    font-size: 13px;
  }

  #title_1 {
    font-size: 20px; /* further scale down */
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
  }
  .gallery-grid img {
    height: 140px; /* compact image tiles */
  }

  .lightbox-img {
    max-width: 92%;
    max-height: 65%;
    border-radius: 12px; /* a bit more rounding on phones */
  }
.close {
    font-size: 26px;
    top: 10px;
    right: 12px;
  }
}

/* Content layout replacements for old tables */
.content-row {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 1.5rem;
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}
.content-col { flex: 1 1 0; min-width: 0; }
.content-col.bg { background: #D8D8D8; padding: 1rem; border-radius: 8px; }
.content-image { max-width: 100%; height: auto; border-radius: 8px; display: block; }

@media (max-width: 768px) {
    .content-row { flex-direction: column; gap: 1rem; padding: 0.75rem; }
}
