/* ─── TipTap 콘텐츠 표시 공용 스타일 ─────────────────────────────────────────
 * admin 에디터(.tiptap-editor .ProseMirror), 미리보기(.tiptap-preview-body),
 * client 뷰(.tiptap-content) 에서 공통 적용
 *
 * 사용법: 콘텐츠 출력 영역에 class="tiptap-content" 추가
 * ──────────────────────────────────────────────────────────────────────────── */

/*
 * 일반 콘텐츠 스타일은 퍼블리싱 CSS보다 낮은 우선순위로 적용한다.
 * 레이어에 포함되지 않은 퍼블리싱 CSS가 같은 속성을 선언하면 퍼블리싱 CSS가 우선한다.
 */
@layer tiptap-base {

    .tiptap-content {
        font-size: 14px;
        line-height: 1.7;
        color: #1d2939;
    }

    .tiptap-content > * + * {
        margin-top: 0.6em;
    }

    .tiptap-content p {
        min-height: 1em;
    }

    .tiptap-content p:empty::after,
    .tiptap-content p > br:only-child {
        content: '\00a0';
    }

    /* 제목 */
    .tiptap-content h1 { font-size: 1.75em; font-weight: 700; }
    .tiptap-content h2 { font-size: 1.4em;  font-weight: 700; }
    .tiptap-content h3 { font-size: 1.15em; font-weight: 700; }

    /* 리스트 — client 전역 리셋(list-style: none) 복구 */
    .tiptap-content ul {
        list-style-type: disc;
        padding-left: 1.4em;
    }

    .tiptap-content ol {
        list-style-type: decimal;
        padding-left: 1.4em;
    }

    .tiptap-content ul ul { list-style-type: circle; }
    .tiptap-content ul ul ul { list-style-type: square; }

    .tiptap-content li {
        list-style: inherit;
    }

    /* 기울임꼴 */
    .tiptap-content em { font-style: italic; }

    /* 하이퍼링크 */
    .tiptap-content a { color: #206bc4; text-decoration: underline; }
    .tiptap-content a:hover { opacity: 0.8; }

    /* 인용구 */
    .tiptap-content blockquote {
        border-left: 4px solid #dee2e6;
        padding-left: 1em;
        color: #6c757d;
        margin: 0.8em 0;
    }

    /* 코드 블록 */
    .tiptap-content pre {
        background: #1e1e1e;
        color: #d4d4d4;
        border-radius: 4px;
        padding: 12px 16px;
        font-family: 'Courier New', monospace;
        font-size: 13px;
        overflow-x: auto;
    }

    /* 인라인 코드 */
    .tiptap-content code {
        background: #f3f4f6;
        border-radius: 3px;
        padding: 2px 5px;
        font-family: 'Courier New', monospace;
        font-size: 0.9em;
    }

    /* 이미지 */
    .tiptap-content img {
        height: auto;
        border-radius: 4px;
        display: block;
    }

    /* 표 */
    .tiptap-content table {
        border-collapse: collapse;
        width: 100%;
        margin: 0.8em 0;
        font-size: 14px;
    }

    .tiptap-content table td,
    .tiptap-content table th {
        border: 1px solid #dee2e6;
        padding: 6px 10px;
        min-width: 60px;
        vertical-align: top;
    }

    .tiptap-content table th {
        background: #f8f9fa;
        font-weight: 600;
        text-align: left;
    }

}

/* ─── TipTap 기능 스타일 — 퍼블리싱 CSS보다 우선 적용 ─── */

/* 태스크 리스트 */
.tiptap-content ul[data-type="taskList"] {
    list-style: none;
    padding-left: 0.4em;
}

.tiptap-content ul[data-type="taskList"] li {
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin: 0.3em 0;
}

.tiptap-content ul[data-type="taskList"] li > label {
    flex-shrink: 0;
}

.tiptap-content ul[data-type="taskList"] li > div {
    flex: 1;
}

.tiptap-content ul[data-type="taskList"] li > label input[type="checkbox"] {
    -webkit-appearance: checkbox;
    appearance: auto;
    width: 15px;
    height: 15px;
    accent-color: #206bc4;
    pointer-events: none;
}

.tiptap-content ul[data-type="taskList"] li > div > p {
    margin: 0;
}

.tiptap-content ul[data-type="taskList"] li[data-checked="true"] > div {
    text-decoration: line-through;
    color: #9ca3af;
}

/* 이미지 정렬 */
.tiptap-content img.align-left,
.tiptap-content img.align-center,
.tiptap-content img.align-right  { display: block; }
.tiptap-content img.align-center { margin: 0 auto; }
.tiptap-content img.align-right  { margin-left: auto; }

/* 게시판형 상세는 퍼블리싱 구조상 tiptap-content 클래스가 없으므로
 * TipTap이 저장한 이미지 정렬 클래스만 별도로 적용한다. */
.post__body img.align-left,
.post__body img.align-center,
.post__body img.align-right  { display: block; }
.post__body img.align-left   { margin-left: 0;    margin-right: auto; }
.post__body img.align-center { margin-left: auto; margin-right: auto; }
.post__body img.align-right  { margin-left: auto; margin-right: 0; }

/* 표 정렬 */
.tiptap-content table[data-align="center"] { margin-left: auto; margin-right: auto; }
.tiptap-content table[data-align="right"]  { margin-left: auto; margin-right: 0; }
.tiptap-content table[data-align="left"]   { margin-left: 0;    margin-right: auto; }

/* 유튜브 */
.tiptap-content div[data-youtube-video] {
    margin: 0.8em 0;
    line-height: 0;
}

.tiptap-content div[data-youtube-video] iframe {
    max-width: 100%;
    border: none;
    border-radius: 4px;
}

/* 유튜브 정렬 */
.tiptap-content div[data-youtube-video].align-left,
.tiptap-content div[data-youtube-video].align-center,
.tiptap-content div[data-youtube-video].align-right  { width: fit-content; }
.tiptap-content div[data-youtube-video].align-left   { margin-right: auto; }
.tiptap-content div[data-youtube-video].align-center { margin-left: auto; margin-right: auto; }
.tiptap-content div[data-youtube-video].align-right  { margin-left: auto; }

/* 에디터 빈 줄 — tiptap-content 클래스가 없는 게시판형 본문(뉴스·인사이트 등 상세, FAQ 답변)도
   에디터처럼 빈 문단(<p></p>)을 한 줄 높이로 보이게 한다 */
.post__body p:empty::after,
.faq-item__a-inner p:empty::after {
    content: '\00a0';
}
