@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Lato:wght@400;700&display=swap');

/* ========================================================================
   Global Variables & Base Styles
   ======================================================================== */
:root {
  --primary-color: #2596be;
  --primary-dark:  #1b6f87;
  --accent-color:  #e6302c;
  --bg-color:      #f4f4f9;
  --text-color:    #333;
  --light-text:    #555;
  --white:         #fff;
  --border-color:  #ddd;
  --navbar-height: 3rem;
  --footer-height: 3rem;
  --card-min: 350px;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Lato', Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.6;
  transition: background-color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Montserrat', sans-serif;
}

/* ========================================================================
   No Results Visualization
   ======================================================================== */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: var(--light-text);
}

.no-results img {
  max-width: 200px;
  margin-bottom: 1rem;
}

/* ========================================================================
   Navbar
   ======================================================================== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--navbar-height);
  background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
  color: var(--white);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  z-index: 20;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.navbar .logo {
  display: flex;
  align-items: center;
  margin-left: -1rem;
}

.navbar .logo img {
  height: var(--navbar-height);
}

.nav-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  transition: all 0.3s ease;
}

.nav-links li {
  margin: 0 1rem;
}

.nav-links a {
  color: var(--white);
  text-decoration: none;
  font-size: 1rem;
  position: relative;
  transition: color 0.3s;
}

.nav-links a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  background: var(--white);
  left: 0;
  bottom: -2px;
  transition: width 0.3s;
}

.nav-links a:hover::after {
  width: 100%;
}

/* Hamburger Toggle Button */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.hamburger {
  width: 25px;
  height: 2px;
  background-color: var(--white);
  display: block;
  position: relative;
  transition: background-color 0.3s ease;
}

.hamburger::before,
.hamburger::after {
  content: "";
  width: 25px;
  height: 2px;
  background-color: var(--white);
  position: absolute;
  left: 0;
  transition: background-color 0.3s ease;
}

.hamburger::before { top: -8px; }
.hamburger::after { top: 8px; }

/* ========================================================================
   Filter Menu
   ======================================================================== */
.filter-menu {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  bottom: var(--footer-height);
  width: 25%;
  min-width: 380px;
  padding: 1.5rem;
  background-color: var(--white);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  z-index: 10;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  transition: all 0.3s ease;
}

.filter-menu::-webkit-scrollbar {
  width: 8px;
}

.filter-menu::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 4px;
}

.filter-menu h3 {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 1rem;
  color: var(--accent-color);
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
}

/* Slider Columns & Containers */
.slider-column {
  padding: 0 1rem;
}

.slider-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.slider-container label {
  flex: 1;
  font-size: 1rem;
  color: var(--text-color);
  cursor: pointer;
}

/* NEW: Slider input base style for cross-browser compatibility */
/* Remove extra padding and use a fixed height for the control's container.
   The track is set to 8px, and the thumb (16px) is centered by a negative margin. */
.slider-container input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  max-width: 60%;
  margin-left: 1rem;
  cursor: pointer;
  background: transparent;
  /* Total height of the control (track area + space for thumb) */
  height: 30px;
  /* Remove extra padding to avoid interference */
  padding: 0;
}

/* Range Input Track */
.slider-container input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  background: var(--border-color);
  border-radius: 5px;
}
.slider-container input[type="range"]::-moz-range-track {
  height: 8px;
  background: var(--border-color);
  border-radius: 5px;
}

/* Range Input Thumb */
.slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  background: var(--primary-color);
  border: 2px solid var(--white);
  border-radius: 50%;
  cursor: pointer;
  /* Center the thumb vertically relative to the track */
  margin-top: -4px;
}
.slider-container input[type="range"]::-moz-range-thumb {
  height: 16px;
  width: 16px;
  background: var(--primary-color);
  border: 2px solid var(--white);
  border-radius: 50%;
  cursor: pointer;
}

/* When focused */
.slider-container input[type="range"]:focus {
  outline: none;
  background-color: #d3d3d3;
}

/* ========================================================================
   Dropdown
   ======================================================================== */
.filter-menu .filter-dropdown {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background-color: var(--white);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
  transition: all 0.3s ease;
}

