/* =======================================================
   04. FEATURE: FLOATING SIDE PANELS
   - 오른쪽: TOC + 진행바 + 홈버튼
   - 왼쪽:   시계 패널 + 뉴스 리스트
   - ≤1200px: 패널 전체 숨김
   - ≤1760px: 고정 마진 → 뷰포트 기준 20px로 전환
======================================================= */
.floating-title-panel {
    position: fixed;
    top: 150px;
    width: 260px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(20px);
    transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s;
    z-index: 100;
    /* 헤더 드롭다운(보통 1000+)보다 낮게 설정하여 간섭 방지 */
}

.floating-title-panel.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.floating-title-inner {
    background: #fff;
    padding: 20px;
    max-height: none;
    /* 높이 제한 해제 */
    overflow-y: visible;
    /* 스크롤바 생성 방지 */
    border-radius: 10px;
    border: 1px solid var(--line-light);
    overflow: hidden;
}

/* 오른쪽 패널 (TOC) */
.floating-title-panel.right-panel {
    left: 50%;
    margin-left: 570px;
}

.floating-title-panel.right-panel .floating-title-inner {
    border-left: none;
}

/* 왼쪽 패널 (News + Clock) */
.floating-title-panel.left-panel {
    right: 50%;
    margin-right: 570px;
}

.floating-title-panel.left-panel .floating-title-inner {
    border-right: none;
}

/* 패널 내부 공통 */
.floating-title-inner h1 {
    font-size: 18px;
    margin: 0 0 8px 0;
}

/* 다크모드 대응: 패널 배경 및 상자 테두리 색상 조정 */
body.dark-theme .floating-title-inner {
    background: var(--bg-panel) !important;
    border-color: var(--border-main) !important;
}

.floating-title-inner .entry-meta {
    font-size: 12px;
    opacity: 0.6;
    margin-bottom: 14px;
    color: #365951;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
}

.floating-title-inner .entry-meta img {
    display: none !important;
}

/* 스크롤 진행바 */
.floating-progress-bar {
    height: 4px;
    width: 100%;
    background: #eee;
    margin-bottom: 16px;
    overflow: hidden;
}

.floating-progress-fill {
    height: 100%;
    width: 0%;
    background: #222;
    transition: width 0.15s linear;
}

/* TOC 링크 */
.floating-toc {
    list-style: none;
    padding: 0;
    margin: 0;
}

.floating-toc li {
    margin-bottom: 2px;
}

.floating-toc li::before {
    display: none;
}

.floating-toc a {
    font-size: 13px;
    text-decoration: none;
    color: #444;
    transition: 0.2s;
    display: block;
    padding: 5px 8px;
    border-radius: 4px;
    line-height: 1.4;
}

.floating-toc a.active {
    font-weight: 600;
    color: #f5f0e8;
    background: #4da318;
}

/* 뉴스 리스트 */
.floating-news-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.floating-news-list li {
    margin-bottom: 12px;
    line-height: 1.4;
}

.floating-news-list a {
    font-size: 13px;
    text-decoration: none;
    color: #444;
    transition: 0.2s;
    display: block;
}

.floating-news-list a:hover {
    color: var(--point-color);
    font-weight: 600;
}

.fnews-genre {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #999;
    margin: 14px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e5e5e5;
}

.fnews-genre:first-child {
    margin-top: 0;
}

.fnews-empty {
    font-size: 12px;
    opacity: 0.5;
    margin: 0;
}

/* 홈 버튼 */
.floating-home-wrapper {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--line-light);
    text-align: center;
}

.floating-home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background: #f4f4f4;
    color: var(--text-black);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    border-radius: 6px;
    transition: var(--transition-fast);
}

.floating-home-btn:hover {
    background: #2D4B43;
    color: #fff !important;
}

