/* ─── Design Tokens ─────────────────────────────────────────────────── */
:root {
  --bg:        #fbfbf8;
  --bg-offset: #f5f4ef;
  --text:      #181715;
  --muted:     #666258;
  --border:    #ded9ce;
  --hover-bg:  #f1eee6;
  --link:      #1d4f7a;
  --accent:    #1d4f7a;
  --accent-bg: rgba(29, 79, 122, 0.12);
  --sidebar-w: 188px;
  --font:      'Inter', system-ui, -apple-system, sans-serif;
  --mono:      'Geist Mono', 'Fira Code', ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg:        #171614;
  --bg-offset: #1f1d1a;
  --text:      #eeebe3;
  --muted:     #b4ada0;
  --border:    #322f2a;
  --hover-bg:  #26231f;
  --link:      #d8c7a3;
  --accent:    #d8c7a3;
  --accent-bg: rgba(216, 199, 163, 0.16);
}

/* ─── Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
img  { max-width: 100%; display: block; }

/* ─── Rainbow bar (full-width, fixed at very top) ─────────────────────── */
#rainbow-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(to right, #ff0018, #ffa52c, #ffff41, #008018, #0000f9, #86007d);
  z-index: 100;
  pointer-events: none;
}
[data-theme="dark"] #rainbow-bar {
  background: linear-gradient(to right, #7c3aed, #a78bfa, #818cf8, #6366f1, #4f46e5);
  opacity: 0.7;
}

body {
  min-height: 100vh;
  font-family: var(--font);
  line-height: 1.7;
  background: var(--bg);
  color: var(--text);
  transition: background 0.25s ease, color 0.25s ease;
  display: block;
  padding-top: 3px;
}

/* ─── Centered layout wrapper ─────────────────────────────────────── */
.layout-wrap {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  min-height: calc(100vh - 3px);
  padding: 0 2.5rem;
  gap: 3.5rem;
  justify-content: center;
}

/* ─── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 3px;
  height: calc(100vh - 3px);
  display: flex;
  flex-direction: column;
  padding: 8.75rem 0 2rem;
  z-index: 20;
  background: var(--bg);
  transition: background 0.25s ease;
}

/* Nav card — liyuxuan style bordered box */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.35rem;
  overflow: hidden;
  background: color-mix(in srgb, var(--bg) 86%, var(--bg-offset) 14%);
}

.sidebar-nav a {
  font-size: 0.86rem;
  color: var(--muted);
  text-decoration: none;
  padding: 0.72rem 0.85rem;
  border-radius: 7px;
  transition: color 0.15s, background 0.15s, transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  line-height: 1;
}
.sidebar-nav a:hover {
  color: var(--text);
  background: var(--hover-bg);
  transform: translateX(3px);
}
.sidebar-nav a.active {
  color: var(--text);
  font-weight: 500;
  background: var(--hover-bg);
  transform: none;
}
[data-theme="dark"] .sidebar-nav a.active {
  background: #2a2a35;
  color: #ffffff;
}

/* ─── Theme toggle — fixed top-right ────────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1.75rem;
  z-index: 50;
}

.toggle-track {
  display: inline-flex;
  align-items: center;
  background: var(--bg-offset);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  user-select: none;
}

.toggle-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 22px;
  border-radius: 999px;
  font-size: 0.78rem;
  transition: background 0.2s, box-shadow 0.2s;
  cursor: pointer;
}
.toggle-opt.selected {
  background: var(--bg);
}
[data-theme="dark"] .toggle-opt.selected {
  background: #2a2a35;
}

/* ─── Main content ───────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
}

/* ─── Page ───────────────────────────────────────────────────────────── */
.page {
  max-width: 640px;
  padding: 6.4rem 0 6.25rem;
}


/* ─── Typography ─────────────────────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; }
h2 { font-size: 1rem;   font-weight: 500; letter-spacing: -0.01em; }

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--border);
  text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent);
  transition: color 0.15s, opacity 0.15s, text-decoration-color 0.15s;
}
a:hover { text-decoration-color: transparent; opacity: 0.65; }

/* ─── Hero ───────────────────────────────────────────────────────────── */
.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4.4rem;
  gap: 2.25rem;
}
.hero-copy { flex: 1; }

.hero-name {
  font-size: 1.82rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
  letter-spacing: -0.03em;
  color: var(--text);
}
.hero-job {
  font-size: 0.86rem;
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 1.05rem;
  line-height: 1.75;
  max-width: 38rem;
}
.lead {
  font-size: 0.86rem;
  color: color-mix(in srgb, var(--text) 82%, var(--muted) 18%);
  line-height: 1.9;
  max-width: 36rem;
}
.hero-links {
  display: flex;
  gap: 1.15rem;
  margin-top: 1.35rem;
  flex-wrap: wrap;
  font-size: 0.86rem;
}
.hero-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
  position: relative;
  display: inline-block;
}
.hero-links a::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: -2px;
  left: 0;
  background-color: var(--hover-color, var(--text));
  transform: scaleX(0);
  transform-origin: bottom right;
  transition: transform 0.25s ease-out;
}
.hero-links a:hover { color: var(--text); opacity: 1; }
.hero-links a:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