.filter-menu .filter-dropdown:focus {
  outline: 3px solid #3498db;
  outline-offset: 2px;
}

/* ========================================================================
   Reset Filters Button
   ======================================================================== */
.filter-menu .reset-btn {
  background-color: var(--primary-color);
  color: var(--white);
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.3s;
  margin-top: 1rem;
  display: block;
  width: 100%;
}

.filter-menu .reset-btn:hover {
  background-color: var(--primary-dark);
}

/* ========================================================================
   Main Content & Gallery
   ======================================================================== */
.main-content {
  padding: 1.5rem;
  margin-top: 5rem;
  margin-bottom: 5rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--card-min)), 1fr));
  gap: 1.5rem;
  margin-top: -3rem;
  margin-left: calc(max(25%, 380px) + 1rem);
  margin-right: 1rem;
  width: calc(100% - max(25%, 380px) - 2rem);
  padding-bottom: 10rem;
  transition: all 0.3s ease;
}

.gallery-header {
  margin: 5rem auto;
  margin-left: max(25%, 380px);
  margin-right: 1rem;
  width: calc(100% - max(25%, 380px) - 1rem);
  padding: 0 1rem;
  border-bottom: 2px solid var(--border-color);
}

.gallery-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.sort-by-container,
.card-resize-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-by-container span,
.card-resize-container label {
  font-size: 1rem;
  color: var(--text-color);
}

.sort-by-container select,
.card-resize-container input[type="range"] {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background-color: var(--white);
  min-width: 200px;
}

/* ========================================================================
   Card Styles
   ======================================================================== */
.image,
.gallery-item {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background-color: var(--white);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.image:hover,
.gallery-item:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.image-container {
  width: 100%;
  overflow: hidden;
  border-radius: 10px;
  transition: transform 0.3s ease;
}

.image-container img {
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  transition: transform 0.3s ease;
}

.text-container {
  margin-top: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: all 0.3s ease;
}

.text-container h3 {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--text-color);
  margin: 0;
  padding-bottom: 0.25rem;
}

.text-container p {
  font-size: 1rem;
  color: var(--light-text);
  line-height: 1.6;
}

/* ========================================================================
   Top-3 Criteria Badge
   ======================================================================== */
