/* ========================================
   Blog System Styles - Whitehat Marketing
   ======================================== */

/* Category Badge */
.category-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 24px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 2;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.category-badge[data-category="SEO"] {
    background: rgba(30,144,255,0.9);
    color: white;
}

.category-badge[data-category="AEO"] {
    background: rgba(255,140,0,0.9);
    color: white;
}

.category-badge[data-category="E-commerce"] {
    background: rgba(147,112,219,0.9);
    color: white;
}

/* Blog Post & Card Structure */
.blog-post, .card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden !important;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    height: auto !important;
    min-height: unset !important; /* Content-driven height - Korean-only excerpts are shorter */
}

.card[style*="padding"] {
    padding: 0 !important;
}

.blog-post:hover, .card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    transform: translateY(-4px);
}

/* Post Summary */
.post-summary {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Post Hero Image */
.post-hero {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    flex-shrink: 0;
}

.blog-post:hover .post-hero, .card:hover .post-hero {
    transform: scale(1.05);
}

.blog-post[data-expanded="true"] .post-hero, .card[data-expanded="true"] .post-hero {
    height: 300px;
}

/* Post Title */
.post-title, .card h2 {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.5;
    margin: 0 0 0.75rem 0;
    color: var(--primary-black);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 4rem;
    word-break: keep-all;
}

.blog-post[data-expanded="true"] .post-title, .card[data-expanded="true"] h2 {
    -webkit-line-clamp: unset;
    overflow: visible;
}

/* Post Meta */
.post-meta {
    font-size: 0.85rem;
    color: var(--gray-medium);
    margin: 0 0 1rem 0;
    flex-shrink: 0;
}

/* Post Excerpt - Korean-only text (no multilingual spans) */
.post-excerpt {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--gray-dark);
    margin: 0 0 1.25rem 0;
    display: -webkit-box;
    -webkit-line-clamp: 4; /* Korean-only excerpts are shorter, 4 lines sufficient */
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
    min-height: unset; /* Content-driven height */
    word-break: keep-all;
}

.blog-post[data-expanded="true"] .post-excerpt, .card[data-expanded="true"] p:nth-of-type(2) {
    -webkit-line-clamp: unset;
    overflow: visible;
}

/* Card Specific Styles */
.card {
    min-height: unset !important; /* Content-driven height */
    overflow: hidden !important;
}

/* Hide extra content in collapsed cards */
.card h3, .card h3 + *, .card h3 ~ *,
.card h4, .card h4 + *, .card h4 ~ *,
.card ul, .card ol,
.card img:nth-of-type(n+2),
.card a.btn, .card a.btn-secondary,
.card .post-excerpt:nth-of-type(n+2),
.card p:nth-of-type(n+3) {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    line-height: 0 !important;
    font-size: 0 !important;
}

/* Card Image */
.card > img:first-of-type {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}

.card:hover > img:first-of-type {
    transform: scale(1.05);
}

/* Card Text Padding */
.card > h2, .card > p {
    padding-left: 2rem;
    padding-right: 2rem;
}

.card > h2 {
    padding-top: 2rem;
}

/* Card Title */
.card > h2 {
    font-size: 1.35rem !important;
    font-weight: 700;
    line-height: 1.5;
    margin: 0 0 0.75rem 0 !important;
    color: var(--primary-black);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 4rem;
    word-break: keep-all;
}

.card > h2 > a {
    color: var(--primary-black);
    text-decoration: none;
}

/* Card Meta */
.card > p:nth-of-type(1) {
    font-size: 0.85rem;
    color: var(--gray-medium) !important;
    margin: 0 0 1rem 0 !important;
    flex-shrink: 0;
}

/* Card Excerpt - FIXED: Increased from 3 lines to 6 lines */
.card > .post-excerpt:first-of-type {
    font-size: 1rem !important;
    line-height: 1.7 !important;
    color: var(--gray-dark) !important;
    margin: 0 0 1.5rem 0 !important;
    padding-bottom: 2rem;
    display: -webkit-box;
    -webkit-line-clamp: 6; /* Changed from 3 to 6 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 10.2rem; /* Changed from 5.1rem */
    flex: 1;
    word-break: keep-all;
}

