/**
 * @file
 * Styles for the gallery modal dialog.
 */

:root {
  --comment-badge-offset: 0.4rem;
  --comment-badge-size: 1.8rem;
  --comment-icon-size: 1rem;
  --comment-icon-top-padding: 0.05rem;
}

/* Transparent overlay link on masonry items */
.gallery-modal__overlay-link {
  color: transparent;
  display: block;
  outline: none;
  text-decoration: none;
}

/* Override jQuery UI dialog for gallery modal */
.gallery-modal-dialog {
  left: 50% !important;
  max-width: 1200px;
  position: fixed !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
}

.gallery-modal-dialog .ui-dialog-titlebar {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
}

.gallery-modal-dialog .ui-dialog-content {
  padding: 0;
}

/* Modal layout */
.gallery-modal {
  display: grid;
  gap: 0;
  grid-template-columns: 1fr;
  max-height: 80vh;
}

@media (min-width: 768px) {
  .gallery-modal {
    grid-template-columns: 2fr 1fr;
  }
}

/* Image section */
.gallery-modal__image {
  align-items: center;
  background: #000;
  display: flex;
  justify-content: center;
  margin: 1rem;
  min-height: 300px;
  overflow: hidden;
  position: relative;
}

.gallery-modal__image img {
  height: auto;
  max-height: 80vh;
  max-width: 100%;
  object-fit: contain;
}

/* Navigation buttons */
.gallery-modal__nav {
  align-items: center;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  display: flex;
  font-size: 2rem;
  height: 50px;
  justify-content: center;
  opacity: 0.7;
  padding: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: opacity 0.2s, background 0.2s;
  width: 50px;
  z-index: 10;
}

.gallery-modal__nav:hover {
  background: rgba(0, 0, 0, 0.7);
  opacity: 1;
}

.gallery-modal__nav:focus {
  background: rgba(0, 0, 0, 0.7);
  opacity: 1;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.gallery-modal__nav--prev {
  left: 1rem;
}

.gallery-modal__nav--next {
  right: 1rem;
}

.gallery-modal__nav-icon {
  display: block;
  line-height: 1;
  user-select: none;
}

/* Touch devices: make nav buttons larger */
@media (pointer: coarse) {
  .gallery-modal__nav {
    font-size: 2.5rem;
    height: 60px;
    width: 60px;
  }
}

/* Sidebar */
.gallery-modal__sidebar {
  background: #fff;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1rem;
}

/* Comments section */
.gallery-modal__comments {
  flex: 1 1 auto;
  margin-bottom: 1rem;
  overflow-y: auto;
}

.gallery-modal__comments-title {
  border-bottom: 1px solid #e0e0e0;
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
}

.gallery-modal__no-comments {
  color: #888;
  font-size: 0.875rem;
  font-style: italic;
}

.gallery-modal__comment {
  border-bottom: 1px solid #f0f0f0;
  padding: 0.5rem 0;
}

.gallery-modal__comment:last-child {
  border-bottom: none;
}

.gallery-modal__comment-author {
  font-size: 0.8125rem;
  font-weight: 600;
}

.gallery-modal__comment-date {
  color: #888;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

.gallery-modal__comment-body {
  font-size: 0.875rem;
  line-height: 1.4;
  margin-top: 0.25rem;
}

/* Comment form */
.gallery-modal__comment-form {
  border-top: 1px solid #e0e0e0;
  flex: 0 0 auto;
  padding-top: 0.75rem;
}

#gallery-comment-form-wrapper textarea {
  border: 1px solid red;
  border-radius: 4px;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem;
  resize: vertical;
  width: 100%;
}

#gallery-comment-form-wrapper .form-actions {
  margin-top: 0.5rem;
}

#gallery-comment-form-wrapper .form-submit {
  background-color: oklch(0.391 0.1616 275.91);
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

#gallery-comment-form-wrapper .form-submit:hover {
  background-color: oklch(0.30 0.18 275);
}

