/* #region Setup */

:root {
--page-bg: rgb(178, 178, 178);
--text-dark: #111;
--accent: #ffffff;
}

*,
*::before,
*::after {
  box-sizing: border-box; /* keep layout predictable */
  margin: 0;
  padding: 0;
}


body {
  background-color: var(--page-bg);
}

body, button, .btn, .tool-btn, .tool-option {
  user-select: none;
  -webkit-user-select: none;
}

/* ============ Canvas ============ */
.canvas {
  position: fixed;
  left: 0;
  top: 0;
}

#flashOverlay {
  position: fixed;
  inset: 0;                 /* full screen */
  background: var(--text-dark);      /* white flash */
  opacity: 0;               /* start hidden */
  pointer-events: none;     /* don't block clicks */
  z-index: 9999;            /* above everything */
  transition: opacity 0.15s ease-out;
}

/* #endregion */


/* #region btn */

/* ============ Start CTA ============ */
#startBtn {
  position: absolute;
  top: 65%;
  left: 50%;
  transform: translate(-50%, -50%); /* center correctly with animation */
  padding: clamp(10px, 2.8vw, 12px) clamp(20px, 5vw, 34px);
  font-size: clamp(16px, 4vw, 28px);
  border: 1px solid var(--text-dark);
  border-radius: 8px;
  background: #fff;
  color: var(--text-dark);
  font-family: "Orbitron", sans-serif; /* keep responsive font-size from clamp */
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  z-index: 2100;
  animation: pulseScale 1.2s ease-in-out infinite alternate;
}

@keyframes pulseScale {
  from {
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    transform: translate(-50%, -50%) scale(1.08);
  }
}

/* ============ Controls Bar ============ */
.controls {
  position: fixed;
  top: 25px;
  left: 50%;                 
  transform: translateX(-50%); 
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  align-items: center;
  justify-content: center;    
  z-index: 10000;
}

.controls .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  /* Balanced size on common mobiles; slightly larger on big screens */
  height: clamp(36px, 4.2vw, 54px);
  padding: 0 clamp(12px, 3.6vw, 30px);
  font-size: clamp(15px, 2.2vw, 19px);
  border-radius: 10px;
 background: rgba(255, 255, 255, 0.559);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--text-dark);
  color: #272727;
  cursor: pointer;
  transition: background 0.25s ease,  border-color 0.25s ease,  transform 0.15s ease;
}

.controls .btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
  transform: scale(1.01);
}




.toolbox {
  position: fixed;
  top: 35px;
  right: 40px;
  left: auto;
  transform: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 9999;
}

/* blur only when there are keys */
.toolbox.has-keys {
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.35);
}




/* زر Studio mode (mainToolBtn) */
.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: clamp(38px, 4vw, 55px);
  padding: 0 clamp(14px, 3.5vw, 26px);
 font-size: clamp(15px, 2.2vw, 19px);

  border-radius: 14px;
  border: 1px solid var(--text-dark);

 background: rgba(255, 255, 255, 0.559);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  color: #272727;
  cursor: pointer;
  transition: background 0.25s ease,
              border-color 0.25s ease,
              transform 0.2s ease;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
  transform: scale(1.03);
}

.tool-btn:active {
  transform: scale(0.98);
}


/* زر الخيارات */
#toolOptions {
  display: flex;
  flex-direction: row;       /* تبقى على خط واحد */
  gap: 8px;
}

/* أزرار Add Key – Preview – Record */
/* أزرار Add Key – Preview – Record */
.tool-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: clamp(32px, 3.8vw, 50px);
  padding: 0 clamp(10px, 3vw, 22px);
  font-size: clamp(10px, 2vw, 17px);
  border-radius: 10px;

 background: rgba(255, 255, 255, 0.559);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  border: 1px solid var(--text-dark);
  color: #272727;
  cursor: pointer;
  transition: background 0.25s ease,
              border-color 0.25s ease,
              transform 0.15s ease;
}

.tool-option:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
  transform: scale(1.03);
}

/* قائمة الكيز تحت الأزرار */
/* قائمة الكيز تحت الأزرار */
.key-list {
  /* ⚠️ no position / top / left / transform here */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  /* ديناميكي حسب ارتفاع الشاشة + سقف أعلى */
  max-height: min(900px, calc(100vh - 200px));
  overflow-y: auto;
}



