/* =========================================================
   Kashyap Raj Karki — Portfolio
   ========================================================= */

:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1140px;
  --header-h: 68px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  --accent-1: #22d3ee;  /* cyan */
  --accent-2: #818cf8;  /* indigo */
  --accent-3: #34d399;  /* green */
  --gradient: linear-gradient(120deg, var(--accent-1), var(--accent-2));
}

/* Dark (default) */
[data-theme="dark"] {
  --bg: #0b0f17;
  --bg-alt: #0f1521;
  --surface: rgba(255, 255, 255, .035);
  --surface-hover: rgba(255, 255, 255, .06);
  --border: rgba(255, 255, 255, .09);
  --text: #e6eaf2;
  --text-muted: #97a1b3;
  --heading: #ffffff;
  --header-bg: rgba(11, 15, 23, .72);
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, .6);
  --terminal-bg: #0d1220;
  --tag-bg: rgba(129, 140, 248, .12);
  --tag-text: #c7cdfb;
}

/* Light */
[data-theme="light"] {
  --bg: #f7f8fb;
  --bg-alt: #eef1f7;
  --surface: #ffffff;
  --surface-hover: #ffffff;
  --border: rgba(15, 23, 42, .09);
  --text: #2a3346;
  --text-muted: #5b667a;
  --heading: #0b1220;
  --header-bg: rgba(247, 248, 251, .8);
  --shadow: 0 20px 45px -25px rgba(30, 41, 59, .35);
  --terminal-bg: #0f172a;
  --tag-bg: rgba(99, 102, 241, .1);
  --tag-text: #4338ca;
  --accent-1: #0891b2;
  --accent-2: #6366f1;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3 { color: var(--heading); line-height: 1.2; margin: 0; letter-spacing: -.02em; }
p { margin: 0 0 1rem; }
strong { color: var(--heading); font-weight: 600; }
button { font: inherit; cursor: pointer; }
::selection { background: var(--accent-2); color: #fff; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.fill { fill: currentColor; stroke: none; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); font-weight: 500; }
.accent { color: var(--accent-1); }
.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--accent-2); color: #fff; padding: 8px 14px; border-radius: 8px;
}
.skip-link:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent-1); outline-offset: 3px; border-radius: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; font-weight: 600; font-size: .95rem;
  border: 1px solid transparent; transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s, border-color .2s;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 10px 30px -10px rgba(99, 102, 241, .6); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 36px -12px rgba(99, 102, 241, .75); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--heading); }
.btn-outline:hover { border-color: var(--accent-2); transform: translateY(-2px); }
.btn-sm { padding: 7px 16px; font-size: .85rem; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--heading);
  transition: border-color .2s, background .2s;
}
.icon-btn:hover { border-color: var(--accent-2); }

/* ---------- Header ---------- */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50; height: var(--header-h);
  background: transparent; border-bottom: 1px solid transparent;
  transition: background .3s, border-color .3s, backdrop-filter .3s;
}
.site-header.scrolled {
  background: var(--header-bg); border-color: var(--border);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
}
.nav { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--heading); font-size: 1.1rem; }
.logo-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: var(--gradient); color: #fff; font-family: var(--font-mono); font-size: .85rem; font-weight: 600;
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  position: relative; padding: 8px 14px; border-radius: 999px; font-size: .92rem; font-weight: 500; color: var(--text-muted);
  transition: color .2s, background .2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--heading); background: var(--surface-hover); }
.nav-cta-mobile { display: none; }
.nav-actions { display: flex; align-items: center; gap: 10px; }

/* theme icons */
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.menu-toggle { display: none; flex-direction: column; gap: 4px; }
.menu-toggle span { display: block; width: 18px; height: 2px; border-radius: 2px; background: currentColor; transition: transform .3s var(--ease), opacity .2s; }
.menu-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  position: relative; min-height: 100vh; min-height: 100svh;
  display: flex; align-items: center; padding: calc(var(--header-h) + 40px) 0 80px; overflow: hidden;
}
.hero-bg { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .45; animation: float 18s ease-in-out infinite; }
.blob-1 { width: 520px; height: 520px; background: var(--accent-2); top: -140px; right: -120px; }
.blob-2 { width: 420px; height: 420px; background: var(--accent-1); bottom: -160px; left: -120px; animation-delay: -9s; opacity: .3; }
[data-theme="light"] .blob { opacity: .22; }
.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%);
  opacity: .6;
}
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-40px, 30px) scale(1.08); }
}

.hero-inner { display: grid; grid-template-columns: 1.15fr .85fr; gap: 56px; align-items: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: .85rem; color: var(--text-muted); margin-bottom: 24px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-3); box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); } }

