/* ═══════════════════════════════════════════════════════════
   K8s SRE Reference — Shared Stylesheet
   All pages link to this file via: ../assets/style.css
   (or ./assets/style.css from index.html)
═══════════════════════════════════════════════════════════ */

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

:root {
  --sidebar-w: 268px;
  --topbar-h:  56px;

  /* Light theme */
  --bg:               #f9f9f8;
  --surface:          #ffffff;
  --surface-2:        #f3f3f1;
  --border:           #e5e5e3;
  --text:             #1a1a18;
  --text-2:           #5a5a56;
  --text-3:           #9a9a94;
  --accent:           #0f7aff;
  --accent-light:     #e8f2ff;
  --accent-dark:      #0060cc;
  --tag-bg:           #edf2ff;
  --tag-text:         #2563eb;
  --warn-bg:          #fff8e6;
  --warn-border:      #f5a623;
  --warn-text:        #7a4f00;
  --tip-bg:           #edfaf3;
  --tip-border:       #22c55e;
  --tip-text:         #145c30;
  --sidebar-bg:       #ffffff;
  --sidebar-active-bg:#e8f2ff;
  --sidebar-active:   #0060cc;
  --sidebar-hover:    #f3f3f1;

  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);

  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="dark"] {
  --bg:               #0f0f0e;
  --surface:          #1a1a18;
  --surface-2:        #242422;
  --border:           #2e2e2c;
  --text:             #f0f0ee;
  --text-2:           #a0a09a;
  --text-3:           #606060;
  --accent:           #3b9eff;
  --accent-light:     #0f2a4a;
  --accent-dark:      #6ab8ff;
  --tag-bg:           #1a2a3a;
  --tag-text:         #6ab8ff;
  --warn-bg:          #2a1f00;
  --warn-border:      #a06820;
  --warn-text:        #f5c842;
  --tip-bg:           #0a2010;
  --tip-border:       #1a7a3a;
  --tip-text:         #5ad68a;
  --sidebar-bg:       #1a1a18;
  --sidebar-active-bg:#0f2a4a;
  --sidebar-active:   #6ab8ff;
  --sidebar-hover:    #242422;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Bar ──────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 100;
  box-shadow: var(--shadow);
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.topbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  padding: 7px 12px 7px 36px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .875rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.topbar-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

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

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.theme-toggle:hover { background: var(--border); color: var(--text); }

.hamburger {
  display: none;
  width: 36px; height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}

/* ── Layout ───────────────────────────────────────────────── */
.layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--topbar-h);
  bottom: 0; left: 0;
  overflow-y: auto;
  padding: 16px 0 32px;
  transition: transform .25s ease;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-section { margin-bottom: 4px; }

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  cursor: pointer;
  user-select: none;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  transition: color .15s;
}
.sidebar-section-header:hover { color: var(--text-2); }
.sidebar-section-header .chevron { transition: transform .2s; flex-shrink: 0; }
.sidebar-section.open .chevron { transform: rotate(180deg); }

.sidebar-items { display: none; flex-direction: column; }
.sidebar-section.open .sidebar-items { display: flex; }

.sidebar-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 24px;
  font-size: .875rem;
  color: var(--text-2);
  text-decoration: none;
  transition: background .12s, color .12s;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
  line-height: 1.4;
}
.sidebar-item:hover { background: var(--sidebar-hover); color: var(--text); }
.sidebar-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
  font-weight: 600;
}
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  width: 3px; height: 24px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* ── Main ─────────────────────────────────────────────────── */
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; }

.content {
  flex: 1;
  min-width: 0;
  max-width: 860px;
  padding: 40px 48px 80px;
}

/* ── On-page TOC ──────────────────────────────────────────── */
.toc { width: 220px; flex-shrink: 0; padding: 40px 24px 40px 8px; }

.toc-inner {
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
}

.toc-title {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}

.toc a {
  display: block;
  font-size: .8rem;
  color: var(--text-3);
  text-decoration: none;
  padding: 3px 0 3px 10px;
  border-left: 2px solid var(--border);
  transition: color .12s, border-color .12s;
  line-height: 1.4;
}
.toc a:hover, .toc a.active { color: var(--accent); border-left-color: var(--accent); }

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  color: var(--text-3);
  margin-bottom: 24px;
}
.breadcrumb a { color: var(--text-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--border); }

/* ── Page Header ──────────────────────────────────────────── */
.page-header { margin-bottom: 32px; }

.page-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

.tag {
  font-size: .7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--tag-bg);
  color: var(--tag-text);
  letter-spacing: .03em;
}

h1.page-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -.02em;
}

.page-meta {
  font-size: .8rem;
  color: var(--text-3);
  display: flex;
  gap: 16px;
  align-items: center;
}

