/* ---------------------------------------------------------------------
   Base ground & selection
--------------------------------------------------------------------- */
html {
  background: #0a0a0f;
}
body {
  background: #0a0a0f;
  color: #e9e9f1;
  overflow-x: hidden;
}
::selection {
  background: rgba(99, 102, 241, 0.45);
  color: #fff;
}

/* Thin, subject-appropriate scrollbar */
::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: #0a0a0f;
}
::-webkit-scrollbar-thumb {
  background: #26263a;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: #343450;
}

/* ---------------------------------------------------------------------
   Loader
--------------------------------------------------------------------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0f;
  transition:
    opacity 0.6s ease,
    visibility 0.6s ease;
}
#loader.done {
  opacity: 0;
  visibility: hidden;
}
.loader-mark {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  color: #9b9bad;
  display: flex;
  align-items: center;
  gap: 12px;
}
.loader-bar {
  width: 160px;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  position: relative;
}
.loader-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, #6366f1, #22d3ee);
  animation: loadSweep 1.1s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
@keyframes loadSweep {
  to {
    transform: translateX(100%);
  }
}

/* ---------------------------------------------------------------------
   Custom cursor (pointer:fine only; hidden if reduced motion)
--------------------------------------------------------------------- */
@media (pointer: fine) {
  .cursor-dot,
  .cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 90;
    border-radius: 50%;
  }
  .cursor-dot {
    width: 6px;
    height: 6px;
    background: #22d3ee;
    transform: translate(-50%, -50%);
  }
  .cursor-ring {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(139, 148, 255, 0.5);
    transform: translate(-50%, -50%);
    transition:
      width 0.25s ease,
      height 0.25s ease,
      border-color 0.25s ease,
      background 0.25s ease;
  }
  .cursor-ring.is-hover {
    width: 56px;
    height: 56px;
    border-color: rgba(34, 211, 238, 0.8);
    background: rgba(34, 211, 238, 0.06);
  }
}
@media (pointer: coarse), (prefers-reduced-motion: reduce) {
  .cursor-dot,
  .cursor-ring {
    display: none !important;
  }
}

