/* ---------- Design tokens ---------- */
:root {
  --bg: #0a0e14;
  --bg-alt: #0f141b;
  --surface: #141a23;
  --border: #1e2631;
  --text: #e6edf3;
  --text-dim: #9aa7b5;
  --accent: #22d3ee;
  --accent-2: #34d399;
  --accent-glow: rgba(34, 211, 238, 0.18);
  --danger: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.6);
  --font-sans: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --container: 1120px;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-alt: #f6f8fb;
  --surface: #ffffff;
  --border: #e5e9ef;
  --text: #0c1220;
  --text-dim: #51606f;
  --accent: #0891b2;
  --accent-2: #059669;
  --accent-glow: rgba(8, 145, 178, 0.12);
  --shadow: 0 10px 30px -15px rgba(12, 18, 32, 0.15);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-2); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.1rem; }
ul { padding-left: 1.1rem; margin: 0.5rem 0; }
p { margin: 0 0 1rem; text-wrap: pretty; }
li { text-wrap: pretty; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #000; padding: 0.5rem 1rem;
}
.skip-link:focus { left: 1rem; top: 1rem; z-index: 999; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 1.25rem; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.75rem 1.25rem;
}
.brand {
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--text); font-weight: 700;
}
.brand-mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #001014; font-family: var(--font-mono); font-weight: 700; font-size: 0.85rem;
}
.brand-text { font-family: var(--font-mono); font-size: 0.95rem; }
.nav-links {
  display: flex; flex-wrap: wrap; gap: 0.25rem;
  list-style: none; margin: 0; padding: 0;
}
.nav-links a {
  display: inline-block; padding: 0.4rem 0.75rem; border-radius: 8px;
  color: var(--text-dim); font-size: 0.9rem; font-weight: 500;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--text); background: var(--surface); }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); width: 36px; height: 36px; border-radius: 8px;
  cursor: pointer; display: inline-grid; place-items: center;
  font-size: 1rem;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: none; }

/* ---------- Hamburger (mobile) ---------- */
.hamburger {
  display: none;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); width: 36px; height: 36px; border-radius: 8px;
  cursor: pointer; place-items: center; font-size: 1.15rem; line-height: 1;
  flex-shrink: 0;
}
.hamburger:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 780px) {
  .nav-links {
    display: none;
    width: 100%; flex-direction: column; gap: 0.1rem;
    border-top: 1px solid var(--border);
    padding: 0.4rem 0.75rem 0.6rem;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 0.55rem 0.75rem; }
  .hamburger { display: inline-grid; }
  .nav { flex-wrap: wrap; padding: 0.6rem 1rem; }
}

/* ---------- Scroll offset (clears sticky header) ---------- */
section[id] { scroll-margin-top: 72px; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: clamp(3rem, 8vw, 6rem) 0 clamp(2rem, 5vw, 4rem);
}
.hero::before {
  content: ""; position: absolute; inset: -20% -10% auto auto;
  width: 60vw; height: 60vw; max-width: 720px; max-height: 720px;
  background: radial-gradient(closest-side, var(--accent-glow), transparent 70%);
  pointer-events: none; z-index: 0;
}
.hero-grid {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 2.5rem; align-items: center;
}
.eyebrow {
  font-family: var(--font-mono); font-size: 0.85rem;
  color: var(--accent); margin-bottom: 0.75rem; letter-spacing: 0.02em;
}
.accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { color: var(--text-dim); font-size: 1.05rem; max-width: 56ch; text-wrap: pretty; }
.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 1.1rem; border-radius: 10px;
  font-weight: 600; font-size: 0.95rem; border: 1px solid transparent;
  transition: transform 0.1s, background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #001014;
}
.btn.primary:hover { filter: brightness(1.05); color: #001014; }
.btn.ghost {
  background: transparent; color: var(--text);
  border-color: var(--border);
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

.hero-stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow);
}
.stat {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.75rem; border-radius: var(--radius-sm);
  background: var(--bg-alt); border: 1px solid var(--border);
}
.stat-num {
  font-family: var(--font-mono); font-weight: 700; font-size: 1.1rem;
  color: var(--accent);
}
.stat-label { font-size: 0.78rem; color: var(--text-dim); }

@media (max-width: 880px) {
  .hero-grid { grid-template-columns: 1fr; }
}

/* ---------- Section defaults ---------- */
.section { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.section.alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section h2 {
  display: inline-block; position: relative; padding-bottom: 0.5rem; margin-bottom: 1.5rem;
}
.section h2::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 44px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 3px;
}
.section-lead { color: var(--text-dim); max-width: 70ch; margin-bottom: 1.5rem; text-wrap: pretty; }
.mt { margin-top: 1.5rem; }

/* ---------- About ---------- */
.about-grid { display: grid; gap: 1rem; max-width: 80ch; color: var(--text-dim); }
.about-grid strong { color: var(--text); }

