/* =============================
   HowTo — Modern Guides Site
   ============================= */

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

:root {
  /* Dark theme (default) */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-hover: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --accent-muted: rgba(88, 166, 255, 0.15);
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --sidebar-width: 280px;
  --header-height: 56px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
  --transition: 200ms ease;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-tertiary: #eaeef2;
  --bg-hover: #d0d7de;
  --text-primary: #1f2328;
  --text-secondary: #656d76;
  --text-muted: #8b949e;
  --border: #d0d7de;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --accent-muted: rgba(9, 105, 218, 0.1);
  --green: #1a7f37;
  --orange: #9a6700;
  --red: #cf222e;
  --purple: #8250df;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

/* --- Layout --- */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--transition), width var(--transition);
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.125rem;
}

.logo:hover {
  color: var(--text-primary);
}

.logo-icon {
  font-size: 1.25rem;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

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

.sidebar-search {
  position: relative;
  padding: 12px 16px;
}

.search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition);
}

#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

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

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

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 3px;
}

.nav-category {
  padding: 4px 20px 2px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 20px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: all var(--transition);
  border-left: 2px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--accent-muted);
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-muted);
  border-left-color: var(--accent);
  font-weight: 500;
}

.nav-item-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

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

.sidebar-version {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.sun-icon, .moon-icon {
  display: block;
}

[data-theme="dark"] .sun-icon {
  display: none;
}

[data-theme="light"] .moon-icon {
  display: none;
}

/* --- Overlay --- */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* --- Content --- */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.content-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 32px;
  min-height: var(--header-height);
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.mobile-menu-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.content-breadcrumb {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.breadcrumb-home {
  color: var(--text-muted);
}

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.content-body::-webkit-scrollbar {
  width: 8px;
}

.content-body::-webkit-scrollbar-track {
  background: transparent;
}

.content-body::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 4px;
}

.content-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --- Landing --- */
.landing {
  max-width: 800px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

.landing-header {
  text-align: center;
  padding: 48px 0 32px;
}

.landing-title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.landing-subtitle {
  color: var(--text-secondary);
  font-size: 1.0625rem;
  max-width: 500px;
  margin: 0 auto;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px 0;
}

.landing-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
}

.landing-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.landing-card-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
  display: block;
}

.landing-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.landing-card-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.landing-card-category {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-muted);
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 8px;
}

.landing-footer {
  text-align: center;
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* --- Guide Article --- */
.guide {
  max-width: 800px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

.guide-article {
  padding: 0 0 48px;
}

.guide-article h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.guide-article h2 {
  font-size: 1.375rem;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.guide-article h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 8px;
}

.guide-article p {
  margin-bottom: 16px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.guide-article ul, .guide-article ol {
  margin-bottom: 16px;
  padding-left: 24px;
  color: var(--text-secondary);
}

.guide-article li {
  margin-bottom: 4px;
}

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

.guide-article code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--orange);
}

.guide-article pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
  margin-bottom: 20px;
  position: relative;
}

.guide-article pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.guide-article blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 16px 0;
  background: var(--accent-muted);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.guide-article blockquote p {
  color: var(--text-secondary);
  margin-bottom: 0;
}

.guide-article table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 0.875rem;
}

.guide-article th {
  background: var(--bg-tertiary);
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  border: 1px solid var(--border);
}

.guide-article td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.guide-article tr:nth-child(even) td {
  background: var(--bg-secondary);
}

.guide-article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.guide-article img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* --- Search Results --- */
.search-results {
  max-width: 800px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

.search-results-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-result-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  cursor: pointer;
  transition: all var(--transition);
}

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

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

.search-result-item .desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.search-result-item .match {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

.search-result-item .match em {
  color: var(--accent);
  font-style: normal;
  font-weight: 500;
}

/* No results */
.no-results {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

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

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: block;
  }

  .overlay.active {
    display: block;
  }

  .mobile-menu-btn {
    display: block;
  }

  .content-header {
    padding: 0 16px;
  }

  .content-body {
    padding: 16px;
  }

  .landing-title {
    font-size: 1.75rem;
  }

  .landing-grid {
    grid-template-columns: 1fr;
  }

  .guide-article h1 {
    font-size: 1.5rem;
  }

  .guide-article table {
    font-size: 0.8125rem;
  }

  .guide-article pre {
    margin: 0 -16px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}

@media (max-width: 480px) {
  .landing-header {
    padding: 24px 0;
  }

  .landing-title {
    font-size: 1.5rem;
  }

  .guide-article h1 {
    font-size: 1.25rem;
  }
}