@font-face {
    font-family: "Ridibatang";
    src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_twelve@1.0/RIDIBatang.woff")
        format("woff");
    font-weight: normal;
    font-display: swap;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --navbar-bg: #12121200;
    --logo-filter: invert(100%);
    --nav-text: #a0a0a0;
    --nav-hover: #fff;
    --breadcrumb-color: #888;
    --code-bg: #2a2a2a;
    --code-text: #e0e0e0;
    --tag-list-color: #555555;
    --tag-color: #777777;
    --tag-hover: #ffffff;
    --toc-border: #333;
    --toc-link: #666;
    --toc-link-hover: #aaa;
    --toc-link-active: #fff;
    --table-border: rgba(255, 255, 255, 0.2);
    --table-header-bg: rgba(255, 255, 255, 0.04);
    --table-header-text: #ffffff;
    --table-header-border: rgba(255, 255, 255, 0.35);
    --table-row-even: rgba(255, 255, 255, 0.1);
    --table-row-hover: rgba(255, 255, 255, 0.03);
    --tab-border: #333;
    --tab-text: #888;
    --tab-hover-text: #fff;
    --tab-hover-border: #666;
    --tab-active-bg: #333;
    --tab-active-border: #555;
    --pdf-border: #333;
    --tree-color: #ddd;
    --tree-summary: #fff;
    --tree-line: #777;

    /* Profile specific */
    --section-label-color: #555555;
    --hero-title-color: #ffffff;
    --tagline-color: #555555;
    --about-text-color: #999999;
    --interest-border: #2a2a2a;
    --interest-text: #555555;
    --interest-text-hover: #cccccc;
    --interest-border-hover: #555555;
    --skill-name-color: #cccccc;
    --skill-dot-color: #ffffff;
    --timeline-border: #222222;
    --timeline-dot-bg: #333333;
    --timeline-dot-border: #555555;
    --timeline-period-color: #555555;
    --timeline-place-color: #bbbbbb;
    --timeline-desc-color: #555555;
    --contact-service-color: #444444;
    --contact-handle-color: #aaaaaaaa;
    --contact-service-hover: #666666;
    --contact-handle-hover: #dddddd;
}

:root.light-mode {
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --navbar-bg: #ffffff00;
    --logo-filter: none;
    --nav-text: #555555;
    --nav-hover: #000000;
    --breadcrumb-color: #666666;
    --code-bg: #f3f3f3;
    --code-text: #1a1a1a;
    --tag-list-color: #666666;
    --tag-color: #555555;
    --tag-hover: #000000;
    --toc-border: #dddddd;
    --toc-link: #888888;
    --toc-link-hover: #333333;
    --toc-link-active: #000000;
    --table-border: rgba(0, 0, 0, 0.15);
    --table-header-bg: rgba(0, 0, 0, 0.03);
    --table-header-text: #000000;
    --table-header-border: rgba(0, 0, 0, 0.25);
    --table-row-even: rgba(0, 0, 0, 0.05);
    --table-row-hover: rgba(0, 0, 0, 0.02);
    --tab-border: #cccccc;
    --tab-text: #666666;
    --tab-hover-text: #000000;
    --tab-hover-border: #999999;
    --tab-active-bg: #e0e0e0;
    --tab-active-border: #bbbbbb;
    --pdf-border: #cccccc;
    --tree-color: #222222;
    --tree-summary: #000000;
    --tree-line: #bbbbbb;

    /* Profile specific */
    --section-label-color: #888888;
    --hero-title-color: #1a1a1a;
    --tagline-color: #888888;
    --about-text-color: #444444;
    --interest-border: #dddddd;
    --interest-text: #666666;
    --interest-text-hover: #1a1a1a;
    --interest-border-hover: #999999;
    --skill-name-color: #1a1a1a;
    --skill-dot-color: #000000;
    --timeline-border: #e0e0e0;
    --timeline-dot-bg: #ffffff;
    --timeline-dot-border: #bbbbbb;
    --timeline-period-color: #888888;
    --timeline-place-color: #1a1a1a;
    --timeline-desc-color: #666666;
    --contact-service-color: #777777;
    --contact-handle-color: #333333;
    --contact-service-hover: #444444;
    --contact-handle-hover: #000000;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: "Ridibatang", sans-serif;
    font-size: 17px;
    transition:
        background-color 1.5s ease,
        color 1.5s ease;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background-color: var(--navbar-bg);

    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 10;
}

main {
    padding-top: 120px !important;
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0px,
        transparent 80px,
        black var(--mask-fade-end, 180px),
        black 100%
    );
    -webkit-mask-size: 100vw 100vh;
    -webkit-mask-repeat: no-repeat;

    -webkit-mask-position: center var(--scroll-y, 0px);

    mask-image: linear-gradient(
        to bottom,
        transparent 0px,
        transparent 80px,
        black var(--mask-fade-end, 180px),
        black 100%
    );
    mask-size: 100vw 100vh;
    mask-repeat: no-repeat;
    mask-position: center var(--scroll-y, 0px);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--nav-hover);
}

