/* ===== Loading screen ===== */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F2F5F7;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease, visibility 0s linear 0s;
}
.loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}
html.loader-seen .loading-screen {
  display: none;
}
.loading-screen__mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.loading-screen__word {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #16283B;
}
.loading-screen__bar {
  width: 84px;
  height: 2px;
  background: #DCE4EA;
  overflow: hidden;
  border-radius: 2px;
}
.loading-screen__bar::after {
  content: '';
  display: block;
  width: 40%;
  height: 100%;
  background: #E8501A;
}
@media (prefers-reduced-motion: no-preference) {
  .loading-screen__bar::after {
    animation: loading-sweep 1.1s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  }
  @keyframes loading-sweep {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(250%); }
  }
}

/* ===== Ambient background ===== */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ===== Background particles ===== */
.bg-particles {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}
.particle {
  position: absolute;
  border-radius: 50%;
  background: #E8501A;
  opacity: 0.18;
}
@media (prefers-reduced-motion: no-preference) {
  .particle {
    will-change: transform;
  }
}

.particle:nth-child(1)  { width: 200px; height: 200px; left: 4%;  top: 8%; }
.particle:nth-child(2)  { width: 60px;  height: 60px;  left: 11%; top: 26%; }
.particle:nth-child(3)  { width: 180px; height: 180px; left: 58%; top: 12%; }
.particle:nth-child(4)  { width: 150px; height: 150px; left: 88%; top: 26%; }
.particle:nth-child(5)  { width: 55px;  height: 55px;  left: 93%; top: 48%; }
.particle:nth-child(6)  { width: 70px;  height: 70px;  left: 38%; top: 58%; }
.particle:nth-child(7)  { width: 90px;  height: 90px;  left: 6%;  top: 70%; }
.particle:nth-child(8)  { width: 110px; height: 110px; left: 80%; top: 75%; }
.particle:nth-child(9)  { width: 40px;  height: 40px;  left: 2%;  top: 45%; }
.particle:nth-child(10) { width: 45px;  height: 45px;  left: 96%; top: 8%; }

/* Same pixel sizes read as oversized on narrow screens (percentage-based
   left/top already scale down fine — only the fixed px diameters don't). */
@media (max-width: 640px) {
  .particle:nth-child(1)  { width: 120px; height: 120px; }
  .particle:nth-child(2)  { width: 36px;  height: 36px; }
  .particle:nth-child(3)  { width: 110px; height: 110px; }
  .particle:nth-child(4)  { width: 90px;  height: 90px; }
  .particle:nth-child(5)  { width: 34px;  height: 34px; }
  .particle:nth-child(6)  { width: 42px;  height: 42px; }
  .particle:nth-child(7)  { width: 54px;  height: 54px; }
  .particle:nth-child(8)  { width: 66px;  height: 66px; }
  .particle:nth-child(9)  { width: 26px;  height: 26px; }
  .particle:nth-child(10) { width: 28px;  height: 28px; }
}

/* ===== Scroll reveal ===== */
.reveal {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1), transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .reveal.is-visible {
    opacity: 1;
    transform: none;
  }
  .reveal-group > *:nth-child(1) { transition-delay: 0s; }
  .reveal-group > *:nth-child(2) { transition-delay: 0.06s; }
  .reveal-group > *:nth-child(3) { transition-delay: 0.12s; }
  .reveal-group > *:nth-child(4) { transition-delay: 0.18s; }
  .reveal-group > *:nth-child(5) { transition-delay: 0.24s; }
  .reveal-group > *:nth-child(n+6) { transition-delay: 0.28s; }
}

/* ===== Logo click feedback ===== */
@media (prefers-reduced-motion: no-preference) {
  .logo-mark.is-clicked {
    animation: logo-pulse 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  }
  @keyframes logo-pulse {
    0% { transform: scale(1); }
    40% { transform: scale(0.88); }
    100% { transform: scale(1); }
  }
}

/* ===== Button press feedback ===== */
.press {
  transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.15s cubic-bezier(0.22, 1, 0.36, 1);
}
.press:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* ===== Mouse-tilt cards ===== */
.tilt-card {
  transform-style: preserve-3d;
  perspective: 800px;
}
@media (prefers-reduced-motion: no-preference) {
  .tilt-card {
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
  }
}

/* ===== Magnetic buttons ===== */
@media (prefers-reduced-motion: no-preference) {
  .magnetic-btn {
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
  }
}

/* ===== Underline-grow links ===== */
.link-underline {
  position: relative;
  text-decoration: none;
}
.link-underline::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.link-underline:hover::after,
.link-underline:focus-visible::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ===== Projects scroll-snap page ===== */
/* Snapping + the per-slide enter animation are desktop-only: on mobile,
   touch-momentum scrolling fighting mandatory snap points (and the
   IntersectionObserver threshold missing fast flicks) made slides feel
   stuck/laggy, so mobile just gets a plain, fully-visible scrolling list. */
@media (min-width: 640px) {
  .projects-scroll-page {
    scroll-snap-type: y mandatory;
  }
}
@media (prefers-reduced-motion: reduce) {
  .projects-scroll-page {
    scroll-snap-type: none;
  }
}
.project-slide .slide-inner {
  opacity: 1;
  transform: none;
}
@media (min-width: 640px) {
  .project-slide .slide-inner {
    opacity: 0.4;
    transform: translateY(18px) scale(0.98);
  }
  @media (prefers-reduced-motion: no-preference) {
    .project-slide .slide-inner {
      transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1), transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    }
  }
  .project-slide.is-active .slide-inner {
    opacity: 1;
    transform: none;
  }
}

.progress-rail {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.progress-rail a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: #5A6E80;
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.progress-rail a:hover,
.progress-rail a:focus-visible {
  color: #E8501A;
}
.progress-rail a.is-current {
  color: #E8501A;
  background: rgba(232, 80, 26, 0.1);
}
