/*
  CSSの`@import`は、複数ファイルの読み込みが遅いなどの理由で非推奨になっている
  ここでは1つのファイルだけを読み込む目的で使用することにする

  複数ファイルを読み込む場合は、

  - Sassの`@use`を使う
  - Frontmaterで複数のCSSファイルを指定できるようにする

  などの代替案を検討すること
*/
@import url("/assets/css/markdown.css");

html {
  scroll-padding-top: 100px;
  scroll-behavior: smooth;
}

@media screen and (max-width: 519px) {
  main {
    padding: 15px;
  }
}
@media screen and (min-width: 750px) {
  main {
    --max-article-width: 660px;
    --aside-width: 250px;
    --column-gap: 60px;
    --w: calc(var(--max-article-width) + var(--column-gap) + var(--aside-width));
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--aside-width);
    row-gap: 30px; /* markdown.css側でも指定しているが、columnとの混同を防ぐため明示的に指定 */
    column-gap: var(--column-gap);
    padding-left: max(30px, calc((100vw - var(--w)) / 2));
    padding-right: max(30px, calc((100vw - var(--w)) / 2));
  }

  main > * {
    grid-column: 1;
  }

  main > .breadcrumbs {
    grid-column-start: 1;
    grid-column-end: -1;
  }

  main > aside {
    grid-row: 2;
    grid-column: 2;
  }

  .articles ~ aside {
    grid-row: 3;
    padding-top: 20px;
  }
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

.page-header > h1 {
  margin: 0;
  font-size: 1.5em;
}

@media screen and (min-width: 520px) {
  .page-header > h1 {
    font-size: 2em;
  }
}

.page-footer {
  padding: 20px 0;
  border-top: 1px solid #ddd;
  border-bottom: 1px solid #ddd;
}

.page-footer img {
  border-radius: 10px;
}

a.footer-banner {
  display: block;
  transition: 0.2s;
}
a.footer-banner:hover {
  opacity: 0.75;
  transform: scale(1.01);
}

/* -----------------------------------------------------------------
オウンドメディア記事一覧
----------------------------------------------------------------- */

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

.articles > article {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 2.5fr;
  grid-template-rows: auto 1fr;
  gap: 5px 10px;
  padding: 20px 0;
  text-decoration: none;
  border-bottom: 1px solid #eee;
}

@media screen and (min-width: 520px) {
  .articles > article {
    grid-template-columns: 180px 1fr;
  }
}

.articles > article .stretched-link::after {
  content: "";
  position: absolute;
  inset: 0;
  display: block;
}

.articles > article .title {
  grid-column: 2;
  grid-row: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  font-weight: bold;
}
.articles > article .title:hover {
  text-decoration: underline;
}

@media screen and (max-width: 360px) {
  .articles > article .title {
    font-size: 12px;
  }
}

@media screen and (min-width: 520px) {
  .articles > article .title {
    font-size: 16px;
  }
}

.articles > article .tags {
  grid-column: 2;
  grid-row: 2;
  pointer-events: none; /* .stretched-link::after のクリック領域を阻害しないために必要 */
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 18px;
}

.tag > a {
  font-size: 12px;
  color: #999;
  pointer-events: all; /* .articles > article .tags での指定を元に戻す */
  padding: 0 3px;
  position: relative;
  left: 13px;
  height: 26px;
  line-height: 26px;
  display: inline-block;
  white-space: nowrap;
  background-color: #def4f8;
}
.tag > a:before {
  content: "";
  position: absolute;
  left: -25.5px;
  border-right: 13px solid;
  border-top: 13px solid transparent;
  border-left: 13px solid transparent;
  border-bottom: 13px solid transparent;
  color: #def4f8;
}

.tag > a:after {
  position: absolute;
  top: calc(50% - 3px);
  left: -6px;
  width: 6px;
  height: 6px;
  content: "";
  border-radius: 50%;
  background: #fff;
}

.tag > a:hover {
  text-decoration: underline;
}

@media screen and (min-width: 520px) {
  .tag > a {
    font-size: 14px;
  }
}

.articles > article img {
  grid-column: 1;
  grid-row: 1 / -1;
  display: block;
  border-radius: 1px;
  pointer-events: none;
  border: 1px solid #ddd;
}

/* -----------------------------------------------------------------
オウンドメディア個別ページ
----------------------------------------------------------------- */

.article-header {
  display: flex;
  flex-direction: column;
  gap: 1em;
  padding-bottom: 15px;
  border-bottom: 1px solid #ccc;
}

.article-header > :empty {
  display: none;
}

.article-header > h1 {
  font-size: 1.5em;
}

@media screen and (min-width: 520px) {
  .article-header > h1 {
    font-size: 2.25em;
    line-height: 1.3;
  }
}

.article-header .published-at {
  font-size: 14px;
  color: #a8abb1;
}

.toc {
  padding: 1.5em 1em;
  background: #f7f8f9;
  color: #5f5f5f;
}

@media screen and (min-width: 520px) {
  .toc {
    padding: 2em;
  }
}

.toc summary {
  font-size: 15px;
  font-weight: 600;
}

.toc summary + ul {
  margin-top: 1em;
}

.toc li {
  margin-left: 1em;
  list-style: unset;
}

@media screen and (min-width: 520px) {
  .toc li {
    margin-left: 1.2em;
  }
}

