/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* === VARIABLES === */
:root {
  --bg: #1a1410;
  --surface: #14100c;
  --text-primary: #d4b896;
  --text-body: #b8a088;
  --text-muted: #8b7355;
  --text-faint: #6b5c4a;
  --text-subtle: #5a4a3a;
  --text-dim: #4a3d2e;
  --border: #2a1f15;
  --border-light: #1f1710;
  --accent: #5a3a1a;
  --link: #c4a878;
  --sidebar-w: 180px;
  --margin-w: 100px;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text-body);
  font-family: Georgia, 'Noto Serif', serif;
  line-height: 1.7;
  min-height: 100vh;
}

a { color: var(--link); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--text-primary); }

/* === LAYOUT === */
.layout { display: flex; min-height: 100vh; }

/* === SIDEBAR === */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 48px 20px 32px;
  text-align: right;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.sidebar-inner { flex: 1; display: flex; flex-direction: column; }

.site-title {
  font-family: Georgia, serif;
  font-size: 18px;
  color: var(--text-primary);
  letter-spacing: 3px;
  display: block;
  margin-bottom: 4px;
}

.title-rule {
  width: 20px;
  height: 1px;
  background: var(--border);
  margin: 14px 0 14px auto;
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  flex: 1;
}

.nav-link { color: var(--text-subtle); transition: color 0.2s; }
.nav-link:hover { color: var(--text-muted); }

.sidebar-footer {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.6;
  padding-top: 24px;
}

.main-content { flex: 1; padding: 48px 40px 60px; max-width: 780px; }

/* === HOMEPAGE === */
.tagline {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 40px;
  padding-left: 2px;
}

.post-card { margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--border-light); }
.post-card:last-child { border-bottom: none; }

.post-date {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--text-subtle);
  display: block;
  margin-bottom: 4px;
}

.post-title { font-size: 20px; font-weight: normal; line-height: 1.3; margin-bottom: 6px; }
.post-title a { color: var(--text-primary); }
.post-title a:hover { color: var(--link); }

.post-desc { font-size: 11px; color: var(--text-faint); line-height: 1.6; margin-bottom: 8px; }

.post-tags { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tag { font-family: 'Courier New', monospace; font-size: 9px; color: var(--text-dim); }
.read-time { font-family: 'Courier New', monospace; font-size: 9px; color: var(--text-dim); }

/* === POST DETAIL === */
.post-detail { display: flex; gap: 24px; }

.post-margin { width: var(--margin-w); flex-shrink: 0; padding-top: 36px; }
.margin-section { margin-bottom: 20px; }

.margin-label {
  font-family: 'Courier New', monospace;
  font-size: 8px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: block;
  margin-bottom: 6px;
}

.margin-tag, .margin-toc-item {
  font-family: 'Courier New', monospace;
  font-size: 8px;
  color: var(--text-dim);
  line-height: 2;
  text-align: right;
}

.post-body { flex: 1; max-width: 520px; }

.back-link {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--text-subtle);
  display: inline-block;
  margin-bottom: 20px;
}
.back-link:hover { color: var(--text-muted); }

.post-title-main {
  font-family: Georgia, serif;
  font-size: 26px;
  font-weight: normal;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 10px;
}

.post-meta-line {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--text-subtle);
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.meta-sep { margin: 0 6px; color: var(--text-dim); }

