/* ─── 기본 리셋 & 공통 ──────────────────────────────────── */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #1a1a1a;
    color: #e0e0e0;
    font-family: 'Pretendard', 'Pretendard Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ─── 노이즈 오버레이 (포트폴리오와 동일) ──────────────── */
.noise {
    content: '';
    position: fixed;
    z-index: 9999;
    height: 180%;
    left: -40%;
    top: -40%;
    width: 180%;
    pointer-events: none;
    opacity: 0.4;
    animation: noiseAnimation 1s steps(4) infinite;
    background-image: url('../img/noise/noise2.webp');
}

@keyframes noiseAnimation {
    0%   { transform: translate(0, 0); }
    10%  { transform: translate(-5%, -5%); }
    20%  { transform: translate(-10%, 5%); }
    30%  { transform: translate(5%, -10%); }
    40%  { transform: translate(-5%, 15%); }
    50%  { transform: translate(-10%, 5%); }
    60%  { transform: translate(15%, 0); }
    70%  { transform: translate(0, 10%); }
    80%  { transform: translate(-15%, 0); }
    90%  { transform: translate(10%, 5%); }
    100% { transform: translate(5%, 0); }
}

/* ─── 헤더 ───────────────────────────────────────────── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: #2c2b29;
    border-bottom: 1px solid #444;
    padding: 16px 20px;
    transition: background-color 0.3s, box-shadow 0.3s, padding 0.3s;
}

.header.scrolled {
    background-color: #1a1a1a;
    border-bottom-color: transparent;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
    padding: 12px 20px;
}

.header-row {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.header-info {
    overflow: hidden;
    max-width: 400px;
    transition: max-width 0.3s, opacity 0.3s, margin 0.3s;
    opacity: 1;
    flex-shrink: 1;
}

.header.scrolled .header-info {
    display: none;
}

.header-search {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    background: #2c2b29;
    border: 1px solid #444;
    border-radius: 50px;
    padding: 4px 4px 4px 0;
    transition: background 0.3s, border-color 0.3s;
}

.header.scrolled .header-search {
    background: #2c2b29;
    border-color: #555;
}

.back-link {
    font-size: 14px;
    color: #a8a8a8;
    font-family: 'S-CoreDream-3Light', serif;
    transition: color 0.3s;
}

.back-link:hover {
    color: #fff;
}

.blog-title {
    font-family: 'PartialSansKR-Regular', serif;
    font-size: 28px;
    color: #f5f5f5;
    margin-top: 8px;
    font-weight: normal;
}

.blog-desc {
    font-size: 14px;
    color: #a8a8a8;
    margin-top: 4px;
    font-family: 'S-CoreDream-3Light', serif;
}

.search-input {
    flex: 1;
    min-width: 0;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: #e0e0e0;
    font-size: 15px;
    font-family: 'S-CoreDream-3Light', serif;
    outline: none;
}

.search-btn {
    background: #f5f5f5;
    border: none;
    border-radius: 50px;
    color: #1a1a1a;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'S-CoreDream-3Light', serif;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s;
    flex-shrink: 0;
}

.search-btn:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.15);
}

.search-btn:active {
    transform: scale(0.97);
}

.sort-wrap {
    display: flex;
    justify-content: flex-end;
}

.sort-select {
    background: #2c2b29;
    border: 1px solid #444;
    border-radius: 6px;
    color: #aaa;
    padding: 6px 12px;
    font-size: 13px;
    font-family: 'S-CoreDream-3Light', serif;
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s;
}

.sort-select:focus {
    border-color: #888;
}

.sort-select option {
    background: #2c2b29;
    color: #e0e0e0;
}

.search-input::placeholder {
    color: #666;
}

.search-input:focus {
    border-color: #888;
}

/* ─── 필터 (시리즈 + 태그) ───────────────────────────── */
.filter-wrap {
    max-width: 800px;
    margin: 20px auto 0;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-section {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.filter-label {
    font-size: 13px;
    color: #8f8f8f;
    font-family: 'S-CoreDream-3Light', serif;
    white-space: nowrap;
    padding-top: 7px;
    min-width: 40px;
}

.filter-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn {
    background: #2c2b29;
    border: 1px solid #444;
    color: #aaa;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-family: 'S-CoreDream-3Light', serif;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-btn:hover,
.filter-btn.active {
    background: #f5f5f5;
    color: #1a1a1a;
    border-color: #f5f5f5;
}

/* ─── 글 카드 시리즈 라벨 ────────────────────────────── */
.post-card-series {
    font-size: 12px;
    color: #5eaeff;
    background: rgba(2, 117, 216, 0.1);
    padding: 2px 10px;
    border-radius: 10px;
    display: inline-block;
    margin-bottom: 6px;
}

/* ─── 글 목록 ────────────────────────────────────────── */
.posts-container {
    max-width: 800px;
    margin: 32px auto;
    padding: 0 20px;
    flex: 1;
}

.post-card {
    background: #2c2b29;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
    transition: transform 0.3s, border-color 0.3s;
    cursor: pointer;
    display: flex;
    gap: 20px;
}

.post-card:hover {
    transform: translateY(-3px);
    border-color: #666;
}

.post-card-thumb {
    width: 160px;
    height: 110px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    filter: grayscale(50%);
    transition: filter 0.3s;
}

.post-card:hover .post-card-thumb {
    filter: grayscale(0%);
}

.post-card-content {
    flex: 1;
    min-width: 0;
}

.post-card-title {
    font-size: 20px;
    font-weight: 600;
    color: #f5f5f5;
    margin-bottom: 8px;
    line-height: 1.4;
}

.post-card-desc {
    font-size: 14px;
    color: #999;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: 'S-CoreDream-3Light', serif;
}

.post-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.post-card-date {
    display: none;
}

.post-card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.post-card-tag {
    font-size: 12px;
    color: #5eaeff;
    background: rgba(2, 117, 216, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ─── 글 상세 ────────────────────────────────────────── */
.post-container {
    max-width: 800px;
    width: 100%;
    margin: 32px auto;
    padding: 0 20px;
    flex: 1;
}

.post-header {
    margin-bottom: 32px;
}

.post-title {
    font-size: 36px;
    font-weight: 700;
    color: #f5f5f5;
    line-height: 1.3;
    margin-bottom: 16px;
}

.post-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 12px;
}

.post-date {
    display: none;
}

.post-series {
    font-size: 13px;
    color: #5eaeff;
    background: rgba(2, 117, 216, 0.1);
    padding: 3px 10px;
    border-radius: 12px;
}

.post-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.post-tag {
    font-size: 13px;
    color: #5eaeff;
    cursor: pointer;
}

.post-tag::before {
    content: '#';
}

.post-thumbnail-wrap {
    margin-bottom: 32px;
}

.post-thumbnail {
    width: auto;
    max-width: 100%;      /* 원본(예: 485px)보다 크게 늘리지 않음 — 확대되면 흐려지고 Lighthouse 도 지적 */
    height: auto;
    border-radius: 8px;
    filter: grayscale(30%);
}

/* ─── 마크다운 본문 ──────────────────────────────────── */
.post-body.markdown-body {
    background: transparent;
    color: #d4d4d4;
    font-size: 16px;
    line-height: 1.8;
    font-family: 'Pretendard', 'Pretendard Fallback', sans-serif;
}

.post-body.markdown-body h1,
.post-body.markdown-body h2,
.post-body.markdown-body h3 {
    color: #f5f5f5;
    border-bottom-color: #444;
}

.post-body.markdown-body b,
.post-body.markdown-body strong {
    font-family: 'Pretendard', 'Pretendard Fallback', sans-serif;
    font-weight: 700;
    color: #f0f0f0;
}

.post-body.markdown-body a {
    color: #5eaeff;
    text-decoration: underline;
    text-underline-offset: 2px;
}
/* github-dark 테마의 .hljs-section(#ffa657)은 어두운 배경에서 대비 부족 → 밝게 */
.post-body.markdown-body .hljs-section { color: #ffc37a; }

.post-body.markdown-body code {
    background: #2c2b29;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

.post-body.markdown-body pre {
    background: #2c2b29;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
}

.post-body.markdown-body pre code {
    background: transparent;
    padding: 0;
}

.post-body.markdown-body blockquote {
    border-left: 4px solid #0275d8;
    color: #aaa;
    background: rgba(44, 43, 41, 0.5);
    padding: 12px 16px;
}

.post-body.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    display: block;
}

.post-body.markdown-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.post-body.markdown-body p,
.post-body.markdown-body li,
.post-body.markdown-body h1,
.post-body.markdown-body h2,
.post-body.markdown-body h3,
.post-body.markdown-body h4 {
    word-break: break-word;
    overflow-wrap: break-word;
}

.post-body.markdown-body table {
    border-collapse: collapse;
}

.post-body.markdown-body th,
.post-body.markdown-body td {
    border: 1px solid #444;
    padding: 8px 12px;
}

.post-body.markdown-body th {
    background: #2c2b29;
}

/* ─── 로딩 ───────────────────────────────────────────── */
.loading {
    text-align: center;
    color: #666;
    padding: 60px 0;
    font-family: 'S-CoreDream-3Light', serif;
    font-size: 18px;
}
/* 빌드 시 정적 카드가 들어 있으면 그것이 곧 로딩 상태 → 문구가 자리를 차지해 카드가 밀리지 않게 */
.loading:has(+ .post-card-link) { display: none; }


.empty-message {
    text-align: center;
    color: #666;
    padding: 60px 0;
    font-family: 'S-CoreDream-3Light', serif;
}

/* ─── 페이지네이션 ───────────────────────────────────── */
.pagination {
    max-width: 800px;
    margin: 0 auto 32px;
    padding: 0 20px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.page-btn {
    background: #2c2b29;
    border: 1px solid #444;
    color: #aaa;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'S-CoreDream-3Light', serif;
    cursor: pointer;
    transition: all 0.3s;
}

.page-btn:hover:not(.disabled) {
    background: #f5f5f5;
    color: #1a1a1a;
    border-color: #f5f5f5;
}

.page-btn.active {
    background: #f5f5f5;
    color: #1a1a1a;
    border-color: #f5f5f5;
}

.page-btn.disabled {
    opacity: 0.3;
    cursor: default;
}

/* ─── 푸터 ───────────────────────────────────────────── */
.blog-footer {
    background-color: #2c2b29;
    text-align: center;
    padding: 16px;
    margin-top: auto;
}

.blog-footer div {
    color: #fefefe;
    font-size: 14px;
    font-family: 'S-CoreDream-3Light', serif;
}

/* ─── 반응형 ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .header-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .header-info {
        max-width: none;
    }

    .header.scrolled .header-info {
        max-width: 0;
        max-height: 0;
        opacity: 0;
        margin: 0;
    }

    .filter-wrap,
    .posts-container,
    .post-container,
    .pagination {
        padding: 0 16px;
    }

    .post-title {
        font-size: 28px;
    }

    .post-meta {
        flex-wrap: wrap;
        gap: 8px;
    }
}

@media (max-width: 600px) {
    .blog-title {
        font-size: 22px;
    }

    .post-card {
        flex-direction: column;
        padding: 16px;
    }

    .post-card-thumb {
        width: 100%;
        height: 180px;
    }

    .post-title {
        font-size: 24px;
    }

    .post-card-title {
        font-size: 17px;
    }

    .post-card-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .filter-section {
        flex-direction: column;
        gap: 8px;
    }

    .filter-label {
        padding-top: 0;
    }

    .search-input {
        font-size: 14px;
        padding: 10px 14px;
    }

    .search-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .page-btn {
        padding: 6px 10px;
        font-size: 13px;
    }

    .post-body.markdown-body {
        font-size: 15px;
    }

    .post-body.markdown-body pre {
        overflow-x: auto;
        font-size: 13px;
    }
}

/* 화면에는 숨기고 검색엔진·스크린리더에만 노출 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 정적 카드(빌드 시 삽입) — blog.js 가 로드되면 교체됨 */
.post-card-link { display: flex; color: inherit; text-decoration: none; }   /* 정적 카드도 JS 카드(.post-card flex)와 같은 배치 → 교체 시 높이 변화 없음 */
.author-box {
    margin-top: 48px;
    padding: 20px 24px;
    border: 1px solid #3a3937;
    border-radius: 10px;
    display: flex;
    gap: 16px;
    align-items: center;
    background: #242322;
}
.author-box img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.author-box strong { display: block; font-size: 15px; color: #f5f5f5; }
.author-box p { margin: 4px 0 0; font-size: 13px; color: #a8a8a8; line-height: 1.5; }
.author-box a { color: #4da3ff; text-decoration: underline; text-underline-offset: 2px; }
.post-author { color: #a8a8a8; text-decoration: none; }
.post-author:hover { color: #f5f5f5; }
