/* =====================================================================
   فَذَكِّرْ page loader — a stretched canvas print turning in 3D.
   Shared by the first-load loader (static markup in index.html, shown
   before the app's JavaScript arrives) and the route-change loader
   (components/PageLoader.js). Loaded from index.html so it's ready instantly.
   ===================================================================== */

.fz-loader {
  --fz-cream: #fbf8f3;
  --fz-sand: #f1e8db;
  --fz-gold: #c9a46a;
  --fz-brown: #9b773d;
  --fz-deep: #6f5630;
  --fz-ink: #4a3f30;
  --fz-w: 120px;          /* canvas width  */
  --fz-h: 150px;          /* canvas height */
  --fz-d: 14px;           /* canvas depth (stretcher bar) */

  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 34px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(201, 164, 106, 0.16) 0%, transparent 55%),
    radial-gradient(ellipse at center, var(--fz-cream) 0%, var(--fz-sand) 100%);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  direction: rtl;
}

.fz-loader--hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ── 3D stage ── */
.fz-stage {
  position: relative;
  width: 220px;
  height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 900px;
}

.fz-float {
  transform-style: preserve-3d;
  animation: fzFloat 2.6s ease-in-out infinite;
}

.fz-canvas {
  position: relative;
  width: var(--fz-w);
  height: var(--fz-h);
  transform-style: preserve-3d;
  animation: fzTurn 5.2s cubic-bezier(0.55, 0.05, 0.35, 0.95) infinite;
}

.fz-face {
  position: absolute;
  backface-visibility: hidden;
}

/* Front: the printed artwork, with a white gallery border */
.fz-front {
  inset: 0;
  transform: translateZ(calc(var(--fz-d) / 2));
  border-radius: 3px;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.9), transparent 55%),
    linear-gradient(160deg, #f8f1e6 0%, #ecdfca 60%, #e2cfb2 100%);
  box-shadow:
    inset 0 0 0 6px #fffdf9,
    inset 0 0 0 7px rgba(201, 164, 106, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fz-art {
  font-family: 'Aref Ruqaa', 'Tajawal', serif;
  font-size: 66px;
  font-weight: 700;
  line-height: 1;
  color: var(--fz-deep);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.6);
  transform: translateY(-4px);
}

/* Gold light sweeping across the print */
.fz-sheen {
  position: absolute;
  inset: -50%;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 238, 200, 0.75) 50%, transparent 58%);
  animation: fzSheen 2.6s ease-in-out infinite;
}

