/* --- 기본 및 색상 변수 설정 --- */
:root {
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --accent-color: #555555;
    --tone-down-accent-color: #777777;
    --border-color: #e0e0e0;
    --code-bg-color: #f5f5f5;
    /* --- [수정] 툴바 색상 및 그림자 --- */
    --toolbar-bg-color: rgba(255, 255, 255, 0.7);
    --toolbar-border-color: rgba(230, 230, 230, 0.8);
    --toolbar-shadow: rgba(0, 0, 0, 0.08);
    --header-font: 'Noto Serif KR', serif;
    --body-font: 'Noto Sans KR', sans-serif;
    --category-font: 'Italianno', cursive;
    font-size: 16px;
}

:-webkit-any(article, aside, nav, section) h1 {
    margin: 0;
}

/* article h1 {
    margin: 0;
} */

/* --- 다크 모드 색상 변수 --- */
html.dark-mode {
    --bg-color: #111111;
    --text-color: #f0f0f0;
    --accent-color: #aaaaaa;
    --tone-down-accent-color: #888888;
    --border-color: #333333;
    --code-bg-color: #2c2c2c;
    /* --- [수정] 다크모드 툴바 색상 및 그림자 --- */
    --toolbar-bg-color: rgba(40, 40, 40, 0.7);
    --toolbar-border-color: rgba(60, 60, 60, 0.8);
    --toolbar-shadow: rgba(0, 0, 0, 0.25);
}

/* --- 기본 스타일 리셋 및 본문 설정 --- */
body {
    font-family: var(--body-font);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.8;
    letter-spacing: 0.2px;
    margin: 0;
    padding: 20px 20px;
    transition: background-color 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

header h1 {
    margin: 0;
    text-align: center;
}

.category {
    text-align: center;
    margin-top: 30px;
    padding: 0;
    font-family: var(--category-font);
    font-weight: 400;
    font-size: 2.0rem;
    color: var(--accent-color);
    line-height: -0.3;
}

/* --- [수정] 툴바 스타일 --- */
.toolbar-wrapper {
    position: sticky;
    top: 20px;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 1000;
    pointer-events: none;
    /* 래퍼의 빈 공간이 클릭을 방해하지 않도록 설정 */
}

.toolbar.hidden {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s 0.3s;
}

.toolbar {
    width: fit-content;
    display: flex;
    align-items: center;
    padding: 6px;
    background-color: var(--toolbar-bg-color);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid var(--toolbar-border-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--toolbar-shadow);
    pointer-events: auto;
    /* 툴바 자체는 클릭이 가능하도록 설정 */
    transition: opacity 0.4s ease, visibility 0s;
    opacity: 1;
    visibility: visible;
}

.toolbar-group {
    display: flex;
    align-items: center;
}

.toolbar-group:not(:last-child) {
    border-right: 1px solid var(--border-color);
    margin-right: 5px;
    padding-right: 5px;
}

.toolbar button,
.toolbar a.toolbar-button {
    background: none;
    border: none;
    color: var(--accent-color);
    width: 38px;
    /* 버튼 크기 축소 */
    height: 38px;
    /* 버튼 크기 축소 */
    border-radius: 8px;
    /* 버튼 둥글기 조정 */
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    /* '가-', '가+' 폰트 크기 */
    font-weight: 500;
    transition: background-color 0.2s;
}

.toolbar-group:not(:last-of-type) {
    border-right: 1px solid var(--border-color);
    margin-right: 5px;
    padding-right: 5px;
}

.toolbar button:hover,
.toolbar a.toolbar-button:hover {
    background-color: var(--border-color);
}

.toolbar .icon-svg {
    width: 20px;
    /* 아이콘 크기 축소 */
    height: 20px;
    stroke: var(--accent-color);
}

/* --- 콘텐츠 컨테이너 --- */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding-top: 0px;
}

