/* 마법 도감 (/spells, templates/spells/list.html · js/spells.js). 시안: docs/spell-sian 시안 H
   왼쪽 = 오락실 주문 창(LIST) 또는 계보도(TREE), 오른쪽 = 시전 장면 TV(브라운관 효과는 여기만) + 설명. 직업 색은 데이터에서 --c 로 */
.sp { padding-bottom: var(--sp-16); }

/* 고르기 줄: 플레이어 · 직업 · 보기 */
.sp-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-4); padding: var(--sp-3); margin: var(--sp-6) 0 var(--sp-4); background: var(--surface-solid); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.sp-group { display: flex; gap: 6px; flex-wrap: wrap; }
.sp-views { margin-left: auto; }
.sp-btn { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 40px; padding: 4px 14px; font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-xl); letter-spacing: var(--ls-arcade-wide); color: var(--text-sub); background: var(--surface); border: 2px solid var(--line-strong); border-radius: var(--radius-sm); cursor: pointer; }
.sp-btn img { width: 26px; height: 26px; border-radius: 4px; }
.sp-btn:hover { color: var(--text-strong); }
.sp-btn[aria-pressed="true"], .sp-btn[aria-selected="true"] { color: var(--bg); background: var(--hud-yellow); border-color: var(--hud-yellow); }
.sp-views .sp-btn[aria-pressed="true"] { background: var(--hud-cyan); border-color: var(--hud-cyan); }

.sp-main { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
/* 왼쪽 목록은 화면을 따라옴. 화면보다 길면 목록 안에서 스크롤 */
.sp-left { position: sticky; top: calc(var(--header-h) + var(--sp-4)); max-height: calc(100vh - var(--header-h) - var(--sp-8)); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: var(--sp-3); background: var(--panel-deep); border: 1px solid var(--line); border-radius: var(--radius-lg); }

/* LIST: 고른 직업의 주문 창 (스크롤 없이 다 펼침) */
.sp-sep { margin: var(--sp-3) 6px 4px; font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-md); letter-spacing: var(--ls-caps); color: var(--sep-ink); border-bottom: 1px dashed var(--line); }
.sp-sep:first-child { margin-top: 2px; }
.sp-li { display: grid; grid-template-columns: 12px 48px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px var(--sp-2); text-align: left; color: var(--text); background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer; }
.sp-li .arrow { display: grid; place-items: center; color: transparent; }
.sp-li img { width: 48px; height: 24px; image-rendering: pixelated; box-shadow: 0 0 0 1px var(--art-bg-deep); }
.sp-li .nm { min-width: 0; }
.sp-li b { display: block; font-size: var(--fs-md); font-weight: var(--fw-bold); line-height: var(--lh-snug); color: var(--text-strong); }
.sp-li small { display: block; font-size: var(--fs-2xs); color: var(--muted); }
.sp-li .ab { min-width: 40px; padding: 2px 6px; font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-md); letter-spacing: 0.06em; text-align: center; color: var(--hud-cyan); background: rgba(var(--hud-cyan-rgb), .08); border: 1px solid rgba(var(--hud-cyan-rgb), .25); border-radius: 4px; }
.sp-only { margin-left: 4px; padding: 0 5px; font-size: var(--fs-micro); font-weight: var(--fw-bold); color: var(--bg); background: var(--hud-yellow); border-radius: 999px; vertical-align: 2px; }
.sp-li:hover { background: var(--surface); }
.sp-li.off { opacity: .35; }
.sp-li.on { background: rgba(var(--hud-yellow-rgb), .1); box-shadow: inset 3px 0 0 var(--hud-yellow); }
.sp-li.on .arrow { color: var(--hud-yellow); animation: sp-blink .8s steps(2) infinite; }
.sp-li.on b { color: var(--hud-yellow); }

