/* 经典设计模式 — 课堂讲义 · 现代静态页 */
:root {
  --bg: #0c0f14;
  --bg-elevated: #121722;
  --surface: #181e2a;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf1;
  --muted: #9aa3b2;
  --accent: #5eead4;
  --accent-2: #a78bfa;
  --warn: #fbbf24;
  --radius: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --font: "DM Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(94, 234, 212, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(167, 139, 250, 0.14), transparent 50%),
    var(--bg);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: #7ff5e4;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: #042f2e;
  font-weight: 600;
  z-index: 100;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

.hero {
  padding: 2.75rem 2rem;
  border-radius: calc(var(--radius) + 6px);
  background: linear-gradient(135deg, rgba(24, 30, 42, 0.95), rgba(18, 23, 34, 0.92));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 55%;
  height: 120%;
  background: radial-gradient(circle, rgba(94, 234, 212, 0.09), transparent 65%);
  pointer-events: none;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.hero .subtitle {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

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

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, #2dd4bf, #14b8a6);
  color: #042f2e;
  box-shadow: 0 8px 28px rgba(45, 212, 191, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 36px rgba(45, 212, 191, 0.32);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
}

nav.toc {
  margin: 2rem 0 2.5rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

nav.toc h2 {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

nav.toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

nav.toc a {
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
}

nav.toc a span.idx {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent-2);
}

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

section {
  margin-bottom: 2.75rem;
  padding: 1.75rem 1.75rem 2rem;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

section h2 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

section h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.05rem;
  color: var(--accent);
}

section p {
  margin: 0 0 1rem;
  color: #c5ced9;
}

section ul,
section ol {
  margin: 0 0 1rem;
  padding-left: 1.35rem;
  color: #c5ced9;
}

section li {
  margin-bottom: 0.35rem;
}

.callout {
  margin: 1.25rem 0;
  padding: 1rem 1.15rem;
  border-radius: 12px;
  border-left: 4px solid var(--accent);
  background: rgba(94, 234, 212, 0.06);
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 1rem 0;
}

th,
td {
  border: 1px solid var(--border);
  padding: 0.65rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.88rem;
}

pre {
  margin: 1rem 0;
  padding: 1rem 1.1rem;
  border-radius: 10px;
  background: #0a0d12;
  border: 1px solid var(--border);
  overflow-x: auto;
  line-height: 1.5;
}

.checklist {
  list-style: none;
  padding-left: 0;
}

.checklist li {
  position: relative;
  padding-left: 1.75rem;
  margin-bottom: 0.5rem;
}

.checklist li::before {
  content: "☐";
  position: absolute;
  left: 0;
  color: var(--accent-2);
  font-size: 1rem;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  padding: 2rem 0 0;
}

h4 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  color: #cbd5e1;
  font-weight: 600;
}

.lesson-steps {
  margin: 1rem 0 1.25rem;
  padding-left: 1.2rem;
  color: #c5ced9;
}

.lesson-steps li {
  margin-bottom: 0.65rem;
}

details.lesson {
  margin: 1rem 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0a0d12;
  overflow: hidden;
}

details.lesson > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: var(--accent-2);
  background: rgba(167, 139, 250, 0.06);
}

details.lesson > summary::-webkit-details-marker {
  display: none;
}

details.lesson[open] > summary {
  border-bottom: 1px solid var(--border);
}

details.lesson .lesson-inner {
  padding: 0 1rem 1rem;
}

.pre-label {
  margin: 1rem 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.tag-inline {
  display: inline-block;
  margin-right: 0.35rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: middle;
}

.tag-java {
  background: rgba(251, 191, 36, 0.15);
  color: #fcd34d;
}

.tag-py {
  background: rgba(94, 234, 212, 0.12);
  color: #5eead4;
}

@media print {
  body {
    background: #fff;
    color: #111;
  }

  .hero,
  section,
  nav.toc {
    box-shadow: none;
    border-color: #ccc;
    break-inside: avoid;
  }

  a {
    color: #0369a1;
  }

  .btn {
    display: none;
  }
}

@media (max-width: 600px) {
  .wrap {
    padding: 1.5rem 1rem 4rem;
  }

  section {
    padding: 1.25rem 1.15rem 1.5rem;
  }
}