/* --- 헤더 및 제목 스타일 --- */
h1,
h2,
h3 {
    font-family: var(--header-font);
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: -0.5px;
    margin-bottom: 0.5em;
    word-break: keep-all;
}

h1 {
    font-size: 2.5rem;
    /* border-bottom: 2px solid var(--text-color); */
    padding-bottom: 0.3em;
    margin-bottom: 0.5em;
}

.meta-info::after {
    content: '...';
    display: block;
    text-align: center;
    color: var(--accent-color);
    font-family: var(--body-font);
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: 0.3em;
    /* 점 사이의 간격 */
    margin-top: 1.5em;
    /* 제목과 점 구분선 사이의 간격 */
    margin-bottom: 1.8em;
}

h2 {
    font-size: 1.8rem;
    margin-top: 2.5em;
    border-left: 4px solid var(--accent-color);
    padding-left: 0.5em;
}

h3 {
    font-size: 1.5rem;
}

/* --- [수정] 포스트 상단 여백 조정 --- */
.meta-info {
    font-family: var(--body-font);
    font-size: 0.85rem;
    color: var(--accent-color);
    margin: 0.2em 0 2em 0;
    /* 3em에서 2em으로 여백 축소 */
    text-align: center;
}

/* --- [추가] 포스트 내부 이미지 스타일 --- */
article img {
    max-width: 100%;
    /* 이미지가 부모 요소의 너비를 넘지 않도록 함 */
    height: auto;
    /* 이미지의 가로세로 비율을 유지 */
    display: block;
    /* 이미지를 블록 요소로 만들어 margin 적용 */
    margin: 0 auto;
    /* 이미지를 가운데 정렬 */
    border-radius: 4px;
    /* 이미지 모서리를 둥글게 처리 */
    clip-path: polygon(35px 0, 100% 0, 100% calc(100% - 35px), calc(100% - 35px) 100%, 0 100%, 0 35px);
    filter: grayscale() contrast(0.85);
    transition: filter 0.4s ease;
}

article img:hover {
    filter: grayscale(0) contrast(1);
    transition: filter 0.4s ease;
}

/* --- [추가] 본문 링크 스타일 --- */
article a {
    color: var(--accent-color);
    text-decoration: none;
    /* 텍스트 아래에 1px짜리 은은한 밑줄을 만듭니다. */
    border-bottom: 1px solid var(--border-color);
    transition: color 0.2s, border-bottom-color 0.2s;
}

article a:hover {
    /* 마우스를 올리면 본문 텍스트 색상과 동일하게 변경됩니다. */
    color: var(--text-color);
    border-bottom-color: var(--text-color);
}

/* 방문했던 링크의 색상이 보라색으로 변하는 것을 방지하고,
  디자인 일관성을 위해 기본 링크 색상과 동일하게 유지합니다.
*/
article a:visited {
    color: var(--accent-color);
    border-bottom-color: var(--border-color);
}

/* figure 태그의 기본 배경색 제거 (이미지에만 적용되도록) */
figure svg,
figure img {
    background-color: transparent;
}

/* --- 이하 스타일은 이전과 동일 --- */
p {
    font-size: 1.1rem;
    font-weight: 400;
    margin: 0 0 1.5em 0;
    text-align: justify;
    widows: 2;
    orphans: 2;
    word-break: keep-all;
}

strong {
    font-weight: 600;
}

u {
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

blockquote {
    font-family: var(--header-font);
    font-style: italic;
    font-size: 1.05rem;
    border-left: 3px solid var(--accent-color);
    padding-left: 1em;
    margin: 1em 0;
    color: var(--accent-color);
}

blockquote p {
    font-size: inherit;
    margin-bottom: 0.5em;
}

blockquote footer {
    font-family: var(--body-font);
    font-style: normal;
    font-size: 0.9rem;
    text-align: right;
}

figure,
pre,
table {
    margin: 2.5em 0;
    width: 100%;
}

figure svg,
figure img {
    width: 100%;
    height: auto;
    display: block;
    background-color: var(--code-bg-color);
    border-radius: 6px;
}

figcaption {
    text-align: center;
    font-size: 0.9rem;
    font-style: italic;
    color: var(--accent-color);
    margin-top: 0.5em;
}

pre {
    background-color: var(--code-bg-color);
    padding: 1.5em;
    overflow-x: auto;
    border-radius: 4px;
    width: calc(100% - 3em);
}

code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.95rem;
    line-height: 1.6;
}