/* TREE: 세 직업 × 레벨 I~IX, 같은 스크롤은 점선 사슬 */
.sp-tree { display: grid; grid-template-columns: 40px minmax(0, 1fr); padding: var(--sp-2); }
.sp-th { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: var(--sp-2); padding: 6px 0 var(--sp-3); font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-xl); letter-spacing: var(--ls-arcade-wide); color: var(--muted); border-bottom: 1px solid var(--line); }
.sp-th { color: var(--hud-yellow); }
.sp-th img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.sp-tl { display: flex; align-items: center; justify-content: center; min-height: 72px; font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-2xl); color: var(--hud-cyan); border-bottom: 1px solid var(--line); }
.sp-tl.empty { min-height: 34px; font-size: var(--fs-lg); color: var(--gem-line); }
.sp-tc { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 72px; padding: var(--sp-2) 4px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
.sp-tc.empty { min-height: 34px; }
.sp-tc::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: rgba(var(--hud-cyan-rgb), .12); }
.sp-chain { position: absolute; left: 22%; right: 22%; top: 38%; height: 2px; background: repeating-linear-gradient(90deg, var(--hud-yellow) 0 5px, transparent 5px 9px); opacity: .8; }
.sp-node { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; color: var(--text-sub); background: none; border: 0; cursor: pointer; }
.sp-gem { display: grid; place-items: center; width: 66px; height: 38px; background: var(--art-bg-deep); border: 2px solid var(--gem-line); clip-path: polygon(10% 0, 90% 0, 100% 50%, 90% 100%, 10% 100%, 0 50%); }
.sp-gem img { width: 52px; height: 26px; image-rendering: pixelated; }
.sp-node > span:last-child { max-width: 72px; font-size: var(--fs-micro); line-height: var(--lh-snug); text-align: center; }
.sp-node em { position: absolute; top: -6px; right: -6px; z-index: 2; padding: 0 5px; font-style: normal; font-size: var(--fs-micro); font-weight: var(--fw-bold); color: var(--bg); background: var(--hud-yellow); border-radius: 999px; }
.sp-node.off { opacity: .25; }
.sp-node:hover .sp-gem { border-color: var(--hud-cyan); }
.sp-node[aria-pressed="true"] .sp-gem { border-color: var(--hud-yellow); background: radial-gradient(circle, rgba(var(--hud-yellow-rgb), .25), var(--art-bg-deep) 70%); }
.sp-node[aria-pressed="true"] > span:last-child { color: var(--hud-yellow); }