/* === POST CONTENT === */
.post-content { font-size: 14px; line-height: 1.85; color: var(--text-body); }
.post-content p { margin-bottom: 16px; }
.post-content h2 { font-family: Georgia, serif; font-size: 20px; font-weight: normal; color: var(--text-primary); margin: 32px 0 12px; }
.post-content h3 { font-family: Georgia, serif; font-size: 17px; font-weight: normal; color: var(--text-muted); margin: 24px 0 10px; }
.post-content code { font-family: 'Courier New', monospace; font-size: 12px; background: var(--surface); padding: 2px 5px; color: #9b8c78; }
.post-content pre { background: var(--surface); border-left: 2px solid var(--accent); padding: 14px 18px; margin: 20px 0; overflow-x: auto; font-family: 'Courier New', monospace; font-size: 12px; line-height: 1.6; color: #9b8c78; }
.post-content pre code { background: none; padding: 0; }
.post-content blockquote { border-left: 1px solid var(--border); padding-left: 16px; margin: 20px 0; color: var(--text-faint); font-style: italic; }
.post-content a { color: var(--link); border-bottom: 1px solid var(--border); }
.post-content a:hover { color: var(--text-primary); border-bottom-color: var(--text-muted); }
.post-content ul, .post-content ol { margin: 16px 0; padding-left: 20px; }
.post-content li { margin-bottom: 6px; }
.post-content hr { border: none; border-top: 1px solid var(--border-light); margin: 32px 0; }
.post-content img { max-width: 100%; height: auto; }
.post-content table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 12px; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.post-content th { font-family: 'Courier New', monospace; font-size: 10px; color: var(--text-muted); background: var(--surface); }

/* === PAGE HEADER === */
.page-header { margin-bottom: 32px; }
.terminal-hint { font-family: 'Courier New', monospace; font-size: 8px; color: var(--text-dim); }

/* === ABOUT === */
.portrait-placeholder { width: 100%; max-width: 200px; aspect-ratio: 1; background: linear-gradient(135deg, var(--border) 0%, var(--border-light) 100%); display: flex; align-items: center; justify-content: center; margin-bottom: 20px; font-family: 'Courier New', monospace; font-size: 9px; color: var(--text-dim); }
.about-name { font-family: Georgia, serif; font-size: 22px; font-weight: normal; color: var(--text-primary); margin-bottom: 6px; }
.about-tagline { font-family: Georgia, serif; font-style: italic; font-size: 11px; color: var(--text-muted); margin-bottom: 18px; }
.about-bio { font-size: 13px; line-height: 1.8; color: var(--text-body); margin-bottom: 18px; }
.about-bio p { margin-bottom: 12px; }
.about-links { padding-top: 14px; border-top: 1px solid var(--border); font-family: 'Courier New', monospace; font-size: 9px; }
.social-link { color: var(--text-subtle); }
.social-link:hover { color: var(--text-muted); }
.link-sep { margin: 0 6px; color: var(--text-dim); }

/* === PROJECTS & FRIENDS === */
.projects-content, .friends-content { font-size: 13px; line-height: 1.8; color: var(--text-body); }
.friends-content a { color: var(--link); }
.projects-content h3 { font-family: Georgia, serif; font-size: 17px; font-weight: normal; color: var(--text-primary); margin: 20px 0 6px; }
.projects-content p { margin-bottom: 10px; }
.friends-content ul { list-style: none; padding: 0; }
.friends-content li { margin-bottom: 10px; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: baseline; justify-content: space-between; padding: 16px 20px; border-right: none; border-bottom: 1px solid var(--border); text-align: left; }
  .site-title { font-size: 15px; }
  .title-rule { display: none; }
  .main-nav { flex-direction: row; gap: 14px; font-size: 11px; }
  .sidebar-footer { display: none; }
  .main-content { padding: 24px 20px 40px; max-width: 100%; }
  .post-detail { flex-direction: column; }
  .post-margin { width: 100%; padding-top: 0; order: 2; }
  .margin-tag, .margin-toc-item { display: inline-block; margin-right: 10px; }
  .post-body { max-width: 100%; }
  .post-title { font-size: 17px; }
  .post-title-main { font-size: 21px; }
}

/* === VISUAL ENHANCEMENTS === */

/* texture overlay */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url(data:image/svg+xml,%3Csvg viewBox=0 0 256 256 xmlns=http://www.w3.org/2000/svg%3E%3Cfilter id=n%3E%3CfeTurbulence type=fractalNoise baseFrequency=0.85 numOctaves=4 stitchTiles=stitch/%3E%3C/filter%3E%3Crect width=100%25 height=100%25 filter=url(%23n) opacity=0.04/%3E%3C/svg%3E);
  pointer-events: none;
  z-index: 0;
}

/* subtle vignette */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 50% 30%, transparent 40%, rgba(0,0,0,0.3) 100%);
  pointer-events: none;
  z-index: 1;
}

.layout { position: relative; z-index: 2; }

/* improve font rendering */
html {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: subpixel-antialiased;
}

/* increase body contrast and size */
body {
  font-size: 17px;
}

.post-content { font-size: 15px; color: #c4b098; }

/* sidebar ambient glow */
.sidebar::before {
  content: '';
  position: absolute;
  top: 10%;
  right: -1px;
  width: 1px;
  height: 30%;
  background: linear-gradient(to bottom, transparent, rgba(180,130,60,0.15), transparent);
}

/* nav hover improvement */
.nav-link {
  transition: all 0.3s ease;
  position: relative;
}
.nav-link:hover {
  color: #c4a878 !important;
  text-shadow: 0 0 8px rgba(180,130,60,0.2);
}

/* post card hover lift */
.post-card {
  transition: border-color 0.3s;
}
.post-card:hover {
  border-bottom-color: var(--border);
}

.post-title a {
  transition: color 0.3s;
}

/* back-link improvement */
.back-link {
  transition: all 0.3s;
}
.back-link:hover {
  color: #c4a878;
}

/* code block subtle glow */
.post-content pre {
  box-shadow: inset 0 0 30px rgba(0,0,0,0.3);
}

/* site title spark */
.site-title {
  transition: color 0.4s, text-shadow 0.4s;
}
.site-title:hover {
  color: #ead0a0;
  text-shadow: 0 0 15px rgba(180,130,60,0.15);
}

/* improve sidebar rule visibility */
.title-rule {
  background: linear-gradient(to right, transparent, rgba(180,130,60,0.3));
  width: 30px;
  height: 1px;
}
