/* ==========================================================================
   main.css — design system for lilyo.github.io
   Replaces Bootstrap 3 + bamos.css. Plain CSS, no build step.
   ========================================================================== */

/* 1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --ink: #0f172a;
  --body: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --card: #ffffff;
  --bg: #f8fafc;
  --code-bg: #f1f5f9;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-lift: 0 2px 4px rgba(15, 23, 42, .08), 0 16px 32px -16px rgba(15, 23, 42, .18);
  --nav-bg: rgba(255, 255, 255, .85);
  --btn-bg: #2563eb;
  --btn-bg-hover: #1d4ed8;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --nav-h: 60px;
}

/* 2. Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
}

h1, h2, h3, h4 {
  color: var(--ink);
  line-height: 1.25;
  margin: 1.4em 0 .5em;
}

h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 800; }
h2 { font-size: 1.45rem; font-weight: 700; }
h3 { font-size: 1.1rem;  font-weight: 600; }
h4 { font-size: 1rem;    font-weight: 600; }

p { margin: .8em 0; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color .15s ease;
}
a:hover { color: var(--primary-dark); text-decoration: underline; }

img, video { max-width: 100%; height: auto; }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2em 0;
}

ul, ol { padding-left: 1.4em; }

blockquote {
  margin: 1em 0;
  padding: .5em 1.2em;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--body);
}

code, kbd {
  font-family: var(--font-mono);
  font-size: .875em;
  background: var(--code-bg);
  border-radius: 5px;
  padding: .15em .4em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.5;
}
pre code { background: none; padding: 0; font-size: .85rem; }

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  font-size: .95rem;
}
th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--ink); font-weight: 600; }

::selection { background: #bfdbfe; color: var(--ink); }

/* Anchor targets clear the sticky nav */
[id] { scroll-margin-top: calc(var(--nav-h) + 20px); }

/* 3. Layout
   -------------------------------------------------------------------------- */
.wrap {
  max-width: 1000px;
  margin-inline: auto;
  padding-inline: 20px;
}

.page-narrow { max-width: 780px; }

main.wrap { padding-top: 8px; padding-bottom: 48px; }

/* 4. Navbar
   -------------------------------------------------------------------------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.site-nav .nav-inner {
  max-width: 1000px;
  margin-inline: auto;
  padding-inline: 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 22px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.nav-brand:hover { text-decoration: none; color: var(--primary); }
.nav-brand img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
}
.nav-links a {
  color: var(--body);
  font-weight: 500;
  padding: 6px 2px;
}
.nav-links a:hover { color: var(--primary); text-decoration: none; }
.nav-links .nav-icon a { font-size: 1.2rem; color: var(--muted); }
.nav-links .nav-icon a:hover { color: var(--primary); }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
}

@media (max-width: 640px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 8px 20px 14px;
  }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: 10px 2px; }
  .site-nav.open .nav-links { display: flex; }
}

/* 5. Hero
   -------------------------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 36px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 44px;
  margin: 32px 0 8px;
}

.hero h1 { margin: 0 0 6px; }

.hero .hero-role {
  font-size: 1.15rem;
  color: var(--body);
  margin: 0 0 2px;
}
.hero .hero-role strong { color: var(--ink); }

.hero .hero-mail {
  color: var(--muted);
  margin: 0 0 18px;
}
.hero .hero-mail a { color: var(--muted); }
.hero .hero-mail a:hover { color: var(--primary); }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.btn-cv {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--btn-bg);
  color: #fff;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.btn-cv:hover {
  background: var(--btn-bg-hover);
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow-lift);
  transform: translateY(-1px);
}

.icon-links {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.icon-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.25rem;
  color: var(--muted);
  border: 1px solid var(--line);
  transition: all .15s ease;
}
.icon-links a:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-soft);
  text-decoration: none;
}

.hero-photo img {
  width: 230px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  display: block;
}

.tagline {
  color: var(--primary);
  font-size: 1.3rem;
  font-weight: 700;
  margin: 26px 4px 10px;
}

.intro {
  margin: 0 4px 6px;
  font-size: 1.02rem;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 32px 24px;
  }
  .hero-photo { order: -1; }
  .hero-photo img { margin-inline: auto; width: 180px; }
  .hero-actions { justify-content: center; }
  .tagline, .intro { text-align: center; }
}

/* 6. CV sections (cards)
   -------------------------------------------------------------------------- */
