/* ============================================
   Article 1 — Cloud Server Traffic Guide
   Scope: pages/cloud-server.html only
   ============================================ */

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

:root {
  --bg-deep: #06080c;
  --bg: #0b0e14;
  --surface: #111720;
  --surface-raised: #171d28;
  --border: #1e2736;
  --border-accent: #1a3a5c;
  --accent: #22d3ee;
  --accent-dim: #0e7490;
  --accent-glow: rgba(34, 211, 238, 0.12);
  --green: #34d399;
  --green-dim: #065f46;
  --red: #f87171;
  --red-dim: #7f1d1d;
  --yellow: #fbbf24;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #4b5b73;
  --font-display: 'Noto Serif SC', serif;
  --font-body: 'Noto Sans SC', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --topbar-h: 56px;
  --topbar-bg: rgba(11, 14, 20, 0.85);
}

/* ===== Light theme overrides ===== */
[data-theme='light'] {
  --bg-deep: #f0f9ff;
  --bg: #ffffff;
  --surface: #f8fafc;
  --surface-raised: #f1f5f9;
  --border: #e2e8f0;
  --border-accent: #bae6fd;
  --accent: #0891b2;
  --accent-dim: #0e7490;
  --accent-glow: rgba(8, 145, 178, 0.08);
  --green: #059669;
  --green-dim: #d1fae5;
  --red: #dc2626;
  --red-dim: #fee2e2;
  --yellow: #d97706;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --topbar-bg: rgba(255, 255, 255, 0.85);
}

[data-theme='light'] body::after {
  opacity: 0.015;
}

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

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

