/**
 * dico-proverbes.com - Design "Encre et Sagesse"
 * Palette: Brun encre #3D2B1F, Ocre chaud #C4956A, Creme #FAF6EF,
 *          Cuir #8B6F4E, Parchemin #E8DCC8
 * Typo: Cormorant Garamond (titres, proverbes) + Inter (corps, UI)
 */

/* ── Reset + Base ──────────────────────────────────────────────── */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --c-encre: #3D2B1F;
    --c-ocre: #C4956A;
    --c-creme: #FAF6EF;
    --c-cuir: #8B6F4E;
    --c-parchemin: #E8DCC8;
    --c-paper: #FFFDF8;
    --c-bg: #FAF6EF;
    --c-text: #3D2B1F;
    --c-text-light: #8B6F4E;
    --c-border: #E8DCC8;
    --c-card-bg: #FFFDF8;
    --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --font-body: 'Inter', -apple-system, 'Segoe UI', sans-serif;
    --max-w: 1100px;
    --sidebar-w: 260px;
}

body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.7;
    color: var(--c-text);
    background: var(--c-bg);
}

/* Dark mode */
body.dark {
    --c-bg: #1C1410;
    --c-text: #E8DCC8;
    --c-text-light: #C4956A;
    --c-border: #3D2B1F;
    --c-card-bg: #261D16;
    --c-paper: #2A201A;
    --c-encre: #E8DCC8;
    --c-parchemin: #3D2B1F;
}

