/* Article page /{slug}/: header, table of contents, the column grid (content 680, wide 1040,
   full bleed; the renderer's image `sizes` assume these), side notes, series navigation, the
   end link and the discussion section. Loaded after prose.css and posts/code.css.

   Layout A (D082): one centred 680 column. From 1300px the table of contents moves into the
   left margin and footnotes are set beside their references in the right margin
   (js/sidenotes.js); narrower screens, print and pages without JavaScript keep the folded
   contents before the text and the notes at the end. */

.st-article-main {
  padding-top: 88px;
}
.st-page-scene + .st-article-main {
  padding-top: 64px;
}

/* ---------------------------------------------------------------- column grid */

.st-grid {
  display: grid;
  grid-template-columns:
    [full-start] minmax(24px, 1fr)
    [wide-start] minmax(0, 180px)
    [content-start] min(680px, calc(100% - 48px))
    [content-end] minmax(0, 180px)
    [wide-end] minmax(24px, 1fr)
    [full-end];
}
.st-grid > * {
  grid-column: content;
  min-width: 0;
}
.st-article-prose > .st-figure--wide,
.st-article-header > .st-article-cover {
  grid-column: wide;
}
.st-article-prose > .st-figure--full {
  grid-column: full;
}
.st-column {
  width: min(680px, calc(100% - 48px));
  margin-inline: auto;
}

/* ---------------------------------------------------------------- header
   Rows 16px apart, on the text's rhythm. */

.st-article-header {
  margin-bottom: 48px;
}
.st-article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  line-height: 1.7;
  letter-spacing: 0.01em;
  color: var(--st-meta);
}
.st-article-meta a:hover {
  opacity: 1;
  color: var(--st-accent);
}
.st-article-meta .st-tags {
  margin: 0;
}
.st-article-meta time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.st-article-title {
  margin-top: 16px;
  /* 42px on wide screens, 36px on phones. */
  font-size: clamp(2.25rem, 1.5rem + 2vw, 2.625rem);
  font-weight: 600;
  line-height: 1.34;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
.st-article-excerpt {
  margin-top: 16px;
  font-size: 1.0625rem;
  line-height: 1.875rem;
  color: var(--st-muted);
}
.st-byline {
  margin-top: 16px;
  font-size: 0.875rem;
  color: var(--st-muted);
}
.st-byline time {
  font-variant-numeric: tabular-nums;
}
.st-byline a:hover {
  opacity: 1;
  color: var(--st-accent);
}
/* The author's avatar before the name (D092); without one the byline is text only. */
.st-byline-avatar {
  margin: -3px 8px 0 0;
  vertical-align: middle;
}
.st-article-cover {
  margin-top: 48px;
}
.st-article-cover img {
  width: 100%;
  background: #eceee8;
  border-radius: 4px;
}

/* Article titles and section headings stay sans, as on the old site (D024). The appearance
   heading setting only drives the wordmark, poems and page headers. */

/* ---------------------------------------------------------------- table of contents
   Wide screens: a quiet rail in the left margin that follows the reader, the current section
   in ink with a 2px rule. Narrower: a collapsed "目录" before the text. */

.st-toc__list {
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  line-height: 1.6;
}
.st-toc__item a {
  display: block;
  padding: 5px 0;
  color: var(--st-meta);
  transition: color 0.2s;
}
.st-toc__item a:hover {
  opacity: 1;
  color: var(--st-ink);
}
.st-toc__item--3 a {
  padding-left: 14px;
  font-size: 0.8125rem;
}

.st-toc--inline {
  width: min(680px, calc(100% - 48px));
  margin: -16px auto 48px;
  border-top: 1px solid var(--st-line);
  border-bottom: 1px solid var(--st-line);
}
.st-toc__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 2px;
  font-size: 0.875rem;
  letter-spacing: 0.16em;
  color: var(--st-meta);
  cursor: pointer;
  list-style: none;
}
.st-toc__summary::-webkit-details-marker {
  display: none;
}
.st-toc__summary::after {
  content: '+';
  font-family: var(--st-mono);
  letter-spacing: 0;
}
.st-toc--inline[open] > .st-toc__summary::after {
  content: '−';
}
.st-toc--inline .st-toc__list {
  padding: 0 2px 14px;
}

.st-article-body {
  position: relative;
}
.st-toc--rail {
  display: none;
}

