@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&display=swap');

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

:root{
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html,
body {
  height: 100%;
}

body {
  background: #000;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  font-family: 'Comic Neue', "Comic Sans MS", cursive;
}

header {
  background: #000;
  height: 50px;
  width: 100%;
}

.container {
  flex: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
  background: #000;
  /* شيلي background من هون، ما عاد محتاجتها */
}

.container .bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
  /* ← الإضافة الناقصة */
  z-index: 0;
  transition: opacity 0.6s ease;
  filter: blur(1px);
}

.cloudy-overlay {
  transition: 0.3s;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
  to bottom, 
  rgba(0, 0, 0, 0.6), /* تعتيم أكثر في الأعلى */
  rgba(0, 0, 0, 0.2) /* شفافية أصلية في الأسفل */
);
  z-index: 2;
  pointer-events: none;
}

.cloudy-overlay{
  opacity: 0;
  display: block;      /* دايمًا موجودة بالـ DOM، بس شفافة */
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.cloudy-overlay.active{
  opacity: 1;
}

.char {
  position: relative;
  border: none;
  /* عشان z-index يشتغل */
  z-index: 1;
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  bottom: 0;
}

.char .layer {
  position: absolute;
  height: 90%;
  bottom: 0;
  display: none;
}

#layerBody {
  display: block;
}

/* الجسم ظاهر دايمًا */

.char img {
  position: absolute;
  height: 90%;
  bottom: 0;
}

.side-buttons {
  position: absolute;
  top: 50%;
  right: 20px;
  /* يمين، بما إنه الصفحة RTL */
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 2;
  /* فوق الخلفية والشخصية */
}

.btn {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #222;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 18px;
  cursor: pointer;
}

.btn:hover {
  background: #000;
}

footer {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
  color: white;
  height: 50px;
  font-weight: bold;
  width: 100%;
}



p {
  font-size: 16px;
}

@media (max-width: 600px) {
  p {
    font-size: 14px;
  }
}

@media (min-width: 1200px) {
  p {
    font-size: 20px;
  }
}

.rain {
  position: absolute;
  top: -20px;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

.drop {
  position: absolute;
  top: -20px;
  width: 2px;
  height: 15px;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.6));
  transform: rotate(10deg);
  /* ميلان بسيط يعطي إحساس حركة الريح */
  animation: dropFall linear infinite;
}

@keyframes dropFall {
  to {
    transform: translateY(110vh) rotate(10deg);
  }
}



.cloudy-overlay.active {
  display: block;
}

/*=========== الخزانة ==========*/

.wardrobe{
  position: absolute;
  border: 2px solid #fff;
  top: 15px;
  bottom: 15px;
  right: -45%;
  width: 40%;              /* بدل 50% */
  height: auto;             /* بدل 100% — بيتحدد تلقائيًا من top/bottom */
  background: #000000;
  border-radius: 16px;      /* رجّعيها مدوّرة من كل الجهات بما إنها ما عاد ملاصقة للحواف */
 /* box-shadow: -6px 0 25px rgba(0, 0, 0, 0.25);*/
  z-index: 10;
  transition: right 0.35s ease;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.wardrobe.active{
  right: 15px;              /* بدل 0 — تترك مسافة من يمين الـ container كمان */
}

.wardrobe-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
 /* border-bottom: 2px solid #eee;*/
}

.wardrobe-tabs {
  display: flex;
  gap: 8px;
}

.tab {
  width: 42px;
  height: 42px;
  border: 2px solid #fff;
  border-radius: 50%;
  
  background: #000;
  color: #444;
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 16px;
}

.tab.active {
  background: #000;
  color: #fff;
}

.tab:hover:not(.active) {
  background: #e5e5e5;
}

#closeWardrobe {
  border: none;
  background: transparent;
  color: #fff;
}

.wardrobe-grid-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-arrow {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #fff;
  font-size: x-large;
  cursor: pointer;
  flex-shrink: 0;
  transition: 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
}

.page-arrow:hover {
  color: #fff;
  font-size: xx-large;
  font-weight: bolder;
}

