/* ==========================================================================
   NetLens — site styles
   Node.js-inspired: dark theme, green accents, system dark-mode toggle.
   ========================================================================== */

/* --- Light theme (default vars) --- */
:root {
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-card: #ffffff;
  --bg-code: #0d1117;
  --bg-terminal: #0d1117;
  --border: #d0d7de;
  --border-muted: #d8dee4;
  --text: #1f2328;
  --text-dim: #57606a;
  --accent: #2ea44f;
  --accent-strong: #1a7f37;
  --accent-2: #6CC24A;
  --green: #2ea44f;
  --green-hover: #2c974b;
  --amber: #9a6700;
  --red: #cf222e;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  --term-text: #e6edf3;
  --term-border: #30363d;
  --term-bar: #161b22;
  --term-comment: #8b949e;
  --term-prompt: #3fb950;
  --hero-glow: rgba(46, 164, 79, 0.14);
  --radius: 8px;
  --maxw: 1080px;
  --nav-h: 64px;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* --- Dark theme --- */
[data-theme="dark"] {
  --bg: #0d1117;
  --bg-subtle: #161b22;
  --bg-card: #161b22;
  --bg-code: #010409;
  --bg-terminal: #0d1117;
  --border: #30363d;
  --border-muted: #21262d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #3fb950;
  --accent-strong: #2ea043;
  --accent-2: #6CC24A;
  --green: #238636;
  --green-hover: #2ea043;
  --amber: #d29922;
  --red: #f85149;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --term-text: #e6edf3;
  --term-border: #30363d;
  --term-bar: #161b22;
  --term-comment: #8b949e;
  --term-prompt: #3fb950;
  --hero-glow: rgba(46, 160, 67, 0.10);
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 12px); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

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

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ==========================================================================
   Header / Nav
   ========================================================================== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-muted);
  transition: background 0.2s ease;
}
@supports not (background: color-mix(in srgb, var(--bg) 92%, transparent)) {
  header { background: var(--bg); }
}
.nav { display: flex; align-items: center; justify-content: space-between; height: var(--nav-h); gap: 16px; }
.brand img { height: 38px; display: block; }
.nav-links { display: flex; gap: 22px; align-items: center; }
.nav-links a {
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 5px 2px;
  transition: color 0.12s ease;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--text); font-weight: 600; }

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border-muted);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border); background: var(--bg-subtle); }
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.1s ease;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-card); color: var(--text); text-decoration: none; }
.btn svg { flex: none; }
.btn-primary {
  background: var(--green);
  border-color: rgba(240, 246, 252, 0.1);
  color: #ffffff;
  box-shadow: 0 1px 0 rgba(27, 31, 36, 0.1);
}
.btn-primary:hover { background: var(--green-hover); color: #ffffff; }
.btn-outline {
  background: transparent;
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn-lg { padding: 13px 26px; font-size: 1.05rem; border-radius: 8px; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }

/* Hamburger (mobile) */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.nav-toggle span {
  width: 22px; height: 2px;
  background: var(--text-dim);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  padding: 84px 0 76px;
  text-align: center;
  border-bottom: 1px solid var(--border-muted);
  background:
    radial-gradient(800px 340px at 50% -100px, var(--hero-glow), transparent),
    radial-gradient(600px 260px at 85% 20%, rgba(108, 194, 74, 0.05), transparent),
    var(--bg);
}
.hero-logo { margin-bottom: 18px; }
.hero-logo img { height: 66px; }
.hero h1 { font-size: 2.8rem; letter-spacing: -0.02em; margin-bottom: 12px; line-height: 1.12; font-weight: 800; }
.hero h1 span { color: var(--accent); }
.hero p.tagline {
  font-size: 1.15rem;
  color: var(--text-dim);
  max-width: 660px;
  margin: 0 auto 32px;
}

/* ==========================================================================
   Premium terminal window (hero)
   ========================================================================== */
.terminal-wrap { max-width: 720px; margin: 0 auto 32px; }
.terminal {
  background: var(--bg-terminal);
  border-radius: 12px;
  border: 1px solid var(--term-border);
  box-shadow: var(--shadow), 0 0 60px rgba(63, 185, 80, 0.07);
  text-align: left;
  overflow: hidden;
}
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--term-bar);
  border-bottom: 1px solid var(--term-border);
}
.terminal-bar .dot { width: 12px; height: 12px; border-radius: 50%; }
.terminal-bar .dot:nth-child(1) { background: #ff5f56; }
.terminal-bar .dot:nth-child(2) { background: #ffbd2e; }
.terminal-bar .dot:nth-child(3) { background: #27c93f; }
.terminal-bar .t-title {
  margin-left: 10px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--term-comment);
  flex: 1;
  text-align: center;
}
.terminal-body { padding: 22px 24px; position: relative; }
.terminal-body pre {
  background: none;
  border: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--term-text);
  overflow-x: auto;
}
.terminal-body pre code { color: var(--term-text); background: none; border: none; padding: 0; white-space: pre; }
.terminal-body .prompt { color: var(--term-prompt); font-weight: 600; }
.terminal-body .comment { color: var(--term-comment); font-style: italic; }
.terminal-body .cmd { color: var(--term-text); }

.terminal-copy {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--term-comment);
  background: rgba(110, 118, 129, 0.12);
  border: 1px solid var(--term-border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.terminal-copy:hover { background: rgba(110, 118, 129, 0.22); color: var(--term-text); }
.terminal-copy.copied { color: #3fb950; border-color: #3fb950; }

/* Badges */
.badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 4px; }
.badges img { height: 22px; border-radius: 4px; }

/* CTA row */
.cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-bottom: 30px; }

/* ==========================================================================
   Sections
   ========================================================================== */
section { padding: 64px 0; }
section.alt { background: var(--bg-subtle); border-top: 1px solid var(--border-muted); border-bottom: 1px solid var(--border-muted); }
section h2 { font-size: 1.7rem; margin-bottom: 8px; letter-spacing: -0.01em; }
section .lead { color: var(--text-dim); margin-bottom: 32px; max-width: 720px; }
section .lead.center { margin-left: auto; margin-right: auto; text-align: center; }
section h3 { font-size: 1.12rem; margin: 26px 0 10px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: 10px;
  padding: 26px 24px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.card h3 { font-size: 1.05rem; margin-bottom: 10px; color: var(--text); display: flex; align-items: center; gap: 10px; margin-top: 0; }
.card h3 svg { flex: none; }
.card p { font-size: 0.93rem; color: var(--text-dim); }
.card code { font-size: 0.85em; }
.card a { font-weight: 600; }

/* ==========================================================================
   Code blocks with copy
   ========================================================================== */
.code-block { position: relative; margin: 16px 0; }
.code-block pre {
  background: var(--bg-code);
  border: 1px solid var(--border-muted);
  border-radius: 10px;
  padding: 18px 22px;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.6;
}
.code-block pre code {
  font-family: var(--font-mono);
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  white-space: pre;
}
.code-block .copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 5px 12px;
  font-size: 0.76rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.code-block:hover .copy-btn { opacity: 1; }
.code-block .copy-btn:hover { background: var(--bg-subtle); color: var(--text); }
.code-block .copy-btn.copied { color: var(--accent); border-color: var(--accent); opacity: 1; }
.code-block .c { color: var(--text-dim); font-style: italic; }
.code-block .g { color: var(--accent); font-weight: 600; }
.code-block .k { color: var(--accent-2); }

/* Inline code */
code {
  font-family: var(--font-mono);
  background: color-mix(in srgb, var(--border) 30%, transparent);
  border-radius: 5px;
  padding: 2px 5px;
  font-size: 0.86em;
  color: var(--accent);
}
@supports not (background: color-mix(in srgb, var(--border) 30%, transparent)) {
  code { background: var(--bg-subtle); }
}
pre code { background: none; border: none; color: inherit; padding: 0; }

/* ==========================================================================
   Lists / tables
   ========================================================================== */
ul.tick { list-style: none; margin: 12px 0; }
ul.tick li { padding: 7px 0 7px 26px; position: relative; color: var(--text-dim); }
ul.tick li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 15px;
  width: 9px;
  height: 4.5px;
  border-left: 2px solid var(--green);
  border-bottom: 2px solid var(--green);
  transform: rotate(-45deg);
}
ul.tick li strong { color: var(--text); }

ol.steps { list-style: none; counter-reset: step; margin: 12px 0; }
ol.steps > li {
  counter-increment: step;
  padding: 8px 0 8px 38px;
  position: relative;
  color: var(--text-dim);
}
ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 9px;
  width: 24px; height: 24px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.8rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 14px; border: 1px solid var(--border-muted); }
