/* ============================================================
   FMI Masonry Gallery - Enhanced Responsive Lightbox v2.0
   Matches FMI mockup designs across all breakpoints
   ============================================================ */

/* Modal Overlay */
.fmi-mg-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100000;
  opacity: 0;
  transition: opacity 0.3s ease;
  overflow-y: auto;
  padding: 20px;
}

.fmi-mg-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

/* Modal Content Container */
.fmi-mg-modal-content {
  background: #ffffff;
  border-radius: 16px;
  max-width: 1610px;
  width: 95%;
  max-height: 95vh;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: row;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
  animation: modalSlideIn 0.35s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Close Button - Pill shaped with border */
.fmi-mg-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  color: #333;
  font-size: 24px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  font-family: 'Poppins', sans-serif;
  outline: none;
  box-shadow: none;
}

.fmi-mg-modal-close:hover {
  background: #f5f5f5;
  border-color: #ccc;
  transform: scale(1.05);
}

.fmi-mg-modal-close:focus {
  outline: none;
  box-shadow: none;
  border-color: #e0e0e0;
}

.fmi-mg-modal-close:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Image Container */
.fmi-mg-modal-image-wrapper {
  flex: 0 0 69%;
  max-width: 69%;
  background: #f8f8f8;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.fmi-mg-modal-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 90vh;
  transition: opacity 0.25s ease-in-out;
}

/* Info Panel */
.fmi-mg-modal-info {
  flex: 1;
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow-y: auto;
  max-height: 80vh;
}

/* Title */
.fmi-mg-modal-title {
  font-family: 'Poppins', sans-serif;
  font-size: 24px;
  font-weight: 600;
  color: #1a1a1a;
  margin: 0 0 24px 0;
  line-height: 1.3;
  padding-right: 50px; /* Space for close button */
  text-align: left;
}

/* Download Buttons Container */
.fmi-mg-modal-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  justify-content: flex-start;
}

/* Download Buttons - Equal width, purple theme */
.fmi-mg-modal-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 20px;
  border-radius: 8px;
  background: transparent;
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-sizing: border-box;
}

/* Primary: Download Image — solid purple */
#modal-download-image {
  background-color: #7c5cfc;
  color: #ffffff;
  border: 1.5px solid #7c5cfc;
}
#modal-download-image:hover {
  background-color: #6a4ce0;
  box-shadow: 0 2px 8px rgba(124, 92, 252, 0.3);
  transform: translateY(-1px);
}

/* Secondary: Download Package — outlined purple */
#modal-download-package {
  background-color: transparent;
  color: #7c5cfc;
  border: 1.5px solid #7c5cfc;
}
#modal-download-package:hover {
  background-color: rgba(124, 92, 252, 0.06);
}

/* Metadata Grid */
.fmi-mg-modal-metadata {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 24px;
  padding-top: 20px;
  border-top: 1px solid #eaeaea;
}

/* Metadata Row - Horizontal layout */
.fmi-mg-modal-meta-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

