@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap");

:root {
  --color-bg: #ffffff;
  --color-text: #222222;
  --color-text-soft: #444444;
  --color-muted: #6b6862;
  --color-link: oklch(0.42 0.09 260);
  --color-link-hover: oklch(0.32 0.09 260);
  --color-border: #e2e0da;
  --color-border-light: #eceae5;
  --content-width: 920px;
  --article-width: 760px;
  --article-figure-width: 700px;
  --article-line-height: 1.85;
  --article-paragraph-gap: 0.9em;
  --page-gutter: 24px;
  --font-sans: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

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

html {
  background: var(--color-bg);
  color: var(--color-text);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--color-link-hover);
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 8px 12px;
  background: var(--color-bg);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: none;
}

#quarto-content {
  width: 100%;
  flex: 1 0 auto;
}

body.page-article #quarto-content.page-columns {
  display: block;
}

.page-columns,
main.content,
#quarto-document-content {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  display: block;
}

.quarto-title-block {
  display: none;
}

body.page-grade1 > #title-block-header,
body.page-about > #title-block-header,
body.page-privacy > #title-block-header,
body.page-contact > #title-block-header {
  display: none;
}

.site-header {
  width: 100%;
  border-bottom: 3px solid var(--color-link);
}

.site-header__inner,
.site-footer__inner,
.page-shell {
  width: min(calc(100% - (2 * var(--page-gutter))), var(--content-width));
  margin-inline: auto;
}

.site-header__inner {
  min-height: 61px;
  padding: 16px 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
}

.site-brand {
  display: flex;
  align-items: baseline;
  gap: 6px 14px;
  flex-wrap: wrap;
}

.site-brand__name {
  color: var(--color-text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
}

.site-brand__name:hover {
  color: var(--color-text);
}

.site-nav {
  display: flex;
  gap: 22px;
  font-size: 14px;
  line-height: 1.6;
}

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

.page-home .site-nav__home,
.page-grade1 .site-nav__grade1,
.page-article .site-nav__grade1 {
  color: var(--color-text);
  font-weight: 700;
}

.page-shell {
  padding-top: 8px;
  padding-bottom: 48px;
}

.page-shell--grade1,
.page-shell--article,
.page-shell--info {
  padding-top: 0;
}

.page-shell--article > .breadcrumb,
.page-shell--article > h1.article-title,
.page-shell--article > .article-last-updated,
.page-shell--article > .article-body,
.page-shell--article > section.article-title {
  width: min(100%, var(--article-width));
}

.page-shell--info > .breadcrumb,
.page-shell--info > h1.page-title,
.page-shell--info > .info-page {
  width: 100%;
}

.info-page {
  color: var(--color-text-soft);
  font-size: 16px;
  line-height: 1.9;
}

.info-page h2 {
  margin: 32px 0 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.6;
}

.info-page p {
  margin: 0 0 0.9em;
}

.contact-form-action {
  margin-top: 28px !important;
}

.contact-form-link {
  font-weight: 500;
}

.page-intro {
  margin: 24px 0 0;
  font-size: 16px;
  line-height: 1.9;
  text-wrap: pretty;
}

.page-title {
  margin: 28px 0 10px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.55;
}

.page-description {
  margin: 12px 0 0;
  color: var(--color-text-soft);
  font-size: 14.5px;
  line-height: 1.9;
}

.section-heading {
  margin: 36px 0 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.6;
}

.exam-index-link {
  margin: 16px 0 0;
  font-size: 16px;
  line-height: 2.2;
}

.exam-index-link strong,
.category-index strong {
  margin-right: 16px;
}

.updates {
  display: flex;
  flex-direction: column;
}

.update-item {
  padding: 12px 4px;
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 16px;
  align-items: baseline;
  border-bottom: 1px solid var(--color-border-light);
}

.update-item time {
  color: var(--color-muted);
  font-size: 14px;
}

.update-item a,
.update-item__text {
  min-width: 0;
  font-size: 16px;
}

.category-index {
  margin: 0;
  font-size: 15px;
  line-height: 2.2;
}

.category-heading-row {
  margin: 32px 0 0;
  padding-bottom: 8px;
  display: flex;
  align-items: baseline;
  gap: 8px 24px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--color-border);
  scroll-margin-top: 16px;
}

.category-heading-row h2,
.category-heading-row h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.6;
}

.category-heading-row h3 {
  font-size: 16px;
}

.category-heading-row p {
  margin: 0;
  font-size: 14px;
  line-height: 2;
}

.category-crosslinks__label {
  margin-right: 8px;
  color: var(--color-muted);
}

