/* K&R aesthetic — cream paper, serif fonts, sparse layout */

/* ---- Fonts ---- */
/* TODO: Add Junicode woff2 for the ƿ glyph (psb1558/Junicode-font on GitHub) */
@font-face {
  font-family: 'Charter';
  src: url('/fonts/charter-regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Charter';
  src: url('/fonts/charter-bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

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

body, h1, h2, h3, h4, p, ul, ol, figure, blockquote {
  margin: 0;
  padding: 0;
}

/* ---- Base ---- */
:root {
  --bg: #FAF8F1;
  --bg-code: #F2EFE4;
  --text: #2C2C2C;
  --text-secondary: #5C5C5C;
  --accent: #4A3728;
  --accent-hover: #2C2C2C;
  --border: #D4CFC4;
  --font-body: 'Charter', Georgia, 'Times New Roman', serif;
  --font-code: 'JetBrains Mono', 'Source Code Pro', 'Menlo', monospace;
  --font-wynn: 'Junicode', 'Charter', Georgia, serif;
  --content-width: 720px;
  --sidebar-width: 180px;
  --header-height: 3rem;
}

html {
  font-size: 18px;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---- Typography ---- */
h1, h2, h3, h4 {
  font-family: var(--font-body);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.4rem;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 1.15rem;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

h4 {
  font-size: 1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

strong {
  font-weight: 700;
}

em {
  font-style: italic;
}

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

ul, ol {
  padding-left: 1.5em;
  margin-bottom: 1rem;
}

li {
  margin-bottom: 0.25rem;
}

li > ul, li > ol {
  margin-top: 0.25rem;
  margin-bottom: 0;
}

blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  color: var(--text-secondary);
  margin: 1rem 0;
}

img {
  max-width: 100%;
  height: auto;
}

/* ---- Code ---- */
code {
  font-family: var(--font-code);
  font-size: 0.85em;
  background: var(--bg-code);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
}

/* ---- Tables ---- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.95rem;
}

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

th {
  font-weight: 700;
  border-bottom: 2px solid var(--border);
}

/* ---- Site Header ---- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

body {
  padding-top: var(--header-height);
}

.site-nav {
  max-width: calc(var(--content-width) + var(--sidebar-width) + 2rem);
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 2rem;
}

.site-logo {
  font-family: var(--font-wynn);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.site-logo:hover {
  text-decoration: none;
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  text-decoration: none;
}

/* ---- Site Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 3rem;
}

/* ---- Content ---- */
.content-single {
  max-width: var(--content-width);
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* ---- Home Page ---- */
.home {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}

.wynn {
  font-family: var(--font-wynn);
  font-size: 18rem;
  line-height: 1;
  color: var(--text);
  margin-bottom: 0;
}

.hero-title {
  font-family: var(--font-wynn);
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.hero-tagline {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto;
}

.home-content {
  padding-bottom: 3rem;
}

.home-content h2 {
  margin-top: 2rem;
}

.home-content .home-links {
  display: flex;
  gap: 1.5rem;
  margin-top: 2rem;
  justify-content: center;
}

.home-content .home-links a {
  font-size: 1.1rem;
  font-weight: 700;
}

.home-art {
  text-align: center;
  margin: 2rem 0;
}

.home-art img {
  max-width: 280px;
}

/* ---- Docs Layout ---- */
.docs-layout {
  max-width: calc(var(--content-width) + var(--sidebar-width) + 3rem);
  margin: 0 auto;
  display: flex;
  gap: 2rem;
  padding: 0 1.5rem;
}

.docs-nav {
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding-top: 2rem;
  position: sticky;
  top: var(--header-height);
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.docs-nav h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.docs-nav h3 a {
  color: var(--text);
}

.docs-nav h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-top: 1.25rem;
  margin-bottom: 0.25rem;
}

.docs-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.docs-nav li {
  margin: 0;
}

.docs-nav li a {
  display: block;
  padding: 0.2rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.docs-nav li a:hover {
  color: var(--text);
  text-decoration: none;
}

.docs-nav li.active a {
  color: var(--text);
  font-weight: 700;
}

.docs-content {
  flex: 1;
  min-width: 0;
  padding: 2rem 0 3rem;
}

.docs-content h1 {
  margin-bottom: 1.5rem;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  html {
    font-size: 16px;
  }

  .wynn {
    font-size: 10rem;
  }

  .hero-title {
    font-size: 2rem;
  }

  .docs-layout {
    flex-direction: column;
  }

  .docs-nav {
    width: 100%;
    position: static;
    max-height: none;
    padding-top: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
  }

  .nav-section {
    display: inline-block;
    margin-right: 1.5rem;
    vertical-align: top;
  }

  pre {
    font-size: 0.8rem;
  }

  .site-nav {
    padding: 0.75rem 1rem;
  }
}

@media (max-width: 480px) {
  .wynn {
    font-size: 7rem;
  }

  .nav-section {
    display: block;
    margin-right: 0;
  }
}

/* ---- Longform Layout (Manual / Spec) ---- */
.longform-layout {
  max-width: calc(var(--content-width) + var(--sidebar-width) + 3rem);
  margin: 0 auto;
  display: flex;
  gap: 2rem;
  padding: 0 1.5rem;
}

.longform-content {
  flex: 1;
  min-width: 0;
  padding: 2rem 0 3rem;
}

.longform-content h1 {
  margin-bottom: 1.5rem;
}

.longform-content section {
  margin-bottom: 3rem;
}

.toc-nav {
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding-top: 2rem;
  position: sticky;
  top: var(--header-height);
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.toc-nav h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.toc-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-group-header {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-top: 0.8rem;
  margin-bottom: 0.15rem;
  list-style: none;
}

.toc-group-header:first-child {
  margin-top: 0;
}

.toc-nav li.toc-section {
  margin: 0;
}

.toc-nav li.toc-section > a {
  display: inline;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.toc-nav li.toc-section > a:hover {
  color: var(--text);
  text-decoration: none;
}

.toc-nav li.toc-section > a.active {
  color: var(--text);
  font-weight: 700;
}

.toc-arrow {
  display: inline-block;
  width: 0.7em;
  font-size: 0.65rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: transform 0.15s;
  user-select: none;
}

.toc-section.open > .toc-arrow {
  transform: rotate(90deg);
}

.toc-sub {
  display: none;
  padding-left: 1rem;
  margin: 0.1rem 0 0.2rem;
}

.toc-section.open > .toc-sub {
  display: block;
}

.toc-sub li a {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  padding: 0.05rem 0;
  line-height: 1.3;
}

.toc-sub li a:hover {
  color: var(--text);
  text-decoration: none;
}

/* ---- Donate Section ---- */
.donate-section {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1.5rem 2rem;
  text-align: center;
  margin: 2rem 0;
}

.donate-section h2 {
  border-bottom: none;
  margin-top: 0;
  padding-bottom: 0;
}

.donate-section p {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
  .longform-layout {
    flex-direction: column;
  }

  .toc-nav {
    width: 100%;
    position: static;
    max-height: none;
    padding-top: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
  }
}
