/* ====================================================
   Kubernetes 云原生教程 — common.css
   ==================================================== */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --card: #1c2128;
  --card-hover: #262c36;
  --border: rgba(180,185,210,0.12);
  --border-bright: rgba(180,185,210,0.26);
  --text: #e6edf3;
  --text-2: #adbac7;
  --text-3: #768390;
  --accent: #326CE5;
  --accent-2: #5b9cf6;
  --accent-glow: rgba(50,108,229,0.2);
  --cyan: #22d3ee;
  --green: #4ade80;
  --orange: #fb923c;
  --red: #f87171;
  --yellow: #fbbf24;
  --radius: 10px;
  --radius-lg: 14px;
}

/* ── Reset & Base ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont,
    'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei',
    sans-serif;
  font-size: 16px;
  line-height: 1.8;
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--cyan); }

h1, h2, h3, h4 {
  line-height: 1.35;
  color: var(--text);
  font-weight: 700;
}

p { margin-bottom: 1rem; color: var(--text-2); }

/* ── Navigation ─────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 2rem;
  height: 56px;
  background: rgba(13,17,23,0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-2);
  font-size: 0.85rem;
  white-space: nowrap;
  transition: color 0.2s;
}
.nav-back::before { content: '←'; color: var(--accent-2); }
.nav-back:hover { color: var(--cyan); }

.nav-title {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-logo {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.nav-logo span { color: var(--accent-2); }

/* ── Hero (index) ───────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  padding: 6rem 2rem 5rem;
  text-align: center;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(50,108,229,0.08) 0%, #161b22 50%, #0d1117 100%);
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(50,108,229,0.22) 0%, transparent 70%),
    radial-gradient(ellipse 40% 30% at 20% 80%, rgba(34,211,238,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 80% 80%, rgba(50,108,229,0.1) 0%, transparent 60%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 1rem;
  background: rgba(50,108,229,0.12);
  border: 1px solid var(--border-bright);
  border-radius: 100px;
  font-size: 0.78rem;
  color: var(--accent-2);
  letter-spacing: 0.5px;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
}

.hero-badge::before { content: '⎈'; font-size: 1em; }

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 1.2rem;
  background: linear-gradient(135deg, #e8f4ff 0%, #5b9cf6 50%, #22d3ee 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--text-2);
  max-width: 560px;
  margin: 0 auto 2.5rem;
  line-height: 1.7;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  flex-wrap: wrap;
  position: relative;
}

.stat-item {
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-2);
  line-height: 1;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 0.25rem;
}

/* Floating K8s elements */
.hero-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.k8s-node {
  position: absolute;
  width: 48px;
  height: 48px;
  border: 1.5px solid rgba(50,108,229,0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: rgba(91,156,246,0.4);
  animation: floatNode 6s ease-in-out infinite;
}

@keyframes floatNode {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.4; }
  50% { transform: translateY(-18px) scale(1.05); opacity: 0.7; }
}

/* ── Container ──────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.section-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.section-sub {
  color: var(--text-3);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

/* ── Tutorial Cards Grid (index) ────────────────── */
.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.2rem;
  margin-top: 1.5rem;
}

.ch-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  animation: cardIn 0.5s ease forwards;
}

.ch-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  opacity: 0;
  transition: opacity 0.2s;
}

.ch-card:hover {
  background: var(--card-hover);
  border-color: var(--border-bright);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(50,108,229,0.2);
}

.ch-card:hover::before { opacity: 1; }

@keyframes cardIn {
  to { opacity: 1; transform: translateY(0); }
}

.ch-num-badge {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(50,108,229,0.15);
  border: 1px solid var(--border-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-2);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.ch-card-body { flex: 1; min-width: 0; }

.ch-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.35rem;
  line-height: 1.4;
}

.ch-card-desc {
  font-size: 0.8rem;
  color: var(--text-3);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ch-card-arrow {
  flex-shrink: 0;
  color: var(--text-3);
  font-size: 0.9rem;
  transition: color 0.2s, transform 0.2s;
  margin-top: 3px;
}
.ch-card:hover .ch-card-arrow { color: var(--accent-2); transform: translateX(4px); }

/* ── Chapter Hero ───────────────────────────────── */
.chapter-hero {
  padding: 4rem 2rem 3rem;
  background: radial-gradient(ellipse at top, #161b22 0%, #0d1117 70%);
  position: relative;
  overflow: hidden;
  text-align: center;
}

.chapter-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 50% 50% at 50% -10%, rgba(50,108,229,0.3) 0%, transparent 60%),
    radial-gradient(ellipse 30% 40% at 10% 90%, rgba(34,211,238,0.08) 0%, transparent 50%),
    radial-gradient(ellipse 30% 40% at 90% 90%, rgba(50,108,229,0.1) 0%, transparent 50%);
  pointer-events: none;
}

