/*****************************************
 * damdanote/detail.css
 *****************************************/

/*-----------------------------------------
 * 섹션
 -----------------------------------------*/
#damdanote-detail-section {
    padding: 40px 0 100px;
}

.note-detail-container {
    width: 100%;
    padding: 0 12px;
    margin: 0;
}

/*-----------------------------------------
 * 모바일 뒤로가기
 -----------------------------------------*/
.note-mobile-back {
    margin-bottom: 20px;
}

.note-back-link {
    font-size: 0.875rem;
    color: var(--damda-sig-color);
    text-decoration: none;
}

.note-back-link:hover {
    text-decoration: underline;
    color: var(--damda-sig-color);
}

/*-----------------------------------------
 * 3단 레이아웃
 -----------------------------------------*/
.note-detail-row {
    align-items: flex-start;
}

/*-----------------------------------------
 * 왼쪽 사이드바
 -----------------------------------------*/
.note-sidebar-col {
    max-width: 300px;
    min-width: 200px;
    padding-right: 24px;
    margin-left: auto;
}

.note-sidebar {
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #e0e0e0 transparent;
}

.note-sidebar::-webkit-scrollbar {
    width: 4px;
}

.note-sidebar::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 2px;
}

.note-sidebar-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--damda-sig-color);
}

.note-sidebar-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--damda-sig-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.note-sidebar-title:hover {
    text-decoration: none;
    opacity: 0.8;
}

.note-sidebar-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.note-sidebar-item {
    border-bottom: 1px solid #f4f4f4;
}

.note-sidebar-link {
    display: block;
    padding: 10px 0;
    font-size: 0.825rem;
    color: #808080;
    text-decoration: none;
    line-height: 1.4;
    transition: color .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-sidebar-link:hover {
    color: var(--damda-sig-color);
    text-decoration: none;
}

.note-sidebar-item.active .note-sidebar-link {
    color: var(--damda-sig-color);
    font-weight: 600;
}

/*-----------------------------------------
 * 본문 영역
 -----------------------------------------*/
.note-content-col {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
}

/*-----------------------------------------
 * 게시글
 -----------------------------------------*/
.note-article {
    margin-bottom: 48px;
}

.note-article-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid #f0f0f0;
}

.note-article-tags {
    margin-bottom: 12px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.note-tag-badge {
    display: inline-block;
    padding: 3px 10px;
    background: #f0f8f4;
    color: var(--damda-sig-color);
    border-radius: 12px;
    font-size: 0.775rem;
    font-weight: 500;
}

.note-article-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #393939;
    line-height: 1.4;
    margin-top: 16px;
    margin-bottom: 16px;
}

.note-article-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.note-article-date {
    font-size: 0.875rem;
    color: #aaa;
}

.note-article-views {
    font-size: 0.875rem;
    color: #bbb;
    display: flex;
    align-items: center;
    gap: 4px;
}

/*-----------------------------------------
 * 본문 타이포그래피 (CKEditor 출력)
 -----------------------------------------*/
.note-article-content {
    font-size: 1rem;
    line-height: 1.85;
    color: #393939;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.note-article-content h1,
.note-article-content h2,
.note-article-content h3,
.note-article-content h4 {
    font-weight: 700;
    margin-top: 2em;
    margin-bottom: .75em;
    color: #222;
    line-height: 1.3;
}

.note-article-content h1 { font-size: 1.6rem; }
.note-article-content h2 { font-size: 1.35rem; }
.note-article-content h3 { font-size: 1.15rem; }
.note-article-content h4 { font-size: 1rem; }

.note-article-content p {
    margin-bottom: 1.25em;
}

/* 일반 img */
.note-article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    display: block;
    margin: 1.5em auto;
    cursor: zoom-in;
}

