/* ===== Theme tokens ===== */
:root {
  --bg: #f7f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1b1e27;
  --muted: #5d6475;
  --border: #dde1e8;
  --accent: #3b5bdb;
  --accent-hover: #2f4ac0;
  --accent-soft: #e7ecff;
  --accent-text: #ffffff;
  --success: #2b8a3e;
  --success-soft: #e6f4ea;
  --danger: #c92a2a;
  --danger-soft: #fdecec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #171a22;
  --surface-2: #1f2330;
  --text: #e7e9ee;
  --muted: #9aa1b2;
  --border: #2a2f3d;
  --accent: #7b93ff;
  --accent-hover: #93a7ff;
  --accent-soft: #1e2645;
  --accent-text: #0f1117;
  --success: #69db7c;
  --success-soft: #16301d;
  --danger: #ff8787;
  --danger-soft: #3a1a1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background-color .2s, color .2s;
}
main { flex: 1; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.02em; }
h2 { font-size: 1.6rem; letter-spacing: -.01em; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.section { padding: 64px 0; }
.section-sm { padding: 40px 0; }
.page-head { padding: 56px 0 8px; }
.page-head p { color: var(--muted); font-size: 1.1rem; max-width: 640px; }
.muted { color: var(--muted); }

/* ===== Header / nav ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); margin-right: auto; }
.brand:hover { text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand .logo { height: 40px; width: auto; max-width: 180px; object-fit: contain; }
.brand .logo-dark,
[data-theme="dark"] .brand .logo-light { display: none; }
[data-theme="dark"] .brand .logo-dark { display: block; }

/* Photos placed inside page text with [image:...] */
.content-image { margin: 1.6em 0; }
.content-image img { border-radius: var(--radius); box-shadow: var(--shadow); margin: 0 auto; max-height: 560px; width: auto; }
.content-image figcaption { text-align: center; color: var(--muted); font-size: .9rem; margin-top: 8px; }
.hero .content-image img { margin: 0; }
.site-nav { display: flex; gap: 4px; }
.site-nav a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 500;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.site-nav a.active { color: var(--accent); background: var(--accent-soft); }

.theme-toggle {
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme-toggle .icon-moon { fill: currentColor; stroke: none; }
[data-theme="dark"] .theme-toggle .icon-moon,
:root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: none; }

.nav-toggle {
  display: none;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  order: 3;
}
.nav-toggle span { width: 18px; height: 2px; background: var(--text); border-radius: 2px; }

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .site-nav {
    display: none;
    position: absolute;
    top: 64px; left: 0; right: 0;
    flex-direction: column;
    padding: 12px 20px 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px; }
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-text);
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.1); }
.btn-sm { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ===== Hero ===== */
.hero { padding: 80px 0 64px; }
.hero-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 48px; align-items: center; }
.hero .eyebrow { color: var(--accent); font-weight: 600; margin-bottom: 12px; }
.hero .lead { font-size: 1.2rem; color: var(--muted); max-width: 560px; }
.hero-photo {
  aspect-ratio: 1;
  width: 100%;
  max-width: 340px;
  justify-self: center;
  border-radius: 50%;
  object-fit: cover;
  border: 6px solid var(--surface);
  box-shadow: var(--shadow);
}
.hero-photo.placeholder {
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
  font-size: 5rem; font-weight: 700; color: var(--accent);
}
@media (max-width: 800px) {
  .hero-grid { grid-template-columns: 1fr; text-align: center; }
  .hero .lead { margin-inline: auto; }
  .hero .btn-row { justify-content: center; }
  .hero-photo { max-width: 220px; grid-row: 1; }
}

/* ===== Cards / grids ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body { padding: 24px; }
.grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.section-title h2 { margin: 0; }

.project-card { display: flex; flex-direction: column; overflow: hidden; }
.project-card .thumb { aspect-ratio: 16 / 10; object-fit: cover; width: 100%; background: var(--surface-2); }
.project-card .thumb.empty { display: grid; place-items: center; color: var(--muted); font-size: 2.5rem; }
.project-card .card-body { flex: 1; display: flex; flex-direction: column; }
.project-card p { color: var(--muted); }
.project-card .links { margin-top: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.project-detail { white-space: normal; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tag {
  font-size: .78rem; font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ===== About ===== */
.about-grid { display: grid; grid-template-columns: 320px 1fr; gap: 48px; align-items: start; }
.about-grid img { border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; object-fit: cover; }
.prose { font-size: 1.08rem; }
.prose p { margin-bottom: 1.2em; }
.prose ul { margin: 0 0 1.2em; padding-left: 1.4em; }
.prose li { margin-bottom: .4em; }
@media (max-width: 800px) { .about-grid { grid-template-columns: 1fr; } .about-grid img { max-width: 320px; } }

/* ===== Resume ===== */
.resume-section { margin-bottom: 48px; }
.resume-section > h2 { padding-bottom: 10px; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.timeline { display: grid; gap: 16px; }
.timeline-item { padding: 20px 24px; }
.timeline-item .head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.timeline-item h3 { margin: 0; }
.timeline-item .org { color: var(--accent); font-weight: 600; }
.timeline-item .dates { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.timeline-item .body { margin-top: 10px; color: var(--muted); }
.timeline-item .body p:last-child { margin-bottom: 0; }
.skills-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* ===== Contact / forms ===== */
.contact-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 40px; align-items: start; }
@media (max-width: 800px) { .contact-grid { grid-template-columns: 1fr; } }
.contact-info dt { font-weight: 600; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.contact-info dd { margin: 2px 0 18px; font-size: 1.05rem; }

.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.hint { font-size: .82rem; color: var(--muted); font-weight: 400; margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="number"], input[type="file"], select, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { min-height: 140px; resize: vertical; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }

.empty-state { padding: 48px 24px; text-align: center; color: var(--muted); }

/* ===== Footer ===== */
.site-footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--muted); font-size: .92rem; }
.footer-wrap { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.footer-wrap p { margin: 0; }
.social { display: flex; gap: 18px; }
.social a { color: var(--muted); }
.social a:hover { color: var(--accent); }
