@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;0,6..72,700;0,6..72,800;1,6..72,400;1,6..72,500&family=DM+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --surface-tint: #F4F3EF;
  --border: #E8E6E1;
  --border-strong: #D4D1CB;
  --text: #1C1917;
  --text-secondary: #57534E;
  --dim: #A8A29E;
  --accent: #1D4ED8;
  --accent-light: #EFF6FF;
  --accent-border: #BFDBFE;
  --green: #15803D;
  --green-bg: #F0FDF4;
  --amber: #B45309;
  --amber-bg: #FFFBEB;
  --red: #B91C1C;
  --red-bg: #FEF2F2;
  --radius: 8px;
  --max-w: 740px;
  --font-display: 'Newsreader', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --font-mono: 'DM Mono', 'Menlo', monospace;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* --- Nav --- */
.wiki-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 32px;
  background: rgba(250,250,247,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.wiki-nav a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.wiki-nav a:hover { text-decoration: underline; }
.wiki-breadcrumb {
  color: var(--dim);
  font-weight: 500;
}
.wiki-breadcrumb::before {
  content: '/';
  margin-right: 12px;
  color: var(--border-strong);
}

/* --- Article --- */
.wiki-article {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 56px 32px 96px;
}
.wiki-article h1 {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 6px;
  color: var(--text);
}
.wiki-article h1 span {
  font-style: italic;
  color: var(--accent);
}
.wiki-meta {
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.wiki-article h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 56px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.wiki-article h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  margin: 32px 0 10px;
  color: var(--text);
}
.wiki-article p {
  margin-bottom: 16px;
  font-size: 15px;
  color: var(--text-secondary);
}
.wiki-article strong { color: var(--text); font-weight: 600; }
.wiki-article a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-border); text-underline-offset: 2px; }
.wiki-article a:hover { text-decoration-color: var(--accent); }
.wiki-article ul, .wiki-article ol {
  margin: 0 0 16px 20px;
  font-size: 15px;
  color: var(--text-secondary);
}
.wiki-article li { margin-bottom: 5px; }
.wiki-article li::marker { color: var(--dim); }
.wiki-article li strong { color: var(--text); }

/* --- Code --- */
code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface-tint);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 12px 0 24px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.65;
  position: relative;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-secondary);
}
pre .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--dim);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
pre:hover .copy-btn { opacity: 1; }
pre .copy-btn:hover { background: var(--border); color: var(--text); }
pre .copy-btn.copied { color: var(--green); }

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 28px;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
th {
  text-align: left;
  padding: 10px 14px;
  background: var(--surface-tint);
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-tint); }
td strong { color: var(--text); font-weight: 600; }

/* --- Comparison Cards --- */
.compare-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 24px 0 32px;
}
.compare-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.compare-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.compare-card h4 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}
.compare-card .card-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 14px;
}
.compare-card .card-tag.tag-good { background: var(--green-bg); color: var(--green); }
.compare-card .card-tag.tag-mid { background: var(--amber-bg); color: var(--amber); }
.compare-card .card-tag.tag-best { background: var(--accent-light); color: var(--accent); }
.compare-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.compare-card li {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 3px 0 3px 18px;
  position: relative;
}
.compare-card li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dim);
}
.compare-card li.pro::before { background: var(--green); }
.compare-card li.con::before { background: var(--red); }
.compare-card li.neutral::before { background: var(--amber); }

/* --- Verdict Box --- */
.verdict {
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 28px 0;
}
.verdict h4 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}
.verdict p { margin-bottom: 0; }

/* --- Wiki Home --- */
.wiki-home {
  max-width: 860px;
  margin: 0 auto;
  padding: 72px 32px;
}
.wiki-home h1 {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  color: var(--text);
}
.wiki-home h1 em {
  font-style: italic;
  color: var(--accent);
}
.wiki-home .subtitle {
  color: var(--dim);
  font-size: 16px;
  margin-bottom: 48px;
}
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.article-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s cubic-bezier(0.16,1,0.3,1);
}
.article-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 16px rgba(0,0,0,0.05);
  transform: translateY(-1px);
}
.article-card .card-category {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 8px;
}
.article-card h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.article-card p {
  font-size: 13px;
  color: var(--dim);
  line-height: 1.5;
}

/* --- Architecture Diagram Components --- */
/* Reusable across all wiki pages — see WIKI-GUIDE.md for usage rules */

/* Diagram wrapper & title */
.diagram-wrapper { margin: 28px 0 36px; }
.diagram-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