/* Light-mode syntax highlighting (darker colors for readability) */
[data-theme='light'] .kw { color: #7c3aed; }
[data-theme='light'] .fn { color: #0369a1; }
[data-theme='light'] .str { color: #15803d; }
[data-theme='light'] .cm { color: #94a3b8; }
[data-theme='light'] .op { color: #c2410c; }
[data-theme='light'] .ip { color: #be185d; }
[data-theme='light'] .arrow { color: #0891b2; }

[data-theme='light'] .callout-info {
  background: rgba(8, 145, 178, 0.04);
}

[data-theme='light'] .callout-warn {
  background: rgba(217, 119, 6, 0.04);
}

[data-theme='light'] .callout-success {
  background: rgba(5, 150, 105, 0.04);
}

[data-theme='light'] .pros-card {
  background: rgba(5, 150, 105, 0.03);
}

[data-theme='light'] .cons-card {
  background: rgba(220, 38, 38, 0.03);
}

[data-theme='light'] tbody tr:hover {
  background: rgba(8, 145, 178, 0.04);
}

html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) var(--bg);
  scroll-padding-top: calc(var(--topbar-h) + 20px);
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.85;
  font-weight: 400;
  overflow-x: hidden;
}

/* Grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

/* Subtle grain */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ===== Top Bar ===== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--topbar-bg, rgba(11, 14, 20, 0.85));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  display: flex;
  align-items: center;
  padding: 0 64px 0 24px;
}

.topbar-back {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

.topbar-back svg {
  width: 16px;
  height: 16px;
}

.topbar-title {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ===== Page ===== */
.page {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: calc(var(--topbar-h) + 40px) 32px 120px;
}

/* ===== HEADER ===== */
.hero {
  padding: 60px 0 48px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
  position: relative;
}

.hero::before {
  content: 'HOME NETWORK GUIDE';
  position: absolute;
  top: 20px;
  left: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.35em;
  color: var(--accent-dim);
  text-transform: uppercase;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 900;
  line-height: 1.25;
  color: var(--text-primary);
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

.hero h1 span {
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent-glow);
}

.hero-desc {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 680px;
  line-height: 1.9;
}

.hero-desc strong {
  color: var(--accent);
  font-weight: 500;
}

/* ===== TOC ===== */
.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 28px 32px;
  margin-bottom: 48px;
}

.toc-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

.toc ol {
  list-style: none;
  counter-reset: toc-counter;
}

.toc li {
  counter-increment: toc-counter;
  margin-bottom: 6px;
}

.toc li::before {
  content: counter(toc-counter, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-right: 12px;
}

.toc a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

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

/* ===== SECTIONS ===== */
.section {
  margin-bottom: 64px;
  animation: fadeUp 0.5s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-number {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent-dim);
  margin-bottom: 8px;
  display: block;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}

h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 36px 0 16px;
}

h4 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 28px 0 12px;
}

p {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

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

/* ===== CODE ===== */
.code-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 24px 0;
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
}

.code-block-header .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.code-block-header .dot:nth-child(1) { background: #f87171; }
.code-block-header .dot:nth-child(2) { background: #fbbf24; }
.code-block-header .dot:nth-child(3) { background: #34d399; }

.code-block-header .label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: 8px;
  letter-spacing: 0.05em;
}

.code-block pre {
  padding: 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--text-secondary);
}

.code-block code {
  font-family: inherit;
}

code.inline {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--accent);
}

/* Syntax highlighting */
.kw { color: #c084fc; }
.fn { color: #67e8f9; }
.str { color: #86efac; }
.cm { color: var(--text-muted); font-style: italic; }
.op { color: var(--yellow); }
.ip { color: #f0abfc; }
.arrow { color: var(--accent); font-weight: 600; }

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

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

thead th {
  background: var(--surface-raised);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

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

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

tbody tr:hover {
  background: var(--accent-glow);
}

td:first-child {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ===== CALLOUT BOXES ===== */
.callout {
  border-radius: 8px;
  padding: 20px 24px;
  margin: 24px 0;
  border-left: 3px solid;
}

.callout-info {
  background: rgba(34, 211, 238, 0.05);
  border-color: var(--accent);
}

.callout-info .callout-icon { color: var(--accent); }

.callout-warn {
  background: rgba(251, 191, 36, 0.05);
  border-color: var(--yellow);
}

.callout-warn .callout-icon { color: var(--yellow); }

.callout-success {
  background: rgba(52, 211, 153, 0.05);
  border-color: var(--green);
}

.callout-success .callout-icon { color: var(--green); }

.callout-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.callout p {
  margin-bottom: 0;
  font-size: 0.92rem;
}

/* ===== LISTS ===== */
ul, ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

li {
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-left: 4px;
}

li strong {
  color: var(--text-primary);
}

/* ===== PROS / CONS ===== */
.pros-cons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 24px 0;
}

.pros-card, .cons-card {
  border-radius: 8px;
  padding: 24px;
  border: 1px solid var(--border);
}

.pros-card {
  background: rgba(52, 211, 153, 0.03);
  border-color: var(--green-dim);
}

.cons-card {
  background: rgba(248, 113, 113, 0.03);
  border-color: var(--red-dim);
}

.pros-card h4 { color: var(--green); margin-top: 0; }
.cons-card h4 { color: var(--red); margin-top: 0; }

.pros-card li::marker { color: var(--green); }
.cons-card li::marker { color: var(--red); }

/* ===== SECURITY LIST ===== */
.security-list {
  counter-reset: sec-counter;
  list-style: none;
  padding-left: 0;
}

.security-list li {
  counter-increment: sec-counter;
  padding: 14px 18px 14px 52px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 10px;
  position: relative;
}

.security-list li::before {
  content: counter(sec-counter);
  position: absolute;
  left: 16px;
  top: 14px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-glow);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== ALTERNATIVES ===== */
.alt-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.alt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

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

.alt-card h4 {
  margin-top: 0;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.alt-card p {
  font-size: 0.88rem;
  margin-bottom: 0;
}

/* ===== BEST PRACTICE CHECKLIST ===== */
.checklist {
  list-style: none;
  padding: 0;
}

.checklist li {
  padding: 10px 0 10px 32px;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.checklist li:last-child { border-bottom: none; }

.checklist li::before {
  content: '\2713';
  position: absolute;
  left: 4px;
  top: 10px;
  color: var(--green);
  font-weight: 700;
  font-size: 0.9rem;
}

/* ===== FOOTER ===== */
.footer {
  margin-top: 80px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer p {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== GOLDEN COMBO DIAGRAM ===== */
.combo-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.combo-node {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 18px;
  color: var(--text-secondary);
  text-align: center;
}

.combo-node.highlight {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-glow);
}

.combo-arrow {
  color: var(--accent-dim);
  font-size: 1.1rem;
}

/* ===== Back to top ===== */
.back-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-raised);
  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);
}

/* ===== SCROLL ANIMATIONS ===== */
.section {
  opacity: 0;
}

.section.visible {
  opacity: 1;
  transition: opacity 0.6s ease, transform 0.6s ease;
  transform: translateY(0) !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .page { padding: calc(var(--topbar-h) + 24px) 20px 80px; }
  .hero { padding: 40px 0 32px; }
  .hero h1 { font-size: 1.5rem; }
  .hero-desc { font-size: 0.95rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }
  .toc { padding: 20px; }
  .toc-title { font-size: 0.7rem; }
  .toc a { font-size: 0.88rem; }

  .pros-cons { grid-template-columns: 1fr; gap: 14px; }
  .pros-card, .cons-card { padding: 18px; }

  .alt-cards { grid-template-columns: 1fr; }

  .code-block pre { font-size: 0.76rem; padding: 16px; }
  .callout { padding: 16px 18px; }
  .callout p { font-size: 0.86rem; }

  .security-list li { padding: 12px 14px 12px 48px; }

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

@media (max-width: 480px) {
  .topbar { padding: 0 52px 0 16px; }
  .topbar-title { display: none; }
  .page { padding: calc(var(--topbar-h) + 16px) 16px 64px; }
  .hero { padding: 28px 0 24px; }
  .hero::before { font-size: 9px; top: 12px; letter-spacing: 0.25em; }
  .hero h1 { font-size: 1.3rem; }
  .hero-desc { font-size: 0.88rem; line-height: 1.8; }
  h2 { font-size: 1.15rem; margin-bottom: 20px; }
  h3 { font-size: 1rem; }
  .toc { padding: 16px; margin-bottom: 32px; }
  .section { margin-bottom: 44px; }

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

  .combo-flow { flex-direction: column; gap: 8px; }
  .combo-arrow { transform: rotate(90deg); }
  .combo-node { padding: 8px 14px; font-size: 0.76rem; }

  .code-block pre { font-size: 0.72rem; padding: 14px; }

  .alt-card { padding: 18px; }
  .pros-card, .cons-card { padding: 16px; }

  .footer p { font-size: 0.68rem; }
}
