/* wlog — Design System */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ==========================================================================
   Color Tokens — 60/30/10 Rule
   60% = background  |  30% = text & surfaces  |  10% = accent (green)
   ========================================================================== */

/* ── Light Mode (default) ── */
:root {
  --bg: #f9fafb;
  --bg-secondary: #f1f5f1;
  --bg-card: #ffffff;
  --bg-hover: #ecf2ec;
  --text: #1a2e23;
  --text-secondary: #4b6455;
  --text-muted: #7d9688;
  --accent: #2a7d4f;
  --accent-secondary: #34a065;
  --accent-glow: rgba(42, 125, 79, 0.08);
  --accent-hover: #1e6b40;
  --border: rgba(42, 125, 79, 0.10);
  --border-accent: rgba(42, 125, 79, 0.22);
  --code-bg: #f0f6f2;
  --link: #1068bf;
  --link-hover: #0b5cad;
  --success: #2a7d4f;
  --header-bg: rgba(249, 250, 251, 0.85);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --max-width: 820px;
  --radius: 10px;
  --radius-sm: 6px;
}

/* ── Dark Mode ── */
:root[data-theme="dark"] {
  --bg: #0d1117;
  --bg-secondary: #151d28;
  --bg-card: #1a2332;
  --bg-hover: #1e2d3d;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #4ade80;
  --accent-secondary: #34d399;
  --accent-glow: rgba(74, 222, 128, 0.10);
  --accent-hover: #6ee7a0;
  --border: rgba(148, 163, 184, 0.10);
  --border-accent: rgba(74, 222, 128, 0.22);
  --code-bg: #0f1714;
  --link: #6cb4f9;
  --link-hover: #97c4f0;
  --success: #4ade80;
  --header-bg: rgba(13, 17, 23, 0.85);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

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

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.layout-wrapper {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

body.sidebar-collapsed .layout-wrapper {
  grid-template-columns: 1fr;
  gap: 0;
}

body.sidebar-collapsed .sidebar {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  display: none;
}

/* ==========================================================================
   Sidebar Navigation Tree
   ========================================================================== */

.sidebar {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 1rem;
  font-size: 0.9rem;
}

.tree-nav ul {
  list-style: none;
  padding-left: 1rem;
  margin-bottom: 0;
}

.tree-nav > ul {
  padding-left: 0;
}

.tree-nav li {
  margin: 0.2rem 0;
}

.tree-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.2rem 0.4rem;
  display: block;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  word-break: break-all;
}

.tree-nav a:hover {
  color: var(--accent);
  background: var(--bg-hover);
}

.tree-nav a.active {
  color: var(--accent);
  background: var(--accent-glow);
  font-weight: 600;
}

.tree-nav details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.tree-nav details > summary::-webkit-details-marker {
  display: none;
}

.tree-nav details > summary::before {
  content: '▶';
  font-size: 0.6rem;
  margin-right: 0.4rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  display: inline-block;
}

.tree-nav details[open] > summary::before {
  transform: rotate(90deg);
}

.tree-nav details > summary > a {
  flex-grow: 1;
  font-weight: 600;
  color: var(--text);
}

/* ==========================================================================
   Header
   ========================================================================== */

header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  transition: background 0.3s ease;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0;
  padding-bottom: 0;
}

header .logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.sidebar-toggle:hover {
  color: var(--accent);
  background: var(--bg-hover);
}

header .logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

header .logo span {
  color: var(--accent);
  transition: color 0.3s ease;
}

header nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

header nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

header nav a:hover {
  color: var(--accent);
  background: var(--accent-glow);
}

/* ── Theme Toggle Button ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  font-size: 1rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--border-accent);
  background: var(--accent-glow);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

/* Light mode: show moon (click to go dark) */
:root:not([data-theme="dark"]) .theme-toggle .icon-moon {
  display: block;
}

/* Dark mode: show sun (click to go light) */
:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

/* ── Search Button ── */
.search-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font-sans);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.search-btn:hover {
  color: var(--accent);
  border-color: var(--border-accent);
  background: var(--accent-glow);
}

