/* ---------- Design tokens ---------- */
:root {
  --bg: #FFFFFF;
  --text: #111111;
  --secondary: #6E6E73;
  --accent: #0071E3;
  --card: #F5F5F7;
  --border: #E5E5E5;
  --card-chip: #FFFFFF;
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .05), 0 16px 48px rgba(0, 0, 0, .12);
  --glass: rgba(255, 255, 255, .72);
  --ease: cubic-bezier(.21, .47, .32, .98);
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: var(--dark);
}

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 2px;
}

html.dark {
  --bg: #0A0A0C;
  --text: #F5F5F7;
  --secondary: #98989E;
  --card: #151518;
  --border: #26262B;
  --card-chip: #202024;
  --glass: rgba(10, 10, 12, .72);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .4);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .4), 0 16px 48px rgba(0, 0, 0, .55);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", Inter, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}

::selection {
  background: rgba(0, 113, 227, .2);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

section {
  padding: 110px 0;
}

.kicker {
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
}

.section-title {
  margin-top: 16px;
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.12;
}

.section-sub {
  margin-top: 18px;
  max-width: 560px;
  font-size: 1.1rem;
  color: var(--secondary);
}

/* ---------- Reveal animations ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  filter: blur(6px);
  transition: opacity .8s var(--ease), transform .8s var(--ease), filter .8s var(--ease);
}

.reveal.visible {
  opacity: 1;
  transform: none;
  filter: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

/* ---------- Progress bar / cursor ---------- */
#progress {
  position: fixed;
  inset: 0 auto auto 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 90;
}

#cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 113, 227, .55);
  pointer-events: none;
  z-index: 95;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: width .2s, height .2s, opacity .3s;
}

#cursor.hover {
  width: 38px;
  height: 38px;
}

@media (hover: none),
(pointer: coarse) {
  #cursor {
    display: none;
  }
}

/* ---------- Nav ---------- */
header.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 80;
  backdrop-filter: saturate(180%) blur(20px);
  background: var(--glass);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  max-width: 1120px;
  margin: 0 auto;
}

.brand {
  font-weight: 650;
  font-size: .95rem;
  letter-spacing: -.01em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.brand img {
  display: block;
  height: auto;
}

.nav-links {
  display: flex;
  gap: 28px;
  list-style: none;
}

.nav-links a {
  font-size: .88rem;
  color: var(--secondary);
  text-decoration: none;
  transition: color .2s;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  padding: 8px;
  border-radius: 10px;
  color: var(--secondary);
  display: inline-flex;
  transition: color .2s, background .2s;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--card);
}

.kbd-btn {
  display: none;
  align-items: center;
  gap: 5px;
  font-size: .75rem;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--secondary);
}

#menuBtn {
  display: none;
}

#mobileMenu {
  display: none;
  border-top: 1px solid var(--border);
  padding: 16px 24px;
}

#mobileMenu ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#mobileMenu a {
  color: var(--secondary);
  text-decoration: none;
  font-size: .95rem;
}

@media (min-width: 768px) {
  .kbd-btn {
    display: inline-flex;
  }
}

@media (max-width: 767px) {
  .nav-links {
    display: none;
  }

  #menuBtn {
    display: inline-flex;
  }
}

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 160px 0 100px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(60% 80% at 72% 18%, rgba(0, 113, 227, .09), transparent 60%),
    radial-gradient(50% 70% at 18% 82%, rgba(110, 110, 115, .08), transparent 60%);
  background-size: 180% 180%;
  animation: drift 16s ease infinite;
}

html.dark .hero::before {
  background: radial-gradient(60% 80% at 72% 18%, rgba(0, 113, 227, .16), transparent 60%),
    radial-gradient(50% 70% at 18% 82%, rgba(120, 120, 128, .1), transparent 60%);
  background-size: 180% 180%;
}

@keyframes drift {

  0%,
  100% {
    background-position: 0% 40%;
  }

  50% {
    background-position: 100% 60%;
  }
}

.hero-video {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-veil {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom,
      rgba(255, 255, 255, .82), rgba(255, 255, 255, .65) 60%, var(--bg));
}

html.dark .hero-veil {
  background: linear-gradient(to bottom,
      rgba(10, 10, 12, .78), rgba(10, 10, 12, .6) 60%, var(--bg));
}