.ch-num {
  font-size: 0.78rem;
  color: var(--accent-2);
  letter-spacing: 3px;
  text-transform: uppercase;
  font-family: 'SF Mono', 'Fira Code', monospace;
  margin-bottom: 0.8rem;
  position: relative;
}

.chapter-hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -0.5px;
  margin-bottom: 0.8rem;
  background: linear-gradient(135deg, #ffffff 0%, #7aabda 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
}

.chapter-hero p {
  font-size: 1rem;
  color: var(--text-2);
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

/* ── Content Area ───────────────────────────────── */
.content {
  max-width: 860px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

.content h2 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text);
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.content h2::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.2em;
  background: linear-gradient(180deg, var(--accent), var(--cyan));
  border-radius: 2px;
  flex-shrink: 0;
}

.content h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-2);
  margin: 1.8rem 0 0.7rem;
}

.content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-2);
  margin: 1.2rem 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Progress Bar ───────────────────────────────── */
.progress {
  height: 4px;
  background: rgba(50,108,229,0.1);
  border-radius: 100px;
  margin-bottom: 2.5rem;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  border-radius: 100px;
  transition: width 0.6s ease;
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  right: 0; top: -2px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

/* ── Callout Boxes ──────────────────────────────── */
.callout {
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin: 1.5rem 0;
  border-left: 3px solid;
  position: relative;
}

.callout-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.callout p { margin: 0; font-size: 0.92rem; }
.callout p + p { margin-top: 0.5rem; }

.callout.info {
  background: rgba(50,108,229,0.08);
  border-color: var(--accent);
}
.callout.info .callout-title { color: var(--accent-2); }
.callout.info .callout-title::before { content: 'ℹ'; }

.callout.tip {
  background: rgba(74,222,128,0.06);
  border-color: var(--green);
}
.callout.tip .callout-title { color: var(--green); }
.callout.tip .callout-title::before { content: '✦'; }

.callout.warning {
  background: rgba(251,191,36,0.07);
  border-color: var(--yellow);
}
.callout.warning .callout-title { color: var(--yellow); }
.callout.warning .callout-title::before { content: '⚠'; }

.callout.danger {
  background: rgba(248,113,113,0.07);
  border-color: var(--red);
}
.callout.danger .callout-title { color: var(--red); }
.callout.danger .callout-title::before { content: '✖'; }

/* ── Definition List ────────────────────────────── */
.def-list {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 1.5rem 0;
}

.def-item {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.def-item:last-child { border-bottom: none; }

.def-term {
  padding: 0.85rem 1.2rem;
  background: rgba(50,108,229,0.06);
  color: var(--accent-2);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  word-break: break-all;
}

.def-desc {
  padding: 0.85rem 1.2rem;
  color: var(--text-2);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ── Code Blocks ────────────────────────────────── */
pre {
  background: #090d12;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
  overflow-x: auto;
  margin: 1.2rem 0;
  position: relative;
  font-size: 0.85rem;
  line-height: 1.7;
}

pre::before {
  content: attr(data-lang);
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  font-size: 0.65rem;
  color: var(--text-3);
  font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: rgba(50,108,229,0.08);
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.87em;
}

p code, li code {
  background: rgba(50,108,229,0.12);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.45em;
  color: var(--cyan);
  font-size: 0.85em;
}

/* YAML / code color tokens */
.kw  { color: #c792ea; }   /* keyword */
.ty  { color: #82aaff; }   /* type / key */
.st  { color: #c3e88d; }   /* string */
.cm  { color: #5c8a7a; font-style: italic; }   /* comment */
.fn  { color: #82aaff; }   /* function */
.nu  { color: #f78c6c; }   /* number */
.at  { color: #ffcb6b; }   /* attribute */
.pr  { color: #89ddff; }   /* punctuation */
.yn  { color: var(--cyan); font-weight: 600; }   /* yaml bool / null */
.yk  { color: var(--accent-2); }   /* yaml key */
.yv  { color: #c3e88d; }   /* yaml value string */
.yc  { color: #5c8a7a; font-style: italic; }   /* yaml comment */
.yi  { color: #f78c6c; }   /* yaml integer */
.cmd { color: var(--cyan); }   /* shell command */
.flag { color: var(--yellow); }   /* shell flag */
.arg  { color: #c3e88d; }   /* shell arg */

/* ── ASCII Diagram ──────────────────────────────── */
.ascii-diagram {
  background: #090d12;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-2);
}

.ascii-diagram .box { color: var(--accent-2); }
.ascii-diagram .label { color: var(--cyan); }
.ascii-diagram .arrow { color: var(--text-3); }
.ascii-diagram .highlight { color: var(--green); }

/* ── Two Column ─────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin: 1.2rem 0;
}

@media (max-width: 640px) {
  .two-col { grid-template-columns: 1fr; }
}

.two-col-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

.two-col-item h4 {
  font-size: 0.85rem;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.6rem;
}

/* ── Table ──────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

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

thead th {
  background: rgba(50,108,229,0.1);
  color: var(--accent-2);
  font-weight: 700;
  text-align: left;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-bright);
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 1rem;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(50,108,229,0.04); }

/* ── Card List ──────────────────────────────────── */
.card-list {
  display: grid;
  gap: 1rem;
  margin: 1.2rem 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
  transition: border-color 0.2s, background 0.2s;
}

.card:hover {
  border-color: var(--border-bright);
  background: var(--card-hover);
}

.card h4 {
  font-size: 0.92rem;
  color: var(--accent-2);
  margin-bottom: 0.4rem;
  text-transform: none;
  letter-spacing: 0;
}

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

/* ── Feature Grid (index) ───────────────────────── */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.feature-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.feature-item:hover {
  border-color: var(--border-bright);
  background: var(--card-hover);
  transform: translateY(-2px);
}

.feature-icon {
  font-size: 1.8rem;
  margin-bottom: 0.6rem;
  display: block;
}

.feature-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.feature-desc {
  font-size: 0.78rem;
  color: var(--text-3);
  line-height: 1.4;
}

/* ── Chapter Navigation ─────────────────────────── */
.chapter-nav {
  display: flex;
  gap: 1rem;
  margin: 3rem 0 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.chapter-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}

.chapter-nav a:hover {
  background: var(--card-hover);
  border-color: var(--border-bright);
}

.chapter-nav .nav-label {
  font-size: 0.72rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chapter-nav .nav-ch-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--accent-2);
  line-height: 1.3;
}

.chapter-nav .prev { text-align: left; }
.chapter-nav .next { text-align: right; }
.chapter-nav .prev .nav-label::before { content: '← '; }
.chapter-nav .next .nav-label::after { content: ' →'; }

/* ── Site Footer ────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 2rem;
  font-size: 0.82rem;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-footer a { color: var(--text-3); }
.site-footer a:hover { color: var(--accent-2); }

/* ── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(50,108,229,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(50,108,229,0.5); }

/* ── Utility ────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'SF Mono', monospace;
}

.tag-blue { background: rgba(50,108,229,0.15); color: var(--accent-2); border: 1px solid var(--border-bright); }
.tag-cyan { background: rgba(34,211,238,0.1); color: var(--cyan); border: 1px solid rgba(34,211,238,0.2); }
.tag-green { background: rgba(74,222,128,0.1); color: var(--green); border: 1px solid rgba(74,222,128,0.2); }
.tag-orange { background: rgba(251,146,60,0.1); color: var(--orange); border: 1px solid rgba(251,146,60,0.2); }
.tag-red { background: rgba(248,113,113,0.1); color: var(--red); border: 1px solid rgba(248,113,113,0.2); }

ul, ol {
  padding-left: 1.4rem;
  margin: 0.8rem 0;
  color: var(--text-2);
}

li { margin-bottom: 0.35rem; line-height: 1.7; }

.steps {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
}

.steps li {
  counter-increment: step;
  padding: 0.6rem 0 0.6rem 2.8rem;
  position: relative;
  border-bottom: 1px solid var(--border);
}

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

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.6rem;
  width: 1.8rem;
  height: 1.8rem;
  background: rgba(50,108,229,0.15);
  border: 1px solid var(--border-bright);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent-2);
  font-family: 'SF Mono', monospace;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  .nav { padding: 0 1rem; }
  .hero { padding: 4rem 1.2rem 3rem; }
  .container { padding: 2rem 1.2rem; }
  .content { padding: 1.5rem 1.2rem 3rem; }
  .chapter-hero { padding: 3rem 1.2rem 2rem; }
  .def-item { grid-template-columns: 1fr; }
  .def-term { border-right: none; border-bottom: 1px solid var(--border); }
  .chapter-nav { flex-direction: column; }
}
