/* ============================================================
   Personal Wiki — Robert Schneider
   Style: Notion meets Linear, dark mode
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Color system */
  --bg:           #0f1117;
  --bg-alt:       #13161f;
  --surface:      #1a1d27;
  --surface-alt:  #1e2130;
  --border:       #2a2d3a;
  --border-light: #353848;
  --accent:       #6366f1;
  --accent-hover: #818cf8;
  --accent-dim:   rgba(99,102,241,0.12);
  --text:         #e2e8f0;
  --text-muted:   #64748b;
  --text-faint:   #475569;
  --success:      #10b981;
  --success-dim:  rgba(16,185,129,0.12);
  --warning:      #f59e0b;
  --warning-dim:  rgba(245,158,11,0.12);
  --danger:       #ef4444;
  --danger-dim:   rgba(239,68,68,0.12);
  --info:         #3b82f6;
  --info-dim:     rgba(59,130,246,0.12);

  /* Layout */
  --sidebar-w:    260px;
  --topbar-h:     56px;
  --content-max:  860px;
  --radius:       8px;
  --radius-sm:    5px;
  --radius-lg:    12px;
  --shadow:       0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-lg:    0 4px 24px rgba(0,0,0,0.5);

  /* Typography */
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Light mode override */
body.light-mode {
  --bg:           #f8fafc;
  --bg-alt:       #f1f5f9;
  --surface:      #ffffff;
  --surface-alt:  #f8fafc;
  --border:       #e2e8f0;
  --border-light: #cbd5e1;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --text-faint:   #94a3b8;
}

/* ---------- Layout Shell ---------- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.sidebar-logo-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0 16px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 4px;
  cursor: pointer;
  user-select: none;
}

.nav-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-section-toggle {
  color: var(--text-faint);
  transition: transform 0.2s;
  font-size: 10px;
}

.nav-section.collapsed .nav-section-toggle {
  transform: rotate(-90deg);
}

.nav-section-items {
  padding: 2px 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
  max-height: 500px;
}

.nav-section.collapsed .nav-section-items {
  max-height: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 28px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.855rem;
  border-radius: 0;
  transition: color 0.15s, background 0.15s;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-link::before {
  content: '';
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border-light);
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

.nav-link.active {
  color: var(--accent-hover);
  background: var(--accent-dim);
}

.nav-link.active::before {
  background: var(--accent);
}

.nav-link-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-left: -4px;
}

/* Standalone nav items (Search) */
.nav-link-standalone {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.855rem;
  transition: color 0.15s, background 0.15s;
  margin: 4px 0;
}

.nav-link-standalone:hover {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

.nav-link-standalone.active {
  color: var(--accent-hover);
  background: var(--accent-dim);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-faint);
}

/* ---------- Main Area ---------- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Top Bar ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 18px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 0;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}
.breadcrumb a:hover { color: var(--text); }
.breadcrumb-sep { color: var(--text-faint); }
.breadcrumb-current {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- Search Box ---------- */
.search-wrap {
  position: relative;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 7px 34px 7px 32px;
  width: 220px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, width 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  width: 280px;
}

.search-input::placeholder { color: var(--text-faint); }

.search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 13px;
  pointer-events: none;
}

.search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text-faint);
  background: var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  font-family: var(--font-mono);
}

/* Search dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  display: none;
}

.search-dropdown.open { display: block; }

.search-dropdown-item {
  display: block;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.search-dropdown-item:last-child { border-bottom: none; }
.search-dropdown-item:hover { background: var(--surface-alt); }

.search-item-title {
  font-size: 0.87rem;
  font-weight: 500;
  margin-bottom: 2px;
}

.search-item-excerpt {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.search-empty {
  padding: 20px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------- Theme Toggle ---------- */
.theme-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  font-size: 14px;
  transition: color 0.15s, background 0.15s;
}
.theme-btn:hover { color: var(--text); background: var(--surface-alt); }

/* ---------- Page Content ---------- */
.page-content {
  flex: 1;
  padding: 32px 40px;
  max-width: calc(var(--content-max) + 80px);
}

.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 6px;
}