/* 하이퍼링크가 걸린 이미지 */
.note-article-content a[href] img {
    cursor: pointer;
    transition: opacity .2s;
}
.note-article-content a[href]:hover img {
    opacity: 0.85;
}
.note-article-content a[href]:has(img),
.note-article-content a[href]:has(video) {
    display: block;
    text-decoration: none;
    width: fit-content;
    max-width: 100%;
}
/* 링크 이미지 정렬: img의 alignment class를 <a> wrapper에 반영 */
.note-article-content a[href]:has(> img.img-align-left)   { margin-right: auto; }
.note-article-content a[href]:has(> img.img-align-center) { margin-left: auto; margin-right: auto; }
.note-article-content a[href]:has(> img.img-align-right)  { margin-left: auto; }

.note-article-content video {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5em auto;
}

/* CKEditor image2 플러그인 출력 — figure/figcaption */
.note-article-content figure {
    margin: 2em 0;
    display: table;    /* figcaption 너비를 이미지에 맞춤 */
}
.note-article-content figure img {
    margin: 0;
}
.note-article-content figcaption {
    display: table-caption;
    caption-side: bottom;
    font-size: 0.825rem;
    color: #808080;
    text-align: center;
    padding-top: 6px;
    line-height: 1.4;
}

/* 이미지 정렬 클래스 */
.note-article-content figure.image-left {
    float: left;
    margin-right: 1.5em;
    margin-bottom: 1em;
    max-width: 45%;
}
.note-article-content figure.image-right {
    float: right;
    margin-left: 1.5em;
    margin-bottom: 1em;
    max-width: 45%;
}
.note-article-content figure.image-center {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

/* float clearfix */
.note-article-content::after {
    content: "";
    display: table;
    clear: both;
}

/* ── TipTap 이미지 정렬 클래스 ────────────────────────────────────── */
.note-article-content img.img-align-left {
    display: block;
    float: none;
    margin-top: 1rem;
    margin-bottom: 1rem;
    margin-left: 0;
    margin-right: auto;
}
.note-article-content img.img-align-center {
    display: block;
    float: none;
    margin: 1rem auto;
}
.note-article-content img.img-align-right {
    display: block;
    float: none;
    margin-top: 1rem;
    margin-bottom: 1rem;
    margin-left: auto;
    margin-right: 0;
}

/* ── TipTap 이미지 갤러리 ─────────────────────────────────────────── */
.note-article-content .image-gallery {
    margin: 1.25rem 0;
}
.note-article-content .image-gallery img {
    margin: 0;
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 4px;
    float: none;
}

/* 2열 그리드 */
.note-article-content .image-gallery--grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
/* 3열 그리드 */
.note-article-content .image-gallery--grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
/* 가로 스크롤 */
.note-article-content .image-gallery--scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    scrollbar-width: thin;
}
.note-article-content .image-gallery--scroll img {
    flex: 0 0 auto;
    width: auto;
    max-width: 320px;
    height: 240px;
    object-fit: cover;
}

/* 모바일 반응형 */
@media (max-width: 767px) {
    .note-article-content .image-gallery--grid-2,
    .note-article-content .image-gallery--grid-3 {
        grid-template-columns: 1fr;
    }
    .note-article-content .image-gallery--scroll img {
        max-width: 260px;
        height: 200px;
    }
}

/* 이미지 클릭 확대 오버레이 */
.note-img-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.85);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.note-img-overlay.active {
    display: flex;
}
.note-img-overlay img {
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 4px;
    object-fit: contain;
    margin: 0;
    cursor: default;
}

.note-article-content ul,
.note-article-content ol {
    padding-left: 1.5em;
    margin-bottom: 1.25em;
}

.note-article-content li {
    margin-bottom: .4em;
}

.note-article-content blockquote {
    border-left: none;
    margin: 1.5em 0;
    padding: .75em 1.25em;
    background: #f8faf9;
    color: #555;
    border-radius: 6px;
}

/* 하이라이트(mark) — 배경색은 inline style(저장된 값)로 적용됨 */
.note-article-content mark {
    padding: 0.05em 0.2em;
    border-radius: 3px;
    color: inherit;
}

