/* ===================================
   CSS Variables
   =================================== */
@font-face {
  font-family: "iA Writer Duo V";
  src: url("/fonts/iAWriterDuoV.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "iA Writer Duo V";
  src: url("/fonts/iAWriterDuoV-Italic.ttf") format("truetype");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root {
  --color-bg: #F5F1E8;
  --color-text: #1A1A1A;
  /* --color-accent: #8B3A3A; */
  --color-accent: #DD4B4F;
  --color-subtle: #8e8675;
  --font-serif: "iA Writer Duo V", "IBM Plex Mono", "Courier New", monospace;
  --font-sans: "iA Writer Duo V", "IBM Plex Mono", "Courier New", monospace;
  --font-mono: "iA Writer Duo V", "IBM Plex Mono", "Courier New", monospace;
  --max-width: 700px;
  --spacing-unit: 1.5rem;

  /* Spacing system - Bear-style tight rhythm
     Everything shares the same vertical rhythm: 1 line-height of space */
  --space-block: 1.7em;  /* matches line-height - one "empty line" */
  --space-tight: 0.2em;  /* minimal spacing within groups */
}

/* ===================================
   Reset & Base Styles
   =================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
  line-height: 1.7;
}

body {
  font-family: var(--font-serif);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===================================
   Typography
   =================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.3;
  margin-top: var(--space-block);
  margin-bottom: var(--space-tight);
}

h1 {
  font-size: 2rem;
  margin-top: 0;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

p {
  margin-bottom: var(--space-block);
}

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

a:hover {
  text-decoration: underline;
}

strong {
  font-weight: 600;
}

em {
  font-style: italic;
}

/* ===================================
   Layout
   =================================== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-unit);
}

main {
  min-height: calc(100vh - 200px);
  padding: calc(var(--spacing-unit) * 0.6) 0;
  opacity: 1;
  transition: opacity 80ms ease;
}

body.is-loading main,
body.is-exiting main {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  main {
    transition: none;
  }

  body.is-loading main,
  body.is-exiting main {
    opacity: 1;
  }
}

img {
    border-radius: 2px !important;
}

/* ===================================
   Header & Navigation
   =================================== */
.site-header {
  padding: calc(var(--spacing-unit) * 0.75) 0;
  margin-bottom: var(--spacing-unit);
  margin-top: var(--spacing-unit);
}

.site-title {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}

/* .site-title a:hover {
  color: var(--color-accent);
  text-decoration: none;
} */

.site-nav {
  margin-top: 0.5rem;
}

.site-nav a {
  color: var(--color-text);
  margin-right: 1.5rem;
  text-decoration: none;
  font-family: var(--font-sans);
  text-transform: lowercase;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--color-accent);
}

/* ===================================
   Image Grid
   =================================== */
.image-grid {
  --image-grid-gap: 1.25rem;
  column-count: 2;
  column-gap: var(--image-grid-gap);
  margin-bottom: 0;
}

.image-grid--cols-1 {
  column-count: 1;
}

.image-grid--cols-3 {
  column-count: 3;
}

.image-grid-item {
  break-inside: avoid;
  margin: 0 0 var(--image-grid-gap);
}

.image-grid + * {
  margin-top: var(--space-block);
}

.image-grid-item img {
  width: 100%;
  height: auto;
  display: block;
  margin-bottom: 0 !important;
}

.image-grid-item figcaption {
  margin-top: 0.5em;
  font-size: 0.9rem;
  color: var(--color-subtle);
}

@media (max-width: 700px) {
  .image-grid {
    column-count: 1;
  }
}

/* ===================================
   Footer
   =================================== */
.site-footer {
  padding: var(--spacing-unit) 0;
  margin-top: calc(var(--spacing-unit) * 2);
}

.site-footer p {
  font-size: 0.9rem;
  color: var(--color-subtle);
  margin-bottom: 0;
}

/* ===================================
   Lists
   =================================== */
ul, ol {
  margin-bottom: var(--space-block);
  padding-left: 2em;
}

li {
  margin-bottom: 0;
}

/* Nested lists */
li > ul,
li > ol {
  margin-top: 0;
  margin-bottom: 0;
}

/* Paragraphs inside list items */
li > p {
  margin-bottom: 0;
}

/* ===================================
   Tables
   =================================== */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.post-content th,
.post-content td {
  border: 1px solid var(--color-subtle);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

.post-content th {
  font-weight: 600;
}

/* ===================================
   Code Blocks
   =================================== */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 1em;
  border-radius: 5px;
  overflow-x: auto;
  margin-bottom: var(--space-block);
}

pre code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
}

/* ===================================
   Blockquotes
   =================================== */
blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: 1em;
  margin: var(--space-block) 0;
  font-style: italic;
  color: #4A4A4A;
}

blockquote > p:last-child {
  margin-bottom: 0;
}

/* ===================================
   Home Page
   =================================== */
.home-intro {
  margin-bottom: calc(var(--spacing-unit) * 2);
}

