/*
 * Index (anchor link) - standalone version.
 *
 * Ported from the Drupal theme (nx_olivero: anchorLink.pcss.css).
 * Works together with anchor-link.js.
 *
 * Breakpoint: SP = max-width 767px / PC = min-width 768px.
 * Icons are loaded relative to this file (img/).
 */

/* ------------------------------------------------------------------
 * Variables (override them on :root or .anchorLink if needed)
 * ------------------------------------------------------------------ */
.anchorLink {
  --anchor-link-font-bold: tazuganegothicstdn-bold, "游ゴシック Medium", "Yu Gothic Medium", "游ゴシック体", yugothic, "游ゴシック", "Yu Gothic", "メイリオ", "Meiryo", "ヒラギノ角ゴ Pro", "Hiragino Kaku Gothic Pro", sans-serif;
  --anchor-link-hover-color: #1a005d;
  --anchor-link-border-color: #e0e0e0;
  /* Gap below the header when stuck. */
  --anchor-link-gap: 1rem;
}

/* ------------------------------------------------------------------
 * Local reset (the Drupal theme has a global "* { margin: 0; ... }")
 * ------------------------------------------------------------------ */
.anchorLink,
.anchorLink *,
.anchorLink *::before,
.anchorLink *::after {
  box-sizing: border-box;
}

.anchorLink,
.anchorLinkHead,
.anchorLinkBody,
.anchorLinkList,
.anchorLinkItem {
  margin: 0;
  padding: 0;
}

.anchorLinkList {
  list-style: none;
}

.anchorLinkLink {
  color: inherit;
}

/* ------------------------------------------------------------------
 * Base
 * ------------------------------------------------------------------ */
html:has(.anchorLinkLink) {
  scroll-behavior: smooth;
}

.anchorLink {
  position: sticky;
  z-index: 10;
  top: calc(var(--anchor-link-offset, 0px) + var(--anchor-link-gap));
  padding: 1rem;
  border-radius: 1rem;
  background: #fff;
}

/* Marks the bar's original position (anchor-link.js watches it). */
.anchorLinkSentinel {
  height: 0;
}

.anchorLink.is-stuck {
  width: 100%;
  margin: auto;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.1);
}
.is-stuckMain {
  overflow-x: initial;
}

/* Offset jump targets so the sticky bar doesn't cover them. */
:target {
  scroll-margin-top: var(--anchor-link-scroll-offset, 0);
}

.anchorLinkHead {
  font-family: var(--anchor-link-font-bold);
  font-weight: 700;
}

/* Accordion toggle (SP only, disabled on PC). */
.anchorLinkToggle {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
  color: inherit;
  border: 0;
  background: none;
  font: inherit;
  appearance: none;
}

.anchorLinkToggle:disabled {
  cursor: auto;
}

.anchorLinkLink {
  position: relative;
  transition:
    color 0.3s ease,
    text-decoration 0.3s ease;
  text-decoration: none !important;
  text-decoration-color: transparent;
}

.anchorLinkLink::after {
  display: inline-block;
  width: 24px;
  height: 24px;
  margin-left: 8px;
  content: "";
  transition: background 0.3s ease;
  vertical-align: middle;
  background: url(/assets/img/ico_arrow_circle_down.svg) 50% 50% / 100% 100% no-repeat;
}

/* ------------------------------------------------------------------
 * PC
 * ------------------------------------------------------------------ */
@media print, screen and (min-width: 768px) {
  .anchorLink {
    display: flex;
    padding: min(29px, 2.01389vw);
    border-radius: min(24px, 1.66667vw);
    gap: min(48px, 3.33333vw);
  }

  .anchorLinkHead {
    flex: 0 0 auto;
  }

  .anchorLinkBody {
    flex: 1 1 auto;
  }

  .anchorLinkList {
    display: flex;
    flex-wrap: wrap;
    gap: min(24px, 1.66667vw);
  }
}

/* ------------------------------------------------------------------
 * SP (accordion)
 * ------------------------------------------------------------------ */
@media screen and (max-width: 767px) {
  .anchorLink {
    --anchor-link-gap: 1.5rem;
  }

  /* On the first item so it's hidden when closed. */
  .anchorLinkItem:first-child {
    margin-top: 8px;
  }

  .anchorLinkToggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }

  .anchorLinkToggle::after {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    content: "";
    background: url(/assets/img/ico_plus.svg) 50% 50% / 100% 100% no-repeat;
  }

  .anchorLink.is-open .anchorLinkToggle::after {
    background-image: url(/assets/img/ico_minus.svg);
  }

  /* Open/close animation. .is-instant skips it on item click. */
  .anchorLink.is-accordion .anchorLinkBody {
    display: grid;
    grid-template-rows: 1fr;
    transition:
      grid-template-rows 0.3s ease,
      visibility 0.3s,
      opacity 0.3s ease;
  }

  .anchorLink.is-accordion .anchorLinkList {
    overflow: hidden;
    min-height: 0;
  }

  .anchorLink.is-accordion:not(.is-open) .anchorLinkBody {
    visibility: hidden;
    grid-template-rows: 0fr;
  }

  .anchorLink.is-instant .anchorLinkBody {
    transition: none;
  }

  /*
   * A stuck bar taller than the viewport can't be scrolled into view, so
   * cap it at the space below its sticky top and scroll the list inside.
   */
  .anchorLink.is-accordion.is-stuck {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - var(--anchor-link-offset, 0px) - var(--anchor-link-gap) * 2);
  }

  .anchorLink.is-accordion.is-stuck .anchorLinkBody {
    min-height: 0;
  }

  /* Pull the scrollbar 10px into the padding so it doesn't touch the arrows. */
  .anchorLink.is-accordion.is-stuck .anchorLinkList {
    overflow-y: auto;
    margin-right: -10px;
    padding-right: 10px;
    overscroll-behavior: contain;
    scrollbar-color: #ccc transparent;
  }

  .anchorLinkItem:not(:last-child) {
    border-bottom: 1px solid var(--anchor-link-border-color);
  }

  .anchorLinkLink {
    display: flex;
    align-items: center;
    padding: 16px 0;
    gap: 16px;
  }

  .anchorLinkItem:last-child .anchorLinkLink {
    padding-bottom: 0;
  }

  .anchorLinkLink::after {
    flex: 0 0 auto;
    margin-left: auto;
  }

  .anchorLink:not(:has(.anchorLinkHead)) .anchorLinkItem:first-child .anchorLinkLink {
    padding-top: 0;
  }
}

/* ------------------------------------------------------------------
 * Hover (mouse only)
 * ------------------------------------------------------------------ */
@media (hover: hover) and (pointer: fine) {
  .anchorLinkLink:hover {
    text-decoration: underline solid !important;
    color: var(--anchor-link-hover-color);
    text-decoration-color: var(--anchor-link-hover-color);
  }

  .anchorLinkLink:hover::after {
    background-image: url(/assets/img/ico_arrow_circle_down_hover.svg);
  }
}

@media (prefers-reduced-motion: reduce) {
  html:has(.anchorLinkLink) {
    scroll-behavior: auto;
  }

  .anchorLink.is-accordion .anchorLinkBody {
    transition: none;
  }
}

*:has(+ div > .anchorLinkSentinel) {
    margin-bottom: 30px;
}
h1:has(+ div > .anchorLinkSentinel) {
    margin-bottom: 0;
}