/* ===========================================================
   Essays — ink on paper
   Display: Gloock · Text: Literata · Accent: proofreader's red
   =========================================================== */

:root {
  color-scheme: light;
  --paper: oklch(0.972 0.012 85);
  --paper-deep: oklch(0.942 0.016 82);
  --ink: oklch(0.24 0.014 60);
  --ink-soft: oklch(0.40 0.014 60);
  --ink-faint: oklch(0.55 0.012 65);
  --rule: oklch(0.84 0.016 80);
  --accent: oklch(0.53 0.165 33);
  --accent-line: oklch(0.53 0.165 33 / 0.45);
  --selection: oklch(0.88 0.06 55);

  --display: "Gloock", "Literata", Georgia, serif;
  --text: "Literata", Georgia, "Times New Roman", serif;

  --wide: 880px;
  --measure: 640px;
  --gutter: clamp(20px, 5vw, 48px);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: oklch(0.205 0.008 60);
    --paper-deep: oklch(0.24 0.009 60);
    --ink: oklch(0.91 0.014 80);
    --ink-soft: oklch(0.78 0.012 75);
    --ink-faint: oklch(0.62 0.01 70);
    --rule: oklch(0.35 0.01 65);
    --accent: oklch(0.72 0.13 42);
    --accent-line: oklch(0.72 0.13 42 / 0.5);
    --selection: oklch(0.40 0.06 45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: oklch(0.205 0.008 60);
  --paper-deep: oklch(0.24 0.009 60);
  --ink: oklch(0.91 0.014 80);
  --ink-soft: oklch(0.78 0.012 75);
  --ink-faint: oklch(0.62 0.01 70);
  --rule: oklch(0.35 0.01 65);
  --accent: oklch(0.72 0.13 42);
  --accent-line: oklch(0.72 0.13 42 / 0.5);
  --selection: oklch(0.40 0.06 45);
}

/* ---------- base ---------- */

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

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-optical-sizing: auto;
  font-size: 19px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

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

a {
  color: inherit;
}

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -60px;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  z-index: 50;
}

.skip-link:focus {
  top: 12px;
}

.smallcaps,
.masthead-section,
.masthead-link,
.index-kicker,
.entry-meta,
.essay-strap,
.essay-byline,
.essay-filed,
.colophon,
.post-loop-name {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.07em;
  font-feature-settings: "c2sc", "smcp";
}

/* ---------- masthead ---------- */

.masthead {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 26px var(--gutter) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.masthead-brand {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  text-decoration: none;
  min-height: 40px;
  align-items: center;
  white-space: nowrap;
}

.masthead-name {
  font-family: var(--display);
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.005em;
}

.masthead-section {
  padding-left: 12px;
  border-left: 1px solid var(--rule);
  color: var(--accent);
  font-size: 18px;
  line-height: 1.1;
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.masthead-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 6px;
  font-size: 17px;
  color: var(--ink-soft);
  text-decoration: none;
  transition-property: color;
  transition-duration: 160ms;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  margin-right: -10px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 15px;
  cursor: pointer;
  transition-property: color, transform;
  transition-duration: 160ms;
}

.theme-toggle:active {
  transform: scale(0.94);
}

@media (hover: hover) {
  .masthead-link:hover,
  .theme-toggle:hover {
    color: var(--accent);
  }
}

main {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

main::before {
  content: "";
  display: block;
  height: 5px;
  margin-top: 16px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

/* ---------- index ---------- */

.index-head {
  padding: clamp(40px, 8vw, 84px) 0 clamp(36px, 6vw, 60px);
}

.index-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 18px;
}

.index-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(76px, 15vw, 156px);
  line-height: 0.88;
  letter-spacing: -0.022em;
}

.index-dek {
  max-width: 34ch;
  margin: 22px 0 0;
  color: var(--ink-soft);
  font-size: clamp(19px, 2.3vw, 22px);
  font-style: italic;
  line-height: 1.5;
  text-wrap: pretty;
}

.essay-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--ink);
}

.essay-list li {
  border-bottom: 1px solid var(--rule);
}

.entry {
  display: grid;
  grid-template-columns: minmax(96px, 150px) 1fr;
  gap: 0 clamp(20px, 4vw, 44px);
  padding: clamp(28px, 4vw, 44px) 0 clamp(32px, 4.5vw, 50px);
  text-decoration: none;
}

.entry-no {
  font-family: var(--display);
  font-size: clamp(64px, 9.5vw, 112px);
  line-height: 0.82;
  letter-spacing: -0.04em;
  color: var(--accent);
  font-variant-numeric: tabular-nums lining-nums;
}

