/* Reset and base layout */
* {
  box-sizing: border-box;
}
html, body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #111;
  font-family: sans-serif;
  height: 100%;
}

/* main page container */
.page {
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* center align for grid */
.gallery-viewport {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  justify-content: center;
  align-items: center;
}
/* wrapper for grid */
.gallery-wrapper {
  width: auto;
  overflow: visible;
}

/* Strict 5x5 grid layout */
.gallery {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 0;
  width: min(1000px, 80vh, 80vw);
  height: min(1000px, 80vh, 80vw);
}

/* info text section */
.intro {
  position: absolute;
  right: calc(50% + (min(1000px, 80vh, 80vw) / 2) + 20px);
  top: 50%;
  transform: translateY(-50%);
 // width: min(280px, 22vw);
  width: 22vw;
  padding: 20px;
  color: #fff;
  background: rgba(27, 27, 27, 0.95);
  border-radius: 8px;
  font-size: clamp(0.8rem, 0.9vw, 1rem);
  line-height: 1.5;
  z-index: 10;
}

.intro h1 {
  font-size: clamp(1.1rem, 1.5vw, 1.6rem);
  margin-bottom: 15px;
  color: #fff;
  line-height: 1.3;
}

.intro p {
  font-size: clamp(0.8rem, 0.9vw, 1rem);
  line-height: 1.5;
  color: #ddd;
  margin: 0;
  text-align:justify;
}

/* Each item is square and responsive */
.gallery-item {
  aspect-ratio: 1 / 1;
  width: 100%;
  height: 100%;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
.gallery-item img:hover {
  transform: scale(1.05);
  z-index: 500;
  position: relative;
  transition: transform 0.3s ease;
}
 h2.role{
    margin: 0;
}
p.role{
	margin-top:-0;
	font-size: clamp(0.8rem, 0.9vw, 1rem); 
	line-height: 1.5; 
	color: #ddd;
	font-weight:700; 
}
/* vertical adaptation */
@media (max-width: 1400px), (max-height: 800px) {
  .page {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 10px 0;
  }
  
  .intro {
    position: static;
    transform: none;
    right: auto;
    top: auto;
    width: 90%;
   // max-width: 500px;
    margin: 0 auto 15px;
    padding: 12px 15px;
    background: rgba(27, 27, 27, 0.95);
    border-radius: 8px;
    line-height: 1.4;
    z-index: 10;
    height: auto;
    min-height: auto;
    flex-shrink: 0;
    
    font-size: clamp(0.7rem, 4vw, 0.9rem);
  }
  
  
  .intro h1 {
    font-size: clamp(0.8rem, 5vw, 1.1rem);
    margin: 0 0 clamp(4px, 1.5vw, 8px) 0;
    padding: 0;
    line-height: 1.2;
    text-align: center;
  }
  
  .intro p {
    font-size: clamp(0.65rem, 3.5vw, 0.85rem);
    line-height: clamp(1.2, 4vw, 1.3);
    margin: 0;
    padding: 0;
    text-align:justify;
  }
  
  .gallery-viewport {
    position: static;
    transform: none;
    margin: 0 auto;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 100%;
    height: auto;
  }
  
  .gallery-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
  }
  
  .gallery {
    width: min(98vw, 98vh - clamp(80px, 25vh, 140px));
    height: min(98vw, 98vh - clamp(80px, 25vh, 140px));
    max-width: 98vw;
    max-height: calc(98vh - clamp(80px, 25vh, 140px));
  }
}

/* small screens adaptation */
@media (max-width: 480px), (max-height: 600px) {
  .page {
    padding: 8px 0;
  }
  
  .intro {
    width: 95%;
    margin: 0 auto 12px;
    //padding: clamp(6px, 2vw, 10px) clamp(8px, 3vw, 12px);
  }
  
  .intro {
    font-size: clamp(0.6rem, 3.5vw, 0.8rem);
  }
  
  .intro h1 {
    font-size: clamp(0.7rem, 4.5vw, 1rem);
    margin-bottom: clamp(3px, 1vw, 6px);
  }
  
  .intro p {
    font-size: clamp(0.55rem, 3vw, 0.75rem);
    line-height: clamp(1.1, 3vw, 1.2);
  }
  
  .gallery {
    width: min(99vw, 99vh - clamp(60px, 20vh, 100px));
    height: min(99vw, 99vh - clamp(60px, 20vh, 100px));
    max-width: 99vw;
  }
}


/* long screens adaptation */
@media (max-height: 500px) {
  body{
    overflow: auto;
  }
  .page {
    padding: 5px 0;
  }
  
  .intro {
    width:90%;
    padding: clamp(4px, 1.5vw, 8px) clamp(6px, 2vw, 10px);
    //margin-bottom: 8px;
   // font-size: clamp(0.1rem, 3vw, 0.75rem);
  }
  
  
  .intro h1 {
    font-size: clamp(0.2rem, 4vw, 0.9rem);
    margin-bottom: clamp(2px, 1vw, 4px);
  }
  
  .intro p {
    font-size: clamp(0.1rem, 2.5vw, 0.7rem);
    line-height: 1.0;
  }
  
  .gallery {
    width: min(95vw, 95vh - clamp(50px, 15vh, 70px));
    height: min(95vw, 95vh - clamp(50px, 15vh, 70px));
  }
}

/* Modal overlay */
.modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.8);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 250ms ease, visibility 250ms ease;
}
.modal.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Modal wrapper for arrows + content */
.modal-wrapper {
  position: relative;
  width: 80%;
  max-width: 1000px;
  margin: 5% auto;
}

/* Modal content layout */
.modal-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background-color: #222;
  border-radius: 8px;
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  transition: transform 300ms ease, opacity 300ms ease;
}
.modal.open .modal-content {
  transform: translateY(0) scale(1);
  opacity: 1;
}
.modal.closing .modal-content {
  transform: translateY(10px) scale(0.98);
  opacity: 0;
}

/* Full-size image */
.modal-content img {
  width: 60%;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
}

/* Text beside image */
.modal-text {
  width: 40%;
  padding-left: 20px;
  font-size: 1.1em;
  color: #fff;
  line-height: 1.6;
}

/* Close button */
.close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 2em;
  color: #fff;
  cursor: pointer;
  z-index: 2000; 
}

/* Navigation arrows */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3em;
  color: #fff;
  cursor: pointer;
  user-select: none;
  text-shadow: 0 0 10px #7fbfff;
  z-index: 2000;  
}

.left-arrow {
  left: -40px;
}

.right-arrow {
  right: -40px;
}

.nav-arrow:hover {
  color: #f7a8c4;
}

/* Link styling */
a {
  color: #7fbfff;
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: #f7a8c4;
}

a:visited {
  color: #c29eff;
}

/* Responsive modal layout */
@media (max-width: 600px) {
  .modal-wrapper {
    width: 95%;
  }

  .modal-content {
    flex-direction: column;
    padding: 10px;
  }

  .modal-content img,
  .modal-text {
    width: 100%;
    padding: 0;
  }

  .modal-text {
    margin-top: 10px;
    font-size: 1em;
  }

  .nav-arrow {
    font-size: 2em;
  }

  .left-arrow {
    left: -30px;
  }

  .right-arrow {
    right: -30px;
  }
}

.modal-spinner {
  position: absolute;
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: modal-spin 0.8s linear infinite;
  pointer-events: none;
  z-index: 2002;
}

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

.modal-content { position: relative; }
#modal-img { display: block; }