/* ═══════════════════════════════════════════════════════════════════════
   시험지 조판 단일 소스 — 변호사시험 선택형 (bar-seltaek)

   앱(byunhosa_final_v1.html)과 SEO 문제 페이지(_work/gen_seo_page.py)가
   이 파일 하나를 공유한다. bar-seltaek 조판은 여기서만 정의한다 —
   다른 곳에서 다시 정의하면 두 화면이 어긋난다.

   값의 출처: 2026-07-25 실제 앱 화면(형사 7회 문25) computed style 실측
   (_work/probe_app_desktop.json). 변경 시 _work/paper_parity_diff.py 로
   앱 baseline과 대조해 0 diff 확인 후 커밋.

   앱 인터랙션 상태(선택·오답·놓친 선지)도 여기 포함 — 이 파일이 마지막에
   로드되어 기존 규칙을 덮으므로, 상태 색을 빼면 앱에서 표시가 사라진다.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── 지면 폭·밀도 (선택형 문제가 떠 있을 때만) ───────────────────────── */
#screen-study:has(.bar-seltaek-mode) {
    zoom: .74;                                    /* PC 밀도 보정 */
    --study-paper-width: min(605px, calc(100vw - 52px));
}
@media (min-width: 900px) {
    #screen-study:has(.bar-seltaek-mode) { --study-paper-width: min(1010px, calc(100vw - 72px)); }
}
@media (min-width: 1100px) {
    #screen-study:has(.bar-seltaek-mode) { --study-paper-width: min(1010px, calc(100vw - 100px)); }
}
@media (max-width: 767px) {
    /* 모바일에서 74%로 줄이면 칼럼이 좁아져 줄바꿈이 심해짐 → 원상복구 */
    #screen-study:has(.bar-seltaek-mode) { zoom: 1; --study-paper-width: calc(100vw - 56px); }
}

/* 시험지를 얹는 카드 표면 */
#screen-study:has(.bar-seltaek-mode) .study-question-card {
    box-sizing: border-box !important;
    width: calc(var(--study-paper-width) + 56px) !important;
    max-width: calc(100vw - 20px) !important;
    margin: 14px auto 0 !important;
    padding: 26px 28px !important;
    background: var(--bg) !important;
    border: 1px solid var(--border) !important;
    border-radius: 14px !important;
    box-shadow: 0 6px 22px rgba(15, 23, 42, .06) !important;
    color: var(--text) !important;
    overflow-x: clip;
}
@media (max-width: 767px) {
    #screen-study:has(.bar-seltaek-mode) .study-question-card {
        padding: 20px 16px !important;
        border-radius: 12px !important;
        border-width: .8px !important;
    }
}
@media (max-width: 400px) {
    #screen-study:has(.bar-seltaek-mode) .study-question-card { padding: 18px 12px !important; }
}

/* !important = 이 파일이 앱의 흩어진 !important 규칙(구 22444행대 max-width:100% 등)을
   이기기 위한 것. 단일 소스가 최종 권위라는 뜻이며, 임의로 떼면 조판이 무너진다. */
#screen-study .study-paper-box.bar-seltaek-mode,
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea {
    width: var(--study-paper-width) !important;
    max-width: var(--study-paper-width) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}
#screen-study .study-paper-box.bar-seltaek-mode {
    display: block;
    padding: 0;
    margin: 0 auto;                               /* 발문↔선지 사이 여백 없음 */
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea { margin-top: 0; }

/* ── 앱 밖(랜딩 카드·정적 페이지)에서 같은 조판을 쓰는 스코프 ──────────
   아래 조판 규칙은 전부 `.bar-seltaek-paper` 로도 걸린다. 마크업만 앱과
   같게 만들면 —
       .prob-text > .bar-seltaek-qnum + .bar-seltaek-qbody
       .choices   > .choice-row > .choice-num + .choice-txt
   — 폰트·자간·행간·격자는 여기서 온다. 랜딩 <style> 에 값을 다시 적지 않는다.
   글자 크기는 앱과 똑같은 22px 이므로, 좁은 카드에는 zoom 으로만 줄인다
   (앱도 #screen-study 에 zoom:.74 를 건다 — 같은 방식, 다른 배율). */