/* Metadata Label */
.fmi-mg-modal-meta-label {
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #777;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Metadata Tag - Light purple pill, consistent sizing */
.fmi-mg-modal-meta-tag {
  display: inline-block;
  padding: 5px 14px;
  background: #ede7f6;
  border-radius: 14px;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #4a4a6a;
  white-space: nowrap;
  min-width: 70px;
  text-align: center;
}

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Desktop Wide - Side by side, image left */
@media (min-width: 1200px) {
  .fmi-mg-modal-content {
    max-width: 1000px;
    flex-direction: row;
  }
  
  .fmi-mg-modal-image-wrapper {
    flex: 0 0 55%;
    max-width: 55%;
  }
  
  .fmi-mg-modal-info {
    flex: 0 0 45%;
    max-width: 45%;
    padding: 40px;
  }
  
  .fmi-mg-modal-title {
    font-size: 26px;
  }
}

/* Desktop Standard - Side by side equal */
@media (min-width: 900px) and (max-width: 1199px) {
  .fmi-mg-modal-content {
    max-width: 880px;
    flex-direction: row;
  }
  
  .fmi-mg-modal-image-wrapper {
    flex: 0 0 50%;
    max-width: 50%;
  }
  
  .fmi-mg-modal-info {
    flex: 0 0 50%;
    max-width: 50%;
    padding: 32px;
  }
}

/* Tablet Landscape - Narrower side by side */
@media (min-width: 769px) and (max-width: 899px) {
  .fmi-mg-modal-content {
    max-width: 780px;
    flex-direction: row;
  }
  
  .fmi-mg-modal-image-wrapper {
    flex: 0 0 45%;
    max-width: 45%;
  }
  
  .fmi-mg-modal-info {
    flex: 0 0 55%;
    max-width: 55%;
    padding: 28px;
  }
  
  .fmi-mg-modal-title {
    font-size: 22px;
  }
  
  .fmi-mg-modal-metadata {
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
  }
}

/* Tablet Portrait - Stacked layout */
@media (min-width: 600px) and (max-width: 768px) {
  .fmi-mg-modal {
    padding: 16px;
    align-items: flex-start;
    padding-top: 40px;
  }
  
  .fmi-mg-modal-content {
    flex-direction: column;
    max-width: 600px;
    max-height: none;
  }
  
  .fmi-mg-modal-image-wrapper {
    flex: none;
    max-width: 100%;
    width: 100%;
    max-height: 45vh;
  }
  
  .fmi-mg-modal-image-wrapper img {
    max-height: 45vh;
  }
  
  .fmi-mg-modal-info {
    flex: none;
    max-height: none;
    padding: 24px;
    overflow: visible;
  }
  
  .fmi-mg-modal-close {
    top: 12px;
    right: 12px;
  }
  
  .fmi-mg-modal-title {
    font-size: 22px;
    padding-right: 0;
    margin-top: 0;
  }
  
  .fmi-mg-modal-metadata {
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
  }
}

/* Mobile Landscape */
@media (max-width: 599px) and (orientation: landscape) {
  .fmi-mg-modal {
    padding: 10px;
    align-items: flex-start;
  }
  
  .fmi-mg-modal-content {
    flex-direction: column;
    max-width: 100%;
    max-height: none;
    border-radius: 12px;
  }
  
  .fmi-mg-modal-image-wrapper {
    flex: none;
    max-width: 100%;
    width: 100%;
    max-height: 50vh;
  }
  
  .fmi-mg-modal-image-wrapper img {
    max-height: 50vh;
  }
  
  .fmi-mg-modal-info {
    flex: none;
    padding: 20px;
    overflow: visible;
  }
  
  .fmi-mg-modal-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
  
  .fmi-mg-modal-title {
    font-size: 20px;
    margin-bottom: 16px;
  }
  
  .fmi-mg-modal-actions {
    gap: 10px;
    margin-bottom: 20px;
  }
  
  .fmi-mg-modal-btn {
    padding: 10px 20px;
    font-size: 14px;
  }
  
  .fmi-mg-modal-metadata {
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
  }
  
  .fmi-mg-modal-meta-label {
    font-size: 13px;
  }
  
  .fmi-mg-modal-meta-tag {
    font-size: 13px;
    padding: 6px 12px;
  }
}

/* Mobile Portrait - Full width stacked */
@media (max-width: 599px) and (orientation: portrait) {
  .fmi-mg-modal {
    padding: 0;
    align-items: flex-start;
  }
  
  .fmi-mg-modal-content {
    flex-direction: column;
    max-width: 100%;
    width: 100%;
    max-height: none;
    min-height: 100vh;
    border-radius: 0;
    margin: 0;
  }
  
  .fmi-mg-modal-image-wrapper {
    flex: none;
    max-width: 100%;
    width: 100%;
    min-height: 280px;
    max-height: 45vh;
    background: #f0f0f0;
  }
  
  .fmi-mg-modal-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    max-height: 45vh;
  }
  
  .fmi-mg-modal-info {
    flex: 1;
    padding: 24px 20px 40px;
    overflow: visible;
    max-height: none;
  }
  
  .fmi-mg-modal-close {
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 24px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }
  
  .fmi-mg-modal-title {
    font-size: 22px;
    margin-bottom: 20px;
    padding-right: 0;
    line-height: 1.35;
  }
  
  .fmi-mg-modal-actions {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 28px;
  }
  
  .fmi-mg-modal-btn {
    width: fit-content;
    padding: 14px 28px;
    font-size: 15px;
  }
  
  /* Single column metadata on mobile portrait */
  .fmi-mg-modal-metadata {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .fmi-mg-modal-meta-row {
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }
  
  .fmi-mg-modal-meta-label {
    flex: 0 0 110px;
    font-size: 15px;
  }
  
  .fmi-mg-modal-meta-tag {
    font-size: 14px;
    padding: 10px 18px;
  }
}

/* Very small phones */
@media (max-width: 374px) {
  .fmi-mg-modal-info {
    padding: 20px 16px 32px;
  }
  
  .fmi-mg-modal-title {
    font-size: 20px;
  }
  
  .fmi-mg-modal-meta-label {
    flex: 0 0 95px;
    font-size: 14px;
  }
  
  .fmi-mg-modal-meta-tag {
    font-size: 13px;
    padding: 8px 14px;
  }
}

/* ============================================================
   LANDSCAPE IMAGE HANDLING - Stacked layout (image top, info below)
   ============================================================ */

.fmi-mg-modal-content.landscape-image {
  flex-direction: column;
  max-width: 750px;
  padding: 20px;
  align-items: stretch;
  overflow: visible;
}

.fmi-mg-modal-content.landscape-image .fmi-mg-modal-image-wrapper {
  flex: none;
  max-width: 100%;
  width: 100%;
  max-height: 50vh;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.fmi-mg-modal-content.landscape-image .fmi-mg-modal-image-wrapper img {
  width: 100%;
  height: auto;
  max-height: 50vh;
  object-fit: contain;
  display: block;
}

/* Close button INSIDE image area for landscape */
.fmi-mg-modal-content.landscape-image .fmi-mg-modal-close {
  top: 28px;
  right: 28px;
}

/* Info section - everything flush left */
.fmi-mg-modal-content.landscape-image .fmi-mg-modal-info {
  flex: none;
  width: 100%;
  max-height: none;
  padding: 20px 0 8px 0;
  text-align: left;
  overflow: visible;
}

.fmi-mg-modal-content.landscape-image .fmi-mg-modal-title {
  text-align: left;
  padding-right: 0;
  margin-bottom: 16px;
  white-space: nowrap;
}

.fmi-mg-modal-content.landscape-image .fmi-mg-modal-actions {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

/* Metadata grid - two columns, flush left, prevent cutoff */
.fmi-mg-modal-content.landscape-image .fmi-mg-modal-metadata {
  display: grid;
  grid-template-columns: auto auto;
  gap: 10px 30px;
  width: fit-content;
}

.fmi-mg-modal-content.landscape-image .fmi-mg-modal-meta-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.fmi-mg-modal-content.landscape-image .fmi-mg-modal-meta-label {
  min-width: 80px;
}

/* ============================================================
   PORTRAIT IMAGE HANDLING - Side by side (image left, info right)
   ============================================================ */

.fmi-mg-modal-content.portrait-image {
  flex-direction: row;
  max-width: 900px;
  padding: 20px;
}

.fmi-mg-modal-content.portrait-image .fmi-mg-modal-image-wrapper {
  flex: 0 0 40%;
  max-width: 40%;
  max-height: 80vh;
  border-radius: 8px;
  overflow: hidden;
}

.fmi-mg-modal-content.portrait-image .fmi-mg-modal-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 80vh;
}

.fmi-mg-modal-content.portrait-image .fmi-mg-modal-info {
  flex: 1;
  max-width: 60%;
  padding: 0 0 0 24px;
}

/* Close button for portrait */
.fmi-mg-modal-content.portrait-image .fmi-mg-modal-close {
  top: 28px;
  right: 28px;
}

@media (min-width: 769px) {
  .fmi-mg-modal-content.portrait-image {
    max-width: 900px;
  }
  
  .fmi-mg-modal-content.portrait-image .fmi-mg-modal-image-wrapper {
    flex: 0 0 40%;
    max-width: 40%;
    max-height: 80vh;
  }
  
  .fmi-mg-modal-content.portrait-image .fmi-mg-modal-info {
    flex: 1;
    max-width: 60%;
    max-height: none;
  }
}

/* ============================================================
   SQUARE IMAGE HANDLING - Side by side (image left, info right)
   Same as portrait but with aspect-ratio constraint
   ============================================================ */

.fmi-mg-modal-content.square-image {
  flex-direction: row;
  max-width: 1125px;
  padding: 25px;
}

.fmi-mg-modal-content.square-image .fmi-mg-modal-image-wrapper {
  flex: 0 0 50%;
  max-width: 50%;
  border-radius: 8px;
  overflow: hidden;
}

.fmi-mg-modal-content.square-image .fmi-mg-modal-info {
  flex: 1;
  max-width: 50%;
  padding: 0 0 0 30px;
}

/* Close button for square */
.fmi-mg-modal-content.square-image .fmi-mg-modal-close {
  top: 35px;
  right: 35px;
}

@media (min-width: 769px) {
  .fmi-mg-modal-content.square-image {
    max-width: 1125px;
  }
  
  .fmi-mg-modal-content.square-image .fmi-mg-modal-image-wrapper {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

/* ============================================================
   LOADING STATE
   ============================================================ */

.fmi-mg-modal-image-wrapper.loading {
  position: relative;
}

.fmi-mg-modal-image-wrapper.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid #e0e0e0;
  border-top-color: #40009f;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   NAVIGATION ARROWS - Hidden for now, can be enabled later
   ============================================================ */

.fmi-mg-modal-nav {
  display: none !important; /* Hidden by default */
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  z-index: 5;
}

.fmi-mg-modal-nav:hover {
  background: #ffffff;
  transform: translateY(-50%) scale(1.1);
}

.fmi-mg-modal-nav.prev {
  left: 16px;
}

.fmi-mg-modal-nav.next {
  right: 16px;
}

.fmi-mg-modal-nav svg {
  width: 24px;
  height: 24px;
  stroke: #333;
  stroke-width: 2;
  fill: none;
}

@media (max-width: 768px) {
  .fmi-mg-modal-nav {
    display: none;
  }
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

.fmi-mg-modal:focus {
  outline: none;
}

.fmi-mg-modal-btn:focus,
.fmi-mg-modal-nav:focus {
  outline: 2px solid #40009f;
  outline-offset: 2px;
}

/* Close button should not have purple outline */
.fmi-mg-modal-close:focus {
  outline: none;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .fmi-mg-modal,
  .fmi-mg-modal-content,
  .fmi-mg-modal-close,
  .fmi-mg-modal-btn {
    transition: none;
    animation: none;
  }
}