@media (min-width: 1300px) {
  .st-toc--inline {
    display: none;
  }
  .st-toc--rail {
    position: absolute;
    top: 0;
    right: calc(50% + 340px + 64px);
    bottom: 0;
    display: block;
    width: 200px;
  }
  .st-toc__inner {
    position: sticky;
    top: calc(var(--st-header) + var(--st-banner) + 40px);
    max-height: calc(100vh - var(--st-header) - var(--st-banner) - 80px);
    overflow-y: auto;
    transition: opacity 0.25s;
  }
  .st-toc--rail .st-toc__list {
    font-size: 0.84375rem;
    line-height: 1.375rem;
  }
  .st-toc--rail.is-covered .st-toc__inner {
    opacity: 0;
    pointer-events: none;
  }
  .st-toc--rail .st-toc__item a {
    padding: 4px 0 4px 14px;
    font-size: inherit;
    border-left: 2px solid transparent;
  }
  .st-toc--rail .st-toc__item--3 a {
    padding-left: 28px;
  }
  .st-toc--rail .st-toc__item a[aria-current='true'] {
    color: var(--st-ink);
    border-left-color: var(--st-ink);
  }
  /* With the contents in the left margin, wide figures only reach out to the right; their
     captions stay under the text column. */
  .st-article--toc .st-article-prose > .st-figure--wide {
    grid-column: content-start / wide-end;
  }
  .st-article--toc .st-article-prose > .st-figure--wide > figcaption {
    margin-left: 0;
  }
}

/* ---------------------------------------------------------------- side notes
   js/sidenotes.js copies each footnote next to its first visible reference (left edge 48px
   past the column) and marks the copied end notes .is-aside; only then, and only on wide
   screens, are those hidden. */

.st-sidenotes {
  display: none;
}

@media screen and (min-width: 1300px) {
  .st-sidenotes {
    display: block;
  }
  .st-sidenote {
    position: absolute;
    left: calc(50% + 340px + 48px);
    width: 232px;
    font-size: 0.84375rem;
    line-height: 1.375rem;
    letter-spacing: 0;
    color: var(--st-meta);
    overflow-wrap: anywhere;
    text-autospace: normal;
    line-break: strict;
    transition: color 0.2s;
  }
  .st-sidenote > * + * {
    margin-top: 8px;
  }
  .st-sidenote__num {
    margin-right: 6px;
    font-weight: 600;
    color: var(--st-ink);
    font-variant-numeric: tabular-nums;
  }
  .st-sidenote a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
  }
  .st-sidenote a:hover {
    opacity: 1;
    color: var(--st-ink);
  }
  .st-sidenote code {
    font-family: var(--st-mono);
    font-size: 0.875em;
  }
  .st-sidenote .katex {
    font-size: 1.1em;
  }
  .st-sidenote.is-active,
  .st-sidenote:focus-visible {
    color: var(--st-ink);
    outline: none;
  }
  .st-footnote.is-aside,
  .st-footnotes.is-aside {
    display: none;
  }
}

@media print {
  .st-sidenotes {
    display: none;
  }
}

/* ---------------------------------------------------------------- series */

.st-series {
  width: min(680px, calc(100% - 48px));
  margin: 64px auto 0;
  border-top: 1px solid var(--st-line);
}
.st-series__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  padding: 20px 0 4px;
  font-size: 0.875rem;
  color: var(--st-meta);
}
.st-series__label {
  font-size: 0.8125rem;
  letter-spacing: 0.2em;
  color: var(--st-muted);
}
.st-series__name {
  font-weight: 500;
  color: var(--st-ink);
}
.st-series__count {
  font-variant-numeric: tabular-nums;
}
.st-series__links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 40px;
}
.st-series__link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 0 22px;
}
.st-series__link--next {
  grid-column: 2;
  text-align: right;
}
.st-series__dir {
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  color: var(--st-muted);
}
.st-series__title {
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.6;
  overflow-wrap: anywhere;
  transition: color 0.2s;
}
.st-series__link:hover {
  opacity: 1;
}
.st-series__link:hover .st-series__title {
  color: var(--st-accent);
}
.st-series + .st-series {
  margin-top: 0;
}

/* ---------------------------------------------------------------- related posts (D095)
   Text rows under the article: the title, the date on the right, hairlines between. */

.st-related {
  width: min(680px, calc(100% - 48px));
  margin: 64px auto 0;
}
.st-related__list {
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--st-line);
}
.st-related__item {
  border-bottom: 1px solid var(--st-line);
}
.st-related__item a {
  display: flex;
  align-items: baseline;
  gap: 24px;
  padding: 16px 0;
}
/* A list title (D091): 22/32 at 600, in the title serif with serif headings (site.css). */
.st-related__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 32px;
  overflow-wrap: anywhere;
  transition: color 0.2s;
}
@media (max-width: 480px) {
  .st-related__title {
    font-size: 20px;
  }
}
.st-related__item time {
  flex: none;
  font-size: 0.8125rem;
  line-height: 24px;
  font-variant-numeric: tabular-nums;
  color: var(--st-meta);
}
.st-related__item a:hover {
  color: inherit;
}
.st-related__item a:hover .st-related__title {
  color: var(--st-accent);
}
.st-related__item a:focus-visible {
  outline-offset: 0;
}