.cv-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  margin: 26px 0;
  transition: box-shadow .15s ease;
}
.cv-section:hover { box-shadow: var(--shadow-lift); }

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
  font-size: 1.3rem;
}
.section-title .fa {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 9px;
  font-size: .95rem;
  flex: none;
}

.date-badge {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 600;
  font-size: .82rem;
  line-height: 1.4;
  padding: 3px 12px;
  border-radius: 999px;
  white-space: nowrap;
  flex: none;
}

/* 7. Spotlight news
   -------------------------------------------------------------------------- */
.news-item {
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
}
.news-item:last-child { border-bottom: 0; padding-bottom: 4px; }
.news-item:first-of-type { padding-top: 4px; }

.news-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}
.news-title { color: var(--ink); font-weight: 600; }

.news-media { max-width: 640px; }
.news-media img {
  border-radius: 10px;
  display: block;
  max-height: 520px;
  width: auto;
  max-width: 100%;
}

/* 8. Disclosure (<details>)
   -------------------------------------------------------------------------- */
details.disclosure { margin-top: 6px; }

details.disclosure > summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  font-size: .9rem;
  list-style: none;
  -webkit-user-select: none;
  user-select: none;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before {
  content: "\f105"; /* fa-angle-right */
  font-family: FontAwesome;
  transition: transform .15s ease;
}
details.disclosure[open] > summary::before { transform: rotate(90deg); }
details.disclosure > summary:hover { text-decoration: underline; }

.disclosure-body {
  margin-top: 10px;
  padding: 4px 2px 2px;
  font-size: .95rem;
}

/* 9. Experience timeline
   -------------------------------------------------------------------------- */
.timeline {
  position: relative;
  padding-left: 26px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--line);
}

.xp-item {
  position: relative;
  padding-bottom: 26px;
}
.xp-item:last-child { padding-bottom: 4px; }
.xp-item::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2.5px solid var(--card);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.xp-company {
  margin: 0 0 8px;
  font-size: 1.08rem;
}
.xp-loc {
  color: var(--muted);
  font-weight: 500;
  font-size: .88rem;
}
.xp-loc::before { content: "· "; }

.xp-role {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 2px 0;
}
.xp-title { font-weight: 600; color: var(--ink); }

.xp-detail { margin-top: 8px; font-size: .95rem; }
.xp-detail-label {
  display: block;
  font-weight: 600;
  color: var(--muted);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 2px;
}
.xp-detail ul { margin: 4px 0; }
.xp-detail li { margin: 2px 0; }

/* 10. Education / honors / patents / talks rows
   -------------------------------------------------------------------------- */
.row-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 18px;
  flex-wrap: wrap;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line);
}
.row-item:last-child { border-bottom: 0; padding-bottom: 4px; }
.row-item:first-of-type { padding-top: 4px; }

.row-main { flex: 1 1 420px; min-width: 0; }
.row-main h3 { margin: 0 0 2px; font-size: 1.02rem; }

.row-sub { color: var(--muted); font-size: .93rem; margin: 0; }
.row-cite { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }

.chip-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 2px 12px;
  border-radius: 999px;
  margin: 6px 8px 0 0;
  transition: all .15s ease;
}
.chip-link:hover {
  background: var(--btn-bg);
  color: #fff;
  text-decoration: none;
}

/* 11. Publications / projects cards
   -------------------------------------------------------------------------- */
.pub-timeline {
  position: relative;
  padding-left: 26px;
}
.pub-timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--line);
}

.tl-group {
  position: relative;
  padding-bottom: 8px;
}
.tl-group:last-child { padding-bottom: 0; }
.tl-group::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2.5px solid var(--card);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.tl-group .row-main + .row-main { margin-top: 16px; }

.tl-year {
  display: inline-block;
  margin: 0 0 12px;
  font-size: .9rem;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 2px 14px;
  border-radius: 999px;
}

.pub-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  margin-bottom: 14px;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.pub-card:hover { box-shadow: var(--shadow); border-color: #cbd5e1; }

.pub-thumb {
  align-self: start;
  display: block;
}
.pub-thumb img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  display: block;
}

.pub-body { min-width: 0; }
.pub-title {
  display: block;
  font-weight: 600;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.4;
}
.pub-title:hover { color: var(--primary); }

