/* ===== Design tokens ===== */
:root {
  --bg: #070b16;
  --bg-alt: #0b1120;
  --card: rgba(255, 255, 255, 0.04);
  --line: rgba(160, 180, 255, 0.15);
  --text: #e8ecf8;
  --muted: #9aa5c3;
  --cyan: #38d6ff;
  --violet: #8b7bff;
  --blue: #3b8dff;
  --head: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --body: "Manrope", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.65 var(--body); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--head); line-height: 1.12; letter-spacing: -0.02em; margin: 0; }
p { margin: 0; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 6px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 22px; }
.sec { padding: 96px 0; }
.sec.alt { background: var(--bg-alt); }
h2 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin-bottom: 14px; }
.lead { color: var(--muted); max-width: 60ch; margin-bottom: 36px; }
.note { font-size: 0.84rem; color: var(--muted); margin-top: 6px; }
.glass { background: var(--card); border: 1px solid var(--line); border-radius: 16px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* ===== Navigation ===== */
.nav { position: sticky; top: 0; z-index: 50; background: rgba(7, 11, 22, 0.8); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo { font: 700 1.05rem var(--head); }
.nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav li a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 0.92rem; transition: color 0.2s, background 0.2s; }
.nav li a:hover { color: var(--text); }
.nav li a.active { color: var(--text); background: var(--card); box-shadow: inset 0 -2px 0 var(--cyan); }
.menu-btn { display: none; background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; }
@media (max-width: 860px) {
  .menu-btn { display: block; }
  .nav ul { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; background: var(--bg-alt); padding: 10px 22px 16px; border-bottom: 1px solid var(--line); }
  .nav ul.open { display: flex; }
}

/* ===== Buttons ===== */
.btns { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.btn { display: inline-flex; align-items: center; padding: 12px 20px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: 600 0.95rem var(--body); cursor: pointer; transition: transform 0.2s, border-color 0.2s; }
.btn:hover { transform: translateY(-2px); border-color: var(--cyan); }
.btn.primary { background: linear-gradient(120deg, var(--violet), var(--blue)); border-color: transparent; color: #fff; }
.btn.sm { padding: 8px 14px; font-size: 0.86rem; }

/* ===== Hero ===== */
.hero { position: relative; overflow: hidden; padding: 96px 0 70px; }
#net { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.6; }
.hero-grid { position: relative; display: grid; grid-template-columns: 1.5fr 1fr; gap: 40px; align-items: center; }
.hello { color: var(--cyan); font-weight: 600; margin-bottom: 12px; }
h1 { font-size: clamp(2.6rem, 7vw, 4.8rem); max-width: 12ch; background: linear-gradient(120deg, #fff 30%, #a9b8ff 70%, var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.role { font: 500 clamp(1.1rem, 2.4vw, 1.5rem) var(--head); margin: 18px 0 4px; }
.sub { color: var(--muted); margin-bottom: 14px; }
.intro { color: #c5cde6; max-width: 56ch; font-size: 1.06rem; }
.avatar { width: min(320px, 70vw); aspect-ratio: 1; justify-self: center; border-radius: 28px; overflow: hidden; display: grid; place-items: center; position: relative; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.fallback { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); font: 700 3rem var(--head); background: linear-gradient(135deg, rgba(139, 123, 255, 0.25), rgba(56, 214, 255, 0.12)); text-align: center; padding: 10px; }
.facts { position: relative; display: flex; flex-wrap: wrap; gap: 28px; margin-top: 56px; padding-top: 26px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.92rem; }
.facts b { display: block; color: var(--text); font: 600 1rem var(--head); }
@media (max-width: 820px) { .hero-grid { grid-template-columns: 1fr; } .avatar { order: -1; width: 180px; } }

/* ===== Layout helpers ===== */
.grid { display: grid; gap: 18px; }
.skills, .certs { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-top: 28px; }
.projects { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 22px; }
.card { padding: 24px; }
.card h3 { font-size: 1.1rem; margin-bottom: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags span { font-size: 0.83rem; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); color: #cfd6ee; background: rgba(139, 123, 255, 0.09); }
.about { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; margin-top: 22px; }
.about p { color: #c5cde6; }
.about p + p { margin-top: 14px; }
.list { list-style: none; margin: 0; padding: 22px; align-self: start; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.list li:last-child { border: 0; }
@media (max-width: 820px) { .about { grid-template-columns: 1fr; } }

/* ===== Projects ===== */
.project { padding: 22px; display: flex; flex-direction: column; gap: 14px; transition: border-color 0.25s, transform 0.25s; }
.project:hover { border-color: rgba(56, 214, 255, 0.5); transform: translateY(-3px); }
.project h3 { font-size: 1.3rem; }
.project p { color: var(--muted); font-size: 0.95rem; }
.cat { color: var(--cyan); font-size: 0.85rem; font-weight: 600; }
.shot { aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.shot img { width: 100%; height: 100%; object-fit: cover; }
.shot .fallback { font-size: 0.95rem; font-weight: 500; }
.acts { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }

/* ===== Dialog (case study) ===== */
dialog { width: min(820px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow: auto; background: var(--bg-alt); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 0; }
dialog::backdrop { background: rgba(3, 6, 14, 0.75); backdrop-filter: blur(4px); }
.close { position: sticky; top: 12px; float: right; margin: 12px 12px 0 0; background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 12px; cursor: pointer; font: inherit; }
.cs { padding: 30px; }
.cs h3 { font-size: 1.9rem; margin: 6px 0 10px; }
.cs h4 { font: 600 1.05rem var(--head); margin: 26px 0 8px; }
.cs p, .cs li { color: #c5cde6; }
.cs li { margin: 6px 0; }
.cs .shot { margin: 18px 0 8px; }
.flow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.flow span { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(56, 214, 255, 0.07); font-size: 0.86rem; }
.flow i { color: var(--muted); font-style: normal; font-size: 0.8rem; }
.metrics { display: flex; flex-wrap: wrap; gap: 12px; }
.metrics div { padding: 10px 16px; border: 1px solid var(--line); border-radius: 12px; }
.metrics b { display: block; font: 700 1.35rem var(--head); }
.metrics span { font-size: 0.8rem; color: var(--muted); }

/* ===== Timeline / education ===== */
.timeline { border-left: 2px solid var(--line); padding-left: 26px; margin-top: 28px; }
.tl-item { position: relative; padding: 24px; }
.tl-item::before { content: ""; position: absolute; left: -35px; top: 32px; width: 12px; height: 12px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px var(--bg-alt); }
.when { color: var(--cyan); font-weight: 600; font-size: 0.9rem; }
.tl-item h3, .card .when + h3 { font-size: 1.3rem; margin: 4px 0; }
.org { color: var(--muted); margin-bottom: 8px; }
.tl-item ul { padding-left: 18px; color: var(--muted); margin: 12px 0 0; }
.tl-item li { margin: 6px 0; }

/* ===== Contact ===== */
.contact { padding: 36px; }
.contact .lead { margin-bottom: 0; }
form { display: grid; gap: 14px; margin-top: 28px; max-width: 560px; }
.field label { display: block; font-size: 0.88rem; color: var(--muted); margin-bottom: 6px; }
input, textarea { width: 100%; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; color: var(--text); font: inherit; }
input.invalid, textarea.invalid { border-color: #ff7a8a; }
.err { display: block; color: #ff9aa6; font-size: 0.82rem; min-height: 1em; margin-top: 4px; }
footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: 0.9rem; }
.to-top { position: fixed; right: 18px; bottom: 18px; z-index: 40; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(12, 18, 34, 0.9); color: var(--text); cursor: pointer; font: inherit; }

/* ===== Scroll reveal (only hides content when JS is running) ===== */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s ease, transform 0.6s ease; }
.js .reveal.in { opacity: 1; transform: none; }

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