/* ---------------------------------------------------------------- lightbox (D095)
   js/lightbox.js: pictures shown smaller than they are, and wide or full-bleed ones, open in a
   native <dialog> fitted to the window, with their caption. */

.st-zoomable {
  cursor: zoom-in;
}
.st-zoomable:focus-visible {
  outline: 2px solid var(--st-focus);
  outline-offset: 4px;
}
.st-lightbox-open {
  overflow: hidden;
}
.st-lightbox-open body {
  padding-right: var(--st-scrollbar-gap, 0);
}
.st-lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: var(--st-on-photo);
  background: transparent;
  border: 0;
}
.st-lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}
.st-lightbox::backdrop {
  background: var(--st-lightbox-bg);
}
.st-lightbox__figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: calc(100vw - 48px);
  margin: 0;
}
.st-lightbox__img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: calc(100dvh - 96px);
  object-fit: contain;
  cursor: default;
}
.st-lightbox.has-caption .st-lightbox__img {
  max-height: calc(100dvh - 176px);
}
.st-lightbox__caption {
  max-width: 680px;
  font-size: 0.875rem;
  line-height: 24px;
  text-align: center;
  color: var(--st-on-photo);
  overflow-wrap: anywhere;
}
.st-lightbox__caption .st-figure__label {
  font-weight: 500;
  color: inherit;
}
.st-lightbox__close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--st-on-photo);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.st-lightbox__close:hover {
  background: color-mix(in srgb, var(--st-on-photo) 12%, transparent);
}
.st-lightbox__close:focus-visible {
  outline-color: var(--st-on-photo);
  outline-offset: 0;
}

/* ---------------------------------------------------------------- end */

.st-article-end {
  width: min(680px, calc(100% - 48px));
  margin: 64px auto 100px;
  padding-top: 30px;
  border-top: 1px solid var(--st-line);
}

/* ---------------------------------------------------------------- discussion
   Values from the banshan theme's discussions.css; the palette accent replaces its fixed
   green. */

.st-discussion {
  width: min(680px, calc(100% - 48px));
  margin: 96px auto 0;
  padding-top: 32px;
  font-size: 16px;
  line-height: 1.75;
  border-top: 1px solid var(--st-line);
  scroll-margin-top: 100px;
}
.st-discussion.is-ready {
  animation: st-discussion-enter 200ms ease-out;
}
@keyframes st-discussion-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.st-discussion__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}
.st-discussion__heading h2 {
  font-size: 25px;
  font-weight: 550;
  line-height: 1.4;
}
.st-discussion__heading h2 span {
  margin-left: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--st-muted);
  font-variant-numeric: tabular-nums;
}
.st-discussion__login {
  font-size: 14px;
  white-space: nowrap;
}
.st-discussion__feedback {
  margin: 16px 0;
  font-size: 14px;
  color: var(--st-muted);
}
.st-discussion__feedback:empty {
  display: none;
}
.st-discussion__feedback.is-error,
.st-discussion__error {
  color: #984b42;
}
.st-discussion__notice {
  margin: 16px 0;
  font-size: 14px;
  color: var(--st-muted);
}

.st-discussion button {
  padding: 6px 10px;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  transition:
    background 180ms ease,
    color 180ms ease;
}
.st-discussion button:hover:not(:disabled) {
  background: rgb(72 102 90 / 0.07);
}
.st-discussion :is(button, textarea, summary):focus-visible {
  outline: 2px solid var(--st-accent);
  outline-offset: 4px;
}
.st-discussion button:disabled {
  cursor: default;
  opacity: 0.5;
}
.st-discussion .st-discussion__primary {
  padding: 10px 20px;
  color: var(--st-brand-fg);
  background: var(--st-brand);
  border-radius: 24px;
}
.st-discussion .st-discussion__primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--st-brand) 86%, #000);
}

