/* Lightweight motion layer shared by the portfolio pages. */
:root {
  --motion-fast: 160ms;
  --motion-standard: 220ms;
  --motion-ease: cubic-bezier(.2, .7, .25, 1);
}

html {
  scroll-behavior: smooth;
}

/* Avoid costly transitions of layout, paint, and filter properties. */
body,
body * {
  transition-duration: var(--motion-standard) !important;
  transition-timing-function: var(--motion-ease) !important;
}

section,
.hero > div,
.hero > aside {
  animation-duration: 420ms !important;
  animation-timing-function: var(--motion-ease) !important;
  will-change: opacity, transform;
}

.mouse-glow-card {
  will-change: transform;
}

/* The mouse-following glow repaints blurred layers for every pointer event. */
.mouse-glow-card::before,
.apple-nav.mouse-glow-card::after,
nav.sticky.mouse-glow-card::after {
  display: none !important;
}

/* Keep the dark theme rich and readable instead of overly transparent. */
body:not(.light) .apple-nav,
html[data-theme="dark"] nav.sticky {
  background: rgba(8, 13, 24, .94) !important;
  backdrop-filter: blur(32px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(32px) saturate(180%) !important;
}

body:not(.light) .profile-card,
body:not(.light) .skill,
body:not(.light) .card,
body:not(.light) .project-card,
html[data-theme="dark"] .project-card,
html[data-theme="dark"] .img-card,
html[data-theme="dark"] .video-wrap {
  background: linear-gradient(145deg, rgba(30, 41, 59, .94), rgba(15, 23, 42, .9)) !important;
  border-color: rgba(148, 163, 184, .18) !important;
}

@media (hover: hover) and (pointer: fine) {
  .project-card:hover,
  .skill:hover,
  .card:hover,
  .img-card:hover {
    transform: translateY(-4px) !important;
  }
}

@media (max-width: 760px), (prefers-reduced-motion: reduce) {
  .mouse-glow-card,
  .profile-card,
  .skill,
  .card,
  .project-card,
  .img-card,
  .video-wrap {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .mouse-glow-card,
  .profile-card,
  .skill,
  .card,
  .project-card,
  .img-card,
  .video-wrap {
    will-change: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Shared primary header: mirrors the homepage navigation on every page. */
.apple-nav {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 1050;
  width: calc(100% - 40px);
  max-width: 1180px;
  padding: 12px 26px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 40px;
  background: rgba(8, 13, 24, .82);
  box-shadow: 0 14px 38px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .16);
  transform: translateX(-50%);
  backdrop-filter: blur(32px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(32px) saturate(180%) !important;
}

nav.sticky {
  backdrop-filter: blur(32px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(32px) saturate(180%) !important;
}

.apple-nav .nav-inner,
.apple-nav .right-side,
.apple-nav .social-icons,
.apple-nav .nav-links {
  display: flex;
  align-items: center;
}

.apple-nav .nav-inner { justify-content: space-between; gap: 20px; }
.apple-nav .logo { display: flex; align-items: center; gap: 10px; color: var(--text-color); font-size: 1.06rem; font-weight: 600; white-space: nowrap; }
.apple-nav .logo i { background: linear-gradient(90deg, var(--accent-color), #6c63ff); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.apple-nav .nav-links { gap: 22px; white-space: nowrap; }
.apple-nav .nav-links a { color: var(--text-color); font-size: .96rem; font-weight: 500; opacity: .75; text-decoration: none; }
.apple-nav .nav-links a:hover { color: var(--accent-color); opacity: 1; }
.apple-nav .right-side { gap: 18px; }
.apple-nav .social-icons { gap: 14px; }
.apple-nav .social-icons a { color: var(--text-color); font-size: 1.15rem; opacity: .75; }
.apple-nav .social-icons a:hover { color: var(--accent-color); opacity: 1; }
.apple-nav .theme-toggle { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; padding: 8px; color: var(--text-color); border: 1px solid rgba(255, 255, 255, .35); border-radius: 50%; background: rgba(255, 255, 255, .15); cursor: pointer; }
.apple-nav .project-title { min-width: 0; overflow: hidden; color: var(--text-color); font-size: .96rem; font-weight: 600; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
body:has(.apple-nav) { padding-top: 92px; }
html[data-theme="light"] .apple-nav { background: rgba(255, 255, 255, .88); border-color: rgba(0, 0, 0, .08); box-shadow: 0 12px 30px rgba(15, 23, 42, .12); }
html[data-theme="light"] .apple-nav .theme-toggle { background: rgba(0, 0, 0, .08); border-color: rgba(0, 0, 0, .15); }

@media (max-width: 980px) {
  body:has(.apple-nav) { padding-top: 80px; }
  .apple-nav { top: 8px; width: calc(100% - 20px); }
  .apple-nav .nav-inner { flex-wrap: wrap; gap: 10px 14px; }
  .apple-nav .logo { flex: 1 1 auto; min-width: 0; }
  .apple-nav .logo span { overflow: hidden; text-overflow: ellipsis; }
  .apple-nav .right-side { flex: 0 0 auto; }
  .apple-nav .social-icons { display: none; }
  .apple-nav .nav-links { flex: 1 0 100%; order: 3; gap: 8px; overflow-x: auto; padding: 6px 2px 2px; scrollbar-width: none; }
  .apple-nav .nav-links::-webkit-scrollbar { display: none; }
  .apple-nav .nav-links a { flex: 0 0 auto; padding: 6px 10px; border: 1px solid var(--glass-border); border-radius: 999px; background: rgba(255, 255, 255, .08); opacity: .95; }
}

@media (max-width: 560px) {
  body:has(.apple-nav) { padding-top: 76px; }
  .apple-nav { top: 6px; width: calc(100% - 12px); padding: 10px 12px; border-radius: 18px; }
  .apple-nav .logo { font-size: .92rem; }
  .apple-nav .project-title { font-size: .82rem; }
  .apple-nav .nav-links { gap: 6px; }
  .apple-nav .nav-links a { padding: 6px 9px; font-size: .84rem; }
}

/* Project pages use a compact, single-row version of the primary header. */
.apple-nav:has(.project-title) .nav-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  flex-wrap: nowrap;
  gap: 14px;
}

.apple-nav:has(.project-title) .logo,
.apple-nav:has(.project-title) .right-side {
  flex: 0 0 auto;
}

/* Reserve clear space below the floating project header. */
body:has(.apple-nav) main.container {
  padding-top: 3rem !important;
}

/* Explicit project-page spacing also covers browsers without :has() support. */
body.project-page {
  padding-top: 112px;
}

body.project-page main.container {
  padding-top: 4rem !important;
}

@media (max-width: 560px) {
  body.project-page { padding-top: 76px; }
  body.project-page main.container { padding-top: 3rem !important; }
  .apple-nav:has(.project-title) .nav-inner { gap: 10px; }
  .apple-nav:has(.project-title) .logo { font-size: .9rem; }
}

/* Project headers float with their page instead of staying pinned to the viewport. */
body.project-page {
  padding-top: 0;
}

body.project-page .apple-nav {
  position: relative;
  top: auto;
  left: auto;
  margin: 12px auto 0;
  transform: none;
}

body.project-page main.container {
  padding-top: 2rem !important;
}
