:root {
  --bg: #f4f8ff;
  --bg-soft: #eaf2ff;
  --text: #122136;
  --muted: #354a63;
  --card: rgba(255, 255, 255, 0.85);
  --line: rgba(17, 62, 114, 0.14);
  --accent: #0f71e7;
  --accent-dark: #0a5dbf;
  --ease-cinematic: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-drift: cubic-bezier(0.3, 0.12, 0.2, 1);
  --mx: 0;
  --my: 0;
  --scroll-progress: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, #edf4ff 60%, #f6f9ff 100%);
  scroll-behavior: smooth;
}

body {
  position: relative;
  overflow-x: hidden;
}

.preloader {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 20%, #e4efff 0%, #c9ddff 55%, #bed6ff 100%);
  transition: opacity 600ms var(--ease-cinematic), visibility 600ms var(--ease-cinematic);
}

.preloader.hide {
  opacity: 0;
  visibility: hidden;
}

.preloader-inner {
  text-align: center;
  width: min(420px, 86vw);
  animation: preloaderEnter 900ms var(--ease-cinematic) both;
}

.preloader-brand {
  font-weight: 800;
  letter-spacing: 0.18em;
  font-size: 13px;
  color: #0f2f52;
  text-transform: uppercase;
  text-shadow: 0 10px 30px rgba(15, 113, 231, 0.3);
}

.preloader-brand,
.preloader-text {
  display: inline-flex;
  gap: 0.01em;
}

.preloader-letter {
  display: inline-block;
  opacity: 0;
  transform: translateY(24px);
  will-change: transform, opacity;
}

.preloader-brand .preloader-letter {
  animation: letterRise 760ms var(--ease-cinematic) forwards;
  animation-delay: calc(var(--i) * 55ms);
}

.preloader-bar {
  margin-top: 16px;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(15, 58, 103, 0.24);
  background: rgba(255, 255, 255, 0.8);
}

.preloader-bar span {
  display: block;
  position: relative;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f71e7, #31d5ff);
  transition: width 520ms var(--ease-cinematic);
}

.preloader-bar span::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 140px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  animation: barSweep 1.4s linear infinite;
}

.preloader-text {
  margin-top: 10px;
  color: #24425f;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.82;
}

.preloader-text .preloader-letter {
  animation: letterPulse 1.25s var(--ease-cinematic) infinite;
  animation-delay: calc(var(--i) * 60ms);
}

@keyframes preloaderEnter {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0px) scale(1);
    filter: blur(0);
  }
}

@keyframes barSweep {
  from {
    transform: translateX(-150px);
  }
  to {
    transform: translateX(420px);
  }
}

@keyframes letterRise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes letterPulse {
  0%,
  100% {
    opacity: 0.5;
    transform: translateY(16px);
  }
  30%,
  55% {
    opacity: 1;
    transform: translateY(0);
  }
}

.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  border-radius: 999px;
  pointer-events: none;
  z-index: 75;
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity 200ms ease;
}

.cursor-dot {
  width: 8px;
  height: 8px;
  background: rgba(15, 113, 231, 0.9);
}

.cursor-ring {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(15, 113, 231, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55) inset;
  transition: width 220ms var(--ease-cinematic), height 220ms var(--ease-cinematic),
    border-color 220ms var(--ease-cinematic), opacity 200ms ease;
}

.cursor-dot.show,
.cursor-ring.show {
  opacity: 1;
}

.cursor-ring.active {
  width: 56px;
  height: 56px;
  border-color: rgba(10, 93, 191, 0.55);
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -3;
  pointer-events: none;
}

.bg-glow {
  position: fixed;
  border-radius: 999px;
  filter: blur(70px);
  z-index: -2;
  pointer-events: none;
  opacity: 0.56;
}

.glow-1 {
  width: 420px;
  height: 420px;
  left: -140px;
  top: 16%;
  background: #8ac8ff;
  animation: floatA 15s var(--ease-drift) infinite;
}

.glow-2 {
  width: 360px;
  height: 360px;
  right: -120px;
  top: 52%;
  background: #95ffe1;
  animation: floatB 18s var(--ease-drift) infinite;
}

@keyframes floatA {
  0%,
  100% {
    transform: translate3d(
      calc(var(--mx) * 26px),
      calc(var(--my) * 22px + var(--scroll-progress) * -50px + 0px),
      0
    );
  }
  50% {
    transform: translate3d(
      calc(var(--mx) * 26px),
      calc(var(--my) * 22px + var(--scroll-progress) * -50px - 24px),
      0
    );
  }
}

