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

/* ------------------------------
　　カレンダー
------------------------------ */

/* 曜日・日付 テーブル
------------------------------ */
.calendar {
  width: 100%;

  .is-week-0 {
    color: var(--color-text-sunday);
  }

  .is-week-6 {
    color: var(--color-text-saturday);
  }
}

/* 曜日セル */
.calendar-label {
  box-sizing: border-box;
  height: 1.5rem + 0.5rem;
  padding: 0 0 0.5rem;
  font-weight: normal;
  vertical-align: middle;
  color: var(--color-text-2nd);
  text-align: center;

  @include acms.media-breakpoint-up(md) {
    width: 3.5rem;
    padding: 0 0 0.75rem;
  }
}

/* 日付セル */
.calendar-day {
  height: 2.5rem;
  padding: 0;
  vertical-align: middle;
  color: var(--color-text);
  text-align: center;

  a {
    position: relative;
    display: inline-block;
    width: 2rem;
    height: 2rem;
    font-weight: bold;
    line-height: 2rem;
    color: currentcolor;
    text-decoration: none;

    &::after {
      position: absolute;
      top: 50%;
      left: 50%;
      z-index: -1;
      display: block;
      width: 2rem;
      height: 2rem;
      content: "";
      background-color: var(--color-gray10);
      border-radius: var(--border-radius-md);
      transform: translate(-50%, -50%);

      @media (hover: hover) {
        transition: all 0.3s ease;
      }
    }

    &:hover::after {
      width: 2.25rem;
      height: 2.25rem;
      border-radius: var(--border-radius-lg);
    }
  }

  @include acms.media-breakpoint-up(md) {
    width: 3.5rem;
    height: 3.5rem;
    padding: 0;

    /* サイドカラム用 */
    .section-side & {
      width: 2.5rem;
      height: 2.5rem;
    }

    a {
      /* サイドカラム用 */
      .section-side & {
        width: 1.75rem;
        height: 1.75rem;
      }
    }
  }
}

/* 年間カレンダーレイアウト
------------------------------ */
.calendar-group {
  display: grid;
  grid-template-rows: 1fr;
  grid-template-columns: 1fr;
  gap: 2rem;

  @include acms.media-breakpoint-up(md) {
    grid-template-columns: repeat(2, 1fr);
  }

  @include acms.media-breakpoint-up(lg) {
    grid-template-columns: repeat(3, 1fr);
  }
}

.calendar-group-item {
  text-align: center;
}

/* 年間カレンダーの月ヘッダー */
.calendar-header {
  margin: 0 0 0.75rem;
}

.calendar-header-title {
  margin: 0;
  font-size: map.get(global.$font-scales, heading-ss);
  font-weight: bold;
  color: var(--color-text);

  a {
    color: inherit;
    text-decoration: none;

    @media (hover: hover) {
      &:any-link:hover {
        text-decoration: underline dotted 1px;
        text-underline-offset: 3px;
      }
    }
  }
}

/* 年間カレンダーとイベントカレンダーのページネーション
------------------------------ */
.calendar-heading {
  margin-bottom: 2rem;
}

.calendar-footing {
  padding-bottom: 4rem;
  margin-top: 2rem;

  @include acms.media-breakpoint-up(md) {
    padding-bottom: 0;
  }
}

.calendar-pagination {
  position: relative;
  text-align: center;
}

.calendar-pagination-title {
  position: relative;
  z-index: 1;
  display: inline-block;
  margin: 0;
  font-size: map.get(global.$font-scales, heading-m);

  @include acms.media-breakpoint-up(md) {
    font-size: map.get(global.$font-scales, heading-m);
  }
}

.calendar-pagination-return {
  position: relative;
  z-index: 1;
  display: inline-block;
  margin: 0;
  transform: translateY(100%);

  @include acms.media-breakpoint-up(md) {
    transform: translateY(0);
  }
}

.calendar-pagination-group {
  padding: 0;
  margin: 0;
  list-style: none;
}

.calendar-pagination-item-previous,
.calendar-pagination-item-next {
  position: absolute;
  top: 0.5rem;
}

.calendar-pagination-item-previous {
  left: 0;
}

.calendar-pagination-item-next {
  right: 0;
}

.calendar-pagination-link {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  padding-block: 0.5rem;
  line-height: 1;
  text-decoration: none;

  @media (hover: hover) {
    &:any-link:hover {
      .calendar-pagination-link-icon {
        background-color: var(--color-icon-bg-hover);
      }
    }
  }

  @include acms.media-breakpoint-up(sm) {
    gap: 0.5rem;
  }
}

.calendar-pagination-link-text {
  font-size: map.get(global.$font-scales, body-m);
  font-weight: bold;
  line-height: var(--line-height-base);
  color: var(--color-text);
}

.calendar-pagination-link-icon {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: auto;
  aspect-ratio: 1 / 1;
  background-color: var(--color-icon-bg);
  border-radius: 50%;

  svg {
    width: 0.625rem;
    height: 0.625rem;
    color: var(--color-white);
    object-fit: contain;

    path {
      stroke: currentcolor;
    }
  }

  @media (hover: hover) {
    transition: background-color 0.3s ease;
  }
}

/* サイドカラムカレンダー
------------------------------ */

/* サイドカラムのカレンダー月送りボタン */
.calendar-next-prev-button-layout {
  display: flex;
  gap: 1rem;
}