.page-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.page-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Badges / Tags ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.badge-accent   { background: var(--accent-dim);   color: var(--accent-hover); border: 1px solid rgba(99,102,241,0.2); }
.badge-success  { background: var(--success-dim);  color: var(--success);      border: 1px solid rgba(16,185,129,0.2); }
.badge-warning  { background: var(--warning-dim);  color: var(--warning);      border: 1px solid rgba(245,158,11,0.2); }
.badge-danger   { background: var(--danger-dim);   color: var(--danger);       border: 1px solid rgba(239,68,68,0.2); }
.badge-info     { background: var(--info-dim);     color: var(--info);         border: 1px solid rgba(59,130,246,0.2); }
.badge-muted    { background: rgba(255,255,255,0.05); color: var(--text-muted); border: 1px solid var(--border); }
.badge-placeholder { background: var(--warning-dim); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }

/* ---------- Stat Cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: border-color 0.15s, transform 0.15s;
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-change {
  font-size: 0.77rem;
  color: var(--text-faint);
}

.stat-icon {
  float: right;
  font-size: 1.5rem;
  opacity: 0.5;
  margin-top: -2px;
}

/* ---------- Section Headers ---------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.section-link {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}
.section-link:hover { color: var(--accent-hover); }

/* ---------- Report Cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}

.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}

.report-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  opacity: 0;
  transition: opacity 0.2s;
}

.report-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.report-card:hover::after { opacity: 1; }

.card-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.card-excerpt {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.card-date {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.card-arrow {
  color: var(--accent);
  font-size: 14px;
  transition: transform 0.15s;
}
.report-card:hover .card-arrow { transform: translateX(3px); }

/* ---------- Placeholder Banner ---------- */
.placeholder-banner {
  background: var(--warning-dim);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.placeholder-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }

.placeholder-text { font-size: 0.87rem; color: var(--text); }
.placeholder-text strong { color: var(--warning); }

/* ---------- Content Sections ---------- */
.content-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
}

.content-section-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.content-section-header:hover { background: var(--surface-alt); }

.content-section-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.content-section-icon { font-size: 1rem; }
.content-section-chevron { color: var(--text-faint); font-size: 11px; transition: transform 0.2s; }
.content-section.open .content-section-chevron { transform: rotate(90deg); }

.content-section-body {
  padding: 16px 18px;
  display: none;
}

.content-section.open .content-section-body { display: block; }

.section-description {
  font-size: 0.87rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.placeholder-tag {
  display: inline-block;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.77rem;
  color: var(--text-faint);
  margin: 3px 3px 3px 0;
}

/* ---------- Divider ---------- */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ---------- Tables ---------- */
.wiki-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
  margin: 12px 0;
}

.wiki-table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.wiki-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.wiki-table tr:last-child td { border-bottom: none; }
.wiki-table tr:hover td { background: var(--surface-alt); }

/* ---------- Code Blocks ---------- */
pre, code {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 12px 0;
  line-height: 1.6;
  color: #a5b4fc;
}

code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  color: #a5b4fc;
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

/* ---------- Prose Content ---------- */
.prose h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin: 24px 0 10px;
  letter-spacing: -0.02em;
}

.prose h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 18px 0 8px;
}

.prose p {
  color: var(--text-muted);
  margin: 8px 0;
  font-size: 0.9rem;
  line-height: 1.7;
}

.prose ul, .prose ol {
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.prose li { margin: 4px 0; }

.prose a { color: var(--accent); text-decoration: none; }
.prose a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---------- Search Page ---------- */
.search-page-wrap {
  max-width: 680px;
}

.search-page-input-wrap {
  position: relative;
  margin-bottom: 24px;
}

.search-page-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  padding: 12px 16px 12px 42px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-page-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search-page-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 16px;
}

.search-results { }

.search-result-item {
  display: block;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}

.search-result-item:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}

.result-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.result-excerpt {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
}

.result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.search-empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.search-empty-state p { font-size: 0.9rem; }

/* ---------- Empty / Utility ---------- */
.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .card-grid  { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main { margin-left: 0; }
  .topbar-menu-btn { display: flex; }
  .page-content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card-grid  { grid-template-columns: 1fr; }
  .search-input { width: 160px; }
  .search-input:focus { width: 200px; }
  .search-dropdown { width: 300px; right: -60px; }
  .page-title { font-size: 1.4rem; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .search-input { width: 120px; }
  .topbar { gap: 8px; }
}

/* ---------- Sidebar Overlay (mobile) ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ---------- Scrollbar (main) ---------- */
::-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(--border-light); }

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-content { animation: fadeIn 0.2s ease; }

/* ---------- Focus styles ---------- */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