table {
    border-collapse: collapse;
    font-size: 1rem;
}

th,
td {
    border-bottom: 1px solid var(--border-color);
    padding: 1em 0.5em;
    text-align: left;
}

thead th {
    border-bottom-width: 2px;
    border-bottom-color: var(--text-color);
    font-weight: 500;
}

tbody tr:last-child td {
    border-bottom: none;
}

.comment::before {
    content: '.';
    display: block;
    text-align: center;
    color: var(--accent-color);
    font-family: var(--body-font);
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: 0.3em;
    /* 점 사이의 간격 */
    margin: 1.5em 0 2.0em 0;
}

.comment {
    margin-top: 0em;
}

.comment h3 {
    font-family: var(--header-font);
    font-size: 1.4rem;
    margin-top: 0;
    margin-bottom: 1.5em;
    text-align: center;
    color: var(--accent-color);
    font-weight: 600;
}

.recent-posts::before {
    content: '.';
    display: block;
    text-align: center;
    color: var(--accent-color);
    font-family: var(--body-font);
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: 0.3em;
    /* 점 사이의 간격 */
    margin: 1.5em 0 2.0em 0;
}

.recent-posts {
    margin-top: 0em;
}

.recent-posts h3 {
    font-family: var(--header-font);
    font-size: 1.4rem;
    margin-top: 0;
    margin-bottom: 1.5em;
    text-align: center;
    color: var(--accent-color);
    font-weight: 600;
}

.recent-posts-list {
    list-style: none;
    padding-left: 0;
    display: grid;
    gap: 1.5em;
    /* 카드 사이의 간격 */
}

.recent-posts-list li {
    text-align: center;
    background-color: var(--code-bg-color);
    border-radius: 8px;
    padding: 1.5em 1.2em;
    transition: transform 0.2s ease-in-out;
}

.recent-posts-list li:hover {
    transform: translateY(-5px);
    /* 마우스를 올리면 살짝 위로 이동 */
}

.recent-posts-list a {
    text-decoration: none;
    color: var(--text-color);
    font-family: var(--header-font);
    font-weight: 600;
    font-size: 1.1rem;
    line-height: 1.4;
    display: block;
    transition: color 0.2s;
}

.recent-posts-list a:hover {
    color: var(--accent-color);
}

.footer::before, .footer-ad::before {
    content: '.';
    display: block;
    text-align: center;
    color: var(--accent-color);
    font-family: var(--body-font);
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: 0.3em;
    /* 점 사이의 간격 */
    margin: 1.5em 0 2.0em 0;
}

.footer, .footer-ad {
    color: var(--accent-color);
    font-family: var(--body-font);
    font-size: 0.8rem;
    text-align: center;
}

.footer-ad h3 {
    margin: 1.5em 0;
}

/* --- [수정] 메인 페이지 포스트 목록 스타일 --- */
.post-list-item {
    display: flex;
    /* align-items: center;를 stretch로 변경하여 아이템들의 높이를 맞춤 */
    align-items: stretch;
    gap: 1.5em;
    padding: 1.5em;
    border-radius: 8px;
    transition: background-color 0.2s;
    text-decoration: none;
    clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
}

.post-list-item:hover {
    background-color: var(--code-bg-color);

    .post-thumbnail img {
        filter: grayscale(0) contrast(1);
        transition: filter 0.4s ease;
    }
}

