/* Theme Tokens */
/* ==================== */

:root {

  /* Colors - Text */

  --body-text-color: var(--text-color-darkmode);
  --body-text-faded: var(--text-secondary-color-darkmode);
  --bright-white-text: #fff;
  --orange-text: var(--accent-color);
  --orange-text-lighter: var(--accent-color-lighter);

  --gallery-card-hover-text: var(--accent-color);
  --gallery-card-hover-text-lighter: var(--accent-color-lighter);
  --gallery-text-color: var(--text-color-darkmode);
  --gallery-date-color: var(--text-secondary-color-darkmode);

  --modal-text-color: var(--text-color-darkmode);
  --modal-caption-color: var(--text-color-darkmode);
  --modal-date-color: var(--text-secondary-color-darkmode);

  /* Font Sizes */
  --gallery-album-title-font-size: var(--text-font-size-small);
  --gallery-caption-font-size: var(--text-font-size-small);
  --gallery-date-font-size: var(--text-font-size-extrasmall);

  --modal-caption-font-size: var(--text-font-size-small);
  --modal-control-font-size: var(--text-font-size-large);
  

  /* Colors - UI Elements */
  --gallery-album-title-color: var(--text-color-darkmode);
  --gallery-card-bg: var(--background-secondary-color-darkmode);
  --gallery-card-hover-bg: var(--background-color-darkmode);
  --gallery-card-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  --gallery-image-placeholder: #2a2a2a;

  --modal-overlay-bg: rgba(0, 0, 0, 0.95);
  --modal-content-bg: var(--background-color-darkmode);
  --modal-hover: rgba(255, 255, 255, 0.05);
  --modal-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --modal-close-bg: rgba(0, 0, 0, 0.7);
  --modal-close-hover-bg: rgba(255, 255, 255, 0.3);
  --modal-nav-bg: rgba(0, 0, 0, 0.7);
  --modal-nav-hover-bg: var(--orange-text-lighter);

}


/* Adjusting surrounding elements from blog design */
/* ============ */

article[data-gallery="css-album"] {
  grid-template-columns: 
    var(--gutter-size)
    1fr
    min( 1200px, calc(100% - 40px) )  /* Make the central column much wider and capped at 1200px in order to fit in more photo tiles in the gallery grid view. */
    1fr
    var(--gutter-size)
}

.credits {
  margin-top: 60px;
}



/* Photo page */
/* ============ */

.related-links {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.2);
  display: inline-block;
  font-family: var(--text-font-family-mono);
  font-size: var(--text-font-size-extrasmall);
  margin-top: 30px;
  margin-bottom: 0;
  padding: 10px;
  text-transform: uppercase;
}

@media (max-width: 768px) {
  .related-links {
    grid-column: 1/-1;
  }
}

@media (min-width: 769px) {
  .related-links {
    justify-self: center;
    margin-inline: auto;
    padding: 6px 17px 5px; /* Strange offsets to compensate for hidden padding, probably inherent to line-heights of app caps text. */
    width: max-content;
  }
}

.related-links a {
  color: var(--orange-text-lighter);
  text-decoration: none;
  text-underline-offset: 4px;
}

