/* modal.css - Insight & Portfolio Detail Modal */

/* Modal Overlay */
.insight_modal_overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
    overflow-x: hidden;
}

.insight_modal_overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* Modal Content Container */
.insight_modal_content {
    width: 100%;
    max-width: var(--container-md);
    max-height: 90vh;
    background: rgba(11, 11, 11, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateY(30px);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.insight_modal_overlay.show .insight_modal_content {
    transform: translateY(0);
}

/* Scrollbar Styling for Modal */
.insight_modal_content::-webkit-scrollbar {
    width: 8px;
}
.insight_modal_content::-webkit-scrollbar-track {
    background: #0b0b0b;
}
.insight_modal_content::-webkit-scrollbar-thumb {
    background: #222;
    border-radius: 4px;
}

/* Close Button */
.insight_modal_close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff !important;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.insight_modal_close:hover {
    background: #eb490b;
    color: #fff;
    transform: rotate(90deg);
}

/* Inner Body Layout */
.insight_modal_body {
    padding: 0;
}

/* Portfolio Specific Split Layout */
.portfolio_modal_container {
    display: flex;
    min-height: 500px;
}

.pf_modal_img {
    width: 50%;
    aspect-ratio: 3 / 4;
    background-size: cover;
    background-position: center;
    position: relative;
}

.pf_modal_info {
    width: 50%;
    padding: 80px 60px;
    background: #0b0b0b;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.pf_modal_cat {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #3b82f6;
    text-transform: uppercase;
    margin-bottom: 15px;
    display: block;
}

.pf_modal_title {
    font-size: 24px;
    letter-spacing: -0.1px;
    font-weight: 900;
    color: #fff;
    margin-bottom: 30px;
    line-height: 1.2;
}

.pf_modal_meta_grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

.pf_meta_item .label {
    font-size: 11px;
    font-weight: 800;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    display: block;
}

.pf_meta_item .val {
    font-size: 15px;
    color: #fff;
    font-weight: 600;
}

.pf_scope_wrap {
    margin-top: 10px;
}

.pf_scope_wrap .label {
    font-size: 11px;
    font-weight: 800;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    display: block;
}

.view_tags_modal.pf_tags {
    display: flex;
    gap: 8px;
    padding: 0;
    margin: 0;
    border: none;
}

.view_tags_modal.pf_tags li {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 8px;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
}

/* Portfolio Body Full Width */
.pf_modal_body_full {
    background: #0b0b0b;
    padding: 60px 0 100px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.pf_modal_body_full .insight_content_modal {
    max-width: 100%;
    margin: 0 auto;
    color: #fff !important;
    font-size: 17px;
}

.pf_modal_body_full .insight_content_modal * {
    color: #fff !important;
}

.pf_modal_body_full .insight_content_modal p {
    padding: 0 60px;
}

.pf_modal_body_full .insight_content_modal img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 20px 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    display: block;
}

/* Hero Banner Inside Modal */
.modal_hero_banner {
    position: relative;
    padding: 120px 60px 80px;
    background-size: cover;
    background-position: center;
    overflow: hidden;
    text-align: center;
    border-bottom: none;
}

.modal_hero_blur {
    position: absolute;
    inset: 0;
    background-image: inherit;
    background-size: cover;
    background-position: inherit;
    filter: brightness(0.5);
    z-index: 0;
}

.modal_hero_overlay {
    position: absolute;
    inset: 0;
    background: fill;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4) 0%, #0b0b0b 100%);
    z-index: 1;
}

.modal_hero_content {
    position: relative;
    z-index: 2;
}

.modal_content_area {
    padding: 50px 40px 80px;
    background: #0b0b0b;
    position: relative;
    z-index: 3;
}

/* Injected Content Styles (Mirroring insight_view.php) */
.modal_hero_content .view_cat_modal,
.modal_hero_content .view_title_modal,
.modal_hero_content .view_date_modal {
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

/* 본문/태그는 모달 폭을 그대로 사용 (좌우 빈 영역 제거) */
.modal_content_area .insight_content_modal,
.modal_content_area .view_tags_modal {
    max-width: 100%;
    width: 100%;
}

/* Category Pop */
.modal_hero_content .view_cat_modal,
.insight_cat_badge {
    background: #eb490b;
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 15px rgba(235, 73, 11, 0.4);
    font-weight: 800;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    width: fit-content;
}

.view_title_modal {
    font-size: 28px;
    letter-spacing: -0.6px;
    font-weight: 900;
    color: #ffffff;
    line-height: 1.35;
    margin-bottom: 20px;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    word-break: keep-all;
}

.view_date_modal {
    color: #aaa;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding-bottom: 0px;
    border-bottom: none;
}

.view_meta_modal {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.view_meta_modal span {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
}

.view_meta_modal span strong {
    color: var(--primary);
    margin-right: 4px;
}

.insight_content_modal {
    font-size: 18px;
    line-height: 1.85;
    letter-spacing: -0.3px;
    color: #ffffff !important;
}

/* main.css의 `* { line-height: 1.4 }` 가 자식 요소를 덮으므로 본문 자식에도 명시 */
.insight_content_modal p,
.insight_content_modal li,
.insight_content_modal span,
.insight_content_modal div,
.insight_content_modal blockquote {
    line-height: 1.85;
    letter-spacing: -0.3px;
}

/* Override global dark-gray color for all elements inside modal content */
.insight_modal_content * {
    color: inherit;
}

.insight_modal_content p,
.insight_modal_content span,
.insight_modal_content div,
.insight_modal_content li {
    color: #ffffff;
}

/* 본문 헤딩 — main.css의 전역 h1(100px)/h2(40px) 덮어쓰기 위해 모두 명시 */
.insight_content_modal h1,
.insight_content_modal h2,
.insight_content_modal h3,
.insight_content_modal h4,
.insight_content_modal h5,
.insight_content_modal h6 {
    color: #ffffff;
    font-weight: 800;
    line-height: 1.4;
    letter-spacing: -0.5px;
    margin-top: 40px;
    margin-bottom: 16px;
    white-space: normal;
}
.insight_content_modal h1 {
    font-size: 28px;
    border-left: 4px solid #eb490b;
    padding-left: 14px;
}
.insight_content_modal h2 {
    font-size: 24px;
    border-left: 4px solid #eb490b;
    padding-left: 14px;
}
.insight_content_modal h3 {
    font-size: 20px;
}
.insight_content_modal h4 {
    font-size: 18px;
}
.insight_content_modal h5,
.insight_content_modal h6 {
    font-size: 16px;
}

.insight_content_modal img {
    border-radius: 12px;
    margin: 30px auto;
    display: block;
    max-width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.view_tags_modal {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.view_tags_modal li {
    background: rgba(255, 255, 255, 0.03);
    padding: 5px 12px;
    border-radius: 20px;
    color: #eb490b;
    font-weight: 700;
    font-size: 12px;
}

/* Loading Spinner */
.modal_loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #eb490b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============ RESPONSIVE ============ */
@media all and (max-width: 1024px) {
    .insight_modal_overlay {
        padding: 0;
    }
    .insight_modal_content {
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
    .portfolio_modal_container {
        flex-direction: column;
    }
    .pf_modal_img {
        width: 100%;
        aspect-ratio: 3 / 4;
        height: auto;
    }
    .pf_modal_info {
        width: 100%;
        padding: 30px 20px;
    }
    .pf_modal_title {
        font-size: 24px;
    }
    .pf_modal_meta_grid {
        gap: 20px;
    }
    .view_tags_modal.pf_tags {
        flex-wrap: wrap;
    }
    .pf_modal_body_full {
        padding: 30px 0;
    }
    .pf_modal_body_full .insight_content_modal p {
        padding: 0 20px;
    }
    .modal_hero_banner {
        padding: 80px 20px 40px;
    }
    .modal_content_area {
        padding: 30px 20px 60px;
    }
}

@media all and (max-width: 768px) {
    /* 풀스크린 모달 — 작은 화면에서 가독성/터치 영역 확보 */
    .insight_modal_overlay {
        padding: 0;
    }

    .insight_modal_content {
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        border: none;
    }

    /* hero(.pf_modal_info)와 본문 사이의 빈 영역 제거 + 본문 p 이중 padding 제거 */
    .pf_modal_body_full {
        padding: 0 !important;
    }
    .pf_modal_body_full .insight_content_modal p {
        padding: 0 !important;
    }
    /* hero 패딩도 모바일에선 컴팩트 */
    .pf_modal_info {
        padding: 24px 20px 28px !important;
    }

    /* 닫기 버튼 — 터치 영역 확보(44x44 권장) + 시인성 */
    .insight_modal_close {
        top: 14px;
        right: 14px;
        width: 40px;
        height: 40px;
        font-size: 16px;
        background: rgba(0, 0, 0, 0.55);
        border-color: rgba(255, 255, 255, 0.35);
    }

    /* Hero 영역 — 좁은 화면에서 위 여백 컴팩트하게 */
    .modal_hero_banner {
        padding: 60px 20px 32px;
    }

    .view_title_modal {
        font-size: 22px;
        line-height: 1.35;
        letter-spacing: -0.5px;
        margin-bottom: 14px;
        word-break: keep-all;
    }

    .modal_hero_content .view_cat_modal {
        padding: 4px 10px;
        font-size: 11px;
        margin-bottom: 12px;
    }

    .view_date_modal {
        font-size: 12px;
    }

    /* 본문 영역 — 좌우 패딩 20px 유지(시각적 안정), 위/아래는 컴팩트 */
    .modal_content_area {
        padding: 28px 20px 56px;
    }

    /* 모바일에서는 작성자 가운데 정렬만 강제 좌측화. 폰트 크기는 작성자 의도 존중. */
    .insight_content_modal,
    .insight_content_modal * {
        text-align: left !important;
        word-break: keep-all !important;
    }

    /* 본문 기본값 — 작성자가 별도 fontsize 안 줬을 때만 적용 (no !important) */
    .insight_content_modal {
        font-size: 16px;
        line-height: 1.75;
        letter-spacing: -0.3px;
    }

    .insight_content_modal p,
    .insight_content_modal li,
    .insight_content_modal span,
    .insight_content_modal div,
    .insight_content_modal blockquote {
        line-height: 1.75 !important;
        letter-spacing: -0.3px !important;
    }

    /* 본문 이미지 — 모서리 작게, margin/그림자 컴팩트 */
    .insight_content_modal img {
        margin: 20px auto !important;
        border-radius: 8px !important;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35) !important;
    }

    /* 헤딩 — 모바일 사이즈 강제 (작성자 inline font-size 덮어쓰기)
       좌측 보더는 모바일에서 제거 (좁은 화면에서 시각적 부담) */
    .insight_content_modal h1 {
        font-size: 22px !important;
        line-height: 1.4 !important;
        margin-top: 32px !important;
        border-left: none !important;
        padding-left: 0 !important;
    }
    .insight_content_modal h2 {
        font-size: 20px !important;
        line-height: 1.4 !important;
        margin-top: 32px !important;
        border-left: none !important;
        padding-left: 0 !important;
    }
    .insight_content_modal h3 {
        font-size: 18px !important;
        line-height: 1.4 !important;
        margin-top: 24px !important;
    }
    .insight_content_modal h4 {
        font-size: 16px !important;
        margin-top: 20px !important;
    }

    /* 태그 — 터치 친화 크기 */
    .view_tags_modal {
        margin-top: 28px;
        padding-top: 16px;
        gap: 6px;
    }

    .view_tags_modal li {
        padding: 6px 12px;
        font-size: 12px;
    }

    .view_meta_modal {
        grid-template-columns: 1fr;
        gap: 6px;
        margin-bottom: 24px;
        padding-bottom: 16px;
    }

    .view_meta_modal span {
        font-size: 13px;
    }
}

/* 매우 작은 화면 — 380px 이하 */
@media all and (max-width: 380px) {
    .modal_hero_banner {
        padding: 56px 16px 28px;
    }
    .view_title_modal {
        font-size: 20px;
    }
    .modal_content_area {
        padding: 24px 16px 48px;
    }
    /* 본문 default만 줄임 (작성자 inline fontsize는 그대로 존중) */
    .insight_content_modal {
        font-size: 15px;
    }
    .insight_content_modal h1 { font-size: 20px !important; }
    .insight_content_modal h2 { font-size: 18px !important; }
    .insight_content_modal h3 { font-size: 17px !important; }
}
