/* 공통 글 상세 — 1120 본문 + 우측 목차 200px */

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

:root {
    --post-article-max: 1120px;
    --post-article-toc-width: 240px;
    --post-article-gap: 2rem;
    --post-article-sticky-top: calc(64px + 1rem + 5px);
}

.post-article-page {
    padding: 2.5rem 0 4rem;
}

/* 상세 본문은 절대 페이드/숨김 처리하지 않음 */
.post-article-page,
.post-article-page .site-reveal,
.post-article-page .site-img-lazy,
.post-article,
.post-article__inner,
.post-article__main,
.post-article__content,
.post-article__lead,
.post-article__title {
    opacity: 1 !important;
    transform: none !important;
}

.post-article {
    width: min(var(--post-article-max), calc(100% - 32px));
    margin: 0 auto;
}

.post-article__head {
    margin-bottom: 1.25rem;
}

.post-article__main > .post-article__head {
    margin-top: 0;
}

.post-article__cat {
    display: inline-block;
    margin-bottom: .75rem;
    padding: .25rem .65rem;
    font-size: .75rem;
    font-weight: 700;
    color: #147985;
    background: rgba(20, 121, 133, .1);
    border-radius: 999px;
}

.post-article__title {
    margin: 0 0 .75rem;
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: -.02em;
    color: #1a2e35;
}

.post-article__date {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    color: #6b7c85;
}

.post-article__lead {
    margin: 0 0 1.5rem;
    padding: 1rem 1.25rem;
    font-size: 1.0625rem;
    line-height: 1.7;
    color: #1a2e35;
    background: #f0ebe3;
    border-left: 4px solid #147985;
    border-radius: 0 12px 12px 0;
}

.post-article__main .post-article__lead {
    margin-top: 0;
}

.post-article__thumb {
    margin: 0 0 2rem;
    border-radius: 12px;
    overflow: hidden;
    background: #f0ebe3;
}

.post-article__thumb img {
    width: 100%;
    height: auto;
    display: block;
}

.post-article__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--post-article-toc-width);
    gap: var(--post-article-gap);
    align-items: start;
}

.post-article__layout--no-toc {
    grid-template-columns: 1fr;
}

.post-article__main {
    min-width: 0;
}

.post-article__content {
    font-size: 1.0625rem;
    line-height: 1.85;
    color: #1a2e35;
}

.post-article__content > :first-child {
    margin-top: 0;
}

.post-article__content h2,
.post-article__content h3,
.post-article__content h4 {
    scroll-margin-top: var(--post-article-sticky-top);
    color: #0c3d5c;
    line-height: 1.35;
}

.post-article__content h2 {
    margin: 2.5rem 0 1.5rem;
    padding: .875rem 0 .875rem 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.5;
    color: #2a3441;
    background: #f3f4f6;
    border-left: 4px solid #3d4f5f;
    border-bottom: 1px solid #c5cad1;
    box-sizing: border-box;
}

.post-article__content h3 {
    margin: 2rem 0 .875rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.post-article__content p {
    margin: 0 0 1.125rem;
}

.post-article__content ul,
.post-article__content ol {
    margin: 0 0 1.25rem 1.25rem;
    padding: 0;
}

.post-article__content li {
    margin-bottom: .5rem;
}

.post-article__content a.internal-link {
    display: inline;
    padding: .2em .5em;
    background: #dbeef1;
    color: #0a4f5c;
    font-weight: 600;
    border-radius: 4px;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.post-article__content a.internal-link:hover {
    background: #147985;
    color: #fff;
}

.post-article__content a.internal-link-underline {
    background: none;
    color: #147985;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.post-article__content a.internal-link-underline:hover {
    color: #0c3d5c;
}

.post-article__content ul:has(a.internal-link-underline) {
    list-style: square;
    padding-left: 1.35rem;
}

.post-article__content ul:has(a.internal-link-underline) li {
    display: list-item;
}

.post-article__content blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    color: #6b7c85;
    background: #fff;
    border-left: 4px solid #d4735e;
    border-radius: 0 12px 12px 0;
}

.post-article__content pre {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    font-size: .875rem;
    line-height: 1.6;
    background: #1a2e35;
    color: #eef4f6;
    border-radius: 12px;
}

.post-article__content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .92em;
}

.post-article__content :not(pre) > code {
    padding: .15rem .4rem;
    background: #f0ebe3;
    border-radius: 4px;
}

.post-article__content table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    font-size: .9375rem;
    background: #fff;
    border: 1px solid #e8e0d6;
    border-radius: 12px;
    overflow: hidden;
}

.post-article__content th,
.post-article__content td {
    padding: .75rem .875rem;
    border: 1px solid #e8e0d6;
    text-align: left;
    vertical-align: top;
}

.post-article__content th {
    font-weight: 700;
    color: #0c3d5c;
    background: #f0ebe3;
}

.post-article__content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
}