/* Buttons */
.btn-expand {
    display: inline-block;
    padding: 0.85rem 2.5rem;
    background: var(--primary-black);
    border: 2px solid var(--primary-black);
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    font-family: 'Noto Sans KR', sans-serif;
    text-align: center;
    margin-top: auto;
}

.btn-expand:hover {
    background: white;
    color: var(--primary-black);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-collapse {
    display: inline-block;
    padding: 0.75rem 2rem;
    margin-top: 2rem;
    background: #F5F5F5;
    border: none;
    border-radius: 6px;
    color: #666;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Noto Sans KR', sans-serif;
}

.btn-collapse:hover {
    background: #E0E0E0;
}

.btn-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.9);
    border: 1px solid #E0E0E0;
    border-radius: 50%;
    color: #666;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.btn-close:hover {
    background: white;
    color: #333;
    border-color: #999;
}

/* Post Content (Expandable) */
.post-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4,0,0.2,1);
}

.blog-post[data-expanded="true"] .post-content {
    max-height: 10000px;
}

.post-content[hidden] {
    display: none;
}

/* Post Divider */
.post-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #E0E0E0 50%, transparent);
    margin: 2rem 0;
}

/* Post Body Content */
.post-body {
    padding: 0 1.5rem;
}

.post-body h3 {
    font-size: 1.35rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    color: var(--primary-black);
}

.post-body h4 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    color: var(--gray-dark);
}

.post-body p {
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    color: var(--gray-dark);
    word-break: keep-all;
}

.post-body img {
    width: 100%;
    border-radius: 8px;
    margin: 1.5rem 0;
}

.post-body ul, .post-body ol {
    font-size: 1.05rem;
    line-height: 1.8;
    margin: 1.5rem 0;
    padding-left: 2rem;
}

.post-body li {
    margin-bottom: 0.5rem;
}

.post-body .btn-secondary {
    display: inline-block;
    margin: 2rem 0;
}

/* Blog Layout Views */
.blog-grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 2.5rem;
    align-items: start;
}

.blog-grid-view .blog-post, .blog-grid-view .card {
    margin-bottom: 0 !important;
}

