/* قلمرو یلدا - دروازه ساده و واضح */

:root {
  --bg: #0a0b1e;
  --gold: #e8b84a;
  --gold-soft: #f0d080;
  --gold-bright: #ffe9a8;
  --stone: #2e2740;
  --stone-dark: #1c1828;
  --sky: #8fd4ff;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: 'Vazirmatn', system-ui, sans-serif;
  color: #f5e9d5;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}

.world {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

/* sky */
.sky {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 120% 70% at 50% 0%, #1a1440 0%, transparent 55%),
              linear-gradient(180deg, #0c0a1c, #14122e 50%, #0e0c1a);
  z-index: 0;
}

.stars {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: #fff;
  border-radius: 50%;
  opacity: 0.7;
  animation: twinkle 3s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.mist {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30%;
  background: linear-gradient(transparent, rgba(160,140,200,0.07));
  z-index: 2;
  pointer-events: none;
}

.particles {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.particle {
  position: absolute;
  bottom: 0;
  width: 3px;
  height: 3px;
  background: var(--gold-soft);
  border-radius: 50%;
  opacity: 0;
  animation: up 11s linear infinite;
  box-shadow: 0 0 6px var(--gold);
}

@keyframes up {
  0% { opacity: 0; transform: translateY(0); }
  15% { opacity: 0.7; }
  100% { opacity: 0; transform: translateY(-100vh); }
}

/* title */
.title {
  position: absolute;
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 20;
}

.title h1 {
  font-family: 'Gulzar', serif;
  font-weight: 400;
  font-size: clamp(22px, 6vw, 32px);
  color: var(--gold-soft);
  text-shadow: 0 0 18px rgba(232,184,74,0.4);
}

.title span {
  color: var(--gold);
  font-size: 12px;
  opacity: 0.7;
}

/* ========== GATE ========== */
.gate {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -52%);
  width: min(88vw, 340px);
  height: min(58vh, 420px);
  z-index: 10;
  transition: transform 2.8s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* pillars */
.pillar {
  position: absolute;
  bottom: 0;
  width: 18%;
  height: 92%;
  background: linear-gradient(180deg, #3d354f 0%, var(--stone) 40%, var(--stone-dark));
  border-radius: 6px 6px 2px 2px;
  box-shadow: inset 0 0 16px rgba(0,0,0,0.4), 0 0 20px rgba(0,0,0,0.5);
  z-index: 5;
}

.pillar.left { left: 0; }
.pillar.right { right: 0; }

.pillar::before {
  content: '';
  position: absolute;
  left: 15%;
  right: 15%;
  top: 18%;
  height: 8%;
  background: linear-gradient(transparent, var(--gold), transparent);
  opacity: 0.55;
  border-radius: 2px;
  box-shadow: 0 0 10px var(--gold);
  animation: pulse 3.5s ease-in-out infinite;
}

.pillar.right::before { animation-delay: 1.2s; }

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.8; }
}

/* arch */
.arch {
  position: absolute;
  top: 0;
  left: 6%;
  right: 6%;
  height: 34%;
  border: 12px solid #3d354f;
  border-bottom: none;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  z-index: 6;
  box-shadow: inset 0 6px 18px rgba(0,0,0,0.35);
}

.arch::after {
  content: '';
  position: absolute;
  inset: 8px 12px 0;
  border: 4px solid rgba(232,184,74,0.3);
  border-bottom: none;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.arch-jewel {
  position: absolute;
  top: 4%;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  background: radial-gradient(circle at 35% 30%, var(--gold-bright), var(--gold));
  border-radius: 50%;
  box-shadow: 0 0 14px var(--gold);
  z-index: 7;
  animation: pulse 2.8s ease-in-out infinite;
}

/* ===== DOORS ===== */
.doors {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 18%;
  bottom: 0;
  z-index: 4;
  display: flex;
}

.door {
  width: 50%;
  height: 100%;
  transition: transform 2.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.left-door { transform-origin: left center; }
.right-door { transform-origin: right center; }

.door-inner {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #352f4a 0%, #241e35 40%, #1a1528 100%);
  border: 2px solid rgba(232,184,74,0.35);
  position: relative;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
}

.left-door .door-inner {
  border-right: 1px solid rgba(232,184,74,0.2);
  border-radius: 3px 0 0 2px;
}

.right-door .door-inner {
  border-left: 1px solid rgba(232,184,74,0.2);
  border-radius: 0 3px 2px 0;
}

.door-inner::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translateX(-50%);
  width: 38%;
  height: 16%;
  border: 1.5px solid rgba(232,184,74,0.4);
  border-radius: 50%;
}

.door-inner::after {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  top: 42%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232,184,74,0.35), transparent);
}

/* light */
.light {
  position: absolute;
  left: 20%;
  right: 20%;
  top: 20%;
  bottom: 5%;
  background: radial-gradient(ellipse at 50% 50%,
    rgba(255,230,160,0.95) 0%,
    rgba(255,200,100,0.5) 35%,
    rgba(180,120,255,0.15) 65%,
    transparent 80%);
  opacity: 0;
  z-index: 3;
  transition: opacity 2.2s ease;
  filter: blur(3px);
  pointer-events: none;
}

/* ===== LOCK SLOTS ===== */
.lock {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%);
  display: flex;
  direction: ltr;
  gap: 8px;
  z-index: 30;
  transition: opacity 1s ease;
}

.slot {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2.5px solid rgba(232,184,74,0.7);
  background: radial-gradient(circle at 40% 35%,
    rgba(255,220,140,0.3),
    rgba(40,30,60,0.95) 70%);
  color: var(--gold-bright);
  font-size: 18px;
  font-weight: 600;
  font-family: 'Vazirmatn', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(232,184,74,0.35),
              inset 0 0 10px rgba(255,200,100,0.12);
  transition: 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.slot:active { transform: scale(0.92); }

.slot.has {
  background: radial-gradient(circle at 40% 35%,
    rgba(255,230,160,0.65),
    rgba(90,55,20,0.95) 70%);
  border-color: var(--gold-bright);
  box-shadow: 0 0 20px rgba(255,200,100,0.7),
              inset 0 0 12px rgba(255,230,160,0.35);
  text-shadow: 0 0 8px rgba(255,220,140,0.9);
}

.slot.checking {
  animation: slotPulse 0.6s ease-in-out infinite;
}

@keyframes slotPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(232,184,74,0.4); }
  50% { box-shadow: 0 0 26px rgba(255,220,140,0.9); }
}

/* ===== OPENING ===== */
body.open .gate {
  transform: translate(-50%, -52%) scale(1.25);
}

body.open .left-door {
  transform: perspective(500px) rotateY(-75deg);
}

body.open .right-door {
  transform: perspective(500px) rotateY(75deg);
}

body.open .light { opacity: 1; }

body.open .lock {
  opacity: 0;
  pointer-events: none;
}

body.open .title {
  opacity: 0;
  transition: opacity 1.2s ease;
}

/* ===== BUTTERFLY ===== */
.butterfly {
  position: absolute;
  left: 72%;
  top: 28%;
  width: 28px;
  height: 24px;
  z-index: 25;
  cursor: pointer;
  transition: left 3.5s ease, top 3.5s ease;
  animation: float 3.5s ease-in-out infinite;
}

.butterfly .w {
  position: absolute;
  width: 12px;
  height: 14px;
  background: linear-gradient(145deg, #c4ebff, #8fd4ff 50%, #5bb8f0);
  border-radius: 70% 40% 50% 50%;
  opacity: 0.9;
  box-shadow: 0 0 8px rgba(143,212,255,0.5);
  top: 2px;
}

.butterfly .w.left {
  left: 0;
  transform-origin: right center;
  animation: flap 0.3s ease-in-out infinite alternate;
}

.butterfly .w.right {
  right: 0;
  transform-origin: left center;
  animation: flap 0.3s ease-in-out infinite alternate-reverse;
  border-radius: 40% 70% 50% 50%;
}

.butterfly .body {
  position: absolute;
  left: 50%;
  top: 6px;
  transform: translateX(-50%);
  width: 4px;
  height: 12px;
  background: linear-gradient(#eaf6ff, #7ec8f0);
  border-radius: 2px;
  z-index: 2;
  box-shadow: 0 0 4px #8fd4ff;
}

@keyframes flap {
  0% { transform: scaleX(1); }
  100% { transform: scaleX(0.5); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* message */
.msg {
  position: absolute;
  left: 50%;
  bottom: 7%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 320px;
  text-align: center;
  font-size: 13px;
  font-weight: 300;
  color: var(--gold-soft);
  opacity: 0;
  transition: opacity 0.7s ease;
  z-index: 30;
  text-shadow: 0 0 10px rgba(232,184,74,0.35);
  line-height: 1.7;
  pointer-events: none;
}

.msg.show { opacity: 0.92; }

/* mobile */
@media (max-width: 480px) {
  .gate {
    width: 92vw;
    height: min(55vh, 390px);
  }
  .slot {
    width: 40px;
    height: 40px;
    font-size: 17px;
  }
  .lock { gap: 6px; top: 60%; }
  .butterfly { left: 75%; top: 24%; width: 26px; height: 22px; }
  .msg { bottom: 5%; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .star, .particle, .butterfly, .butterfly .w { animation: none !important; }
  body.open .left-door,
  body.open .right-door,
  body.open .gate,
  body.open .light { transition-duration: 0.5s !important; }
}