.hero h1 {
  max-width: 15ch;
  font-size: clamp(2.8rem, 7vw, 5.2rem);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.05;
}

.hero .subtitle {
  margin-top: 30px;
  max-width: 620px;
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
  font-weight: 500;
  line-height: 1.45;
}

.hero .desc {
  margin-top: 18px;
  max-width: 540px;
  font-size: 1.08rem;
  color: var(--secondary);
}

.cta-row {
  margin-top: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  padding: 13px 28px;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 550;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .2s;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.btn-primary:hover {
  box-shadow: var(--shadow-lift);
}

.btn-secondary {
  border: 1px solid var(--border);
  background: var(--card);
}

.btn-secondary:hover {
  box-shadow: var(--shadow-soft);
}

.btn-ghost {
  color: var(--accent);
  padding: 13px 18px;
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  gap: 56px;
  align-items: center;
}

@media (min-width: 880px) {
  .about-grid {
    grid-template-columns: 1fr 1.1fr;
  }
}

.portrait {
  aspect-ratio: 4/5;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
  border-radius: 32px;
  background: var(--card);
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.portrait::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 113, 227, .1), transparent 55%, rgba(110, 110, 115, .1));
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.about-copy p {
  margin-top: 22px;
  font-size: 1.1rem;
  color: var(--secondary);
}

/* ---------- Skills ---------- */
.cards-grid {
  margin-top: 56px;
  display: grid;
  gap: 22px;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 30px;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lift);
}

.card h3 {
  font-size: 1.1rem;
  font-weight: 620;
  letter-spacing: -.01em;
}

.card .emoji {
  font-size: 1.5rem;
  display: inline-flex;
  width: 46px;
  height: 46px;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--card-chip);
  box-shadow: var(--shadow-soft);
  margin-bottom: 18px;
}

.chips {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.chips li {
  background: var(--card-chip);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .84rem;
  color: var(--secondary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

/* ---------- Projects ---------- */
.proj-tools {
  margin-top: 48px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-btn {
  padding: 9px 18px;
  border-radius: 999px;
  font-size: .86rem;
  font-weight: 520;
  background: var(--card);
  color: var(--secondary);
  transition: all .2s;
}

.filter-btn:hover {
  color: var(--text);
}

.filter-btn.active {
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-soft);
}

#projSearch {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: .88rem;
  width: min(260px, 100%);
}

#projSearch:focus {
  border-color: var(--accent);
  outline: none;
}

.proj-grid {
  margin-top: 40px;
  display: grid;
  gap: 28px;
}

@media (min-width: 800px) {
  .proj-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.proj-card {
  border: 1px solid var(--border);
  border-radius: 32px;
  overflow: hidden;
  background: var(--card);
  display: flex;
  flex-direction: column;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}

.proj-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lift);
}

.proj-cover {
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.proj-cover span {
  font-size: 3.4rem;
  font-weight: 650;
  letter-spacing: -.03em;
  opacity: .12;
  transition: transform .5s var(--ease);
}

.proj-card:hover .proj-cover span {
  transform: scale(1.12);
}

.proj-body {
  padding: 30px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.proj-body h3 {
  font-size: 1.25rem;
  font-weight: 630;
  letter-spacing: -.015em;
}

.proj-body p {
  margin-top: 10px;
  color: var(--secondary);
  flex: 1;
}

.proj-actions {
  margin-top: 24px;
  display: flex;
  gap: 10px;
}

.proj-actions a {
  text-decoration: none;
  font-size: .85rem;
  font-weight: 550;
  padding: 10px 20px;
  border-radius: 999px;
  transition: box-shadow .2s, transform .2s;
}

.proj-actions a:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.proj-gh {
  border: 1px solid var(--border);
  background: var(--card-chip);
}

.proj-demo {
  background: var(--accent);
  color: #fff;
}

#projEmpty {
  display: none;
  text-align: center;
  color: var(--secondary);
  padding: 48px 0;
}

/* ---------- Experience ---------- */
.timeline {
  margin-top: 56px;
  list-style: none;
  border-left: 1px solid var(--border);
  margin-left: 8px;
}

.timeline li {
  position: relative;
  padding: 0 0 56px 40px;
}

.timeline li:last-child {
  padding-bottom: 0;
}

.timeline li::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 8px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--bg);
  box-shadow: var(--shadow-soft);
}

