/* --- Global Reset & Layout --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #b9bbb9;
  overflow: hidden; 
  width: 100vw;
  height: 100vh;
  font-family: system-ui, -apple-system, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

/* --- 90% Viewport Container --- */
.container {
  position: absolute;
  top: 50%;
  left: 50%;
  /* Using translate3d forces clean GPU rendering, preventing edge bleed */
  transform: translate3d(-50%, -50%, 0); 
  width: 90vw;
  height: 90vh;
  
  background: #b9bbb9; /* Matches body to hide sub-pixel rounding glow */
  box-shadow: 0 30px 50px #dbdbdb;
  border-radius: 20px;
  
  backface-visibility: hidden; 
  outline: 1px solid transparent; 
}

.container .slide {
  border-radius: 20px;
  width: 100%;
  height: 100%;
}

/* --- Carousel Items --- */
.container .slide .item {
  width: 200px;
  height: 300px;
  position: absolute;
  top: 50%;
  transform: translate(0, -50%);
  border-radius: 20px;
  box-shadow: 0 30px 50px #505050;
  background-position: 50% 50%;
  background-size: cover;
  display: inline-block;
  transition: all 0.5s;
}

.slide .item:nth-child(1),
.slide .item:nth-child(2) {
  top: 0;
  left: 0;
  transform: translate(0, 0);
  width: 100%;
  height: 100%;
  border-radius: 20px;
}

.slide .item:nth-child(3) { left: 65%; }
.slide .item:nth-child(4) { left: calc(65% + 220px); }
.slide .item:nth-child(5) { left: calc(65% + 440px); }
.slide .item:nth-child(n + 6) {
  left: calc(65% + 660px);
  opacity: 0;
}

/* --- Frosted Glass Content Box (Opaque Light Theme) --- */
.item .content {
  position: absolute;
  top: 50%;
  left: 32.5%; 
  transform: translate(-50%, -50%); 
  
  width: fit-content; 
  max-width: 450px;
  text-align: left;
  display: none;
  z-index: 10;
  
  background: rgba(255, 255, 255, 0.7); 
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  padding: 30px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.slide .item:nth-child(2) .content {
  display: block;
  /* Waits 0.5s for the card to expand, then fades in over 0.5s */
  animation: fadeInGlass 0.5s ease-in-out 0.5s both; 
}

/* --- Content Text (Solid Black) --- */
.content .name {
  font-size: 40px;
  text-transform: uppercase;
  font-weight: bold;
  color: #000;
  text-shadow: none; 
  /* Starts at 1.0s (after card expands + box fades in) */
  animation: animate 1s ease-in-out 1.0s both;
}

.content .des {
  margin-top: 10px;
  margin-bottom: 20px;
  font-size: 18px;
  color: #333; 
  text-shadow: none;
  /* Starts at 1.3s */
  animation: animate 1s ease-in-out 1.3s both;
}

.content button {
  padding: 10px 20px;
  border: none;
  cursor: pointer;
  border-radius: 10px;
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  transition: all 0.5s;
  /* Starts at 1.6s */
  animation: animate 1s ease-in-out 1.6s both;
}

.content button:hover {
  background-color: #000;
  transform: scale(1.05);
}

/* --- Navigation & UI --- */
.button {
  width: 100%;
  text-align: center;
  position: absolute;
  bottom: 20px;
  display: flex;
  justify-content: center;
  gap: 20px;
  z-index: 20;
}

.button button {
  width: 40px;
  height: 35px;
  border-radius: 8px;
  border: 2px solid #000000bd;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.578);
  transition: 0.3s;
}

.button button:hover {
  background: #ffffff;
  transform: scale(1.1);
}

/* --- Admin Settings Button --- */
.admin-controls {
  position: fixed;
  bottom: 10px;
  right: 10px;
  z-index: 9999;
}

#openAdmin {
  padding: 6px 10px;
  background: rgba(51, 51, 51, 0.3);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
}

#openAdmin:hover {
  background: rgba(51, 51, 51, 1);
  color: #fff;
  opacity: 1;
}

/* --- Frosted Glass Modals --- */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6); 
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal-content {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  margin: 5vh auto;
  padding: 30px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 15px;
  color: #fff;
  overscroll-behavior: contain;
}

.modal-content h2 {
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  margin-bottom: 20px;
}