/* ── TL;DR Box ────────────────────────────────────────────── */
.tldr {
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin: 28px 0;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.tldr-label {
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  margin-top: 2px;
  flex-shrink: 0;
}
.tldr p { font-size: .9rem; color: var(--text); line-height: 1.6; margin: 0; }

/* ── Typography ───────────────────────────────────────────── */
h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 44px 0 14px;
  color: var(--text);
  letter-spacing: -.015em;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
h3 { font-size: 1.05rem; font-weight: 600; margin: 28px 0 10px; color: var(--text); }
p { margin-bottom: 14px; color: var(--text); font-size: .95rem; }
ul, ol { margin: 10px 0 16px 20px; font-size: .95rem; color: var(--text); }
li { margin-bottom: 5px; line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: var(--font-mono);
  font-size: .82em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text);
}

/* ── Callouts ─────────────────────────────────────────────── */
.callout {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 18px 0;
  display: flex;
  gap: 12px;
  font-size: .9rem;
}
.callout.warn { background: var(--warn-bg); border-left: 3px solid var(--warn-border); color: var(--warn-text); }
.callout.tip  { background: var(--tip-bg);  border-left: 3px solid var(--tip-border);  color: var(--tip-text);  }
.callout-icon { flex-shrink: 0; font-size: 1rem; margin-top: 1px; }
.callout strong { display: block; margin-bottom: 3px; }

/* ── Diagram Container ────────────────────────────────────── */
.diagram-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin: 24px 0;
  overflow-x: auto;
  box-shadow: var(--shadow);
}
.diagram-caption {
  font-size: .78rem;
  color: var(--text-3);
  text-align: center;
  margin-top: 14px;
  font-style: italic;
}

/* ── Code Blocks ──────────────────────────────────────────── */
.code-block {
  margin: 20px 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid #2e3440;
  box-shadow: var(--shadow-md);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: #161b22;
  border-bottom: 1px solid #2e3440;
}

.code-header-left { display: flex; align-items: center; gap: 10px; }

.code-dots { display: flex; gap: 5px; }
.code-dots span { width: 11px; height: 11px; border-radius: 50%; display: block; }
.code-dots .dot-r { background: #ff5f57; }
.code-dots .dot-y { background: #febc2e; }
.code-dots .dot-g { background: #28c840; }

.code-lang {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: #6b7280;
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.code-filename { font-family: var(--font-mono); font-size: .75rem; color: #8b949e; }

.copy-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-body);
  font-size: .75rem;
  color: #8b949e;
  background: none;
  border: 1px solid #30363d;
  border-radius: 5px;
  padding: 3px 10px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.copy-btn:hover { color: #e6edf3; border-color: #8b949e; background: #30363d; }
.copy-btn.copied { color: #3fb950; border-color: #3fb950; }

.code-block pre {
  margin: 0;
  padding: 18px 20px;
  background: #1e2127;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .82rem;
  line-height: 1.7;
  color: #abb2bf;
}
.code-block pre::-webkit-scrollbar { height: 5px; }
.code-block pre::-webkit-scrollbar-track { background: #1e2127; }
.code-block pre::-webkit-scrollbar-thumb { background: #3e4451; border-radius: 4px; }

.code-block code { background: none; border: none; padding: 0; font-size: inherit; color: inherit; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 20px 0; }

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

th {
  text-align: left;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: .8rem;
  letter-spacing: .02em;
  color: var(--text-2);
  white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ── Component Cards ──────────────────────────────────────── */
.component-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 20px 0;
}
.component-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: box-shadow .15s, border-color .15s;
}
.component-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent); }
.component-card h4 {
  font-size: .875rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 7px;
}
.component-card p { font-size: .82rem; color: var(--text-2); margin: 0; line-height: 1.5; }

/* ── Learning Path ────────────────────────────────────────── */
.path-list {
  display: grid;
  gap: 14px;
  margin: 20px 0;
}

.path-step {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.path-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 800;
  font-size: .9rem;
}

.path-step h3 {
  margin-top: 0;
  margin-bottom: 6px;
}

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

/* ── Gotchas ──────────────────────────────────────────────── */
.gotcha-list { list-style: none; margin: 0; padding: 0; }
.gotcha-list li {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: .875rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.gotcha-icon { flex-shrink: 0; font-size: 1rem; }

/* ── Related Pages ────────────────────────────────────────── */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.related-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: .85rem;
  font-weight: 500;
  transition: border-color .15s, box-shadow .15s;
}
.related-card:hover { border-color: var(--accent); box-shadow: var(--shadow); text-decoration: none; color: var(--accent); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .toc { display: none; }
  .content { max-width: 100%; }
}
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar { transform: translateX(-100%); z-index: 90; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .content { padding: 24px 20px 60px; }
  h1.page-title { font-size: 1.5rem; }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 89;
}
.sidebar-overlay.show { display: block; }
