:root {
  --bg: #f5f7f4;
  --text: #1a211c;
  --muted: #5a665c;
  --accent: #1a211c;
  --border: #5a665c30;
  --surface: #eef0ec;

  --font-heading: Georgia, 'Times New Roman', serif;
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Courier New', Courier, monospace;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

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

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

h1 {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 400;           /* Normal weight, not bold. Confident. */
  letter-spacing: -0.02em;    /* Tighten slightly at large sizes */
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 1.5rem;
}

h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--text);
}

h3 {
  font-family: var(--font-body);  /* Switch to sans for smaller headings */
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

h4 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  font-style: italic;
  line-height: 1.4;
  color: var(--text);
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--muted);     /* Underline is muted, not full black */
  text-underline-offset: 3px;              /* Breathing room */
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.15s ease;
}

a:hover {
  text-decoration-color: var(--text);      /* Underline darkens on hover */
}

body {
    max-width: 48rem;
    margin: 0 auto;
    padding: 1.5rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 4rem;
}

header a {
    font-family: var(--font-mono);
    color: var(--muted);
    font-size: 0.8rem;
    margin: 0;
    text-decoration: none;
}

header .site-title {
    font-size: 0.9rem;
}

header nav ul {
    display: flex;
    gap: 1.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.headshot {
  display: block;
  margin-bottom: 1.5rem;
}

.intro {
    color: var(--muted);
    font-size: 1.125rem;
    margin: 0;
    line-height: 1.5;
}

.posts ul {
    padding: 1rem 0 0 0;
}

.posts ul li {
    list-style: none;
}

.post-header h1 {
    margin-bottom: 0.5rem;
}

.books {
    margin-top: 2rem;
}

.post-header time,
.book-meta {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 2rem;
} 

.library h2 {
    margin-bottom: 1rem;
}

#TableOfContents {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 2rem;
}

#TableOfContents a {
    color: var(--muted);
}

#TableOfContents ul {
    list-style: none;
    padding-left: 1.25rem;
}

#TableOfContents > ul {
    padding-left: 0;
}

#TableOfContents li {
    margin-bottom: 0.25rem;
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content h2 {
    margin-top: 3rem;
    margin-bottom: 1rem;
}

.post-content h3 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.post-content h4 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.post-content ul,
.post-content ol {
    margin-bottom: 1.5rem;
}

.post-content li > ul,
.post-content li > ol {
    margin-bottom: 0;
}

.post-content li > p {
    margin-bottom: 0;
}

.sidebar-block {
    margin: 2rem 0;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border-left: 3px solid var(--border);
    font-size: 0.95rem;
}
	
.sidebar-block p:last-child {
    margin-bottom: 0;
}

.post-content .captioned-content {
    display: flex;
    flex-direction: column-reverse;
    margin: 2rem 0;
    overflow-x: auto;
}

.post-content .caption {
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
    margin-top: 0.5rem;
}

.diagram {
    overflow-x: auto;
}

/* Photo Gallery - Flexbox masonry */
.gallery {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
    height: 600px;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    margin-top: 3rem;
    margin-bottom: 0.5rem;
}

.gallery-item {
    margin: 0;
    flex-shrink: 0;
    /* Landscape: half the container height minus half the gap */
    height: calc(50% - 0.25rem);
    width: calc((300px - 0.125rem) * var(--ar));
}

.gallery-item.portrait {
    /* Portrait: full container height */
    height: 100%;
    width: calc(600px * var(--ar));
}

.gallery-item a {
    display: block;
    height: 100%;
}

.gallery-item img {
    height: 100%;
    width: 100%;
    object-fit: cover;
}

.scroll-hint {
    text-align: right;
    font-size: 0.8rem;
    color: var(--muted);
}

@media (max-width: 768px) {
    .gallery {
        height: 50vh;
    }

    .gallery-item {
        width: calc((25vh - 0.125rem) * var(--ar));
    }

    .gallery-item.portrait {
        width: calc(50vh * var(--ar));
    }
}
