@use "sass:math";
@use "../../global/acms-common" as acms;
@use "../../global/common" as global;

/* ------------------------------
　　エントリー
------------------------------ */
.#{acms.$entry-class} {
  overflow: hidden;
  word-break: break-word;
}

/*  テキストユニット
------------------------------ */
.#{global.$entry-text-unit} {
  @include acms.font-size(global.$entry-font-size-base);

  color: global.$entry-text-base-color;
  font-weight: global.$entry-font-weight-normal;
  word-break: break-word;

  /* 共通余白設定 */
  h2,
  h3,
  h4,
  h5,
  h6,
  p,
  dl {
    margin-right: math.div(acms.$grid-space, 2);
    margin-left: math.div(acms.$grid-space, 2);
  }

  blockquote {
    margin-right: 0;
    margin-left: 0;
  }

  /* リンク */
  a {
    &:link,
    &:hover,
    &:focus,
    &:active {
      color: global.$link-color;
      text-decoration: underline;
    }

    &:visited {
      color: global.$link-color-visited;
    }
  }

  /* 強調 */
  em {
    font-weight: global.$entry-font-weight-normal;
    font-style: normal;
    border-bottom: dotted 3px global.$entry-color-point-base;
  }

  /* 重要 */
  strong{
    font-weight: global.$entry-font-weight-bold;
    font-style: normal;
  }
}

@media screen and (min-width: acms.$breakpoint-md-min) {
  .#{global.$entry-text-unit} {
    @include acms.font-size(global.$entry-font-size-base-wide-screen);
    @include acms.font-size(global.$entry-font-size-base-wide-screen);
  }
}

/* 見出し */
.#{global.$entry-text-unit} {
  h2:not([class]) {
    @include acms.font-size(global.$entry-font-size-title-lg);
    @include acms.font-size(global.$entry-font-size-title-lg);

    margin-top: global.$entry-element-margin-top;
    margin-bottom: global.$entry-element-margin-bottom-md;
    padding: 0 0 0 10px;
    overflow: hidden;
    font-weight: global.$entry-font-weight-bold;
    line-height: global.$entry-title-lineheight;
    border-left: 4px solid global.$entry-color-point-base;
  }

  h3:not([class]) {
    @include acms.font-size(global.$entry-font-size-title-md);
    @include acms.font-size(global.$entry-font-size-title-md);

    margin-top: global.$entry-element-margin-top;
    margin-bottom: global.$entry-element-margin-bottom-md;
    padding: 10px;
    overflow: hidden;
    font-weight: global.$entry-font-weight-normal;
    line-height: global.$entry-title-lineheight;
    background-color: global.$entry-color-bg-base;
  }

  h4:not([class]) {
    @include acms.font-size(global.$entry-font-size-title-sm);
    @include acms.font-size(global.$entry-font-size-title-sm);

    margin-top: global.$entry-element-margin-top;
    margin-bottom: global.$entry-element-margin-bottom-md;
    overflow: hidden;
    font-weight: global.$entry-font-weight-normal;
    line-height: global.$entry-title-lineheight;
  }
}

@media screen and (min-width: acms.$breakpoint-md-min) {
  .#{global.$entry-text-unit} {
    h2:not([class]) {
      @include acms.font-size(global.$entry-font-size-title-lg-wide-screen);
      @include acms.font-size(global.$entry-font-size-title-lg-wide-screen);
    }

    h3:not([class]) {
      @include acms.font-size(global.$entry-font-size-title-md-wide-screen);
      @include acms.font-size(global.$entry-font-size-title-md-wide-screen);
    }

    h4:not([class]) {
      @include acms.font-size(global.$entry-font-size-title-sm-wide-screen);
      @include acms.font-size(global.$entry-font-size-title-sm-wide-screen);
    }
  }
}

/* 本文 */
.#{global.$entry-text-unit} {
  p:not([class]) {
    margin-top: global.$entry-element-margin-top;
    margin-bottom: global.$entry-element-margin-bottom-md;
    font-weight: global.$entry-font-weight-normal;
    line-height: global.$entry-text-lineheight;
  }
}

/* リスト */
.#{global.$entry-text-unit} ul {
  margin: global.$entry-element-margin-top 0 global.$entry-element-margin-bottom-md 0;
  padding: 0 math.div(acms.$grid-space, 2);

  li {
    position: relative;
    display: block;
    margin: 0 0 global.$entry-list-li-bottom-space 0;
    padding: 0 0 0 global.$entry-list-marker-space;
    font-weight: global.$entry-font-weight-normal;
    line-height: global.$entry-text-lineheight;

    &::before {
      position: absolute;
      top: .5em;
      left: 12px;
      width: 0;
      height: 0;
      border: 3px solid global.$entry-color-point-base;
      border-radius: 50%;
      content: "";
    }

    ul {
      margin: global.$entry-list-li-bottom-space 0;
    }
  }
}