/* Back: kraft paper over the wooden stretcher */
.fz-back {
  inset: 0;
  transform: rotateY(180deg) translateZ(calc(var(--fz-d) / 2));
  border-radius: 3px;
  background:
    linear-gradient(90deg, #a77d4b 0 10px, transparent 10px calc(100% - 10px), #a77d4b calc(100% - 10px)),
    linear-gradient(0deg, #a77d4b 0 10px, transparent 10px calc(100% - 10px), #a77d4b calc(100% - 10px)),
    linear-gradient(160deg, #d8bf96 0%, #c5a676 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.fz-back::after {
  content: "فَذَكِّرْ";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Aref Ruqaa', serif;
  font-size: 22px;
  color: rgba(74, 52, 28, 0.45);
}

/* Sides: canvas wrapped around the stretcher bars */
.fz-side {
  background: linear-gradient(180deg, #efe3cf 0%, #d9c4a2 100%);
}
.fz-right,
.fz-left {
  top: 0;
  left: 50%;
  width: var(--fz-d);
  height: 100%;
  margin-left: calc(var(--fz-d) / -2);
}
.fz-right { transform: rotateY(90deg) translateZ(calc(var(--fz-w) / 2)); }
.fz-left  { transform: rotateY(-90deg) translateZ(calc(var(--fz-w) / 2)); filter: brightness(0.86); }
.fz-top,
.fz-bottom {
  left: 0;
  top: 50%;
  width: 100%;
  height: var(--fz-d);
  margin-top: calc(var(--fz-d) / -2);
}
.fz-top    { transform: rotateX(90deg) translateZ(calc(var(--fz-h) / 2)); filter: brightness(1.05); }
.fz-bottom { transform: rotateX(-90deg) translateZ(calc(var(--fz-h) / 2)); filter: brightness(0.8); }

/* Soft shadow on the "floor", breathing with the float */
.fz-shadow {
  position: absolute;
  bottom: 6px;
  left: 50%;
  width: 120px;
  height: 16px;
  margin-left: -60px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(90, 64, 34, 0.32) 0%, transparent 70%);
  animation: fzShadow 2.6s ease-in-out infinite;
}

/* Gold sparkles orbiting the canvas */
.fz-orbit {
  position: absolute;
  inset: 0;
  animation: fzOrbit 6s linear infinite;
  pointer-events: none;
}
.fz-spark {
  position: absolute;
  width: 9px;
  height: 9px;
  background: var(--fz-gold);
  transform: rotate(45deg);
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(201, 164, 106, 0.8);
  animation: fzTwinkle 1.8s ease-in-out infinite;
}
.fz-spark:nth-child(1) { top: 14px; left: 50%; }
.fz-spark:nth-child(2) { bottom: 48px; left: 10px; width: 6px; height: 6px; animation-delay: 0.6s; }
.fz-spark:nth-child(3) { bottom: 62px; right: 8px; width: 7px; height: 7px; animation-delay: 1.2s; }

/* ── Brand + progress ── */
.fz-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.fz-name {
  font-family: 'Aref Ruqaa', 'Tajawal', serif;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  color: var(--fz-deep);
}

.fz-tagline {
  font-family: 'Tajawal', sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  color: #a08a6b;
  letter-spacing: 0.2px;
}

.fz-bar {
  position: relative;
  width: 140px;
  height: 3px;
  margin-top: 6px;
  border-radius: 3px;
  background: #e8dccb;
  overflow: hidden;
}
.fz-bar::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 45%;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--fz-gold), var(--fz-brown));
  animation: fzBar 1.3s ease-in-out infinite;
}

/* ── Motion ── */
@keyframes fzTurn {
  0%   { transform: rotateX(-10deg) rotateY(0deg); }
  40%  { transform: rotateX(-10deg) rotateY(180deg); }
  50%  { transform: rotateX(-10deg) rotateY(180deg); }
  90%  { transform: rotateX(-10deg) rotateY(360deg); }
  100% { transform: rotateX(-10deg) rotateY(360deg); }
}
@keyframes fzFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}
@keyframes fzShadow {
  0%, 100% { transform: scaleX(1);    opacity: 1; }
  50%      { transform: scaleX(0.78); opacity: 0.6; }
}
@keyframes fzSheen {
  0%, 30% { transform: translateX(70%); }
  100%    { transform: translateX(-70%); }
}
@keyframes fzOrbit {
  to { transform: rotate(360deg); }
}
@keyframes fzTwinkle {
  0%, 100% { opacity: 0.35; transform: rotate(45deg) scale(0.8); }
  50%      { opacity: 1;    transform: rotate(45deg) scale(1.15); }
}
@keyframes fzBar {
  0%   { right: -45%; }
  100% { right: 100%; }
}

@media (max-width: 480px) {
  .fz-loader { gap: 26px; --fz-w: 104px; --fz-h: 130px; --fz-d: 12px; }
  .fz-art { font-size: 58px; }
  .fz-name { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .fz-float, .fz-canvas, .fz-sheen, .fz-shadow, .fz-orbit, .fz-spark, .fz-bar::before {
    animation: none !important;
  }
  .fz-canvas { transform: rotateX(-8deg) rotateY(-22deg); }
  .fz-bar::before { right: 27%; }
}
