:root {
  color-scheme: light dark;
  --bg: #fbfbf8;
  --text: #20211f;
  --muted: #626760;
  --line: #d8ddd5;
  --accent: #315f5b;
  --accent-hover: #173d3a;
  --accent-underline: rgb(49 95 91 / 35%);
  --photo-bg: #e8eee9;
  --fallback-bg: #eef3ee;
  --pattern: rgb(36 33 29 / 8%);
  --pattern-soft: rgb(36 33 29 / 7%);
  --font: "Inter Variable", Arial, sans-serif;
  --title-size: 18px;
  --text-size: 9px;
  --nav-size: 12px;
  --meta-size: 9px;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111412;
  --text: #f1eee6;
  --muted: #a7afa8;
  --line: #303830;
  --accent: #9bcac1;
  --accent-hover: #d3eee8;
  --accent-underline: rgb(155 202 193 / 45%);
  --photo-bg: #1b211e;
  --fallback-bg: #171c19;
  --pattern: rgb(241 238 230 / 7%);
  --pattern-soft: rgb(241 238 230 / 6%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111412;
    --text: #f1eee6;
    --muted: #a7afa8;
    --line: #303830;
    --accent: #9bcac1;
    --accent-hover: #d3eee8;
    --accent-underline: rgb(155 202 193 / 45%);
    --photo-bg: #1b211e;
    --fallback-bg: #171c19;
    --pattern: rgb(241 238 230 / 7%);
    --pattern-soft: rgb(241 238 230 / 6%);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  font-size: var(--text-size);
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration-color: var(--accent-underline);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.page {
  display: grid;
  grid-template-columns: 148px minmax(0, 660px);
  gap: 48px;
  width: min(calc(100% - clamp(28px, 10vw, 128px) - 28px), 940px);
  margin: 0 0 0 clamp(28px, 10vw, 128px);
  padding: 54px 0 80px;
}

.intro {
  display: contents;
}

.nav {
  position: sticky;
  top: 40px;
  align-self: start;
  display: flex;
  grid-column: 1;
  grid-row: 1 / span 20;
  flex-direction: column;
  gap: 7px;
  font-size: var(--nav-size);
  letter-spacing: 0;
  line-height: 1.35;
}

.nav::before {
  margin-bottom: 8px;
  color: var(--muted);
  content: "Francis Greenleaf";
  font-size: var(--nav-size);
}

.nav a {
  color: var(--muted);
  text-decoration: none;
}

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

.nav a[aria-current="page"] {
  color: var(--text);
}

.theme-toggle {
  position: fixed;
  left: clamp(28px, 10vw, 128px);
  bottom: 28px;
  z-index: 10;
  flex: 0 0 auto;
  width: 30px;
  height: 16px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.theme-toggle::before {
  position: absolute;
  top: 3px;
  left: 4px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  content: "";
  transition:
    background-color 180ms ease,
    transform 180ms ease;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--muted);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

:root[data-theme="dark"] .theme-toggle::before {
  transform: translateX(12px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle::before {
    transform: translateX(12px);
  }
}

h1 {
  max-width: 12ch;
  margin: 0;
  font-size: var(--title-size);
  font-weight: 500;
  line-height: 1.1;
}

#site-title {
  grid-column: 2;
  max-width: none;
  font-size: var(--title-size);
}

.portrait-block {
  grid-column: 2;
  margin: 32px 0 28px;
}

.portrait {
  display: block;
  width: min(100%, 260px);
  aspect-ratio: 1;
  border: 0;
  background: var(--photo-bg);
  object-fit: cover;
  object-position: center;
}

.portrait-fallback {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 420px;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 28px;
  border: 1px solid var(--line);
  color: var(--muted);
  background:
    linear-gradient(135deg, var(--pattern) 25%, transparent 25%) 0 0 / 18px
      18px,
    linear-gradient(315deg, var(--pattern) 25%, transparent 25%) 0 0 / 18px
      18px,
    var(--fallback-bg);
  text-align: center;
}

.portrait-fallback span {
  color: var(--text);
  font-size: var(--text-size);
}

.portrait-fallback small {
  font-size: var(--meta-size);
}

.copy {
  grid-column: 2;
  max-width: 590px;
}

.copy p {
  margin: 0;
}

.copy p + p {
  margin-top: 22px;
}

.compact-intro {
  display: contents;
}

.list-section {
  display: grid;
  gap: 28px;
  grid-column: 2;
  margin-top: 38px;
}

.list-item {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.list-item h2 {
  margin: 0 0 8px;
  font-size: var(--text-size);
  font-weight: 500;
  line-height: 1.45;
}

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

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

.list-item p,
.muted {
  margin: 0;
  color: var(--muted);
}

.article {
  grid-column: 2;
  margin-top: 0;
}

.article-header {
  margin-bottom: 34px;
}

.article-header h1 {
  max-width: none;
  font-size: var(--title-size);
  line-height: 1.1;
}

.article-header p {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: var(--meta-size);
}

.article-body h1,
.article-body h2 {
  margin: 34px 0 12px;
  font-weight: 500;
  line-height: 1.45;
}

.article-body h1 {
  font-size: var(--title-size);
}

.article-body h2 {
  font-size: var(--text-size);
}

.article-body p,
.article-body ul {
  margin: 0;
}

.article-body p + p,
.article-body p + ul,
.article-body ul + p {
  margin-top: 20px;
}

.article-body li + li {
  margin-top: 6px;
}

code {
  font-family: inherit;
  font-size: inherit;
}

.gallery-page h1 {
  max-width: none;
}

.gallery {
  column-gap: 14px;
  columns: 3 180px;
  grid-column: 2;
  margin-top: 46px;
}

.gallery-item {
  break-inside: avoid;
  margin: 0 0 14px;
}

.gallery-photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  border: 0;
  background: var(--photo-bg);
  object-fit: cover;
  object-position: center;
}

.photo-square .gallery-photo {
  aspect-ratio: 1;
}

.photo-wide .gallery-photo {
  aspect-ratio: 4 / 3;
}

.photo-tall .gallery-photo {
  aspect-ratio: 3 / 4;
}

.photo-fallback {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 260px;
  place-items: center;
  padding: 24px;
  border: 1px solid var(--line);
  color: var(--muted);
  background:
    linear-gradient(135deg, var(--pattern-soft) 25%, transparent 25%) 0 0 /
      16px 16px,
    linear-gradient(315deg, var(--pattern-soft) 25%, transparent 25%) 0 0 /
      16px 16px,
    var(--fallback-bg);
  font-size: var(--text-size);
  text-align: center;
}

@media (max-width: 900px) {
  .gallery {
    columns: 2 180px;
  }
}

@media (max-width: 720px) {
  .page,
  .gallery-page {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 28px;
    width: min(calc(100% - 36px), 860px);
    margin-left: 18px;
  }
}

@media (max-width: 560px) {
  .page,
  .gallery-page {
    display: block;
    width: min(100% - 28px, 680px);
    margin: 0 auto;
    padding: 26px 0 54px;
  }

  .intro {
    display: block;
  }

  .nav {
    position: static;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 36px;
  }

  .nav::before {
    margin-bottom: 0;
  }

  .portrait-block {
    margin: 28px 0 26px;
  }

  .portrait {
    width: min(100%, 220px);
  }

  .portrait-fallback {
    min-height: 330px;
  }

  .gallery {
    column-gap: 12px;
    columns: 2 140px;
    margin-top: 36px;
  }

  .gallery-item {
    margin-bottom: 12px;
  }

  .photo-fallback {
    min-height: 170px;
  }

  .list-section,
  .article {
    margin-top: 36px;
  }

}
