/* =========================================================
   COLORS: light theme by default
   ========================================================= */
:root {
  --bg: #fbfbfd;
  --bg-alt: #f3f4f8;
  --surface: #ffffff;
  --text: #0e1223;
  --muted: #5b6275;
  --border: #e6e8ef;
  --accent: #5b5bf6;
  --accent-2: #0ea5e9;
  --accent-soft: #eef0ff;
  --accent-text: #4338ca;
  --shadow: 0 1px 2px rgba(14, 18, 35, .04), 0 8px 24px rgba(14, 18, 35, .06);
  --shadow-lg: 0 24px 60px rgba(40, 40, 120, .14);
  --grid-line: rgba(14, 18, 35, .05);
  --radius: 18px;
  color-scheme: light;
}

/* Dark palette: shared by the system setting and the toggle button */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07080f;
    --bg-alt: #0c0e19;
    --surface: #121526;
    --text: #eceef6;
    --muted: #9aa1b8;
    --border: #1f2338;
    --accent: #8083ff;
    --accent-2: #38bdf8;
    --accent-soft: #1a1c3a;
    --accent-text: #a5a7ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
    --grid-line: rgba(255, 255, 255, .04);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07080f;
  --bg-alt: #0c0e19;
  --surface: #121526;
  --text: #eceef6;
  --muted: #9aa1b8;
  --border: #1f2338;
  --accent: #8083ff;
  --accent-2: #38bdf8;
  --accent-soft: #1a1c3a;
  --accent-text: #a5a7ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
  --grid-line: rgba(255, 255, 255, .04);
  color-scheme: dark;
}

/* =========================================================
   BASE
   ========================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 24px; }

.i {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

.gradient-text {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* =========================================================
   NAV
   ========================================================= */
