/* ============================================
   TORLYAI BLOG - SHARED ENHANCED STYLES
   ============================================
   Clean, content-focused blog styles shared
   between home.php and archive.php.
   No glass-morphism, no animated orbs, no
   gradient borders. Medium/Ghost inspired.
   ============================================ */

/* ---- Layout ---- */

.archive-page,
.blog-index {
    padding: 0;
    background: #ffffff;
}

.archive-posts-container,
.blog-posts-container {
    position: relative;
}

/* ---- Grid ---- */

.blog-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    .blog-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .blog-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* ---- Cards ---- */

.blog-card {
    background: var(--white, #ffffff);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.blog-card.animate-in {
    opacity: 0;
    transform: translateY(20px);
}

.blog-card.animate-in.visible {
    opacity: 1;
    transform: translateY(0);
}

.blog-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.12);
}

/* ---- Thumbnail ---- */

.blog-thumbnail-link {
    display: block;
    overflow: hidden;
    height: 200px;
}

.blog-thumbnail {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.blog-card:hover .blog-thumbnail {
    transform: scale(1.03);
}

/* ---- Card Content ---- */

.blog-content {
    padding: 1.25rem 1.5rem 1.5rem;
}

.blog-meta {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    color: var(--text-secondary, #6b7280);
    font-size: 0.8125rem;
    flex-wrap: wrap;
}

.blog-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.blog-meta svg {
    width: 14px;
    height: 14px;
    opacity: 0.6;
}

.blog-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1.3;
    color: var(--text-primary, #000000) !important;
}

.blog-title a {
    color: inherit !important;
    text-decoration: none;
    transition: color 0.15s ease;
}

.blog-title a:hover {
    color: var(--color-chat-green, #10b981) !important;
}

.blog-excerpt {
    color: var(--text-secondary, #6b7280) !important;
    font-size: 0.9375rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---- Read More ---- */

.read-more {
    color: var(--color-chat-green, #10b981);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: gap 0.2s ease;
}

.read-more:hover {
    gap: 0.5rem;
}

.read-more svg {
    width: 16px;
    height: 16px;
}

/* ---- Pagination ---- */

.blog-pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 3rem;
    margin-bottom: 1rem;
}

.blog-pagination .nav-links {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.blog-pagination a,
.blog-pagination span {
    padding: 0.5rem 1rem;
    background: var(--white, #ffffff);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary, #000000);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.blog-pagination a:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.blog-pagination .current {
    background: var(--color-chat-green, #10b981);
    color: #ffffff;
    border-color: var(--color-chat-green, #10b981);
}

/* ---- No Posts ---- */

.no-posts {
    text-align: center;
    padding: 4rem 2rem;
    max-width: 500px;
    margin: 0 auto;
}

.no-posts h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-primary, #000000);
}

.no-posts p {
    color: var(--text-secondary, #6b7280);
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.6;
}

.no-posts .btn-primary {
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1.5rem;
    background: var(--color-chat-green, #10b981);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9375rem;
    transition: background 0.15s ease;
}

.no-posts .btn-primary:hover {
    background: #059669;
}

/* ---- Archive Header ---- */

.archive-header {
    text-align: center;
    margin-bottom: 3rem;
    padding: clamp(3rem, 6vw, 5rem) 0 clamp(2rem, 4vw, 3rem);
}

.archive-type {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-chat-green, #10b981);
    background: rgba(16, 185, 129, 0.08);
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    border: 1px solid rgba(16, 185, 129, 0.15);
    margin-bottom: 1rem;
}

.archive-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: var(--text-primary, #000000);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.archive-description {
    font-size: clamp(1rem, 2vw, 1.125rem);
    color: var(--text-secondary, #6b7280);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ---- Dark Mode ---- */

[data-theme="dark"] .archive-page,
[data-theme="dark"] .blog-index {
    background: #0a0a0a;
}

[data-theme="dark"] .blog-card {
    background: #141414;
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .blog-card:hover {
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(52, 211, 153, 0.15);
    border-color: rgba(52, 211, 153, 0.25);
}

[data-theme="dark"] .blog-title,
[data-theme="dark"] .blog-title a {
    color: rgba(255, 255, 255, 0.92) !important;
}

[data-theme="dark"] .blog-title a:hover {
    color: #34d399 !important;
}

[data-theme="dark"] .blog-excerpt {
    color: rgba(255, 255, 255, 0.6) !important;
}

[data-theme="dark"] .blog-meta {
    color: rgba(255, 255, 255, 0.44);
}

[data-theme="dark"] .read-more {
    color: #34d399;
}

[data-theme="dark"] .blog-pagination a,
[data-theme="dark"] .blog-pagination span {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] .blog-pagination a:hover {
    background: #222222;
    border-color: rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .blog-pagination .current {
    background: #34d399;
    color: #121212;
    border-color: #34d399;
}

[data-theme="dark"] .archive-type {
    background: rgba(52, 211, 153, 0.1);
    border-color: rgba(52, 211, 153, 0.2);
    color: #34d399;
}

[data-theme="dark"] .archive-title {
    color: #ffffff;
}

[data-theme="dark"] .archive-description {
    color: rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .no-posts h2 {
    color: rgba(255, 255, 255, 0.92);
}

[data-theme="dark"] .no-posts p {
    color: rgba(255, 255, 255, 0.6);
}

/* ---- Responsive ---- */

@media (max-width: 480px) {
    .blog-grid {
        gap: 1rem;
    }

    .blog-content {
        padding: 1rem 1.25rem 1.25rem;
    }

    .blog-title {
        font-size: 1.125rem;
    }

    .blog-excerpt {
        font-size: 0.875rem;
        -webkit-line-clamp: 2;
        margin-bottom: 0.75rem;
    }

    .blog-meta {
        flex-direction: row;
        gap: 0.5rem;
        font-size: 0.75rem;
    }

    .blog-thumbnail {
        height: 180px;
    }

    .blog-pagination .nav-links {
        gap: 0.375rem;
    }

    .blog-pagination a,
    .blog-pagination span {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
        min-width: 36px;
        text-align: center;
    }

    .archive-header {
        padding: 2rem 0 1.5rem;
        margin-bottom: 2rem;
    }

    .archive-title {
        font-size: 1.75rem;
    }

    .no-posts {
        padding: 3rem 1.5rem;
    }
}

/* Larger phones - 2 columns earlier */
@media (min-width: 540px) and (max-width: 767px) {
    .blog-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .blog-thumbnail {
        height: 160px;
    }

    .blog-title {
        font-size: 1.0625rem;
    }

    .blog-excerpt {
        -webkit-line-clamp: 2;
        font-size: 0.875rem;
    }
}

/* Touch-friendly tap targets */
@media (hover: none) and (pointer: coarse) {
    .blog-card:hover {
        transform: none;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    }

    .blog-card:active {
        transform: scale(0.98);
    }

    .read-more {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .blog-pagination a,
    .blog-pagination span {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* Safe area insets for notched phones */
@supports (padding: env(safe-area-inset-bottom)) {
    .archive-page .container,
    .blog-index .container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* ---- Accessibility ---- */

@media (prefers-reduced-motion: reduce) {
    .blog-card,
    .blog-thumbnail,
    .read-more,
    .blog-title a,
    .blog-pagination a {
        transition: none;
    }
}

.blog-card:focus-within {
    outline: 2px solid var(--color-chat-green, #10b981);
    outline-offset: 2px;
}

.read-more:focus-visible,
.blog-pagination a:focus-visible {
    outline: 2px solid var(--color-chat-green, #10b981);
    outline-offset: 2px;
}