/* Social sharing */
.gallery-modal__share {
  border-top: 1px solid #e0e0e0;
  flex: 0 0 auto;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}

.gallery-modal__share-title {
  font-size: 0.8125rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.gallery-modal__share-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  position: relative;
}

.gallery-modal__share-link {
  align-items: center;
  background: transparent;
  border: none;
  color: inherit;
  display: inline-flex;
  font-size: 0.8125rem;
  justify-content: center;
  padding: 0;
  text-decoration: none;
  transition: opacity 0.2s;
}

.gallery-modal__share-link:hover {
  color: inherit;
  opacity: 0.85;
}

.gallery-modal__share-link--facebook,
.gallery-modal__share-link--facebook:visited,
.gallery-modal__share-link--facebook:hover,
.gallery-modal__share-link--facebook:focus {
  color: #1877f2;
}

.gallery-modal__share-link--facebook svg {
  color: #1877f2;
  fill: #1877f2;
}

.gallery-modal__share-link--copy {
  color: #555;
  cursor: pointer;
}

.gallery-modal__share-toast {
  background: rgba(33, 33, 33, 0.92);
  border-radius: 4px;
  bottom: calc(100% + 6px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 0.75rem;
  left: 0;
  opacity: 0;
  padding: 0.25rem 0.5rem;
  pointer-events: none;
  position: absolute;
  transition: opacity 0.2s, transform 0.2s;
  transform: translateY(3px);
  white-space: nowrap;
  z-index: 100;
}

.gallery-modal__share-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.gallery-modal__share-toast.is-error {
  background: rgba(179, 38, 30, 0.95);
}

.gallery-modal__share-link--pinterest {
  background-color: #e60023;
}

.gallery-modal__share-link--email {
  background-color: #555;
}

/* Masonry item trigger styles */
.gallery-modal-trigger {
  cursor: pointer;
  position: relative;
  transition: opacity 0.2s, transform 0.2s;
}

.gallery-modal-trigger--has-comments::after {
  background: rgba(0, 0, 0, 0.45);
  border-radius: 50%;
  content: '';
  height: var(--comment-badge-size);
  pointer-events: none;
  position: absolute;
  right: var(--comment-badge-offset);
  top: var(--comment-badge-offset);
  width: var(--comment-badge-size);
  z-index: 2;
}

.gallery-modal-trigger--has-comments::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3 3.5A2.5 2.5 0 0 1 5.5 1h9A2.5 2.5 0 0 1 17 3.5v6A2.5 2.5 0 0 1 14.5 12H9l-3.8 3.1a.75.75 0 0 1-1.2-.59V12H5.5A2.5 2.5 0 0 1 3 9.5v-6z'/%3E%3C/svg%3E");
  background-color: rgba(255, 255, 255, 0.9);
  content: '';
  height: var(--comment-icon-size);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3 3.5A2.5 2.5 0 0 1 5.5 1h9A2.5 2.5 0 0 1 17 3.5v6A2.5 2.5 0 0 1 14.5 12H9l-3.8 3.1a.75.75 0 0 1-1.2-.59V12H5.5A2.5 2.5 0 0 1 3 9.5v-6z'/%3E%3C/svg%3E");
  mask-repeat: no-repeat;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  pointer-events: none;
  position: absolute;
  right: calc(var(--comment-badge-offset) + (var(--comment-badge-size) - var(--comment-icon-size)) / 2);
  top: calc(var(--comment-badge-offset) + (var(--comment-badge-size) - var(--comment-icon-size)) / 2 + var(--comment-icon-top-padding));
  width: var(--comment-icon-size);
  z-index: 3;
}

.gallery-modal-trigger:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.gallery-modal-trigger:focus-visible {
  outline: 3px solid oklch(0.391 0.1616 275.91);
  outline-offset: 2px;
}

.form-gallery-comment-form__author-name input[id^="edit-author-name--"] {
  width: 70%;
}