.media {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.3s ease;
  overflow-y: auto;
}

.media[data-visible="true"] {
  display: flex;
  opacity: 1;
  animation: fadeIn 0.3s ease;
}

.media[data-closing="true"] {
  animation: fadeOut 0.3s ease;
}

/* Modal Content Box - Centered inside backdrop */
.media__container {
  margin: auto;
  margin-top: 0;
  max-width: 64.8125rem;
  width: 80%;
  max-height: 90vh;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Modal Header */
.media__header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}
.media__info {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.media__title {
  color: #1a1c1e;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.75rem;
  margin: 0;
}

.media__filename {
  color: #5a5c62;
  font-size: 0.6875rem;
  font-weight: 400;
  margin: 0;
}

/* Modal Tools */
.media__tools {
  align-self: start;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.media__save,
.media__close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  opacity: 0.6;
  transition: 0.3s ease;
}

.media__save svg,
.media__close svg {
  fill: #d34d7e ;
  padding: 5px;
  max-width: fit-content;
  background-color: #ffe9ee;
  border-radius: 100px;
  width: 30px;
  height: 30px;
}

.media__save:hover,
.media__close:hover {
  opacity: 1;
  /* transform: scale(1.1); */
}


/* Content Wrapper */
.media__wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 70vh;
}

.media__content {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 0;
}

.media__wrapper button {
  padding: 0;
}

/* Navigation Buttons */
.media__button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: none;
  border: none;
  cursor: pointer;
}

.media__button_ico {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 2.25rem;
  height: 2.25rem;
  margin: 1rem;
  border-radius: 50%;
  background-color: rgba(188, 182, 184, 0.70);
;
  transition: 0.3s;
  opacity: 0.8;
}

.media__button_ico svg {
  fill: rgba(20, 20, 20, 0.50);
  opacity: 0.8;
  transition: 0.3s;
}

.media__button:hover .media__button_ico {
  background-color: #e0e2ec;
  opacity: 1;
}
.media__button:hover .media__button_ico svg {
  opacity: 1;
}

#media-back {
  left: -5rem;
  transform: translateY(-50%) rotate(270deg);
}

#media-next {
  right: -5rem;
  transform: translateY(-50%) rotate(90deg);
}

/* File Preview */
.media__file {
  margin: auto;
  min-width: 23rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  padding: 1.4rem;
  border-radius: 0.9375rem;
  box-sizing: border-box;
  background-color: #eeeef0;
}

.media__preview {
  width: 5rem;
  height: 5rem;
  flex-shrink: 0;
}

.media__preview img {
  height: 100%;
  object-fit: contain;
}

.media__details {
  display: flex;
  flex-direction: column;
  gap: 0.3125rem;
  color: #1a1c1e;
}


/* Image Display */
.media__img {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

.media__img img {
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: 1.5rem;
}

.media__img img,
.media__thumb_img {
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto;
  -webkit-user-drag: none;
}

/* Video Container */
.media__video {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  border-radius: 1.5rem;
}

.media__video video {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Responsive Design */
@media (max-height: 980px) {
  .media__wrapper {
    height: 45vh;
  }
}
@media (max-height: 860px) {
  .media__thumbnails {
    display: none;
  }
  .media__wrapper {
    height: 60vh;
  }
}

@media (max-height: 720px) {
  .media {
    margin: auto;
    height: 97vh;
    /* width: 50vw; */
  }

  .media__container {
    padding: 2rem 2.5rem;
  }

  .media__wrapper {
    margin-top: 0.5rem;
  }
}

@media (max-height: 520px) {
  .media {
    height: 99vh;
    width: 80vw;
    margin: auto;
  }
  .media__wrapper {
    height: 40vh;
  }
}

@media (max-width: 768px) {
  .media {
    margin: auto;
  }
  .media__container {
    padding: 1.5rem;
  }

  .media__wrapper {
    height: 60vh;
  }

  .media__content {
    max-width: 100%;
    padding: 0;
  }

  .media__title {
    font-size: 1.25rem;
  }

  .media__button_ico {
    width: 2.5rem;
    height: 2.5rem;
  }

  .media__file {
    flex-direction: column;
    text-align: center;
  }

  .media__details {
    align-items: center;
  }

  .media__name {
    max-width: 100%;
  }

  .media__thumb-list {
    max-width: 100%;
  }

  .media__thumb_img {
    height: 6rem;
  }

  .media__button {
    display: none;
  }

  .media__memo {
    padding: 0 .5rem;
  }
}

@media (max-width: 480px) {
  .media {
    padding: 0.5rem;
  }

  .media__container {
    padding: 1rem;
  }

  .media__wrapper {
    height: 60vh;
  }

  .media__tools {
    gap: 0.5rem;
  }
}

@media (max-width: 410px) {
  .media__tools {
    gap: 0.2rem;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  .media,
  .media__button_ico,
  .media__thumb,
  .media__thumb_img {
    transition: none;
  }

  .visible {
    animation: none;
  }
}

/* Focus Styles */
.media__save:focus-visible,
.media__close:focus-visible,
.media__button:focus-visible,
.media__save-link:focus-visible {
  outline: 2px solid #0172f0;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.media.visible {
  display: flex;
  animation: fadeIn 0.3s ease forwards;
}

.media.closing {
  display: flex;
  animation: fadeOut 0.3s ease forwards;
}

/* --- State for download button  */
button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

button:disabled:hover {
  transform: none;
}