/*
Theme Name: Seliweb View
Theme URI: https://github.com/seliweb
Description: Thème front-end pour le plugin Seliweb - Système d'Échange Local
Version: 0.8.12
Author: Philippe Le Duigou
Text Domain: seliweb-view
*/

/* ================================================================
   RESET & BASE
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-primary:    #1d6a4a;
    --color-primary-dk: #134d35;
    --color-accent:     #e8a020;
    --color-accent-lt:  #fdf3e0;
    --color-text:       #222;
    --color-text-soft:  #555;
    --color-border:     #dde3dd;
    --color-bg:         #f4f6f4;
    --color-white:      #fff;
    --color-header-bg:  #1d6a4a;
    --color-footer-bg:  #134d35;
    --color-nav-bg:      #134d35;
    --color-nav-text:    rgba(255,255,255,.85);
    --color-header-text: #fff;
    --color-h1:          #1d6a4a;
    --color-h2:          #222;
    --color-tag-cat-bg:      #e0ede7;
    --color-tag-cat-text:    #1d6a4a;
    --color-tag-type-bg:     #e8f0fe;
    --color-tag-type-text:   #1a56a0;
    --color-tag-rubrique-bg: #fef3e2;
    --color-tag-rubrique-text: #8a5100;
    --color-statut:      #5a5a9a;
    --color-don:         #1d6a4a;
    --radius:           6px;
    --shadow:           0 2px 10px rgba(0,0,0,.08);
    --container:        1200px;
    --sidebar-w:        280px;
    --font-title:       'Merriweather', Georgia, serif;
    --font-body:        'Source Sans 3', 'Segoe UI', sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

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

.swv-container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

/* ================================================================
   BANNIÈRE (header)
   ================================================================ */
#swv-header {
    background: var(--color-header-bg);
    color: var(--color-white);
    position: relative;
}

.swv-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 120px;
    padding: 16px 20px;
    max-width: var(--container);
    margin: 0 auto;
    gap: 20px;
}

/* Bannière image de fond */
#swv-header.has-banner {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
#swv-header.has-banner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
}
#swv-header.has-banner .swv-header-inner {
    position: relative;
    z-index: 1;
}

/* Logo + titre */
.swv-site-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.swv-site-logo img {
    height: 96px;
    width: auto;
    border-radius: var(--radius);
}

.swv-site-logo-placeholder {
    width: 96px;
    height: 96px;
    background: rgba(255,255,255,.15);
    border: 2px solid rgba(255,255,255,.3);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: rgba(255,255,255,.7);
}

.swv-site-title {
    font-family: var(--font-title);
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    font-weight: 700;
    color: var(--color-header-text);
    line-height: 1.2;
    text-shadow: 0 1px 3px rgba(0,0,0,.3);
}

.swv-site-desc {
    font-size: .9rem;
    color: var(--color-header-text);
    opacity: .75;
    margin-top: 4px;
}

/* Bouton connexion */
.swv-login-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--color-white);
    text-decoration: none;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.25);
    transition: background .2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.swv-login-btn:hover {
    background: rgba(255,255,255,.22);
    text-decoration: none;
    color: var(--color-white);
}

.swv-login-icon {
    width: 36px;
    height: 36px;
}

.swv-login-label {
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}

/* ================================================================
   NAVIGATION PRINCIPALE (optionnelle)
   ================================================================ */
#swv-nav {
    background: var(--color-nav-bg);
    border-bottom: 2px solid var(--color-accent);
}

.swv-nav-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    min-height: 44px;
}

#swv-nav ul {
    list-style: none;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

#swv-nav ul li a {
    display: block;
    padding: 10px 14px;
    color: var(--color-nav-text);
    font-size: .9rem;
    font-weight: 500;
    border-radius: 3px;
    transition: background .15s, color .15s;
}
#swv-nav ul li a:hover,
#swv-nav ul li.current-menu-item > a {
    background: rgba(255,255,255,.12);
    color: var(--color-white);
    text-decoration: none;
}

/* Sous-menus (dépôt de niveau 2) — en colonne dans tous les cas (repris
   tel quel en mobile, où le sous-menu reste dans le flux normal, juste
   indenté). Le survol/repliage en menu déroulant n'est activé qu'en
   version bureau, ci-dessous. */
#swv-nav ul ul.sub-menu {
    flex-direction: column;
    gap: 0;
}

/* Ancrage du menu déroulant : chaque <li> devient le référentiel de
   positionnement de son sous-menu (sans effet en mobile, où le
   sous-menu n'est pas positionné en absolu). */
#swv-nav ul li {
    position: relative;
}

/* Version bureau uniquement : le sous-menu est masqué et positionné en
   superposition, affiché au survol ou au focus clavier (Tab) du lien
   parent. Un fond opaque est nécessaire car le sous-menu se superpose
   au contenu de la page en dessous (position:absolute), qui serait
   sinon visible par transparence à travers les liens. */
@media (min-width: 783px) {
    #swv-nav ul ul.sub-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 100%;
        width: max-content;
        background: var(--color-nav-bg);
        border-bottom: 2px solid var(--color-accent);
        z-index: 1000;
    }

    #swv-nav ul li:hover > ul.sub-menu,
    #swv-nav ul li:focus-within > ul.sub-menu {
        display: flex;
    }
}

/* Bouton hamburger — masqué en version bureau */
.swv-nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    padding: 0;
    margin-right: 4px;
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}
.swv-nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-nav-text);
    border-radius: 2px;
    transition: transform .2s ease, opacity .2s ease;
}
.swv-nav-toggle:hover span { background: var(--color-white); }

