/* --- Custom properties --- */

:root {
  --bg:             #FFFEF9;
  --bg-code:        #F4F1EB;
  --bg-code-inline: #EDE9E1;
  --text:           #1C1917;
  --text-muted:     #6B6560;
  --text-code:      #1C1917;
  --border:         #E2DDD5;
  --border-accent:  #1D4ED8;
  --link:           #1D4ED8;
  --link-hover:     #1E40AF;
  --header-bg:      #FFFEF9;
  --header-border:  #E2DDD5;
  --footer-text:    #9E9792;

  --font-serif:  'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-sans:   'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* --- Reset and base --- */

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

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Layout --- */

.site-header,
.site-main,
.site-footer {
  width: 100%;
}

.header-inner,
.footer-inner {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 1.75rem;
}

.content {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 1.75rem;
}

/* --- Header --- */

.site-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-icon-link {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  text-decoration: none;
}

.header-icon-link:hover {
  color: var(--text);
}

.site-domain {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.translate-link {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-sans);
}

.translate-link:hover {
  color: var(--text);
}

/* --- Main content area --- */

.site-main {
  padding: 3.5rem 0 5rem;
}

/* --- Typography --- */

.content h1 {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.content h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text);
  margin: 3rem 0 0.75rem;
}

.content h3 {
  font-family: var(--font-serif);
  font-size: 1.1875rem;
  font-weight: 400;
  font-style: italic;
  line-height: 1.4;
  color: var(--text);
  margin: 2rem 0 0.5rem;
}

.content h4 {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 1.75rem 0 0.4rem;
}

.content h2,
.content h3,
.content h4 {
  scroll-margin-top: 5rem;
}

.heading-anchor {
  display: inline-flex;
  align-items: center;
  margin-left: 0.45rem;
  color: var(--text-muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity 160ms ease, color 160ms ease;
}

.heading-anchor:hover {
  color: var(--link);
}

.content h2:hover .heading-anchor,
.content h3:hover .heading-anchor,
.content h4:hover .heading-anchor,
.content h2:focus-within .heading-anchor,
.content h3:focus-within .heading-anchor,
.content h4:focus-within .heading-anchor {
  opacity: 1;
}

.content p {
  margin-bottom: 1.2rem;
}

.content strong {
  font-weight: 700;
}

.content em {
  font-style: italic;
}

/* Subtitle — bold line directly under h1 */
.content h1 + p strong {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Version / date line */
.content h1 + p em,
.content h1 + p + p em {
  font-size: 0.875rem;
  font-style: normal;
  color: var(--text-muted);
}

/* --- Horizontal rules --- */

.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

/* --- Links --- */

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

.content a:hover {
  color: var(--link-hover);
}

/* --- Lists --- */

.content ul,
.content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.2rem;
}

.content li {
  margin-bottom: 0.35rem;
}

.content li p {
  margin-bottom: 0.35rem;
}

/* --- Inline code --- */

.content code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-code-inline);
  color: var(--text-code);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

/* --- Code blocks --- */

.content pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin-bottom: 1.75rem;
  -webkit-overflow-scrolling: touch;
}

.content pre code {
  font-size: 0.78rem;
  background: none;
  padding: 0;
  border-radius: 0;
  color: var(--text-code);
  line-height: 1.65;
}

/* Prism syntax highlighting — warm palette */
.token.comment                { color: #9E9792; font-style: italic; }
.token.string                 { color: #166534; }
.token.keyword                { color: #1D4ED8; font-weight: 500; }
.token.annotation             { color: #B45309; font-weight: 500; }
.token.effect                 { color: #047857; }
.token.builtin                { color: #6D28D9; }
.token.boolean                { color: #6D28D9; }
.token.number                 { color: #92400E; }
.token.operator               { color: var(--text-muted); }
.token.punctuation            { color: var(--text-muted); }
.token.function               { color: var(--text); }

/* Remove Prism's default backgrounds */
code[class*="language-"],
pre[class*="language-"]       { background: none; text-shadow: none; }

/* --- Tables --- */

.content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.75rem;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  display: block;
  overflow-x: auto;
}

.content thead {
  border-bottom: 2px solid var(--border);
}

.content th {
  text-align: left;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  white-space: nowrap;
}

.content td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.content tr:last-child td {
  border-bottom: none;
}

/* --- Reader's Guide callout --- */

.reader-guide {
  border-left: 3px solid var(--border-accent);
  padding: 1rem 1.25rem;
  margin: 1.75rem 0 2rem;
}

.reader-guide p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  line-height: 1.6;
}

.reader-guide p:first-child {
  color: var(--text);
  font-weight: 500;
  margin-bottom: 0.75rem;
}

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

.reader-guide strong {
  color: var(--text);
  font-weight: 600;
}

/* --- Blockquotes --- */

.content blockquote {
  border-left: 3px solid var(--border);
  padding: 0.25rem 1.25rem;
  margin: 1.75rem 0;
  color: var(--text-muted);
}

.content blockquote p {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.65;
}

.content blockquote strong {
  color: var(--text);
}

/* --- Footer --- */

.site-footer {
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--footer-text);
  font-family: var(--font-mono);
}

/* --- Responsive --- */

@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  .content h1 {
    font-size: 1.75rem;
  }

  .content h2 {
    font-size: 1.125rem;
  }

  .site-main {
    padding: 2.5rem 0 4rem;
  }

  .content pre {
    padding: 1rem 1rem;
    border-radius: 4px;
  }
}
