/* ── لودینگ: کد از بالا → ساخت لوگو و منو ── */

html.sam-is-loading,
html.sam-is-loading body {
  overflow: hidden !important;
  height: 100%;
}

html.sam-is-loading .sam-site-shell {
  visibility: hidden;
  pointer-events: none;
}

.sam-loader {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  background: #061216;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.sam-loader.is-exit {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sam-loader__bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 50% -10%, rgba(255, 184, 0, 0.08), transparent 55%),
    radial-gradient(ellipse 40% 30% at 100% 100%, rgba(15, 185, 82, 0.06), transparent 50%),
    #061216;
  pointer-events: none;
}

.sam-loader__code {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  gap: 0;
  padding: 0 2vw;
  overflow: hidden;
  mask-image: linear-gradient(180deg, #000 0%, #000 72%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 72%, transparent 100%);
  opacity: 0.92;
  transition: opacity 0.4s ease;
}

.sam-loader.is-building .sam-loader__code,
.sam-loader.is-exit .sam-loader__code {
  opacity: 0.35;
}

.sam-loader__col {
  flex: 1;
  max-width: 11%;
  min-width: 0;
  position: relative;
  height: 100%;
  overflow: hidden;
  opacity: 0.55;
}

.sam-loader__col:nth-child(odd) {
  opacity: 0.75;
}

.sam-loader__stream {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 4px;
  font-family: 'Cascadia Code', 'Fira Code', Consolas, 'Courier New', monospace;
  font-size: clamp(9px, 1.05vw, 12px);
  line-height: 1.55;
  white-space: nowrap;
  direction: ltr;
  text-align: left;
  animation: sam-loader-fall var(--fall-dur, 3.2s) linear infinite;
  animation-delay: var(--fall-delay, 0s);
}

.sam-loader__line {
  display: block;
  opacity: 0;
  animation: sam-loader-line-in 0.35s ease forwards;
  animation-delay: var(--line-delay, 0s);
}

.sam-loader__line .tn { color: #7dd3fc; }
.sam-loader__line .kw { color: #ffd700; }
.sam-loader__line .fn { color: #0fb952; }
.sam-loader__line .id { color: #f8fafc; }
.sam-loader__line .str { color: #18e838; }
.sam-loader__line .cm { color: #64748b; }
.sam-loader__line .num { color: #f97316; }

@keyframes sam-loader-fall {
  0% { transform: translateY(-55%); }
  100% { transform: translateY(0%); }
}

@keyframes sam-loader-line-in {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

/* خط اسکن — از بالا به پایین */
.sam-loader__beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #ffd700, #0fb952, #ffd700, transparent);
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.55), 0 0 48px rgba(15, 185, 82, 0.25);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  z-index: 2;
}

.sam-loader.is-active .sam-loader__beam {
  animation: sam-loader-beam 2.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes sam-loader-beam {
  0% {
    opacity: 0;
    top: 0;
  }
  8% {
    opacity: 1;
  }
  88% {
    opacity: 1;
    top: calc(100% - 3px);
  }
  100% {
    opacity: 0;
    top: calc(100% - 3px);
  }
}

/* هدر / لوگو — موقعیت مشابه منوی واقعی */
.sam-loader__header {
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  padding: 22px 0 0;
}

.sam-loader__header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 64px;
}

.sam-loader__logo {
  position: relative;
  flex-shrink: 0;
  opacity: 0;
  transform: translateY(-12px) scale(0.94);
  filter: blur(6px);
  clip-path: inset(100% 0 0 0);
  transition: none;
}

.sam-loader.is-building .sam-loader__logo,
.sam-loader.is-done .sam-loader__logo {
  animation: sam-loader-logo-build 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.sam-loader__logo img {
  display: block;
  height: 52px;
  width: auto;
  max-width: min(200px, 42vw);
}

.sam-loader__logo-scan {
  position: absolute;
  inset: -4px -8px;
  background: linear-gradient(180deg, transparent 40%, rgba(255, 215, 0, 0.35) 50%, transparent 60%);
  opacity: 0;
  pointer-events: none;
}

.sam-loader.is-building .sam-loader__logo-scan {
  animation: sam-loader-logo-scan 0.85s ease forwards;
}

@keyframes sam-loader-logo-build {
  0% {
    opacity: 0;
    transform: translateY(-12px) scale(0.94);
    filter: blur(6px);
    clip-path: inset(100% 0 0 0);
  }
  40% {
    opacity: 0.6;
    filter: blur(2px);
    clip-path: inset(55% 0 0 0);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
    clip-path: inset(0 0 0 0);
  }
}

@keyframes sam-loader-logo-scan {
  0% { opacity: 0; transform: translateY(-100%); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(100%); }
}

/* آیتم‌های منو — بعد از لوگو */
.sam-loader__nav {
  display: none;
  align-items: center;
  gap: 18px;
  flex: 1;
  justify-content: center;
  padding: 0 12px;
}

@media (min-width: 992px) {
  .sam-loader__nav {
    display: flex;
  }
}

.sam-loader__nav-item {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  width: 0;
  opacity: 0;
  transform: scaleX(0.6);
  transform-origin: center;
}

.sam-loader__nav-item:nth-child(1) { max-width: 36px; }
.sam-loader__nav-item:nth-child(2) { max-width: 52px; }
.sam-loader__nav-item:nth-child(3) { max-width: 44px; }
.sam-loader__nav-item:nth-child(4) { max-width: 48px; }
.sam-loader__nav-item:nth-child(5) { max-width: 32px; }
.sam-loader__nav-item:nth-child(6) { max-width: 56px; }

.sam-loader.is-building .sam-loader__nav-item {
  animation: sam-loader-nav-in 0.4s ease forwards;
}

.sam-loader.is-building .sam-loader__nav-item:nth-child(1) { animation-delay: 0.55s; width: 36px; }
.sam-loader.is-building .sam-loader__nav-item:nth-child(2) { animation-delay: 0.62s; width: 52px; }
.sam-loader.is-building .sam-loader__nav-item:nth-child(3) { animation-delay: 0.69s; width: 44px; }
.sam-loader.is-building .sam-loader__nav-item:nth-child(4) { animation-delay: 0.76s; width: 48px; }
.sam-loader.is-building .sam-loader__nav-item:nth-child(5) { animation-delay: 0.83s; width: 32px; }
.sam-loader.is-building .sam-loader__nav-item:nth-child(6) { animation-delay: 0.9s; width: 56px; }

@keyframes sam-loader-nav-in {
  to {
    opacity: 1;
    transform: scaleX(1);
    background: rgba(255, 215, 0, 0.35);
  }
}

.sam-loader__cta {
  display: none;
  width: 118px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffd700, #ffb800);
  opacity: 0;
  transform: translateX(12px);
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(255, 184, 0, 0.25);
}

@media (min-width: 1200px) {
  .sam-loader__cta {
    display: block;
  }

  .sam-loader.is-building .sam-loader__cta {
    animation: sam-loader-cta-in 0.45s ease 1s forwards;
  }
}

@keyframes sam-loader-cta-in {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.sam-loader__status {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: rgba(148, 163, 184, 0.9);
  font-family: IRANSansWeb, Tahoma, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  z-index: 4;
  transition: opacity 0.3s ease;
}

.sam-loader.is-done .sam-loader__status,
.sam-loader.is-exit .sam-loader__status {
  opacity: 0;
}

@media (max-width: 575px) {
  .sam-loader__header-inner {
    justify-content: center;
  }

  .sam-loader__logo img {
    height: 44px;
  }

  .sam-loader__col {
    max-width: 14%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sam-loader,
  .sam-loader * {
    animation: none !important;
    transition: none !important;
  }
}