.st-discussion__form {
  margin: 24px 0 32px;
  padding: 22px;
  background: rgb(255 255 255 / 0.45);
  border: 1px solid var(--st-line);
  border-radius: 14px;
}
.st-discussion__form label {
  display: block;
  margin-bottom: 12px;
  font-weight: 500;
}
.st-discussion__form textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 12px;
  font-size: 16px;
  line-height: 1.8;
  color: var(--st-ink);
  background: var(--st-paper);
  border: 1px solid var(--st-line);
  border-radius: 8px;
  resize: vertical;
}
.st-discussion__form textarea::placeholder {
  color: var(--st-muted);
}
.st-discussion__error {
  margin: 12px 0 0;
  font-size: 14px;
}
.st-discussion__error:empty {
  display: none;
}
.st-discussion__form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}
/* Replying or editing: the composer sits inside the comment it belongs to. */
.st-comment > .st-discussion__form {
  margin: 18px 0 4px;
}

.st-comment {
  padding: 28px 0;
  border-bottom: 1px solid var(--st-line);
  scroll-margin-top: 104px;
}
.st-comment:target {
  border-radius: 10px;
  outline: 2px solid var(--st-line);
  outline-offset: 10px;
}
.st-comment__byline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--st-muted);
}
.st-comment__avatar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 13px;
  color: var(--st-meta);
  background: var(--st-line);
  border-radius: 50%;
}
.st-comment__info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.st-comment__author {
  font-size: 0.9375rem;
  font-weight: 550;
  color: var(--st-ink);
}
.st-comment__author a:hover {
  opacity: 1;
  color: var(--st-accent);
}
.st-comment__reason {
  margin-top: 10px;
  font-size: 0.875rem;
  color: var(--st-meta);
}
.st-comment__body {
  margin: 12px 0 15px;
  overflow-wrap: anywhere;
}
.st-comment__body a {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.st-comment.is-hidden > :is(.st-comment__byline, .st-comment__body) {
  opacity: 0.6;
}
.st-comment__tombstone {
  font-size: 14px;
  color: var(--st-muted);
}
.st-comment__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--st-muted);
}
.st-comment__actions:empty {
  display: none;
}
.st-discussion .st-comment__actions button {
  padding: 2px 0;
}
.st-discussion .st-comment__actions button:hover:not(:disabled) {
  color: var(--st-accent);
  background: transparent;
}
.st-comment__actions [aria-pressed='true'] {
  font-weight: 550;
  color: var(--st-accent);
}
.st-comment__moderation {
  display: inline-flex;
  gap: 14px;
  margin-left: auto;
}
.st-comment__menu {
  position: relative;
  flex: none;
  margin-left: auto;
  color: var(--st-ink);
}
.st-comment__menu summary {
  padding: 4px 8px;
  font-size: 16px;
  cursor: pointer;
  list-style: none;
}
.st-comment__menu summary::-webkit-details-marker {
  display: none;
}
.st-comment__menu > div {
  position: absolute;
  right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-width: 168px;
  padding: 6px;
  background: var(--st-paper);
  border: 1px solid var(--st-line);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgb(25 40 32 / 0.08);
}
.st-discussion .st-comment__menu button {
  display: block;
  padding: 8px 10px;
  font-size: 14px;
  text-align: left;
  white-space: nowrap;
}
.st-comment__replies {
  margin: 0 0 0 22px;
  padding-left: 24px;
  border-left: 1px solid var(--st-line);
}
.st-comment__replies > .st-comment:last-child {
  border-bottom: 0;
}
.st-discussion__pagination {
  display: flex;
  justify-content: center;
  margin-top: 22px;
  font-size: 14px;
  color: var(--st-muted);
}
.st-discussion__empty {
  padding: 32px 0;
  color: var(--st-muted);
}

/* ---------------------------------------------------------------- tablet and phone */

@media (max-width: 800px) {
  .st-article-main {
    padding-top: 50px;
  }
  .st-page-scene + .st-article-main {
    padding-top: 44px;
  }
  .st-article-end {
    margin: 56px auto 70px;
  }
}

@media (max-width: 600px) {
  .st-article-excerpt {
    font-size: 1.0625rem;
  }
  .st-series__links {
    grid-template-columns: 1fr;
  }
  .st-series__link--next {
    grid-column: 1;
    text-align: left;
  }
  .st-series__link + .st-series__link {
    border-top: 1px solid var(--st-line);
  }
  .st-discussion {
    margin-top: 64px;
  }
  .st-discussion__heading {
    align-items: center;
    gap: 12px;
  }
  .st-discussion__heading h2 {
    font-size: 22px;
  }
  .st-discussion__login {
    font-size: 0.875rem;
  }
  .st-discussion__form {
    padding: 16px;
  }
  .st-comment__replies {
    margin-left: 6px;
    padding-left: 16px;
  }
  .st-comment__byline {
    gap: 8px;
  }
  .st-comment__moderation {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .st-discussion.is-ready {
    animation: none;
  }
}