@keyframes floatB {
  0%,
  100% {
    transform: translate3d(
      calc(var(--mx) * -30px),
      calc(var(--my) * -24px + var(--scroll-progress) * 42px + 0px),
      0
    );
  }
  50% {
    transform: translate3d(
      calc(var(--mx) * -30px),
      calc(var(--my) * -24px + var(--scroll-progress) * 42px + 26px),
      0
    );
  }
}

a {
  color: var(--accent);
}

.container {
  width: min(1120px, 92vw);
  margin: 0 auto;
}

.narrow {
  width: min(760px, 92vw);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 248, 255, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}

.logo {
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 13px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
  position: relative;
  padding-bottom: 2px;
  transition: color 260ms var(--ease-cinematic);
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  border-radius: 99px;
  transform: scaleX(0);
  transform-origin: left;
  background: linear-gradient(90deg, var(--accent), #31d5ff);
  transition: transform 340ms var(--ease-cinematic);
}

.nav a:hover {
  color: var(--accent);
}

.nav a:hover::after {
  transform: scaleX(1);
}

.menu-btn {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 700;
}

.hero {
  padding: 92px 0 72px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr;
  gap: 24px;
  align-items: center;
  perspective: 1200px;
}

.hero-photo,
.about-photo {
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 18px 42px rgba(14, 43, 75, 0.12);
  transform-style: preserve-3d;
  will-change: transform;
}

.hero-photo img,
.about-photo img,
.card-image {
  width: 100%;
  display: block;
  object-fit: cover;
  will-change: transform;
  transform-origin: center;
  transition: transform 500ms var(--ease-cinematic);
}

.hero-photo img {
  height: 340px;
  transform: scale(1.08)
    translate3d(calc(var(--mx) * -14px), calc(var(--my) * -8px + var(--scroll-progress) * -18px), 0);
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  align-items: center;
  max-width: 920px;
}

.about-photo img {
  height: 260px;
  transform: scale(1.06)
    translate3d(calc(var(--mx) * -10px), calc(var(--my) * -6px + var(--scroll-progress) * -10px), 0);
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

h1,
h2,
h3,
p,
ul,
figure {
  margin: 0;
}

h1 {
  margin-top: 10px;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.08;
}

.lead {
  margin-top: 16px;
  max-width: 720px;
  color: var(--muted);
  font-size: clamp(17px, 2.2vw, 21px);
  line-height: 1.5;
}

.hero h1.hero-text-rise {
  --rise-stagger: 22ms;
  --rise-delay: 120ms;
}

.hero .lead.hero-text-rise {
  --rise-stagger: 52ms;
  --rise-delay: 720ms;
}

.hero-text-rise {
  display: block;
}

.hero-text-rise .rise-unit {
  display: inline-block;
  opacity: 0;
  transform: translateY(1.1em);
  filter: blur(4px);
  will-change: transform, opacity, filter;
}

.hero-text-rise.play .rise-unit {
  animation: heroTextRise 820ms var(--ease-cinematic) forwards;
  animation-delay: calc(var(--rise-delay, 0ms) + var(--i) * var(--rise-stagger, 26ms));
  animation-play-state: paused;
}

body.app-ready .hero-text-rise.play .rise-unit {
  animation-play-state: running;
}

@keyframes heroTextRise {
  0% {
    opacity: 0;
    transform: translateY(1.1em);
    filter: blur(4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

.hero-actions {
  margin-top: 26px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.social-links {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  transition: transform 220ms var(--ease-cinematic), box-shadow 220ms var(--ease-cinematic),
    border-color 220ms var(--ease-cinematic);
}

.social-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.social-link:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 113, 231, 0.36);
  box-shadow: 0 10px 22px rgba(15, 59, 112, 0.15);
}

.social-note {
  margin-top: 10px;
  max-width: 720px;
  color: var(--muted);
  font-size: 15px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 700;
  transition: transform 260ms var(--ease-cinematic), border-color 260ms var(--ease-cinematic),
    box-shadow 260ms var(--ease-cinematic), background-color 260ms var(--ease-cinematic);
}

.btn:hover {
  transform: translateY(-2px) scale(1.01);
  border-color: rgba(17, 62, 114, 0.3);
  box-shadow: 0 10px 20px rgba(15, 59, 112, 0.16);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-dark);
}

.section {
  padding: 66px 0;
  position: relative;
}

.section.alt {
  background: rgba(220, 233, 252, 0.45);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.section h2 {
  font-size: clamp(30px, 4vw, 44px);
  margin-bottom: 22px;
}

.section p {
  color: var(--muted);
  font-size: clamp(18px, 2.1vw, 24px);
  line-height: 1.75;
}

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.cards.three {
  grid-template-columns: 1fr;
}

.card {
  display: block;
  color: var(--text);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 28px rgba(14, 43, 75, 0.07);
  transition: transform 360ms var(--ease-cinematic), box-shadow 360ms var(--ease-cinematic),
    border-color 360ms var(--ease-cinematic);
  transform-style: preserve-3d;
  will-change: transform;
}

.project-card-link {
  cursor: pointer;
}

.card:hover {
  box-shadow: 0 22px 44px rgba(14, 43, 75, 0.16);
  border-color: rgba(15, 113, 231, 0.26);
}

.tilt {
  transform-style: preserve-3d;
  transition: transform 260ms var(--ease-cinematic);
  will-change: transform;
}

.tilt.tilting {
  transition: none !important;
}

.card:not(.tilt):hover {
  transform: translateY(-3px) scale(1.01);
}

.project-card {
  overflow: hidden;
  padding: 0;
}

.project-card h3,
.project-card p,
.project-card .meta {
  padding-left: 16px;
  padding-right: 16px;
}

.project-card h3 {
  margin-top: 16px;
}

.project-card .meta {
  margin-top: 8px;
}

.project-card p:last-child {
  margin-top: 12px;
  padding-bottom: 18px;
}

.card-image {
  height: 190px;
  transform: scale(1.06)
    translate3d(calc(var(--mx) * -6px), calc(var(--my) * -4px + var(--scroll-progress) * -8px), 0);
}

.card-logo {
  object-fit: contain;
  background: #ffffff;
  padding: 26px;
  transform: none;
}

.card h3 {
  font-size: clamp(18px, 2.2vw, 24px);
  line-height: 1.25;
}

.meta {
  margin-top: 8px;
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
}

.card p {
  margin-top: 12px;
  font-size: clamp(16px, 1.4vw, 18px);
  line-height: 1.7;
}

.card ul {
  margin-top: 12px;
  padding-left: 20px;
  color: var(--muted);
  display: grid;
  gap: 8px;
  font-size: clamp(16px, 1.25vw, 18px);
  line-height: 1.65;
}

.skills-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.skills-grid > div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 28px rgba(14, 43, 75, 0.06);
  transition: border-color 220ms ease, box-shadow 220ms ease;
}

.skills-grid > div:hover {
  border-color: rgba(15, 113, 231, 0.25);
  box-shadow: 0 16px 30px rgba(14, 43, 75, 0.11);
}

.skills-grid h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.skills-grid ul {
  padding-left: 20px;
  color: var(--muted);
  display: grid;
  gap: 7px;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(5px);
}

.footer-wrap {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer-wrap p {
  color: var(--muted);
}

.reveal {
  opacity: 0;
  transform: translateY(32px) scale(0.97) rotateX(6deg);
  filter: blur(6px);
  transform-origin: 50% 100%;
  transition: opacity 900ms var(--ease-cinematic), transform 900ms var(--ease-cinematic),
    filter 860ms var(--ease-cinematic);
}

.reveal.in-view {
  opacity: 1;
  transform: translateY(0) scale(1) rotateX(0deg);
  filter: blur(0);
}

.reveal.delay-1:not(.in-view) {
  transition-delay: 150ms;
}

.reveal.delay-2:not(.in-view) {
  transition-delay: 280ms;
}

.tilt.reveal.in-view {
  transition: transform 260ms var(--ease-cinematic), box-shadow 360ms var(--ease-cinematic),
    border-color 360ms var(--ease-cinematic);
}

@media (min-width: 860px) {
  .hero-grid {
    grid-template-columns: 1.08fr 0.92fr;
  }

  .hero-photo img {
    height: 100%;
    min-height: 400px;
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cards.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .skills-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .cursor-dot,
  .cursor-ring {
    display: none;
  }

  .menu-btn {
    display: inline-flex;
  }

  .nav {
    display: none;
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 12px 4vw;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .nav.open {
    display: flex;
  }
}

@media (prefers-reduced-motion: reduce) {
  .preloader {
    display: none;
  }

  .cursor-dot,
  .cursor-ring {
    display: none;
  }

  .bg-glow,
  .reveal,
  .card,
  .btn,
  .tilt {
    animation: none;
    transition: none;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  .hero-text-rise .rise-unit {
    opacity: 1;
    transform: none;
    filter: none;
    animation: none;
  }
}