.post-thumbnail {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    position: relative; /* ::before, ::after 가상요소의 위치 기준점 */
    display: inline-block; /* 내부 이미지 크기에 맞게 컨테이너 크기 조절 */
    line-height: 0; /* 이미지 하단의 불필요한 공백 제거 */
}


/* 2. 라인을 그릴 가상 요소 스타일 (공통) */
.post-thumbnail::before {
    content: '';
    position: absolute;
    background-color: var(--tone-down-accent-color);
    width: 40px;
    height: 1px;
    transform: rotate(-45deg);
    z-index: 999;
    top: 10px;
    left: -10px;
}

.post-thumbnail::after {
    content: '';
    position: absolute;
    background-color: var(--tone-down-accent-color);
    width: 40px;
    height: 1px;
    transform: rotate(-45deg);
    z-index: 999;
    bottom: 10px;
    right: -10px;
}


.post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    filter: grayscale() contrast(0.7);
    transition: filter 0.4s ease;
    /* 우측 하단을 사선으로 자르는 clip-path 속성 추가 */
    clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
}

.post-content h2 {
    margin: 0 0 0.2em 0;
    font-family: var(--header-font);
    font-size: 1.2rem;
    padding: 0;
    border: none;
    color: var(--text-color);
    line-height: 1.4;

    display: -webkit-box;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
    text-overflow: ellipsis;

    /* 고정된 최소 높이(min-height)를 제거하여 자연스러운 높이를 갖도록 함 */
}

.post-content .post-meta-category {
    font-family: var(--category-font);
    font-size: 1.6rem;
    color: var(--accent-color);
}

.post-content .post-meta {
    font-size: 0.9rem;
    color: var(--accent-color);
}

@media (max-width: 768px) {
    body {
        padding: 10px 15px;
    }

    .container {
        padding-top: 0px;
    }

    h1 {
        font-size: 2.2rem;
    }

    h2 {
        font-size: 1.6rem;
    }

    h3 {
        font-size: 1.3rem;
    }

    p {
        font-size: 1rem;
    }

    .post-list-item {
        display: flex;
        /* align-items: center;를 stretch로 변경하여 아이템들의 높이를 맞춤 */
        align-items: stretch;
        gap: 1em;
        padding: 1em 1em;
        border-radius: 8px;
        transition: background-color 0.2s;
        text-decoration: none;
        clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
    }
}

.image-container {
    margin: 2em 0;
}

.post-image-wrapper {
    cursor: zoom-in;
    /* 이미지에 마우스를 올리면 확대 커서 표시 */
    position: relative;
    /* ::before, ::after 가상요소의 위치 기준점 */
    display: inline-block;
    /* 내부 이미지 크기에 맞게 컨테이너 크기 조절 */
    margin: 0 auto;
    /* 블로그 본문에서 가운데 정렬을 위함 */
    line-height: 0;
    /* 이미지 하단의 불필요한 공백 제거 */
}

/* 2. 라인을 그릴 가상 요소 스타일 (공통) */
.post-image-wrapper::before {
    content: '';
    position: absolute;
    background-color: var(--tone-down-accent-color);
    width: 64px;
    height: 1px;
    transform: rotate(-45deg);
    z-index: 999;
    top: 17px;
    left: -15px;
}

.post-image-wrapper::after {
    content: '';
    position: absolute;
    background-color: var(--tone-down-accent-color);
    width: 64px;
    height: 1px;
    transform: rotate(-45deg);
    z-index: 999;
    bottom: 17px;
    right: -15px;
}

.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    /* 평소에는 숨김 */
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-overlay.visible {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-caption {
    color: #fff;
    margin-top: 1em;
    font-size: 1rem;
    text-align: center;
    max-width: 70ch;
    line-height: 1.5;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: none;
    border: none;
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 1rem;
    -webkit-tap-highlight-color: transparent;
    /* 모바일 터치 시 하이라이트 제거 */
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    opacity: 1;
}

.lightbox-close {
    top: 10px;
    right: 15px;
}

.lightbox-prev {
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
}

.lightbox-next {
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
}