.hero-title { font-size: clamp(2.4rem, 6vw, 4.2rem); font-weight: 800; letter-spacing: -.035em; margin-bottom: 16px; }
.hero-role { font-family: var(--font-mono); font-size: clamp(1rem, 2.2vw, 1.25rem); color: var(--accent-1); margin-bottom: 20px; min-height: 1.6em; }
.caret { animation: blink 1s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.hero-sub { font-size: clamp(1rem, 1.6vw, 1.12rem); color: var(--text-muted); max-width: 560px; margin-bottom: 32px; }
.hero-ctas { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-ctas.center { justify-content: center; }
.hero-social { display: flex; gap: 10px; margin-top: 32px; }
.hero-social a {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  transition: color .2s, border-color .2s, transform .2s var(--ease);
}
.hero-social a:hover { color: var(--heading); border-color: var(--accent-2); transform: translateY(-3px); }

/* Terminal */
.terminal {
  background: var(--terminal-bg); border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius); box-shadow: var(--shadow), 0 0 0 1px rgba(129, 140, 248, .08), 0 30px 80px -30px rgba(99, 102, 241, .45);
  overflow: hidden; transform: perspective(1200px) rotateY(-6deg) rotateX(2deg);
  transition: transform .5s var(--ease);
}
.terminal:hover { transform: perspective(1200px) rotateY(0) rotateX(0); }
.terminal-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid rgba(255, 255, 255, .06); background: rgba(255, 255, 255, .02); }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ff5f57; } .dot.yellow { background: #febc2e; } .dot.green { background: #28c840; }
.terminal-title { margin-left: auto; margin-right: auto; font-family: var(--font-mono); font-size: .75rem; color: #7b8496; transform: translateX(-24px); }
.terminal-body { margin: 0; padding: 20px 22px 24px; font-family: var(--font-mono); font-size: .86rem; line-height: 1.75; color: #cbd5e1; overflow-x: auto; }
.t-prompt { color: var(--accent-3); } .t-key { color: #93c5fd; } .t-str { color: #fbbf24; }
.t-cursor { color: #cbd5e1; animation: blink 1s steps(1) infinite; }

.scroll-hint {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%);
  width: 26px; height: 42px; border: 2px solid var(--border); border-radius: 14px;
}
.scroll-hint span { position: absolute; left: 50%; top: 8px; width: 4px; height: 8px; margin-left: -2px; border-radius: 2px; background: var(--text-muted); animation: scroll 1.8s infinite; }
@keyframes scroll { 0% { opacity: 0; transform: translateY(0); } 40% { opacity: 1; } 100% { opacity: 0; transform: translateY(14px); } }

/* ---------- Sections ---------- */
.section { padding: 110px 0; position: relative; }
.section-alt { background: var(--bg-alt); }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 48px; }
.section-head h2 { font-size: clamp(1.8rem, 3.6vw, 2.5rem); font-weight: 700; }
.section-head::after { content: ""; flex: 1; height: 1px; background: var(--border); align-self: center; margin-left: 12px; max-width: 280px; }
.section-num { font-family: var(--font-mono); font-size: .95rem; color: var(--accent-1); }

/* About */
.about-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 56px; align-items: start; }
.about-text p { font-size: 1.06rem; color: var(--text-muted); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stat {
  padding: 24px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; gap: 6px; transition: transform .25s var(--ease), border-color .25s;
}
.stat:hover { transform: translateY(-4px); border-color: var(--accent-2); }
.stat-num { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1.1; }
.stat-label { font-size: .88rem; color: var(--text-muted); }

/* Skills */
.skills-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.skill-card {
  position: relative; padding: 28px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  overflow: hidden; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s;
}
.skill-card::before {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity .3s;
  background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 0%), rgba(129, 140, 248, .12), transparent 40%);
  pointer-events: none;
}
.skill-card:hover { transform: translateY(-6px); border-color: rgba(129, 140, 248, .45); box-shadow: var(--shadow); }
.skill-card:hover::before { opacity: 1; }
.skill-icon {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; margin-bottom: 18px;
  background: var(--tag-bg); color: var(--accent-2);
}
.skill-icon svg { width: 24px; height: 24px; }
.skill-card h3 { font-size: 1.12rem; margin-bottom: 16px; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags li {
  font-size: .82rem; font-weight: 500; padding: 5px 12px; border-radius: 999px;
  background: var(--tag-bg); color: var(--tag-text); border: 1px solid transparent;
}
.tags-sm { margin-top: 18px; }
.tags-sm li { font-family: var(--font-mono); font-size: .74rem; padding: 3px 10px; }

/* Timeline */
.timeline { position: relative; padding-left: 36px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--accent-1), var(--accent-2), transparent); opacity: .5; }
.timeline-item { position: relative; padding-bottom: 28px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-marker {
  position: absolute; left: -36px; top: 28px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent-2);
}
.timeline-marker.current { border-color: var(--accent-3); box-shadow: 0 0 0 6px rgba(52, 211, 153, .15); }
.timeline-card {
  padding: 28px 30px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  transition: border-color .3s, transform .3s var(--ease), box-shadow .3s;
}
.timeline-card:hover { border-color: rgba(129, 140, 248, .45); transform: translateX(4px); box-shadow: var(--shadow); }
.timeline-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.timeline-card h3 { font-size: 1.25rem; }
.company { margin: 4px 0 0; color: var(--accent-1); font-weight: 600; }
.company a { display: inline-flex; align-items: center; gap: 4px; }
.company a:hover { text-decoration: underline; text-underline-offset: 3px; }
.ext { width: 15px; height: 15px; }
.date-pill {
  font-family: var(--font-mono); font-size: .78rem; padding: 6px 12px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--border); color: var(--text-muted); background: var(--bg);
}
.current-pill { color: var(--accent-3); border-color: rgba(52, 211, 153, .35); }
.bullets li { position: relative; padding-left: 22px; margin-bottom: 10px; color: var(--text-muted); }
.bullets li::before { content: "▹"; position: absolute; left: 0; top: 0; color: var(--accent-1); }

