/* =====================================================================
   THEME — change colors, fonts, and sizing here.
   Light mode is the first block; dark mode overrides are below it.
   ===================================================================== */
:root {
  --accent: #0f9d8a;          /* main highlight color (buttons, links) */
  --accent-strong: #0b7c6d;
  --accent-soft: rgba(15, 157, 138, 0.12);

  --bg: #f7f8fa;              /* page background */
  --surface: #ffffff;         /* cards */
  --text: #16191f;
  --muted: #5b6472;
  --border: #e3e6eb;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);

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

  --radius: 14px;
  --max-width: 1100px;
  --header-h: 64px;
}

/* Dark mode: follows the visitor's system setting unless they click the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-soft: rgba(45, 212, 191, 0.12);
    --bg: #0d1117;
    --surface: #151b23;
    --text: #e6e9ef;
    --muted: #9aa4b2;
    --border: #262e3a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}
:root[data-theme="dark"] {
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --bg: #0d1117;
  --surface: #151b23;
  --text: #e6e9ef;
  --muted: #9aa4b2;
  --border: #262e3a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* =====================================================================
   BASE
   ===================================================================== */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s, color 0.2s;
}

img { max-width: 100%; display: block; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
code { font-family: var(--font-mono); font-size: 0.85em; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 16px; z-index: 100; background: var(--surface); padding: 8px 12px; }

.accent { color: var(--accent); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0 0 10px;
}
.meta { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); margin: 0; }
.subtitle { color: var(--muted); margin: 4px 0 0; font-size: 0.95rem; }
.label { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin: 18px 0 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.chip {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid transparent;
}
.tags { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }

.bullets { margin: 12px 0 0; padding-left: 20px; }
.bullets li { margin-bottom: 6px; color: var(--text); }
.bullets li::marker { color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
  transition: transform 0.15s, background-color 0.15s, border-color 0.15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: #04201c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #04201c; } }
.btn-primary:hover { background: var(--accent-strong); }
.btn-small { padding: 6px 12px; font-size: 0.85rem; }

/* =====================================================================
   HEADER / NAV
   ===================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; height: 100%; gap: 16px; }
.nav-brand { font-weight: 700; color: var(--text); margin-right: auto; }
.nav-brand:hover { text-decoration: none; color: var(--accent); }
.nav-links { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; }
.nav-links a {
  display: block;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}
.nav-links a:hover { color: var(--text); background: var(--accent-soft); text-decoration: none; }
.nav-links a.is-active { color: var(--accent-strong); background: var(--accent-soft); }

.theme-toggle,
.nav-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text);
}
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

.nav-toggle { display: none; gap: 4px; align-content: center; }
.nav-toggle span { display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; }

@media (max-width: 760px) {
  .nav-toggle { display: grid; order: 3; }
  .nav-links {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    padding: 12px 16px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: none;
  }
  .nav-links.is-open { display: flex; }
  .nav-links a { padding: 10px 12px; }
}

/* =====================================================================
   HERO
   ===================================================================== */
.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 48px;
  align-items: center;
  padding-top: 88px;
  padding-bottom: 72px;
}
.hero h1 { font-size: clamp(2.4rem, 5vw, 3.6rem); font-weight: 700; }
.hero-tagline { font-size: 1.15rem; color: var(--muted); max-width: 34em; margin: 18px 0 28px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.social { list-style: none; display: flex; gap: 10px; padding: 0; margin: 28px 0 0; }
.social a {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
}
.social a:hover { color: var(--accent); border-color: var(--accent); }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.hero-photo { justify-self: center; width: 100%; max-width: 340px; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding-top: 48px; gap: 32px; }
  .hero-photo { order: -1; max-width: 200px; justify-self: start; }
}

/* =====================================================================
   IMAGES & PLACEHOLDERS
   ===================================================================== */
.img-frame { position: relative; overflow: hidden; background: var(--accent-soft); }
.img-frame img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.img-frame.is-placeholder {
  display: grid;
  place-items: center;
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  background:
    repeating-linear-gradient(45deg, transparent 0 12px, var(--accent-soft) 12px 24px),
    var(--surface);
}
.placeholder-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 12px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}
.placeholder-label svg { width: 28px; height: 28px; fill: none; stroke: var(--accent); stroke-width: 1.6; }
.placeholder-label code { word-break: break-all; color: var(--text); }

.avatar { aspect-ratio: 1; border-radius: 50%; box-shadow: var(--shadow); border: 4px solid var(--surface); }
.avatar.is-placeholder { border-style: dashed; border-width: 2px; }

.logo { width: 48px; height: 48px; border-radius: 10px; flex: none; }
.logo .placeholder-label { padding: 0; }
.logo .placeholder-label span { display: none; } /* too small for text — icon only */
.logo .placeholder-label svg { width: 20px; height: 20px; }

/* =====================================================================
   SECTIONS
   ===================================================================== */
.section { padding: 72px 0; }
.section-head { margin-bottom: 32px; }
.section-head h2 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); }

/* Reveal-on-scroll animation */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* About */
.about-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 40px; align-items: start; }
.about-text p { margin: 0 0 16px; }
.stats { display: grid; gap: 12px; }
.stat { padding: 18px 20px; display: flex; flex-direction: column; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--accent); line-height: 1.1; }
.stat-label { font-size: 0.88rem; color: var(--muted); }
@media (max-width: 760px) {
  .about-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat { padding: 14px; }
  .stat-value { font-size: 1.4rem; }
}