.toc a {
  display: block;
  padding: 0.25em 0;
  font-size: 15px;
  color: inherit;
}

.toc a:hover {
  text-decoration: underline;
}

.markdown {
  color: #272727;
}

.markdown p {
  width: 100%;
  line-height: 1.8;
}

.markdown a {
  color: #55778d;
}

.markdown img {
  margin: 0 auto;
  max-height: 350px;
}

@media screen and (min-width: 750px) {
  .markdown img {
    max-height: 400px;
  }
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
  margin-top: 1.25em;
}

.markdown h2 {
  width: 100%;
  margin-top: 0.5em;
  margin-bottom: 0.25em;
  padding: 1em 0.75em;
  letter-spacing: 0.01em;
  font-size: 1.2em;
  line-height: 1.4;
  background-color: #3880b0;
  color: #fff;
}

@media screen and (min-width: 520px) {
  .markdown h2 {
    padding: 1.5em 1.25em;
    font-size: 1.3em;
  }

  .markdown h2:nth-child(n + 2) {
    margin-top: 1.5em;
  }
}

.markdown h3 {
  margin-top: 0.75em;
  margin-left: 0.1em;
  padding-left: 0.75em;
  font-size: 1.1em;
  line-height: 1.3;
  border-left: 0.5em solid #3880b0;
}

@media screen and (min-width: 520px) {
  .markdown h3 {
    margin-top: 1em;
    font-size: 1.25em;
  }
}

.markdown h4 {
  display: flex;
  font-size: 1em;
  align-items: center;
  gap: 0.4em;
}

.markdown h4::before {
  content: "";
  display: block;
  width: 10px;
  height: 2px;
  transform: translateY(1px);
  background-color: #000;
}

.markdown > ol,
.markdown > ul {
  width: 100%;
  border-radius: 2px;
  background-color: #f7f8f9;
}

.markdown > ol {
  padding: 1em;
  gap: 7px;
}

@media screen and (min-width: 520px) {
  .markdown > ol {
    padding: 1.5em 1.75em;
  }
}

.markdown > ul {
  padding: 1.5em 1.75em;
}

.markdown > ul ::marker {
  color: #272727;
}

.markdown ul > li,
.markdown ol > li {
  margin-left: 16px;
}

.markdown table {
  width: 100%;
  margin: 5px 0;
}

.markdown table tr > :first-child {
  white-space: pre;
}

.markdown table td {
  vertical-align: top;
}

/*
  画面幅が小さい場合に、tableを横スクロール可能にする。
  tableにblock要素を指定するのは少しハッキーだけど、今のところ表示は良さそう

  TODO: 横スクロール可能なことをわかりやすく示す
*/
@media screen and (max-width: 519px) {
  .markdown table {
    display: block;
    overflow-x: scroll;
    white-space: nowrap;
    font-size: 15px;
  }
}

table.scroll-table {
  display: block;
  overflow-x: scroll;
  white-space: nowrap;
}

/* -----------------------------------------------------------------
サイドカラム
----------------------------------------------------------------- */

aside {
  display: flex;
  flex-direction: column;
  row-gap: 40px;
}

aside > section {
  all: unset;
}

.aside-banner {
  display: none;
}
@media screen and (min-width: 750px) {
  .aside-banner {
    display: block;
  }
}

.aside-banner > a {
  display: block;
  transition: 0.2s;
}
.aside-banner > a:hover {
  opacity: 0.75;
  transform: scale(1.02);
}

.aside-banner img {
  border-radius: 5px;
}

.recommended-articles {
  display: flex;
  flex-direction: column;
}
@media screen and (min-width: 750px) {
  .recommended-articles {
    position: sticky;
    top: 100px;
    gap: 5px;
  }
}

.recommended-articles > header {
  font-size: 14px;
  font-weight: bold;
  color: #666;
}
@media screen and (min-width: 750px) {
  .recommended-articles > header {
    font-size: 12px;
  }
}

.recommended-articles > ul {
  display: flex;
  flex-direction: column;
}

.recommended-article > a {
  display: block;
  padding: 18px 0px;
  text-decoration: none;
  color: #303036;
  border-bottom: 1px solid #eee;
}

.recommended-article:last-child > a {
  border-bottom: 1px solid #eee;
}

.recommended-article > a:hover {
  text-decoration: underline;
}

.recommended-article .labels {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recommended-article .title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  font-weight: bold;
}

@media screen and (max-width: 360px) {
  .recommended-article .title {
    font-size: 12px;
  }
}

@media screen and (min-width: 520px) {
  .recommended-article .title {
    font-size: 16px;
  }
}

@media screen and (min-width: 750px) {
  .recommended-article .title {
    font-size: 14px;
  }
}
.pagination_button {
  display: inline-block;
  text-align: center;
  font-size: 15px;
  margin: 10px 3px 0;
  height: 38px;
  min-width: 38px;
  line-height: 34px;
  border-radius: 38px;
  border: 2px solid #ddd;
  padding: 0 0.5em;
  font-weight: 700;
}
.pagination_button:not(.current):hover {
  background-color: #ececec;
}
.article_index {
  margin: 20px 0 0;
  color: #666;
}
.pagination_button.current {
  color: var(--blue-2023);
  border-color: var(--blue-2023);
}
