/* ============================================================
   FORGELY — chrome: preloader, nav, cursor, three canvases
   ============================================================ */

/* ---------- preloader ---------- */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--black);
  display: grid;
  place-content: center;
  gap: 30px;
  transition: opacity 0.9s var(--ease), visibility 0.9s var(--ease);
}
#preloader.done { opacity: 0; visibility: hidden; }

.pre-mark {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  text-align: center;
}
.pre-mark span { color: var(--fg-mute); }

.pre-bar {
  width: min(280px, 62vw);
  height: 1px;
  background: rgba(255,255,255,0.12);
  overflow: hidden;
}
.pre-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--fg);
  transition: width 0.28s var(--ease);
}
.pre-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-mute);
}

/* ---------- scroll progress rail ---------- */
#rail {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--fg-mute), var(--fg));
  z-index: 120;
  pointer-events: none;
}

/* ---------- nav ---------- */
#nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 110;
  padding: 20px 0;
  transition: background 0.5s var(--ease), backdrop-filter 0.5s var(--ease),
              border-color 0.5s var(--ease), padding 0.5s var(--ease);
  border-bottom: 1px solid transparent;
}
#nav.stuck {
  padding: 13px 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom-color: var(--line);
}

.nav-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.brand .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fg);
  align-self: center;
  animation: pulse 2.6s var(--ease-io) infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%     { opacity: 0.35; transform: scale(0.8); }
}
.brand em { font-style: normal; color: var(--fg-mute); font-weight: 400; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0; padding: 0;
}
.nav-links a {
  position: relative;
  display: block;
  padding: 8px 15px;
  font-size: 0.85rem;
  color: var(--fg-dim);
  border-radius: 100px;
  transition: color 0.35s var(--ease);
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 15px; right: 15px; bottom: 3px;
  height: 1px;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s var(--ease);
}
.nav-links a:hover { color: var(--fg); }
.nav-links a:hover::after,
.nav-links a[aria-current="true"]::after { transform: scaleX(1); }
.nav-links a[aria-current="true"] { color: var(--fg); }

.nav-cta { display: inline-flex; }
.nav-cta .btn { padding: 11px 22px; font-size: 0.82rem; }

/* burger */
.burger {
  display: none;
  width: 42px; height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  place-content: center;
  gap: 5px;
  z-index: 130;
}
.burger i {
  display: block;
  width: 16px; height: 1.5px;
  background: var(--fg);
  transition: transform 0.45s var(--ease), opacity 0.3s var(--ease);
}
.burger.open i:nth-child(1) { transform: translateY(3.25px) rotate(45deg); }
.burger.open i:nth-child(2) { transform: translateY(-3.25px) rotate(-45deg); }

/* mobile drawer */
#drawer {
  position: fixed;
  inset: 0;
  z-index: 105;
  background: rgba(0,0,0,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 var(--gut);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s var(--ease), visibility 0.5s var(--ease);
}
#drawer.open { opacity: 1; visibility: visible; }
#drawer ul { list-style: none; margin: 0; padding: 0; }
#drawer li { overflow: hidden; }
#drawer a {
  display: block;
  padding: 13px 0;
  font-size: clamp(1.75rem, 8vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  transform: translateY(105%);
  transition: transform 0.7s var(--ease);
}
#drawer.open a { transform: none; }
#drawer.open li:nth-child(1) a { transition-delay: 0.06s; }
#drawer.open li:nth-child(2) a { transition-delay: 0.11s; }
#drawer.open li:nth-child(3) a { transition-delay: 0.16s; }
#drawer.open li:nth-child(4) a { transition-delay: 0.21s; }
#drawer.open li:nth-child(5) a { transition-delay: 0.26s; }
#drawer.open li:nth-child(6) a { transition-delay: 0.31s; }
#drawer .drawer-foot {
  margin-top: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-mute);
}

/* ---------- custom cursor (pointer devices only) ---------- */
#cursor, #cursor-dot {
  position: fixed;
  top: 0; left: 0;
  z-index: 150;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}
#cursor {
  width: 34px; height: 34px;
  border: 1px solid rgba(255,255,255,0.45);
  margin: -17px 0 0 -17px;
  transition: opacity 0.35s var(--ease), width 0.35s var(--ease),
              height 0.35s var(--ease), margin 0.35s var(--ease),
              background 0.35s var(--ease), border-color 0.35s var(--ease);
}
#cursor-dot {
  width: 4px; height: 4px;
  background: var(--fg);
  margin: -2px 0 0 -2px;
}
body.cursor-on #cursor,
body.cursor-on #cursor-dot { opacity: 1; }
body.cursor-on #cursor.hot {
  width: 48px; height: 48px;
  margin: -24px 0 0 -24px;
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.16);
}

@media (hover: none), (pointer: coarse) {
  #cursor, #cursor-dot { display: none; }
}

/* ---------- responsive nav ---------- */
@media (max-width: 900px) {
  .nav-links, .nav-cta { display: none; }
  .burger { display: grid; }
}