.top-criteria {
  margin-top: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ========================================================================
   All Criteria Container (initially hidden)
   ======================================================================== */
.all-criteria {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.4s ease;
}

.all-criteria.show {
  max-height: 500px;
  opacity: 1;
  margin-top: 1rem;
}

/* ========================================================================
   Badge Styling
   ======================================================================== */
.criteria-badge {
  background-color: var(--primary-color);
  color: var(--white);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: bold;
  font-size: 0.9rem;
}

/* ========================================================================
   Toggle All Criteria Button
   ======================================================================== */
.toggle-all-criteria {
  background-color: var(--accent-color);
  color: var(--white);
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin-top: 1rem;
  position: relative;
  padding-right: 30px;
}

.toggle-all-criteria:hover {
  background-color: var(--primary-dark);
}

.toggle-all-criteria::after {
  content: "▼";
  position: absolute;
  right: 10px;
  transition: transform 0.3s ease;
}

.toggle-all-criteria.expanded::after {
  transform: rotate(180deg);
}

/* ========================================================================
   Hide top criteria container when showing all
   ======================================================================== */
.criteria-hidden {
  display: none;
}

/* ========================================================================
   Tooltip Dialog
   ======================================================================== */
.dialog {
  position: absolute;
  display: none;
  padding: 8px;
  background-color: rgba(0, 0, 0, 0.85);
  color: var(--white);
  border-radius: 4px;
  font-size: 14px;
  max-width: 200px;
  z-index: 1000;
  transition: opacity 0.3s ease;
}

.dialog.show {
  display: block;
}

/* ========================================================================
   Modal
   ======================================================================== */
.modal {
  display: none;
  justify-content: center;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 1000;
}

.modal.show {
  display: flex;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-content {
  max-width: 60%;
  background-color: var(--white);
  padding: 20px;
  border-radius: 8px;
  text-align: center;
}

.close {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 2rem;
  color: var(--white);
  cursor: pointer;
}

.hidden {
  display: none;
}

/* ========================================================================
   Footer
   ======================================================================== */
footer {
  background-color: var(--text-color);
  color: var(--white);
  text-align: center;
  padding: 1rem 2rem;
  width: 100%;
  position: fixed;
  bottom: 0;
  left: 0;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  transition: all 0.3s ease;
  height: var(--footer-height);
}

footer p {
  margin: 0;
  font-size: 0.875rem;
}

/* ========================================================================
   Form & Button Styles
   ======================================================================== */
form label {
  font-size: 1rem;
  display: block;
  margin-bottom: 0.5rem;
}

form input,
form textarea {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  font-family: 'Lato', sans-serif;
}

form input:focus,
form textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 5px rgba(37, 150, 190, 0.5);
}

form textarea {
  resize: vertical;
}

form input[type="submit"] {
  background-color: var(--primary-color);
  color: var(--white);
  border: none;
  cursor: pointer;
  padding: 0.75rem;
  font-size: 1rem;
  transition: background-color 0.3s ease, transform 0.2s ease;
  border-radius: 6px;
}

form input[type="submit"]:hover {
  background-color: var(--primary-dark);
  transform: scale(1.03);
}

.toggle-btn {
  background-color: #3498db;
  color: var(--white);
  font-size: 1rem;
  padding: 0.75rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.toggle-btn:hover {
  background-color: #2980b9;
  transform: scale(1.03);
}

.toggle-btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* ========================================================================
   Section Styles
   ======================================================================== */
section {
  padding: 2rem;
  margin: 2rem;
  background-color: var(--white);
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

h2 {
  font-size: 1.5rem;
  color: var(--text-color);
}

p {
  font-size: 1rem;
  color: var(--light-text);
  line-height: 1.6;
}

/* ========================================================================
   Responsive Styles
   ======================================================================== */
@media (max-width: 768px) {
  .filter-menu {
    position: relative;
    width: 100%;
    min-width: 300px;
    height: auto;
    border-right: none;
    border-radius: 0;
  }

  .gallery {
    width: calc(100% - 2rem);
    margin: 0 1rem;
  }

  .gallery-header {
    margin: 5rem 1rem 0 1rem;
    width: calc(100% - 2rem);
    padding: 0 1rem;
  }

  .menu-toggle {
    display: block;
  }

  .nav-links {
    position: absolute;
    top: var(--navbar-height);
    left: 0;
    width: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    flex-direction: column;
    transform: scaleY(0);
    transform-origin: top;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
  }

  .nav-links.active {
    transform: scaleY(1);
    opacity: 1;
    pointer-events: auto;
  }

  .nav-links li {
    margin: 1rem 0;
    text-align: center;
  }
}

/* ========================================================================
   Detail Page Styles
   ======================================================================== */
.detail-container {
  display: flex;
  flex-wrap: wrap;
  width: 80%;
  margin: 5rem auto;
  gap: 2rem;
  align-items: flex-start;
}

.detail-left {
  flex: 1;
  min-width: 300px;
}

.detail-right {
  flex: 2;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  justify-content: center;
}

.detail-image {
  width: 100%;
  max-width: 800px;
  text-align: center;
  margin: 0 auto;
}

.detail-image img {
  width: 100%;
  height: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  display: block;
  transition: transform 0.3s ease;
}

.detail-image img:hover {
  transform: scale(1.05);
}

.detail-image figcaption {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--light-text);
  font-style: italic;
}

/* Back Button for Detail Page */
.back-btn {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.75rem 1.5rem;
  background-color: var(--primary-color);
  color: var(--white);
  text-decoration: none;
  border-radius: 6px;
  transition: background-color 0.3s ease;
}

.back-btn:hover {
  background-color: var(--primary-dark);
}
.image-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.image-group img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  max-height: 320px;
  object-fit: contain;
}

figure {
  text-align: center;
  margin: 2rem 0;
}
figcaption {
  font-size: 0.95rem;
  color: #555;
  margin-top: 0.5rem;
}
article {
  margin-bottom: 2.5rem;
}

.image-group img:hover {
  transform: scale(1.03);
  transition: transform 0.2s ease;
}