/* ============================================
   KIMERZ CONSTRUCTION - BLOG STYLES
   ============================================ */

/* --- Anti horizontal scroll (mobile/tablet) ---
   Bloque TOUT glissement horizontal :
   - overflow-x: clip (plus strict que hidden, ne crée pas de scroll context)
   - overscroll-behavior-x: none (empêche l'élastic scroll iOS)
   - touch-action: pan-y (autorise seulement le scroll vertical) */
html {
    overflow-x: clip;
    overscroll-behavior-x: none;
}
body {
    overflow-x: clip;
    overscroll-behavior-x: none;
    position: relative;
    width: 100%;
    touch-action: pan-y pinch-zoom;
}

/* --- Blog Page Header Override ---
   On blog/article pages the header is relative (not fixed),
   so we must keep header-actions visible at all breakpoints.
   The main styles.css hides .header-actions .btn at 1024px
   for the homepage hamburger menu — we override that here. */
body:has(.blog-hero) .header-actions .btn,
body:has(.article-hero) .header-actions .btn,
body:has(.blog-section) .header-actions .btn {
    display: inline-flex !important;
}
/* Fallback for browsers without :has() — scoped via blog.css only loading on blog pages */
.header[style*="relative"] .header-actions .btn {
    display: inline-flex !important;
}
.header[style*="relative"] .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.header[style*="relative"] .header-inner {
    gap: 12px;
    overflow: hidden;
}
.header[style*="relative"] .logo {
    min-width: 0;
    overflow: hidden;
}
.header[style*="relative"] .logo-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Blog Hero --- */
.blog-hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 80px 0 60px;
    text-align: center;
    color: var(--white);
}
.blog-hero h1 {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 16px;
    line-height: 1.2;
}
.blog-hero p {
    font-size: 1.15rem;
    color: var(--gray-300);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* --- Blog Grid --- */
.blog-section {
    padding: 80px 0;
    background: var(--gray-50);
}
.blog-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    margin-top: 0;
}

/* --- Blog Card --- */
.blog-card {
    background: var(--white);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
}
.blog-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
}
.blog-card-image {
    position: relative;
    height: 220px;
    overflow: hidden;
    flex-shrink: 0;
}
.blog-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition);
}
.blog-card:hover .blog-card-image img {
    transform: scale(1.05);
}
.blog-card-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.blog-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: var(--gray-400);
    flex-wrap: wrap;
}
.blog-card-meta i {
    font-size: 0.8rem;
}
.blog-card h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    line-height: 1.4;
}
.blog-card h3 a {
    color: inherit;
    transition: color var(--transition);
}
.blog-card h3 a:hover {
    color: var(--accent);
}
.blog-card p {
    color: var(--gray-500);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 20px;
    flex: 1;
}
.blog-card-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.95rem;
    transition: gap var(--transition);
    padding: 8px 0;
    min-height: 44px;
}
.blog-card-link:hover {
    gap: 10px;
}

/* --- Category Badge --- */
.category-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    flex-shrink: 0;
}
.category-badge.renovation { background: rgba(249, 115, 22, 0.12); color: var(--accent); }
.category-badge.construction { background: rgba(27, 42, 74, 0.1); color: var(--primary); }
.category-badge.conseils { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.category-badge.legal { background: rgba(100, 116, 139, 0.12); color: var(--gray-600); }
.category-badge.tendances { background: rgba(139, 92, 246, 0.12); color: #8B5CF6; }
.category-badge.toiture { background: rgba(14, 165, 233, 0.12); color: #0EA5E9; }
.category-badge.interieur { background: rgba(236, 72, 153, 0.12); color: #EC4899; }

/* --- Article Hero --- */
.article-hero {
    position: relative;
    height: 400px;
    overflow: hidden;
}
.article-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.article-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(15, 26, 48, 0.3) 0%, rgba(15, 26, 48, 0.7) 100%);
}

/* --- Breadcrumb --- */
.breadcrumb {
    padding: 16px 0;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}
.breadcrumb-list {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    font-size: 0.9rem;
    color: var(--gray-400);
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
}
.breadcrumb-list a {
    color: var(--accent);
    font-weight: 500;
}
.breadcrumb-list a:hover {
    text-decoration: underline;
}
.breadcrumb-list li {
    display: inline-flex;
    align-items: center;
}
.breadcrumb-list li:not(:last-child)::after {
    content: "\203A";
    margin-left: 8px;
    color: var(--gray-300);
}
.breadcrumb-list li:last-child {
    color: var(--gray-500);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 350px;
}

/* --- Article Content --- */
.article-section {
    padding: 60px 0 80px;
}
.article-wrapper {
    max-width: 800px;
    margin: 0 auto;
    overflow: hidden;
}
.article-header {
    margin-bottom: 40px;
}
.article-header h1 {
    font-family: var(--font-heading);
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.3;
    margin-bottom: 20px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.article-meta {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    color: var(--gray-400);
    font-size: 0.9rem;
}
.article-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.article-content {
    overflow-wrap: break-word;
    word-wrap: break-word;
}
.article-content h2 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    margin: 40px 0 16px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-100);
    line-height: 1.3;
}
.article-content h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
.article-content h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-light);
    margin: 28px 0 12px;
    line-height: 1.4;
}
.article-content p {
    color: var(--gray-600);
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 18px;
}
.article-content ul, .article-content ol {
    padding-left: 24px;
    margin-bottom: 18px;
}
.article-content li {
    color: var(--gray-600);
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 8px;
}
.article-content blockquote {
    border-left: 4px solid var(--accent);
    padding: 20px 24px;
    margin: 28px 0;
    background: var(--gray-50);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
    color: var(--gray-600);
}
.article-content strong {
    color: var(--gray-700);
    font-weight: 600;
}
.article-content .info-box {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.06) 0%, rgba(249, 115, 22, 0.02) 100%);
    border: 1px solid rgba(249, 115, 22, 0.15);
    border-radius: var(--radius-md);
    padding: 24px;
    margin: 28px 0;
}
.article-content .info-box h4 {
    color: var(--accent);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Tables: scrollable on mobile --- */
.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 0.95rem;
}
.article-content table th,
.article-content table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-600);
}
.article-content table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}
.article-content table tr:hover {
    background: var(--gray-50);
}
/* Overflow wrapper for tables */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 24px 0;
    padding: 0;
}
.table-wrapper table {
    margin: 0;
    min-width: 500px;
}