.search-btn kbd {
  font-size: 0.7rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
  font-family: var(--font-mono);
  line-height: 1.5;
}

.search-btn-label {
  font-size: 0.8rem;
}

/* ==========================================================================
   Search Modal
   ========================================================================== */

.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.search-overlay.open {
  display: flex;
}

.search-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 24px 64px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 580px;
  margin: 0 1rem;
  overflow: hidden;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.search-modal-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 1rem;
  color: var(--text);
  font-family: var(--font-sans);
  caret-color: var(--accent);
}

#search-input::placeholder {
  color: var(--text-muted);
}

.search-esc-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.search-results {
  list-style: none;
  padding: 0.4rem;
  margin: 0;
  max-height: 380px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s ease;
}

.search-result-item:hover,
.search-result-item.selected {
  background: var(--bg-hover);
}

.search-result-item.selected .search-result-title {
  color: var(--accent);
}

.search-result-title {
  font-weight: 500;
  color: var(--text);
  font-size: 0.9rem;
  transition: color 0.1s ease;
}

.search-result-path {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.search-no-results {
  padding: 1.5rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}


/* ==========================================================================
   Breadcrumb
   ========================================================================== */

.breadcrumb {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.breadcrumb a:hover {
  color: var(--accent);
  background: var(--accent-glow);
}

.breadcrumb .sep {
  margin: 0 0.15rem;
  opacity: 0.35;
}

/* ==========================================================================
   Article Content
   ========================================================================== */

article {
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

article h1 {
  font-size: 2.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.035em;
  line-height: 1.25;
  color: var(--text);
}

article h2 {
  font-size: 1.45rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.02em;
  color: var(--text);
}

article h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

article h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
}

article p {
  margin-bottom: 1rem;
  color: var(--text);
}

article a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

article a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

article strong {
  color: var(--text);
  font-weight: 600;
}

article em {
  color: var(--text-secondary);
}

article ul,
article ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

article li {
  margin-bottom: 0.35rem;
}

article li a {
  border-bottom: none;
}

/* ── Code ── */
article code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  padding: 0.15em 0.45em;
  border-radius: 5px;
  font-size: 0.85em;
  border: 1px solid var(--border);
  color: var(--accent);
}

article pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

article pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.84rem;
  color: var(--text);
}

/* ── Blockquote ── */
article blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--accent-glow);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
  font-style: italic;
}

article blockquote p {
  margin-bottom: 0;
}

/* ── Tables ── */
article table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

article th,
article td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border: 1px solid var(--border);
}

article th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

article tr:hover {
  background: var(--bg-hover);
}

/* ── Horizontal Rule ── */
article hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-accent), transparent);
  margin: 2.5rem 0;
}

/* ── Images ── */
article img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 1rem 0;
  box-shadow: var(--shadow);
}

/* ==========================================================================
   Directory Description
   ========================================================================== */

.dir-description {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.dir-description blockquote {
  margin-top: 0.75rem;
}

/* ==========================================================================
   Directory Listing
   ========================================================================== */

.index-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.2rem;
}

.index-list li {
  margin-bottom: 0;
}

.index-list a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.index-list a:hover {
  background: var(--bg-hover);
  color: var(--accent);
  border-color: var(--border);
  transform: translateX(4px);
}

.index-list .icon {
  font-size: 1rem;
  width: 1.4rem;
  text-align: center;
  flex-shrink: 0;
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

footer .container {
  font-style: italic;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .layout-wrapper {
    grid-template-columns: 1fr !important;
  }
  
  .sidebar {
    position: static;
    max-height: none;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    display: none;
  }

  body:not(.sidebar-collapsed) .sidebar {
    display: block;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 1.25rem 1rem;
  }

  article h1 {
    font-size: 1.65rem;
  }

  article h2 {
    font-size: 1.25rem;
  }

  header .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  header nav {
    gap: 0;
  }

  header nav a:first-child {
    padding-left: 0;
  }

  .index-list a:hover {
    transform: none;
  }
}