.blog-list-view {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.blog-list-view .blog-post, .blog-list-view .card {
    margin-bottom: 0 !important;
}

.blog-list-view .blog-post:not([data-expanded="true"]), .blog-list-view .card {
    flex-direction: row;
    align-items: flex-start;
    height: auto !important;
    max-height: none !important;
    min-height: auto !important;
}

.blog-list-view .blog-post:not([data-expanded="true"]) .post-summary {
    flex-direction: row;
}

.blog-list-view .blog-post:not([data-expanded="true"]) .post-hero, .blog-list-view .card > img:first-of-type {
    width: 300px;
    min-width: 300px;
    height: 200px;
}

.blog-list-view .card {
    flex-wrap: wrap;
}

.blog-list-view .card > img:first-of-type {
    order: 1;
}

.blog-list-view .card > h2 {
    order: 2;
    flex: 1;
    padding-top: 0;
}

.blog-list-view .card > p:nth-of-type(1) {
    order: 3;
    flex: 1;
}

.blog-list-view .card > p:nth-of-type(2) {
    order: 4;
    flex: 1;
}

/* Animations */
@keyframes expandCard {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.blog-post[data-expanded="true"] .post-content {
    animation: expandCard 0.3s ease-out;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .blog-grid-view {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .post-hero, .card > img:first-of-type {
        height: 180px;
    }

    .blog-post[data-expanded="true"] .post-hero {
        height: 250px;
    }

    .post-title, .card > h2 {
        font-size: 1.2rem !important;
        min-height: 3.6rem;
    }

    .post-excerpt, .card > .post-excerpt:first-of-type {
        font-size: 0.95rem !important;
        min-height: unset; /* Content-driven height */
    }

    .card > h2, .card > p {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    .card > h2 {
        padding-top: 1.5rem;
    }

    .category-badge {
        top: 0.75rem;
        left: 0.75rem;
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .post-body h3 {
        font-size: 1.3rem;
    }

    .post-body p {
        font-size: 1rem;
        line-height: 1.8;
    }

    /* List view mobile adjustments */
    .blog-list-view .blog-post:not([data-expanded="true"]), .blog-list-view .card {
        flex-direction: column;
    }

    .blog-list-view .blog-post:not([data-expanded="true"]) .post-summary {
        flex-direction: column;
    }

    .blog-list-view .blog-post:not([data-expanded="true"]) .post-hero, .blog-list-view .card > img:first-of-type {
        width: 100%;
        min-width: 100%;
    }

    .blog-list-view .card > img:first-of-type {
        order: 0;
    }

    .blog-list-view .card > h2 {
        order: 0;
        padding-top: 1.5rem;
    }

    .blog-list-view .card > p:nth-of-type(1) {
        order: 0;
    }

    .blog-list-view .card > p:nth-of-type(2) {
        order: 0;
    }

    .btn-close {
        top: 0.5rem;
        right: 0.5rem;
    }
}

/* Accessibility Focus States */
.blog-post:focus-within {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.btn-expand:focus, .btn-collapse:focus, .btn-close:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Modal Styles */
.blog-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4,0,0.2,1);
}

.blog-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.blog-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.blog-modal-overlay.active .blog-modal-content {
    transform: translateY(0) scale(1);
}

.blog-modal-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #E0E0E0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.blog-modal-close {
    width: 40px;
    height: 40px;
    background: #F5F5F5;
    border: none;
    border-radius: 50%;
    color: #666;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.blog-modal-close:hover {
    background: #E0E0E0;
    color: #333;
}

.blog-modal-body {
    padding: 2rem;
}

.blog-modal-body .post-hero {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.blog-modal-body .category-badge {
    display: inline-block;
    margin-bottom: 1rem;
}

.blog-modal-body .post-title {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 1rem 0;
    color: var(--primary-black);
}

.blog-modal-body .post-meta {
    font-size: 0.9rem;
    color: var(--gray-medium);
    margin-bottom: 2rem;
}

.blog-modal-body .post-excerpt {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--gray-dark);
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #F9F9F9;
    border-left: 4px solid var(--accent-color);
    border-radius: 4px;
}

.blog-modal-body .post-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #E0E0E0 50%, transparent);
    margin: 2rem 0;
}

.blog-modal-body .post-body {
    max-width: 100%;
}

.blog-modal-body .post-body h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 2.5rem 0 1rem;
    color: var(--primary-black);
    padding-top: 1rem;
    border-top: 1px solid #F0F0F0;
}

.blog-modal-body .post-body h3:first-child {
    border-top: none;
    padding-top: 0;
}

.blog-modal-body .post-body p {
    font-size: 1.125rem;
    line-height: 2;
    margin-bottom: 1.5rem;
    color: var(--gray-dark);
    word-break: keep-all;
}

.blog-modal-body .post-body img {
    width: 100%;
    border-radius: 8px;
    margin: 2rem 0;
}

.blog-modal-body .post-body ul, .blog-modal-body .post-body ol {
    font-size: 1.125rem;
    line-height: 2;
    margin: 1.5rem 0;
    padding-left: 2rem;
}

.blog-modal-body .post-body li {
    margin-bottom: 0.75rem;
}

.blog-modal-body .post-body strong {
    font-weight: 600;
    color: var(--primary-black);
}

.blog-modal-body .btn-secondary {
    display: inline-block;
    margin: 2rem 0;
}

/* Modal Mobile Responsive */
@media (max-width: 768px) {
    .blog-modal-overlay {
        padding: 0;
        align-items: flex-start;
    }

    .blog-modal-content {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        height: 100%;
    }

    .blog-modal-header {
        padding: 1rem;
    }

    .blog-modal-body {
        padding: 1.5rem;
    }

    .blog-modal-body .post-title {
        font-size: 1.5rem;
    }

    .blog-modal-body .post-hero {
        max-height: 250px;
    }
}

/* Scrollbar Styles */
.blog-modal-content::-webkit-scrollbar {
    width: 8px;
}

.blog-modal-content::-webkit-scrollbar-track {
    background: #F5F5F5;
}

.blog-modal-content::-webkit-scrollbar-thumb {
    background: #CCCCCC;
    border-radius: 4px;
}

.blog-modal-content::-webkit-scrollbar-thumb:hover {
    background: #999999;
}

/* Prevent body scroll when modal open */
body.modal-open {
    overflow: hidden;
}
