:root {
  --folder-color: #d4af37;
  --folder-back-color: #b5952f;
  --paper-1: #e6e6e6;
  --paper-2: #ebebeb;
  --paper-3: #f0f0f0;
  --paper-4: #f5f5f5;
  --paper-5: #fafafa;
  --paper-6: #ffffff;
}

.folder-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 700px;
  position: relative;
  margin-top: 40px;
}

.folder {
  transition: all 0.2s ease-in;
  cursor: pointer;
  position: relative;
}

.folder:hover {
  transform: translateY(-8px);
}

.folder:hover .paper {
  transform: translate(-50%, 0%);
}

.folder:hover .folder__front {
  transform: skew(15deg) scaleY(0.6);
}

.folder:hover .right {
  transform: skew(-15deg) scaleY(0.6);
}

.folder.open {
  transform: translateY(-8px);
}

/* Fanning out 3 certificates */
.folder.open .paper:nth-child(1) { transform: translate(-160%, -70%) rotateZ(-20deg); }
.folder.open .paper:nth-child(1):hover { transform: translate(calc(-160% + var(--magnet-x, 0px)), calc(-70% + var(--magnet-y, 0px))) rotateZ(-20deg) scale(1.1); z-index: 10; }

.folder.open .paper:nth-child(2) { transform: translate(-50%, -90%) rotateZ(0deg); }
.folder.open .paper:nth-child(2):hover { transform: translate(calc(-50% + var(--magnet-x, 0px)), calc(-90% + var(--magnet-y, 0px))) rotateZ(0deg) scale(1.1); z-index: 10; }

.folder.open .paper:nth-child(3) { transform: translate(60%, -70%) rotateZ(20deg); }
.folder.open .paper:nth-child(3):hover { transform: translate(calc(60% + var(--magnet-x, 0px)), calc(-70% + var(--magnet-y, 0px))) rotateZ(20deg) scale(1.1); z-index: 10; }

.folder.open .folder__front {
  transform: skew(15deg) scaleY(0.6);
}

.folder.open .right {
  transform: skew(-15deg) scaleY(0.6);
}

.folder__back {
  position: relative;
  width: 200px;
  height: 160px;
  background: var(--folder-back-color);
  border-radius: 0px 15px 15px 15px;
}

.folder__back::after {
  position: absolute;
  z-index: 0;
  bottom: 98%;
  left: 0;
  content: '';
  width: 60px;
  height: 20px;
  background: var(--folder-back-color);
  border-radius: 8px 8px 0 0;
}

.paper {
  position: absolute;
  z-index: 2;
  bottom: 10%;
  left: 50%;
  transform: translate(-50%, 10%);
  width: 90%;
  height: 70%;
  border-radius: 4px;
  transition: all 0.3s ease-in-out;
  background-size: cover;
  background-position: center;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.paper:nth-child(1) { background-color: var(--paper-1); z-index: 2; }
.paper:nth-child(2) { background-color: var(--paper-2); z-index: 3; }
.paper:nth-child(3) { background-color: var(--paper-3); z-index: 4; }
.paper:nth-child(4) { background-color: var(--paper-4); z-index: 5; }
.paper:nth-child(5) { background-color: var(--paper-5); z-index: 6; }
.paper:nth-child(6) { background-color: var(--paper-6); z-index: 7; }

.folder__front {
  position: absolute;
  z-index: 8;
  width: 100%;
  height: 100%;
  background: var(--folder-color);
  border-radius: 8px 15px 15px 15px;
  transform-origin: bottom;
  transition: all 0.3s ease-in-out;
}

/* Pagination container styles */
.folder-pagination {
  position: absolute;
  top: 200px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  gap: 20px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.folder.open .folder-pagination {
  opacity: 1;
  pointer-events: auto;
}

.folder-pagination button {
  background: rgba(20, 20, 20, 0.7);
  backdrop-filter: blur(5px);
  pointer-events: auto;
  border-radius: 20px;
}

/* Certificate Modal Styles */
.cert-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.cert-modal.active {
  opacity: 1;
  visibility: visible;
}

.cert-modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cert-modal-img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 2px solid var(--folder-color);
}

.cert-modal-close {
  position: absolute;
  top: -40px;
  right: 0px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s;
}

.cert-modal-close:hover {
  color: var(--folder-color);
}

@keyframes modalPop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .folder-wrapper {
    justify-content: flex-start;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    height: 700px;
    padding: 0;
    display: flex;
  }
  
  .folder-wrapper::-webkit-scrollbar {
    display: none;
  }

  /* Create scrollable space on both sides of the folder so the fanned certificates don't get cut off */
  .folder-wrapper::before,
  .folder-wrapper::after {
    content: '';
    flex: 0 0 350px; 
  }

  .folder {
    flex-shrink: 0;
    scroll-snap-align: center;
    width: auto;
  }
}