/* ---------------------------------------------------------------------
   Glass & gradient utilities
--------------------------------------------------------------------- */
.glass {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.glass-strong {
  background: rgba(18, 18, 26, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.grad-text {
  background: linear-gradient(92deg, #818cf8 0%, #22d3ee 55%, #67e8f9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #8b94ff;
}

/* Animated gradient border for the featured project card */
.grad-border {
  position: relative;
  border-radius: 24px;
  padding: 1px;
  overflow: hidden;
}
.grad-border::before {
  content: "";
  position: absolute;
  inset: -150%;
  background: conic-gradient(
    from 0deg,
    transparent 0 30%,
    #6366f1 42%,
    #22d3ee 50%,
    #f472b6 58%,
    transparent 70% 100%
  );
  animation: spinBorder 7s linear infinite;
}
.grad-border > * {
  position: relative;
  border-radius: 23px;
}
@keyframes spinBorder {
  to {
    transform: rotate(1turn);
  }
}

/* ---------------------------------------------------------------------
   Scroll-reveal system (JS adds .revealed)
--------------------------------------------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.revealed {
  opacity: 1;
  transform: none;
}
.reveal-left {
  opacity: 0;
  transform: translateX(-32px);
  transition:
    opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal-left.revealed {
  opacity: 1;
  transform: none;
}

/* ---------------------------------------------------------------------
   Hero entrance (staggered on load)
--------------------------------------------------------------------- */
.hero-in {
  opacity: 0;
  transform: translateY(24px);
}
body.loaded .hero-in {
  animation: heroUp 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
body.loaded .hero-in:nth-child(1) {
  animation-delay: 0.05s;
}
body.loaded .hero-in:nth-child(2) {
  animation-delay: 0.15s;
}
body.loaded .hero-in:nth-child(3) {
  animation-delay: 0.25s;
}
body.loaded .hero-in:nth-child(4) {
  animation-delay: 0.35s;
}
body.loaded .hero-in:nth-child(5) {
  animation-delay: 0.45s;
}
@keyframes heroUp {
  to {
    opacity: 1;
    transform: none;
  }
}

/* Rotating role word in the hero */
#role-swap {
  display: inline-block;
  min-width: 1ch;
}
.role-out {
  animation: roleOut 0.35s ease forwards;
}
.role-in {
  animation: roleIn 0.35s ease forwards;
}
@keyframes roleOut {
  to {
    opacity: 0;
    transform: translateY(-14px);
    filter: blur(4px);
  }
}
@keyframes roleIn {
  from {
    opacity: 0;
    transform: translateY(14px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

/* Terminal caret in the Aster demo card */
.caret::after {
  content: "▍";
  color: #22d3ee;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ---------------------------------------------------------------------
   Nav
--------------------------------------------------------------------- */
#nav {
  transition:
    background 0.4s ease,
    border-color 0.4s ease,
    backdrop-filter 0.4s ease;
  border-bottom: 1px solid transparent;
}
#nav.scrolled {
  background: rgba(10, 10, 15, 0.75);
  border-bottom-color: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.nav-link {
  position: relative;
  color: #9b9bad;
  transition: color 0.25s ease;
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  height: 1px;
  width: 100%;
  background: linear-gradient(90deg, #6366f1, #22d3ee);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.nav-link:hover,
.nav-link.active {
  color: #e9e9f1;
}
.nav-link:hover::after,
.nav-link.active::after {
  transform: scaleX(1);
}

/* ---------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------- */
.btn-primary {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(92deg, #6366f1, #4f46e5);
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.25s ease;
}
.btn-primary::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(92deg, #22d3ee, #6366f1);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px -12px rgba(99, 102, 241, 0.55);
}
.btn-primary:hover::before {
  opacity: 1;
}
.btn-ghost {
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.25s ease,
    background 0.25s ease;
}
.btn-ghost:hover {
  transform: translateY(-2px);
  border-color: rgba(34, 211, 238, 0.5);
  background: rgba(34, 211, 238, 0.06);
}

/* Focus visibility for keyboard users */
a:focus-visible,
button:focus-visible {
  outline: 2px solid #22d3ee;
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------------
   Skills
--------------------------------------------------------------------- */
.skill-tab {
  transition:
    color 0.25s ease,
    background 0.25s ease,
    border-color 0.25s ease;
}
.skill-tab.active {
  color: #e9e9f1;
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(129, 140, 248, 0.45);
}
.skill-chip {
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.25s ease,
    background 0.25s ease;
}
.skill-chip:hover {
  transform: translateY(-3px);
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.07);
}

/* ---------------------------------------------------------------------
   Experience timeline
--------------------------------------------------------------------- */
.timeline {
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: linear-gradient(
    180deg,
    rgba(99, 102, 241, 0.6),
    rgba(34, 211, 238, 0.25),
    rgba(255, 255, 255, 0.06)
  );
}
.timeline-dot {
  position: absolute;
  left: 0;
  top: 6px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #0a0a0f;
  border: 2px solid #6366f1;
  box-shadow:
    0 0 0 4px rgba(99, 102, 241, 0.15),
    0 0 18px rgba(99, 102, 241, 0.5);
}

/* ---------------------------------------------------------------------
   Project cards (tilt handled in JS via --rx/--ry)
--------------------------------------------------------------------- */
.tilt-card {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg))
    translateY(var(--lift, 0px));
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.3s ease,
    box-shadow 0.3s ease;
  will-change: transform;
}
.tilt-card:hover {
  border-color: rgba(129, 140, 248, 0.4);
  box-shadow:
    0 24px 60px -24px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(99, 102, 241, 0.12);
}
.proj-arrow {
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.tilt-card:hover .proj-arrow {
  transform: translate(4px, -4px);
}

/* ---------------------------------------------------------------------
   Misc
--------------------------------------------------------------------- */
.tabular {
  font-variant-numeric: tabular-nums;
}
h1,
h2,
h3 {
  text-wrap: balance;
}
.divider {
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.09),
    transparent
  );
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal,
  .reveal-left,
  .hero-in {
    opacity: 1 !important;
    transform: none !important;
  }
  html {
    scroll-behavior: auto;
  }
}