/* ---------- Skills ---------- */
.skill-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.skill-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.1rem 1.2rem;
  transition: border-color 0.15s, transform 0.15s;
}
.skill-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.skill-card h3 {
  font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); margin-bottom: 0.75rem;
}
.chips {
  list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem;
  padding: 0; margin: 0;
}
.chips li {
  font-family: var(--font-mono); font-size: 0.78rem;
  padding: 0.25rem 0.6rem; border-radius: 999px;
  background: var(--bg-alt); border: 1px solid var(--border);
  color: var(--text);
}
.chips.small li { font-size: 0.72rem; padding: 0.2rem 0.5rem; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.t-item {
  display: grid; grid-template-columns: 220px 1fr; gap: 1.25rem;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
  padding: 1.25rem;
}
.t-meta { display: flex; flex-direction: column; gap: 0.25rem; color: var(--text-dim); }
.t-date { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent); }
.t-loc { font-size: 0.82rem; }
.t-body h3 { margin-bottom: 0.15rem; }
.t-company { font-family: var(--font-mono); color: var(--text-dim); margin: 0 0 0.75rem; font-size: 0.9rem; }
.t-body ul { color: var(--text-dim); }
.t-body ul li { margin-bottom: 0.4rem; }
.t-body strong { color: var(--text); }

@media (max-width: 780px) {
  .t-item { grid-template-columns: 1fr; }
}

/* ---------- Projects / AI ---------- */
.proj-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.proj-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.1rem 1.2rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  transition: border-color 0.15s, transform 0.15s;
}
.proj-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.proj-card header h3 { margin: 0; }
.proj-card p { color: var(--text-dim); margin: 0; font-size: 0.92rem; }

/* ---------- Certifications / Education ---------- */
.cert-grid, .edu-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.75rem; list-style: none; padding: 0; margin: 0;
}
.cert-grid li, .edu-grid li {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.85rem 1rem; color: var(--text-dim);
}
.cert-grid li strong, .edu-grid li strong { color: var(--text); display: block; margin-bottom: 0.1rem; }
.edu-grid li span { font-size: 0.88rem; }

/* ---------- CV cards ---------- */
.cv-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.cv-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem;
  color: var(--text); display: block;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.cv-card:hover {
  border-color: var(--accent); color: var(--text);
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--surface) 80%, var(--accent-glow));
}
.cv-card h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.cv-card p { margin: 0; color: var(--text-dim); font-size: 0.88rem; }
.cv-badge {
  position: absolute; top: 0.75rem; right: 0.75rem;
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600;
  padding: 0.15rem 0.5rem; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #001014;
}

/* ---------- Contact ---------- */
.contact-list {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.5rem;
}
.contact-list li {
  display: flex; gap: 0.75rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.75rem 1rem;
}
.contact-list span {
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-dim);
  min-width: 72px; text-transform: uppercase; letter-spacing: 0.06em;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); padding: 1.5rem 0;
  color: var(--text-dim); font-size: 0.85rem;
}
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; }
.foot-meta a { margin-left: 0.25rem; }

/* ---------- Case study pages ---------- */
.case .hero { padding-top: clamp(2rem, 5vw, 3rem); }
.case-body { max-width: 80ch; }
.case-body h2 {
  margin-top: 2rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border);
}
.case-body ul { color: var(--text-dim); }
.case-body ul li { margin-bottom: 0.4rem; }
.case-body strong { color: var(--text); }
.case-body code {
  font-family: var(--font-mono); font-size: 0.85em;
  background: var(--bg-alt); border: 1px solid var(--border);
  padding: 0.1rem 0.4rem; border-radius: 4px;
}
.case-body pre.code {
  font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.5;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem; overflow-x: auto;
  color: var(--text);
}
.back-cta { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }

/* ---------- Chatbot ---------- */
.chat-fab {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 100;
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.1rem; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #001014; font-weight: 700; font-size: 0.95rem;
  border: none; cursor: pointer;
  box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.45);
  transition: transform 0.1s, filter 0.15s;
}
.chat-fab:hover { filter: brightness(1.05); }
.chat-fab:active { transform: translateY(1px); }
.chat-fab-text { font-family: var(--font-mono); letter-spacing: 0.02em; }

.chat-panel {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 101;
  width: min(380px, calc(100vw - 2rem));
  height: min(560px, calc(100vh - 2rem));
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.chat-panel[hidden] { display: none; }
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.chat-title { display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; }
.chat-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2);
}
.chat-close {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 0.25rem;
}
.chat-close:hover { color: var(--text); }
.chat-body {
  flex: 1; overflow-y: auto; padding: 0.75rem 1rem;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.chat-msg {
  max-width: 85%; padding: 0.6rem 0.85rem; border-radius: 14px;
  font-size: 0.9rem; line-height: 1.45; white-space: pre-wrap;
}
.chat-msg a { color: var(--accent); }
.chat-bot {
  align-self: flex-start; background: var(--bg-alt);
  border: 1px solid var(--border); border-bottom-left-radius: 4px;
}
.chat-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #001014; border-bottom-right-radius: 4px;
}
.chat-suggs {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  padding: 0 1rem 0.5rem;
}
.chat-sugg {
  font-size: 0.78rem; padding: 0.3rem 0.6rem; border-radius: 999px;
  background: var(--bg-alt); color: var(--text); border: 1px solid var(--border);
  cursor: pointer; font-family: var(--font-sans);
}
.chat-sugg:hover { border-color: var(--accent); color: var(--accent); }
.chat-form {
  display: flex; gap: 0.5rem; padding: 0.75rem 1rem;
  border-top: 1px solid var(--border); background: var(--bg-alt);
}
.chat-form input {
  flex: 1; padding: 0.55rem 0.75rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 0.9rem;
}
.chat-form input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.chat-send {
  padding: 0.55rem 0.9rem; border-radius: 8px; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #001014; font-weight: 600; cursor: pointer; font-size: 0.9rem;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
