/* ==========================================================
   MediEdu content common style
   - Tiptap editor content
   - Lecture viewer content

medu-content.css
- 본문 p/h/table/img/mark/strong/code/blockquote
- formula-inline-image
- editor-equation-image


<학생이 사용시 css>
medu-content.css
→ 실제 본문 안의 글자, 표, 이미지, 문단 폭


   ========================================================== */
/*
Word (pt)	웹 (px)	웹 (rem, 기본 16px 기준)	비고
9 pt	12 px	0.75 rem	캡션, 각주, 작은 본문
10 pt	13.33 px	0.833 rem	일반 본문 (작은 편)
11 pt	14.67 px	0.917 rem	Word 기본 본문 크기
12 pt	16 px	1 rem	웹 표준 본문 크기
14 pt	18.67 px	1.167 rem	소제목
18 pt	24 px	1.5 rem	대제목

 */
/*
기본 폰트 : 15px
Word 폰트크기 변환
9pt 미만 → 10px
9pt  → 12px
10pt → 13px
11pt → 15px
12pt → 16px
13pt → 17px
14pt → 19px
15pt → 20px
16pt → 21px
17pt → 23px
18pt → 24px
18pt 초과 → 26px
 */
:root {
    --medu-content-max-width: 1100px;
    --medu-content-font-size: 15px;
    --medu-content-line-height: 1.65;
    --medu-content-color: #374151;
    /* ── SPEC-177-02: 다크모드 대응용 색 변수 승격 (라이트 값 = 기존 하드코딩 원값) ── */
    --medu-heading-color: #1e293b;      /* h1, h2, th 텍스트 */
    --medu-heading-sub-color: #334155;  /* h3 */
    --medu-em-color: #4f46e5;           /* em 강조 */
    --medu-strike-color: #94a3b8;       /* s 취소선 */
    --medu-code-bg: #f1f5f9;            /* code 배경, th 배경 */
    --medu-code-color: #dc2626;         /* code 글자 */
    --medu-line-color: #e2e8f0;         /* code 보더, blockquote 좌보더 */
    --medu-quote-bg: #f8fafc;           /* blockquote 배경 */
    --medu-quote-color: #64748b;        /* blockquote 글자 */
    --medu-table-bg: #ffffff;           /* table 배경 */
    --medu-table-border: #d1d5db;       /* th/td 보더 */
    --medu-note-title-color: #92400e;   /* p.paste-note-title */
}

/* ── SPEC-177-02: 다크모드 오버라이드 (RES-177-01 전역 토큰 참조) ── */
[data-bs-theme="dark"] {
    --medu-content-color: var(--color-text-primary);
    --medu-heading-color: var(--color-text-primary);
    --medu-heading-sub-color: var(--color-text-secondary);
    --medu-em-color: var(--color-primary-emphasis);
    --medu-strike-color: var(--color-text-muted);
    --medu-code-bg: var(--color-surface-2);
    --medu-code-color: var(--color-danger-emphasis);
    --medu-line-color: var(--color-border);
    --medu-quote-bg: var(--color-surface-2);
    --medu-quote-color: var(--color-text-secondary);
    --medu-table-bg: var(--color-surface);
    --medu-table-border: var(--color-border);
    --medu-note-title-color: var(--color-warning-emphasis);
}

/*
 * 태블릿 가로모드 대응 (아이패드 프로 11/12.9형, 갤럭시 탭 S 시리즈 landscape 기준).
 * 뷰포트가 넓어져도 본문 폭이 1000px 그대로 고정돼 좌우 여백만 커지는 문제 보완.
 */
@media (min-width: 1150px) {
    :root {
        --medu-content-max-width: 1200px;
    }
}

.medu-content {
    font-family: 'Nanum Gothic', 'Noto Sans KR', sans-serif;
    color: var(--medu-content-color);
    font-size: var(--medu-content-font-size);
    line-height: var(--medu-content-line-height);
    word-break: keep-all;
    overflow-wrap: break-word;
}

/*
 * 실제 수강생 화면 / 미리보기 / 에디터 본문 공통 콘텐츠 폭
 */