.related-links a:hover {
  color: var(--bright-white-text);
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

@media (max-width: 768px) {
  body > header {
    padding-left: 20px;
    padding-right: 20px;
  }
}




/* Gallery Grid - Desktop only */
/* ============ */

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

/* Mobile: Single column, no grid */
@media (max-width: 768px) {
  .gallery {
    display: block;
  }
  
  .photo-card {
    margin-bottom: 20px;
  }
}

/* Photo Card */
.photo-card {
  background: var(--gallery-card-bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--gallery-card-shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  display: block;
}

.albums .photo-card {
  margin-bottom: 20px;
}

.gallery a.photo-card,
.gallery a.photo-card:visited {
  padding-bottom: 0;
  border-bottom: none;
  -webkit-tap-highlight-color: transparent;
}

.gallery a.photo-card:hover,
.gallery a.photo-card:focus,
.gallery a.photo-card:active {
  padding-bottom: 0;
  border-bottom: none;
}

.gallery a.photo-card:focus-visible {
  outline: 2px solid var(--orange-text-lighter);
  outline-offset: 3px;
}

/* Desktop: Clickable cards with hover */
@media (min-width: 769px) {
  @media (hover: hover) {
    .photo-card:hover {
      background-color: var(--modal-hover);
      border-bottom: none;

      & img {
      transform: scale(1.04);
      transition: transform 0.2s;
      }
    }
  }
}

/* Mobile: Not clickable for non-link cards (album pages with modals), but allow links to work */
@media (max-width: 768px) {
  .photo-card:not(a) {
    pointer-events: none;
    cursor: default;
  }
  
  /* Ensure links are always clickable */
  a.photo-card {
    pointer-events: auto;
    cursor: pointer;
  }
}

.photo-card img {
  border-radius: 8px 8px 0 0;
  
  width: 100%;
  height: 250px;
  object-fit: cover;
  display: block;
  background-color: var(--gallery-image-placeholder);
}

/* Mobile: Full aspect ratio, no cropping */
@media (max-width: 768px) {
  .photo-card img {
    height: auto;
    object-fit: contain;
  }
}

/* Photo Info */
.photo-info {
  padding: 15px;
  color: var(--gallery-text-color);
}

.albums .photo-info {
  padding: 20px 15px 15px;
}

.photo-info .album-title {
  color: var(--gallery-album-title-color);
  font-size: var(--gallery-album-title-font-size);
  line-height: 100%;
}

.photo-info .caption {
  font-size: var(--gallery-caption-font-size);

  margin-bottom: 10px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.photo-info .date {
  color: var(--gallery-date-color);
  font-family: var(--text-font-family-mono);
  font-size: var(--gallery-date-font-size);
  line-height: 100%;
  text-transform: uppercase;
}

/* Truncate long captions in gallery */
.photo-info .caption {
  margin-top: 10px;
  
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 769px) {
  .photo-info .caption {
    -webkit-line-clamp: 5;
    line-clamp: 5;
  }
}

@media (max-width: 768px) {
  .photo-info .caption {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
  }
}

/* Modal Styles - Desktop only */
/* ============ */

/* Hide modal by default */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--modal-overlay-bg);
  z-index: 1000;
  overflow-y: auto;
  padding: 20px;
  align-items: center;
  justify-content: center;
  overscroll-behavior: contain;
}

/* Show modal when :target matches */
.modal:target,
.modal.active {
  display: flex;
}

body:has(.modal:target) {
  overflow: hidden;
}

/* Modal Container */
.modal-content {
  position: relative;
  max-width: 90vw;
  margin: 20px auto;
  overflow: hidden;
  box-shadow: var(--modal-shadow);
  z-index: 1000;
  width: fit-content;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Close Button */
.modal-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: var(--modal-close-bg);
  color: var(--modal-text-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--modal-control-font-size);
  z-index: 1001;
  transition: background 0.2s;
  text-decoration: none;
}

.modal-close:hover {
  background: var(--modal-close-hover-bg);
  text-decoration: none;
}

.modal-image {
  width: 100%;
  max-width: 90vw;
  max-height: 70vh;
  height: auto;
  display: block;
  object-fit: contain;
  background-color: var(--gallery-image-placeholder);
}

@media (max-width: 768px) {
  .modal {
    padding: 40px 0 20px;
    align-items: center;
    justify-content: center;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
  }

  .modal-content picture,
  .modal-content img {
    background: none;
    width: 100%;
    max-width: 100%;
    height: auto;
  }

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

  .modal-nav {
    display: none !important;
  }
}

/* Modal Info */
.modal-info {
  padding: 20px;
  color: var(--modal-text-color);
}

.modal-caption {
  font-size: var(--modal-caption-font-size);
  margin-bottom: 10px;
  line-height: 1.5;
  color: var(--modal-caption-color);
  overflow-wrap: anywhere;
  text-align: center;
  word-break: break-word;
}

.modal-date {
  color: var(--modal-date-color);
  font-family: var(--text-font-family-mono);
  font-size: var(--gallery-date-font-size);
  text-transform: uppercase;
}

.photo-info .caption a,
.modal-caption a {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* Navigation Buttons */
.modal-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: var(--modal-nav-bg);
  color: var(--modal-text-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  z-index: 1001;
  transition: background 0.2s;
  font-size: var(--modal-control-font-size);
}

.modal-close:hover, .modal-nav:hover {
  background: var(--modal-nav-hover-bg);
  color: var(--background-color-darkmode);
  text-decoration: none;
}

.modal:hover, .modal-content:hover, .modal-overlay:hover, .modal-close:hover, .modal-nav:hover {
  border: none;
}

.modal-nav.prev {
  left: 20px;
}

.modal-nav.next {
  right: 20px;
}

/* Overlay Click to Close - invisible link covering entire modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: transparent;
}

/* Fade-in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.photo-card img {
  animation: fadeIn 0.4s ease-in;
}