.bar-seltaek-paper { zoom: var(--bar-seltaek-zoom, .74); }

/* ── 발문 — 돋움 굵은고딕 "문　N." ──────────────────────────────────── */
#screen-study .study-paper-box.bar-seltaek-mode .prob-text,
.bar-seltaek-paper .prob-text {
    width: 100%;
    max-width: none;
    margin: 0;
    /* qnum·qbody 가 자기 폰트를 갖지만, 자간·줄바꿈은 여기서 상속된다 */
    font-family: "Noto Serif CJK KR", "Noto Serif KR", "Batang", serif;
    font-size: 23px;
    font-weight: 700;
    line-height: 1.8;
    letter-spacing: 0;
    word-break: keep-all;
    overflow-wrap: anywhere;
}
@media (min-width: 900px) {
    /* 발문 자간은 여기서 상속된 px 값 (18px × -.015em = -0.27px) */
    #screen-study .study-paper-box.bar-seltaek-mode .prob-text,
    .bar-seltaek-paper .prob-text {
        font-size: 18px;
        line-height: 1.62;
        letter-spacing: -.015em;
    }
}
#screen-study .study-paper-box.bar-seltaek-mode .prob-text .bar-seltaek-qnum,
#screen-study .study-paper-box.bar-seltaek-mode .prob-text .bar-seltaek-qbody,
.bar-seltaek-paper .prob-text .bar-seltaek-qnum,
.bar-seltaek-paper .prob-text .bar-seltaek-qbody {
    display: block;
    font-family: "Dotum", "돋움", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.6;
    color: var(--text);
    overflow-wrap: anywhere;
}
#screen-study .study-paper-box.bar-seltaek-mode .prob-text .bar-seltaek-qnum,
.bar-seltaek-paper .prob-text .bar-seltaek-qnum {
    letter-spacing: .05em;
    word-break: keep-all;
}
#screen-study .study-paper-box.bar-seltaek-mode .prob-text .bar-seltaek-qbody,
.bar-seltaek-paper .prob-text .bar-seltaek-qbody {
    padding-left: 1em;                            /* "문　N." 아래 들여쓰기 */
    margin-bottom: 0;
    word-break: break-all;                        /* 실제 시험지 조판 */
}

/* [보기] 박스 */
#screen-study .study-paper-box.bar-seltaek-mode .bar-seltaek-bogi,
.bar-seltaek-paper .bar-seltaek-bogi {
    margin-top: 8px;
    border: 1px solid var(--text);
    padding: 4px 8px;
}
#screen-study .study-paper-box.bar-seltaek-mode .bar-seltaek-bogi-item,
.bar-seltaek-paper .bar-seltaek-bogi-item {
    font-family: var(--exam-serif-font);
    font-size: 22px;
    font-weight: 400;
    line-height: 1.6;
    margin-bottom: 0;
}