.pub-authors { margin: 6px 0 0; font-size: .92rem; }
.pub-venue { margin: 2px 0 0; color: var(--muted); font-size: .88rem; }
.pub-links { margin-top: 8px; }
.pub-links details.disclosure { margin: 2px 0 6px; }

@media (max-width: 900px) {
  .pub-card { grid-template-columns: 1fr; }
  .pub-thumb { max-width: 380px; }
}

/* 12. Skills
   -------------------------------------------------------------------------- */
.skill-row {
  display: flex;
  align-items: baseline;
  gap: 10px 18px;
  flex-wrap: wrap;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
}
.skill-row:last-child { border-bottom: 0; }
.skill-label {
  flex: 0 0 210px;
  font-weight: 600;
  color: var(--ink);
  font-size: .95rem;
}
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}
.chip {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--body);
  font-size: .85rem;
  font-weight: 500;
  padding: 3px 13px;
  border-radius: 999px;
  transition: all .15s ease;
}
.chip:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-soft);
}

@media (max-width: 640px) {
  .skill-label { flex-basis: 100%; }
}

/* 13. Video embeds
   -------------------------------------------------------------------------- */
.video-embed {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 16 / 9;
  margin: 10px 0;
}
.video-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 10px;
}

/* 14. Blog list + posts
   -------------------------------------------------------------------------- */
.post-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.post-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 18px;
  flex-wrap: wrap;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
}
.post-list li:last-child { border-bottom: 0; }
.post-list-title { font-weight: 600; font-size: 1.02rem; }

.post-title { margin-top: .6em; }
.post-date { color: var(--muted); margin: 2px 0 22px; }

.post img { border-radius: var(--radius-sm); }

#toc:not(:empty) {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 18px 14px 34px;
  margin: 18px 0;
  font-size: .93rem;
}
#toc .toc-h3 { padding-left: 1.6em; list-style: none; }

.image-wrapper { text-align: center; margin: 18px 0; }
.image-wrapper img { border-radius: var(--radius-sm); }
.image-caption {
  color: var(--muted);
  font-size: .85rem;
  font-style: italic;
  margin-top: 6px;
}

.comments {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* 15. Footer / misc
   -------------------------------------------------------------------------- */
.updated {
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  margin: 34px 0 8px;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--card);
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: .87rem;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--primary); }

@media (max-width: 640px) {
  .cv-section { padding: 20px 18px; }
  .hero { padding: 26px 18px; }
}

/* 16. Dark mode (follows system preference)
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  html { color-scheme: dark; }

  :root {
    --primary: #60a5fa;
    --primary-dark: #93c5fd;
    --primary-soft: rgba(96, 165, 250, .14);
    --ink: #f1f5f9;
    --body: #cbd5e1;
    --muted: #94a3b8;
    --line: #2a3648;
    --card: #151f2e;
    --bg: #0b1220;
    --code-bg: #1a2434;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -12px rgba(0, 0, 0, .5);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .4), 0 16px 32px -16px rgba(0, 0, 0, .6);
    --nav-bg: rgba(11, 18, 32, .85);
  }

  ::selection { background: #1d4ed8; color: #f1f5f9; }

  /* Dim bright figures slightly so they sit well on dark cards */
  .post img,
  .image-wrapper img,
  .news-media img,
  .pub-thumb img { filter: brightness(.88); }
  .hero-photo img,
  .nav-brand img { filter: none; }

  /* Pygments (default.css is light-only) — recolor common tokens */
  .highlight, pre { background: var(--code-bg); }
  .highlight .c, .highlight .c1, .highlight .cm, .highlight .cp { color: #8b98ab; font-style: italic; }
  .highlight .k, .highlight .kn, .highlight .kd, .highlight .kc { color: #93c5fd; }
  .highlight .s, .highlight .s1, .highlight .s2, .highlight .sd { color: #86efac; }
  .highlight .m, .highlight .mi, .highlight .mf { color: #fbbf24; }
  .highlight .nb, .highlight .nf, .highlight .nc, .highlight .nd { color: #c4b5fd; }
  .highlight .o, .highlight .ow { color: #cbd5e1; }
  .highlight .n, .highlight .p, .highlight .nn { color: #e2e8f0; }
  .highlight .err { color: #fca5a5; }
}