/* Projects */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.filter {
  cursor: pointer;
  font-family: inherit;
  background: var(--surface);
  color: var(--muted);
  border-color: var(--border);
}
.filter:hover { border-color: var(--accent); color: var(--text); }
.filter.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

.project-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.project { display: flex; flex-direction: column; overflow: hidden; transition: transform 0.2s, border-color 0.2s; }
.project:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.project-img { aspect-ratio: 16 / 9; border-radius: 0; border-width: 0 0 1px; }
.project-img.is-placeholder { border: 0; border-bottom: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); }
.project-body { padding: 22px 24px 24px; display: flex; flex-direction: column; flex: 1; }
.project-body h3 { font-size: 1.3rem; margin-top: 6px; }
.summary { margin: 12px 0 0; }

.more { margin-top: 16px; }
.more summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent-strong);
  list-style: none;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: "+ "; font-family: var(--font-mono); }
.more[open] summary::before { content: "− "; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.gallery .img-frame { aspect-ratio: 4 / 3; border-radius: 10px; }

.project-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 18px; }

@media (min-width: 900px) {
  /* Featured projects span the full width with the image on the side. */
  .project.is-featured { grid-column: 1 / -1; flex-direction: row; }
  .project.is-featured .project-img { width: 48%; aspect-ratio: auto; min-height: 300px; border-width: 0 1px 0 0; }
  .project.is-featured .project-img.is-placeholder { border-bottom: 0; border-right: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); }
  .project.is-featured .project-body { padding: 28px 32px; }
}
@media (max-width: 760px) {
  .project-grid { grid-template-columns: 1fr; }
}

/* Experience timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 28px; position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -27px;
  top: 26px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--accent);
}
.timeline-item .card, .edu { padding: 22px 24px; }
.exp-head { display: flex; gap: 14px; align-items: flex-start; }
.exp-head > div:not(.img-frame) { flex: 1; min-width: 0; }
.exp-head h3 { font-size: 1.1rem; }
.date { text-align: right; white-space: nowrap; padding-top: 3px; }
@media (max-width: 600px) {
  .exp-head { flex-wrap: wrap; }
  .date { flex-basis: 100%; text-align: left; order: -1; }
}

/* Skills */
.skills-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.skill-group { padding: 20px 22px; }
.skill-group h3 { font-size: 1rem; }

/* Contact */
.contact-card { padding: 36px; text-align: center; }
.contact-heading { font-size: 1.6rem; margin-bottom: 8px; }
.contact-card > p { color: var(--muted); max-width: 36em; margin: 0 auto; }
.contact-links { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.contact-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-align: left;
  font-size: 0.92rem;
  max-width: 100%;
}
.contact-link span { min-width: 0; overflow-wrap: anywhere; }
.contact-link small { display: block; color: var(--muted); font-size: 0.75rem; }
.contact-link .icon { color: var(--accent); }
.contact-link:hover { border-color: var(--accent); text-decoration: none; }

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

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.85);
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox img { max-height: 90vh; border-radius: 8px; }
.lightbox-close { position: absolute; top: 16px; right: 20px; background: none; border: 0; color: #fff; font-size: 2rem; cursor: pointer; }

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .section { padding: 56px 0; }
  .contact-card { padding: 24px 16px; }
}

/* =====================================================================
   VIDEO + GALLERY SECTION
   ===================================================================== */
.img-frame.video video,
.img-frame.video iframe { display: block; width: 100%; height: 100%; border: 0; background: #000; }
.img-frame.video:not(.project-img) iframe { aspect-ratio: 16 / 9; height: auto; }
.img-frame.video:not(.project-img) video { height: auto; max-height: 80vh; }
.project-img.video video { object-fit: contain; }

.section-intro { color: var(--muted); max-width: 40em; margin: -12px 0 28px; }
.gallery-group + .gallery-group { margin-top: 40px; }
.gallery-group > h3 { font-size: 1.2rem; }
.gallery-group > .subtitle { margin-bottom: 0; }

/* Masonry: photos keep their natural shape (portrait or landscape). */
.masonry { columns: 3 260px; column-gap: 16px; margin-top: 16px; }
.gallery-item { break-inside: avoid; margin: 0 0 16px; overflow: hidden; }
.gallery-item .img-frame img { height: auto; }
.gallery-item .img-frame.is-placeholder { min-height: 180px; }
.gallery-item figcaption { padding: 10px 14px 12px; font-size: 0.88rem; color: var(--muted); }

/* Side Projects: smaller cards, three across, no featured layout. */
.project-grid.compact { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.project-grid.compact .project-img { aspect-ratio: 4 / 3; }
.project-grid.compact .project-body { padding: 18px 20px 20px; }
.project-grid.compact .project-body h3 { font-size: 1.1rem; }

/* Videos inside a project's "More details" keep their own shape (often portrait). */
.gallery { align-items: start; }
.gallery .img-frame.video { aspect-ratio: auto; }
.gallery .img-frame.video video { height: auto; max-height: 360px; }

/* A portrait video as a featured project's main media: fill the side panel
   without stretching the card, letterboxed on black. */
.project.is-featured .project-img.video { position: relative; }
@media (min-width: 900px) {
  .project.is-featured .project-img.video video { position: absolute; inset: 0; }
}
.gallery .img-frame.video video { max-height: 240px; }

/* Space between stacked education cards. */
.edu + .edu { margin-top: 16px; }