/* --- Article CTA --- */
.article-cta {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    text-align: center;
    margin: 60px 0 0;
    color: var(--white);
}
.article-cta h3 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--white);
}
.article-cta p {
    color: var(--gray-300);
    font-size: 1.05rem;
    margin-bottom: 24px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}
.article-cta .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* --- Related Posts --- */
.related-posts {
    padding: 80px 0;
    background: var(--gray-50);
}
.related-posts h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    margin-bottom: 40px;
}
.related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
}

/* ===========================
   RESPONSIVE
   =========================== */

/* Tablet Landscape (1024px) */
@media (max-width: 1024px) {
    .blog-hero h1 { font-size: 2.3rem; }
    .blog-grid { grid-template-columns: repeat(2, 1fr); gap: 24px; }
    .related-grid { grid-template-columns: repeat(2, 1fr); }
    .article-header h1 { font-size: 2rem; }
    .article-hero { height: 340px; }

    /* Keep header button visible but smaller */
    .header[style*="relative"] .header-actions .btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

/* Tablet Portrait (768px) */
@media (max-width: 768px) {
    /* Blog Hero */
    .blog-hero { padding: 60px 0 40px; }
    .blog-hero h1 { font-size: 1.8rem; }
    .blog-hero p { font-size: 1rem; line-height: 1.6; }

    /* Blog Grid — horizontal card layout on tablet */
    .blog-section { padding: 48px 0; }
    .blog-grid { grid-template-columns: 1fr; gap: 20px; max-width: 640px; margin: 0 auto; }
    .blog-card { flex-direction: row; }
    .blog-card-image { height: auto; width: 200px; min-height: 180px; }
    .blog-card-body { padding: 20px; }
    .blog-card h3 { font-size: 1.1rem; }
    .blog-card p { font-size: 0.9rem; margin-bottom: 12px; }

    /* Related grid */
    .related-grid { grid-template-columns: 1fr; max-width: 500px; margin: 0 auto; }
    .related-posts { padding: 48px 0; }
    .related-posts h2 { font-size: 1.6rem; margin-bottom: 28px; }

    /* Article hero */
    .article-hero { height: 260px; }

    /* Article content */
    .article-section { padding: 36px 0 48px; }
    .article-header { margin-bottom: 28px; }
    .article-header h1 { font-size: 1.65rem; margin-bottom: 16px; }
    .article-meta { gap: 12px; font-size: 0.85rem; }
    .article-content h2 { font-size: 1.35rem; margin: 32px 0 14px; }
    .article-content h3 { font-size: 1.1rem; margin: 24px 0 10px; }
    .article-content p, .article-content li { font-size: 1rem; line-height: 1.75; }
    .article-content blockquote { padding: 16px 18px; margin: 24px 0; font-size: 0.95rem; }
    .article-content .info-box { padding: 20px; margin: 24px 0; }
    .article-content ul, .article-content ol { padding-left: 20px; }

    /* Table responsive — contained scroll */
    .article-content table {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    .article-content table th,
    .article-content table td { padding: 10px 12px; white-space: nowrap; }

    /* CTA */
    .article-cta { padding: 32px 24px; margin: 40px 0 0; border-radius: var(--radius-md); }
    .article-cta h3 { font-size: 1.4rem; }
    .article-cta p { font-size: 0.95rem; }

    /* Breadcrumb */
    .breadcrumb { padding: 12px 0; }
    .breadcrumb-list { font-size: 0.82rem; gap: 6px; }
    .breadcrumb-list li:last-child { max-width: 220px; }

    /* Header on blog pages — shorter logo text */
    .header[style*="relative"] .logo-name { font-size: 0.9rem; }
    .header[style*="relative"] .header-actions .btn {
        padding: 8px 14px;
        font-size: 0.82rem;
    }
    .header[style*="relative"] .header-actions .btn i { display: none; }
}

/* Mobile (480px) */
@media (max-width: 480px) {
    /* Blog Hero */
    .blog-hero { padding: 44px 0 32px; }
    .blog-hero h1 { font-size: 1.5rem; }
    .blog-hero p { font-size: 0.9rem; }

    /* Blog Grid — stack vertically */
    .blog-section { padding: 32px 0; }
    .blog-grid { gap: 16px; }
    .blog-card { flex-direction: column; }
    .blog-card-image { width: 100%; height: 180px; min-height: auto; }
    .blog-card-body { padding: 16px; }
    .blog-card h3 { font-size: 1.05rem; margin-bottom: 8px; }
    .blog-card p { font-size: 0.88rem; margin-bottom: 14px; line-height: 1.5; }
    .blog-card-link { font-size: 0.88rem; }
    .blog-card-meta { gap: 8px; font-size: 0.78rem; }

    /* Article Hero */
    .article-hero { height: 200px; }

    /* Article */
    .article-section { padding: 28px 0 40px; }
    .article-header { margin-bottom: 24px; }
    .article-header h1 { font-size: 1.35rem; line-height: 1.35; margin-bottom: 14px; }
    .article-meta { gap: 8px; font-size: 0.78rem; }
    .article-meta span { gap: 4px; }

    /* Article content */
    .article-content h2 {
        font-size: 1.2rem;
        margin: 28px 0 12px;
        padding-top: 16px;
    }
    .article-content h3 { font-size: 1.05rem; margin: 20px 0 8px; }
    .article-content p, .article-content li {
        font-size: 0.93rem;
        line-height: 1.7;
    }
    .article-content ul, .article-content ol { padding-left: 18px; }
    .article-content blockquote {
        padding: 14px 16px;
        margin: 20px 0;
        font-size: 0.9rem;
        line-height: 1.6;
    }
    .article-content .info-box {
        padding: 16px;
        margin: 20px 0;
        border-radius: var(--radius-sm);
    }
    .article-content .info-box h4 { font-size: 0.9rem; }

    /* Table — contained on small mobile */
    .article-content table { font-size: 0.8rem; max-width: 100%; }
    .article-content table th,
    .article-content table td {
        padding: 8px 10px;
    }

    /* CTA */
    .article-cta {
        padding: 28px 18px;
        margin: 32px 0 0;
        border-radius: var(--radius-sm);
    }
    .article-cta h3 { font-size: 1.25rem; margin-bottom: 10px; }
    .article-cta p { font-size: 0.9rem; margin-bottom: 20px; }
    .article-cta .btn {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
        font-size: 0.95rem;
    }

    /* Related */
    .related-posts { padding: 36px 0; }
    .related-posts h2 { font-size: 1.4rem; margin-bottom: 20px; }
    .related-grid { gap: 16px; }

    /* Breadcrumb */
    .breadcrumb { padding: 10px 0; }
    .breadcrumb-list { font-size: 0.75rem; gap: 4px; }
    .breadcrumb-list li:last-child { max-width: 160px; font-size: 0.72rem; }
    .breadcrumb-list li:not(:last-child)::after { margin-left: 4px; }

    /* Header on blog pages */
    .header[style*="relative"] .logo-name {
        font-size: 0.78rem;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .header[style*="relative"] .logo-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    .header[style*="relative"] .header-actions .btn {
        padding: 7px 12px;
        font-size: 0.78rem;
    }

    /* Category badge smaller */
    .category-badge {
        padding: 3px 10px;
        font-size: 0.68rem;
    }
}

/* Extra Small (360px and below) */
@media (max-width: 360px) {
    .blog-hero h1 { font-size: 1.3rem; }
    .blog-hero p { font-size: 0.85rem; }
    .article-header h1 { font-size: 1.2rem; }
    .article-content h2 { font-size: 1.1rem; }
    .article-content p, .article-content li { font-size: 0.88rem; }
    .article-cta h3 { font-size: 1.15rem; }

    .header[style*="relative"] .logo-name {
        max-width: 110px;
        font-size: 0.72rem;
    }
    .header[style*="relative"] .header-actions .btn {
        padding: 6px 10px;
        font-size: 0.72rem;
    }

    .breadcrumb-list li:last-child { max-width: 120px; }
}

/* --- Touch device improvements --- */
@media (hover: none) and (pointer: coarse) {
    .blog-card:hover {
        transform: none;
        box-shadow: var(--shadow-sm);
    }
    .blog-card:active {
        transform: scale(0.98);
        box-shadow: var(--shadow-md);
    }
    .blog-card-link {
        min-height: 48px;
        padding: 12px 0;
    }
}

/* --- Reduce motion --- */
@media (prefers-reduced-motion: reduce) {
    .blog-card,
    .blog-card-image img {
        transition: none;
    }
    .blog-card:hover {
        transform: none;
    }
    .blog-card:hover .blog-card-image img {
        transform: none;
    }
}