.timeline .period {
  font-size: .85rem;
  color: var(--secondary);
  font-weight: 500;
}

.timeline h3 {
  margin-top: 8px;
  font-size: 1.45rem;
  font-weight: 640;
  letter-spacing: -.02em;
}

.timeline .role {
  color: var(--accent);
  font-size: .92rem;
  font-weight: 550;
  margin-top: 2px;
}

.timeline p.desc {
  margin-top: 14px;
  max-width: 640px;
  color: var(--secondary);
}

/* ---------- Marquee ---------- */
.marquee-wrap {
  margin-top: 60px;
  overflow: hidden;
  mask-image: linear-gradient(to right, transparent, black 12%, black 88%, transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 12%, black 88%, transparent);
}

.marquee-track {
  display: flex;
  gap: 16px;
  width: max-content;
  padding-right: 16px;
  animation: marquee 30s linear infinite;
}

.marquee-wrap:hover .marquee-track {
  animation-play-state: paused;
}

@keyframes marquee {
  to {
    transform: translateX(-50%);
  }
}

.marquee-track span {
  white-space: nowrap;
  padding: 15px 32px;
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 520;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--secondary);
}

/* ---------- Stats ---------- */
.stats-grid {
  display: grid;
  gap: 22px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stat {
  text-align: center;
  padding: 44px 24px;
}

.stat .value {
  font-size: clamp(2.4rem, 4vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -.03em;
}

.stat .label {
  margin-top: 8px;
  color: var(--secondary);
  font-size: .95rem;
}

/* ---------- Testimonials ---------- */
.quote-mark {
  color: var(--accent);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.t-quote {
  margin-top: 14px;
  color: var(--secondary);
  flex: 1;
}

.t-name {
  margin-top: 22px;
  font-weight: 620;
}

.t-role {
  font-size: .86rem;
  color: var(--secondary);
}

.t-card {
  display: flex;
  flex-direction: column;
}

/* ---------- Contact ---------- */
.contact-grid {
  margin-top: 56px;
  display: grid;
  gap: 48px;
}

@media (min-width: 880px) {
  .contact-grid {
    grid-template-columns: 3fr 2fr;
  }
}

.form-row {
  display: grid;
  gap: 18px;
}

@media (min-width: 560px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

.field label {
  display: block;
  font-size: .88rem;
  font-weight: 550;
  margin-bottom: 8px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 15px 18px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: .95rem;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.field .error {
  display: none;
  margin-top: 7px;
  font-size: .84rem;
  color: #E5484D;
}

.field.invalid .error {
  display: block;
}

.field.invalid input,
.field.invalid textarea {
  border-color: #E5484D;
}

#formOk {
  display: none;
  margin-left: 14px;
  color: #30A46C;
  font-size: .9rem;
}

.contact-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contact-links a {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  padding: 16px 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  font-size: .92rem;
  font-weight: 520;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}

.contact-links a:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.contact-links svg {
  color: var(--secondary);
  flex: none;
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border);
  padding: 44px 0;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}

.footer-inner p {
  font-size: .88rem;
  color: var(--secondary);
}

.footer-links {
  display: flex;
  gap: 6px;
}

/* ---------- Command palette ---------- */
#paletteOverlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .32);
  backdrop-filter: blur(4px);
  padding: 18vh 16px 0;
  justify-content: center;
  align-items: flex-start;
}

#paletteOverlay.open {
  display: flex;
}

#palette {
  width: 100%;
  max-width: 520px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  animation: palIn .18s var(--ease);
}

@keyframes palIn {
  from {
    opacity: 0;
    transform: scale(.97) translateY(-8px);
  }
}

#paletteInput {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .95rem;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

#paletteList {
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  padding: 8px;
}

#paletteList .group {
  padding: 10px 12px 4px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--secondary);
}

#paletteList button {
  display: flex;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: .92rem;
  gap: 10px;
  align-items: center;
}

#paletteList button.active {
  background: rgba(0, 113, 227, .1);
  color: var(--accent);
}

#paletteEmpty {
  padding: 30px;
  text-align: center;
  color: var(--secondary);
  font-size: .9rem;
  display: none;
}