/* Grid layout for map art items */
.mapart-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 16px;
  grid-auto-flow: dense;
  padding: 12px 0;
  width: 100%;
  box-sizing: border-box;
}

/* Individual map art items */
.mapart-item {
  position: relative;
  cursor: pointer;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

/* Image styling */
.mapart-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0;
  image-rendering: pixelated;
  outline: 3px solid transparent;
  transition: outline-color 0.2s ease;
}

.mapart-item img:hover {
  outline-color: #379cd2;
}

/* Top section container styles - ensure fixed height */
.top-section {
  display: grid;
  grid-template-columns: 3fr 5fr;
  gap: 20px;
  margin-bottom: 20px;
  width: 100%;
  height: 375px; /* Fixed height */
  padding: 16px 0;
  overflow: hidden; /* Prevent content from expanding the container */
}

/* Filter section styles */
.filter-section {
  width: 100%;
  height: 100%;
}

.filter-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  background: #f5f5f5;
  border: 1px solid #eee;
  border-radius: 8px;
  align-items: flex-start;
  width: 100%;
  box-sizing: border-box;
  height: 100%;
  overflow-y: auto;
  padding: 16px;
}

/* Filter group styles - updated to match ReFrame */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
}

/* Updated select styles to match ReFrame buttons */
.filter-group select {
  padding: 6px 8px;
  border-radius: 0;
  border: 1px solid #4c96b3;
  background-color: #e7f3f7;
  color: #4c96b3;
  font-size: 12px;
  width: 100%;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234c96b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  padding-right: 28px;
  height: 30px;
  box-sizing: border-box;
}

/* Style select dropdowns on hover/focus to match ReFrame */
.filter-group select:hover {
  background-color: #d3e7eb;
}

.filter-group select:focus {
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Style select options */
.filter-group select option {
  background-color: white;
  color: #333;
}

/* Style for default option in dropdowns */
.filter-group select option.default-option {
  color: #aaa;
}

/* Style for the selected default option */
.filter-group select option[value=""]:checked {
  color: #888;
}

/* Additional styling for the dropdown when showing default option */
.filter-group select:has(option[value=""]:checked) {
  color: #888;
}

/* Style for filters with non-default values */
.filter-group select.has-value {
  background-color: #3d87a4;
  border-color: #2a6381;
  color: white;
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(42, 99, 129, 0.3);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

/* Add a small indicator dot for active filters */
.filter-group select:not([value=""]):not([value="*"])::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  background-color: #379cd2;
  border-radius: 50%;
}

/* Style for dimension filters with non-default values */
.dimension-control.has-value {
  background-color: #3d87a4;
  border-color: #2a6381;
  box-shadow: 0 0 0 1px rgba(42, 99, 129, 0.3);
}

.dimension-control.has-value .size-value {
  color: white;
  font-weight: 600;
}

/* Style for vertical toggles with non-default values */
.vertical-toggle.has-value {
  border-color: #2a6381;
}

.vertical-toggle.has-value .toggle-option.active {
  background-color: #3d87a4;
  color: white;
  font-weight: 600;
}

/* Tristate toggle styles - inspired by ReFrame */
.tristate-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tristate-group label {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
}

.tristate-toggle {
  display: flex;
  height: 24px;
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.tristate-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  position: relative;
  z-index: 1;
  color: #7a8c97;
  background-color: #e7f3f7;
  border: 1px solid #4c96b3;
  margin-right: -1px;
  transition: all 0.2s ease;
}

.tristate-option:first-child {
  border-radius: 4px 0 0 4px;
}

.tristate-option:last-child {
  border-radius: 0 4px 4px 0;
  margin-right: 0;
}

.tristate-option.active {
  background-color: #3d87a4;
  color: white;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3),
              0 1px 3px rgba(0, 0, 0, 0.2);
  transform: scale(0.95);
  z-index: 2;
}

.tristate-option:hover:not(.active) {
  background-color: #d3e7eb;
}

/* Hide the original select elements for tristate toggles */
.tristate-group select {
  display: none;
}