.application-heading {
  margin: 36px 0 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.6;
}

.application-category {
  margin-top: 24px;
  padding-bottom: 0;
  border-bottom: 0;
}

.application-category--following {
  margin-top: 32px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border);
}

.application-category--following h3 {
  font-size: 18px;
}

.section-placeholder {
  margin-top: 8px;
}

.exam-table-scroll {
  width: 100%;
  max-width: 100%;
  margin-top: 6px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.exam-table {
  min-width: 700px;
}

.exam-table__head,
.exam-row {
  display: grid;
  grid-template-columns: 52px repeat(5, minmax(0, 1fr));
  column-gap: 16px;
  align-items: start;
}

.exam-table__head {
  padding: 10px 4px 8px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.6;
}

.exam-table--no-head .exam-row:first-child {
  border-top: 1px solid var(--color-border-light);
}

.exam-table__head .problem-heading {
  grid-column: 2 / -1;
}

.exam-row {
  min-height: 53px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 15px;
  line-height: 1.9;
}

.exam-year {
  font-weight: 500;
}

.exam-problem {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  align-items: start;
}

.exam-theme {
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.exam-status {
  grid-column: 2 / -1;
  color: var(--color-muted);
}

.breadcrumb {
  margin: 0;
  display: flex;
  gap: 4px 8px;
  flex-wrap: wrap;
  color: var(--color-muted);
  font-size: 13px;
  line-height: 1.8;
}

.breadcrumb__separator {
  color: var(--color-muted);
}

h1.article-title {
  margin: 20px 0 24px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.6;
}

h1.article-title:has(+ .article-last-updated) {
  margin-bottom: 6px;
}

h1.article-title:has(+ .answer-article) {
  margin-bottom: 10px;
}

.article-last-updated {
  margin: 0 0 10px;
  color: var(--color-muted);
  font-size: 13.5px;
  line-height: 1.8;
  text-align: right;
}

.article-body {
  min-width: 0;
  font-size: 16px;
  line-height: 1.95;
}

.article-section-nav {
  margin: 26px 0 0;
  display: flex;
  gap: 4px 10px;
  align-items: baseline;
  font-size: 15px;
  line-height: 1.8;
}

h2.article-section-heading {
  margin: 34px 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.6;
}

.article-body h3 {
  margin: 28px 0 10px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.7;
}

.page-article .math.display {
  width: 100%;
  max-width: 100%;
  margin: 1.25rem 0;
  padding: 0.2rem 0 0.35rem;
  display: block;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.page-article .math.display > mjx-container[display="true"] {
  margin: 0 !important;
}

/* 解答兼解説記事：WordPress版の読み順をQuartoの共通構造として再実装 */
body.page-answer {
  overflow-x: hidden;
  overflow-x: clip;
}

.page-answer h1.article-title {
  margin-top: 22px;
  font-size: 26px;
  line-height: 1.45;
}

.page-answer .answer-article {
  color: #333333;
  font-size: 18px;
  line-height: var(--article-line-height);
}

.answer-article > p {
  margin: 0 0 var(--article-paragraph-gap);
}

.answer-article > p:has(> .math.display:only-child) {
  margin: 0;
}

.answer-article .article-notice {
  margin: 0 0 2.4em;
  padding: 1em 0 1.2em;
  border-top: 1px solid var(--color-border-light);
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text-soft);
  font-size: 0.78em;
  line-height: 1.8;
}

.answer-article .article-notice p {
  margin: 0 0 0.75em;
}

.answer-article .article-notice > p:nth-of-type(-n + 2) {
  margin-bottom: 0.2em;
}

.answer-article .article-notice ul {
  margin: 0.8em 0 0;
  padding-left: 1.4em;
}

.answer-article .article-notice li + li {
  margin-top: 0.25em;
}

.answer-article h2.answer-heading {
  margin: 0 0 1.4em;
  padding: 0;
  border: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.45;
}

.answer-article .answer-heading-row {
  display: flex;
  align-items: baseline;
  gap: 0.5em 1.2em;
  flex-wrap: wrap;
  margin: 0;
}

.answer-article .answer-heading-row h2.answer-heading {
  flex: 0 0 auto;
  margin: 0;
}

.answer-article h3.subquestion-heading {
  margin: 2em 0 1em;
  padding: 0.6em 0.9em;
  border: 0;
  border-radius: 2px;
  background: #f5f6f7;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
}

.answer-article .subquestion-nav {
  max-width: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4em 0.85em;
  flex-wrap: wrap;
  font-size: 0.92em;
}

.answer-article .subquestion-nav a {
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.page-answer .math.display {
  margin: 1.1em 0;
  padding: 0.15em 0;
}

.page-answer mjx-container:not([display="true"]) {
  margin-inline: 0.18em !important;
}

.page-answer mjx-mtr + mjx-mtr > mjx-mtd {
  padding-top: 0.18em !important;
}

/* alignedによる複数行の計算式は、行列より行間を広くする */
.page-answer mjx-container[display="true"] > mjx-math > mjx-mtable > mjx-table > mjx-itable > mjx-mtr + mjx-mtr > mjx-mtd {
  padding-top: 0.45em !important;
}

/* casesによる場合分けも、複数行の計算式と同じ行間にする */
.page-answer mjx-mo:has(> mjx-c.mjx-c7B) + mjx-mtable > mjx-table > mjx-itable > mjx-mtr + mjx-mtr > mjx-mtd {
  padding-top: 0.45em !important;
}

.answer-article figure {
  margin: 1.6em auto 0;
  max-width: var(--article-figure-width);
  text-align: center;
}

.answer-article figure img {
  width: auto;
  max-width: 100%;
  height: auto;
  display: block;
  margin-inline: auto;
}

.answer-article .table-scroll {
  width: 100%;
  max-width: 100%;
  margin: 1.4em 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.answer-article .table-scroll table {
  width: max-content;
  margin: 0 auto;
  border-collapse: collapse;
}

.answer-article .table-scroll th,
.answer-article .table-scroll td {
  padding: 0.45em 0.8em;
}

.answer-article .table-scroll thead th {
  border-bottom: 1px solid var(--color-text-soft);
}

.answer-article .table-scroll th:nth-child(1),
.answer-article .table-scroll td:nth-child(1),
.answer-article .table-scroll th:nth-child(3),
.answer-article .table-scroll td:nth-child(3) {
  border-right: 1px solid var(--color-text-soft);
}

.answer-article figcaption {
  margin-top: 0.55em;
  color: var(--color-muted);
  font-size: 0.72em;
  line-height: 1.6;
}

.article-prev-next {
  margin-top: 2.5em;
  padding-top: 1.1em;
  border-top: 1px solid var(--color-border-light);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
  font-size: 16px;
  line-height: 1.7;
}

.article-prev-next__item {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.article-prev-next__item--next {
  text-align: right;
}

.article-prev-next__label,
.article-prev-next__empty {
  color: var(--color-muted);
}

.article-prev-next__label {
  font-size: 0.8em;
}

.article-placeholder {
  margin: 28px 0 0;
  font-size: 15px;
  line-height: 2.1;
}

.article-back-link {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--color-border);
  font-size: 14px;
}

.site-footer {
  width: 100%;
  flex: 0 0 auto;
  border-top: 1px solid var(--color-border);
}

.site-footer__inner {
  padding: 20px 0;
  display: flex;
  justify-content: space-between;
  gap: 8px 24px;
  flex-wrap: wrap;
  color: var(--color-muted);
  font-size: 12.5px;
  line-height: 1.7;
}

.site-footer__nav {
  display: flex;
  gap: 8px 18px;
  flex-wrap: wrap;
}

@media (max-width: 767px) {
  :root {
    --page-gutter: 16px;
  }

  .page-answer h1.article-title {
    font-size: 22px;
  }

  .answer-article h2.answer-heading {
    font-size: 21px;
  }

  .answer-article h3.subquestion-heading {
    font-size: 20px;
  }

  .page-answer .answer-article {
    font-size: 16px;
  }

  .article-prev-next {
    font-size: 15px;
  }

  .answer-article h3.subquestion-heading {
    margin-top: 2em;
    padding: 0.6em 0.8em;
  }

  .exam-table-scroll {
    overflow-x: visible;
  }

  .exam-table {
    min-width: 0;
  }

  .exam-table__head,
  .exam-row {
    grid-template-columns: 52px minmax(0, 1fr);
    column-gap: 12px;
  }

  .exam-table__head .problem-heading {
    grid-column: 2;
  }

  .exam-row {
    row-gap: 7px;
  }

  .exam-row > .exam-problem,
  .exam-row > .exam-status {
    grid-column: 2;
  }

  .exam-row > [role="cell"][aria-label$="なし"] {
    display: none;
  }
}

@page {
  size: A4;
  margin: 14mm 12mm 16mm;
}

@media print {
  body.page-answer {
    overflow-x: visible;
  }

  .page-answer .math.display {
    width: 100%;
    max-width: 100%;
    margin-right: 0;
    margin-left: 0;
    overflow-x: visible;
    overflow-y: visible;
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