/* صندوق كل Key */
.key-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid #111;
  background: rgba(255, 255, 255, 0.85);
  font-family: "Prosto One", sans-serif;
  font-size: 12px;

  cursor: pointer;                /* 👈 يظهر يد عند الهوفر */
  transition: background 0.15s ease, transform 0.12s ease;
}

.key-item:hover {
  background: rgba(255, 255, 255, 1);

}


/* رقم الكي */
.key-label {
  min-width: 52px;
}

/* إدخال الوقت */
.key-time-input {
  width: 42px;
  padding: 2px 4px;
  border-radius: 6px;
  border: 1px solid #777;
  font-size: 11px;
}



.hidden {
  display: none;
}

#clearKeysBtn {
  display: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid #111;
  background: rgba(255, 255, 255, 0.85);
  font-family: "Prosto One", sans-serif;
  font-size: 12px;
  color: #111;

  cursor: pointer;
  margin-top: 10px;

  /* ✔️ خليها سنتر */
  align-self: center;

  width: auto;
  height: 26px;
}


#clearKeysBtn:hover {
  background: rgba(255, 255, 255, 1);
}
.key-item.active-key {
  background: rgba(255, 230, 120, 0.9); /* أصفر لطيف */
  border-color: #d0a200;
}

/* إدخال الوقت */
.key-time-input {
  width: 42px;
  padding: 2px 4px;
  border-radius: 6px;
  border: 1px solid #777;
  font-size: 11px;
}

/* دائرة لون الكي (نفس لون زر الماتريال) */
.key-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #555;
  flex-shrink: 0;
}

/* زر حذف الكي */
.key-delete {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}
#toolOptions.hidden {
    display: none !important;
}
#keyList.hidden {
    display: none !important;
}
#clearKeysBtn.hidden {
    display: none !important;
}
/* Camera button inside Studio mode toolbox */
#toolOptions #shotBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: clamp(32px, 3.8vw, 50px);
  padding: 0 clamp(10px, 3vw, 22px);
  border-radius: 10px;

  background: rgba(255, 255, 255, 0.559);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  border: 1px solid var(--text-dark);
  cursor: pointer;
  transition: background 0.25s ease,
              border-color 0.25s ease,
              transform 0.15s ease;
}

/* hover مثل باقي الأزرار */
#toolOptions #shotBtn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
  transform: scale(1.03);
}
#shotBtn .icon-camera {
  width: clamp(30px, 4vw, 40px);
  height: clamp(30px, 4vw, 40px);
  object-fit: contain;
  pointer-events: none;
  filter: invert(0);
}

.studio-tools {
  position: fixed;
  top: 95px;            /* تحت شريط الـ controls */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 9999;
}
/* Preset buttons row */
.studio-preset {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-top: 8px;
  align-self: center;  /* خليها بالمركز تحت الكيز */
 
}

/* Preset row line */
.preset-row {
  display: flex;
  flex-direction: row;
  gap: 6px;
  margin-top: 8px;
  align-self: center;
}

/* very small clean buttons */
.preset-btn {
  padding: 4px 14px;
  font-size: 14px;
  border-radius: 8px;

  border: 1px solid var(--text-dark);
 background: rgba(255, 255, 255, 0.559);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  color: #111;
  cursor: pointer;

  transition: background 0.2s ease, transform 0.15s ease;
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.38);
  transform: scale(1.04);
}

.preset-btn:active {
  transform: scale(0.96);
}
/* 🔴 Record button active state */
.recording-active {
  opacity: 1 !important;     /* ⬅ يمنع الشفافية */
  background: rgb(216, 32, 32) !important;
  border-color: rgb(184, 30, 30) !important;
  color: #fff !important;
  animation: recordPulse 1s infinite ease-in-out;
}




/* #endregion */


/* #region Popup */

/* ============ Popup (Enhanced Style) ============ */
.popup {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: clamp(260px, 80vw, 380px);
  max-height: 85vh;       
  padding: clamp(14px, 3vw, 24px);
  border-radius: 18px;
  /* === Premium Glass === */
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(20px) saturate(190%);
  -webkit-backdrop-filter: blur(20px) saturate(190%);
  background-clip: padding-box;
  border: 1px solid rgba(255,255,255,0.32);
  color: var(--text-dark);
  line-height: 1.5;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto; 
}


/* === Better Visibility === */
.popup.visible {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%) scale(1);
}


