:root {
    --md-sys-color-background: #141218;
    --md-sys-color-on-background: #e6e1e5;
    --md-sys-color-surface: #1d1b20;
    --md-sys-color-surface-variant: #49454f;
    --md-sys-color-on-surface: #e6e1e5;
    --md-sys-color-on-surface-variant: #cac4d0;
    --md-sys-color-surface-container: #211f26;
    
    --md-sys-color-primary: #a8c7fa;
    --md-sys-color-on-primary: #062e6f;
    --md-sys-color-primary-container: #004a77;
    --md-sys-color-outline: #938f99;
    --md-sys-color-outline-variant: #444746;

    --font-title: 'Montserrat', sans-serif;
    --font-subtitle: 'Poppins', sans-serif;
    --font-body: 'Roboto', sans-serif;
    --font-code: 'Space Mono', monospace;

    --md-shape-corner-small: 8px;
    --md-shape-corner-medium: 12px;
    --md-shape-corner-large: 16px;
    --md-shape-corner-extra-large: 28px;
    --md-shape-corner-full: 50px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

.container { max-width: 1100px; margin: 0 auto; width: 100%; }
.page-padding { padding: 130px 5% 60px 5%; }
.text-center { text-align: center; }

/* Status & Navbar */
.status-bar {
    background: var(--md-sys-color-surface);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    width: 100%; padding: 6px 0; position: fixed; top: 0; z-index: 1001; display: flex; justify-content: center;
}
.status-content { display: flex; align-items: center; gap: 10px; font-family: var(--font-subtitle); font-size: 0.75rem; color: var(--md-sys-color-on-surface-variant); }
.pulsing-dot { width: 8px; height: 8px; background: #4ade80; border-radius: 50%; box-shadow: 0 0 8px #4ade80; }

.navbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 5%; height: 64px; position: fixed; top: 32px; width: 100%;
    background: rgba(29, 27, 32, 0.85); backdrop-filter: blur(20px);
    z-index: 1000; border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.logo a { font-family: var(--font-title); font-size: 1.2rem; font-weight: 700; color: var(--md-sys-color-primary); }

.btn-portfolio-back {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary);
    font-family: var(--font-subtitle); font-weight: 600; font-size: 0.85rem;
    padding: 8px 18px; border-radius: var(--md-shape-corner-full); transition: transform 0.2s;
}
.btn-portfolio-back:hover { transform: translateY(-2px); }

/* En-tête */
.blog-header { margin-bottom: 32px; }
.blog-badge {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(168, 199, 250, 0.1); border: 1px solid var(--md-sys-color-primary);
    color: var(--md-sys-color-primary); padding: 6px 16px; border-radius: var(--md-shape-corner-full);
    font-family: var(--font-subtitle); font-size: 0.85rem; font-weight: 600; margin-bottom: 16px;
}
.section-title { font-family: var(--font-title); font-size: 2.5rem; font-weight: 900; margin-bottom: 12px; }
.blog-subtitle { font-family: var(--font-body); color: var(--md-sys-color-on-surface-variant); max-width: 600px; margin: 0 auto; font-size: 1rem; line-height: 1.6; }

/* ==========================================================================
   BARRE D'OUTILS : RECHERCHE + FILTRES + TRI
   ========================================================================== */

.blog-controls-wrapper {
    max-width: 100%;
    margin: 0 auto 36px auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 1. Barre de recherche pleine largeur */
.search-bar-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 20px;
    color: var(--md-sys-color-primary);
    font-size: 1.05rem;
    pointer-events: none;
}

#blog-search-input {
    width: 100% !important;
    display: block !important;
    padding: 16px 52px 16px 52px !important;
    background: var(--md-sys-color-surface-container) !important;
    border: 1px solid var(--md-sys-color-outline-variant) !important;
    border-radius: 50px !important;
    color: #ffffff !important;
    font-family: var(--font-subtitle) !important;
    font-size: 0.95rem !important;
    outline: none !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
    transition: all 0.25s ease !important;
}

#blog-search-input:focus {
    border-color: var(--md-sys-color-primary) !important;
    box-shadow: 0 0 0 3px rgba(168, 199, 250, 0.2) !important;
    background: #27242d !important;
}

.search-clear-btn {
    position: absolute;
    right: 18px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.85rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.search-clear-btn:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }

/* 2. Ligne des filtres et du tri */
.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    padding: 12px 18px;
    border-radius: var(--md-shape-corner-large);
}

.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