.page-indicator {
  text-align: center;
  font-size: 13px;
  color: #999;
  margin-top: 10px;
}
/*
.wardrobe-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  /* 3×3 = 9 قطع */
/*  gap: 16px;
  align-content: start;
}*/

.wardrobe-grid{
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;      /* بدل grid-template-rows الثابتة — بتسمح بعدد صفوف مرن */
  gap: 16px;
  align-content: start;
}

@media (max-width: 480px){
  .wardrobe{
    padding: 14px;
  }
  .wardrobe-grid{
    grid-template-columns: repeat(3, 1fr);   /* عمودين بدل 3 */
    gap: 10px;
  }
  .wardrobe-item img{
    padding: 12px;   /* هامش أقل حوالين الصورة = مساحة أكبر للصورة نفسها */
  }
}

.wardrobe-item {
  aspect-ratio: 1;
  border: 2px solid #eee;
  border-radius: 16px;
  cursor: pointer;
  overflow: hidden;
  background: #222;
  transition: 0.2s;
}

.wardrobe-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.5));
  
  /* هامش أكبر حوالين الصورة = قطع تبين أوضح */
}

.layer-slot {
  position: absolute;
  height: 90%;
  bottom: 0;
  width: 100%;
  display: flex;
  justify-content: center;
}

.layer-slot img {
  position: absolute;
  height: 100%;
  bottom: 0;
}

.char {
  transition: transform 0.35s ease;
  /* ضيفي هاد السطر */
}

.container.wardrobe-open .char{
  transform: translateX(-18%);   /* بدل -25% — أقل بما إنه الخزانة أصغر هلأ */
}

.wardrobe-item.selected{
  border-color: #fff;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.425);
}



@media (max-width: 700px){
  header{
    height: 10px;
  }
  footer{
    margin-bottom: 40px;
  }
  .wardrobe{
    top: 48%;
    height: 50%;
    width: 95%;
    right: -100%;
    background: rgba(0, 0, 0, 0.7);
  }
  .wardrobe.active{
    right: 3%;
  }

  .container.wardrobe-open .char{
    transform: none;   /* بدل translateX(-35%) — بلاش تحاولي تحركيها */
  }

  .side-buttons{
    top: 20%;
    right: 10px;
    gap: 10px;
  }
  .btn{
    width: 38px;
    height: 38px;
    font-size: 15px;
  }
  
  .wardrobe-header{
    margin-bottom: 5px;
  }
  .wardrobe-item img{
    padding: 3px;
  }
  .page-indicator{
    display: none;
  }
  

}

@media (min-width: 1400px){
  .char img,
  .char .layer{
    max-width: 480px;   /* يمنع الشخصية من التمدد بعرض مبالغ فيه على شاشات عريضة */
  }

}


@media (max-height: 500px) and (orientation: landscape){
  .wardrobe-grid-wrapper{
    align-items: stretch;
    overflow-y: auto;
  }
  
  .wardrobe{
    top: 5%;
    height: 90%;
    width: 50%;
    right: -55%;
    padding: 10px;
  }
  .wardrobe.active{
    right: 3%;
  }
  .wardrobe-header{
    margin-bottom: 6px;
    padding-bottom: 6px;
  }
  .wardrobe-tabs{
    gap: 4px;
  }
  .tab, #closeWardrobe{
    width: 30px;
    height: 30px;
    font-size: 13px;
  }
  .wardrobe-grid{
    gap: 6px;
  }
  .wardrobe-item{
    aspect-ratio: unset;   /* يسمح للمربعات تتصغر حسب المساحة المتاحة، مش تفرض شكل مربع */
  }
  .wardrobe-item img{
    padding: 4px;
  }
  .page-arrow{
    width: 26px;
    height: 26px;
    font-size: medium;
  }
  .page-indicator{
    display: none;
  }
  .side-buttons{
    top: 50%;
    gap: 6px;
  }
  .btn{
    width: 30px;
    height: 30px;
    font-size: 12px;
  }
}

/*=======*/

#loadingScreen{
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  transition: opacity 0.4s ease;
}

.loader-spinner{
  width: 50px;
  height: 50px;
  border: 4px solid #333;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

#loadingScreen.hidden{
  opacity: 0;
  pointer-events: none;
}