/* ============================================
   Article 2 — Server Networking & Reverse Proxy
   Scope: pages/reverse-proxy.html only
   ============================================ */

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

:root {
  --bg: #0a0e17;
  --bg-surface: #111827;
  --bg-card: #1a2332;
  --bg-code: #0d1321;
  --border: #1e2d42;
  --border-light: #2a3a52;
  --accent: #e8a838;
  --accent-dim: #c4882a;
  --accent-glow: rgba(232, 168, 56, 0.12);
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.12);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.1);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.1);
  --purple: #a78bfa;
  --text-primary: #e8edf5;
  --text-body: #b0bec9;
  --text-muted: #6b7d92;
  --text-dim: #4a5a6e;
  --sidebar-w: 280px;
  --mobile-bar-h: 56px;
  --bar-bg: rgba(10, 14, 23, 0.92);
}

/* ===== Light theme overrides ===== */
[data-theme='light'] {
  --bg: #fdfaf3;
  --bg-surface: #ffffff;
  --bg-card: #fef9ef;
  --bg-code: #f8f4ea;
  --border: #e5dcc8;
  --border-light: #d4c4a0;
  --accent: #b45309;
  --accent-dim: #92400e;
  --accent-glow: rgba(180, 83, 9, 0.08);
  --green: #15803d;
  --green-dim: rgba(21, 128, 61, 0.08);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.06);
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.06);
  --purple: #7c3aed;
  --text-primary: #1c1917;
  --text-body: #57534e;
  --text-muted: #78716c;
  --text-dim: #a8a29e;
  --bar-bg: rgba(253, 250, 243, 0.92);
}

[data-theme='light'] body::before {
  background:
    radial-gradient(ellipse at 15% 10%, rgba(180, 83, 9, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 85%, rgba(37, 99, 235, 0.02) 0%, transparent 50%);
}

[data-theme='light'] .mobile-bar {
  background: var(--bar-bg);
}

[data-theme='light'] .sidebar {
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.06);
}

[data-theme='light'] .sidebar-overlay {
  background: rgba(0, 0, 0, 0.35);
}

[data-theme='light'] pre .code-header {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme='light'] tr:hover td {
  background: rgba(0, 0, 0, 0.015);
}

[data-theme='light'] thead {
  background: rgba(180, 83, 9, 0.04);
}

/* Light-mode syntax highlighting */
[data-theme='light'] .cm { color: #a8a29e; }
[data-theme='light'] .kw { color: #7c3aed; }
[data-theme='light'] .fn { color: #2563eb; }
[data-theme='light'] .st { color: #15803d; }
[data-theme='light'] .nu { color: #c2410c; }
[data-theme='light'] .op { color: #0e7490; }
[data-theme='light'] .dc { color: #b45309; }
[data-theme='light'] .vr { color: #44403c; }

[data-theme='light'] .hero::after {
  background: radial-gradient(circle, rgba(180, 83, 9, 0.04) 0%, transparent 70%);
}

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

body {
  font-family: 'Noto Serif SC', 'Georgia', serif;
  background: var(--bg);
  color: var(--text-body);
  line-height: 1.85;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(232, 168, 56, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 85%, rgba(96, 165, 250, 0.02) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ====== Mobile Top Bar ====== */
.mobile-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--mobile-bar-h);
  background: var(--bar-bg, rgba(10, 14, 23, 0.92));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  align-items: center;
  padding: 0 16px;
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--accent);
  transition: border-color 0.2s ease;
}

.menu-toggle:hover {
  border-color: var(--accent);
}

.menu-toggle svg {
  width: 20px;
  height: 20px;
}

.menu-toggle .icon-close { display: none; }

.mobile-bar.open .menu-toggle .icon-menu { display: none; }
.mobile-bar.open .menu-toggle .icon-close { display: block; }

.mobile-bar-title {
  margin-left: 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Noto Serif SC', serif;
}

.mobile-bar-back {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.mobile-bar-back:hover { color: var(--accent); }
.mobile-bar-back svg { width: 14px; height: 14px; }

/* ====== Sidebar overlay (mobile) ====== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 180;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* ====== Sidebar ====== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.sidebar-header h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Noto Serif SC', serif;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.sidebar-header p {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
}

.sidebar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.sidebar-back:hover { color: var(--accent); }
.sidebar-back svg { width: 14px; height: 14px; }

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

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

.nav-group-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 14px 22px 6px;
}

.nav-link {
  display: block;
  padding: 7px 22px 7px 28px;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.2s ease;
  font-family: 'Noto Serif SC', serif;
  line-height: 1.5;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.nav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-glow);
}

.nav-link .num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-right: 6px;
}

/* ====== Main ====== */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.hero {
  padding: 80px 60px 60px;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(232, 168, 56, 0.05) 0%, transparent 70%);
  pointer-events: none;
}

.hero-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 16px;
  opacity: 0;
  animation: fadeUp 0.5s ease forwards;
}

.hero h2 {
  font-size: 2.6rem;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1.3;
  letter-spacing: -0.01em;
  opacity: 0;
  animation: fadeUp 0.5s ease 0.1s forwards;
}

.hero h2 span { color: var(--accent); }

.hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 16px;
  max-width: 600px;
  opacity: 0;
  animation: fadeUp 0.5s ease 0.2s forwards;
}

.content {
  padding: 50px 60px 80px;
  max-width: 960px;
}

/* ====== Sections ====== */
.section {
  margin-bottom: 64px;
  opacity: 0;
  animation: fadeUp 0.6s ease forwards;
}

.section:nth-child(1) { animation-delay: 0.1s; }
.section:nth-child(2) { animation-delay: 0.15s; }
.section:nth-child(3) { animation-delay: 0.2s; }
.section:nth-child(4) { animation-delay: 0.25s; }
.section:nth-child(5) { animation-delay: 0.3s; }
.section:nth-child(6) { animation-delay: 0.35s; }
.section:nth-child(7) { animation-delay: 0.4s; }

.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--accent-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.section > h3 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 28px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border);
  line-height: 1.4;
}

.section > h3 .hl {
  color: var(--accent);
  font-style: normal;
}

h4 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 32px 0 14px;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  line-height: 1.5;
}

h5 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 24px 0 10px;
}

p { margin-bottom: 14px; }

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

ul, ol {
  padding-left: 24px;
  margin-bottom: 14px;
}

li { margin-bottom: 6px; }

/* ====== Code ====== */
code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  background: var(--bg-code);
  color: var(--green);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  margin: 18px 0;
  overflow: hidden;
  position: relative;
}

