/* SOPDEV motion layer — load AFTER global.css. Opacity/transform only, no layout shifts. */
:root {
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 0.2s;
  --t-med: 0.45s;
}

/* Page enter / leave (opacity only so the fixed header is never affected) */
body {
  animation: pageIn 0.45s var(--ease) both;
}
body.page-leaving {
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
@keyframes pageIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Global API activity bar (sits under the scroll-progress bar) */
#apiLoader {
  position: fixed;
  top: 2px;
  left: 0;
  width: 100%;
  height: 2px;
  overflow: hidden;
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#apiLoader.on {
  opacity: 1;
}
#apiLoader::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--cy), transparent);
  animation: apiSlide 1.1s var(--ease) infinite;
}
@keyframes apiSlide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}

/* Smoother reveal (stagger delay is set from JS via --i, then cleared) */
.reveal {
  transition:
    opacity 0.6s var(--ease),
    transform 0.6s var(--ease),
    border-color 0.3s;
}

/* States fade/slide in */
.state-msg,
.contact-status.is-ok,
.contact-status.is-error,
.contact-status.is-loading {
  animation: fadeUp 0.35s var(--ease) both;
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Skeleton loaders (same footprint as .featured-project, so no jump) */
.featured-projects.is-leaving {
  opacity: 0;
  transition: opacity 0.15s ease;
}
.skeleton-card {
  overflow: hidden;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 6px;
  animation: fadeUp 0.35s var(--ease) both;
}
.skeleton-card:nth-child(2) {
  animation-delay: 0.08s;
}
.skeleton-card:nth-child(3) {
  animation-delay: 0.16s;
}
.skeleton-card:nth-child(4) {
  animation-delay: 0.24s;
}
.skeleton-body {
  padding: 26px;
  display: grid;
  gap: 12px;
}
.skeleton {
  position: relative;
  overflow: hidden;
  background: #121b2b;
  border-radius: 4px;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent,
    rgba(56, 208, 255, 0.07),
    transparent
  );
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}
.sk-img {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 0;
}
.sk-tag {
  height: 12px;
  width: 80px;
}
.sk-title {
  height: 26px;
  width: 65%;
}
.sk-line {
  height: 14px;
  width: 100%;
}
.sk-line.short {
  width: 70%;
}

/* Images fade in once loaded instead of popping */
.img-fade {
  opacity: 0;
  transition:
    opacity 0.5s var(--ease),
    transform 0.5s;
}
.img-fade.is-loaded {
  opacity: 1;
}

/* Buttons: hover / active / loading */
.hero-primary,
.hero-secondary,
.nav-cta,
.contact-submit,
.view-all-projects {
  transition:
    background 0.25s,
    color 0.25s,
    border-color 0.25s,
    transform var(--t-fast) var(--ease),
    opacity var(--t-fast);
}
.hero-primary:hover,
.hero-secondary:hover,
.nav-cta:hover {
  transform: translateY(-1px);
}
.hero-primary:active,
.hero-secondary:active,
.nav-cta:active,
.contact-submit:active {
  transform: translateY(0) scale(0.97);
}
.contact-submit:disabled {
  transform: none;
}
.contact-submit.is-loading svg,
.contact-submit.is-loading i {
  display: none;
}
.contact-submit.is-loading::before {
  content: "";
  width: 1.1em;
  height: 1.1em;
  border: 2px solid rgba(4, 16, 26, 0.3);
  border-top-color: #04101a;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Form field focus feedback */
.contact-form input,
.contact-form textarea {
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.contact-form input:focus,
.contact-form textarea:focus {
  box-shadow: 0 0 0 3px rgba(56, 208, 255, 0.12);
}

@media (prefers-reduced-motion: reduce) {
  body,
  .skeleton-card,
  .state-msg {
    animation: none !important;
  }
  .img-fade {
    opacity: 1;
  }
  #apiLoader::before {
    animation: none;
    width: 100%;
  }
}

/* ---- Projects list + detail page loading states ---- */
.is-leaving {
  opacity: 0;
  transition: opacity 0.15s ease;
}
/* Skeleton project card reuses the real .project-card layout */
.project-card.is-skeleton {
  pointer-events: none;
  animation: fadeUp 0.35s var(--ease) both;
}
.project-card.is-skeleton:hover {
  transform: none;
  border-color: var(--line);
}
.is-skeleton .project-thumbnail {
  position: relative;
  min-height: 180px;
}
.is-skeleton .project-thumbnail > .skeleton {
  position: absolute;
  inset: 0;
  border-radius: 0;
}
.is-skeleton .project-content {
  display: grid;
  gap: 12px;
  align-content: start;
}
.project-card.is-skeleton:nth-child(2) {
  animation-delay: 0.08s;
}
.project-card.is-skeleton:nth-child(3) {
  animation-delay: 0.16s;
}
.project-card.is-skeleton:nth-child(4) {
  animation-delay: 0.24s;
}

/* Detail page skeleton */
.detail-skeleton {
  display: grid;
  gap: 16px;
  animation: fadeUp 0.35s var(--ease) both;
}
.detail-skeleton .sk-title {
  height: 44px;
  width: 70%;
}
.detail-skeleton .sk-hero {
  width: 100%;
  aspect-ratio: 16/9;
  max-height: 560px;
  margin-top: 8px;
}
.detail-skeleton .sk-h2 {
  height: 28px;
  width: 180px;
  margin-top: 20px;
}

/* Header pieces of the detail page ease in */
.project-detail-links a {
  transition:
    transform var(--t-fast) var(--ease),
    background 0.25s,
    color 0.25s;
}
.project-detail-links a:hover {
  transform: translateY(-1px);
}
.project-detail-links a:active {
  transform: scale(0.97);
}
.gallery-image {
  transition: opacity 0.5s var(--ease);
}
