/* ============================================================
   Effects: preloader, page curtain, cursor, grain, progress, marquee
   ============================================================ */

/* ---- Intro preloader ---- */
.preloader {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 26px var(--gut) 34px;
  background: var(--bg); color: var(--text);
  transition: transform 1.05s var(--ease-io);
}
.preloader.is-leaving { transform: translateY(-100%); }
.preloader__top { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: 0.22em; color: var(--text-faint); }
.preloader__top span:first-child { color: var(--text); }
.preloader__mid { overflow: hidden; }
.preloader__word {
  display: block; font-size: clamp(48px, 9vw, 150px); font-weight: 300; line-height: 1; letter-spacing: -0.04em;
  animation: preWord 1.1s var(--ease) both;
}
.preloader__word--thin { font-weight: 100; color: var(--accent); animation-delay: 0.12s; }
.preloader.is-leaving .preloader__word { transform: translateY(-30%); opacity: 0; transition: all 0.8s var(--ease-io); }
@keyframes preWord { from { transform: translateY(105%); } to { transform: none; } }
.preloader__bot { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 14px 24px; }
.preloader__label { font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-faint); }
.preloader__num { font-size: clamp(56px, 9vw, 140px); font-weight: 100; line-height: 0.8; letter-spacing: -0.04em; }
.preloader__bar { grid-column: 1 / -1; height: 1px; background: var(--line-strong); overflow: hidden; }
.preloader__bar span { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }
[dir="rtl"] .preloader__bar span { transform-origin: right; }

/* ---- Page-transition curtain ---- */
.curtain {
  position: fixed; inset: 0; z-index: 150; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); transform: scaleY(0); transform-origin: bottom;
}
.curtain::after { content: ""; position: absolute; inset: auto 0 0 0; height: 1px; background: var(--on-accent); opacity: 0.4; }
.curtain--cover { transform: scaleY(1); transform-origin: bottom; transition: transform 0.62s var(--ease-io); pointer-events: auto; }
.curtain--reveal { transform: scaleY(0); transform-origin: top; transition: transform 0.78s var(--ease-io) 0.06s; }
.curtain__label {
  color: var(--on-accent); font-size: clamp(34px, 6vw, 96px); font-weight: 200; padding-inline: var(--gut); text-align: center;
  opacity: 0; transform: translateY(40px); transition: opacity 0.3s, transform 0.3s;
}
.curtain--cover .curtain__label { opacity: 1; transform: none; transition: opacity 0.5s var(--ease) 0.2s, transform 0.7s var(--ease) 0.2s; }
.curtain--reveal .curtain__label { opacity: 0; transform: translateY(-30px); transition: opacity 0.35s, transform 0.5s var(--ease-io); }

/* ---- Film grain ---- */
.grain {
  position: fixed; inset: -50%; width: 200%; height: 200%; z-index: 120; pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1.1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 0.9s steps(5) infinite;
}
.grain { filter: invert(1); opacity: 0.03; }
[data-theme="dark"] .grain { filter: none; opacity: 0.045; }
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -4%); }
  60% { transform: translate(-4%, -2%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}
@media (prefers-reduced-motion: reduce) { .grain { animation: none; } }

/* ---- Reading progress ---- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60; pointer-events: none; }
.progress span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }
[dir="rtl"] .progress span { transform-origin: right; }

/* ---- Custom cursor ---- */
html.has-cursor, html.has-cursor * { cursor: none !important; }
html.has-cursor input, html.has-cursor textarea { cursor: text !important; }
.cursor-dot, .cursor-ring { position: fixed; top: 0; left: 0; pointer-events: none; transition: opacity 0.3s; }
.cursor-dot { z-index: 301; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--accent); }
.cursor-ring { z-index: 300; width: 0; height: 0; }
.cursor-ring__circle {
  position: absolute; left: -18px; top: -18px; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--accent); opacity: 0.55;
  transition: width 0.45s var(--ease), height 0.45s var(--ease), left 0.45s var(--ease), top 0.45s var(--ease), background 0.3s, opacity 0.3s, transform 0.2s;
}
.cursor-ring.is-link .cursor-ring__circle { left: -27px; top: -27px; width: 54px; height: 54px; background: var(--accent-soft); opacity: 1; }
.cursor-ring.is-label .cursor-ring__circle { left: -46px; top: -46px; width: 92px; height: 92px; background: var(--accent); opacity: 0.95; }
.cursor-ring.is-down .cursor-ring__circle { transform: scale(0.82); }
.cursor-ring__label {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%) scale(0.5);
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--on-accent); white-space: nowrap;
  opacity: 0; transition: opacity 0.25s, transform 0.4s var(--ease);
}
[dir="rtl"] .cursor-ring__label { letter-spacing: 0; font-family: var(--arabic); }
.cursor-ring.is-label .cursor-ring__label { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.cursor-out .cursor-dot, .cursor-out .cursor-ring { opacity: 0; }

/* ---- Marquee ---- */
.marquee { position: relative; z-index: 1; overflow: hidden; direction: ltr; border-block: 1px solid var(--line); padding-block: clamp(18px, 2.4vw, 30px); background: var(--bg); }
.marquee__track { display: flex; width: max-content; animation: marquee 46s linear infinite; }
.marquee:hover .marquee__track { animation-play-state: paused; }
.marquee__row { display: flex; flex-shrink: 0; }
.marquee__item {
  display: inline-flex; align-items: center; gap: clamp(22px, 3vw, 44px); padding-inline-end: clamp(22px, 3vw, 44px);
  font-size: clamp(28px, 4.2vw, 64px); font-weight: 200; letter-spacing: -0.03em; white-space: nowrap; line-height: 1.15;
  color: var(--text); transition: color 0.4s var(--ease);
}
.marquee__item:nth-child(even) { color: var(--text-faint); font-weight: 100; }
.marquee__item:hover { color: var(--accent); }
.marquee__sep { font-size: 0.26em; color: var(--accent); -webkit-text-stroke: 0; }
@keyframes marquee { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .marquee__track { animation-duration: 160s; } }

/* ---- Small shared pieces ---- */
.nav__pulse {
  display: inline-block; flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%;
  background: #41c98a; box-shadow: 0 0 0 0 rgba(65,201,138,0.55); animation: pulse 2.2s infinite;
}
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(65,201,138,0.55); } 70% { box-shadow: 0 0 0 9px rgba(65,201,138,0); } 100% { box-shadow: 0 0 0 0 rgba(65,201,138,0); } }
@keyframes spin { to { transform: rotate(360deg); } }
html.menu-open body, html.lb-open body { overflow: hidden; }