.lecture-content.medu-content,
.tiptap-editor-content .ProseMirror.medu-content {
    width: 100%;
    max-width: var(--medu-content-max-width);
    margin-left: auto;
    margin-right: auto;
}

/* ── Headings ───────────────────────────────────────────── */

.medu-content h1 {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--medu-heading-color);
    line-height: 1.35;
    margin: 1.2rem 0 0.75rem;
}

.medu-content h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--medu-heading-color);
    line-height: 1.35;
    margin: 1.1rem 0 0.65rem;
}

.medu-content h3 {
    font-size: 1.12rem;
    font-weight: 600;
    color: var(--medu-heading-sub-color);
    line-height: 1.4;
    margin: 0.9rem 0 0.5rem;
}

/* ── Paragraphs ─────────────────────────────────────────── */

.medu-content p {
    margin: 0 0 0.7rem;
    line-height: var(--medu-content-line-height);
    color: var(--medu-content-color);
    /*
    * 미리보기에서 앞 공백, 연속 공백, 엔터 빈 줄 표현
    */
    white-space: pre-wrap;
    min-height: calc(var(--medu-content-font-size) * var(--medu-content-line-height));
}

.medu-content p:last-child {
    margin-bottom: 0;
}

.medu-content p:empty::before {
    content: "\00a0";
}

.medu-content p:has(br:only-child) {
    min-height: 1.65em;
}

/* Word에서 들어온 기본 문단 */
.medu-content p.MsoNormal,
.medu-content .MsoNormal {
    margin-top: 0 !important;
    margin-bottom: 0.45rem !important;
    line-height: 1.52 !important;
}


/* ── Lists ──────────────────────────────────────────────── */

.medu-content ul,
.medu-content ol {
    padding-left: 1.5rem;
    margin: 0.45rem 0 0.75rem;
}

.medu-content li {
    line-height: 1.55;
    margin-bottom: 0.25rem;
    color: var(--medu-content-color);
}

/* ── Inline formatting ──────────────────────────────────── */

.medu-content strong {
    color: inherit;
    font-weight: 700;
}

.medu-content em {
    color: var(--medu-em-color);
    font-style: italic;
}