/* Ensure boolean filters are styled consistently */
.filter-group:has(#animatedFilter),
.filter-group:has(#transparentFilter),
.filter-group:has(#tilableFilter) {
  margin-bottom: 0;
}

/* Spotlight section styles - completely separate from modal */
.spotlight-section {
  width: 100%;
  height: 100%;
}

.spotlight-container {
  margin: 0;
  height: 100%;
  width: 100%;
}

.spotlight {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  background: #f5f5f5;
  border: 1px solid #eee;
  border-radius: 0 0 8px 8px;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.spotlight-image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #f5f5f5;
  overflow: hidden;
  position: relative;
}

.spotlight-image {
  position: absolute;
  width: calc(100% - 32px); /* Account for padding */
  height: calc(100% - 32px); /* Account for padding */
  object-fit: contain;
  image-rendering: pixelated;
}

.spotlight .info-panel {
  padding: 12px 16px;
  background: #ddd;
  color: #333;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.spotlight .info-title {
  font-size: 16px;
  margin: 0;
  font-weight: 500;
  color: #333;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Only show author information in spotlight */
.spotlight .info-details {
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  max-width: 40%;
}

.spotlight .info-details .info-row:not(:first-child) {
  display: none;
}

.spotlight .info-row:first-child {
  border: none;
  margin: 0;
  padding: 0;
  min-height: auto;
}

.spotlight .info-row:first-child .info-value {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #379cd2;
}

/* Make artist links visible on the colored background */
.spotlight .info-details .info-row:first-child .info-value a {
  color: #379cd2;
  text-decoration: none;
}

.spotlight .info-details .info-row:first-child .info-value a:hover {
  text-decoration: underline;
}

/* Modal styles - completely separate from spotlight */
.mapart-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.mapart-modal {
  background: #f5f5f5;
  border-radius: 12px;
  height: 500px;
  display: grid;
  grid-template-columns: auto 300px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
  padding: 0.5em;
  gap: 0.5em;
  max-width: calc(100vw - 40px);
  margin: 0 auto;
}

.modal-image-container {
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.modal-image {
  height: calc(500px - 40px);
  width: auto;
  max-width: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.modal-content {
  width: 300px;
  background: white;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 16px;
  border: 1px solid #eee;
  border-radius: 8px;
}

/* Modal info panel styles */
.modal-content .info-title {
  font-size: 17px;
  color: #222;
  margin: 0;
  line-height: 1.2;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-content .info-details {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 0;
}

.modal-content .info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  padding-bottom: 1px;
  border-bottom: none;
  margin: 0;
}

/* Remove these since we don't need the label styling anymore */
.info-row:first-child .info-label {
  display: none;
}

/* Add dividers after specific rows - updated to include Set */
.info-row:nth-child(2), /* After Set (if present) */
.info-row:nth-child(4), /* After Material */
.info-row:nth-child(6), /* After Resolution */
.info-row:nth-child(9) { /* After Tilable */
  border-bottom: 1px solid #eee;
  padding-bottom: 2px;
  margin-bottom: 2px;
}

/* All other rows */
.info-row:not(:first-child) {
  justify-content: space-between;
}

.info-label {
  font-weight: 600;
  color: #222;
  min-width: 85px;
  font-size: 13px;
}

.info-value {
  color: #333;
  overflow-wrap: break-word;
  word-break: break-word;
  font-size: 13px;
}

/* Right align all values except artist */
.info-row:not(:first-child) .info-value {
  text-align: right;
  max-width: 160px;
}

/* Add styles for artist links */
.artist-link {
  color: #379cd2;
  text-decoration: none;
  cursor: pointer;
}

.artist-link:hover {
  text-decoration: underline;
}

/* Add styles for set links (similar to artist links) */
.set-link {
  color: #379cd2;
  text-decoration: none;
  cursor: pointer;
}

.set-link:hover {
  text-decoration: underline;
}

/* Add styles for no results message */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
  color: #666;
  font-style: italic;
}

/* Responsive styles */
@media (max-width: 900px) {
  .mapart-grid {
    --cell-size: calc((100% - (7 * var(--gap))) / 8);
  }
  
  .spotlight {
    grid-template-columns: 1fr;
    grid-template-rows: 300px auto;
  }

  .spotlight-image-container {
    height: 100%;
    width: 100%;
    padding: 10px;
  }

  .spotlight .info-panel {
    width: 100%;
  }

  .filter-container {
    padding: 12px;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  /* Adjust filter group sizes for mobile */
  .filter-group:has(#artistFilter),
  .filter-group:has(#methodFilter),
  .filter-group:has(#materialFilter) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .top-section {
    grid-template-columns: 1fr;
    gap: 16px;
    height: auto;
  }
  
  .filter-container {
    height: auto;
    max-height: 350px;
  }
  
  .spotlight {
    height: 350px;
  }
  
  .mapart-modal {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    max-height: 90vh;
    width: 90vw;
    margin: 20px auto;
  }

  .modal-image-container {
    height: auto;
    max-height: 60vh;
  }

  .modal-image {
    height: auto;
    max-height: 60vh;
    width: 100%;
  }

  .modal-content {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .mapart-grid {
    --gap: 8px;
    --cell-size: calc((100% - (7 * var(--gap))) / 8);
  }
  
  .filter-container {
    padding: 10px;
    gap: 8px;
  }
  
  .spotlight {
    padding: 0.3em;
    gap: 0.8em;
  }
  
  .spotlight-image-container {
    padding: 10px;
    height: 250px;
  }
}

/* Add header styles for filter and spotlight */
.filter-header, .spotlight-header {
  background-color: #333333;
  color: white;
  padding: 8px 12px;
  border-radius: 6px 6px 0 0;
  margin: 0;
}

.filter-header h3, .spotlight-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

/* Adjust container styles to work with headers */
.filter-container, .spotlight-container {
  border-radius: 0 0 8px 8px;
  height: calc(100% - 36px); /* Subtract header height from container */
}

.spotlight {
  border-radius: 0 0 8px 8px;
}

/* Ensure filter section maintains proper height */
.filter-section, .spotlight-section {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Style for dimension group in the filter grid */
.dimension-group {
  display: flex;
  flex-direction: column;
}

/* Style for dimension selectors container */
.dimension-selectors {
  display: flex;
  gap: 8px;
  width: 100%;
}

/* Style for dimension controls to exactly match dropdown height */
.dimension-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f5f8fa;
  border: 1px solid #e0e6eb;
  border-radius: 4px;
  height: 30px;
  padding: 0;
  box-sizing: border-box;
  flex: 1;
}

/* Adjust size buttons to match dropdown styling */
.size-btn {
  width: 24px;
  height: 30px;
  padding: 0;
  border: none;
  background: none;
  color: #4c96b3;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.size-btn:hover {
  background: #e7f3f7;
  border-radius: 3px;
}

.size-btn:active {
  background: #d3e7eb;
}

/* Style for "*" value - remove italic */
.size-value.default {
  color: #999;
  font-style: normal; /* Remove italic */
}

/* Ensure all size values are properly centered */
.size-value {
  flex: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: #4a4a4a;
  padding: 0 4px;
  height: 30px;
  display: flex;
  align-items: center; /* Center vertically */
  justify-content: center; /* Center horizontally */
}

/* Style resolution select to match other dropdowns */
.dimension-row select {
  padding: 6px 8px;
  border-radius: 0;
  border: 1px solid #4c96b3;
  background-color: #e7f3f7;
  color: #4c96b3;
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234c96b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  padding-right: 28px;
  height: 24px;
}

/* Apply the same hover/focus styles */
.dimension-row select:hover {
  background-color: #d3e7eb;
}

.dimension-row select:focus {
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Apply the same option styles */
.dimension-row select option {
  background-color: white;
  color: #333;
}

/* Apply the same default option styles */
.dimension-row select option.default-option {
  color: #888;
}

/* Apply the same selected default option styles */
.dimension-row select option[value=""]:checked {
  color: #888;
}

/* Apply the same dropdown styling when showing default option */
.dimension-row select:has(option[value=""]:checked) {
  color: #888;
}

/* Remove the conflicting styles */
.dimension-row .filter-group select {
  display: none; /* This is no longer needed */
}

/* Boolean filters grid */
.boolean-filters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  grid-column: 1 / -1;
  margin-top: 12px;
}

/* Boolean filter container */
.boolean-filter {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.boolean-filter label {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  text-align: center;
}

/* Vertical toggle styles - improved to match reframe */
.vertical-toggle {
  display: flex;
  flex-direction: column;
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
  border: none;
  gap: 0; /* Remove gap so buttons touch */
}

.toggle-option {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  font-size: 11px;
  cursor: pointer;
  color: #7a8c97;
  background-color: #e7f3f7;
  border: 1px solid #4c96b3;
  border-radius: 0; /* Default: no rounded corners */
  margin-top: -1px; /* Overlap borders to avoid double thickness */
  transition: all 0.2s ease;
  position: relative; /* Added for proper z-index handling */
  user-select: none; /* Disable text highlighting/selection */
  -webkit-user-select: none; /* For Safari */
  -moz-user-select: none; /* For Firefox */
  -ms-user-select: none; /* For IE/Edge */
}

/* First option needs no negative margin at top */
.toggle-option:first-child {
  margin-top: 0;
  border-radius: 4px 4px 0 0; /* Round only top corners of first button */
}

/* More specific selector for last button - select the last .toggle-option before any select element */
.toggle-option:last-of-type {
  border-radius: 0 0 4px 4px; /* Round bottom corners with the same radius */
}

/* Ensure the transform doesn't break the rounded corners */
.toggle-option.active {
  background-color: #3d87a4;
  color: white;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  transform: scaleX(0.95); /* Horizontal shrink only */
  /* Keep the border rounded even when active */
  transform-origin: center;
  z-index: 2; /* Keep on top when scaled */
}

/* Additional rule to ensure active last buttons keep their rounded corners */
.toggle-option:last-of-type.active {
  border-radius: 0 0 4px 4px; /* Ensure bottom corners stay rounded when active */
}

.toggle-option:hover:not(.active) {
  background-color: #d3e7eb;
}

/* Hide the original select elements */
.hidden {
  display: none;
}

/* Filter highlight animation */
@keyframes filter-pulse {
  0% { box-shadow: 0 0 0 0 rgba(55, 156, 210, 0.7); }
  70% { box-shadow: 0 0 0 5px rgba(55, 156, 210, 0); }
  100% { box-shadow: 0 0 0 0 rgba(55, 156, 210, 0); }
}

.filter-highlight {
  animation: filter-pulse 1s ease-in-out;
  animation-iteration-count: 3;
  border-color: #2a6381 !important;
  background-color: #3d87a4 !important;
  color: white !important;
}