.suwonj-nav-icon {
    height: 30px;
    width: auto;
    object-fit: contain;

    filter: var(--logo-filter);
    opacity: 0.9;
    transition:
        opacity 0.3s ease,
        filter 0.3s ease;
}

#halftone-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
}

.nav-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--breadcrumb-color);
    font-size: 0.95rem;
    flex: 1;
    min-width: 0;
    margin-left: 1.5rem;
}

.nav-breadcrumb a {
    color: var(--breadcrumb-color);
    text-decoration: none;
    transition: color 0.2s;
    white-space: nowrap;
}

.nav-breadcrumb a:hover {
    color: var(--nav-hover);
}

.mobile-text {
    display: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--nav-text);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--nav-hover);
}

.theme-toggle-btn {
    background: none;
    border: none;
    color: var(--nav-text);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    padding: 0;
    margin-left: 0.5rem;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.theme-toggle-btn:hover {
    color: var(--nav-hover);
}

.theme-toggle-btn .material-symbols-outlined {
    font-size: 20px;
    display: inline-block;
    vertical-align: middle;
}

hr {
    margin: 2rem 0;
    opacity: 0;
}

h1 {
    font-size: 2.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--hero-title-color);
}

#content {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#content img {
    max-width: 100%;
    height: auto;
}

#content pre {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre;
    padding: 2.5rem 1.5rem 1.5rem 1.5rem;
    background: transparent !important;
    margin: 2.8rem 0;
    cursor: pointer;
    position: relative;
    border: none;
}

#content pre[data-lang]::before {
    content: attr(data-lang);
    position: absolute;
    top: 0.8rem;
    left: 1.5rem;
    font-size: 0.75rem;
    color: var(--breadcrumb-color);
    font-family: "Google Sans Code", monospace;
    text-transform: uppercase;
    transition: color 0.2s ease;
}

#content pre.copied[data-lang]::before {
    color: var(--nav-hover);
    font-weight: bold;
}

#content code {
    word-break: break-all;
    font-family: "Google Sans Code", monospace;
    font-optical-sizing: auto;
    font-weight: 400;
    font-style: normal;
    font-variation-settings: "MONO" 1;
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

#content pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 0.95em;
    line-height: 1.5;
}

#content ul,
#content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

#content li {
    margin-bottom: 0.3rem;
}

#content li > ul,
#content li > ol {
    margin-top: 0.3rem;
    margin-bottom: 0;
}

#content p {
    margin-bottom: 1rem;
}

#content h2,
#content h3,
#content h4 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--hero-title-color);
}

@media (max-width: 768px) {
    main {
        padding: 1.5rem !important;
        padding-top: 100px !important;
    }

    .navbar {
        padding: 1.5rem 1.5rem;
    }

    .navbar.scrolled {
        padding: 0.8rem 1.5rem;
    }

    /* 모바일 브라우저 주소창 숨김 시 캔버스 요동침 방지 */
    #halftone-canvas {
        height: 100dvh !important;
    }

    .nav-breadcrumb {
        margin-left: 0.5rem;
        font-size: 0.85rem;
        gap: 0.3rem;
    }

    .desktop-text {
        display: none;
    }

    .mobile-text {
        display: inline;
    }
}

.bc-path-link:hover,
.bc-toc-link:hover {
    color: var(--nav-hover) !important;
    text-decoration: underline !important;
}

body {
    overflow-x: hidden;
}

mark {
    background-color: #cceeff;
    color: #000;
    border-radius: 0.25rem;
    padding: 0.15rem;
}

.katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
}

/* Tag List Styles */
.tag-list {
    margin: 0 0 2rem 0;
    font-size: 0.95rem;
    color: var(--tag-list-color);
    font-family: "Google Sans Code", monospace;
}

.tag-list span {
    margin: 0 0.3rem;
}

.tag {
    cursor: pointer;
    color: var(--tag-color);
    transition: color 0.3s ease;
}

.tag:hover,
.tag.active {
    color: var(--tag-hover);
}

/* --- Image Lightbox --- */
#content img {
    cursor: zoom-in;
    border-radius: 8px;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}
#content img:hover {
    transform: scale(1.01);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
#lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
}
#lightbox.active {
    opacity: 1;
    pointer-events: auto;
    cursor: zoom-out;
}
#lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}
#lightbox.active img {
    transform: scale(1);
}