.calendar-next-prev-button {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--color-white);
  background-color: var(--color-icon-bg);
  border-radius: 50%;

  svg {
    width: 0.657rem;
    height: 0.657rem;
    color: inherit;
    object-fit: contain;

    path {
      stroke: currentcolor;
    }
  }

  @media (hover: hover) {
    transition: background-color 0.3s ease;

    &:hover {
      background-color: var(--color-icon-bg-hover);
    }
  }
}

/* サイドカラムの「年間カレンダーで見る」リンク */
.section-side-link {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  justify-content: flex-end;
  padding-block: 0.25rem;
  margin: 0;
  line-height: 1;
  text-decoration: none;

  @media (hover: hover) {
    &:any-link:hover {
      .section-side-link-icon {
        background-color: var(--color-icon-bg-hover);
      }
    }
  }
}

.section-side-link-text {
  font-size: map.get(global.$font-scales, body-s);
  font-weight: bold;
  line-height: var(--line-height-base);
  color: var(--color-text);
}

.section-side-link-icon {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 1rem;
  height: auto;
  aspect-ratio: 1 / 1;
  background-color: var(--color-icon-bg);
  border-radius: 50%;

  svg {
    width: 0.625rem;
    height: 0.625rem;
    color: var(--color-white);
    object-fit: contain;

    path {
      stroke: currentcolor;
    }
  }

  @media (hover: hover) {
    transition: background-color 0.3s ease;
  }
}

/* イベントカレンダー
------------------------------ */
.calendar-event-table {
  --calendar-event-item-cell-spacing-y: 0.5rem;
  --calendar-event-item-link-spacing-y: 0.5rem;
  --calendar-event-item-link-spacing-x: 0.5rem;

  @include acms.media-breakpoint-up(sm) {
    --calendar-event-item-link-spacing-y: 1rem;
    --calendar-event-item-link-spacing-x: 1rem;
  }
}

.calendar-event-table {
  display: table;
  width: 100%;
  margin-bottom: 2rem;
  border-collapse: collapse;
  border-top: var(--border-width-sm) solid var(--color-gray30);

  th {
    padding-block: calc(var(--calendar-event-item-cell-spacing-y) + var(--calendar-event-item-link-spacing-y));
    padding-inline-end: 0.5rem;
    vertical-align: top;
    text-align: right;
    white-space: nowrap;
    border-bottom: var(--border-width-sm) solid var(--color-gray30);

    @include acms.media-breakpoint-up(sm) {
      padding-inline: 1rem;
    }
  }

  td {
    width: 100%;
    padding-block: var(--calendar-event-item-cell-spacing-y);
    vertical-align: top;
    border-bottom: var(--border-width-sm) solid var(--color-gray30);
  }
}

.calendar-event-fore-spacer,
.calendar-event-rear-spacer {
  background-color: var( --color-gray10);
}

.calendar-event-day-layout {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;

  @include acms.media-breakpoint-up(md) {
    gap: 1rem;
  }
}

.calendar-event-day {
  display: block;
  font-size: map.get(global.$font-scales, heading-ss);
  font-weight: bold;
  line-height: var(--line-height-base);
  text-align: right;

  @include acms.media-breakpoint-up(md) {
    font-size: map.get(global.$font-scales, heading-s);
  }
}

.badge-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  font-size: map.get(global.$font-scales, body-m);
  line-height: 1;
  color: var(--color-text-2nd);
  text-align: center;
  background-color: var(--color-gray10);
  border-radius: var(--border-radius-round);

  &.is-week-0 {
    color: var(--color-text-sunday);
  }

  &.is-week-6 {
    color: var(--color-text-saturday);
  }

  @include acms.media-breakpoint-up(md) {
    width: 2rem;
    height: 2rem;
    font-size: map.get(global.$font-scales, body-m);
  }
}

.calendar-event-item-link {
  display: block;
  width: 100%;
  overflow: hidden;
  text-decoration: none;
  border-radius: var( --border-radius-lg);

  @media (hover: hover) {
    transition: background-color 0.3s ease;

    &:any-link:hover {
      background-color: var(--color-hover-bg-2nd);
    }
  }
}

.calendar-event-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem 1rem;
  align-items: flex-start;
  padding-block: var(--calendar-event-item-link-spacing-y);
  padding-inline: var(--calendar-event-item-link-spacing-x);

  @include acms.media-breakpoint-up(md) {
    flex-direction: row;
    justify-content: space-between;
  }
}

.calendar-item-texts-layout {
  display: grid;
  gap: 0.5rem;
}

.calendar-item-labels-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.calendar-item-time {
  margin-block: 0;
  font-size: map.get(global.$font-scales, body-s);
  line-height: var(--line-height-base);
  color: var(--color-text);

  @include acms.media-breakpoint-up(md) {
    font-size: map.get(global.$font-scales, body-m);
  }
}

.calendar-event-item-title {
  margin-block: 0;
  font-size: map.get(global.$font-scales, heading-3s);
  font-weight: bold;
  line-height: var(--line-height-base);
  color: var(--color-text);

  @include acms.media-breakpoint-up(md) {
    font-size: map.get(global.$font-scales, heading-ss);
  }
}

.calendar-event-item-img {
  display: block;
  width: 11.25rem;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--border-radius-lg);

  @include acms.media-breakpoint-up(sm) {
    width: 10rem;
  }
}