.filter-chip {
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
    padding: 8px 16px;
    border-radius: var(--md-shape-corner-medium);
    font-family: var(--font-subtitle);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-chip.active, .filter-chip:hover {
    background: var(--md-sys-color-primary-container);
    color: #c2e7ff;
    border-color: var(--md-sys-color-primary);
}

/* Contrôles de tri sombres */
.sort-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.sort-label {
    font-family: var(--font-subtitle);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--md-sys-color-on-surface-variant);
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-select-wrap {
    position: relative;
    display: inline-block;
}

.custom-select-wrap select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: var(--md-sys-color-surface-container);
    color: #e6e1e5;
    border: 1px solid var(--md-sys-color-outline-variant);
    padding: 8px 34px 8px 14px;
    border-radius: var(--md-shape-corner-medium);
    font-family: var(--font-subtitle);
    font-size: 0.82rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.custom-select-wrap select:focus {
    border-color: var(--md-sys-color-primary);
}

.custom-select-wrap::after {
    content: "▼";
    font-size: 0.65rem;
    color: var(--md-sys-color-primary);
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.btn-sort-dir {
    background: rgba(168, 199, 250, 0.1);
    border: 1px solid var(--md-sys-color-primary);
    color: var(--md-sys-color-primary);
    padding: 8px 14px;
    border-radius: var(--md-shape-corner-medium);
    font-family: var(--font-subtitle);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-sort-dir:hover {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.search-feedback {
    font-family: var(--font-subtitle);
    font-size: 0.88rem;
    color: var(--md-sys-color-primary);
    text-align: left;
    padding: 0 4px;
}

mark.search-match {
    background: var(--md-sys-color-primary);
    color: #0d0c11;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 4px;
}

/* ==========================================================================
   GRILLE ET CARTES D'ARTICLES
   ========================================================================== */

.articles-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); 
    gap: 24px; 
    text-align: left; 
}

.article-card {
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-extra-large);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.article-card:hover {
    border-color: var(--md-sys-color-primary);
    transform: translateY(-4px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
}

.article-card.card-newest {
    border-color: rgba(168, 199, 250, 0.45);
}

.pill-newest-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(18, 16, 26, 0.9);
    border: 1px solid var(--md-sys-color-primary);
    color: var(--md-sys-color-primary);
    font-family: var(--font-code);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(8px);
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 6px #4ade80;
    animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.5; }
}

.article-card-cover {
    width: 100%;
    height: 190px;
    background: #0d0c11;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
}

.article-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.article-card:hover .article-card-cover img { transform: scale(1.04); }

.article-card-body {
    padding: 22px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.article-tag {
    background: rgba(168, 199, 250, 0.12);
    color: var(--md-sys-color-primary);
    padding: 4px 10px;
    border-radius: var(--md-shape-corner-full);
    font-family: var(--font-subtitle);
    font-size: 0.72rem;
    font-weight: 700;
}

.article-date {
    font-family: var(--font-code);
    font-size: 0.75rem;
    color: var(--md-sys-color-outline);
}

.article-card h3 {
    font-family: var(--font-title);
    font-size: 1.22rem;
    margin-bottom: 10px;
    color: var(--md-sys-color-on-surface);
    line-height: 1.35;
    transition: color 0.2s;
}
.article-card h3:hover { color: var(--md-sys-color-primary); }

.article-excerpt-box {
    flex-grow: 1;
    margin-bottom: 16px;
}

.article-excerpt-box p {
    font-family: var(--font-body);
    font-size: 0.88rem;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.55;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.article-media-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.media-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--md-shape-corner-small);
    padding: 3px 8px;
    font-family: var(--font-subtitle);
    font-size: 0.7rem;
    color: var(--md-sys-color-on-surface-variant);
}

.article-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    padding-top: 16px;
    margin-top: auto;
}

.btn-read {
    font-family: var(--font-subtitle);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--md-sys-color-primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: gap 0.2s;
}
.btn-read:hover { gap: 10px; }

.article-actions { display: flex; align-items: center; gap: 12px; }
.btn-action {
    background: transparent;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-family: var(--font-code);
    transition: color 0.2s;
}
.btn-action:hover, .btn-action.liked { color: #ff85a1; }

.empty-results-box {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: var(--md-sys-color-surface-container);
    border: 1px dashed var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-large);
}
.empty-icon { font-size: 2.5rem; color: var(--md-sys-color-outline); margin-bottom: 16px; }
.empty-results-box h3 { font-family: var(--font-title); color: #e6e1e5; margin-bottom: 6px; }
.empty-results-box p { color: var(--md-sys-color-on-surface-variant); font-size: 0.9rem; }

/* Modal Article Complet */
.article-modal {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(16px);
    z-index: 2000; display: none; align-items: center; justify-content: center; padding: 20px;
}
.article-modal.active { display: flex; }
.modal-card {
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-corner-extra-large);
    max-width: 820px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 36px; position: relative; text-align: left;
}
.modal-close {
    position: absolute; top: 20px; right: 20px; background: rgba(0,0,0,0.6); border: 1px solid var(--md-sys-color-outline-variant);
    width: 38px; height: 38px; border-radius: 50%; color: var(--md-sys-color-on-surface); font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 15;
}