a { color: var(--c-ocre); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* ── Skip link ─────────────────────────────────────────────────── */

.skip-link {
    position: absolute; left: -9999px; top: 0;
    background: var(--c-encre); color: var(--c-creme);
    padding: 8px 16px; z-index: 10000; font-size: 14px;
}
.skip-link:focus { left: 0; }

/* ── Header / Nav ──────────────────────────────────────────────── */

.site-header {
    position: sticky; top: 0; z-index: 1000;
    background: #3D2B1F; color: #FAF6EF;
    border-bottom: 2px solid var(--c-ocre);
}

.header-inner {
    max-width: var(--max-w); margin: 0 auto;
    padding: 0 20px; height: 56px;
    display: flex; align-items: center; gap: 24px;
}

.logo {
    font-family: var(--font-display);
    font-size: 22px; font-weight: 500;
    color: #FAF6EF; text-decoration: none;
    letter-spacing: 0.5px; white-space: nowrap;
}
.logo-prov { color: var(--c-ocre); }

.nav-desktop { display: flex; gap: 20px; margin-left: auto; }
.nav-desktop a {
    color: #D4C4AA; font-size: 13px; letter-spacing: 0.3px;
    text-decoration: none; transition: color 0.2s;
}
.nav-desktop a:hover, .nav-desktop a.active { color: #FAF6EF; }

.toggle-theme {
    background: none; border: 1px solid #5C4A3A;
    border-radius: 50%; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    color: var(--c-ocre); cursor: pointer; flex-shrink: 0;
    transition: border-color 0.2s;
}
.toggle-theme:hover { border-color: var(--c-ocre); }

.burger {
    display: none; background: none; border: none;
    color: #FAF6EF; cursor: pointer; padding: 4px;
}

/* Nav mobile */
.nav-mobile {
    display: none; background: #3D2B1F;
    padding: 0 20px 16px; flex-direction: column; gap: 2px;
}
.nav-mobile.open { display: flex; }
.nav-mobile a {
    color: #D4C4AA; font-size: 14px; padding: 10px 0;
    text-decoration: none; border-bottom: 1px solid #5C4A3A;
}
.nav-mobile a:hover { color: #FAF6EF; }

/* ── Breadcrumb ────────────────────────────────────────────────── */

.breadcrumb {
    background: #F5EFE3; padding: 8px 20px;
    border-bottom: 1px solid var(--c-border);
    position: relative; z-index: 1;
}
body.dark .breadcrumb { background: #1C1410; }
.breadcrumb ol {
    list-style: none; display: flex; flex-wrap: wrap;
    gap: 0; max-width: var(--max-w); margin: 0 auto;
    font-size: 12px; color: var(--c-text-light);
}
.breadcrumb li::before { content: ' \203A '; margin: 0 6px; }
.breadcrumb li:first-child::before { display: none; }
.breadcrumb a { color: var(--c-ocre); }

/* ── Layout ────────────────────────────────────────────────────── */

.page-wrap {
    max-width: var(--max-w); margin: 0 auto; padding: 24px 20px;
    display: flex; gap: 32px;
}
.page-main { flex: 1; min-width: 0; }
.page-sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    position: sticky; top: 80px; align-self: flex-start;
    max-height: calc(100vh - 100px); overflow-y: auto;
}

.page-full { max-width: var(--max-w); margin: 0 auto; padding: 24px 20px; }

/* ── Hero ──────────────────────────────────────────────────────── */

.hero {
    text-align: center; padding: 40px 20px 32px;
    border-bottom: 1px solid var(--c-border);
}
.hero h1 {
    font-family: var(--font-display);
    font-size: 30px; font-weight: 500; line-height: 1.3;
    color: var(--c-text); margin-bottom: 10px;
}
.hero .subtitle {
    font-size: 14px; color: var(--c-text-light);
    max-width: 560px; margin: 0 auto 24px; line-height: 1.6;
}

/* ── Search ────────────────────────────────────────────────────── */

.search-wrap {
    max-width: 500px; margin: 0 auto; position: relative;
}
.search-wrap input[type="text"],
.search-wrap input[type="search"] {
    width: 100%; border: 1px solid var(--c-border);
    background: var(--c-card-bg); border-radius: 8px;
    padding: 12px 44px 12px 16px; font-size: 16px;
    font-family: var(--font-body); color: var(--c-text);
    outline: none; transition: border-color 0.2s;
}
.search-wrap input:focus { border-color: var(--c-ocre); }
.search-btn {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    background: var(--c-ocre); border: none; border-radius: 6px;
    width: 36px; height: 36px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #FFF; transition: background 0.2s;
}
.search-btn:hover { background: var(--c-cuir); }
.search-hint {
    font-size: 12px; color: var(--c-text-light);
    margin-top: 8px; text-align: center;
}

/* Autocomplete */
.autocomplete-list {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--c-card-bg); border: 1px solid var(--c-border);
    border-radius: 0 0 8px 8px; max-height: 300px; overflow-y: auto;
    display: none; z-index: 100;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
    padding: 10px 16px; cursor: pointer;
    font-size: 14px; border-bottom: 1px solid var(--c-border);
}
.autocomplete-item:hover, .autocomplete-item.active {
    background: #F5EFE3;
}
body.dark .autocomplete-item:hover,
body.dark .autocomplete-item.active { background: #3D2B1F; }

/* ── Proverbe Card ─────────────────────────────────────────────── */

.prov-card {
    background: var(--c-card-bg); border: 1px solid var(--c-border);
    border-radius: 10px; padding: 20px 22px; margin-bottom: 14px;
    position: relative; transition: border-color 0.2s;
}
.prov-card:hover { border-color: var(--c-ocre); }

.prov-card .guillemet {
    position: absolute; top: 8px; left: 14px;
    font-size: 42px; color: var(--c-ocre); opacity: 0.3;
    font-family: var(--font-display); line-height: 1;
    pointer-events: none;
}

.prov-card .prov-text {
    font-family: var(--font-display); font-size: 17px;
    font-style: italic; line-height: 1.7;
    color: var(--c-text); padding-left: 28px; margin-bottom: 10px;
}

.prov-card .prov-origin {
    font-size: 12px; color: var(--c-text-light); text-align: right;
    font-weight: 500; letter-spacing: 0.8px; text-transform: uppercase;
}
.prov-card .prov-origin a { color: var(--c-text-light); }
.prov-card .prov-origin a:hover { color: var(--c-ocre); }

.prov-card .prov-meta {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 6px;
}

.prov-card .prov-latin {
    font-size: 12px; color: var(--c-ocre); font-style: normal;
    margin-top: 6px; padding-left: 28px; opacity: 0.8;
}

.dicocit-link {
    font-size: 11px; color: var(--c-ocre); opacity: 0.7;
    display: inline-flex; align-items: center; gap: 4px;
    transition: opacity 0.2s;
}
.dicocit-link:hover { opacity: 1; text-decoration: none; }

/* Featured proverbe (dark bg) */
.prov-featured {
    background: #3D2B1F; border-radius: 10px;
    padding: 24px 22px; margin-bottom: 20px; position: relative;
}
.prov-featured .guillemet {
    position: absolute; top: 8px; left: 14px;
    font-size: 42px; color: var(--c-ocre); opacity: 0.5;
    font-family: var(--font-display); line-height: 1;
}
.prov-featured .prov-text {
    font-family: var(--font-display); font-size: 18px;
    font-style: italic; line-height: 1.7;
    color: #FAF6EF; padding-left: 28px; margin-bottom: 10px;
}
.prov-featured .prov-origin {
    font-size: 12px; color: var(--c-ocre); text-align: right;
    font-weight: 500; letter-spacing: 0.8px; text-transform: uppercase;
}

/* ── Stats ──────────────────────────────────────────────────────── */

.stats-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 10px; margin-bottom: 24px;
}
.stat-card {
    background: var(--c-card-bg); border: 1px solid var(--c-border);
    border-radius: 8px; padding: 14px; text-align: center;
}
.stat-num {
    font-family: var(--font-display); font-size: 26px;
    font-weight: 500; color: var(--c-ocre);
}
.stat-label { font-size: 11px; color: var(--c-text-light); margin-top: 2px; }

/* ── Section titles ────────────────────────────────────────────── */

.section-title {
    font-family: var(--font-display); font-size: 18px;
    font-weight: 500; color: var(--c-text); margin-bottom: 14px;
    display: flex; align-items: center; gap: 10px;
}
.section-title .line { flex: 1; height: 1px; background: var(--c-border); }

/* ── Origins grid ──────────────────────────────────────────────── */

.origins-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px; margin-bottom: 24px;
}
.origin-pill {
    display: flex; align-items: center; gap: 8px;
    background: var(--c-card-bg); border: 1px solid var(--c-border);
    border-radius: 8px; padding: 10px 14px;
    font-size: 14px; color: var(--c-text);
    text-decoration: none; transition: border-color 0.2s;
}
.origin-pill:hover { border-color: var(--c-ocre); text-decoration: none; }
.origin-pill .count {
    margin-left: auto; color: var(--c-ocre);
    font-weight: 500; font-size: 12px;
}
.origin-pill svg { flex-shrink: 0; color: var(--c-ocre); }

/* ── Sidebar ───────────────────────────────────────────────────── */

.sb-title {
    font-family: var(--font-display); font-size: 15px;
    font-weight: 500; color: var(--c-text); margin-bottom: 10px;
    padding-bottom: 8px; border-bottom: 1px solid var(--c-border);
    display: flex; align-items: center; gap: 6px;
}
.sb-title svg { color: var(--c-ocre); flex-shrink: 0; }

.sb-block { margin-bottom: 20px; }

.sb-alpha {
    display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px;
}
.sb-alpha a {
    width: 28px; height: 28px; display: flex;
    align-items: center; justify-content: center;
    font-size: 12px; font-weight: 500; border-radius: 4px;
    border: 1px solid var(--c-border); color: var(--c-text-light);
    text-decoration: none; transition: all 0.2s;
}
.sb-alpha a:hover, .sb-alpha a.active {
    background: #3D2B1F; color: #FAF6EF; border-color: #3D2B1F;
}
body.dark .sb-alpha a:hover,
body.dark .sb-alpha a.active { background: var(--c-ocre); color: #1C1410; }

/* Cross-linking network block */
.net-block {
    background: var(--c-card-bg); border: 1px solid var(--c-border);
    border-radius: 10px; padding: 16px;
}
.net-block .net-title {
    font-family: var(--font-display); font-size: 14px;
    font-weight: 500; margin-bottom: 10px;
    display: flex; align-items: center; gap: 6px;
}
.net-link {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--c-text-light);
    padding: 4px 0; text-decoration: none;
}
.net-link:hover { color: var(--c-ocre); }
.net-link svg { flex-shrink: 0; width: 14px; height: 14px; color: var(--c-ocre); }

/* ── Pagination ────────────────────────────────────────────────── */

.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 4px; margin: 24px 0; flex-wrap: wrap;
}
.page-link {
    min-width: 36px; height: 36px; display: flex;
    align-items: center; justify-content: center;
    border: 1px solid var(--c-border); border-radius: 6px;
    font-size: 13px; color: var(--c-text); background: var(--c-card-bg);
    text-decoration: none; padding: 0 10px;
    transition: all 0.2s; cursor: pointer;
}
.page-link:hover { border-color: var(--c-ocre); color: var(--c-ocre); text-decoration: none; }
.page-link.active {
    background: #3D2B1F; color: #FAF6EF; border-color: #3D2B1F;
}
body.dark .page-link.active { background: var(--c-ocre); color: #1C1410; }
.page-dots { color: var(--c-text-light); padding: 0 4px; }

/* ── Footer ────────────────────────────────────────────────────── */

.site-footer {
    background: #3D2B1F; color: #D4C4AA; margin-top: 40px;
    border-top: 2px solid var(--c-ocre);
}
.footer-inner { max-width: var(--max-w); margin: 0 auto; padding: 32px 20px; }
.footer-top {
    display: grid; grid-template-columns: 1fr 1fr 1fr;
    gap: 24px; margin-bottom: 24px;
    padding-bottom: 20px; border-bottom: 1px solid #5C4A3A;
}
.footer-logo {
    font-family: var(--font-display); font-size: 20px;
    font-weight: 500; color: #FAF6EF;
}
.footer-logo span { color: var(--c-ocre); }
.footer-tagline { font-size: 12px; margin-top: 4px; color: #8B6F4E; }
.footer-links { display: flex; flex-direction: column; gap: 6px; }
.footer-links a { color: #D4C4AA; font-size: 13px; }
.footer-links a:hover { color: #FAF6EF; }
.footer-net-label { font-size: 12px; font-weight: 500; color: #8B6F4E; display: block; margin-bottom: 6px; }
.footer-network a { display: inline; color: #D4C4AA; font-size: 13px; margin-right: 12px; }
.footer-network a:hover { color: #FAF6EF; }
.footer-bottom { font-size: 11px; color: #8B6F4E; }
.footer-bottom p { margin-bottom: 4px; }
.footer-contact { margin-top: 4px; }

/* ── Ad slots ──────────────────────────────────────────────────── */

.ad-slot { margin: 16px 0; min-height: 90px; }

/* ── Liens page ────────────────────────────────────────────────── */

.liens-counters {
    display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap;
}
.liens-counter {
    background: var(--c-card-bg); border: 1px solid var(--c-border);
    border-radius: 8px; padding: 10px 16px; text-align: center; flex: 1;
    min-width: 100px;
}
.liens-counter .num {
    font-family: var(--font-display); font-size: 22px;
    font-weight: 500; color: var(--c-ocre);
}
.liens-counter .lbl { font-size: 11px; color: var(--c-text-light); }

.liens-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px; margin-bottom: 20px;
}
.lien-item {
    background: var(--c-card-bg); border: 1px solid var(--c-border);
    border-radius: 8px; padding: 12px 16px;
}
.lien-item a {
    font-weight: 500; font-size: 14px; display: block; margin-bottom: 2px;
}
.lien-item .lien-desc { font-size: 12px; color: var(--c-text-light); }
.lien-item.lien-current {
    border-color: var(--c-ocre); background: var(--c-bg);
}

/* ── A propos ──────────────────────────────────────────────────── */

.apropos-content {
    max-width: 700px; margin: 0 auto;
}
.apropos-content h2 {
    font-family: var(--font-display); font-size: 22px;
    font-weight: 500; margin: 28px 0 12px;
}
.apropos-content p { margin-bottom: 14px; }

/* ── 404 ───────────────────────────────────────────────────────── */

.page-404 { text-align: center; padding: 60px 20px; }
.page-404 h1 {
    font-family: var(--font-display); font-size: 72px;
    color: var(--c-ocre); font-weight: 500;
}
.page-404 p { font-size: 16px; color: var(--c-text-light); margin: 12px 0 24px; }

/* ── Print ─────────────────────────────────────────────────────── */

@media print {
    .site-header, .nav-mobile, .breadcrumb, .page-sidebar,
    .ad-slot, .site-footer, .pagination, .search-wrap,
    .skip-link, .burger, .toggle-theme { display: none !important; }
    body { background: #fff; color: #000; font-size: 12pt; }
    .prov-card { border: 1px solid #ccc; break-inside: avoid; }
}

/* ── Reduced motion ────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── CSS contain ───────────────────────────────────────────────── */

.origins-grid, .liens-grid, .prov-card { contain: layout style; }

/* ── Responsive ────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .page-wrap { flex-direction: column; gap: 24px; }
    .page-sidebar {
        width: 100%; position: static;
        max-height: none; overflow: visible;
    }
    .footer-top { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
    html { overflow-x: hidden; }
    .nav-desktop { display: none; }
    .burger { display: flex; }
    .hero { padding: 24px 16px 20px; }
    .hero h1 { font-size: 22px; }
    .hero .subtitle { font-size: 13px; }
    .page-wrap { padding: 16px 12px; gap: 20px; }
    .page-full { padding: 16px 12px; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .stat-card { padding: 10px 6px; }
    .stat-num { font-size: 22px; }
    .origins-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .prov-card { padding: 14px 14px 14px 16px; margin-bottom: 10px; }
    .prov-card .prov-text { font-size: 15px; padding-left: 18px; }
    .prov-card .guillemet { font-size: 30px; left: 10px; }
    .prov-featured { padding: 18px 16px; }
    .prov-featured .prov-text { font-size: 16px; padding-left: 22px; }
    .search-wrap input { font-size: 16px; padding: 14px 48px 14px 14px; }
    .section-title { font-size: 16px; }

    /* Touch targets minimum 44px sur mobile */
    .nav-mobile a { min-height: 48px; display: flex; align-items: center; }
    .search-btn { width: 44px; height: 44px; right: 2px; }
    .page-link { min-width: 44px; height: 44px; font-size: 13px; }
    .origin-pill { min-height: 48px; padding: 12px 14px; }
    .sb-alpha a { width: 40px; height: 40px; font-size: 14px; }
    .breadcrumb { padding: 8px 12px; }
    .breadcrumb ol { font-size: 11px; }
    .net-link { min-height: 44px; padding: 8px 0; }
    .footer-inner { padding: 24px 12px; }
    .footer-network a { display: block; padding: 4px 0; }
    .liens-grid { grid-template-columns: 1fr; }
    .lien-item a { min-height: 44px; display: flex; align-items: center; }
}

@media (max-width: 480px) {
    .origins-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
    .stat-num { font-size: 20px; }
    .stat-label { font-size: 10px; }
    .sb-alpha { gap: 3px; }
    .sb-alpha a { width: 36px; height: 36px; font-size: 13px; }
    .hero h1 { font-size: 20px; }
    .liens-counters { flex-direction: column; gap: 8px; }
    .pagination { gap: 3px; }
    .page-link { min-width: 40px; height: 40px; padding: 0 8px; }
}
