:root {
  /* SF Pro Rounded where available (Safari via ui-rounded, or installed locally), else Rouna */
  --body-font: ui-rounded, "SF Pro Rounded", "Rouna";
  --heading-font: var(--body-font);
  --ink: #222;
  --text: #111;
  --bg: #ffecd2;
  /* Light grey behind code, pre and selected text */
  --tint: #f0f0f0;
  /* Grey for dates, meta and other secondary text */
  --muted: #777;
  --line: 9px;
  --rule-gap: 22px;
  --split: 70%;
  --gutter: 88px;
  --logo: 230px;
  --frame-top: 64px;
  /* Text sits inset within <main>: left and right space, and line length */
  --inset: calc(var(--gutter) * 1.2);
  --inset-end: 48px;
  --measure: 33em;
  /* Everything above <main>: top space, three rules and gaps, masthead (logo minus its overlap), rule */
  --header-h: calc(var(--frame-top) + 2 * var(--line) + 2 * var(--rule-gap) + var(--logo));
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body-font), system-ui, sans-serif;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

::selection {
  background: var(--tint);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
  text-underline-offset: 3px;
}

.frame {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-top: var(--frame-top);
  /* Anchors the side column (.side) */
  position: relative;
}

.rules,
.masthead,
.rule {
  /* Paint over <main>, which sits behind them */
  position: relative;
  z-index: 1;
}

.rules {
  display: flex;
  flex-direction: column;
  gap: var(--rule-gap);
}

.rules span,
.rule {
  display: block;
  height: var(--line);
  background: var(--ink);
}

/* Masthead */

.masthead {
  display: grid;
  grid-template-columns: var(--split) 1fr;
  align-items: end;
}

.brand {
  display: flex;
  align-items: center;
  gap: 48px;
  padding-left: var(--gutter);
  color: var(--ink);
}

.logo {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--logo);
  height: var(--logo);
  border: var(--line) solid var(--ink);
  border-radius: 50%;
  /* Pull the circle over the rules above and below it */
  margin: calc(-1 * var(--line)) 0;
  position: relative;
  z-index: 1;
  background: var(--bg);
}

.logo img {
  width: 56%;
  transform: translateY(-4%);
}

.masthead h1,
.byline {
  font-family: var(--heading-font), var(--body-font), sans-serif;
}

.masthead h1 {
  margin: 0;
  font-size: 84px;
  font-weight: 500;
  line-height: 1.02;
  text-transform: uppercase;
}

/* Bigger single-word heading for section pages, e.g. News */
.masthead h1.big {
  font-size: 160px;
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: -0.02em;
}

.byline {
  margin: 0;
  padding: 0 32px 18px 40px;
  font-size: 1rem;
  text-transform: uppercase;
  text-wrap: balance;
}

/* Hover: invert the brand cell (logo + title), not the byline */

@media (hover: hover) {
  .brand:hover {
    background: var(--ink);
    color: #fff;
  }

  .brand:hover .logo {
    background: #fff;
  }
}

/* Body */

.page-body {
  flex: 1;
  width: var(--split);
  margin-top: calc(-1 * var(--header-h));
  padding: calc(var(--header-h) + 96px) 0 120px;
  border-right: var(--line) solid var(--ink);
}

.text {
  max-width: calc(var(--measure) + var(--inset) + var(--inset-end));
  padding: 0 var(--inset-end) 0 var(--inset);
}

.news {
  list-style: none;
  padding-left: 0 !important;
}

.news li {
  margin-bottom: 0.4em;
  padding-left: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news .date {
  display: inline-block;
  min-width: 5.5em;
  color: var(--muted);
}

.work {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-flow: dense;
  align-items: start;
  gap: 1.5em;
  margin-bottom: 1.4em;
}

.work figure {
  position: relative;
  margin: 0;
}

.work .landscape {
  grid-column: 1 / -1;
}

@keyframes work-spin {
  to {
    transform: rotate(1turn);
  }
}

@media (hover: hover) {
  .work figure {
    transition:
      rotate 0.25s linear,
      scale 0.25s linear;
  }

  .work .cell:hover figure {
    rotate: 20deg;
    scale: 0.6;
    animation: work-spin 0.25s linear;
  }
}

.work img {
  display: block;
  margin: 0;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top;
  border: 4px solid var(--ink);
}

.work .landscape img {
  aspect-ratio: 16 / 10;
}

.work .book img {
  padding-bottom: 3em;
  background: #e2e2e2;
  object-position: 50% 25%;
}

.work .more figure {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  border: 4px solid var(--ink);
}

.work figcaption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.9em 0.8em;
  background: var(--ink);
  color: #fff;
  font-size: 0.8em;
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
}

@media (max-width: 500px) {
  .work {
    grid-template-columns: minmax(0, 1fr);
  }
}

.wide {
  padding: 0 var(--inset-end) 0 var(--inset);
}

.side {
  position: absolute;
  top: var(--header-h);
  bottom: 0;
  left: var(--split);
  right: 0;
}

html:has(.toc) {
  scroll-behavior: smooth;
}

.toc {
  position: sticky;
  top: 0;
  max-height: 100dvh;
  overflow-y: auto;
  padding: 40px 32px 40px 40px;
  font-size: 0.85rem;
}

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

.toc li {
  margin: 0 0 1.2em;
  line-height: 1.25;
}

@media (hover: hover) {
  .toc a:hover {
    text-decoration: underline;
  }
}

.toc .date {
  display: block;
  font-size: 0.8em;
  color: var(--muted);
}

.post {
  margin-bottom: 2.5em;
  padding-bottom: 2.5em;
  border-bottom: var(--line) solid var(--ink);
  scroll-margin-top: 24px;
}

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

.column .post h2 {
  margin-top: 0;
  margin-bottom: 0.3em;
}

.post h2 a {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: #ccc;
  text-underline-offset: 5px;
}

@media (hover: hover) {
  .post h2 a:hover {
    text-decoration-color: currentColor;
  }
}

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

@media (max-width: 1200px) {
  :root {
    --gutter: 48px;
    --logo: 160px;
  }

  .brand {
    gap: 32px;
  }

  .masthead h1 {
    font-size: 60px;
  }

  .masthead h1.big {
    font-size: 112px;
  }
}

@media (max-width: 800px) {
  :root {
    --line: 6px;
    --rule-gap: 14px;
    --gutter: 24px;
    --frame-top: 32px;
    --inset: var(--gutter);
    --inset-end: var(--gutter);
  }

  html,
  body {
    font-size: 18px;
  }

  .masthead {
    grid-template-columns: minmax(0, 1fr);
  }

  .brand {
    gap: 20px;
    padding: 0 var(--gutter);
  }

  .logo {
    width: 108px;
    height: 108px;
  }

  .masthead h1 {
    font-size: 40px;
  }

  .masthead h1.big {
    font-size: 72px;
  }

  .byline {
    padding: 16px var(--gutter);
    border-top: var(--line) solid var(--ink);
  }

  .side {
    display: none;
  }

  .page-body {
    width: auto;
    margin-top: 0;
    padding: 48px 0 72px;
    border-right: none;
  }
}
