/* 対象フォームを加工するJSと合わせて読み込んでください。 */
.joruri-cascade {
  --joruri-cascade-ready: 1;
  position: relative;
  width: 100%;
  max-width: 400px;
  font: inherit;
}

.joruri-cascade *,
.joruri-cascade__popup,
.joruri-cascade__popup * {
  box-sizing: border-box;
}

/* 閉じている状態は、サイトのフォーム（.surveyForm の select）と同じ見た目にそろえます。 */
.joruri-cascade__trigger {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 15px 60px 15px 15px;
  border: 1px solid #b3b3b3;
  border-radius: 5px;
  background: #fff;
  color: #000;
  font: inherit;
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.6;
  text-align: left;
  white-space: normal;
  cursor: pointer;
}
.joruri-cascade__trigger:focus-visible {
  outline: 3px solid #176bcc;
  outline-offset: 3px;
}
.joruri-cascade__trigger[aria-expanded="true"] {
  border-color: #3572cc;
  background: #e1ebf8;
}
.joruri-cascade__trigger[aria-invalid="true"] { border-color: #b22b35; }
.joruri-cascade__trigger:disabled {
  background: #f0f2f4;
  color: #687583;
  cursor: default;
}
/* 未選択で文字が空でも、1行分の高さを保ちます。 */
.joruri-cascade__value { display: block; min-height: 1.6em; overflow-wrap: anywhere; }
.joruri-cascade__value-parent { display: block; color: #666; font-size: .8em; }
.joruri-cascade__value-child { display: block; }
/* サイトの ic-pulldown.svg と同じ形・色の矢印です。 */
.joruri-cascade__arrow {
  position: absolute;
  top: 50%;
  right: 28px;
  width: 21px;
  height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='21' height='12' viewBox='-0.672 -0.906 21 12'%3E%3Cpolygon fill='%23b3b3b3' points='9.664,10.085 0,1.494 1.328,0 9.664,7.409 18,0 19.328,1.494'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  transform: translateY(-50%);
}
.joruri-cascade__error {
  margin: 8px 0 0;
  color: #a2232f;
  font-size: .875em;
  line-height: 1.5;
}

/* display:noneやdisabledにせず、HTML標準の送信と必須チェックを維持します。 */
.joruri-cascade__native,
.joruri-cascade__sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.joruri-cascade__native { pointer-events: none; }

/* 1段目（学部）はボタンの直下、2段目（学科）はその横に別パネルで表示します。 */
.joruri-cascade__popup {
  position: fixed;
  z-index: 10000;
  margin: 0;
  padding: 0;
  color: #1b2b3c;
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.joruri-cascade__parents,
.joruri-cascade__child-pane {
  border: 1px solid #c3d1df;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgb(20 48 78 / 13%), 0 2px 6px rgb(20 48 78 / 6%);
}
.joruri-cascade__parents {
  min-height: 0;
  margin: 0;
  padding: 4px 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #aebfd0 transparent;
}
.joruri-cascade__parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin: 0;
  padding: 10px 22px 10px 19px;
  cursor: pointer;
}
.joruri-cascade__parent-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: .6em;
  min-width: 0;
}
.joruri-cascade__faculty {
  font-weight: 500;
  overflow-wrap: anywhere;
}
.joruri-cascade__campus {
  color: #61768b;
  font-size: .78em;
}
.joruri-cascade__chevron {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
}
.joruri-cascade__parent:hover { background: #eef4fc; }
.joruri-cascade__parent.has-selection { color: #2363b5; }
.joruri-cascade__parent.has-selection .joruri-cascade__faculty { font-weight: 700; }
.joruri-cascade__parent.is-expanded {
  color: #fff;
  background: #3572cc;
}
.joruri-cascade__parent.is-expanded .joruri-cascade__campus { color: #fff; }

.joruri-cascade__child-pane {
  position: absolute;
  display: flex;
  flex-direction: column;
  width: max-content;
  min-width: 220px;
  overflow: hidden;
}
.joruri-cascade__children {
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 4px 0;
}
.joruri-cascade__child-pane .joruri-cascade__children {
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #aebfd0 transparent;
}
.joruri-cascade__choice {
  position: relative;
  min-height: 46px;
  padding: 11px 44px 11px 20px;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.joruri-cascade__choice:hover { background: #eef4fc; }
.joruri-cascade__choice.is-selected {
  color: #2363b5;
  font-weight: 700;
}
.joruri-cascade__choice.is-selected::after {
  position: absolute;
  top: 50%;
  right: 18px;
  content: '✓';
  transform: translateY(-50%);
}
.joruri-cascade__choice.is-focused {
  color: #fff;
  background: #3572cc;
}

/* キーボード操作中だけ、フォーカス位置を枠線で示します。 */
.joruri-cascade__popup.is-keyboard .joruri-cascade__parent.is-focused {
  outline: 2px solid #1f5fb8;
  outline-offset: -3px;
}
.joruri-cascade__popup.is-keyboard .joruri-cascade__parent.is-expanded.is-focused,
.joruri-cascade__popup.is-keyboard .joruri-cascade__choice.is-focused {
  outline: 2px solid #fff;
  outline-offset: -4px;
}
.joruri-cascade__parent[aria-disabled="true"],
.joruri-cascade__choice[aria-disabled="true"] {
  color: #778899;
  background: #f7f8fa;
  cursor: default;
}

/* 横に並べる余白がない画面では、学部の行の直下に学科を開きます（矢印は閉じて∨・開いて∧）。 */
.joruri-cascade__popup.is-stacked .joruri-cascade__parent {
  transition: background-color .2s ease, color .2s ease;
}
.joruri-cascade__popup.is-stacked .joruri-cascade__chevron {
  transform: translateY(-25%) rotate(135deg);
  transition: transform .26s cubic-bezier(.2, 0, 0, 1);
}
.joruri-cascade__popup.is-stacked .joruri-cascade__parent.is-expanded .joruri-cascade__chevron {
  transform: translateY(25%) rotate(-45deg);
}
/* 学科一覧はJSで高さを変えて開閉するため、はみ出した部分を隠します。 */
.joruri-cascade__popup.is-stacked .joruri-cascade__children {
  overflow: hidden;
  padding: 0;
  border-bottom: 1px solid #dbe5ef;
  background: #f4f8fd;
}
.joruri-cascade__popup.is-stacked .joruri-cascade__choice { padding-left: 34px; }
.joruri-cascade__popup.is-stacked .joruri-cascade__choice:hover { background: #e6effa; }
.joruri-cascade__popup.is-stacked .joruri-cascade__choice.is-focused { background: #3572cc; }

.joruri-cascade [hidden],
.joruri-cascade__popup[hidden],
.joruri-cascade__popup [hidden] { display: none !important; }

/* サイトのフォームと同じく、768px以下では矢印を小さくして右に寄せます。 */
@media (max-width: 768px) {
  .joruri-cascade__trigger { padding-right: 40px; }
  .joruri-cascade__arrow {
    right: 15px;
    width: 12px;
    height: calc(12px * 12 / 21);
  }
}

@media (max-width: 700px) {
  .joruri-cascade { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .joruri-cascade__popup.is-stacked .joruri-cascade__parent,
  .joruri-cascade__popup.is-stacked .joruri-cascade__chevron { transition: none; }
}

@media (forced-colors: active) {
  .joruri-cascade__trigger,
  .joruri-cascade__parents,
  .joruri-cascade__child-pane { border: 1px solid ButtonText; }
  .joruri-cascade__parent.is-expanded,
  .joruri-cascade__choice.is-focused {
    forced-color-adjust: none;
    color: HighlightText;
    background: Highlight;
  }
  .joruri-cascade__parent.is-expanded .joruri-cascade__campus { color: HighlightText; }
}