/* --- Floating TOC (Tree Style) --- */
#floating-toc {
    display: none;
}
#floating-tree {
    display: none;
    font-family: Ridibatang;
}
@media (min-width: 1200px) {
    main {
        margin-left: max(5%, calc((100vw - 1100px) / 2)) !important;
        margin-right: auto;
    }
    #floating-toc {
        display: block;
        position: fixed;
        top: 150px;
        right: max(2%, calc((100vw - 1100px) / 2 - 250px));
        width: 250px;
        max-height: calc(100vh - 180px);
        overflow-y: auto;
        padding-left: 1rem;
        border-left: 1px solid var(--toc-border);
        font-size: 0.85rem;
    }
    #floating-tree {
        display: block;
        position: fixed;
        top: 150px;
        left: 20px;
        width: 200px;
        max-height: calc(100vh - 180px);
        overflow-y: auto;
        padding-right: 1rem;
        border-right: 1px solid var(--toc-border);
        font-size: 0.85rem;
    }
    /* 스크롤바 숨기기 */
    #floating-tree::-webkit-scrollbar {
        width: 4px;
    }
    #floating-tree::-webkit-scrollbar-thumb {
        background: #444;
        border-radius: 4px;
    }
    /* 스크롤바 숨기기 */
    #floating-toc::-webkit-scrollbar {
        width: 4px;
    }
    #floating-toc::-webkit-scrollbar-thumb {
        background: #444;
        border-radius: 4px;
    }
    #floating-toc ul {
        list-style: none;
        padding-left: 0;
        margin: 0;
    }
    #floating-toc li {
        margin-bottom: 0.6rem;
    }
    #floating-toc ul ul {
        padding-left: 1rem;
        margin-top: 0.6rem;
        border-left: 1px solid var(--toc-border);
    }
    #floating-toc a {
        color: var(--toc-link);
        text-decoration: none;
        display: block;
        padding-left: 0.5rem;
        transition: all 0.2s ease;
        line-height: 1.4;
    }
    #floating-toc a:hover {
        color: var(--toc-link-hover);
    }
    #floating-toc a.active {
        color: var(--toc-link-active);
        font-weight: 500;
        position: relative;
    }
    #floating-toc a.active::before {
        content: "";
        position: absolute;
        left: -1px; /* 부모 border-left와 위치 맞춤 */
        top: 0;
        bottom: 0;
        width: 2px;
        background-color: var(--toc-link-active);
        border-radius: 2px;
    }
    /* 중첩된 리스트의 active bar 위치 보정 */
    #floating-toc ul ul a.active::before {
        left: -17px;
    }
    #floating-toc ul ul ul a.active::before {
        left: -17px;
    }
}

/* --- Table Styles --- */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin: 2.8rem 0;
    -webkit-overflow-scrolling: touch;
}

#content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-color);
}

#content th,
#content td {
    padding: 0.8rem 1rem;
    border: 1px solid var(--table-border); /* 깔끔하고 얇은 반투명 흰색 선 */
    text-align: left;
}

#content th {
    background-color: var(
        --table-header-bg
    ); /* 헤더 영역에 아주 옅은 투명 흰색 적용 */
    color: var(--table-header-text);
    font-weight: 600;
    border-bottom: 2px solid var(--table-header-border);
}

#content tr:nth-child(even) {
    background: var(--table-row-even);
}

.tree-view {
    font-family: Ridibatang;
    font-size: 0.95rem;
    color: var(--tree-color);
    margin-top: 1rem;
    line-height: 1.4;
}

.tree-view a {
    color: #9ab8dd;
    text-decoration: none;
}

.tree-view a:hover {
    text-decoration: underline;
}

.tree-view ul {
    list-style: none;
    padding-left: 1.3rem;
    margin: 0;
}

.tree-view > ul {
    padding-left: 0;
}

.tree-view li {
    position: relative;
    margin: 0;
    padding: 0;
}

.tree-view li::before,
.tree-view li::after {
    content: "";
    position: absolute;
    left: -1rem;
}

.tree-view li::before {
    border-top: 1px solid var(--tree-line);
    top: 0.7em;
    width: 0.8rem;
}

.tree-view li::after {
    border-left: 1px solid var(--tree-line);
    top: 0;
    bottom: 0;
}

.tree-view li:last-child::after {
    bottom: auto;
    height: 0.7em;
}

.tree-view > ul > li::before,
.tree-view > ul > li::after {
    display: none;
}

.tree-view details > summary {
    cursor: pointer;
    display: inline-block;
    user-select: none;
    color: var(--tree-summary);
    font-weight: bold;
}

.tree-view details > summary::-webkit-details-marker {
    display: none;
}

.tree-view details > summary::before {
    content: "";
}

.tree-view details[open] > summary::before {
    content: "";
}

#content tr:hover {
    background-color: var(--table-row-hover); /* 호버 시 미세하게 밝아짐 */
}

/* 탭 네비게이션 스타일 */
.tab-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    align-items: center;
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--tab-border);
    color: var(--tab-text);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--tab-hover-text);
    border-color: var(--tab-hover-border);
}

.tab-btn.active {
    color: var(--tab-hover-text);
    background-color: var(--tab-active-bg);
    border-color: var(--tab-active-border);
}

/* PDF 컨테이너 스타일 */
.pdf-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.pdf-page-canvas {
    max-width: 100%;
    height: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--pdf-border);
}
