@import url("https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700&display=swap");

:root {
  color-scheme: light dark;
  --bg: #e1e0e1;
  --text: #040003;
  --muted: #939393;
  --muted-strong: #6f6f6f;
  --card: #fefefe;
  --border: #b6b6b6;
  --border-strong: #8f8b8f;
  --accent: #700a6d;
  --accent-soft: rgba(112, 10, 109, 0.12);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  --max-width: 1120px;
  --radius: 12px;
  --gap: 24px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  line-height: 1.7;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Merriweather", Georgia, "Times New Roman", serif;
}

body.dark {
  --bg: #040003;
  --text: #e1e0e1;
  --muted: #b6b6b6;
  --muted-strong: #c9c3c9;
  --card: #0d000c;
  --border: #3b1238;
  --border-strong: #553452;
  --accent: #700a6d;
  --accent-soft: rgba(112, 10, 109, 0.2);
  --shadow: none;
}

* {
  box-sizing: border-box;
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

header {
  border-bottom: 1px solid var(--border-strong);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
}

.logo {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.logo img {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--border), var(--accent) 25%);
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.95rem;
}

.toggle {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 24px 72px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

.hero {
  display: grid;
  gap: 24px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3rem);
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--border-strong), var(--accent) 20%);
}

.section-title h2 {
  margin: 0;
  font-size: 1.4rem;
}

h1,
h2,
h3,
.logo,
.nav-links,
.toggle,
.badge,
.section-title,
.tag {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.tag {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: calc(var(--gap) * 0.67);
  margin-top: 6px;
}

.card {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.card p {
  margin: 0;
  color: var(--muted);
}

.card .meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.list {
  display: grid;
  gap: 20px;
}

.post-preview {
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--card);
  display: grid;
  gap: 8px;
}

.post-preview h3 {
  margin: 0;
}

.post-preview .excerpt {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding: 0 0 4px 0;
  border-bottom: 1px solid var(--border-strong);
  border-radius: 0;
  font-weight: 600;
}

body.dark .badge {
  color: var(--muted-strong);
}

.gallery-tile {
  display: grid;
  gap: 0;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.tile-image {
  background: color-mix(in srgb, var(--card), var(--accent) 6%);
  padding: 12px 12px 16px;
  min-height: 120px;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
  color: var(--text);
}

.tile-image strong {
  color: var(--accent);
}

.tile-thumb {
  width: 100%;
  height: 128px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: var(--bg);
}

.tile-image span {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.caption {
  border: none;
  padding: 18px 22px 20px;
  background: transparent;
  display: grid;
  gap: 8px;
}

.caption details {
  color: var(--muted);
}

/* Tufte-inspired notes and figures */
.page {
  position: relative;
  overflow: visible;
  max-width: 760px;
  margin: 0 auto;
}

.marginnote,
.sidenote {
  float: right;
  clear: right;
  margin-right: -300px;
  width: 240px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--muted-strong);
  margin-top: -0.1em;
}

.marginnote img,
.sidenote img {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 8px;
}

.margin-caption {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
}

.footnote-ref {
  vertical-align: super;
  font-size: 0.75em;
  margin-left: 2px;
}

.footnote-note .footnote-index {
  font-weight: 600;
  margin-right: 6px;
}

.sidenote-number,
.sidenote-number::after,
.sidenote-number::before {
  font-size: 0.75em;
}

.sidenote-number {
  vertical-align: super;
}

.sidenote-number::after {
  content: "]";
}

.sidenote-number::before {
  content: "[";
}

.margin-toggle {
  display: none;
}

.page figure {
  margin: 24px 0;
  clear: both;
}

.page figure figcaption {
  float: right;
  clear: right;
  margin-right: -300px;
  width: 240px;
  font-size: 0.9rem;
  color: var(--muted-strong);
  margin-top: 0;
  margin-bottom: 12px;
}

.fullwidth {
  width: calc(100% + 300px);
  margin-left: -150px;
}

.page figure.fullwidth figcaption {
  float: none;
  width: 100%;
  margin: 12px 0 0;
}

@media (max-width: 1100px) {
  .page {
    max-width: 680px;
  }

  .marginnote,
  .sidenote,
  .page figure figcaption {
    margin-right: -220px;
    width: 200px;
  }

  .fullwidth {
    width: calc(100% + 220px);
    margin-left: -110px;
  }
}

@media (max-width: 900px) {
  .page {
    max-width: 100%;
  }

  .marginnote,
  .sidenote,
  .page figure figcaption {
    float: none;
    margin-right: 0;
    width: 100%;
  }

  .fullwidth {
    width: 100%;
    margin-left: 0;
  }
}

.caption details {
  color: var(--muted);
}

.caption summary {
  cursor: pointer;
  color: var(--accent);
}

.caption a {
  font-weight: 600;
}

.page {
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 36px;
  box-shadow: var(--shadow);
}

.page h1 {
  margin-top: 0;
}

.page .kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--muted);
}

.page pre {
  background: #1f1f1f;
  color: #f1f1f1;
  padding: 16px;
  border-radius: 12px;
  overflow: auto;
}

.page code {
  background: rgba(31, 75, 63, 0.15);
  padding: 2px 6px;
  border-radius: 6px;
}

.page table {
  width: 100%;
  border-collapse: collapse;
}

.page table th,
.page table td {
  border-bottom: 1px solid var(--border-strong);
  padding: 10px 8px;
  text-align: left;
}

.footer {
  border-top: 1px solid var(--border-strong);
  padding: 24px;
  text-align: center;
  color: var(--muted);
}


body:not(.dark) .gallery-tile {
  border-color: color-mix(in srgb, var(--border-strong), var(--accent) 16%);
}

@media (max-width: 720px) {
  .nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero {
    padding: 28px;
  }
}