/* Container box — represents a Docker container or service */
.d-box {
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  position: relative;
  transition: box-shadow 0.2s;
}
.d-box:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.d-box-name { font-weight: 700; font-size: 11.5px; margin-bottom: 2px; }
.d-box-detail { color: var(--dim); font-size: 10px; }

/* Container color themes (see WIKI-GUIDE.md for color coding rules) */
.d-box.theme-gray   { border-color: #9CA3AF; border-left: 3px solid #9CA3AF; }
.d-box.theme-purple  { border-color: #A78BFA; border-left: 3px solid #7C3AED; }
.d-box.theme-green   { border-color: #6EE7B7; border-left: 3px solid #059669; }
.d-box.theme-blue    { border-color: #93C5FD; border-left: 3px solid #2563EB; }
.d-box.theme-amber   { border-color: #FCD34D; border-left: 3px solid #D97706; }
.d-box.theme-red     { border-color: #FCA5A5; border-left: 3px solid #DC2626; }
.d-box.theme-slate   { border-color: #CBD5E1; border-left: 3px solid #64748B; background: #F8FAFC; }

.d-box-name.c-gray   { color: #6B7280; }
.d-box-name.c-purple { color: #7C3AED; }
.d-box-name.c-green  { color: #059669; }
.d-box-name.c-blue   { color: #2563EB; }
.d-box-name.c-amber  { color: #D97706; }
.d-box-name.c-red    { color: #DC2626; }
.d-box-name.c-slate  { color: #475569; }

/* Tech tag pills */
.d-tag {
  display: inline-block;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 3px;
  margin-top: 4px;
}
.d-tag.t-purple { background: #EDE9FE; color: #7C3AED; }
.d-tag.t-green  { background: #ECFDF5; color: #059669; }
.d-tag.t-blue   { background: #EFF6FF; color: #2563EB; }
.d-tag.t-amber  { background: #FFFBEB; color: #D97706; }
.d-tag.t-red    { background: #FEF2F2; color: #DC2626; }
.d-tag.t-gray   { background: #F3F4F6; color: #6B7280; }
.d-tag.t-slate  { background: #F1F5F9; color: #475569; }

/* Port badge — sits inside top-right corner of a d-box */
.port-badge {
  position: absolute;
  top: 0;
  right: 0;
  font-family: var(--font-mono);
  border-radius: 0 4px 0 5px;
  overflow: hidden;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  line-height: 1;
  display: flex;
  flex-direction: column;
}
.port-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 2.5px 0;
}
.port-label {
  font-size: 7px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  width: 22px;
  text-align: center;
  padding: 0 3px;
  flex-shrink: 0;
}
.port-val {
  font-size: 9px;
  font-weight: 500;
  padding: 0 6px 0 0;
  white-space: nowrap;
}
/* EXT row — port exposed to host */
.port-row.ext { background: #ECFDF5; border-bottom: 1px solid #D1FAE5; }
.port-row.ext .port-label { color: #059669; background: #D1FAE5; }
.port-row.ext .port-val { color: #065F46; }
/* EXT row — not exposed */
.port-row.ext.none { background: var(--surface-tint); border-bottom: 1px solid var(--border); }
.port-row.ext.none .port-label { color: var(--border-strong); background: var(--surface-tint); }
.port-row.ext.none .port-val { color: var(--border-strong); font-size: 8px; }
/* INT row — container-internal port */
.port-row.int { background: var(--surface-tint); }
.port-row.int .port-label { color: var(--text-secondary); background: var(--surface-tint); }
.port-row.int .port-val { color: var(--text-secondary); }

/* Docker compose wrapper */
.docker-arch {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  position: relative;
}
.docker-arch-label {
  position: absolute;
  top: -11px;
  left: 20px;
  background: var(--bg);
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}
.docker-arch-network {
  position: absolute;
  top: -11px;
  right: 20px;
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  padding: 1px 8px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--accent);
}

/* Grid layers inside Docker wrapper */
.docker-layer { display: grid; gap: 10px; margin-bottom: 14px; }
.docker-layer-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  margin-bottom: 6px;
  padding-left: 2px;
}
.docker-layer.l-web { grid-template-columns: 1fr 2fr 1fr; }
.docker-layer.l-work { grid-template-columns: 1fr 1fr 1.5fr; }
.docker-layer.l-monitor { grid-template-columns: 1.2fr 1fr; }
.docker-divider { border: none; border-top: 1px dashed var(--border); margin: 6px 0 10px; }

/* Webhook arrow connector */
.webhook-arrow { display: flex; align-items: center; gap: 6px; margin: 8px 0; padding: 0 8px; }
.webhook-line { flex: 1; height: 0; border-top: 2px dashed #D97706; }
.webhook-label { font-family: var(--font-mono); font-size: 9px; color: #D97706; font-weight: 600; white-space: nowrap; background: #FFFBEB; padding: 2px 6px; border-radius: 3px; border: 1px solid #FDE68A; }
.webhook-tip { width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 8px solid #D97706; }

/* External servers section */
.external-servers { margin-top: 20px; }
.external-servers-label { font-family: var(--font-mono); font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); margin-bottom: 8px; padding-left: 2px; }
.external-servers-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.scrape-indicator { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; padding-left: 4px; }
.scrape-line { width: 40px; border-top: 2px dashed #D97706; }
.scrape-label { font-family: var(--font-mono); font-size: 9px; color: #D97706; font-weight: 500; }

/* Vertical flow steps (no horizontal scrolling!) */
.vflow { display: flex; flex-direction: column; gap: 0; margin: 20px 0 28px; }
.vflow-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-bottom: none;
  position: relative;
}
.vflow-step:first-child { border-radius: 8px 8px 0 0; }
.vflow-step:last-child { border-bottom: 1.5px solid var(--border-strong); border-radius: 0 0 8px 8px; }
.vflow-step::after {
  content: '↓';
  position: absolute;
  bottom: -14px;
  left: 28px;
  font-size: 13px;
  color: var(--border-strong);
  z-index: 1;
  background: var(--bg);
  width: 18px;
  text-align: center;
}
.vflow-step:last-child::after { display: none; }
.vflow-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid;
}
.vflow-num.n-slate  { background: #F1F5F9; color: #475569; border-color: #94A3B8; }
.vflow-num.n-amber  { background: #FFFBEB; color: #B45309; border-color: #FBBF24; }
.vflow-num.n-red    { background: #FEF2F2; color: #B91C1C; border-color: #F87171; }
.vflow-num.n-green  { background: #ECFDF5; color: #059669; border-color: #34D399; }
.vflow-num.n-blue   { background: #EFF6FF; color: #1D4ED8; border-color: #60A5FA; }
.vflow-body h4 { font-family: var(--font-mono); font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.vflow-body h4.c-slate { color: #475569; }
.vflow-body h4.c-amber { color: #B45309; }
.vflow-body h4.c-red   { color: #B91C1C; }
.vflow-body h4.c-green { color: #059669; }
.vflow-body h4.c-blue  { color: #1D4ED8; }
.vflow-body p { font-size: 12px; color: var(--text-secondary); margin: 0; line-height: 1.5; }

/* Sequence diagram rows */
.seq { margin: 20px 0 28px; }
.seq-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--surface-tint); }
.seq-row:last-child { border-bottom: none; }
.seq-from, .seq-to { font-family: var(--font-mono); font-size: 10px; font-weight: 700; padding: 4px 8px; border-radius: 4px; text-align: center; min-width: 90px; white-space: nowrap; }
.seq-from.sf-slate, .seq-to.sf-slate { background: #F1F5F9; color: #475569; border: 1px solid #CBD5E1; }
.seq-from.sf-amber, .seq-to.sf-amber { background: #FFFBEB; color: #B45309; border: 1px solid #FDE68A; }
.seq-from.sf-red, .seq-to.sf-red { background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA; }
.seq-from.sf-green, .seq-to.sf-green { background: #ECFDF5; color: #059669; border: 1px solid #A7F3D0; }
.seq-from.sf-blue, .seq-to.sf-blue { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.seq-msg { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.seq-arrow { color: var(--border-strong); font-size: 14px; flex-shrink: 0; }
.seq-line { flex: 1; border-top: 1.5px solid var(--border); }
.seq-line.dashed { border-top-style: dashed; }
.seq-line.thick { border-top: 2px solid #D97706; }
.seq-line.green { border-top: 2px solid #059669; }
.seq-line.red { border-top: 2px solid #DC2626; }
.seq-label { font-family: var(--font-mono); font-size: 10px; color: var(--dim); white-space: nowrap; }
.seq-section { font-family: var(--font-mono); font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); padding: 12px 0 4px; border-bottom: 1px dashed var(--border); margin-bottom: 4px; }

@media (max-width: 800px) {
  .compare-grid { grid-template-columns: 1fr; }
  .docker-layer { grid-template-columns: 1fr !important; }
}
@media (max-width: 640px) {
  .wiki-article { padding: 32px 16px 64px; }
  .wiki-article h1 { font-size: 28px; }
  .wiki-home h1 { font-size: 32px; }
  .wiki-nav { padding: 12px 16px; }
}
