:root {
  --background: #f2ede4;
  --foreground: #000000;
  --neutral-200: #e5e5e5;
  --neutral-400: #a3a3a3;
  --neutral-500: #737373;
  --neutral-700: #404040;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #141414;
    --foreground: #e5e5e5;
    --neutral-200: #404040;
    --neutral-400: #525252;
    --neutral-500: #a3a3a3;
    --neutral-700: #525252;
  }
}

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

body {
  background: var(--background);
  color: var(--foreground);
  font-family: "Geist", Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}

/* Skip to content */
.skip-to-content {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  padding: 0.5rem 1rem;
  background: var(--foreground);
  color: var(--background);
  font-size: 0.875rem;
  font-weight: 600;
}
.skip-to-content:focus {
  left: 0.5rem;
}

/* Focus states */
a:focus-visible,
button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Page transition */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
main {
  animation: fadeIn 0.3s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  main {
    animation: none;
  }
}

/* Container */
.page-wrap {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 2rem;
}
@media (min-width: 768px) {
  .page-wrap {
    padding: 0 3rem;
  }
}

/* Header */
header {
  padding: 2rem 0 3rem;
}
header .part-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--neutral-500);
  margin-bottom: 0.5rem;
}
header h1 {
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.02em;
}
@media (min-width: 768px) {
  header h1 {
    font-size: 3.5rem;
  }
}
header .subtitle {
  font-size: 0.875rem;
  color: var(--neutral-500);
  margin-top: 1rem;
  line-height: 1.5;
}

/* Site navigation (back to main site) */
nav.site-nav {
  padding: 1rem 0;
  font-size: 0.75rem;
}
nav.site-nav a {
  color: var(--neutral-500);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: opacity 0.2s;
}
nav.site-nav a:hover {
  opacity: 0.7;
}

/* Navigation bar */
nav.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--foreground);
  font-size: 0.875rem;
}
nav.page-nav a {
  color: var(--foreground);
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}
nav.page-nav a:hover {
  opacity: 0.7;
}
nav.page-nav .disabled {
  color: var(--neutral-400);
  pointer-events: none;
}

/* Two-column section (ws-gong pattern) */
.section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  border-top: 1px solid var(--foreground);
  padding: 2rem 0 2.5rem;
}
@media (min-width: 768px) {
  .section {
    grid-template-columns: 1fr 2fr;
    gap: 3rem;
  }
}
.section h2 {
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
@media (min-width: 768px) {
  .section h2 {
    font-size: 1.5rem;
  }
}
.section-content {
  font-size: 0.875rem;
  line-height: 1.7;
}
.section-content > * + * {
  margin-top: 1rem;
}
.section-content h3 {
  font-size: 1rem;
  font-weight: 900;
  margin-top: 1.75rem;
}

/* Paragraphs and lists */
.section-content p {
  margin-top: 0.75rem;
}
.section-content p:first-child {
  margin-top: 0;
}
.section-content ul,
.section-content ol {
  margin: 0.75rem 0 0.75rem 1.25rem;
  line-height: 1.8;
}
.section-content li {
  margin-bottom: 0.25rem;
}
.section-content li strong {
  font-weight: 700;
}

/* Emphasis and inline code */
.section-content em {
  font-style: italic;
}
.section-content code {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.8em;
  background: #1c1917;
  color: #e5e5e5;
  padding: 0.2em 0.45em;
  border-radius: 4px;
}

/* Code blocks */
pre {
  background: #1c1917;
  color: #e5e5e5;
  padding: 1.25rem 1.5rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.7;
  margin: 1rem 0;
}
pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  color: inherit;
}

/* Syntax highlighting — matches markdown rendering */
pre code .hljs-keyword,
pre code .hljs-selector-tag {
  color: #c678dd;
}
pre code .hljs-string,
pre code .hljs-template-tag,
pre code .hljs-template-variable {
  color: #98c379;
}
pre code .hljs-comment {
  color: #5c6370;
  font-style: italic;
}
pre code .hljs-number,
pre code .hljs-literal {
  color: #d19a66;
}
pre code .hljs-function,
pre code .hljs-title {
  color: #61afef;
}
pre code .hljs-built_in {
  color: #e5c07b;
}
pre code .hljs-type,
pre code .hljs-params {
  color: #e5c07b;
}
pre code .hljs-attr,
pre code .hljs-property {
  color: #d19a66;
}
pre code .hljs-variable,
pre code .hljs-name {
  color: #e06c75;
}
pre code .hljs-punctuation {
  color: #abb2bf;
}
pre code .hljs-meta {
  color: #61afef;
}
pre code .hljs-selector-class {
  color: #d19a66;
}
pre code .hljs-symbol {
  color: #56b6c2;
}
pre code .hljs-regexp {
  color: #98c379;
}

/* Steps */
.step {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--neutral-500);
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--neutral-200);
  margin: 1.25rem 0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin: 1rem 0;
}
th {
  text-align: left;
  font-weight: 700;
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid var(--foreground);
}
td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--neutral-200);
  vertical-align: top;
}

/* Images */
.section-content img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.25rem 0;
}
.section-content img.photo {
  border: 1px solid var(--neutral-200);
}
.section-content figcaption {
  font-size: 0.75rem;
  color: var(--neutral-500);
  text-align: center;
  margin-top: -0.75rem;
  margin-bottom: 1rem;
}

/* Image placeholders (for images not yet created) */
.image-placeholder {
  border: 1px solid var(--neutral-200);
  border-radius: 4px;
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--neutral-500);
  font-size: 0.75rem;
  font-style: italic;
  margin: 1.25rem 0;
}

/* Table of contents (index page) */
.toc {
  list-style: none;
}
.toc li {
  border-top: 1px solid var(--foreground);
}
.toc li:last-child {
  border-bottom: 1px solid var(--foreground);
}
.toc a {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
  padding: 1.25rem 0;
  color: var(--foreground);
  text-decoration: none;
  transition: opacity 0.2s;
}
@media (min-width: 768px) {
  .toc a {
    grid-template-columns: 3rem 1fr;
    gap: 1.5rem;
    align-items: baseline;
  }
}
.toc a:hover {
  opacity: 0.7;
}
.toc .part-num {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--neutral-500);
  letter-spacing: 0.05em;
}
.toc .part-title {
  font-size: 1rem;
  font-weight: 900;
}
.toc .part-desc {
  font-size: 0.8rem;
  color: var(--neutral-500);
  line-height: 1.5;
  grid-column: 1 / -1;
}
@media (min-width: 768px) {
  .toc .part-desc {
    grid-column: 2 / -1;
  }
}

/* Footer */
footer {
  border-top: 1px solid var(--foreground);
  padding: 2rem 0 2.5rem;
  font-size: 0.75rem;
  color: var(--neutral-500);
  line-height: 1.5;
}

/* Bottom nav */
nav.bottom-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0;
  border-top: 1px solid var(--foreground);
  font-size: 0.875rem;
  margin-top: 0;
}
nav.bottom-nav a {
  color: var(--foreground);
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}
nav.bottom-nav a:hover {
  opacity: 0.7;
}

/* Print */
@media print {
  body {
    background: white;
    color: black;
    font-size: 11pt;
  }
  nav,
  footer,
  .skip-to-content {
    display: none !important;
  }
  .section {
    display: block !important;
    border: none !important;
    padding: 0.5em 0 !important;
  }
  pre {
    border: 1px solid #ccc;
  }
}