.home-intro h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

/* ===================================
   Blog Listing
   =================================== */
.post-list {
  list-style: none;
  padding-left: 0;
}

.post-list-item {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-subtle);
}

.post-list-item:last-child {
  border-bottom: none;
}

.post-list-item h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.post-list-item h2 a {
  color: var(--color-text);
}

.post-list-item h2 a:hover {
  color: var(--color-accent);
}

.post-meta {
  font-size: 0.9rem;
  color: var(--color-subtle);
  font-family: var(--font-sans);
  margin-bottom: 0.5rem;
}

.post-excerpt {
  margin-top: 0.75rem;
}

.post-excerpt--clamped {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-excerpt--clamped img,
.post-excerpt--clamped .video-embed,
.post-excerpt--clamped iframe {
  display: none !important;
}

.read-more {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--color-accent);
  text-decoration: none;
  font-family: var(--font-sans);
}

.read-more:hover {
  text-decoration: underline;
}

/* Compact blog list by year */
.year-section {
  margin-bottom: 3rem;
}

.year-heading {
  font-size: 1.75rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

.year-section:first-of-type .year-heading {
  margin-top: 0;
}

.posts-by-year {
  list-style: none;
  padding-left: 0;
}

.post-item-compact {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-family: var(--font-sans);
}

.post-month {
  min-width: 2.5rem;
  text-align: left;
  font-size: 0.95rem;
  color: var(--color-text);
}

.post-day {
  min-width: 1.5rem;
  text-align: right;
  font-size: 0.95rem;
  color: var(--color-text);
}

.post-title-link {
  flex: 1;
  color: var(--color-text);
  text-decoration: none;
}

.post-title-link:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.post-category {
  font-size: 0.9rem;
  color: var(--color-subtle);
  margin-left: auto;
}

.post-count {
  margin-top: 2rem;
  font-size: 0.9rem;
  color: var(--color-subtle);
}

/* ===================================
   Single Blog Post
   =================================== */
.post-header {
  margin-bottom: 2rem;
}

.post-title {
  margin-bottom: 0.5rem;
}

.post-tags,
.post-categories {
  margin-top: 2rem;
  font-size: 0.9rem;
}

.post-tags a,
.post-categories a {
  display: inline-block;
  margin-right: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0.75rem;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
  color: var(--color-text);
}

.post-tags a:hover,
.post-categories a:hover {
  background-color: var(--color-accent);
  color: var(--color-bg);
  text-decoration: none;
}

.post-nav {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-subtle);
  display: flex;
  justify-content: space-between;
}

.post-nav a {
  font-family: var(--font-sans);
}

.post-nav-next {
  text-align: right;
}

.post-content img,
.post-excerpt img {
  max-width: 100%;
  height: auto;
  display: block;
  margin-bottom: var(--space-block);
}
.post-content p:has(+ ul),
.post-content p:has(+ ol) {
  margin-bottom: 0;
}

.video-embed {
  margin: var(--space-block) 0;
}

.video-embed__frame {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 2px;
}

.video-embed__frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-embed figcaption {
  margin-top: 0.5em;
  font-size: 0.9rem;
  color: var(--color-subtle);
}

.video-embed figcaption > p {
  margin: 0;
}

/* ===================================
   Projects
   =================================== */
.project-list {
  list-style: none;
  padding-left: 0;
}

.project-item {
  margin-bottom: 3rem;
}

.project-item:last-child {
  margin-bottom: 0;
}

.project-item h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.project-item h2 a {
  color: var(--color-accent);
  text-decoration: none;
}

.project-item h2 a:hover {
  text-decoration: underline;
  color: var(--color-accent);
}

/* ===================================
   Design Notes Gallery
   =================================== */
.design-notes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-bottom: var(--space-block);
}

.design-note-card {
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 2px;
  overflow: hidden;
  text-decoration: none;
  color: var(--color-text);
  transition: box-shadow 0.15s ease;
}

.design-note-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  text-decoration: none;
}

.design-note-card__image {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background-color: rgba(0, 0, 0, 0.03);
}

.design-note-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  margin-bottom: 0 !important;
}

.design-note-card__body {
  padding: 0.75rem 1rem 1rem;
}

.design-note-card__title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.4rem 0;
  line-height: 1.3;
}

.design-note-card__tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
  color: var(--color-subtle);
  font-family: var(--font-sans);
}

@media (max-width: 700px) {
  .design-notes-grid {
    grid-template-columns: 1fr;
  }
}

/* ===================================
   Pagination
   =================================== */
.pagination {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  font-family: var(--font-sans);
}

.pagination a {
  color: var(--color-text);
}

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

.pagination .disabled {
  color: var(--color-subtle);
  pointer-events: none;
}

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

  .site-nav {
    display: flex;
    gap: 1rem;
  }

  .site-nav a {
    margin-right: 0;
  }

  .post-nav {
    flex-direction: column;
    gap: 1rem;
  }

  .post-nav-next {
    text-align: left;
  }
}