pre .code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
}

pre .code-header .lang-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

pre .code-header .dots {
  display: flex;
  gap: 6px;
}

pre .code-header .dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-light);
}

pre .code-header .dots span:nth-child(1) { background: #f87171; }
pre .code-header .dots span:nth-child(2) { background: #eab308; }
pre .code-header .dots span:nth-child(3) { background: #4ade80; }

pre code {
  display: block;
  padding: 20px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.75;
  background: transparent;
  border: none;
  color: var(--text-body);
  -webkit-overflow-scrolling: touch;
}

pre code::-webkit-scrollbar { height: 5px; }
pre code::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* Syntax colors */
.cm { color: #5a6a7a; }
.kw { color: #c792ea; }
.fn { color: #82aaff; }
.st { color: #c3e88d; }
.nu { color: #f78c6c; }
.op { color: #89ddff; }
.dc { color: #e8a838; }
.vr { color: #f0ece4; }

/* ====== Tables ====== */
.table-wrap {
  overflow-x: auto;
  margin: 18px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead {
  background: rgba(232, 168, 56, 0.06);
}

th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 12px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-body);
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(255, 255, 255, 0.015); }

td code { font-size: 0.82em; }

/* ====== Diagram Blocks ====== */
.diagram {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  margin: 18px 0;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

.diagram .hl { color: var(--accent); }
.diagram .hl2 { color: var(--blue); }
.diagram .hl3 { color: var(--green); }

/* ====== Callouts ====== */
.callout {
  padding: 18px 22px;
  border-radius: 10px;
  margin: 18px 0;
  border-left: 3px solid;
}

.callout-info {
  background: var(--blue-dim);
  border-left-color: var(--blue);
}

.callout-warn {
  background: var(--red-dim);
  border-left-color: var(--red);
}

.callout-tip {
  background: var(--green-dim);
  border-left-color: var(--green);
}

.callout p:last-child { margin-bottom: 0; }

.callout-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.callout-info .callout-label { color: var(--blue); }
.callout-warn .callout-label { color: var(--red); }
.callout-tip .callout-label { color: var(--green); }

/* ====== Verdict Tag ====== */
.verdict {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 8px;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(232, 168, 56, 0.2);
  margin: 10px 0;
}

/* ====== Recommendation Cards ====== */
.rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.rec-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

.rec-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.rec-card .rec-scene {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.rec-card .rec-pick {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.rec-card .rec-reason {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ====== Footer ====== */
.footer {
  border-top: 1px solid var(--border);
  padding: 30px 60px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: 0.05em;
}

/* ====== Back to top ====== */
.back-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, border-color 0.2s ease;
  z-index: 150;
}

.back-top.show {
  opacity: 1;
  visibility: visible;
}

.back-top:hover {
  border-color: var(--accent);
}

.back-top svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

/* ====== Animations ====== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ====== Responsive — Tablet ====== */
@media (max-width: 1024px) {
  .hero { padding: 60px 40px 48px; }
  .hero h2 { font-size: 2.1rem; }
  .content { padding: 40px 40px 64px; }
  .footer { padding: 24px 40px; }
}

/* ====== Responsive — Mobile ====== */
@media (max-width: 900px) {
  .mobile-bar { display: flex; padding-right: 60px; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.4);
  }

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

  .main {
    margin-left: 0;
    padding-top: var(--mobile-bar-h);
  }

  .hero {
    padding: 36px 24px 32px;
  }

  .hero h2 {
    font-size: 1.6rem;
  }

  .hero-desc {
    font-size: 0.9rem;
  }

  .content {
    padding: 28px 20px 56px;
  }

  .section > h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
  }

  h4 {
    font-size: 1.05rem;
    margin: 24px 0 12px;
  }

  .section {
    margin-bottom: 44px;
  }

  .footer {
    padding: 20px 24px;
    font-size: 0.68rem;
  }

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

  .diagram {
    padding: 18px;
    font-size: 0.72rem;
  }

  pre code {
    font-size: 0.76rem;
    padding: 16px;
  }

  .callout {
    padding: 14px 16px;
  }

  .back-top {
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 480px) {
  .hero { padding: 28px 16px 24px; }
  .hero h2 { font-size: 1.35rem; }
  .hero-tag { font-size: 0.65rem; }
  .hero-desc { font-size: 0.85rem; }

  .mobile-bar { padding-right: 48px; }

  .content { padding: 20px 16px 48px; }

  .section > h3 { font-size: 1.15rem; }
  h4 { font-size: 0.98rem; }

  table { font-size: 0.78rem; }
  th, td { padding: 9px 12px; }

  .diagram {
    padding: 14px;
    font-size: 0.66rem;
    line-height: 1.6;
  }

  pre code {
    font-size: 0.7rem;
    padding: 14px;
  }

  .verdict {
    font-size: 0.78rem;
    padding: 6px 14px;
  }

  .callout {
    padding: 12px 14px;
  }

  .callout p { font-size: 0.86rem; }
}