.nav {
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid transparent;
  transition: background .3s, border-color .3s, backdrop-filter .3s;
}
.nav.scrolled {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom-color: var(--border);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 72px; gap: 16px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.02rem; }
.logo-mark {
  position: relative; overflow: hidden;
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: .85rem; font-weight: 800;
}
.nav-links { display: flex; gap: 6px; }
.nav-links a {
  padding: 8px 14px; border-radius: 999px; font-size: .93rem; font-weight: 500; color: var(--muted);
  transition: color .2s, background .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--accent-soft); }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
  transition: border-color .2s, transform .2s;
}
.icon-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}
.menu-btn { display: none; }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 22px; border-radius: 12px; font-weight: 600; font-size: .96rem;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .2s, box-shadow .2s, background .2s, border-color .2s;
}
.btn:hover { transform: translateY(-2px); }
.btn-sm { padding: 9px 16px; font-size: .88rem; border-radius: 10px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn-primary:hover { box-shadow: 0 12px 32px color-mix(in srgb, var(--accent) 45%, transparent); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-white { background: #fff; color: #1e1b4b; }
.btn-glass { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .28); }
.btn-glass:hover { background: rgba(255, 255, 255, .2); }

/* =========================================================
   HERO
   ========================================================= */
.hero { position: relative; padding: 72px 0 0; overflow: hidden; }
.hero-bg {
  position: absolute; inset: -72px 0 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px 400px at 15% 20%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(500px 380px at 85% 30%, color-mix(in srgb, var(--accent-2) 18%, transparent), transparent 70%),
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 48px 48px;
  mask-image: linear-gradient(to bottom, #000 60%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent);
}
.hero-inner { display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: 56px; padding-bottom: 72px; }
.badge {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 7px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.pulse {
  width: 8px; height: 8px; border-radius: 50%; background: #22c55e; position: relative; display: inline-block;
}
.pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: #22c55e;
  animation: ping 1.8s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes ping { 75%, 100% { transform: scale(2.6); opacity: 0; } }

.hero h1 {
  font-size: clamp(2.4rem, 5.4vw, 4rem); line-height: 1.08; font-weight: 800;
  letter-spacing: -0.035em; margin: 22px 0 20px;
}
.lead { font-size: 1.14rem; color: var(--muted); max-width: 560px; }
.lead strong { color: var(--text); font-weight: 600; }
.hero-buttons { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 28px; font-size: .9rem; color: var(--muted); }
.hero-meta span { display: inline-flex; align-items: center; gap: 7px; }
.hero-meta .i { width: 16px; height: 16px; color: var(--accent); }

/* Terminal card */
.terminal {
  border-radius: var(--radius); overflow: hidden;
  background: #0d1020; border: 1px solid #23284a;
  box-shadow: var(--shadow-lg);
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: .86rem;
  transform: perspective(1200px) rotateY(-6deg) rotateX(2deg);
  transition: transform .5s;
}
.terminal:hover { transform: none; }
.terminal-bar { display: flex; align-items: center; gap: 8px; padding: 14px 16px; background: #151935; border-bottom: 1px solid #23284a; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ff5f57; } .dot.yellow { background: #febc2e; } .dot.green { background: #28c840; }
.terminal-title { margin-left: 10px; color: #7c83a8; font-size: .78rem; }
.terminal-body { padding: 20px 22px 24px; color: #d6d9f0; min-height: 300px; }
.t-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.t-prompt { color: #a5a7ff; margin-right: 6px; }
.t-ok { color: #4ade80; margin-right: 8px; }
.t-dim { color: #6f76a0; }
.t-pass { color: #4ade80; font-weight: 500; margin-top: 12px; }
.cursor { display: inline-block; width: 8px; height: 1.05em; background: #a5a7ff; margin-left: 4px; vertical-align: text-bottom; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.js .t-line { opacity: 0; animation: lineIn .35s ease forwards; }
.t-line:nth-child(1) { animation-delay: .3s; }
.t-line:nth-child(2) { animation-delay: .8s; }
.t-line:nth-child(3) { animation-delay: 1.2s; }
.t-line:nth-child(4) { animation-delay: 1.5s; }
.t-line:nth-child(5) { animation-delay: 1.8s; }
.t-line:nth-child(6) { animation-delay: 2.1s; }
.t-line:nth-child(7) { animation-delay: 2.4s; }
.t-line:nth-child(8) { animation-delay: 2.7s; }
.t-line:nth-child(9) { animation-delay: 3.2s; }
@keyframes lineIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* Tech marquee */
.marquee {
  border-block: 1px solid var(--border); padding: 18px 0; overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}
.marquee-track { display: flex; width: max-content; gap: 48px; animation: scroll 40s linear infinite; }
.marquee-track span { font-weight: 700; font-size: 1.05rem; color: var(--muted); opacity: .75; white-space: nowrap; }
@keyframes scroll { to { transform: translateX(calc(-50% - 24px)); } }

/* =========================================================
   STATS
   ========================================================= */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  margin-top: 64px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); overflow: hidden;
}
.stat { padding: 28px 24px; border-right: 1px solid var(--border); }
.stat:last-child { border-right: 0; }
.stat-num {
  display: block; font-size: 2.3rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-label { display: block; margin-top: 6px; font-size: .9rem; color: var(--muted); }

/* =========================================================
   SECTIONS
   ========================================================= */
.section { padding: 110px 0; }
.section-alt { background: var(--bg-alt); border-block: 1px solid var(--border); }
.section-head { margin-bottom: 48px; }
.kicker {
  display: inline-block; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: .8rem; font-weight: 500; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent-text); margin-bottom: 12px;
}
.kicker::before { content: "// "; opacity: .6; }
.kicker.light { color: rgba(255, 255, 255, .8); }
.section-title { font-size: clamp(1.9rem, 3.6vw, 2.6rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; }

/* About */
.about { display: grid; grid-template-columns: 340px 1fr; gap: 72px; align-items: center; }
.about-photo { position: relative; justify-self: center; }
.avatar {
  position: relative; overflow: hidden;
  width: 320px; height: 380px; border-radius: 28px; box-shadow: var(--shadow-lg);
}
.avatar img, .logo-mark img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 25%;
}
.logo-mark { border-radius: 50%; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--accent) 50%, transparent); }
.avatar {
  display: grid; place-items: center; color: #fff; font-size: 5rem; font-weight: 800; letter-spacing: -0.04em;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .25), transparent 50%),
    linear-gradient(145deg, var(--accent), var(--accent-2));
}
.about-chip {
  position: absolute; bottom: -18px; right: -18px;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: .92rem;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.about-chip .i { color: var(--accent); }
.about-text .section-title { margin-bottom: 22px; }
.about-text p:not(.kicker) { color: var(--muted); font-size: 1.06rem; margin-bottom: 16px; }
.about-text strong { color: var(--text); font-weight: 600; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow);
  transition: transform .3s, box-shadow .3s, border-color .3s;
}
.card:hover {
  transform: translateY(-4px); box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.card h3 { font-size: 1.08rem; font-weight: 700; letter-spacing: -0.01em; }

.skills-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.skill-icon {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent-text); margin-bottom: 18px;
}
.skill-icon .i { width: 22px; height: 22px; }
.skill h3 { margin-bottom: 14px; }

.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tags span {
  padding: 5px 11px; border-radius: 8px; font-size: .8rem; font-weight: 500;
  background: var(--bg-alt); border: 1px solid var(--border); color: var(--muted);
}
.section-alt .tags span { background: var(--bg); }

/* Timeline */
.timeline { position: relative; display: grid; gap: 22px; padding-left: 36px; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 12px; bottom: 12px; width: 2px;
  background: linear-gradient(var(--accent), var(--accent-2) 40%, var(--border));
}
.job {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 30px; box-shadow: var(--shadow);
  transition: border-color .3s, box-shadow .3s;
}
.job:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); box-shadow: var(--shadow-lg); }
.job::before {
  content: ""; position: absolute; left: -36px; top: 32px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent);
}
.job.current::before { background: var(--accent); box-shadow: 0 0 0 6px var(--accent-soft); }
.job-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.job h3 { font-size: 1.18rem; font-weight: 700; }
.company { color: var(--muted); font-weight: 500; font-size: .95rem; }
.date {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .8rem; font-weight: 500;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
  background: var(--accent-soft); color: var(--accent-text);
}
.job ul { list-style: none; margin: 16px 0 18px; color: var(--muted); }
.job li { position: relative; padding-left: 20px; margin-bottom: 8px; }
.job li::before {
  content: ""; position: absolute; left: 0; top: .68em;
  width: 8px; height: 2px; border-radius: 2px; background: var(--accent);
}

/* Projects */
.projects-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.project { position: relative; overflow: hidden; padding: 32px; }
.project::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0); transform-origin: left; transition: transform .4s;
}
.project:hover::before { transform: scaleX(1); }
.project-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.project-num { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .85rem; color: var(--muted); }
.project-tag {
  font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent-text); background: var(--accent-soft); padding: 5px 10px; border-radius: 999px;
}
.project h3 { font-size: 1.3rem; margin-bottom: 12px; }
.project p { color: var(--muted); margin-bottom: 20px; }
.project-impact {
  display: inline-block; margin: -6px 0 20px; font-weight: 700; font-size: .9rem; color: #16a34a;
}
.project-impact::before { content: "▲ "; font-size: .7rem; }

/* Education */
.edu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.edu { display: flex; align-items: center; gap: 18px; }
.edu .skill-icon { margin-bottom: 0; }
.edu p { color: var(--muted); font-size: .94rem; }

/* Contact CTA */
.cta {
  position: relative; overflow: hidden; text-align: center; color: #fff;
  padding: 80px 32px; border-radius: 28px;
  background:
    radial-gradient(500px 300px at 10% 0%, rgba(255, 255, 255, .18), transparent 60%),
    radial-gradient(500px 300px at 90% 100%, rgba(14, 165, 233, .5), transparent 60%),
    linear-gradient(135deg, #4f46e5, #6d28d9 50%, #0369a1);
  box-shadow: var(--shadow-lg);
}
.cta h2 { font-size: clamp(1.9rem, 4vw, 2.9rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; max-width: 720px; margin: 0 auto 16px; }
.cta > p:not(.kicker) { color: rgba(255, 255, 255, .85); font-size: 1.1rem; max-width: 560px; margin: 0 auto; }
.cta-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 36px; }

/* Footer */
.footer { padding: 32px 0 40px; color: var(--muted); font-size: .9rem; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* =========================================================
   SCROLL REVEAL ANIMATION
   ========================================================= */
.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .7, .2, 1); }
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal, .js .t-line { opacity: 1; transform: none; }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1000px) {
  .skills-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-inner { grid-template-columns: 1fr; gap: 48px; }
  .terminal { transform: none; max-width: 560px; }
  .about { grid-template-columns: 1fr; gap: 56px; }
}

@media (max-width: 820px) {
  .menu-btn { display: grid; }
  .nav-cv { display: none; }
  .nav-links {
    position: absolute; top: 72px; left: 16px; right: 16px;
    flex-direction: column; gap: 2px; padding: 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
    opacity: 0; visibility: hidden; transform: translateY(-8px); transition: .2s;
  }
  .nav-links.open { opacity: 1; visibility: visible; transform: none; }
  .nav-links a { padding: 12px 14px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .projects-grid, .edu-grid { grid-template-columns: 1fr; }
  .section { padding: 80px 0; }
}

@media (max-width: 560px) {
  .container { padding: 0 18px; }
  .hero { padding-top: 40px; }
  .skills-grid { grid-template-columns: 1fr; }
  .terminal { font-size: .76rem; }
  .terminal-body { padding: 16px; min-height: 0; }
  .avatar { width: 260px; height: 300px; }
  .about-chip { right: -8px; }
  .timeline { padding-left: 26px; }
  .timeline::before { left: 4px; }
  .job { padding: 22px 20px; }
  .job::before { left: -29px; width: 14px; height: 14px; }
  .project { padding: 24px; }
  .cta { padding: 56px 22px; border-radius: 22px; }
  .cta .btn { width: 100%; justify-content: center; }
  .logo-text { display: none; }
}
