@import url('https://cdn.jsdelivr.net/gh/dreampulse/computer-modern-web-fonts@master/fonts.css');
@import url('https://fonts.googleapis.com/css2?family=Tilt+Prism&display=swap');
/* Base reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'CMU Serif', 'Computer Modern Serif', 'Latin Modern Roman', 'Times New Roman', Times, serif;
  color: #e6e6e6;
  background: #151515;
}

/* Custom Thin Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #0f0f0f; 
}
::-webkit-scrollbar-thumb {
  background: #333; 
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #f3d37a; 
}

/* Sidebar */
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 0;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  width: 360px;
  background: #0f0f0f;
  border-right: 1px solid #262626;
  overflow: auto;
}
.sidebar-inner { padding: 28px 22px; }
.sidebar-section { margin: 16px 0 0; }
.sidebar-heading { margin: 0 0 8px; font-size: 13px; color: #bdbdbd; text-transform: uppercase; letter-spacing: .4px; }
.link-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.link-list a { color: #e6e6e6; text-decoration: none; display: block; padding: 8px 10px; border-radius: 2px; border: 2px solid #2a2a2a; background: #141414; }
.link-list a:hover { background: #1f1f1f; border-color: #3a3a3a; }
.menu-toggle { display: none; }

.brand { text-align: center; margin-bottom: 24px; }
.avatar { width: 148px; height: 148px; border-radius: 50%; display: block; margin: 0 auto 12px; object-fit: cover; }
.site-title { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: 0.3px; }
.site-title span { color: #f3d37a; }
.tagline { margin: 6px 0 0; color: #b0b0b0; font-size: 14px; }

.nav { display: flex; flex-direction: column; gap: 8px; margin: 18px 0 24px; }
.nav-link {
  color: #e6e6e6; text-decoration: none; padding: 8px 10px; border-radius: 6px; transition: background 0.2s ease;
}
.nav-link:hover { background: #1f1f1f; }
.nav-link.active { color: #111; background: #f3d37a; font-weight: 700; }

.social { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 8px; }
.social a { text-align: center; color: #e6e6e6; text-decoration: none; padding: 8px 10px; border-radius: 2px; border: 2px solid #2a2a2a; background: #141414; font-family: 'CMU Serif', 'Computer Modern Serif', 'Latin Modern Roman', 'Times New Roman', Times, serif; font-size: 13px; }
.social a:hover { background: #1f1f1f; border-color: #3a3a3a; }
.sidebar-footer { margin-top: 16px; color: #9a9a9a; font-size: 12px; text-align: center; }

/* Personal/bio fill for sidebar */
.bio { text-align: left; color: #cfcfcf; font-size: 14px; margin: 14px 0; line-height: 1.6; }
.bio strong { color: #f3d37a; }
.bio-list { list-style: none; padding: 0; margin: 10px 0 0; }
.bio-list li { display: flex; gap: 8px; margin: 6px 0; color: #d4d4d4; }
.bio-list li span { color: #9a9a9a; min-width: 86px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { padding: 4px 10px; border-radius: 2px; background: #151515; border: 2px solid #2a2a2a; font-size: 12px; color: #e6e6e6; }
.license { margin: 0; }

/* Content */
.content { 
  min-height: 100dvh; 
  padding: 0; /* Remove default padding from wrapper to let page handle it or be centered cleanly */
  display: flex;
  justify-content: center; /* Center the page */
  background: #151515;
}

.page { 
  max-width: 820px; 
  width: 100%;
  margin: 0; 
  padding: 40px 56px; /* Move padding inside the page */
  min-height: 100dvh; /* Full height lines */
  border-left: 1px solid #7c7b7bff;
  border-right: 1px solid #7c7b7bff;
  background: #151515; /* Ensure background matches */
  box-sizing: border-box;
}
.page-header { margin-bottom: 22px; }
.page-title { font-size: 34px; margin: 4px 0 0; }
.meta { color: #9a9a9a; font-size: 14px; }

.posts { display: grid; gap: 14px; }
.post-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.post-toolbar .search { flex: 1; }
.post-toolbar input[type="search"] { width: 100%; background: #121212; border: 2px solid #2b2b2b; color: #e8e8e8; padding: 10px 12px; border-radius: 10px; }
.post-toolbar select { background: #121212; border: 2px solid #2b2b2b; color: #e8e8e8; padding: 10px 12px; border-radius: 10px; }
.post-tabs { display: flex; gap: 8px; margin: 6px 0 12px; flex-wrap: wrap; }
.post-tab { padding: 6px 10px; border: 2px solid #2b2b2b; border-radius: 2px; background: #141414; color: #e6e6e6; cursor: pointer; }
.post-tab.active { background: #f3d37a; color: #111; border-color: #f3d37a; }
.post-card {
  display: block;
  padding: 16px 18px 14px;
  border: 2px solid #2b2b2b;
  border-radius: 2px;
  background: #131313;
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease, box-shadow .12s ease;
  max-width: 960px;
  position: relative;
  clip-path: polygon(16px 0, 100% 0, calc(100% - 16px) 100%, 0 100%);
}
.post-card:hover { transform: translateY(-2px); background: #151515; border-color: #3a3a3a; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.post-title { margin: 0 0 6px; font-size: 22px; font-weight: 700; }
.post-card .post-title { font-family: 'Tilt Prism', serif; }
.post-card:hover .post-title { text-decoration: underline; text-underline-offset: 3px; }
.post-excerpt { margin: 0 8px 12px 0; color: #b8b8b8; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-meta { color: #9a9a9a; font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.badge { padding: 2px 8px; border-radius: 2px; border: 2px solid #2b2b2b; background: #141414; color: #dcdcdc; font-size: 12px; }
.chips.inline { display: inline-flex; gap: 6px; }
.post-chip { appearance: none; border: 2px solid #2a2a2a; background: #151515; color: #e6e6e6; padding: 4px 10px; border-radius: 2px; cursor: pointer; font: inherit; }
.post-chip:hover { background: #1f1f1f; border-color: #3a3a3a; }
.title-prism { font-family: 'Tilt Prism', serif; display: inline-block; position: relative; line-height: 1.1; letter-spacing: .3px; }
.title-prism::after { content: ""; position: absolute; left: 0; right: 0; height: 5px; bottom: -6px; background: #f3d37a; border-radius: 2px; transform: skewX(-10deg); }
.title-prism { text-shadow: 1px 1px 0 rgba(255,255,255,0.06), 2px 2px 0 rgba(0,0,0,0.25); }
.pager { display: flex; gap: 10px; margin: 16px 0; }
.pager button { padding: 8px 12px; background: #121212; border: 2px solid #2b2b2b; color: #e6e6e6; border-radius: 2px; cursor: pointer; }
.pager button[disabled] { opacity: .5; cursor: not-allowed; }

@media (min-width: 1440px) {
  .posts.masonry { column-count: 2; column-gap: 18px; }
  .posts.masonry .post-card { display: inline-block; width: 100%; break-inside: avoid; }
}

/* Typography */
h1,h2,h3 { line-height: 1.25; font-family: 'CMU Serif', 'Computer Modern Serif', 'Latin Modern Roman', 'Times New Roman', Times, serif; }
p { line-height: 1.7; }
a { color: #f3d37a; }
code { background: #1d1d1d; padding: 2px 6px; border-radius: 6px; font-family: 'CMU Typewriter Text','Computer Modern Typewriter','Latin Modern Mono','Consolas',monospace; }

/* Disable old TOC (kept for compatibility) */
.toc { display: none !important; }
.toc-title, .toc-list, .toc-link { display: none !important; }

/* Right-side minimap */
.minimap {
  position: fixed;
  z-index: 20;
  top: 24px;
  right: 18px;
  width: 180px;
  height: calc(100dvh - 48px);
  overflow: hidden;
  border: 1px solid #262626;
  border-radius: 10px;
  background: #0f0f0f;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  pointer-events: none;
}

/* PDF viewer layout */
.page.is-pdf { max-width: 100%; margin: 0; }
.pdf-layout { display: grid; grid-template-columns: 1fr 260px; gap: 16px; align-items: start; }
.pdf-outline { display: block; border: 1px solid #262626; border-radius: 10px; background: #0f0f0f; height: 100vh; overflow: auto; position: sticky; top: 0; }
.pdf-outline-inner { padding: 10px; font-size: 14px; }
.pdf-viewer { height: 100vh; overflow: auto; border: 0; border-radius: 0; background: #0f0f0f; }
.pdf-viewer #viewer { position: relative; padding: 0; display: block; }
.pdf-page { display: block; margin: 0 0 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.35); background: #111; width: 100%; }
.post-header-detail { margin-bottom: 1.6rem; border-bottom: 1px solid #333; padding-bottom: 1rem; }
.post-title-detail {
  margin: 0 0 .55rem;
  color: #f3d37a;
  line-height: 1.2;
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  word-break: break-word;
}
.post-actions { margin-bottom: .7rem; }
.post-back-button { cursor: pointer; }
.paper-actions { margin-bottom: .6rem; }
.paper-actions-minimal { display: flex; align-items: center; }
.paper-open-link {
  display: inline-block;
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid #2b2b2b;
  border-radius: 2px;
  background: #141414;
  color: #f3d37a;
}
.paper-open-link:hover { background: #1b1b1b; border-color: #3a3a3a; }
.post-paper-frame { width: 100%; min-height: 84vh; border: 2px solid #2b2b2b; border-radius: 2px; background: #111; }
.page.paper-focus {
  padding: 14px 0 0;
}
.page.paper-focus .post-actions,
.page.paper-focus .paper-actions-minimal {
  padding: 0 14px;
}
.page.paper-focus .post-paper-frame {
  min-height: calc(100dvh - 92px);
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}

@media (max-width: 1200px) {
  .pdf-layout { grid-template-columns: 1fr; }
}
.minimap-content {
  position: absolute;
  inset: 8px 6px;
  transform-origin: top left;
}
.minimap-viewport {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 8px;
  height: 120px;
  border-radius: 6px;
  border: 1px solid #f3d37a;
  background: rgba(243,211,122,0.12);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3) inset;
}
.minimap .page { max-width: none; }
.minimap img { filter: grayscale(1) contrast(0.9) brightness(0.8); }

/* Avoid content being covered by minimap */
body.has-minimap .content { padding-right: 260px; }

@media (max-width: 1200px) {
  .minimap { display: none; }
  body.has-minimap .content { padding-right: 18px; }
}

/* Global right-edge scroll progress */
.scroll-progress { position: fixed; right: 6px; top: 0; bottom: 0; width: 6px; pointer-events: none; z-index: 50; }
.scroll-progress__track { position: absolute; inset: 8px 0 8px 0; background: rgba(255,255,255,0.06); border-radius: 99px; }
.scroll-progress__bar { position: absolute; left: 0; right: 0; bottom: 8px; height: 0; background: #f3d37a; border-radius: 99px; box-shadow: 0 0 0 1px rgba(0,0,0,0.25) inset; }

@media (max-width: 900px) {
  .scroll-progress { display: none; }
}

/* Section mini-map (right fixed) */
.section-map { position: fixed; top: 0; right: 0; height: 100dvh; width: 150px; background: #1e1e1e; border-left: 1px solid #333; z-index: 40; padding: 8px 6px; display: none; }
.section-map__list { position: relative; height: 100%; }
.section-map__item { position: absolute; left: 6px; right: 6px; border-radius: 8px; background: #151515; border: 1px solid #2a2a2a; opacity: .55; outline: none; }
.section-map__item:hover { opacity: .8; }
.section-map__item.is-active { opacity: 1; border-color: #f3d37a; box-shadow: 0 0 0 1px #f3d37a inset, 0 4px 12px rgba(0,0,0,.35); }
.section-map__thumb { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(0,0,0,.05)); filter: blur(2px); opacity: .5; }
.section-map__label { position: absolute; left: 6px; bottom: 6px; right: 6px; font-size: 11px; color: #cfcfcf; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.section-map__indicator { position: absolute; left: 2px; right: 2px; height: 40px; border-radius: 6px; border: 1px solid #f3d37a; background: rgba(243,211,122,0.12); box-shadow: 0 0 0 1px rgba(0,0,0,.3) inset; pointer-events: none; }

/* Reserve space and reposition progress bar when map exists */
body.has-section-map .content { padding-right: 180px; }
body.has-section-map .scroll-progress { right: 160px; }

@media (max-width: 1024px) {
  .section-map { display: none !important; }
  body.has-section-map .content { padding-right: 18px; }
  body.has-section-map .scroll-progress { right: 6px; }
}

/* Responsive */
@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; right: 0; top: 0; height: auto; width: auto; border-right: none; border-bottom: 1px solid #262626; }
  .sidebar-inner { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; }
  .brand { display: flex; align-items: center; gap: 12px; margin: 0; }
  .avatar { width: 56px; height: 56px; margin: 0; }
  .site-title { font-size: 20px; }
  .tagline { display: none; }
  .nav { display: none; }
  .menu-toggle { display: inline-flex; position: absolute; right: 10px; top: 10px; background: #1d1d1d; color: #f3d37a; border: 1px solid #333; padding: 6px 10px; border-radius: 6px; }
  .content { padding: 84px 18px 28px; }
  .page.paper-focus { padding-top: 10px; }
  .page.paper-focus .post-actions,
  .page.paper-focus .paper-actions-minimal { padding: 0 10px; }
  .page.paper-focus .post-paper-frame { min-height: calc(100dvh - 120px); }
}

/* Mobile menu expanded */
.sidebar.open .nav { display: flex; position: absolute; top: 56px; left: 0; right: 0; background: #0f0f0f; padding: 10px 14px 14px; border-bottom: 1px solid #262626; }

/* Parallelogram edges and skewed accent similar to title */
.post-tab, .post-chip, .badge, .chip, .social a, .link-list a, .pager button {
  position: relative;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}
.post-tab::after, .post-chip::after, .badge::after, .chip::after, .social a::after, .link-list a::after, .pager button::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  bottom: -6px;
  background: #f3d37a;
  border-radius: 2px;
  transform: skewX(-10deg);
}