.popup .close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 0.95);
  font-weight: bold;
  color: var(--text-dark);
  cursor: pointer;
  font-size: 28px;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
  z-index: 99;
}
.popup .close-btn:hover {
  background: #fff;
  transform: scale(1.08);
}

/* ===== ABOUT POPUP CONTENT ===== */
#aboutPopup #popup-content {
  text-align: center;
  font-family: "Poppins", "Inter", "Roboto", sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-dark);
  letter-spacing: 0.2px;
}

#aboutPopup .about-author {
  font-family: "Orbitron", sans-serif;
   font-size: clamp(18px, 5vw, 24px);
  color: var(--text-dark);
}

#aboutPopup .about-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.2s ease;
}
#aboutPopup .about-link:hover {
  opacity: 0.8;
}

#aboutPopup .about-info {
  margin-top: 10px;
  color: rgb(36, 36, 36);
  font-size: clamp(14px, 4vw, 20px);
  font-weight: 500;  
}

#logo-pa-about {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 180px;
  overflow: hidden;
  border-radius: 16px;
  margin-bottom: 12px;
  font-family: "Prosto One", sans-serif;
}


#logo-pa-about .a,
#logo-pa-about .p {
  position: relative;
  font-size: 9rem;
  line-height: 1;
  z-index: 1;
  user-select: none;
  transition: transform 0.3s ease;
}

#logo-pa-about .a {
  color: #111;
  transform: translate(90px, 22px);
}

#logo-pa-about .p {
  color: #ffffff;
  transform: translate(-60px, -6px);
}

.mat-list {
  position: fixed;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 10px;
  width: clamp(160px, 42vw, 240px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20000;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  transition: opacity 0.2s ease, transform 0.2s ease;
  left: 0;
  top: 0;
}

.mat-list.hidden {
  display: none;
}

.mat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  color: #111;
}

.mat-item:hover {
  background: #b7b7b7;
  border-radius: 6px;
}

.mat-color {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #555;
}

/* ================= AI Generate Panel ================= */
.ai-disabled {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);

  display: flex;
  flex-direction: column;
  gap: 12px;

  padding: 20px 28px;

  background: rgba(255, 255, 255, 0.40);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.35);

 z-index: 12000;


  width: clamp(280px, 60vw, 820px);
}

.ai-disabled.hidden {
  display: none !important;
}

/* صف العنوان (حاليًا بس يحمل الـ X) */
.ai-header-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* عنوان أو لابل فوق البوكس */
.ai-title,
.ai-label {
  font-family: sans-serif;
  font-weight: 600;
  font-size: clamp(14px, 2.2vw, 18px);
  color: #111;
  opacity: 0.9;
}
.ai-label {
  display: block;
  margin-top: 32px;  /* push text + input down away from X */
}

/* زر الإغلاق (X) على اليمين فوق البوكس */
.ai-close-btn {
  position: absolute;
  top: -9px;
  right: -15px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.25);
  background: rgba(255,255,255,0.95);
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.2s ease, transform 0.15s ease;
}

.ai-close-btn:hover {
  background: #fff;
  transform: scale(1.07);
}

/* صف الـ input + زر Generate */
.ai-input-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

/* حقل البرومبت */
.ai-input {
  
  flex: 1;
  height: clamp(42px, 4.2vw, 58px);  /* 🔥 ارتفاع ديناميكي */
  padding: 16px 16px;                 /* نلغي البادينغ العمودي ونخليه بالارتفاع */

  border-radius: 10px;
  border: 1px solid #111;

  background: rgba(255, 255, 255, 0.85);
  color: #333;

  font-size: clamp(11px, 1.8vw, 16px);

  text-align: left;
}
.ai-input::placeholder {
  font-family: "Orbitron", sans-serif;
  color: #666; /* نفس اللون الحالي أو بدك أفتح */
  opacity: 0.8; /* اختياري */
}


/* زر Generate بنفس ستايل tool-option */
.ai-generate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: clamp(32px, 3.8vw, 50px);
  padding: 0 clamp(10px, 3vw, 22px);

  border-radius: 10px;
  border: 1px solid var(--text-dark);

  background: rgba(255, 255, 255, 0.559);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  cursor: pointer;
  font-size: clamp(10px, 2vw, 20px);
  gap: 6px;

  transition: background 0.25s ease,
              border-color 0.25s ease,
              transform 0.15s ease;
}

.ai-generate-btn:hover:not(.ai-busy) {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
  transform: scale(1.01);
}

