/* ===== codingrich.com 커스텀 스타일 ===== */

/* 반응형 이미지 */
img,
.wp-block-image img,
.wp-block-image figure img,
figure.wp-block-image img {
    max-width: 100% !important;
    height: auto !important;
}

.wp-block-image {
    max-width: 100% !important;
    overflow: hidden;
}

.entry-content img,
.post-content img,
article img {
    max-width: 100% !important;
    height: auto !important;
    display: block;
}

/* figcaption */
figcaption {
    font-size: 0.85em;
    color: #888;
    text-align: center;
    margin-top: 0.5em;
    font-style: italic;
}

/* ===== 글 목록 카드 스타일 ===== */

/* 글 목록에서 각 글을 카드로 분리 */
.blog .wp-block-post,
.archive .wp-block-post,
.home .wp-block-post,
.search .wp-block-post {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.blog .wp-block-post:hover,
.archive .wp-block-post:hover,
.home .wp-block-post:hover,
.search .wp-block-post:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* 다크모드 대응 */
@media (prefers-color-scheme: dark) {
    .blog .wp-block-post,
    .archive .wp-block-post,
    .home .wp-block-post,
    .search .wp-block-post {
        background: #1e293b;
        border-color: #334155;
    }
}

/* 글 제목 스타일 */
.wp-block-post-title {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
    line-height: 1.4 !important;
    margin-bottom: 0.75rem !important;
}

.wp-block-post-title a {
    text-decoration: none !important;
    color: #1a202c !important;
    transition: color 0.2s ease;
}

.wp-block-post-title a:hover {
    color: #4f46e5 !important;
}

@media (prefers-color-scheme: dark) {
    .wp-block-post-title a {
        color: #e2e8f0 !important;
    }
    .wp-block-post-title a:hover {
        color: #818cf8 !important;
    }
}

/* 글 날짜 */
.wp-block-post-date {
    font-size: 0.85rem !important;
    color: #94a3b8 !important;
    margin-bottom: 0.5rem !important;
}

/* 발췌 (excerpt) */
.wp-block-post-excerpt {
    color: #64748b !important;
    line-height: 1.7 !important;
    font-size: 0.95rem !important;
}

@media (prefers-color-scheme: dark) {
    .wp-block-post-excerpt {
        color: #94a3b8 !important;
    }
}

/* 카테고리 배지 */
.wp-block-post-terms a {
    display: inline-block;
    background: #eef2ff;
    color: #4f46e5;
    padding: 0.2em 0.7em;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    margin-right: 0.4em;
    margin-bottom: 0.4em;
    transition: background 0.2s ease;
}

.wp-block-post-terms a:hover {
    background: #c7d2fe;
}

@media (prefers-color-scheme: dark) {
    .wp-block-post-terms a {
        background: #312e81;
        color: #a5b4fc;
    }
}

/* ===== 개별 글 본문 스타일 ===== */

/* 본문 가독성 */
.entry-content,
.wp-block-post-content {
    font-size: 1.05rem;
    line-height: 1.85;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.entry-content p,
.wp-block-post-content p {
    margin-bottom: 1.2em;
}

.entry-content h2,
.wp-block-post-content h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.entry-content h3,
.wp-block-post-content h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.8rem;
}

/* 코드 블록 */
.entry-content code,
.wp-block-post-content code {
    background: #f1f5f9;
    color: #e11d48;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: "JetBrains Mono", "Fira Code", monospace;
}

.entry-content pre,
.wp-block-post-content pre {
    background: #1e293b !important;
    color: #e2e8f0 !important;
    padding: 1.2em !important;
    border-radius: 8px !important;
    overflow-x: auto !important;
    font-size: 0.9rem !important;
    line-height: 1.6 !important;
    margin: 1.5em 0 !important;
}

.entry-content pre code,
.wp-block-post-content pre code {
    background: transparent !important;
    color: inherit !important;
    padding: 0 !important;
}

/* 리스트 */
.entry-content ul,
.entry-content ol,
.wp-block-post-content ul,
.wp-block-post-content ol {
    padding-left: 1.5em;
    margin-bottom: 1.2em;
}

.entry-content li,
.wp-block-post-content li {
    margin-bottom: 0.5em;
    line-height: 1.7;
}

/* 링크 */
.entry-content a,
.wp-block-post-content a {
    color: #4f46e5;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

.entry-content a:hover,
.wp-block-post-content a:hover {
    color: #4338ca;
}

/* strong 강조 */
.entry-content strong,
.wp-block-post-content strong {
    font-weight: 700;
    color: #1e293b;
}

@media (prefers-color-scheme: dark) {
    .entry-content strong,
    .wp-block-post-content strong {
        color: #f1f5f9;
    }
    .entry-content code,
    .wp-block-post-content code {
        background: #334155;
        color: #fb7185;
    }
    .entry-content h2,
    .wp-block-post-content h2 {
        border-bottom-color: #334155;
    }
}

/* ===== 댓글 영역 ===== */
.comments-area,
.wp-block-comments {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid #e2e8f0;
}

/* ===== 모바일 최적화 ===== */
@media (max-width: 768px) {
    .blog .wp-block-post,
    .archive .wp-block-post,
    .home .wp-block-post,
    .search .wp-block-post {
        padding: 1.2rem;
        margin-bottom: 1.2rem;
        border-radius: 8px;
    }

    .wp-block-post-title {
        font-size: 1.25rem !important;
    }

    .entry-content,
    .wp-block-post-content {
        font-size: 1rem;
        line-height: 1.8;
    }

    .entry-content h2,
    .wp-block-post-content h2 {
        font-size: 1.35rem;
    }

    .entry-content h3,
    .wp-block-post-content h3 {
        font-size: 1.15rem;
    }

    .entry-content pre,
    .wp-block-post-content pre {
        font-size: 0.82rem !important;
        padding: 0.8em !important;
    }
}

.entry-content img,
.wp-block-post-content img,
.wp-block-image img {
    margin-left: auto !important;
    margin-right: auto !important;
    display: block !important;
}

/* 이미지 중앙 정렬 — 강제 */
figure,
figure.wp-block-image,
.wp-block-image,
div.wp-block-image,
.entry-content figure,
.entry-content .wp-block-image,
.wp-block-post-content figure,
.wp-block-post-content .wp-block-image,
article figure,
article .wp-block-image {
    text-align: center !important;
    margin-left: auto !important;
    margin-right: auto !important;
    display: block !important;
    width: 100% !important;
}

figure img,
figure.wp-block-image img,
.wp-block-image img,
.entry-content figure img,
.entry-content img,
.wp-block-post-content img,
article img {
    margin-left: auto !important;
    margin-right: auto !important;
    display: block !important;
    max-width: 100% !important;
    height: auto !important;
}

/* 코드 블록 중앙 배치 + 가독성 */
.entry-content pre,
.wp-block-post-content pre,
article pre {
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: left !important;
    white-space: pre !important;
    word-wrap: normal !important;
    overflow-x: auto !important;
    box-sizing: border-box !important;
}

/* 코드 블록 본문 너비에 맞추기 */
.entry-content pre,
.wp-block-post-content pre,
article pre,
.wp-block-code,
.wp-block-post-content .wp-block-code {
    max-width: 645px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* ===== 카드 목록 레이아웃 조정 ===== */

/* 카드 내 columns 간격 축소 */
.wp-block-post .wp-block-columns {
    gap: 1.2rem !important;
    align-items: flex-start !important;
}

/* 썸네일 크기 고정 */
.wp-block-post .wp-block-column:first-child {
    flex-basis: 160px !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

.wp-block-post .wp-block-column:first-child img {
    width: 160px !important;
    height: 160px !important;
    object-fit: cover !important;
    border-radius: 8px !important;
}

/* 텍스트 컬럼 */
.wp-block-post .wp-block-column:last-child {
    flex: 1 !important;
    min-width: 0 !important;
}

/* 카드 패딩 축소 */
.wp-block-post .has-border-color {
    padding: 1rem !important;
}

/* 발췌 마진 축소 */
.wp-block-post .wp-block-post-excerpt {
    margin-top: 0 !important;
    margin-bottom: 0.3rem !important;
}

.wp-block-post .wp-block-post-excerpt__excerpt {
    margin: 0 !important;
}

/* 카테고리 마진 */
.wp-block-post .wp-block-post-terms {
    margin-bottom: 0 !important;
}

/* 모바일: 세로 배치 + 간격 축소 */
@media (max-width: 768px) {
    .wp-block-post .wp-block-columns {
        flex-direction: column !important;
        gap: 0.6rem !important;
    }

    .wp-block-post .wp-block-column:first-child {
        flex-basis: auto !important;
        width: 100% !important;
    }

    .wp-block-post .wp-block-column:first-child img {
        width: 100% !important;
        height: 180px !important;
        object-fit: cover !important;
    }

    .wp-block-post .has-border-color {
        padding: 0.8rem !important;
    }

    .wp-block-post .wp-block-post-title {
        font-size: 1.15rem !important;
    }
}

/* ===== 카드 너비 + 간격 미세 조정 ===== */

/* 데스크탑: 카드 너비를 본문 너비에 맞춤 */
.wp-block-query.alignwide {
    max-width: 780px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* 카드 마진 축소 */
.wp-block-post .has-border-color {
    margin-bottom: 1rem !important;
}

/* 모바일: 썸네일-제목 간격 최소화 */
@media (max-width: 768px) {
    .wp-block-post .wp-block-columns {
        gap: 0 !important;
    }

    .wp-block-post .wp-block-column:last-child {
        padding-top: 0.4rem !important;
    }

    .wp-block-post .wp-block-post-terms {
        margin-top: 0 !important;
        margin-bottom: 0.2rem !important;
    }

    .wp-block-post .wp-block-post-title {
        margin-top: 0 !important;
        margin-bottom: 0.3rem !important;
    }

    .wp-block-post .wp-block-post-excerpt {
        margin-bottom: 0.2rem !important;
    }

    .wp-block-post .wp-block-post-date {
        margin-top: 0.2rem !important;
    }
}

/* 모바일: 썸네일 div 높이를 이미지에 맞춤 */
@media (max-width: 768px) {
    .wp-block-post .wp-block-column:first-child {
        line-height: 0 !important;
        font-size: 0 !important;
    }

    .wp-block-post .wp-block-post-featured-image {
        margin: 0 !important;
        padding: 0 !important;
        line-height: 0 !important;
    }

    .wp-block-post .wp-block-post-featured-image a {
        display: block !important;
        line-height: 0 !important;
    }

    .wp-block-post .wp-block-column:first-child img {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* 썸네일 컬럼 높이 맞춤 */
.wp-block-post .wp-block-column:first-child {
    overflow: hidden !important;
}

.wp-block-post figure.wp-block-post-featured-image {
    aspect-ratio: unset !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
}

.wp-block-post figure.wp-block-post-featured-image img {
    aspect-ratio: 1 !important;
    width: 100% !important;
    height: auto !important;
    object-fit: cover !important;
}

/* ===== 네비게이션 메뉴 스타일 ===== */
.wp-block-navigation a {
    text-decoration: none !important;
    font-weight: 500 !important;
    font-size: 0.95rem !important;
}

.wp-block-navigation a:hover {
    color: #4f46e5 !important;
}

/* 카테고리 서브메뉴 */
.wp-block-navigation-submenu .wp-block-navigation__submenu-container {
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
    padding: 0.5rem 0 !important;
}

.wp-block-navigation-submenu .wp-block-navigation__submenu-container a {
    padding: 0.4rem 1rem !important;
    font-size: 0.9rem !important;
}

/* 전체 글 목록 페이지 스타일 */
.page-template-default .wp-block-query .wp-block-group {
    transition: background 0.15s ease;
}

.page-template-default .wp-block-query .wp-block-group:hover {
    background: #f8fafc;
}

@media (prefers-color-scheme: dark) {
    .page-template-default .wp-block-query .wp-block-group:hover {
        background: #1e293b;
    }
}

/* ===== 다크모드 전체 보강 ===== */
@media (prefers-color-scheme: dark) {
    /* 배경/텍스트 기본 */
    body,
    .wp-site-blocks {
        background-color: #0f172a !important;
        color: #e2e8f0 !important;
    }

    /* 카드 배경 */
    .wp-block-post .has-border-color,
    .wp-block-post .has-base-background-color,
    .wp-block-group.has-base-background-color {
        background-color: #1e293b !important;
        border-color: #334155 !important;
    }

    /* 글 본문 텍스트 */
    .entry-content,
    .entry-content p,
    .wp-block-post-content,
    .wp-block-post-content p,
    article p,
    .wp-block-post-excerpt,
    .wp-block-post-excerpt p,
    .wp-block-post-excerpt__excerpt {
        color: #cbd5e1 !important;
    }

    /* 제목 */
    h1, h2, h3, h4, h5, h6,
    .wp-block-post-title,
    .wp-block-post-title a,
    .wp-block-heading,
    .wp-block-site-title a {
        color: #f1f5f9 !important;
    }

    .wp-block-post-title a:hover {
        color: #818cf8 !important;
    }

    /* 날짜/메타 */
    .wp-block-post-date,
    time {
        color: #64748b !important;
    }

    /* 링크 */
    .entry-content a,
    .wp-block-post-content a {
        color: #818cf8 !important;
    }

    .entry-content a:hover,
    .wp-block-post-content a:hover {
        color: #a5b4fc !important;
    }

    /* 강조 */
    .entry-content strong,
    .wp-block-post-content strong {
        color: #f1f5f9 !important;
    }

    /* 리스트 */
    .entry-content li,
    .wp-block-post-content li {
        color: #cbd5e1 !important;
    }

    /* 코드 블록 */
    .entry-content code,
    .wp-block-post-content code {
        background: #334155 !important;
        color: #fb7185 !important;
    }

    .entry-content pre,
    .wp-block-post-content pre {
        background: #0f172a !important;
        color: #e2e8f0 !important;
        border: 1px solid #334155 !important;
    }

    .entry-content pre code,
    .wp-block-post-content pre code {
        background: transparent !important;
        color: #e2e8f0 !important;
    }

    /* h2 구분선 */
    .entry-content h2,
    .wp-block-post-content h2 {
        border-bottom-color: #334155 !important;
        color: #f1f5f9 !important;
    }

    /* 카테고리 배지 */
    .wp-block-post-terms a {
        background: #312e81 !important;
        color: #a5b4fc !important;
    }

    .wp-block-post-terms a:hover {
        background: #3730a3 !important;
    }

    /* 네비게이션 */
    .wp-block-navigation a {
        color: #e2e8f0 !important;
    }

    .wp-block-navigation a:hover {
        color: #818cf8 !important;
    }

    /* 서브메뉴 */
    .wp-block-navigation__submenu-container {
        background: #1e293b !important;
        border-color: #334155 !important;
    }

    /* 댓글 영역 */
    .comments-area,
    .wp-block-comments {
        border-top-color: #334155 !important;
        color: #cbd5e1 !important;
    }

    .comment-form input,
    .comment-form textarea {
        background: #1e293b !important;
        color: #e2e8f0 !important;
        border-color: #475569 !important;
    }

    /* figcaption */
    figcaption {
        color: #64748b !important;
    }

    /* 페이지네이션 */
    .wp-block-query-pagination a {
        color: #818cf8 !important;
    }

    /* 전체 글 목록 hover */
    .page-template-default .wp-block-query .wp-block-group:hover {
        background: #1e293b !important;
    }

    /* 푸터 */
    .wp-block-template-part footer,
    footer {
        color: #94a3b8 !important;
    }

    footer a {
        color: #818cf8 !important;
    }
}

/* ===== 본문 가독성 강화 ===== */

/* 줄 간격 + 문단 간격 */
.entry-content p,
.wp-block-post-content p {
    line-height: 2.0 !important;
    margin-bottom: 1.5em !important;
    word-break: keep-all !important;
    letter-spacing: -0.01em !important;
}

/* 리스트 줄 간격 */
.entry-content li,
.wp-block-post-content li {
    line-height: 1.9 !important;
    margin-bottom: 0.6em !important;
}

/* h2 앞뒤 여백 */
.entry-content h2,
.wp-block-post-content h2 {
    margin-top: 3rem !important;
    margin-bottom: 1.2rem !important;
    padding-bottom: 0.6rem !important;
}

/* h3 앞뒤 여백 */
.entry-content h3,
.wp-block-post-content h3 {
    margin-top: 2.2rem !important;
    margin-bottom: 1rem !important;
}

/* 이미지 앞뒤 여백 */
.entry-content figure,
.wp-block-post-content figure {
    margin-top: 2rem !important;
    margin-bottom: 2rem !important;
}

/* 모바일 가독성 */
@media (max-width: 768px) {
    .entry-content p,
    .wp-block-post-content p {
        line-height: 1.9 !important;
        margin-bottom: 1.3em !important;
        font-size: 1rem !important;
    }
}

/* 데스크탑 본문 너비 70% */
@media (min-width: 769px) {
    .wp-block-post-content,
    .entry-content,
    .is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
        max-width: 70vw !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* 코드 블록도 동일 너비 */
    .entry-content pre,
    .wp-block-post-content pre {
        max-width: 70vw !important;
    }
}

/* 개별 글 대표 이미지(썸네일) 크기 제한 */
.wp-block-post-featured-image img,
.single .wp-post-image {
    max-height: 400px !important;
    width: 100% !important;
    object-fit: cover !important;
}

@media (max-width: 768px) {
    .wp-block-post-featured-image img,
    .single .wp-post-image {
        max-height: 250px !important;
    }
}

/* 본문 이미지 크기 통일 */
.entry-content figure.wp-block-image,
.wp-block-post-content figure.wp-block-image {
    max-width: 100% !important;
    width: 100% !important;
}

.entry-content figure.wp-block-image img,
.wp-block-post-content figure.wp-block-image img {
    width: 100% !important;
    max-height: 450px !important;
    object-fit: cover !important;
    border-radius: 8px !important;
}

@media (max-width: 768px) {
    .entry-content figure.wp-block-image img,
    .wp-block-post-content figure.wp-block-image img {
        max-height: 300px !important;
    }
}

/* ===== Card Carousel ===== */
.card-carousel {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  margin: 2rem auto;
  background: #f1f5f9;
  max-width: 100%;
}
.card-carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.card-carousel-track::-webkit-scrollbar { display: none; }
.card-carousel-slide {
  min-width: 100%;
  flex-shrink: 0;
  scroll-snap-align: start;
}
.card-carousel-slide img {
  width: 100% !important;
  height: auto !important;
  max-height: none !important;
  display: block;
  border-radius: 0 !important;
}
.card-carousel-counter {
  text-align: center;
  padding: 8px 0;
  font-size: 13px;
  color: #64748b;
}
@media (prefers-color-scheme: dark) {
  .card-carousel { background: #1e293b; }
  .card-carousel-counter { color: #94a3b8; }
}