th { background: var(--bg-subtle); color: var(--text); font-weight: 600; }
td { color: var(--text-dim); }
td code, th code { white-space: nowrap; }

/* ==========================================================================
   Callouts
   ========================================================================== */
.note {
  background: var(--bg-subtle);
  border: 1px solid var(--border-muted);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 0.94rem;
  margin: 18px 0;
  color: var(--text-dim);
}
.note strong { color: var(--text); }
.note.info { border-left: 4px solid var(--accent); }
.note.warn { border-left: 4px solid var(--amber); background: color-mix(in srgb, #d4a72c 8%, var(--bg-subtle)); border-color: color-mix(in srgb, #d4a72c 40%, var(--border-muted)); }
.note.warn strong { color: var(--amber); }
.note.ok { border-left: 4px solid var(--green); background: color-mix(in srgb, var(--green) 8%, var(--bg-subtle)); border-color: color-mix(in srgb, var(--green) 35%, var(--border-muted)); }
.note.ok strong { color: var(--accent); }
.note.danger { border-left: 4px solid var(--red); background: color-mix(in srgb, var(--red) 8%, var(--bg-subtle)); border-color: color-mix(in srgb, var(--red) 35%, var(--border-muted)); }
.note.danger strong { color: var(--red); }

/* ==========================================================================
   Docs page
   ========================================================================== */
.docs-layout { display: grid; grid-template-columns: 250px 1fr; gap: 40px; align-items: start; }
.docs-toc {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
  background: var(--bg-card);
  border: 1px solid var(--border-muted);
  border-radius: 10px;
  padding: 16px 14px;
  font-size: 0.88rem;
  max-height: calc(100vh - var(--nav-h) - 48px);
  overflow-y: auto;
}
.docs-toc h4 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 12px; padding: 0 8px; }
.docs-toc ol { list-style: none; counter-reset: toc; }
.docs-toc ol li { counter-increment: toc; margin: 1px 0; }
.docs-toc ol li a {
  display: block;
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 6px;
  transition: background 0.12s ease, color 0.12s ease;
}
.docs-toc ol li a::before { content: counter(toc) ". "; color: var(--accent); font-weight: 600; }
.docs-toc ol li a:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.docs-toc ol li a.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); font-weight: 600; }