/* 오른쪽 무대: TV + 설명 (내려도 따라옴) */
.sp-stage { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
/* TV · 브라운관 · 장면 메뉴(.sp-tv · .sp-crt · .sp-osd)는 직업 공략 마법 탭과 같이 써서 dnd2.css 로 */

.sp-info { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-4); align-items: start; padding: var(--sp-5); background: var(--surface-solid); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.sp-info .big { margin-top: 4px; width: 64px; height: 32px; image-rendering: pixelated; box-shadow: 0 0 0 2px var(--hud-yellow); }
.sp-info h2 { font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-arcade-name); font-weight: var(--fw-bold); line-height: var(--lh-none); letter-spacing: var(--ls-arcade); color: var(--hud-yellow); }
.sp-info h2 span { display: block; margin-top: 2px; font-family: var(--font); font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: 0; color: var(--text-strong); }
.sp-info p { margin-top: var(--sp-2); font-size: var(--fs-base); line-height: var(--lh-loose); color: var(--text); }
.sp-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: var(--sp-2); }
.sp-lv { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 var(--sp-2); font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-md); font-weight: var(--fw-regular); letter-spacing: 0.06em; line-height: 1; color: var(--text-strong); background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.sp-kind { font-size: var(--fs-xs); color: var(--muted); }
.sp-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; font-size: var(--fs-2xs); font-weight: var(--fw-bold); color: var(--text-sub); background: var(--surface-2); border-radius: 999px; }
.sp-tag.only { color: var(--bg); background: var(--hud-yellow); }
.sp-row { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--sp-3); } /* 제목 · 설명과 같은 선에서 시작 */
.sp-req { display: flex; align-items: center; padding: 5px 10px; font-size: var(--fs-xs); color: var(--req-ink); background: var(--req-bg); border-left: 3px solid var(--req-line); border-radius: 2px; }
.sp-stat { min-width: 100px; padding: 6px var(--sp-3); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.sp-stat span { display: block; font-size: var(--fs-2xs); color: var(--muted); }
.sp-stat b { font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: var(--ls-arcade); color: var(--text-strong); }
/* 같은 스크롤을 함께 쓰는 주문 (수치 상자 옆, 같은 모양에 글씨만 보통 글꼴) */
.sp-share { padding: 6px var(--sp-3); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.sp-share span { display: block; font-size: var(--fs-2xs); color: var(--muted); }
.sp-share b { display: block; margin-top: 2px; font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--text-strong); }

/* 아래: 레벨별 수치 표 · 알아둘 것 */
/* DETAIL → LEVEL TABLE: 오른쪽 칸(.sp-stage) 안 TV · 설명 아래에 한 줄로 쌓음 */
.sp-more { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
.sp-mnav { display: none; }
.sp-sheet-top, .sp-dim { display: none; } /* 폰 · 태블릿 아래 창의 손잡이 · 닫기 · 어둡게 (넓은 화면엔 없음) */
/* 자세한 설명: 왼쪽 소제목(노란 Bebas + 한글) | 오른쪽 문단 · 원문 그림. 소제목끼리는 가는 선으로 나눔 */
.sp-sec { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.sp-sec:first-of-type { padding-top: var(--sp-1); border-top: 0; }
.sp-sec h4 { font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-xl); font-weight: var(--fw-regular); line-height: var(--lh-tight); letter-spacing: 0.06em; color: var(--hud-yellow); }
.sp-sec h4 small { display: block; margin-top: 2px; font-family: var(--font); font-size: var(--fs-xs); letter-spacing: 0; color: var(--muted); }
.sp-sec__body { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.sp-sec__body p { font-size: var(--fs-md); line-height: var(--lh-loose); color: var(--text); }
/* 원문 그림: 배경을 지운 가장자리가 거칠어서 칸 위에 올림. 바탕 = 누끼 그림 칸 (dnd2.css .art-cut, 빛은 마법 하늘색) · 판 높이를 정해 크기를 맞춤 (그림은 판 안에 비율 그대로) */
.sp-fig img { display: block; box-sizing: border-box; width: 100%; max-width: 480px; height: 220px; padding: var(--sp-2); object-fit: contain; image-rendering: pixelated;
  --art-glow-c: var(--hud-cyan); border: 1px solid var(--art-line); border-radius: var(--radius-sm); }
.sp-figs--row .sp-fig img { max-width: none; height: 170px; }
.sp-fig figcaption { font-size: var(--fs-xs); line-height: var(--lh-base); color: var(--muted); }
.sp-fig figcaption b { margin-right: 6px; font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-md); font-weight: var(--fw-regular); color: var(--hud-cyan); }
.sp-tbl { display: flex; flex-direction: column; gap: var(--sp-2); max-width: 100%; overflow-x: auto; }
.sp-tbl .sp-table { min-width: max-content; }
.sp-more .card { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-5); }
.sp-more h3 { font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: 0.06em; color: var(--text-strong); }
.sp-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.sp-table th, .sp-table td { padding: 6px 10px; text-align: center; border: 1px solid var(--line); }
.sp-table thead th { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--muted); background: var(--surface); }
.sp-table tbody th { text-align: left; font-weight: var(--fw-semibold); color: var(--text-sub); white-space: nowrap; }
.sp-table td { color: var(--text-strong); font-variant-numeric: tabular-nums; }
.sp-table tbody tr:nth-child(even) { background: var(--surface); }
/* 레벨 구간 표: 머리 = 하늘색 Bebas, 수치 = Bebas, 가장 높은 레벨 칸(마지막 열) = 노랑 */
.sp-table--lv thead th:not(:first-child) { font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-md); font-weight: var(--fw-regular); letter-spacing: 0.06em; color: var(--hud-cyan); }
.sp-table--lv td { font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-lg); letter-spacing: 0.04em; }
.sp-table--lv thead th:last-child, .sp-table--lv td:last-child { color: var(--hud-yellow); background: rgba(var(--hud-yellow-rgb), .08); }
/* 행 이름: 일반 = 하늘색 점, 보스 = 빨간 점 */
.sp-table tr.normal th::before, .sp-table tr.boss th::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; vertical-align: 1px; }
.sp-table tr.normal th::before { background: var(--hud-cyan); }
.sp-table tr.boss th { color: var(--req-ink); }
.sp-table tr.boss th::before { background: var(--req-line); }
.sp-no { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: var(--fs-xs); }
.sp-no b { margin-right: 4px; font-weight: var(--fw-bold); color: var(--state-warn); }
.sp-no span { padding: 1px var(--sp-2); color: var(--text-sub); background: var(--surface-2); border-radius: 999px; }
.sp-boss { display: grid; grid-template-columns: auto 1fr; gap: 4px var(--sp-3); font-size: var(--fs-xs); }
.sp-boss dt { font-weight: var(--fw-semibold); color: var(--text-sub); white-space: nowrap; }
.sp-boss dd { line-height: var(--lh-base); color: var(--text); }
/* 팁 (설명 바로 밑): 얇은 줄 아래 노란 TIP 딱지(.sp-lv 와 같은 크기) + 팁 줄은 점선으로 구분 */
.sp-tips { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-3); margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.sp-tips b { display: inline-grid; place-items: center; height: 22px; padding: 0 var(--sp-2); font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-md); font-weight: var(--fw-regular); letter-spacing: 0.08em; line-height: 1; color: var(--bg); background: var(--hud-yellow); border-radius: var(--radius-sm); }
.sp-tips ul { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.sp-tips li { font-size: var(--fs-sm); line-height: var(--lh-loose); color: var(--text); }
.sp-tips li + li { padding-top: 4px; border-top: 1px dashed var(--line); }
.sp-note { font-size: var(--fs-xs); color: var(--muted); }

@media (max-width: 1024px) {
  .sp-main { grid-template-columns: minmax(0, 1fr); } /* minmax: 칸 많은 표가 카드를 넓히지 않고 표 안에서 옆으로 밀리게 */
  /* 폰 · 태블릿: 화면에는 목록만, 주문을 누르면 TV · 설명 · DETAIL · 표가 아래에서 올라오는 창(.sp-stage)에 (spells.js openSheet)
     예전엔 TV → 설명 → 목록 → DETAIL 순서라 목록에서 고르면 위로 올라가 보고, DETAIL 은 다시 맨 아래로 내려가야 했음 */
  .sp-left { position: static; max-height: none; overflow: visible; }
  .sp-stage { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sheet); max-height: calc(100svh - 48px); overflow-y: auto; overscroll-behavior: contain;
    padding: 0 14px 84px; background: var(--bg); border-top: 1px solid var(--line-strong); border-radius: 18px 18px 0 0; box-shadow: 0 -24px 60px rgba(0,0,0,.75);
    transform: translateY(105%); visibility: hidden; transition: transform .28s cubic-bezier(.2,.8,.2,1), visibility 0s .28s; }
  .sp.is-sheet .sp-stage { transform: none; visibility: visible; transition: transform .28s cubic-bezier(.2,.8,.2,1); }
  .sp-sheet-top { position: sticky; top: 0; z-index: 3; display: flex; justify-content: center; align-items: center; height: 40px; margin: 0 -14px; background: var(--bg); }
  .sp-sheet-top::before { content: ""; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); }
  .sp-sheet-x { position: absolute; right: 10px; top: 5px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; color: var(--text-strong); background: var(--surface); border: 1px solid var(--line); border-radius: 50%; cursor: pointer; }
  .sp-dim { display: block; position: fixed; inset: 0; z-index: calc(var(--z-sheet) - 1); background: rgba(0,0,0,.55); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sp.is-sheet .sp-dim { opacity: 1; pointer-events: auto; }
  html.sp-lock { overflow: hidden; }
  /* 아래 막대(이전 · 지금 주문 · 다음 · 목록으로): 창이 열렸을 때만, 창 맨 아래에 */
  .sp-mnav { display: none !important; }
  .sp.is-sheet .sp-mnav { display: grid !important; }
  .sp-mnav { position: fixed; left: 12px; right: 12px; z-index: calc(var(--z-sheet) + 1); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px auto; align-items: center; gap: 4px; padding: 4px; background: rgba(var(--bg-rgb), .94); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 14px 30px -12px rgba(0,0,0,.9); backdrop-filter: blur(10px); }
  .sp-mnav button { display: grid; place-items: center; height: 40px; font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--text-strong); background: var(--surface); border: 0; border-radius: 10px; cursor: pointer; }
  .sp-mnav .cur { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; padding: 0 6px; background: none; }
  .sp-mnav .cur b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); color: var(--hud-yellow); }
  .sp-mnav .cur small { font-family: 'Bebas Neue', var(--font-display); font-size: var(--fs-xs); letter-spacing: var(--ls-caps); color: var(--muted); }
  .sp-mnav .list { padding: 0 12px; color: var(--bg); background: var(--hud-yellow); }
  .sp-views { margin-left: 0; }
}
@media (max-width: 480px) {
  /* 폰: 위 줄 [1P 2P] … [LIST TREE], 아래 줄 직업 셋을 같은 폭으로 한 줄에 (예전엔 ELF 가 혼자 둘째 줄로 밀렸음) */
  .sp-bar { display: grid; grid-template-columns: auto auto; justify-content: space-between; gap: var(--sp-3); }
  .sp-bar #spClasses { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-1); }
  #spClasses .sp-btn { justify-content: center; gap: var(--sp-1); min-width: 0; min-height: 44px; padding: 4px; font-size: var(--fs-lg); letter-spacing: var(--ls-arcade); white-space: nowrap; }
  #spClasses .sp-btn img { width: 22px; height: 22px; }
  .sp-group .sp-btn { min-height: 44px; }
  .sp-sec { grid-template-columns: 1fr; gap: var(--sp-2); }
  .sp-figs--row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sp-fig img { height: 180px; } .sp-figs--row .sp-fig img { height: 120px; }
  .sp-info { grid-template-columns: 1fr; }
  .sp-row { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { .sp-crt img, .sp-crt::after, .sp-li.on .arrow, .sp-osd button::before { animation: none; } }
