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

@font-face {
  font-family: "Vazirmatn";
  src: url("assets/font/webfonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

html,
body {
  width: 100%;
  height: 100vh;
  height: 100dvh; /* برای هماهنگی با نوار آدرس دینامیک سافاری موبایل */
  font-family: "Vazirmatn", Tahoma, Arial, sans-serif;
  background: #1a1a2e;
  color: #fff;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* جلوگیری از هرگونه اسکرول صفحه، حتی اگه جوجه با transform کمی بیرون بزنه */
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  font-family: Tahoma, "Segoe UI", sans-serif;
}

#login-screen {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ---------- جوجه ---------- */

#duck-container {
  position: relative;
  z-index: 600;
  width: clamp(150px, 50vw, 220px);
  height: clamp(150px, 50vw, 220px);
  will-change: transform;
}

/* حلقه‌ی بی‌نهایت "کشمکش" جوجه برای کشیدن چاقو بیرون از فرم */
#duck-container.tugging {
  animation: duckTug 0.45s ease-in-out infinite alternate;
}

@keyframes duckTug {
  0% {
    transform: translate(var(--duck-final-x, 0px), var(--duck-final-y, 0px))
      scale(var(--duck-final-scale, 1));
  }
  100% {
    transform: translate(
        calc(var(--duck-final-x, 0px) - 7px),
        calc(var(--duck-final-y, 0px) + 2px)
      )
      scale(var(--duck-final-scale, 1));
  }
}

/* حلقه‌ی بی‌نهایت لرزش چاقو (انگار داره مقاومت می‌کنه و گیر کرده) */
#flying-knife.tugging {
  animation: knifeTug 0.45s ease-in-out infinite alternate;
  animation-delay: 0.08s;
}

@keyframes knifeTug {
  0% {
    transform: translate(var(--knife-final-x, 0px), var(--knife-final-y, 0px))
      rotate(var(--knife-final-rot, 0deg));
  }
  100% {
    transform: translate(
        calc(var(--knife-final-x, 0px) - 3px),
        calc(var(--knife-final-y, 0px) + 1px)
      )
      rotate(calc(var(--knife-final-rot, 0deg) - 4deg));
  }
}

#duck-container svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

#knife {
  transform-origin: 0px 0px;
  animation: knifeWiggle 0.6s ease-in-out infinite;
}

@keyframes knifeWiggle {
  0%,
  100% {
    transform: translate(172px, 178px) scale(-1, 1) rotate(0deg);
  }
  50% {
    transform: translate(172px, 178px) scale(-1, 1) rotate(15deg);
  }
}

/* حالت اخم و عصبانیت */
#eyebrow-left.angry {
  transform: rotate(45deg) translateY(-1px);
}

#eyebrow-right.angry {
  transform: rotate(-45deg) translateY(-1px);
}

#angry-blush.show {
  opacity: 1;
}

#knife.paused {
  animation-play-state: paused;
}

/* چرخش ۳۶۰ درجه‌ی چاقو در هوا (داخل بدن جوجه) */
#knife.spin-throw {
  animation: knifeSpinThrow 1s ease-in-out forwards;
}

@keyframes knifeSpinThrow {
  0% {
    transform: translate(172px, 178px) scale(-1, 1) rotate(0deg);
  }
  50% {
    transform: translate(172px, 60px) scale(-1, 1) rotate(720deg);
  }
  100% {
    transform: translate(172px, 178px) scale(-1, 1) rotate(1440deg);
  }
}

/* ---------- چاقوی پرنده (مستقل از SVG جوجه) ---------- */

#flying-knife {
  position: fixed;
  top: 0;
  left: 0;
  width: clamp(70px, 22vw, 90px);
  aspect-ratio: 100 / 30;
  opacity: 0;
  pointer-events: none;
  z-index: 999;
  will-change: transform, opacity;
}

#flying-knife svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ---------- دسته‌گل پرنده (جایگزین چاقو بعد از ورود موفق) ---------- */

#flying-bouquet {
  position: fixed;
  top: 0;
  left: 0;
  width: clamp(70px, 22vw, 90px);
  aspect-ratio: 1 / 1;
  opacity: 0;
  pointer-events: none;
  z-index: 999;
  will-change: transform, opacity;
}

#flying-bouquet svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ---------- پاپ‌آپ خطا (از بالای صفحه میاد پایین) ---------- */

#error-popup {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -120%);
  width: min(90vw, 420px);
  background: #ff5c5c;
  border: 2px solid #c62828;
  border-radius: 0 0 16px 16px;
  padding: clamp(14px, 4vw, 20px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

#error-popup.show {
  transform: translate(-50%, 0%);
}

#error-popup-text {
  color: #fff;
  text-align: center;
  font-size: clamp(14px, 3.8vw, 17px);
  font-weight: bold;
  margin: 0;
}

/* ---------- حالت خوشحال جوجه (بعد از ورود موفق) ---------- */

#eyebrow-left.happy {
  transform: rotate(-15deg) translateY(-3px);
}

#eyebrow-right.happy {
  transform: rotate(15deg) translateY(-3px);
}

/* ---------- فرم لاگین ---------- */

#login-form {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(92vw, 460px);
  transform: translate(-50%, -50%) translateX(120vw);
  opacity: 0;
  background: #22223a;
  border: 2px solid #ffdd33;
  border-radius: 20px;
  padding: clamp(20px, 6vw, 32px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 500;
  pointer-events: none;
  will-change: transform, opacity;
}

#login-form.show {
  pointer-events: auto;
}

.login-title {
  color: #ffdd33;
  text-align: center;
  font-size: clamp(18px, 5vw, 28px);
  margin-bottom: clamp(16px, 4vw, 24px);
}

.input-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  color: #cfcfe8;
  font-size: clamp(12px, 3.2vw, 14px);
}

.input-group input {
  background: #1a1a2e;
  border: 1.5px solid #3a3a5c;
  border-radius: 10px;
  padding: clamp(10px, 3vw, 12px) 14px;
  color: #fff;
  font-size: clamp(14px, 3.6vw, 18px);
  outline: none;
  transition: border-color 0.2s ease;
  width: 100%;
}

.input-group input:focus {
  border-color: #ffdd33;
}

#login-btn {
  width: 100%;
  margin-top: 8px;
  padding: clamp(10px, 3vw, 13px);
  background: #ffdd33;
  border: none;
  border-radius: 10px;
  color: #1a1a1a;
  font-weight: bold;
  font-size: clamp(14px, 3.8vw, 19px);
  cursor: pointer;
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
}

#login-btn:hover {
    background: #63ee13;
    scale: 1.03;
    transition: 0.5s ease;
}

#login-btn:active {
  transform: scale(0.97);
  filter: brightness(0.95);
}

/* ---------- ریسپانسیو برای صفحه‌های خیلی کوچیک (آیفون 11 پرو و مشابه) ---------- */
@media (max-width: 400px) {
  #duck-container {
    width: 45vw;
    height: 45vw;
  }
}

@media (max-height: 700px) {
  #login-form {
    padding: clamp(14px, 5vw, 24px);
  }
  .login-title {
    margin-bottom: clamp(10px, 3vw, 16px);
  }
}