/* Version mobile : bouton visible, menu replié par défaut.
   Sélecteurs à deux ID (#swv-nav #swv-nav-menu) : la règle générale
   "#swv-nav ul { display:flex }" plus haut a pour spécificité 1 ID + 1
   balise, donc un simple "#swv-nav-menu { display:none }" (1 ID) ne
   suffisait pas à la contredire — le menu restait visible en permanence
   quel que soit l'état du bouton. */
@media (max-width: 782px) {
    .swv-nav-inner { flex-wrap: wrap; }
    .swv-nav-toggle { display: flex; }

    #swv-nav #swv-nav-menu {
        display: none;
        flex-direction: column;
        gap: 0;
        flex-basis: 100%;
        width: 100%;
        padding: 6px 0 10px;
    }
    #swv-nav #swv-nav-menu.is-open { display: flex; }

    #swv-nav #swv-nav-menu li { width: 100%; }
    #swv-nav #swv-nav-menu li a { padding: 12px 6px; }

    #swv-nav #swv-nav-menu ul.sub-menu {
        padding-left: 16px;
    }

    /* Bouton transformé en croix quand le menu est ouvert */
    .swv-nav-toggle.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
    .swv-nav-toggle.is-open span:nth-child(2) { opacity: 0; }
    .swv-nav-toggle.is-open span:nth-child(3) { opacity: 0; }
    .swv-nav-toggle.is-open span:nth-child(4) { transform: translateY(-6px) rotate(-45deg); }
}

/* ================================================================
   PIED DE PAGE
   ================================================================ */
#swv-footer {
    background: var(--color-footer-bg);
    color: rgba(255,255,255,.8);
    padding: 32px 0 16px;
    margin-top: auto;
}

.swv-footer-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

.swv-footer-widgets {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px 56px;
    margin-bottom: 24px;
}

.swv-footer-widget-col { min-width: 150px; }

.swv-footer-widget-col .widget-title {
    font-family: var(--font-title);
    font-size: .9rem;
    font-weight: 700;
    color: var(--color-white);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 10px;
}

.swv-footer-widget-col ul { list-style: none; margin: 0; padding: 0; }
.swv-footer-widget-col ul li { margin-bottom: 6px; }
.swv-footer-widget-col a {
    color: rgba(255,255,255,.7);
    font-size: .88rem;
    transition: color .15s;
}
.swv-footer-widget-col a:hover { color: var(--color-white); text-decoration: none; }

.swv-footer-bottom {
    border-top: 1px solid rgba(255,255,255,.12);
    padding-top: 14px;
    font-size: .8rem;
    color: rgba(255,255,255,.5);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

/* ================================================================
   PAGE UNIQUE (single / page)
   ================================================================ */
.swv-content {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 28px 32px;
}

.swv-content h1, .swv-content h2, .swv-content h3 {
    font-family: var(--font-title);
    margin-bottom: .6em;
}
.swv-content h1 { color: var(--color-h1); }
.swv-content h2 { color: var(--color-h2); }

.swv-content p { margin-bottom: 1em; }

/* ================================================================
   PAGES DE CATÉGORIES
   ================================================================ */
.swv-category-wrap {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.swv-category-wrap h1 {
    font-family: var(--font-title);
    font-size: 2rem;
    color: var(--color-h1);
    margin-bottom: 20px;
    text-align: center;
}

.swv-posts-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.swv-post-item {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.swv-post-item h2 {
    font-family: var(--font-title);
    font-size: 1.25rem;
    margin-bottom: 10px;
}

.swv-post-item h2 a {
    color: var(--color-h2);
    text-decoration: none;
}

.swv-post-item h2 a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.swv-post-meta {
    font-size: .85rem;
    color: var(--color-text-soft);
    margin-bottom: 10px;
}

.swv-post-excerpt {
    color: var(--color-text);
    line-height: 1.6;
}

/* ================================================================
   FAQ — bloc « Détails » natif (questions repliables)
   Fonctionne sur tout bloc Détails ; le motif « FAQ — questions
   repliables » les regroupe dans .swv-faq.
   ================================================================ */
.wp-block-details {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-white);
    margin: 0 0 10px;
    padding: 0 16px;
    overflow: hidden;
}

.wp-block-details > summary {
    margin: 0 -16px;
    padding: 14px 44px 14px 16px;
    position: relative;
    list-style: none;
    cursor: pointer;
    font-family: var(--font-title);
    font-weight: 700;
    color: var(--color-primary);
}
.wp-block-details > summary::-webkit-details-marker { display: none; }
.wp-block-details > summary:hover { background: var(--color-accent-lt); }
.wp-block-details > summary:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

.wp-block-details > summary::after {
    content: "";
    position: absolute;
    right: 18px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-70%) rotate(45deg);
    transition: transform .15s ease;
}
.wp-block-details[open] > summary::after {
    transform: translateY(-30%) rotate(225deg);
}

.wp-block-details[open] > summary {
    margin-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}
.wp-block-details > *:not(summary) {
    color: var(--color-text);
    line-height: 1.6;
}
.wp-block-details > *:last-child { margin-bottom: 14px; }

.swv-faq {
    max-width: 760px;
    margin: 0 auto;
}
.swv-faq > h2 {
    font-family: var(--font-title);
    color: var(--color-h1);
    margin-bottom: 16px;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 600px) {
    .swv-header-inner { flex-wrap: wrap; min-height: auto; }
    .swv-footer-widgets { flex-direction: column; gap: 20px; }
    .swv-footer-bottom { flex-direction: column; }
}
