/* ==========================================================
   Reset & base
   ========================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, p, ul, ol, li, figure, blockquote, pre { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

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

:root {
  --bg: #0B0E14;
  --text: #ECE9E1;
  --text-dim: #8B93A3;
  --border: rgba(236, 233, 225, 0.12);
  --accent: #C9A24B;
  --grid-dot: rgba(236, 233, 225, 0.05);

  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --sidebar-w: 260px;
  --topbar-h: 0px;
  --edge: clamp(32px, 6vw, 96px);
}

html[data-theme="light"] {
  --bg: #F1F3F4;
  --text: #14181F;
  --text-dim: #5B6472;
  --border: rgba(20, 24, 31, 0.14);
  --accent: #8A6A1E;
  --grid-dot: rgba(20, 24, 31, 0.06);
}

body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 28px 28px;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3 { font-weight: 600; line-height: 1.15; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg);
  color: var(--text);
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border);
  z-index: 100;
}
.skip-link:focus { left: 1rem; top: 1rem; }

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ==========================================================
   Sidebar navigation (left-aligned, fixed)
   ========================================================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 2.25rem 1.75rem;
  border-right: 1px solid var(--border);
  z-index: 10;
}

.mark {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  width: fit-content;
  align-self: center;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0.25rem 0.5rem 0.9rem;
  border-left: 2px solid transparent;
  color: var(--text-dim);
  transition: color 0.25s ease, border-color 0.25s ease;
}
.nav-link:hover { color: var(--text); }
.nav-link.active {
  color: var(--text);
  border-left-color: var(--accent);
}
.nav-index {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  color: var(--text-dim);
}
.nav-link.active .nav-index { color: var(--accent); }
.nav-label { font-size: 0.95rem; }

/* ==========================================================
   Theme toggle (top right, small)
   ========================================================== */
.theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background-color: var(--bg);
  z-index: 20;
  transition: border-color 0.25s ease, transform 0.2s ease, background-color 0.3s ease;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle .icon { width: 18px; height: 18px; }
.icon-moon { display: none; }
html[data-theme="light"] .icon-sun { display: none; }
html[data-theme="light"] .icon-moon { display: block; }

/* ==========================================================
   Layout / scrollable content
   No scroll-snap anywhere — sections grow with their content
   and scrolling stays free, only smoothed via html{scroll-behavior}.
   ========================================================== */
.content {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  position: relative;
  z-index: 1;
}

.page {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: clamp(32px, 2vw, 0px) var(--edge);
  scroll-margin-top: var(--topbar-h);
}

.page + .page { border-top: 1px solid var(--border); }

.page-inner, .section-intro, .hero, .project-list, .blog-list, .contact-row, .social-list {
  max-width: 900px;
}

/* ==========================================================
   Home / hero
   ========================================================== */
.hero-name {
  font-size: clamp(2.75rem, 4vw + 1.5rem, 4.75rem);
  margin-bottom: 0.75rem;
}
.hero-role {
  font-size: clamp(1.1rem, 1vw + 0.9rem, 1.35rem);
  color: var(--text-dim);
  margin-bottom: 1.75rem;
}
.hero-intro {
  font-size: 1.05rem;
  max-width: 60ch;
  margin-bottom: 2rem;
}
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 3rem;
}
.tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
}
.tag-row.small { margin-bottom: 0; }
.tag-row.small .tag { font-size: 0.7rem; padding: 0.25rem 0.65rem; }

/* Single orchestrated entrance moment for the hero only */
.hero-name, .hero-role, .hero-intro, .tag-row {
  animation: rise 0.7s ease-out both;
}
.hero-role { animation-delay: 0.08s; }
.hero-intro { animation-delay: 0.16s; }
.tag-row { animation-delay: 0.24s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   Section head (About / Projects / Blog / Contact)
   ========================================================== */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  margin-bottom: 1rem;
}
.section-index {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  letter-spacing: 0.03em;
}
.section-head h2 { font-size: clamp(1.9rem, 2vw + 1.2rem, 2.5rem); }
.section-intro {
  color: var(--text-dim);
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

/* ==========================================================
   About
   ========================================================== */
.page-about .page-inner p { margin-bottom: 1.35rem; font-size: 1.05rem; }
.page-about .page-inner p:last-child { margin-bottom: 0; }

/* ==========================================================
   Projects
   ========================================================== */
.project-list { display: flex; flex-direction: column; }
.project-item {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  gap: 1.25rem;
  align-items: start;
  padding: 1.75rem 0;
  border-top: 1px solid var(--border);
}
.project-list li:last-child { border-bottom: 1px solid var(--border); }
.item-index {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  padding-top: 0.2rem;
}
.item-body h3 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.item-body p { color: var(--text-dim); font-size: 0.95rem; margin-bottom: 0.85rem; max-width: 48ch; }
.item-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  padding-top: 0.2rem;
  transition: color 0.2s ease;
}
.item-link:hover { color: var(--accent); }

