/**
 * Permathèque — Rendu front-end des blocs Editor.js (BlockRenderer PHP)
 *
 * Toutes les classes sont préfixées `ph-` pour ne jamais interférer avec
 * l'existant. Ces styles s'appliquent au HTML généré par BlockRenderer
 * quand une page/post a un `content_blocks` non-null.
 *
 * Philosophie :
 *  - Utilise les tokens CSS existants (--primary, --color-text, --color-border…)
 *  - Dark mode via variables (aucun selector .dark-mode ajouté ici)
 *  - Responsive par défaut, fallback gracieux sans JS
 */

/* ================== wrapper générique ================== */

.ph-block {
    margin: 1.2em 0;
}

.ph-block--delimiter {
    text-align: center;
    margin: 2em 0;
}

.ph-block hr.ph-delimiter {
    border: 0;
    border-top: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
    width: 60%;
    margin: 0 auto;
}

/* ================== anchor (point d'ancrage invisible) ================== */

.ph-block--anchor {
    margin: 0;
    padding: 0;
    height: 0;
    line-height: 0;
    overflow: hidden;
}

.ph-anchor {
    display: block;
    width: 0;
    height: 0;
    scroll-margin-top: var(--anchor-scroll-offset, 90px);
    visibility: hidden;
}

/* ================== header (h1..h6) ================== */

.ph-block--header h1,
.ph-block--header h2,
.ph-block--header h3,
.ph-block--header h4,
.ph-block--header h5,
.ph-block--header h6 {
    margin: 0.6em 0 0.4em;
}

/* ================== list ================== */

.ph-block--list ul,
.ph-block--list ol {
    margin: 0.3em 0 0.8em 1.2em;
    padding-left: 1em;
}

.ph-block--list li {
    margin: 0.15em 0;
    line-height: 1.6;
}

/* ================== quote ================== */