.home-icon {
    width: 14px;
    height: 14px;
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

.floating-home-btn:hover .home-icon {
    background-color: #fff;
}

/* NOW / STRAVA 서브 버튼 */
.floating-sub-btns {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

/* 라이트모드 기본값 하드코딩 */
.floating-sub-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    flex: 1;
    padding: 8px 6px;
    background: #f4f4f4;
    color: var(--text-black);
    font-size: 11px;
    font-weight: 800;
    text-decoration: none;
    border-radius: 6px;
    transition: var(--transition-fast);
    letter-spacing: 0.3px;
}

/* 로고 이미지: 라이트모드 기본 상태 — 텍스트 색과 통일 (어둡게) */
.floating-sub-btn img {
    filter: grayscale(1) brightness(0);
    transition: filter 0.25s ease;
}

.floating-sub-btn:hover {
    background: #2D4B43;
    color: #fff !important;
}

/* 호버 시 로고 흰색 */
.floating-sub-btn:hover img {
    filter: grayscale(1) brightness(10) !important;
}

/* 다크모드: CSS 변수 오버라이드 */
body.dark-theme .floating-sub-btn {
    background: var(--sub-btn-bg, #2a2a2a);
    color: var(--sub-btn-text, #ddd);
}

body.dark-theme .floating-sub-btn img {
    filter: grayscale(1) brightness(10);
}

body.dark-theme .floating-sub-btn:hover {
    background: var(--sub-btn-hover-bg, #2D4B43);
    color: var(--sub-btn-hover-text, #fff) !important;
}

body.dark-theme .floating-sub-btn:hover img {
    filter: grayscale(1) brightness(10) !important;
}


/* =======================================================
   05. COMPONENT: CLOCK (오른쪽 패널 하단 통합)
   - 별도 패널 없이 right-panel 내부에 .ftp-clock-integrated 로 통합
   - 목차 끝단과 맞춰 border-top 구분선으로 연결
   - fpc-top: 요일 + 월/일 한 줄
   - fpc-bottom: HH:MM + 초 배지
======================================================= */
.floating-title-panel.right-panel {
    top: 100px;
}

.floating-title-panel.left-panel {
    top: 100px;
}

/* 시계+토글 가로 배치 래퍼 — JS 인라인 style 과 동기 */
.ftp-clock-integrated {
    flex: 1;
    min-width: 0;
}

/* TOP: 한 줄 날짜 바 */
.fpc-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 2px 10px 4px;
}

/* 요일 (SAT) */
.fpc-dow {
    font-family: 'Pretendard', sans-serif;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: #888;
    line-height: 1;
    text-transform: uppercase;
    margin-bottom: 0;
}

/* 날짜 숫자 행 */
.fpc-date-row {
    display: flex;
    align-items: center;
    gap: 3px;
}

/* 날짜 숫자(03.07), 월(MARCH) */
.fpc-day,
.fpc-month {
    font-family: 'Pretendard', sans-serif;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #aaa;
    line-height: 1;
}

/* 구분점 */
.fpc-sep {
    font-size: 8px;
    color: #ccc;
    line-height: 1;
}

/* BOTTOM: 시간 표시 */
.fpc-bottom {
    padding: 0 10px 4px;
    width: 100%;
    box-sizing: border-box;
}

.fpc-time {
    font-family: 'Pretendard', sans-serif;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #2D4B43;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.fpc-colon {
    color: #FC4C02;
    margin: 0 2px;
    font-size: 22px;
    animation: fpc-blink 1s step-end infinite;
}

@keyframes fpc-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.2;
    }
}

.fpc-sec {
    margin-left: 6px;
    background: #FC4C02;
    color: #fff;
    font-family: 'Pretendard', sans-serif;
    font-size: 9px;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 3px;
    align-self: center;
    letter-spacing: 0.5px;
    min-width: 24px;
    text-align: center;
    margin-top: 3px;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}


/* =======================================================
   07. COMPONENT: MOBILE POPUP TOC
   - ≤1200px 에서만 표시
   - fixed 원형 버튼 → 오버레이 팝업
======================================================= */
.mobile-toc-wrapper {
    display: none;
}

#mobile-toc-btn {
    position: fixed;
    right: 20px;
    bottom: 85px;
    width: 46px;
    height: 46px;
    background: #2D4B43;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#mobile-toc-btn.visible {
    opacity: 1;
    visibility: visible;
}

#mobile-toc-btn:hover,
#mobile-toc-btn:active {
    opacity: 1;
    background: rgba(45, 75, 67, 1);
    transform: scale(1.05);
}

/* 데스크탑 완전 숨김 */
@media (min-width: 1025px) {
    #mobile-toc-btn {
        display: none !important;
    }
}

@media (max-width: 1200px) {
    .mobile-toc-wrapper {
        display: block;
    }

    #mobile-toc-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.8);
        backdrop-filter: blur(4px);
        z-index: 10002;
        display: none;
        justify-content: center;
        align-items: center;
    }

    .mobile-toc-content {
        width: 85%;
        max-height: 70vh;
        background: #fff;
        border-radius: 20px;
        padding: 30px 25px;
        position: relative;
        overflow-y: auto;
    }

    .mobile-toc-content h3 {
        font-size: 20px;
        font-weight: 800;
        margin-bottom: 20px;
        border-bottom: 2px solid #111;
        padding-bottom: 10px;
    }

    #close-toc {
        position: absolute;
        top: 20px;
        right: 20px;
        font-size: 28px;
        font-weight: 300;
        cursor: pointer;
    }

    .mobile-toc-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .mobile-toc-list li {
        margin-bottom: 15px;
    }

    .mobile-toc-list a {
        font-size: 16px;
        text-decoration: none;
        color: #333;
        font-weight: 600;
        display: block;
        line-height: 1.4;
    }
}

@media (max-width: 1024px) {
    #mobile-toc-btn {
        bottom: 90px;
        right: 16px;
    }
}

@media (max-width: 768px) {
    #mobile-toc-btn {
        bottom: 80px;
        right: 19px;
    }
}


/* =======================================================
   08. COMPONENT: CUSTOM LINK CARD (.tv-link-card-bold)
   - 호버 시 배경/텍스트 반전 (화이트 → 블랙)
======================================================= */
.tv-link-card-bold {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 30px auto;
    padding: 22px 30px;
    background: #ffffff;
    border: 1.5px solid #111;
    border-radius: 8px;
    text-decoration: none !important;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    max-width: 900px;
    position: relative;
    overflow: hidden;
}