.docs-breadcrumb { font-size: 0.92rem; margin-bottom: 20px; color: var(--text-dim); }
.docs-breadcrumb a { color: var(--accent); }

article h1 { font-size: 1.9rem; letter-spacing: -0.02em; margin-bottom: 10px; }
article h2 { font-size: 1.35rem; margin: 44px 0 12px; padding-top: 8px; scroll-margin-top: calc(var(--nav-h) + 16px); }
article h2:first-of-type { margin-top: 20px; }
article h3 { font-size: 1.05rem; margin: 26px 0 8px; color: var(--text); }
article p { color: var(--text-dim); margin: 12px 0; }
article ul, article ol { color: var(--text-dim); margin: 12px 0 12px 22px; }
article li { margin: 6px 0; }
article .sub { color: var(--text-dim); font-size: 0.98rem; margin-bottom: 26px; }

/* ==========================================================================
   Footer
   ========================================================================== */
footer {
  border-top: 1px solid var(--border-muted);
  padding: 36px 0;
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  margin-top: 40px;
  background: var(--bg);
}
footer a { color: var(--text-dim); }
footer a:hover { color: var(--accent); text-decoration: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 860px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-toc { position: static; max-height: none; }
}

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border-muted);
    padding: 10px 24px 16px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 4px; }
  .nav-links .theme-toggle { align-self: flex-start; margin-top: 8px; }
  .hero { padding: 56px 0 48px; }
  .hero h1 { font-size: 2rem; }
  .hero p.tagline { font-size: 1.02rem; }
  .hero-logo img { height: 52px; }
  .terminal-body { padding: 16px 18px; }
  .terminal-body pre { font-size: 0.8rem; }
  section { padding: 44px 0; }
  article h1 { font-size: 1.5rem; }
  article h2 { font-size: 1.2rem; }
  .code-block pre { font-size: 0.8rem; padding: 14px 16px; }
  .code-block .copy-btn { opacity: 1; }
}