/* 인용구 색상 프리셋 (어드민 에디터와 동일 — class 기반) */
.note-article-content blockquote.bq-c-gray   { background: #f1f3f5; }
.note-article-content blockquote.bq-c-yellow { background: #fff9db; }
.note-article-content blockquote.bq-c-green  { background: #ebfbee; }
.note-article-content blockquote.bq-c-blue   { background: #e7f5ff; }
.note-article-content blockquote.bq-c-red    { background: #fff5f5; }
.note-article-content blockquote.bq-c-purple { background: #f3f0ff; }
.note-article-content blockquote.bq-c-orange { background: #fff4e6; }

.note-article-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5em;
    font-size: 0.9rem;
}

.note-article-content table th,
.note-article-content table td {
    border: 1px solid #e0e0e0;
    padding: 10px 14px;
    text-align: left;
}

.note-article-content table th {
    background: #f8faf9;
    font-weight: 600;
}

/* ── TipTap: 표 wrap 정렬 ──────────────────────────────────────────── */
.note-article-content table[data-table-align="center"] {
    width: auto;
    margin: 0 auto;
}
.note-article-content table[data-table-align="right"] {
    width: auto;
    margin-left: auto;
    margin-right: 0;
}

/* ── TipTap: 셀 배경색 (inline style="background-color:...") ─────── */
.note-article-content table td[style*="background-color"],
.note-article-content table th[style*="background-color"] {
    /* inline style 적용 허용 — 별도 CSS override 없음 */
}

/* ── TipTap: 표 테두리 스타일 ─────────────────────────────────────── */
.note-article-content table[data-border-style="none"],
.note-article-content table[data-border-style="none"] th,
.note-article-content table[data-border-style="none"] td {
    border: none;
}
.note-article-content table[data-border-style="outer"] th,
.note-article-content table[data-border-style="outer"] td {
    border: none;
}
.note-article-content table[data-border-style="outer"] {
    border: 1px solid #e0e0e0;
}

.note-article-content a {
    color: var(--damda-sig-color);
    text-decoration: underline;
}

.note-article-content a:hover {
    opacity: .8;
}

.note-article-content strong {
    font-weight: 700;
}

.note-article-content code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.875em;
}

.note-article-content pre {
    background: #f4f4f4;
    padding: 1.25em;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1.5em;
}

/*-----------------------------------------
 * 게시글 하단 태그
 -----------------------------------------*/
.note-article-footer {
    padding-top: 24px;
    border-top: 1px solid #f0f0f0;
}

.note-article-footer-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/*-----------------------------------------
 * 관련 게시글
 -----------------------------------------*/
.note-related {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 2px solid #f0f0f0;
}

.note-related-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: #393939;
}

.note-related-item {
    margin-bottom: 16px;
}

.note-related-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.note-related-link:hover {
    text-decoration: none;
}

.note-related-link:hover .note-related-card-title {
    color: var(--damda-sig-color);
}

.note-related-thumb {
    width: 100%;
    aspect-ratio: 3/2;
    overflow: hidden;
    border-radius: 6px;
    background: #f4f4f4;
    margin-bottom: 8px;
}

.note-related-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s ease;
    display: block;
}

.note-related-link:hover .note-related-thumb img {
    transform: scale(1.04);
}

.note-related-card-title {
    font-size: 0.825rem;
    font-weight: 600;
    line-height: 1.4;
    color: #393939;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color .15s;
}

/*-----------------------------------------
 * 목록 버튼
 -----------------------------------------*/
.note-back-wrap {
    margin-top: 40px;
    padding-top: 24px;
    text-align: center;
}

.note-back-btn {
    padding: 10px 32px;
    font-size: 0.9rem;
}

/*-----------------------------------------
 * 반응형
 -----------------------------------------*/
@media (max-width: 991.98px) {
    #damdanote-detail-section {
        padding: 24px 0 80px;
    }

    .note-article-title {
        font-size: 1.4rem;
    }

    .note-article-content {
        font-size: 0.975rem;
    }
}

@media (max-width: 575.98px) {
    .note-article-title {
        font-size: 1.25rem;
    }

    .note-article-content h1 { font-size: 1.3rem; }
    .note-article-content h2 { font-size: 1.15rem; }
    .note-article-content h3 { font-size: 1rem; }
}