.modal-cover-box {
    position: relative; width: 100%; max-height: 420px; background: #000;
    border-radius: var(--md-shape-corner-large); overflow: hidden; margin-bottom: 24px;
    display: flex; align-items: center; justify-content: center; cursor: zoom-in;
    border: 1px solid var(--md-sys-color-outline-variant);
}
.modal-cover-box img { max-width: 100%; max-height: 420px; object-fit: contain; display: block; }
.cover-zoom-pill {
    position: absolute; bottom: 12px; right: 12px; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px);
    color: #fff; font-family: var(--font-subtitle); font-size: 0.75rem; padding: 6px 12px; border-radius: var(--md-shape-corner-full); pointer-events: none;
}

.article-gallery-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 24px 0; }
.gallery-thumb { height: 140px; border-radius: var(--md-shape-corner-medium); overflow: hidden; background: #000; cursor: zoom-in; border: 1px solid var(--md-sys-color-outline-variant); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }

.lightbox-modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.95); z-index: 3000; display: none; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.lightbox-modal.active { display: flex; }
.lightbox-modal img { max-width: 95vw; max-height: 95vh; object-fit: contain; border-radius: 8px; }

.media-audio-card { background: var(--md-sys-color-surface); border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-shape-corner-medium); padding: 16px; margin: 16px 0; }
.media-audio-label { font-family: var(--font-subtitle); font-size: 0.82rem; font-weight: 600; color: var(--md-sys-color-primary); margin-bottom: 8px; }
.media-audio-card audio { width: 100%; outline: none; }

.media-video-container { position: relative; width: 100%; padding-bottom: 56.25%; background: #000; border-radius: var(--md-shape-corner-medium); overflow: hidden; margin: 20px 0; border: 1px solid var(--md-sys-color-outline-variant); }
.media-video-container iframe, .media-video-container video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }

.media-pdf-card { display: flex; justify-content: space-between; align-items: center; background: var(--md-sys-color-surface); border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-shape-corner-large); padding: 16px 20px; margin: 12px 0; gap: 16px; }
.pdf-card-info { display: flex; align-items: center; gap: 14px; }
.pdf-icon { font-size: 1.8rem; color: #ff85a1; }
.pdf-card-info strong { display: block; font-family: var(--font-title); font-size: 0.9rem; color: var(--md-sys-color-on-surface); }
.btn-pdf-download { display: inline-flex; align-items: center; gap: 8px; background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); font-family: var(--font-subtitle); font-size: 0.82rem; font-weight: 700; padding: 8px 16px; border-radius: var(--md-shape-corner-full); }

.btn-download-all { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; background: var(--md-sys-color-primary-container); border: 1px solid var(--md-sys-color-primary); color: #c2e7ff; font-family: var(--font-subtitle); font-size: 0.9rem; font-weight: 700; padding: 14px; border-radius: var(--md-shape-corner-medium); margin-top: 28px; cursor: pointer; }

.article-full-body { font-family: var(--font-body); line-height: 1.8; font-size: 1rem; color: var(--md-sys-color-on-surface); white-space: pre-wrap; margin: 20px 0; }

.spinner { width: 36px; height: 36px; border: 3px solid rgba(168, 199, 250, 0.2); border-top-color: var(--md-sys-color-primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 16px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.green-web-badge-container { display: flex; justify-content: center; align-items: center; margin-bottom: 16px; }
.green-web-badge-container img { border-radius: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); }

footer { margin-top: auto; padding: 36px 0; text-align: center; color: var(--md-sys-color-on-surface-variant); font-family: var(--font-subtitle); font-size: 0.8rem; border-top: 1px solid var(--md-sys-color-outline-variant); }

@media screen and (max-width: 768px) {
    .controls-row { flex-direction: column; align-items: stretch; }
    .sort-controls { justify-content: space-between; margin-left: 0; width: 100%; }
    .media-pdf-card { flex-direction: column; align-items: flex-start; }
    .btn-pdf-download { width: 100%; justify-content: center; }
    .modal-card { padding: 20px; }
}