.entry-body {
  display: block;
  min-width: 0;
}

.entry-meta {
  display: block;
  margin-bottom: 10px;
  color: var(--ink-faint);
  font-size: 17px;
  line-height: 1.2;
}

.entry-title {
  display: block;
  font-family: var(--display);
  font-size: clamp(32px, 4.6vw, 50px);
  line-height: 1.06;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.entry-title > span {
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 0 92%;
  background-size: 0% 2px;
  transition-property: background-size;
  transition-duration: 520ms;
  transition-timing-function: var(--ease);
}

.entry-dek {
  display: block;
  max-width: 54ch;
  margin-top: 16px;
  color: var(--ink-soft);
  font-size: 18px;
  font-style: italic;
  line-height: 1.55;
  text-wrap: pretty;
}

@media (hover: hover) {
  .entry:hover .entry-title > span {
    background-size: 100% 2px;
  }
}

.entry:focus-visible .entry-title > span {
  background-size: 100% 2px;
}

.index-empty {
  color: var(--ink-faint);
  font-style: italic;
  padding: 40px 0;
}

/* ---------- essay header ---------- */

.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  z-index: 40;
  pointer-events: none;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.essay-head {
  padding: clamp(40px, 7vw, 72px) 0 clamp(30px, 4vw, 40px);
  border-bottom: 1px solid var(--ink);
  margin-bottom: clamp(36px, 5vw, 52px);
}

.essay-strap {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 clamp(22px, 3vw, 30px);
  font-size: 18px;
  line-height: 1;
  color: var(--ink-faint);
}

.essay-no {
  color: var(--accent);
}

.essay-strap-rule {
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.essay-head h1 {
  margin: 0;
  max-width: 15ch;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(46px, 8vw, 88px);
  line-height: 1;
  letter-spacing: -0.016em;
  text-wrap: balance;
}

.essay-dek {
  max-width: 36ch;
  margin: clamp(20px, 3vw, 28px) 0 0;
  color: var(--ink-soft);
  font-size: clamp(20px, 2.5vw, 24px);
  font-style: italic;
  line-height: 1.45;
  text-wrap: pretty;
}

.essay-byline {
  margin: clamp(22px, 3vw, 30px) 0 0;
  color: var(--ink-faint);
  font-size: 17px;
  line-height: 1.3;
}

.essay-author {
  color: var(--ink);
}

.nowrap {
  white-space: nowrap;
}

/* ---------- prose ---------- */

.prose {
  max-width: var(--measure);
  counter-reset: section;
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1.1em;
  text-wrap: pretty;
  hanging-punctuation: first;
}

.prose > p:first-child::first-letter {
  float: left;
  margin: 0.06em 0.08em 0 -0.02em;
  font-family: var(--display);
  font-size: 4.6em;
  line-height: 0.8;
  color: var(--accent);
}

.prose > p:last-child::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin-left: 0.4em;
  background: var(--accent);
  vertical-align: 0.02em;
}

.prose h2 {
  counter-increment: section;
  margin: 2.4em 0 0.7em;
  font-family: var(--display);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: -0.006em;
  text-wrap: balance;
}

.prose h2::before {
  content: counter(section, upper-roman) ".";
  display: block;
  margin-bottom: 8px;
  font-family: var(--text);
  font-size: 18px;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.prose h3 {
  margin: 1.8em 0 0.5em;
  font-size: 21px;
  font-weight: 600;
}

.prose strong {
  font-weight: 650;
}

.prose a {
  text-decoration-line: underline;
  text-decoration-color: var(--accent-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition-property: color, text-decoration-color;
  transition-duration: 160ms;
}

@media (hover: hover) {
  .prose a:hover {
    color: var(--accent);
    text-decoration-color: var(--accent);
  }
}

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

.prose ul > li {
  position: relative;
  padding-left: 1.5em;
  margin: 0.6em 0;
}

.prose ul > li::before {
  content: "–";
  position: absolute;
  left: 0.15em;
  color: var(--accent);
}

.prose ol {
  padding-left: 1.4em;
}

.prose ol > li::marker {
  color: var(--accent);
}

.prose blockquote {
  margin: 0 0 1.1em;
  padding: 0 0 0 1.2em;
  border-left: 1px solid var(--rule);
  color: var(--ink-soft);
  font-style: italic;
}

.prose blockquote.pull {
  position: relative;
  width: min(var(--wide) - 2 * var(--gutter), calc(100vw - 2 * var(--gutter)));
  max-width: none;
  margin: 1.6em 0 1.7em;
  padding: 0.2em 0 0 64px;
  border: 0;
  color: var(--ink);
  font-style: normal;
}

.prose blockquote.pull::before {
  content: "“";
  position: absolute;
  left: -0.08em;
  top: -0.12em;
  font-family: var(--display);
  font-size: 96px;
  line-height: 1;
  color: var(--accent);
}

.prose blockquote.pull p {
  margin: 0;
  max-width: 22ch;
  font-family: var(--display);
  font-size: clamp(30px, 4.2vw, 44px);
  line-height: 1.14;
  letter-spacing: -0.008em;
  text-wrap: balance;
}

.prose code {
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82em;
  padding: 0.1em 0.35em;
  border-radius: 3px;
  background: var(--paper-deep);
}

.prose hr {
  border: 0;
  margin: 2.4em 0;
  text-align: center;
}

.prose hr::after {
  content: "⁂";
  font-size: 22px;
  color: var(--accent);
}

/* ---------- figure: design loop ---------- */

.post-loop {
  width: min(var(--wide) - 2 * var(--gutter), calc(100vw - 2 * var(--gutter)));
  margin: 2.2em 0 2.4em;
}

.post-loop ol {
  list-style: none;
  counter-reset: loop;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
  margin: 0;
  padding: 0;
}

.post-loop li {
  counter-increment: loop;
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--ink);
  font-size: 16px;
  line-height: 1.45;
}

.post-loop li::before {
  content: counter(loop, decimal-leading-zero);
  display: block;
  margin-bottom: 10px;
  font-family: var(--display);
  font-size: 40px;
  line-height: 0.9;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.post-loop-name {
  display: block;
  font-size: 19px;
  margin-bottom: 4px;
}

.post-loop-desc {
  display: block;
  color: var(--ink-soft);
}

.post-loop-return {
  margin: 20px 0 0 !important;
  color: var(--ink-soft);
  font-size: 17px;
  font-style: italic;
}

.post-loop-return i {
  margin-right: 8px;
  font-size: 0.8em;
  color: var(--accent);
}

.post-loop figcaption {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  color: var(--ink-faint);
  font-size: 15px;
  line-height: 1.5;
}

.post-loop figcaption::before {
  content: "Fig. 1  ";
  color: var(--ink);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.07em;
}

/* ---------- essay foot ---------- */

.essay-foot {
  max-width: var(--measure);
  margin-top: clamp(48px, 7vw, 72px);
  padding-top: 18px;
  border-top: 1px solid var(--ink);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px 24px;
}

.essay-filed {
  margin: 0;
  color: var(--ink-faint);
  font-size: 17px;
}

.essay-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  font-size: 18px;
  font-style: italic;
  text-decoration: none;
  transition-property: color;
  transition-duration: 160ms;
}

@media (hover: hover) {
  .essay-back:hover {
    color: var(--accent);
  }
}

/* ---------- colophon ---------- */

.colophon {
  max-width: var(--wide);
  margin: clamp(64px, 10vw, 110px) auto 0;
  padding: 0 var(--gutter) 40px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 24px;
  color: var(--ink-faint);
  font-size: 16px;
}

.colophon::before {
  content: "";
  flex-basis: 100%;
  height: 5px;
  margin-bottom: 14px;
  border-top: 1px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

.colophon p {
  margin: 0;
}

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  body {
    font-size: 17.5px;
    line-height: 1.68;
  }

  .masthead {
    padding-top: 16px;
  }

  .masthead-name {
    font-size: 19px;
  }

  .masthead-section {
    font-size: 16px;
    padding-left: 10px;
  }

  .masthead-brand {
    gap: 10px;
  }

  .masthead-link {
    font-size: 16px;
  }

  .entry {
    grid-template-columns: 1fr;
  }

  .entry-no {
    margin-bottom: 14px;
  }

  .entry-dek {
    font-size: 17px;
  }

  .prose h2 {
    font-size: 28px;
  }

  .prose blockquote.pull {
    padding-left: 44px;
  }

  .prose blockquote.pull::before {
    font-size: 72px;
  }

  .post-loop ol {
    grid-template-columns: 1fr 1fr;
    gap: 22px 18px;
  }
}

@media (max-width: 480px) {
  .masthead-section {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .entry-title > span,
  .masthead-link,
  .theme-toggle,
  .prose a,
  .essay-back {
    transition-duration: 0ms;
  }
}