/* IssueHub 게시글 본문 공통 스타일 */
.post-content h2 { margin: 2.75rem 0 0.85rem; }
.post-content h3 { margin: 2rem 0 0.65rem; }

.post-content h2 + p,
.post-content h2 + ul,
.post-content h2 + ol,
.post-content h2 + blockquote,
.post-content h3 + p,
.post-content h3 + ul,
.post-content h3 + ol,
.post-content h3 + blockquote { margin-top: 0; }

.post-content p { margin: 0 0 1.05rem; }
.post-content ul,
.post-content ol { margin: 0.45rem 0 1.35rem; }
.post-content li + li { margin-top: 0.45rem; }

/* 모든 본문 링크: 밑줄 대신 배경색과 글자색으로 표시 */
.post-content a:not([href^="#"]) {
    padding: 0.08em 0.36em;
    border-radius: 0.32em;
    font-weight: 700;
    line-height: 1.65;
    text-decoration: none;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
    transition: color 0.16s ease, background-color 0.16s ease;
}

/* IssueHub 내부 글 */
.post-content a[href^="/"]:not([href^="#"]) {
    color: #1556a8;
    background-color: #eaf3ff;
}
.post-content a[href^="/"]:not([href^="#"])::after {
    content: " →";
    font-size: 0.86em;
}
.post-content a[href^="/"]:not([href^="#"]):hover {
    color: #0d3f7e;
    background-color: #d6e9ff;
}

/* 공식 출처 등 외부 사이트 */
.post-content a[href^="http://"],
.post-content a[href^="https://"] {
    color: #8a4300;
    background-color: #fff0d6;
}
.post-content a[href^="http://"]::after,
.post-content a[href^="https://"]::after {
    content: " ↗";
    font-size: 0.86em;
}
.post-content a[href^="http://"]:hover,
.post-content a[href^="https://"]:hover {
    color: #6c3200;
    background-color: #ffe2ad;
}

.post-content a:not([href^="#"]):focus-visible {
    outline: 3px solid rgba(28, 103, 190, 0.32);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .post-content a:not([href^="#"]) { transition: none; }
}

