/* ============================================================
   VOLUNTAS — 学校ピッカー（school-picker.js）
   公開サイトの .field input と同じ見た目。styles.css の色変数を使う。
   ============================================================ */
.sp { position: relative; }
.sp [hidden] { display: none !important; }

/* ---- 検索欄 ---- */
.sp-box { position: relative; }
.sp .sp-box input {
  width: 100%; min-height: 52px;
  padding-left: 44px;                      /* 虫めがねアイコンの分 */
  scroll-margin-top: 96px;                 /* スマホで上へスクロールしたとき、固定ヘッダーに隠れない */
}
.sp-ic { position: absolute; left: 15px; top: 50%; width: 19px; height: 19px; margin-top: -9.5px; color: var(--gold); pointer-events: none; transition: color .2s ease; }
.sp-ic svg { width: 100%; height: 100%; display: block; }
.sp-box:focus-within .sp-ic { color: var(--blue-deep); }
.sp .sp-box input::placeholder, .sp .sp-other::placeholder { color: #a99f8a; }
/* 候補を開いている間は、入力欄と候補リストを一体に見せる */
.sp.sp-open .sp-box input { border-color: var(--blue); }

/* 読み込み中：右端に小さなくるくる */
.sp.sp-loading .sp-box::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 16px; height: 16px; margin-top: -8px;
  border: 2px solid var(--gold-line); border-top-color: var(--gold); border-radius: 50%;
  animation: sp-spin .8s linear infinite;
}
@keyframes sp-spin { to { transform: rotate(360deg); } }

/* ---- 候補リスト ---- */
.sp-list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px);
  max-height: 320px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  margin: 0; padding: 6px; list-style: none;
  background: #fff; border: 1.5px solid var(--gold-line); border-radius: var(--r-sm, 16px);
  box-shadow: 0 22px 48px -20px rgba(44,40,32,.32), 0 2px 6px -2px rgba(44,40,32,.08);
  animation: sp-drop .14s ease-out;
}
@keyframes sp-drop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.sp-list li[role=option] {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  min-height: 48px; padding: 9px 12px; border-radius: 11px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sp-list li[role=option]:hover { background: var(--cream, #fdfbf6); }
.sp-list li[aria-selected=true], .sp-list li[aria-selected=true]:hover { background: #f5eedd; box-shadow: inset 3px 0 0 var(--gold); }
.sp-name { font-family: var(--sans); font-weight: 500; font-size: 15.5px; line-height: 1.4; color: var(--ink); }
.sp-name mark { background: none; color: var(--gold-deep); font-weight: 700; text-decoration: underline; text-decoration-color: var(--gold-line); text-decoration-thickness: 3px; text-underline-offset: 3px; }
.sp-meta { font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.sp-list .sp-empty { padding: 12px 12px 10px; font-size: 13.5px; line-height: 1.7; color: var(--muted); }
/* 末尾の「リストにない」 */
.sp-list li.sp-other-opt {
  flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px;
  margin-top: 4px; position: relative;
  font-family: var(--sans); font-weight: 700; font-size: 14px; color: var(--gold-deep);
}
.sp-list li.sp-other-opt::before { content: ""; position: absolute; left: 10px; right: 10px; top: -3px; border-top: 1px dashed var(--gold-line); }
.sp-list li.sp-other-opt:first-child { margin-top: 0; }
.sp-list li.sp-other-opt:first-child::before, .sp-list .sp-empty + li.sp-other-opt::before { display: none; }
.sp-other-opt svg { width: 18px; height: 18px; flex: none; }

/* 「所属なし」ボタン（検索中だけ表示） */
.sp .sp-none {
  margin-top: 8px; padding: 6px 12px; border: 1px dashed var(--gold-line); border-radius: 999px;
  background: none; font: inherit; font-size: 13px; font-weight: 700; color: var(--gold-deep); cursor: pointer;
}
.sp .sp-none:hover, .sp .sp-none:focus-visible { background: rgba(180, 145, 87, .08); }
.sp .sp-none[hidden] { display: none; }

/* ---- 選択済み ---- */
.sp-chosen {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 8px 8px 14px;
  background: var(--gold-soft, #f6efe1); border: 1.5px solid var(--gold); border-radius: var(--r-sm, 16px);
}
.sp-check { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: #fff; display: grid; place-items: center; }
.sp-check svg { width: 15px; height: 15px; }
.sp-cname { flex: 1; min-width: 0; display: grid; gap: 1px; }
.sp-cname b { font-family: var(--sans); font-weight: 700; font-size: 16px; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere; }
.sp-cname small { font-size: 12.5px; color: var(--gold-deep); }
.sp.sp-pop .sp-check { animation: sp-pop .32s cubic-bezier(.3,1.6,.5,1); }
@keyframes sp-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.sp-change, .sp-back {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 16px;
  font-family: var(--sans); font-weight: 700; font-size: 14px; color: var(--gold-deep);
  background: #fff; border: none; border-radius: var(--r-pill, 999px); cursor: pointer;
  box-shadow: inset 0 0 0 1.5px var(--gold-line);
  transition: box-shadow .2s ease, color .2s ease;
}
.sp-change:hover, .sp-back:hover { box-shadow: inset 0 0 0 1.5px var(--gold); color: var(--ink); }
.sp-change:focus-visible, .sp-back:focus-visible { outline: 3px solid var(--blue-deep); outline-offset: 2px; }
.sp-back svg { width: 15px; height: 15px; }

/* ---- 自由入力（リストにない） ---- */
.sp-otherbox { display: flex; gap: 10px; align-items: stretch; }
.sp-otherbox .sp-other { flex: 1; min-width: 0; }
.sp-otherbox .sp-back { background: var(--cream, #fdfbf6); }
@media (max-width: 480px) {
  .sp-otherbox { flex-direction: column; }
  .sp-otherbox .sp-back { align-self: flex-start; }
}

/* ---- 補足・エラー ---- */
.sp-hint { font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.sp.sp-failed .sp-hint { color: #8a5a12; }
.sp-err { margin: 0; font-family: var(--sans); font-weight: 700; font-size: 13px; color: #b3261e; }
.sp-err:empty { display: none; }
.sp.sp-invalid .sp-box input, .sp.sp-invalid .sp-other { border-color: #e08a83; }
.sp.sp-invalid .sp-box input:focus, .sp.sp-invalid .sp-other:focus { box-shadow: 0 0 0 4px #fdecec; }
.sp-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .sp-list, .sp.sp-pop .sp-check { animation: none; }
  .sp.sp-loading .sp-box::after { animation-duration: 2.4s; }
}