/* 番号付きリスト */
.#{global.$entry-text-unit} ol {
  margin: global.$entry-element-margin-top 0 global.$entry-element-margin-bottom-md 0;
  padding: 0 math.div(acms.$grid-space, 2);
  list-style: none;
  counter-reset: ol-counter;

  li {
    position: relative;
    margin: 0 0 global.$entry-list-li-bottom-space 0;
    padding: 0 0 0 global.$entry-list-marker-space;
    line-height: global.$entry-text-lineheight;

    &::before {
      position: absolute;
      top: .4em;
      left: 8px;
      display: inline-block;
      color: global.$entry-color-point-base;
      line-height: 1;
      content: counter(ol-counter)".";
      counter-increment: ol-counter;
    }

    ol {
      margin-top: global.$entry-list-li-bottom-space;
    }
  }
}

/* 定義リスト */
.#{global.$entry-text-unit} dl {
  margin-top: global.$entry-element-margin-top;
  margin-bottom: global.$entry-element-margin-bottom-lg;
  padding: global.$entry-dl-space 0;
  line-height: global.$entry-text-lineheight;
  border-top: global.$entry-dl-border;
  border-bottom: global.$entry-dl-border;

  dt {
    position: relative;
    margin: 0 0 5px;
    padding-left: global.$entry-dt-border-space + global.$entry-dt-border-width;
    font-weight: global.$entry-font-weight-bold;

    &::before {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      border-left: global.$entry-dt-border-width solid global.$entry-color-point-base;
      content: "";
    }
  }

  dd {
    margin-left: 0;
    padding-left: global.$entry-dt-border-width + global.$entry-dt-border-space;

    & + dt {
      margin-top: global.$entry-dl-space;
      padding-top: global.$entry-dl-space;
      border-top: global.$entry-dl-border;

      &::before {
        top: global.$entry-dl-space;
      }
    }
  }
}

/* 引用 */
[class*=column-quote] blockquote,
.#{global.$entry-text-unit} blockquote {
  box-sizing: border-box;
  width: 100%;
  margin-top: global.$entry-element-margin-top;
  margin-bottom: global.$entry-element-margin-bottom-lg;
  padding: 30px!important; /* acms-adminの上書き */
  line-height: global.$entry-text-lineheight;
  background: global.$entry-color-bg-base;
  border-left: 4px solid global.$entry-color-point-base;
}

/* ソースコード */
.#{global.$entry-text-unit} pre {
  box-sizing: border-box;
  width: 100%;
  margin: global.$entry-element-margin-top 0 global.$entry-element-margin-bottom-lg 0;

  ol {
    margin: 0;
    padding: 0 0 0 2em;
    list-style: decimal;

    li {
      margin: 0 0 3px;
      padding-left: 12px;
      line-height: 1.7;

      &::before {
        content: none;
      }
    }
  }
}

/*  テーブルユニット
/*  テキストユニットのテーブル
------------------------------ */
.#{global.$entry-text-unit} table,
[class^=column-table-] table {
  width: calc(100% - #{acms.$grid-space});
  margin: 0 math.div(acms.$grid-space, 2) global.$entry-element-margin-bottom-lg;
  border: 0 solid global.$entry-color-border-base;
  border-right-width: 1px;
  border-bottom-width: 1px;
  border-collapse: collapse;
}

.#{global.$entry-text-unit} th,
[class^=column-table-] th,
.#{global.$entry-text-unit} td,
[class^=column-table-] td {
  display: block;
  padding: 5px 10px;

  @include acms.font-size(global.$entry-font-size-base);
  @include acms.font-size(global.$entry-font-size-base);

  line-height: global.$entry-text-lineheight;
  border: 0 solid global.$entry-color-border-base;
  border-top-width: 1px;
  border-left-width: 1px;
}

.#{global.$entry-text-unit} th,
[class^=column-table-] th{
  font-weight: global.$entry-font-weight-bold;
  background-color: global.$entry-color-bg-base;

  &:not([align]) {
    text-align: left;
  }
}

/* テーブルユニット */
[class^="column-table-"] .entry-container {
  margin-bottom: global.$entry-element-margin-bottom-lg;
  overflow-x: auto;
  overflow-y: visible !important;
  -webkit-overflow-scrolling: touch;

  /* entry-containerで余白を保つため打ち消し */
  table {
    width: 100%;
    margin-right: 0;
    margin-bottom: 0;
    margin-left: 0;
  }
}

/* テキストユニットでのテーブル */

/* entry-containerで余白を保つため打ち消し */
.#{global.$entry-text-unit} .entry-container table {
  width: 100%;
  margin-right: 0;
  margin-left: 0;
}

/* スクロールするテーブル */
[class^=column-table-],
.#{global.$entry-text-unit} {
  .acms-table-scrollable,
  .js-table-unit-scroll-hint {
    th,
    td {
      display: table-cell;
      white-space: nowrap;
    }
  }
}

@media screen and (min-width: acms.$breakpoint-md-min) {
  .#{global.$entry-text-unit} th,
  [class^=column-table-] th,
  .#{global.$entry-text-unit} td,
  [class^=column-table-] td {
    display: table-cell;

    @include acms.font-size(global.$entry-font-size-base-wide-screen);
    @include acms.font-size(global.$entry-font-size-base-wide-screen);
  }
}

/*  エントリー内要素
------------------------------ */

/* キャプション */
.#{acms.$entry-class} {
  [class*="column-media"] {
    .caption {
      @include acms.font-size(13);

      line-height: 1.4;
    }
  }
}