.post-article__aside {
    width: var(--post-article-toc-width);
    position: sticky;
    top: var(--post-article-sticky-top);
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.post-aside-drawer__head {
    display: none;
}

.post-aside-drawer__body {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.post-aside-drawer__body > .post-related {
    margin-top: 10px;
}

.post-toc-fab,
.post-toc-backdrop {
    display: none;
}

.post-toc {
    padding: 1rem .875rem;
    background: #fff;
    border: 1px solid #e8e0d6;
    border-radius: 12px;
}

.post-toc__title {
    margin: 0 0 .75rem;
    font-size: .8125rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #0c3d5c;
}

.post-toc__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.post-toc__item {
    margin: 0 0 .5rem;
    font-size: .8125rem;
    line-height: 1.45;
    min-width: 0;
}

.post-toc__item:last-child {
    margin-bottom: 0;
}

.post-toc__item a {
    display: block;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #6b7c85;
    text-decoration: none;
    transition: color .15s ease;
}

.post-toc__item a::before {
    display: none;
}

.post-toc__item a:hover {
    color: #147985;
}

.post-related {
    padding: 1rem .875rem;
    background: #fff;
    border: 1px solid #e8e0d6;
    border-radius: 12px;
}

.post-related__title {
    margin: 0 0 .75rem;
    font-size: .8125rem;
    font-weight: 800;
    letter-spacing: .04em;
    color: #0c3d5c;
}

.post-related__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.post-related__item {
    margin: 0 0 .55rem;
    min-width: 0;
}

.post-related__item:last-child {
    margin-bottom: 0;
}

.post-related__link {
    display: flex;
    align-items: flex-start;
    gap: .4rem;
    min-width: 0;
    max-width: 100%;
    font-size: .8125rem;
    line-height: 1.45;
    font-weight: 500;
    color: #6b7280;
    text-decoration: none;
    transition: color .15s ease;
}

.post-related__link::before {
    content: '';
    flex: 0 0 6px;
    width: 6px;
    height: 6px;
    margin-top: calc((1.45em - 6px) / 2);
    background: #9ca3af;
    border-radius: 1px;
}

.post-related__text {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.post-related__item:not(.is-current) a.post-related__link:hover {
    color: #147985;
}

.post-related__item.is-current .post-related__link {
    font-weight: 700;
    color: #c2410c;
}

.post-related__item.is-current .post-related__link::before {
    content: '→';
    flex: 0 0 auto;
    width: auto;
    height: auto;
    margin-top: 0;
    background: none;
    border-radius: 0;
    font-size: .8125rem;
    font-weight: 700;
    line-height: 1.45;
    color: #c2410c;
}

@media (max-width: 960px) {
    .post-article__content,
    .post-article__lead {
        font-size: 1.0625rem;
    }

    .post-article__layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* 레이아웃 안 사이드바는 모바일에서 완전 숨김 — 버튼으로 열 때만 body 드로어 */
    .post-article__layout > .post-article__aside {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    /* 닫힌 드로어 — 슬라이드 아웃 유지 (visibility로 끊지 않음) */
    body > .post-article__aside.is-drawer:not([data-open="1"]) {
        pointer-events: none !important;
        transform: translateX(100%);
    }

    body > .post-article__aside.is-drawer {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 1200;
        display: flex !important;
        flex-direction: column;
        gap: 0;
        width: min(80vw, 340px);
        height: 100%;
        height: 100dvh;
        max-height: 100%;
        max-height: 100dvh;
        margin: 0;
        padding: 0;
        overflow: hidden;
        background: #fff;
        border: 0;
        box-shadow: -10px 0 30px rgba(15, 23, 42, .22);
        transform: translateX(100%);
        transition: transform .28s ease;
        pointer-events: none;
        visibility: visible;
        box-sizing: border-box;
    }

    body > .post-article__aside.is-drawer[data-open="1"] {
        transform: translateX(0);
        pointer-events: auto;
    }

    body > .post-article__aside.is-drawer .post-aside-drawer__head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .75rem;
        flex: 0 0 auto;
        margin: 0;
        padding: 1rem 1.15rem .75rem;
        border: 0;
        background: #fff;
    }

    body > .post-article__aside.is-drawer .post-aside-drawer__title {
        margin: 0;
        font-size: 1.05rem;
        font-weight: 800;
        color: #111827;
    }

    body > .post-article__aside.is-drawer .post-aside-drawer__close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 6px;
        background: transparent;
        color: #c0c4cc;
        font-size: 1.65rem;
        line-height: 1;
        cursor: pointer;
    }

    /* 목록 영역만 세로 스크롤 — 하단이 잘리지 않음 */
    body > .post-article__aside.is-drawer .post-aside-drawer__body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 0 1.15rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
    }

    body > .post-article__aside.is-drawer .post-toc,
    body > .post-article__aside.is-drawer .post-related {
        padding: 0;
        background: transparent;
        border: 0;
        border-radius: 0;
    }

    body > .post-article__aside.is-drawer .post-related {
        margin-top: 1.25rem;
    }

    body > .post-article__aside.is-drawer .post-toc__title {
        display: none;
    }

    body > .post-article__aside.is-drawer .post-toc__item {
        margin: 0 0 .7rem;
        font-size: .9rem;
        min-width: 0;
    }

    body > .post-article__aside.is-drawer .post-toc__item a {
        display: block;
        min-width: 0;
        color: #9ca3af;
        line-height: 1.45;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    body > .post-article__aside.is-drawer .post-toc__item a::before {
        display: none;
    }

    body > .post-article__aside.is-drawer .post-related__title {
        margin: 0 0 .85rem;
        font-size: .95rem;
        font-weight: 800;
        letter-spacing: 0;
        text-transform: none;
        color: #111827;
    }

    body > .post-article__aside.is-drawer .post-related__item {
        margin: 0 0 .65rem;
    }

    body > .post-article__aside.is-drawer .post-related__link {
        font-size: .875rem;
        color: #6b7280;
    }

    body > .post-article__aside.is-drawer .post-related__link::before {
        width: 7px;
        height: 7px;
        flex-basis: 7px;
        background: #2563eb;
        border-radius: 1px;
    }

    body > .post-article__aside.is-drawer .post-related__item.is-current .post-related__link {
        color: #ea580c;
    }

    body > .post-article__aside.is-drawer .post-related__item.is-current .post-related__link::before {
        content: '→';
        width: auto;
        height: auto;
        flex-basis: auto;
        background: none;
        color: #ea580c;
        font-size: .875rem;
    }

    body > .post-toc-fab {
        position: fixed;
        top: var(--post-toc-fab-top, calc(64px + 2rem + 6px));
        right: 12px;
        z-index: 1100;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 58px;
        height: 58px;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 999px;
        background: #1e3a5f;
        color: #fff;
        font-size: .9rem;
        font-weight: 700;
        letter-spacing: .02em;
        box-shadow: 0 6px 18px rgba(15, 23, 42, .3);
        cursor: pointer;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: none;
        transition: opacity .5s ease, visibility .5s ease;
    }

    body > .post-toc-fab.is-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    body > .post-toc-fab[hidden] {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    body > .post-toc-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1150;
        background: rgba(17, 24, 39, .4);
    }

    body > .post-toc-backdrop[hidden] {
        display: none !important;
        pointer-events: none !important;
    }

    body.is-post-toc-open {
        overflow: hidden;
    }
}

@media (min-width: 961px) {
    .post-aside-drawer__head,
    .post-toc-fab,
    .post-toc-backdrop,
    body > .post-toc-fab,
    body > .post-toc-backdrop,
    body > .post-article__aside.is-drawer {
        display: none !important;
    }
}