.tv-link-card-bold:hover {
    background: #111;
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.1);
}

.tv-link-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.tv-link-title {
    font-size: 24px;
    font-weight: 800;
    color: #111;
    line-height: 1.3;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
    transition: color 0.3s ease;
}

.tv-link-url {
    font-size: 13px;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
}

.tv-link-card-bold:hover .tv-link-title {
    color: #fff;
}

.tv-link-card-bold:hover .tv-link-url {
    color: #aaa;
}

.tv-link-arrow {
    width: 24px;
    height: 24px;
    color: #111;
    transition: all 0.3s ease;
    margin-left: 15px;
}

.tv-link-card-bold:hover .tv-link-arrow {
    color: #fff;
    transform: translateX(5px);
}

@media (max-width: 768px) {
    .tv-link-card-bold {
        padding: 18px 20px;
        margin: 20px auto;
    }

    .tv-link-title {
        font-size: 19px;
    }

    .tv-link-arrow {
        display: none;
    }
}


/* =======================================================
   09. COMPONENT: IMAGE CAPTION
   - 다크그린 세로선 배경 패턴
======================================================= */
.wp-block-image {
    text-align: center;
}

.wp-block-image figcaption {
    display: block;
    margin: 18px auto 0;
    padding: 0 0 0 20px;
    font-size: 18px;
    font-weight: 700;
    color: #333;
    line-height: 1.6;
    text-align: left;
    max-width: fit-content;
    margin-left: auto;
    margin-right: auto;
    background-image: linear-gradient(to bottom, #424219 8px, transparent 8px);
    background-repeat: repeat-y;
    background-size: 8px 1.6em;
    background-position: 0 0.65em;
}

@media (max-width: 768px) {
    .wp-block-image figcaption {
        font-size: 14px;
        padding-left: 18px;
        background-size: 8px 1.6em;
        background-image: linear-gradient(to bottom, #2D4B43 7px, transparent 7px);
    }
}


/* =======================================================
   10. COMPONENT: FOOTNOTES (.wp-block-footnotes)
   - 본문 최하단 각주 원문 영역
   - 작고 흐린 텍스트로 처리
======================================================= */
.wp-block-footnotes {
    font-size: 13px;
    font-weight: 400;
    color: #aaa;
    line-height: 1.7;
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.wp-block-footnotes li {
    font-size: 13px;
    font-weight: 400;
    color: #aaa;
}

.wp-block-footnotes a {
    color: #bbb;
    font-weight: 400;
    text-decoration: none;
}

.wp-block-footnotes a:hover {
    color: #2D4B43;
}


/* =======================================================
   11. COMPONENT: ENLIGHTERJS CODE BLOCK
======================================================= */
.enlighter-default {
    max-width: 900px !important;
    margin: 30px auto !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.enlighter-default .enlighter {
    overflow-x: auto !important;
    white-space: pre !important;
}

.enlighter-default .enlighter code,
.enlighter-default .enlighter span {
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
}

@media (max-width: 768px) {
    .enlighter-default {
        margin: 20px auto !important;
        border-radius: 0;
    }

    .enlighter-default .enlighter {
        white-space: pre-wrap !important;
        word-break: break-all !important;
        overflow-x: visible !important;
    }
}


/* =======================================================
   12. COMPONENT: RELATED POSTS
   - 3컬럼 그리드, 16:9 썸네일
======================================================= */
.ct-related-posts {
    max-width: 1200px !important;
    margin: 60px auto !important;
    padding: 0 20px !important;
}

.ct-related-posts .ct-module-title {
    font-size: 22px !important;
    font-weight: 800 !important;
    margin-bottom: 30px !important;
    text-align: left;
    border-bottom: 2px solid #111;
    padding-bottom: 10px;
}

.ct-related-posts-items[data-layout="grid"] {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 25px !important;
}

.ct-related-posts-items article {
    margin: 0 !important;
    padding: 0 !important;
}

.ct-related-posts .ct-media-container {
    display: block !important;
    aspect-ratio: 16 / 9 !important;
    overflow: hidden !important;
    border-radius: 8px !important;
    margin-bottom: 12px !important;
}

.ct-related-posts .ct-media-container img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    transition: transform 0.4s ease;
}

.ct-related-posts article:hover img {
    transform: scale(1.05);
}

.related-entry-title {
    font-size: 16px !important;
    line-height: 1.4 !important;
    font-weight: 700 !important;
    margin: 0 0 8px 0 !important;
    word-break: keep-all;
}

.related-entry-title a {
    color: var(--text-black) !important;
    text-decoration: none !important;
}

.ct-related-posts .entry-meta {
    display: flex !important;
    justify-content: flex-end !important;
    font-size: 12px !important;
    color: var(--text-gray) !important;
    opacity: 0.7;
    border-top: 1px solid var(--line-light);
    padding-top: 8px;
    margin-top: auto !important;
}

@media (max-width: 900px) {
    .ct-related-posts-items[data-layout="grid"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 600px) {
    .ct-related-posts-items[data-layout="grid"] {
        grid-template-columns: 1fr !important;
    }
}