.ph-quote {
    margin: 1.2em 0;
    padding: 1em 1.4em;
    background: var(--color-surface-alt, rgba(107, 142, 78, 0.06));
    border-left: 4px solid var(--color-accent, #6b8e4e);
    border-radius: 6px;
    font-style: italic;
}

.ph-quote p { margin: 0 0 0.4em; }

.ph-quote footer {
    font-style: normal;
    font-size: 0.9em;
    color: var(--color-muted, #7b7565);
}

.ph-quote--center { text-align: center; }
.ph-quote--right  { text-align: right; }

/* ================== code ================== */

.ph-block--code pre {
    background: var(--color-surface-alt, #f4f1e6);
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
    border-radius: 6px;
    padding: 0.9em 1.1em;
    overflow-x: auto;
    font-family: var(--font-mono, 'SFMono-Regular', Menlo, monospace);
    font-size: 0.88em;
    line-height: 1.5;
}

/* ================== image ================== */

.ph-img {
    display: block;
    margin: 1.2em auto;
    max-width: 100%;
}

.ph-img img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.ph-img figcaption {
    text-align: center;
    font-size: 0.88em;
    color: var(--color-muted, #7b7565);
    margin-top: 0.5em;
}

.ph-img--s    img { max-width: 320px; margin: 0 auto; }
.ph-img--m    img { max-width: 600px; margin: 0 auto; }
.ph-img--l    img { max-width: 900px; margin: 0 auto; }
.ph-img--full img { width: 100%; }

.ph-img--border img { border: 1px solid var(--color-border, rgba(0, 0, 0, 0.15)); }
.ph-img--shadow img { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); }
.ph-img--stretched { margin-left: -5%; margin-right: -5%; }

/* ================== embed ================== */

.ph-embed {
    margin: 1.4em 0;
}

.ph-embed__frame {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.ph-embed__frame iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.ph-embed figcaption {
    margin-top: 0.5em;
    text-align: center;
    font-size: 0.88em;
    color: var(--color-muted, #7b7565);
}

/* ================== video / audio ================== */

.ph-video,
.ph-audio {
    margin: 1.4em 0;
}

.ph-video video,
.ph-audio audio {
    display: block;
    width: 100%;
    max-width: 100%;
}

.ph-video figcaption,
.ph-audio figcaption {
    margin-top: 0.5em;
    text-align: center;
    font-size: 0.88em;
    color: var(--color-muted, #7b7565);
}

/* ================== table ================== */

.ph-table-wrap {
    overflow-x: auto;
    margin: 1.2em 0;
}

.ph-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.ph-table th,
.ph-table td {
    padding: 0.6em 0.9em;
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
    text-align: left;
}

.ph-table thead th {
    background: var(--color-surface-alt, rgba(107, 142, 78, 0.08));
    font-weight: 600;
}

/* ================== columns ================== */

.ph-columns {
    display: grid;
    gap: 1.2em;
    margin: 1.4em 0;
}

.ph-columns--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ph-columns--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ph-columns--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.ph-column { min-width: 0; }

@media (max-width: 720px) {
    .ph-columns--2,
    .ph-columns--3,
    .ph-columns--4 { grid-template-columns: 1fr; }
}

/* ================== hero ================== */

.ph-hero {
    position: relative;
    padding: clamp(2em, 6vw, 4em) 1.6em;
    margin: 1.6em 0;
    background: var(--color-surface-alt, rgba(107, 142, 78, 0.08));
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.ph-hero__inner {
    max-width: 780px;
    margin: 0 auto;
}

.ph-hero--align-left   { text-align: left; }
.ph-hero--align-center { text-align: center; }
.ph-hero--align-right  { text-align: right; }

.ph-hero__title {
    font-size: clamp(1.6rem, 3vw, 2.6rem);
    margin: 0 0 0.4em;
    line-height: 1.15;
}

.ph-hero__subtitle {
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    opacity: 0.95;
    margin: 0 0 1em;
}

.ph-hero__cta {
    display: inline-block;
    margin-top: 0.3em;
}

/* ================== button ================== */

.ph-btn-wrap {
    margin: 1em 0;
}

.ph-btn-wrap--left   { text-align: left; }
.ph-btn-wrap--center { text-align: center; }
.ph-btn-wrap--right  { text-align: right; }

.ph-btn {
    display: inline-block;
    padding: 0.7em 1.4em;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    line-height: 1.2;
    transition: filter 0.15s ease, transform 0.15s ease;
}

.ph-btn--sm { padding: 0.4em 0.9em; font-size: 0.9em; }
.ph-btn--lg { padding: 0.9em 1.8em; font-size: 1.1em; }

.ph-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ================== callout ================== */

.ph-callout {
    display: block;
    padding: 0.9em 1.1em;
    margin: 1.2em 0;
    border-radius: 8px;
    border-left: 4px solid var(--color-accent, #6b8e4e);
    background: var(--color-surface-alt, rgba(107, 142, 78, 0.08));
}

.ph-callout--info    { border-left-color: #4a90d9; background: rgba(74, 144, 217, 0.08); }
.ph-callout--warning { border-left-color: #e0a23c; background: rgba(224, 162, 60, 0.08); }
.ph-callout--success { border-left-color: #5cb85c; background: rgba(92, 184, 92, 0.08); }
.ph-callout--error   { border-left-color: #d9534f; background: rgba(217, 83, 79, 0.08); }

.ph-callout__title {
    margin: 0 0 0.4em;
    font-weight: 700;
}

.ph-callout__body { margin: 0; }
.ph-callout__body > *:last-child { margin-bottom: 0; }

/* ================== accordion ================== */

.ph-accordion {
    margin: 1.2em 0;
}

.ph-accordion__item {
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
    border-radius: 6px;
    margin-bottom: 0.5em;
    padding: 0.2em 0.8em;
}

.ph-accordion__title {
    padding: 0.6em 0;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.ph-accordion__body {
    padding: 0.2em 0 0.8em;
    border-top: 1px solid var(--color-border, rgba(0, 0, 0, 0.1));
}

/* ================== gallery ================== */

.ph-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin: 1.4em 0;
}

.ph-gallery__item {
    margin: 0;
}

.ph-gallery__item img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

/* ================== entity-card ================== */

.ph-entity-card {
    display: block;
    padding: 0.9em 1.1em;
    margin: 1em 0;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
    border-radius: 8px;
    color: var(--color-text, #2c2c2c);
}

/* ================== map-point ================== */

.ph-map-point {
    display: block;
    padding: 0.9em 1.1em;
    margin: 1em 0;
    background: var(--color-surface-alt, rgba(107, 142, 78, 0.06));
    border: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
    border-radius: 8px;
}

.ph-map-point__title {
    margin: 0 0 0.3em;
    font-weight: 600;
}

/* ================== raw (HTML sanitizé) ================== */

.ph-block--raw > * {
    max-width: 100%;
}
