@import url('../global.css');

body {
  background-color: #111;
  color: #fff;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
}

img {
  color: #fff;
  font-style: italic;
}

/* --- Grid Styles --- */
.gallery-section {
  border-bottom: 1px solid #333;
  padding: 20px;
}

.section-header {
  margin: 0 auto 12px;
  max-width: 1200px;

  h2 {
    color: var(--link_color);
    font-family: 'Audiowide', sans-serif;
    font-size: 32px;
    margin: 8px 0;
  }
  p {
    margin: 0;
  }
}

.list {
  columns: 3;
  gap: 10px;
  margin: 0 auto;
  max-width: 1200px;
}

@media (max-width: 768px) {
  .list {
    columns: 2;
  }
}

@media (max-width: 480px) {
  .list {
    columns: 1;
  }
}

.thumbnail {
  background: #222;
  border: none;
  break-inside: avoid;
  cursor: pointer;
  display: block;
  margin-bottom: 10px;
  outline: none;
  padding: 0;
  border-radius: 4px;
  transition:
    filter 0.2s,
    opacity 0.2s,
    transform 0.2s;
  width: 100%;
}

.thumbnail:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.list:has(.thumbnail:hover) .thumbnail:not(:hover) {
  filter: grayscale(1);
  opacity: 0.5;
}

.thumbnail img {
  border-radius: 4px;
  display: block;
  height: auto;
  width: 100%;
}

.thumbnail:focus-visible {
  outline: 3px solid var(--highlight_color);
  outline-offset: 3px;
  transform: scale(1.02);
}

/* --- Modal Layout --- */
dialog {
  align-items: center;
  backdrop-filter: blur(5px);
  background: rgba(0, 0, 0, 0.85);
  border: none;
  display: none;
  height: 100%;
  inset: 0;
  justify-content: center;
  margin: 0;
  max-height: none;
  max-width: none;
  padding: 0;
  position: fixed;
  width: 100%;
  z-index: 2000;
}

dialog[open] {
  display: flex;
}

.modal-content {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-height: 95dvh;
  outline: none;
  position: relative;
  width: 95vw;
}

.modal-header {
  color: var(--link_color);
  flex-shrink: 0;
  font-family: 'Audiowide', sans-serif;
  font-size: clamp(16px, 4vw, 32px);
  margin-bottom: 10px;
  text-align: center;
}

.modal-image {
  border-radius: 4px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
  max-height: calc(95dvh - 150px);
  max-width: 100%;
  object-fit: contain;
}

/* --- Caption Styling with Link Support --- */
.modal-caption {
  backdrop-filter: blur(10px);
  background-color: hsl(from var(--link_color) h s l / 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  flex-shrink: 0;
  font-size: clamp(14px, 3vw, 18px);
  margin-top: 15px;
  max-width: 80%;
  padding: 12px 20px;
  text-align: center;
}

.modal-caption a {
  color: var(--link_color);
  font-weight: bold;
  text-decoration: underline;
}

.modal-caption a:hover {
  color: var(--highlight_color);
}

/* --- Unified Button Styles --- */
.modal-close,
.modal-nav button {
  align-items: center;
  background-color: hsl(from var(--link_color) h s l / 0.25);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  font-size: 35px;
  height: 50px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: all 0.2s ease;
  width: 50px;
  z-index: 2100;
}

.modal-close:hover,
.modal-nav button:hover:not(:disabled),
.modal-close:focus,
.modal-nav button:focus {
  background-color: var(--highlight_color);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
  color: #fff;
  outline: none;
  transform: scale(1.1);
}

.modal-close {
  position: absolute;
  right: 0;
  top: -32px;
}

.modal-nav {
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
}

.modal-nav button {
  margin: 0 5px;
  pointer-events: all;
}

.modal-nav button:disabled {
  opacity: 0;
  pointer-events: none;
}

body.modal-open {
  overflow: hidden;
}

@media (max-height: 500px) {
  .modal-close {
    right: -32px;
    top: 0;
  }
  .modal-header {
    display: none;
  }
}