.close {
  float: right;
  font-size: 28px;
  color: #fff;
  cursor: pointer;
  transition: 0.3s;
}

.close:hover {
  color: #ddd;
}

/* --- Modal Input & Button Styling (Sorting enabled) --- */
.card-edit-row {
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 15px;
  margin-bottom: 15px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.4);
}

.card-edit-row input, 
.card-edit-row textarea {
  width: 100%;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
}

.card-actions {
  display: flex;
  gap: 10px;
}

.move-up, .move-down {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: 0.3s;
  flex: 1;
  font-weight: bold;
}

.move-up:hover:not(:disabled), .move-down:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.4);
}

.move-up:disabled, .move-down:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.remove-card {
  background: rgba(255, 77, 77, 0.8);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: 0.3s;
  flex: 1;
  font-weight: bold;
}

.remove-card:hover {
  background: rgba(255, 77, 77, 1);
}

#addCardBtn, #saveAdminBtn, #backupBtn {
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 5px;
  border: none;
  font-weight: bold;
  flex: 1; 
}

#backupBtn {
  background: rgba(0, 123, 255, 0.8);
  color: white;
}

#backupBtn:hover {
  background: rgba(0, 123, 255, 1);
}

#addCardBtn {
  background: rgba(255, 255, 255, 0.8);
  color: #333;
}

#addCardBtn:hover {
  background: #fff;
}

#saveAdminBtn {
  background: rgba(40, 167, 69, 0.9);
  color: white;
}

#saveAdminBtn:hover {
  background: #28a745;
}

/* --- Password Prompt Specifics --- */
.custom-input {
  width: 100%;
  margin-bottom: 15px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  font-size: 16px;
}

.custom-submit-btn {
  padding: 12px;
  border: none;
  border-radius: 5px;
  background: rgba(40, 167, 69, 0.9);
  color: white;
  cursor: pointer;
  font-weight: bold;
  width: 100%;
  font-size: 16px;
  transition: 0.3s;
}

.custom-submit-btn:hover {
  background: rgba(40, 167, 69, 1);
}

/* --- TIER 1: Unfolded Foldables & Tablets (Square/Portrait) --- */
@media (max-width: 1024px) {
  .container {
    width: 95vw;
    height: 85vh; 
    height: 85dvh; 
  }

  /* Medium Cards */
  .container .slide .item {
    width: 150px;
    height: 225px;
    top: calc(100% - 260px); 
    transform: translate(0, 0);
  }
  
  .slide .item:nth-child(1),
  .slide .item:nth-child(2) {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }

  .slide .item:nth-child(3) { left: 45%; }
  .slide .item:nth-child(4) { left: calc(45% + 160px); }
  .slide .item:nth-child(5) { left: calc(45% + 320px); }
  .slide .item:nth-child(n + 6) { opacity: 0; }

  .item .content {
    top: 35%;
    left: 50%; 
    transform: translate(-50%, -50%); 
    width: 90%;
    max-width: 500px;
    padding: 25px;
  }

  .content .name { font-size: 32px; }
  .content .des { font-size: 16px; }

  .button {
    bottom: 25px;
  }
}

/* --- TIER 2: Standard Mobile & Folded Outer Screens (Narrow) --- */
@media (max-width: 500px) {
  /* Smaller Cards */
  .container .slide .item {
    width: 100px;
    height: 150px;
    top: calc(100% - 190px); 
  }

  .slide .item:nth-child(1),
  .slide .item:nth-child(2) {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }

  .slide .item:nth-child(3) { left: 35%; }
  .slide .item:nth-child(4) { left: calc(35% + 110px); }
  .slide .item:nth-child(5) { left: calc(35% + 220px); }

  .item .content {
    top: 35%;
    padding: 15px;
    width: 92%;
  }

  .content .name { font-size: 24px; }
  .content .des { font-size: 14px; margin-bottom: 15px;}

  .button {
    bottom: 15px;
  }

  #openAdmin {
    padding: 10px;
    font-size: 0;
  }
  #openAdmin::after {
    content: '⚙';
    font-size: 16px;
  }
}

/* --- Animations --- */
@keyframes animate {
  from {
    opacity: 0;
    transform: translate(0, 100px);
    filter: blur(33px);
  }
  to {
    opacity: 1;
    transform: translate(0);
    filter: blur(0);
  }
}

@keyframes fadeInGlass {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}