/* Shared by the article and its rich-text editor; saved content keeps these classes. */
#pageContent .editable-content:has(.preface-document) {
  padding: 24px 32px 40px;
}

.preface-document {
  container: preface / inline-size;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  font-size: 16px;
  line-height: 1.85;
  color: var(--color-text, #30343b);
  overflow-wrap: anywhere;
}

.preface-document p {
  margin: 0 0 10px;
}

/* The guide preview lives in an iframe, outside editor.css. Empty paragraphs
   saved by Tiptap must still occupy a line after leaving the editor. */
.usage-guide-document p:empty {
  min-height: 1em;
  min-height: 1lh;
}

/* Keep screenshots and other inline document images inside the reading column. */
.preface-document img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 16px auto;
}

.preface-document .preface-title {
  margin: 0 0 20px;
  padding: 0;
  border: 0;
  font-family: inherit;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.15em;
  text-align: center;
  color: #214bb4;
}

.preface-introduction > p {
  text-indent: 2em;
}

.preface-document .preface-section-title {
  margin: 0;
  padding: 0;
  border: 0;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  font-style: italic;
  line-height: 1.85;
  color: #214bb4;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

.preface-document .preface-references-title {
  margin: 22px 0 10px;
}

.preface-references,
.preface-organizations {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
}

.preface-reference-column > p {
  margin: 0 0 8px;
  padding-left: 2em;
  text-indent: 0;
  line-height: 1.75;
}

.preface-reference-column > .preface-more {
  margin-bottom: 0;
  padding-left: 0;
  text-indent: 0;
  text-align: center;
}

.preface-section {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  align-items: start;
  gap: 8px 16px;
  margin-top: 22px;
}

.preface-document .preface-publisher {
  margin: 0;
}

/* Saved articles may still contain the previous bold publisher markup. */
.preface-document .preface-publisher,
.preface-document .preface-publisher strong {
  font-family: inherit;
  font-size: inherit;
  font-weight: 400;
}

.preface-organizations {
  column-gap: 36px;
}

.preface-organization-column {
  display: grid;
  align-content: start;
  gap: 10px;
}

.preface-document .preface-organization {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 0;
}

.preface-organization > span:last-child {
  flex: 0 0 auto;
}

.preface-document .preface-blank {
  display: block;
  flex: 1 1 0;
  min-width: 0;
  min-height: 1.55em;
  border-bottom: 1px solid #8c939d;
  text-align: center;
}

.preface-names {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px 22px;
}

.preface-document .preface-source {
  margin: 28px 0 0;
  font-size: 13px;
  text-align: right;
}

.preface-source a {
  color: #526a8b;
  text-underline-offset: 3px;
}

/* Follow the reading area's width, including resized desktop panels and editor iframes. */
@container preface (max-width: 700px) {
  .preface-references,
  .preface-organizations,
  .preface-section {
    grid-template-columns: minmax(0, 1fr);
  }

  .preface-organizations {
    row-gap: 10px;
  }

  .preface-section {
    margin-top: 20px;
    row-gap: 8px;
  }

  .preface-names {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 24px;
  }
}

@media (max-width: 600px) {
  #pageContent .editable-content:has(.preface-document) {
    padding: 18px 18px 28px;
  }

  .preface-document .preface-title {
    font-size: 24px;
    margin-bottom: 16px;
  }
}

:root[data-color-mode="dark"] .preface-document .preface-section-title,
:root[data-color-mode="dark"] .preface-document .preface-title {
  color: #a6c4ff;
}

:root[data-color-mode="dark"] .preface-source a {
  color: #a6c4ff;
}