.link-email { --hover-color: #ff0018; }
.link-linkedin { --hover-color: #0000f9; }
.link-medium { --hover-color: #008018; }

[data-theme="dark"] .link-email { --hover-color: #a78bfa; }
[data-theme="dark"] .link-linkedin { --hover-color: #818cf8; }
[data-theme="dark"] .link-medium { --hover-color: #6366f1; }

/* ─── Profile Avatar ─────────────────────────────────────────────────── */
.hero-avatar {
  flex-shrink: 0;
}

.profile-container {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.profile-pic {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}



/* ─── Sections ───────────────────────────────────────────────────────── */
.section { margin-bottom: 4.5rem; }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
}
.section > .section-title {
  display: inline-block;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
}
.section-title {
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.see-all {
  font-size: 0.78rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}
.see-all:hover { color: var(--text); opacity: 1; }

.section p {
  font-size: 0.86rem;
  color: color-mix(in srgb, var(--text) 79%, var(--muted) 21%);
  line-height: 1.92;
  margin-bottom: 1.2rem;
}
.section p:last-child { margin-bottom: 0; }

strong {
  color: var(--text);
  font-weight: 600;
  position: relative;
  white-space: nowrap;
  z-index: 1;
  padding: 0 0.1em;
}
strong::before {
  content: "";
  position: absolute;
  left: -0.15em;
  right: -0.15em;
  bottom: 0.1em;
  height: 0.45em;
  z-index: -1;
  background: var(--hl-color, #ff0018);
  opacity: 0.35;
  /* Magic CSS trick for organic marker scribble shapes */
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  transform: rotate(-1deg);
}

.hl-red { --hl-color: #ff0018; }
.hl-orange { --hl-color: #ffa52c; }
.hl-yellow { --hl-color: #eab308; } /* Darkened yellow for contrast */
.hl-green { --hl-color: #008018; }
.hl-blue { --hl-color: #0000f9; }
.hl-purple { --hl-color: #86007d; }

[data-theme="dark"] strong::before {
  opacity: 0.5;
}

/* Reusing the purple/indigo hues for the dark theme */
[data-theme="dark"] .hl-red { --hl-color: #a78bfa; }
[data-theme="dark"] .hl-orange { --hl-color: #818cf8; }
[data-theme="dark"] .hl-yellow { --hl-color: #6366f1; }
[data-theme="dark"] .hl-green { --hl-color: #7c3aed; }
[data-theme="dark"] .hl-blue { --hl-color: #4f46e5; }
[data-theme="dark"] .hl-purple { --hl-color: #a78bfa; }

/* ─── Skills grid ────────────────────────────────────────────────────── */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1.5rem 2rem;
  margin-top: 1rem;
}
.skill-group {
  padding: 0;
}
.skill-group h3 { 
  font-size: 0.75rem; 
  font-weight: 600; 
  text-transform: uppercase; 
  letter-spacing: 0.06em; 
  color: var(--text); 
  margin-bottom: 0.8rem; 
}
.skill-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.skill-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: color-mix(in srgb, var(--text) 79%, var(--muted) 21%);
}
.skill-list img, .skill-list svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}
.skill-list li:hover img, .skill-list li:hover svg {
  transform: scale(1.1);
}
.skill-concepts {
  margin-top: 1.25rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.6;
}
.skill-concepts strong {
  color: var(--text);
  font-weight: 500;
  display: inline-block;
  margin-bottom: 0.25rem;
}
.skill-concepts strong::before {
  display: none; /* Hide the marker highlight for these small labels */
}

/* ─── List (blog posts) ──────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; }

.list-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  text-decoration: none;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  flex-wrap: wrap;
}
.list-item:hover { 
  opacity: 0.9;
  transform: translateX(3px);
}
.list-item:hover .item-title {
  color: var(--link);
}

.item-main {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  width: 100%;
  gap: 1.5rem;
}
.item-title  { font-size: 0.95rem; font-weight: 500; color: var(--text); flex: 1; transition: color 0.2s ease; }
.item-date   { font-size: 0.85rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* ─── Projects Minimal List ────────────────────────────────────────────── */
.project-list-group {
  display: flex;
  flex-direction: column;
  margin-top: 1rem;
}

.project-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.6rem 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: opacity 0.3s ease;
}
.project-row:last-child {
  border-bottom: none;
}

.project-row-left {
  flex: 1;
  max-width: 75%;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.project-row-title {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
  transition: color 0.3s ease;
}

.project-row-desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.project-row-tools {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.65;
}

.project-row-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.project-arrow {
  font-size: 1.15rem;
  color: var(--muted);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.3s ease;
}

/* Hover effects */
.project-list-group:hover .project-row { opacity: 0.35; }
.project-list-group .project-row:hover { opacity: 1; }

.project-row:hover .project-row-left { transform: translateX(8px); }
.project-row:hover .project-row-title { color: var(--link); }
.project-row:hover .project-arrow {
  color: var(--text);
  transform: translate(3px, -3px);
}


/* ─── Tags ───────────────────────────────────────────────────────────── */
.tag-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.5rem; }
.tag-btn {
  appearance: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.73rem;
  padding: 2px 10px;
  transition: color 0.15s, border-color 0.15s;
}
.tag-btn:hover, .tag-btn.active { color: var(--text); border-color: var(--muted); }

.post-tags { display: flex; gap: 0.35rem; margin-top: 0.2rem; flex-wrap: wrap; }
.tag { font-size: 0.7rem; color: var(--muted); padding: 1px 7px; border: 1px solid var(--border); border-radius: 4px; }

/* ─── Page title ─────────────────────────────────────────────────────── */
.page-title    { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.3rem; letter-spacing: -0.02em; }
.page-desc     { font-size: 0.92rem; color: var(--muted); margin-bottom: 2rem; line-height: 1.75; max-width: 34rem; }

/* ─── Blog post ──────────────────────────────────────────────────────── */
.post-header   { margin-bottom: 2.2rem; padding-bottom: 0.8rem; border-bottom: 1px solid var(--border); }
.post-header h1{ margin-bottom: 0.2rem; font-size: 1.75rem; font-weight: 500; letter-spacing: -0.03em; line-height: 1.25; }
.post-meta     { font-size: 0.78rem; color: var(--muted); }

.post-body     { font-size: 1rem; line-height: 1.85; color: var(--text); }
.post-body p   { margin-bottom: 1.45rem; color: var(--text); }
.post-body h1  { font-size: 1.6rem; margin: 0 0 1rem; line-height: 1.35; letter-spacing: -0.01em; }
.post-body h1  { font-weight: 550; }
.post-body h2  { margin: 2.6rem 0 1rem; font-size: 1.14rem; line-height: 1.42; letter-spacing: -0.01em; font-weight: 520; }
.post-body h3  { margin: 1.8rem 0 0.7rem; font-size: 0.98rem; line-height: 1.5; font-weight: 500; }
.post-body ul, .post-body ol { padding-left: 1.5rem; margin-bottom: 1.25rem; }
.post-body li  { margin-bottom: 0.45rem; }

.post-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--hover-bg);
  padding: 0.2em 0.45em;
  border-radius: 4px;
}
.post-body pre {
  position: relative;
  background: #181715;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.75rem 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #eeebe3;
}
[data-theme="dark"] .post-body pre {
  background: #11100e;
  border-color: #322f2a;
}
.post-body pre code { background: none; border: none; padding: 0; color: inherit; }

.post-image    { margin: 1.75rem 0; }
.post-image figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.825rem;
  color: var(--muted);
  margin-bottom: 2rem;
  text-decoration: none;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text); opacity: 1; }

/* ─── Footer ─────────────────────────────────────────────────────────── */
.site-footer { padding: 1.5rem 2rem 2.5rem; }

/* ─── Copy button ────────────────────────────────────────────────────── */
.copy-btn {
  position: absolute;
  top: 0.5rem; right: 0.5rem;
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.7rem;
  padding: 2px 8px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); }

/* ─── Scroll progress ────────────────────────────────────────────────── */
#progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px; width: 0;
  background: var(--link);
  opacity: 0.4;
  z-index: 999;
  transition: width 0.1s linear;
  pointer-events: none;
}

/* ─── Back to top ────────────────────────────────────────────────────── */
#back-top {
  position: fixed;
  bottom: 1.25rem; right: 1.25rem;
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, color 0.15s;
}
#back-top.visible { opacity: 1; pointer-events: auto; }
#back-top:hover   { color: var(--text); }

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .layout-wrap {
    flex-direction: column;
    padding: 0;
    gap: 0;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 0.85rem 1.25rem;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    top: auto;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.1rem;
    flex: 1;
    border: none;
    padding: 0;
  }
  .sidebar-nav a { padding: 0.25rem 0.5rem; font-size: 0.82rem; }

  .main-content { padding-left: 0; }
  .page { padding: 2.8rem 1.25rem 4.25rem; }

  .hero { flex-direction: column-reverse; gap: 1.25rem; }
  .projects-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