/* Education */
.edu-card {
  display: flex; align-items: center; gap: 22px; padding: 28px 30px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
}
.edu-icon { flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 14px; background: var(--gradient); color: #fff; }
.edu-icon svg { width: 28px; height: 28px; }
.edu-body { flex: 1; }
.edu-body h3 { font-size: 1.15rem; }

/* Contact */
.contact-card {
  text-align: center; padding: 64px 40px; border-radius: 24px; border: 1px solid var(--border);
  background:
    radial-gradient(600px circle at 0% 0%, rgba(34, 211, 238, .1), transparent 50%),
    radial-gradient(600px circle at 100% 100%, rgba(129, 140, 248, .14), transparent 50%),
    var(--surface);
}
.contact-card h2 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 800; margin: 12px auto 16px; max-width: 720px; }
.contact-sub { color: var(--text-muted); max-width: 520px; margin: 0 auto 36px; }
.contact-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 36px; text-align: left; }
.contact-item {
  display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--heading); font-weight: 500; font-size: .95rem;
  transition: border-color .2s, transform .2s var(--ease); min-width: 0;
}
a.contact-item:hover { border-color: var(--accent-2); transform: translateY(-3px); }
.contact-item svg { flex: none; color: var(--accent-1); }
.contact-item span { min-width: 0; overflow-wrap: anywhere; }
.contact-item small { display: block; font-size: .75rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; font-size: .88rem; color: var(--text-muted); }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer-inner p { margin: 0; }
.footer-links { display: flex; gap: 20px; }
.footer-links a:hover { color: var(--heading); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--heading); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: .9rem; font-weight: 500;
  transition: opacity .25s, transform .25s var(--ease); z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.visible { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .skills-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-inner { gap: 40px; }
}

@media (max-width: 880px) {
  .menu-toggle { display: inline-flex; }
  .nav-cv { display: none; }
  .nav-links {
    position: fixed; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 4px; padding: 16px 24px 24px;
    background: var(--header-bg); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
    transform: translateY(-12px); opacity: 0; visibility: hidden;
    transition: transform .3s var(--ease), opacity .3s, visibility .3s;
  }
  .nav-links.open { transform: none; opacity: 1; visibility: visible; }
  .nav-links a { padding: 12px 14px; font-size: 1rem; border-radius: 12px; }
  .nav-cta-mobile { display: block; margin-top: 8px; }
  .nav-cta-mobile .btn { width: 100%; color: #fff; }
  .site-header:has(.nav-links.open) { background: var(--header-bg); border-color: var(--border); backdrop-filter: blur(18px); }

  .hero-inner { grid-template-columns: 1fr; }
  .hero-visual { max-width: 560px; }
  .terminal { transform: none; }
  .about-grid { grid-template-columns: 1fr; gap: 36px; }
  .contact-grid { grid-template-columns: 1fr; }
  .scroll-hint { display: none; }
}

@media (max-width: 600px) {
  .container { padding: 0 18px; }
  .section { padding: 80px 0; }
  .section-head { margin-bottom: 32px; }
  .section-head::after { display: none; }
  .skills-grid { grid-template-columns: 1fr; }
  .stats { gap: 12px; }
  .stat { padding: 18px; }
  .stat-num { font-size: 1.8rem; }
  .timeline { padding-left: 26px; }
  .timeline::before { left: 6px; }
  .timeline-marker { left: -26px; width: 16px; height: 16px; }
  .timeline-card { padding: 22px 20px; }
  .timeline-card:hover { transform: none; }
  .edu-card { flex-direction: column; align-items: flex-start; padding: 24px 20px; }
  .contact-card { padding: 44px 20px; }
  .terminal-body { font-size: .76rem; padding: 16px; }
  .hero-ctas .btn { flex: 1 1 auto; }
  .footer-inner { flex-direction: column; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}

@media print {
  .site-header, .hero-bg, .scroll-hint, .hero-visual, .toast { display: none !important; }
  .reveal { opacity: 1 !important; transform: none !important; }
  body { background: #fff; color: #000; }
}
