/* ============================================
   lyrumu's site — Custom Stylesheet
   Dark theme, sidebar, markdown, responsive
   ============================================ */

:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1c2128;
  --bg-input: #0d1117;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-muted: #484f58;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-dim: rgba(88,166,255,0.15);
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --sidebar-w: 280px;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: #79c0ff; }

::selection { background: var(--accent-dim); color: var(--text); }

/* ============ Sidebar ============ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s cubic-bezier(.4,0,.2,1);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-header h1 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}

.sidebar-header h1 a { color: var(--text); }
.sidebar-header h1 a:hover { color: var(--accent); text-decoration: none; }

.search-box {
  width: 100%;
  padding: 7px 10px 7px 30px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.search-box:focus { border-color: var(--accent); }
.search-box::placeholder { color: var(--text-muted); }

.search-wrapper {
  position: relative;
}
.search-wrapper::before {
  content: "🔍";
  position: absolute;
  left: 8px; top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  pointer-events: none;
}

/* Tree */
.tree-container {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.tree-container ul { list-style: none; }

.tree-item {
  user-select: none;
}

.tree-item > a,
.tree-item > .toggle-row {
  display: flex;
  align-items: center;
  padding: 3px 12px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-item > a:hover,
.tree-item > .toggle-row:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.tree-item.active > a {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

.toggle-icon {
  display: inline-block;
  width: 14px;
  text-align: center;
  font-size: 9px;
  transition: transform 0.15s;
  flex-shrink: 0;
  color: var(--text-muted);
}

.tree-item.open > .toggle-row > .toggle-icon,
.tree-item.open > a > .toggle-icon {
  transform: rotate(90deg);
}

.tree-children {
  display: none;
}
.tree-item.open > .tree-children {
  display: block;
}

/* Indent levels */
.tree-container .tree-children .tree-item > a,
.tree-container .tree-children .tree-item > .toggle-row { padding-left: 24px; }
.tree-container .tree-children .tree-children .tree-item > a,
.tree-container .tree-children .tree-children .tree-item > .toggle-row { padding-left: 36px; }
.tree-container .tree-children .tree-children .tree-children .tree-item > a,
.tree-container .tree-children .tree-children .tree-children .tree-item > .toggle-row { padding-left: 48px; }
.tree-container .tree-children .tree-children .tree-children .tree-children .tree-item > a,
.tree-container .tree-children .tree-children .tree-children .tree-children .tree-item > .toggle-row { padding-left: 56px; }

/* ============ Main Content ============ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.content-header {
  padding: 24px 48px 20px;
  border-bottom: 1px solid var(--border);
}

.content-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}
.breadcrumb a { color: var(--text-dim); }
.breadcrumb a:hover { color: var(--accent); }

.content-body {
  padding: 32px 48px 80px;
  max-width: 900px;
}

/* ============ Markdown Typography ============ */
.content-body h1 { font-size: 2em; font-weight: 700; margin: 32px 0 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.content-body h2 { font-size: 1.5em; font-weight: 600; margin: 28px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.content-body h3 { font-size: 1.25em; font-weight: 600; margin: 24px 0 8px; }
.content-body h4 { font-size: 1.1em; font-weight: 600; margin: 20px 0 6px; }
.content-body h5, .content-body h6 { font-size: 1em; font-weight: 600; margin: 16px 0 4px; color: var(--text-dim); }

.content-body p { margin: 10px 0; }
.content-body ul, .content-body ol { margin: 10px 0; padding-left: 24px; }
.content-body li { margin: 4px 0; }
.content-body li > ul, .content-body li > ol { margin: 4px 0; }

.content-body blockquote {
  border-left: 4px solid var(--accent);
  padding: 10px 16px;
  margin: 16px 0;
  background: var(--bg-card);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-dim);
}

.content-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

/* Inline code */
.content-body code {
  background: rgba(110,118,129,0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: "SF Mono", "Fira Code", "JetBrains Mono", Consolas, monospace;
}

/* Code blocks — Prism takes over styling */
.content-body pre {
  margin: 16px 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.content-body pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 14px;
}

/* Standalone code blocks without Prism */
.code-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.55;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
}

/* ============ Tables ============ */
.table-container {
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  background: var(--bg-hover);
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(110,118,129,0.06); }

/* ============ TOC ============ */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 16px 0;
}

.toc summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  list-style: none;
}
.toc summary::before { content: "📑 "; }

.toc ul { margin: 8px 0; padding-left: 20px; }
.toc li { margin: 3px 0; font-size: 14px; }
.toc a { color: var(--text-dim); }
.toc a:hover { color: var(--accent); }

/* ============ Media ============ */
.image-container {
  text-align: center;
  margin: 20px 0;
}

.image-container img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform 0.2s;
}

.image-container img.zoomed {
  max-height: none;
  cursor: zoom-out;
  position: fixed;
  top: 4%; left: 4%;
  width: 92%; height: 92%;
  object-fit: contain;
  z-index: 1000;
  background: rgba(0,0,0,0.92);
  padding: 16px;
  border: none;
}

.audio-player {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
}

.audio-player p { margin-bottom: 10px; color: var(--text-dim); font-size: 14px; }
.audio-player audio { width: 100%; border-radius: 6px; }

.download-card {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  margin: 16px 0;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.download-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
  color: var(--text);
  text-decoration: none;
}
.download-card .icon { font-size: 28px; }
.download-card .name { font-weight: 600; font-size: 14px; }
.download-card .meta { color: var(--text-muted); font-size: 12px; }

/* ============ Directory List ============ */
.dir-list {
  list-style: none;
  padding: 0;
  margin: 16px 0;
}

.dir-list li {
  border-bottom: 1px solid var(--border);
}

.dir-list li:last-child { border-bottom: none; }

.dir-list li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  transition: background 0.1s;
}

.dir-list li a:hover {
  background: var(--bg-hover);
  border-radius: var(--radius);
  color: var(--accent);
}

/* ============ Mobile ============ */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.6); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .content-header { padding: 16px; padding-top: 52px; }
  .content-body { padding: 20px 16px 60px; }
}

/* ============ Scrollbar ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============ Print ============ */
@media print {
  .sidebar, .menu-toggle, .sidebar-overlay { display: none !important; }
  .main-content { margin-left: 0 !important; }
  body { background: white; color: black; }
}

/* ============ Prism overrides ============ */
pre[class*="language-"] {
  margin: 16px 0;
  border-radius: var(--radius);
  background: var(--bg-card) !important;
  border: 1px solid var(--border);
}
code[class*="language-"] {
  font-family: "SF Mono", "Fira Code", "JetBrains Mono", Consolas, monospace;
  font-size: 14px;
  line-height: 1.55;
}
.line-numbers .line-numbers-rows {
  border-right: 1px solid var(--border);
}
.line-numbers-rows > span:before {
  color: var(--text-muted);
}

/* ============ Markdown Extensions ============ */
/* Strikethrough */
.content-body del { text-decoration: line-through; opacity: 0.7; }

/* Mark/Highlight */
.content-body mark {
  background: rgba(210, 153, 34, 0.3);
  color: var(--text);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Task list checkboxes */
.task-list-item {
  list-style: none;
  margin-left: -1.5em;
  padding-left: 0;
}
.task-list-item input[type="checkbox"] {
  margin-right: 6px;
  accent-color: var(--accent);
}

/* Details/summary (collapsible) */
.content-body details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 12px 0;
  background: var(--bg-card);
}
.content-body details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}
.content-body details[open] summary {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Kbd (keyboard) */
.content-body kbd {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.85em;
  font-family: "SF Mono", Consolas, monospace;
}