.medu-content u {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.medu-content s {
    text-decoration: line-through;
    color: var(--medu-strike-color);
}

.medu-content mark,
.tiptap-editor-content .ProseMirror mark {
    color: inherit !important;
    font-size: inherit !important;
    font-weight: inherit !important;
    font-family: inherit !important;
    line-height: inherit;

    padding: 0 0.12em;
    border-radius: 3px;

    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* [REQ-179] SPEC-179-02 검토 완료 — 배경값 불변 확정. 다크 텍스트색 고정 규칙은 아래 참조 */
.medu-content mark:not([style*="background-color"]),
.tiptap-editor-content .ProseMirror mark:not([style*="background-color"]) {
    background: #fef9c3;
}

/* ── SPEC-179-02: mark(형광펜/메모 하이라이트) 다크모드 텍스트색 고정 ──
   배경색(기본 #fef9c3, 저자 커스텀 인라인색, .memo-highlight의 highlightColor)은 절대 변경하지 않는다.
   다크모드에서 본문 텍스트색이 밝아지며(SPEC-177-02) mark 내부 글자도 color:inherit를 따라 밝아져
   밝은 하이라이트 배경과 겹쳐 안 보이게 되는 회귀(대비 1.07:1)만, 라이트와 동일한 고정 진한
   텍스트색(#1A2332 = --color-text-primary 라이트 리터럴, 대비 10.8~14.7:1)으로 방지한다.
   <mark class="memo-highlight">도 #lectureContentBody(.medu-content) 하위 mark이므로 이 규칙 하나로 함께 처리. */
[data-bs-theme="dark"] .medu-content mark,
[data-bs-theme="dark"] .tiptap-editor-content .ProseMirror mark {
    color: #1A2332 !important;
}

.medu-content code {
    background: var(--medu-code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.88em;
    color: var(--medu-code-color);
    border: 1px solid var(--medu-line-color);
}

/* ── Blockquote ─────────────────────────────────────────── */

.medu-content blockquote {
    border-left: 4px solid var(--medu-line-color);
    padding: 0.8rem 1.1rem;
    background: var(--medu-quote-bg);
    border-radius: 0 8px 8px 0;
    margin: 1rem 0;
    color: var(--medu-quote-color);
    font-style: italic;
}

/* ── Tables ─────────────────────────────────────────────── */

.medu-content table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    margin: 1rem 0 1.2rem;
    font-size: inherit;
    line-height: inherit;
    background: var(--medu-table-bg);
}

/*
 * 열이 많은 표가 본문 폭을 넘을 때를 대비
 */
.medu-content table {
    overflow-x: auto;
}

/* 강의 본문(수강생 강의화면)의 표 상단 여백만 5px로 축소 (SPEC-185-01).
   #studentPreviewInjectedBody(admin-lecture-contents.html/admin-lecture-content-form.html의
   "수강생 화면 미리보기")도 같은 본문 컨테이너 역할이라 실제 화면과 동일하게 5px로 맞춘다(추가요청 2026-08-17). */
#lectureContentBody table,
#lectureContentBodyEn table,
#studentPreviewInjectedBody table {
    margin-top: 5px;
}

.medu-content th,
.medu-content td {
    border: 1px solid var(--medu-table-border);
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
    font-size: inherit;
    line-height: var(--medu-content-line-height);
    color: var(--medu-content-color);
    box-sizing: border-box;

    /*
     * 긴 영어/의학용어가 표 폭을 깨지 않도록 처리
     */
    word-break: keep-all;
    overflow-wrap: anywhere;
}

.medu-content th {
    background: var(--medu-code-bg);
    font-weight: 700;
    color: var(--medu-heading-color);
}

.medu-content td p,
.medu-content th p {
    margin: 0 0 0.25rem;
    font-size: inherit;
    line-height: inherit;
    white-space: pre-wrap;
    min-height: calc(var(--medu-content-font-size) * var(--medu-content-line-height));
}

.medu-content td p:last-child,
.medu-content th p:last-child {
    margin-bottom: 0;
}

/* Word 표 */
.medu-content table.MsoTableGrid {
    border-collapse: collapse;
    box-shadow: none;
}

/* Word span 글자 크기 보정 */
/*
 * Word에서 붙여넣은 작은 pt 글자 보정
 * 9pt/10pt/11pt는 강의 본문 기준에서는 너무 작으므로 기본 본문 크기로 보정한다.
 */
/*
 pt -> px 전환방식으로 제거
.medu-content span[style*="font-size:9pt"],
.medu-content span[style*="font-size: 9pt"],
.medu-content span[style*="font-size:9.0pt"],
.medu-content span[style*="font-size: 9.0pt"],
.medu-content span[style*="font-size:10pt"],
.medu-content span[style*="font-size: 10pt"],
.medu-content span[style*="font-size:10.0pt"],
.medu-content span[style*="font-size: 10.0pt"],
.medu-content span[style*="font-size:11pt"],
.medu-content span[style*="font-size: 11pt"],
.medu-content span[style*="font-size:11.0pt"],
.medu-content span[style*="font-size: 11.0pt"] {
    font-size: inherit !important;
    line-height: inherit !important;
}
*/

/* ── ul ─────────────────────────────────────────────── */
.medu-content ul.paste-bullet-list {
    list-style-type: disc;
    margin: 0.45rem 0 0.75rem;
    padding-left: 1.4rem;
}

.medu-content ul.paste-bullet-list > li {
    line-height: 1.55;
    margin-bottom: 0.35rem;
}

.medu-content ul.paste-dash-list {
    list-style-type: none;
    margin: 0.3rem 0 0.55rem;
    padding-left: 1.4rem;
}

.medu-content ul.paste-dash-list > li {
    position: relative;
    line-height: 1.5;
    margin-bottom: 0.25rem;
}

.medu-content ul.paste-dash-list > li::before {
    content: "-";
    position: absolute;
    left: -1rem;
}

.medu-content ul.paste-arrow-list {
    list-style-type: none;
    margin: 0.3rem 0 0.55rem;
    padding-left: 1.4rem;
}

.medu-content ul.paste-arrow-list > li {
    position: relative;
    line-height: 1.5;
    margin-bottom: 0.25rem;
}

.medu-content ul.paste-arrow-list > li::before {
    content: "→";
    position: absolute;
    left: -1.15rem;
}

.medu-content ul.paste-arrow-list.paste-note-dash-list {
    margin-top: 0.25rem;
    margin-bottom: 0.75rem;
    padding-left: 1.4rem;
}


.medu-content ul.paste-sub-list {
    margin-top: 0.35rem;
    margin-bottom: 0.25rem;
}

.medu-content p.paste-note-title {
    margin: 0.8rem 0 0.35rem;
    font-weight: 600;
    color: var(--medu-note-title-color);
    line-height: 1.55;
}

.medu-content ul.paste-note-dash-list {
    margin-top: 0.25rem;
    margin-bottom: 0.75rem;
    padding-left: 1.4rem;
}

/* ── Images ─────────────────────────────────────────────── */

.medu-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.medu-content > img,
.medu-content p > img:only-child {
    display: block;
    margin: 1rem auto;
    border-radius: 10px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
}

.medu-content table img {
    display: inline-block;
    margin: 0.15rem auto;
    border-radius: 4px;
    box-shadow: none;
}

.medu-content img.editor-image {
    cursor: zoom-in;
}

/* REQ-176: .medu-align-scope = 시험문항 등 타이포그래피 규칙 없이 이미지 정렬만 스코프하는 전용 클래스 */
.medu-content img.editor-image[data-align="center"]:not(.editor-equation-image),
.lecture-content img.editor-image[data-align="center"]:not(.editor-equation-image),
.tiptap-editor-content img.editor-image[data-align="center"]:not(.editor-equation-image),
.medu-align-scope img.editor-image[data-align="center"]:not(.editor-equation-image) {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.medu-content img.editor-image[data-align="left"]:not(.editor-equation-image),
.lecture-content img.editor-image[data-align="left"]:not(.editor-equation-image),
.tiptap-editor-content img.editor-image[data-align="left"]:not(.editor-equation-image),
.medu-align-scope img.editor-image[data-align="left"]:not(.editor-equation-image) {
    display: block;
    margin-left: 0;
    margin-right: auto;
}

.medu-content img.editor-image[data-align="right"]:not(.editor-equation-image),
.lecture-content img.editor-image[data-align="right"]:not(.editor-equation-image),
.tiptap-editor-content img.editor-image[data-align="right"]:not(.editor-equation-image),
.medu-align-scope img.editor-image[data-align="right"]:not(.editor-equation-image) {
    display: block;
    margin-left: auto;
    margin-right: 0;
}

/* ── Mobile ─────────────────────────────────────────────── */

@media (max-width: 860px) {
    :root {
        --medu-content-font-size: 15px;
        --medu-content-line-height: 1.6;
    }

    .medu-content table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: normal;
    }

    .medu-content th,
    .medu-content td {
        min-width: 120px;
        padding: 6px 8px;
    }
}

@media (max-width: 600px) {
    :root {
        --medu-content-font-size: 14px;
        --medu-content-line-height: 1.6;
    }
}


/*
@media (max-width: 768px) {
    .medu-content {
        font-size: 0.93rem;
        line-height: 1.55;
    }

    .medu-content table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: normal;
    }

    .medu-content th,
    .medu-content td {
        min-width: 120px;
        padding: 5px 8px;
    }
}
*/

.medu-content img.formula-inline-image,
.tiptap-editor-content img.formula-inline-image {
    display: inline-block;
    vertical-align: middle;
    margin: 0 0.15em;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
}

.editor-equation-image {
    display: inline-block;
    vertical-align: middle;
    max-width: none;
}

.ProseMirror img.editor-equation-image,
.medu-content img.editor-equation-image {
    display: inline-block;
    vertical-align: middle;
}

.medu-content img.editor-equation-image,
.lecture-content img.editor-equation-image,
.tiptap-editor-content img.editor-equation-image,
.ProseMirror img.editor-equation-image {
    display: inline-block !important;
    vertical-align: middle !important;
    max-width: none !important;
    height: auto;
    margin: 0 0.12em;
    border-radius: 0 !important;
    box-shadow: none !important;
}