.ai-generate-btn:disabled {
  opacity: 0.7;
  cursor: default;
}

/* سبنر اللودينغ */
.ai-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #000;
  animation: aiSpin 0.9s linear infinite;
}

.ai-spinner.hidden {
  display: none;
}

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

/* حالة النص تحت الزر (status) */
.ai-status {
  min-height: 18px;
  font-size: 19px;
  opacity: 0.8;
    font-family: "Orbitron", sans-serif;
}

/* مكان الصورة الناتجة من AI */
.ai-result {
  margin-top: 6px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.25);
}

.ai-result.hidden {
  display: none;
}

.ai-result img {
  display: block;
  width: 100%;
  height: auto;
}


.ai-download-btn {
  margin: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: #ffffff90;
  backdrop-filter: blur(10px);
  font-size: 18px;
  cursor: pointer;

  /* 🔥 التوسيط */
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.ai-download-btn:hover {
  background: #ffffffc5;
}



/* ========== AI Clear Button ========== */
#aiClearBtn {
  margin: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;

  background: #ffffff70;        /* نفس ستايل download */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  font-size: 18px;
  cursor: pointer;

  display: block;
  margin-left: auto;
  margin-right: auto;

  transition: background 0.25s ease, transform 0.15s ease;
}

#aiClearBtn:hover {
  background: #ffffffc5;
  transform: scale(1.03);
}

#aiClearBtn:active {
  transform: scale(0.97);
}





/* #endregion */

/* ================= HELP POPUP (Optional Tweaks) ================= */

#helpPopup {
  /* يطابق aboutPopup بالضبط لأنه يستخدم نفس .popup */
  width: clamp(300px, 85vw, 720px);

}

#helpPopup #help-content {
  text-align: left;
  font-family: "Poppins", "Inter", "Roboto", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: #222;
}

#helpPopup h2 {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(20px, 5vw, 26px);
  margin: 10px;
  text-align: center;
}

/* لو بدك صورة داخل الهيلب لاحقاً */
#helpPopup .help-image {
  width: 100%;
  border-radius: 12px;
  margin: 12px 0;
  overflow: hidden;
}


/* #region Loading Screen */

#loading-screen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgb(255, 255, 255);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 25px;
  transition: opacity 0.8s ease;
}

#loading-text {
  position: absolute;
  top: 65%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  font-family: "Prosto One", sans-serif;
  color: var(--text-dark);
  opacity: 0.8;
}

.ls-btn {
  padding: 12px 32px;
  border: none;
  background: var(--text-dark);
  color: #fff;
  border-radius: 8px;
  font-family: "Prosto One", sans-serif;
  font-size: 22px;
  cursor: pointer;
  display: none; 
  transition: background 0.25s ease;
}

.ls-btn:hover {
  background: #202020;
}

#ls-title {
  font-family: "Prosto One", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.0;
  user-select: none;
  margin-bottom: -10px; 
}

#ls-title .t1 {
  font-size: clamp(50px, 14vw, 180px);
  letter-spacing: 0.12em;
  color: var(--text-dark);
  transform: translate(5px, -90px);
}

#ls-title .t2 {
  font-size: clamp(28px, 9vw, 80px);
  letter-spacing: 0.12em;
  color: #656565;
  transform: translate(clamp(20px, 15vw, 160px), -90px);
}

/* #endregion */


/* #region Orbit Hint */
#orbitHint {
  position: fixed;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%) scale(1); 
  padding: clamp(10px, 2.5vw, 18px) clamp(32px, 4vw, 32px);
  white-space: nowrap;

  font-size: clamp(14px, 3vw, 20px);
  font-weight: 500;
  text-align: center;
  background: rgb(238, 238, 238);
  backdrop-filter: blur(20px) saturate(190%);
  -webkit-backdrop-filter: blur(20px) saturate(190%);
  border-radius: 14px;
  border: 1px solid var(--text-dark);
  box-shadow: inset 0 0 12px rgba(255,255,255,0.18), 0 8px 28px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  z-index: 5000;
  animation: hintPulse 1.5s ease-in-out infinite alternate;
   font-family: "Orbitron", sans-serif;
}

#orbitHint.hide {
  opacity: 0;
}

@keyframes hintPulse {
  from {
    transform: translateX(-50%) scale(1);    
  }
  to {
    transform: translateX(-50%) scale(1.04); 
  }
}
/* #endregion */