/* ------------------------------------------------------------------
   Intro animations: door opening + logo draw-in
   Variants are chosen with a class on <body>:
     intro-doors  door opening only
     intro-draw   logo draws itself only
     intro-both   doors open first, then the logo draws itself on the page
   ------------------------------------------------------------------ */

body.intro-doors { --t0: .8s; --open: .3s; }
body.intro-draw  { --t0: 1.7s; --g0: .2s; }   /* --g0: when the logo starts drawing */
body.intro-both  { --t0: 2.5s; --open: .3s; --g0: .9s; } /* logo draws as the doors finish opening */

body.intro-doors,
body.intro-both  { --intro-end: calc(var(--open) + 1.1s); }

/* ---------- door panels ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  direction: ltr; /* keep the left door on the left even when the page is right-to-left (Arabic) */
  cursor: pointer;
  animation: intro-gone 0s linear var(--intro-end) forwards;
}

.door {
  position: relative;
  flex: 1 1 50%;
  background-color: #222222;
  background-image: linear-gradient(90deg, rgba(255, 255, 255, .045), rgba(0, 0, 0, .16));
  animation: door-open 1s cubic-bezier(.76, 0, .24, 1) var(--open) forwards;
}
.door-l { --dir: -101%; border-right: 1px solid #3a3a3a; }
.door-r {
  --dir: 101%;
  border-left: 1px solid #3a3a3a;
  background-image: linear-gradient(270deg, rgba(255, 255, 255, .045), rgba(0, 0, 0, .16));
}

/* ---------- palace door: gold frame, arched panel, geometric inlay ---------- */
.intro {
  --gold: #c2a661;
  --arch: min(calc(25vw - 26px), 150px);
}

/* concentric gold lines around each door leaf */
.door::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 7px #222222,
    inset 0 0 0 9px var(--gold),
    inset 0 0 0 12px #222222,
    inset 0 0 0 13px rgba(194, 166, 97, .5);
}

/* recessed panels with a gold edge */
.panel {
  position: absolute;
  left: 26px;
  right: 26px;
  background-color: #1b1b1b;
  border: 1.5px solid var(--gold);
  box-shadow:
    inset 0 0 0 4px #1b1b1b,
    inset 0 0 0 5px rgba(194, 166, 97, .45),
    inset 0 0 36px rgba(0, 0, 0, .65);
}
.panel-top { top: 6%; bottom: 38%; border-radius: var(--arch) var(--arch) 8px 8px; }
.panel-bottom { top: 66%; bottom: 6%; border-radius: 8px; }

/* a slow gleam of light across the gold as the page opens */
.door::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 232, 170, .16) 50%, transparent 62%);
  transform: translateX(-110%);
  animation: door-gleam 1.3s ease-in-out .1s forwards;
}
@keyframes door-gleam {
  to { transform: translateX(110%); }
}

/* pull handle on each door, next to the seam (mirrored on the right door) */
.handle {
  position: absolute;
  top: 50%;
  right: 26px;
  height: min(62dvh, 560px);
  width: auto;
  transform: translateY(-50%);
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .55));
  pointer-events: none;
}
.door-r .handle { right: auto; left: 26px; transform: translateY(-50%) scaleX(-1); }

@keyframes door-open {
  to { transform: translateX(var(--dir)); }
}
@keyframes intro-gone {
  to { visibility: hidden; }
}

/* ---------- logo drawing (SVG) ---------- */
.logo-svg svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.logo-svg .s path {
  fill: none;
  stroke: currentColor;
  stroke-width: 7;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  animation: draw .75s cubic-bezier(.5, 0, .2, 1) forwards;
  animation-delay: calc(var(--g0, 0s) + var(--d, 0s));
}

.logo-svg .f {
  fill: currentColor;
  fill-rule: evenodd;
  opacity: 0;
  animation: fill-in .6s ease forwards;
  animation-delay: calc(var(--g0, 0s) + 1s);
}

@keyframes draw    { to { stroke-dashoffset: 0; } }
@keyframes fill-in { to { opacity: 1; } }

/* logo drawn directly on the page */
.logo-svg {
  width: min(38vw, 140px, 21dvh);
  aspect-ratio: 580 / 950;
  color: var(--ink);
}

/* ---------- skipped (tap on the intro, or returning visitor) ---------- */
body.intro-skipped { --t0: 0s !important; }
body.intro-skipped .intro { display: none; }
body.intro-skipped .logo-svg .s path { animation: none; stroke-dashoffset: 0; }
body.intro-skipped .logo-svg .f { animation: none; opacity: 1; }

/* ---------- preview helper (only on the preview pages) ---------- */
.preview-tag {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 10px;
  z-index: 5;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: .78rem;
  color: var(--muted);
}
.preview-tag button {
  font: inherit;
  padding: 4px 10px;
  border: 1px solid var(--muted);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  body.intro-doors, body.intro-draw, body.intro-both { --t0: 0s; }
  .intro { display: none; }
  .logo-svg .s path { animation: none; stroke-dashoffset: 0; }
  .logo-svg .f { animation: none; opacity: 1; }
}