/* ── 선지 — 나눔명조 + serif 번호 ──────────────────────────────────── */
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choices,
.bar-seltaek-paper .choices {
    width: 100%;
    max-width: 100%;
    margin: 0 0 24px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    font-size: 16px;                              /* 번호 em 기준 */
}
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-row,
.bar-seltaek-paper .choice-row {
    display: grid;
    grid-template-columns: 1.05em minmax(0, 1fr) !important;
    column-gap: .4em !important;
    align-items: baseline;
    width: 100%;
    padding: 2px 0 !important;
    margin-bottom: 0 !important;
    line-height: 1.6;
    position: relative;
    border-bottom: none !important;
    cursor: pointer;
}
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-num,
.bar-seltaek-paper .choice-num {
    font-family: "Noto Serif CJK KR", "Noto Serif KR", "Batang", serif;
    font-size: 16px;
    font-weight: 700;
    width: 1.45em;
    text-align: left;
    padding: 0;
    line-height: inherit;
    color: var(--text);
    position: relative;
    z-index: 1;
    user-select: none;
    cursor: pointer;
}
@media (min-width: 900px) {
    #screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-num,
    .bar-seltaek-paper .choice-num { font-size: 17px; }
}
@media (max-width: 767px) {
    #screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-num,
    .bar-seltaek-paper .choice-num { width: 26px; }
}
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-txt,
.bar-seltaek-paper .choice-txt {
    min-width: 0;
    font-family: var(--exam-serif-font) !important;
    font-size: 22px !important;
    font-weight: 400 !important;
    line-height: 1.6 !important;
    letter-spacing: -.03em !important;
    color: var(--text);
    text-align: left;
    word-break: normal !important;
    overflow-wrap: anywhere !important;
    line-break: strict;
    text-wrap: pretty;
}
@media (min-width: 900px) {
    #screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-txt,
    .bar-seltaek-paper .choice-txt { letter-spacing: -.024em !important; }
}
@media (max-width: 767px) {
    #screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-txt,
    .bar-seltaek-paper .choice-txt { letter-spacing: -.015em !important; }
}

/* ── 채점·선택 상태 (앱 인터랙션 — 빼면 표시가 사라진다) ─────────────── */
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-row.correct .choice-num,
.bar-seltaek-paper .choice-row.correct .choice-num { color: var(--success); }
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-row.wrong .choice-num,
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-num.wrong-num,
.bar-seltaek-paper .choice-row.wrong .choice-num { color: var(--danger); }
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-num.selected { color: var(--primary); }
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-row.missed .choice-num,
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-row.missed .choice-txt { color: #10b981; font-weight: 700; }
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-num.disabled { cursor: default; pointer-events: none; }
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-num.locked { pointer-events: none; opacity: .72; }
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-num:hover { opacity: .7; }
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-num:focus,
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-num:focus-visible { outline: none; box-shadow: none; }
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-row.keyboard-active { box-shadow: inset 0 0 0 1px rgba(36, 81, 223, .28); }
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-row.keyboard-active .choice-num { color: var(--primary); font-weight: 800; }
#screen-study .study-paper-box.bar-seltaek-mode + #choicesArea .choice-row.keyboard-active .choice-txt { color: var(--primary); font-weight: 700; }

/* ── 해설 본문도 시험지와 같은 22px·행간 1.6 (앱 전용) ───────────────── */
#screen-study .study-paper-box.bar-seltaek-mode ~ #expArea .exp-inner,
#screen-study .study-paper-box.bar-seltaek-mode ~ #expArea .exp-md,
#screen-study .study-paper-box.bar-seltaek-mode ~ #expArea .exp-md .sg-p,
#screen-study .study-paper-box.bar-seltaek-mode ~ #expArea .exp-md .sg-li,
#screen-study .study-paper-box.bar-seltaek-mode ~ #expArea .exp-md .sg-h2,
#screen-study .study-paper-box.bar-seltaek-mode ~ #expArea .exp-md .sg-h3,
#screen-study .study-paper-box.bar-seltaek-mode ~ #expArea .exp-md .sg-h4,
#screen-study .study-paper-box.bar-seltaek-mode ~ #expArea .exp-md .sg-h5 { font-size: 22px; line-height: 1.6; }
/* sgMd 가 항목 사이에 <br> 1개를 넣으므로 margin 은 0 (간격 균일) */
#screen-study .study-paper-box.bar-seltaek-mode ~ #expArea .exp-md .sg-p { margin: 0; }
#screen-study .study-paper-box.bar-seltaek-mode ~ #expArea .exp-toggle span { font-size: 16px; }

/* ── 출처 표기 (앱: 화면 우하단 고정) ───────────────────────────────── */
#screen-study .study-paper-box.bar-seltaek-mode #problemAttribution { position: fixed; bottom: 12px; right: 16px; }
#screen-study .study-paper-box.bar-seltaek-mode #problemAttribution .problem-attribution,
.bar-seltaek-paper .problem-attribution {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
    font-size: 11px;
    color: #94a3b8;
}