/* ==========================================================
   Blog (index list)
   ========================================================== */
.blog-list { display: flex; flex-direction: column; }
.blog-item { border-top: 1px solid var(--border); }
.blog-list li:last-child { border-bottom: 1px solid var(--border); }
.blog-link {
  display: block;
  padding: 1.75rem 0;
  color: inherit;
  transition: color 0.2s ease;
}
.blog-link h3 { transition: color 0.2s ease; }
.blog-link:hover h3 { color: var(--accent); }
.post-status {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  color: var(--accent);
  display: block;
  margin-bottom: 0.6rem;
}
.blog-item h3 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.blog-item p { color: var(--text-dim); font-size: 0.95rem; max-width: 48ch; }

/* ==========================================================
   Blog post (individual page)
   ========================================================== */
.page-post {
  padding-top: clamp(20px, 3vw, 0px);
  padding-bottom: clamp(64px, 7vw, 104px);
}

.post { max-width: 900px; }

.post-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 0rem;
  transition: color 0.2s ease;
}
.post-back:hover { color: var(--accent); }

.post-header { margin-bottom: 3rem; }
.post-header h1 {
  font-size: clamp(2rem, 2.4vw + 1.2rem, 2.85rem);
  margin: 0.35rem 0 1rem;
}
.post-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}
.post-meta .dot { color: var(--border); }

.post-body { font-size: 1.05rem; }
.post-body p { margin-bottom: 1.35rem; }
.post-body h2 {
  font-size: 1.5rem;
  margin: 2.75rem 0 1rem;
}
.post-body h3 {
  font-size: 1.2rem;
  margin: 2rem 0 0.75rem;
}
.post-body ul, .post-body ol {
  list-style: disc;
  padding-left: 1.4rem;
  margin-bottom: 1.35rem;
}
.post-body ol { list-style: decimal; }
.post-body li { margin-bottom: 0.55rem; }
.post-body li > ul, .post-body li > ol { margin-top: 0.55rem; margin-bottom: 0; }

.post-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(236, 233, 225, 0.06);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}
html[data-theme="light"] .post-body code {
  background: rgba(20, 24, 31, 0.06);
}

.post-body pre {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  background: rgba(236, 233, 225, 0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.75rem 0;
}
html[data-theme="light"] .post-body pre {
  background: rgba(20, 24, 31, 0.03);
}
.post-body pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.post-body blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 1.25rem;
  margin: 2rem 0;
  color: var(--text-dim);
  font-style: italic;
}

.post-body a {
  color: var(--accent);
  border-bottom: 1px solid currentColor;
}

.post-body strong { font-weight: 600; }

/* ==========================================================
   Contact
   ========================================================== */
.contact-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.email-link {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.2rem;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.email-link:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); }
.copy-btn.copied { color: var(--accent); border-color: var(--accent); }

.social-list { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.social-list a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  transition: color 0.2s ease;
}
.social-list a:hover { color: var(--accent); }

/* ==========================================================
   Footer
   ========================================================== */
.site-footer {
  padding: 0 var(--edge) 3rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* ==========================================================
   Reduced motion
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-name, .hero-role, .hero-intro, .tag-row {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  * { transition-duration: 0.001ms !important; }
}

/* ==========================================================
   Responsive — sidebar becomes a top bar
   ========================================================== */
@media (max-width: 880px) {
  :root { --topbar-h: 64px; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; right: 0;
    width: 100%;
    height: var(--topbar-h);
    flex-direction: row;
    align-items: center;
    padding: 0 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg);
    z-index: 30;
  }
  .mark { margin-bottom: 0; margin-right: 1.25rem; font-size: 1.15rem; }
  .nav-list {
    flex-direction: row;
    flex: 1;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-link {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    padding: 0.4rem 0.65rem;
    border-left: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
  }
  .nav-link.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .nav-index { display: none; }
  .nav-label { font-size: 0.82rem; }

  .theme-toggle {
    position: static;
    margin-left: 0.5rem;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  .content { margin-left: 0; }
}

@media (max-width: 560px) {
  .project-item { grid-template-columns: 1fr; }
  .item-index { display: none; }
  .item-link { padding-top: 0; }
}