/* Smart Campus Modal - Glassmorphism */

/* Prevent background scrolling when modal is open */
html.smc-modal-open,
body.smc-modal-open {
  overflow: hidden !important;
}

.smc-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(12, 22, 60, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 9999;
}

.smc-modal--open {
  display: flex;
  animation: smc-fade-in 160ms ease-out;
}

.smc-modal-dialog {
  width: min(900px, calc(100% - 40px));
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 40px 120px rgba(3, 12, 44, 0.45);
  border-radius: 16px;
  padding: 24px;
  color: #fff;
  backdrop-filter: blur(20px) saturate(120%);
  -webkit-backdrop-filter: blur(20px) saturate(120%);
  position: relative;
  will-change: transform, opacity;
  transition: transform 200ms ease, opacity 200ms ease;
  /* Ensure modal fits viewport and allows internal scroll */
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.smc-modal-header {
  margin-bottom: 14px;
  text-align: center;
}

.smc-modal-title {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  color: #dbeafe; /* light blue */
}

.smc-modal-body {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  grid-template-areas:
    "left right"
    "action right";
  gap: 20px;
  align-items: start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}
.smc-modal-left { grid-area: left; display: flex; flex-direction: column; gap: 12px; }
.smc-modal-right { grid-area: right; display: flex; flex-direction: column; gap: 12px; }
.smc-modal-action { grid-area: action; }
.smc-modal-title--mobile { grid-area: title; }

.smc-modal-right{
  height: 100%;
}
.smc-modal-action {
  margin-top: 12px;
  display: inline-block;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.18);
  color: #bfdbfe;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  width: 100%;
}
.smc-modal-action:hover { background: rgba(37, 99, 235, 0.26); color: #fff; }

/* Show image figure area in modal */
.smc-modal-figure { display: block; margin: 0; width: 100%; }

.smc-modal-figure img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Lazy image container with stable dimensions */
.smc-modal-figure { position: relative; }
.smc-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10; /* preserve size to prevent jumps */
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}
.smc-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 200ms ease;
}
.smc-image-wrap.is-loaded img { opacity: 1; }

/* Loader overlay shown only while loading */
.smc-image-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(17, 94, 216, 0.08));
}
.smc-image-wrap:not(.is-loading) .smc-image-loader { display: none; }
.smc-image-loader::after {
  content: '';
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: smc-spin 900ms linear infinite;
}
@keyframes smc-spin { to { transform: rotate(360deg); } }

/* Fallback fills the container if image fails */
.smc-image-fallback { height: 100%; display: flex; align-items: center; justify-content: center; }

.smc-image-placeholder {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.35);
  display: grid;
  place-items: center;
  color: #cbd5e1;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(17, 94, 216, 0.08));
}

.smc-modal-copy {
  color: #e5e7eb; /* gray-200 */
  /* Fixed-height content panel with vertical scrolling on desktop */
  height: 260px;
  overflow-y: auto;
  min-width: 0;
}
.smc-modal-copy p {
  margin: 0;
  line-height: 1.6;
}

.smc-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.18);
  color: #bfdbfe; /* blue-200 */
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.smc-modal-close:hover {
  background: rgba(37, 99, 235, 0.26);
  color: #fff;
}

@keyframes smc-fade-in {
  from { opacity: 0; transform: translate3d(0, 6px, 0); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 768px) {
  /* Fix modal height on mobile to 85dvh and enable scrolling */
  .smc-modal-dialog { height: 85dvh; }
  .smc-modal-body {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "left"
      "right"
      "action";
    gap: 12px;
    justify-items: start;
    align-items: start;
    align-content: start;
  }
  .smc-image-placeholder { height: auto; }
  /* On mobile, let copy expand naturally */
  .smc-modal-copy { height: auto; overflow: visible; }
  .smc-modal-right { display: flex; flex-direction: column; }
  .smc-modal-title--mobile { display: block; }
  .smc-modal-left,
  .smc-modal-copy,
  .smc-modal-action,
  .smc-modal-title--mobile { justify-self: center; align-self: start; }
  .smc-modal-right .smc-modal-title { display: none; }
}

@media (min-width: 769px) {
  .smc-modal-title--mobile { display: none; }
}

#contact-modal .smc-modal-dialog { width: min(1100px, calc(100% - 64px)); max-height: 92dvh; }
@media (min-width: 769px) {
  #contact-modal .smc-modal-copy { height: 460px; overflow-y: auto; }
}
@media (max-width: 768px) {
  #contact-modal .smc-modal-dialog { height: 92dvh; }
}

/* Make module cards obviously clickable */
.module-box[role="button"] { cursor: pointer; }

/* Lightbox navigation buttons */
.smc-modal-prev,
.smc-modal-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.smc-modal-prev { left: 8px; }
.smc-modal-next { right: 8px; }
.smc-modal-prev[disabled], .smc-modal-next[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Footer module list */
.smc-modal-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(12, 22, 60, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.smc-modal-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin; /* Firefox */
}
.smc-modal-list::-webkit-scrollbar { height: 8px; }
.smc-modal-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 999px; }
.smc-modal-item {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.20);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}
.smc-modal-item.is-active {
  background: rgba(37, 99, 235, 0.28);
  border-color: rgba(37, 99, 235, 0.55);
  color: #fff;
}

@media (max-width: 768px) {
  .smc-modal-prev, .smc-modal-next { width: 36px; height: 36px; }
}

/* Subtle swap transitions for prev/next */
.smc-swap-out-left { opacity: 0; transform: translateX(-8px); }
.smc-swap-out-right { opacity: 0; transform: translateX(8px); }

/* Card-level slide transitions */
.smc-card-out-left { opacity: 0; transform: translateX(-60px); }
.smc-card-out-right { opacity: 0; transform: translateX(60px); }
.smc-card-in-left { opacity: 0; transform: translateX(-60px); }
.smc-card-in-right { opacity: 0; transform: translateX(60px); }

/* Lightbox-style keyframe animations (exact behavior requested) */
@keyframes smc-slideleft {
  33% { transform: translateX(-300px); opacity: 0; }
  66% { transform: translateX(300px); opacity: 0; }
}
@keyframes smc-slideright {
  33% { transform: translateX(300px); opacity: 0; }
  66% { transform: translateX(-300px); opacity: 0; }
}
.smc-card-slideleft {
  animation-name: smc-slideleft;
  animation-duration: .5s;
  animation-timing-function: ease;
}
.smc-card-slideright {
  animation-name: smc-slideright;
  animation-duration: .5s;
  animation-timing-function: ease;
}