/*
Theme Name: Mehdi Mouslim
Description: Thème académique sobre et trilingue (FR / EN / AR) pour le site de Dr Mehdi Mouslim. Compatible Polylang, prise en charge de l'arabe de droite à gauche.
Version: 1.0.0
Requires at least: 6.4
Requires PHP: 8.0
Text Domain: mehdi-mouslim
License: GPL-2.0-or-later
*/

/* ---------- Polices (hébergées dans le thème, aucun appel à Google) ---------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("assets/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("assets/fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Noto Sans Arabic";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("assets/fonts/noto-sans-arabic-arabic-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

/* ---------- Jetons ---------- */
:root {
  --navy: #183153;
  --navy-deep: #0f2240;
  --navy-soft: #2a4a75;
  --white: #ffffff;
  --paper: #f6f7f9;
  --tint: #eef2f7;
  --ink: #16202e;
  --muted: #5a6677;
  --line: #e2e7ee;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 34, 64, .04), 0 8px 24px rgba(15, 34, 64, .06);
  --wrap: 1120px;
  --read: 720px;
  --gutter: clamp(16px, 4vw, 40px);
  --font: "Inter", "Noto Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ar: "Noto Sans Arabic", "Inter", system-ui, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
:lang(ar) body, body:lang(ar) { font-family: var(--font-ar); font-size: 18px; line-height: 1.9; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--navy); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--navy-soft); }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3, h4 { color: var(--navy); line-height: 1.2; letter-spacing: -0.02em; font-weight: 650; margin: 0 0 .6em; }
:lang(ar) h1, :lang(ar) h2, :lang(ar) h3 { letter-spacing: 0; line-height: 1.4; }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); font-weight: 700; letter-spacing: -0.035em; }
h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1.2em; }
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; inset-inline-start: 16px; top: -60px; z-index: 100; background: var(--navy); color: var(--white); padding: 10px 16px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 12px; color: var(--white); }

/* ---------- En-tête ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
.site-header.is-scrolled { border-bottom-color: var(--line); }
.admin-bar .site-header { top: 32px; }
.header-inner { display: flex; align-items: center; gap: 24px; height: 72px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--navy); margin-inline-end: auto; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: var(--navy); color: var(--white); font-weight: 700; font-size: 15px; letter-spacing: .02em;
}
.brand-name { font-weight: 650; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; }
.primary-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.primary-nav a {
  display: block; padding: 8px 14px; border-radius: 999px;
  color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.primary-nav a:hover { background: var(--tint); color: var(--navy); }
.primary-nav .current-menu-item > a, .primary-nav .current_page_item > a { background: var(--navy); color: var(--white); }
.lang-switch { list-style: none; display: flex; gap: 2px; margin: 0; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.lang-switch a { display: block; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; text-decoration: none; color: var(--muted); text-transform: uppercase; }
.lang-switch a:hover { color: var(--navy); }
.lang-switch .current-lang a { background: var(--tint); color: var(--navy); }
.menu-toggle {
  display: none; align-items: center; justify-content: center; width: 44px; height: 44px;
  background: none; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--navy);
}
.menu-toggle svg { width: 20px; height: 20px; }

@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .primary-nav {
    position: fixed; inset: 72px 0 auto 0; background: var(--white);
    border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
    padding: 12px var(--gutter) 20px; display: none;
  }
  .admin-bar .primary-nav { top: 118px; }
  .primary-nav.is-open { display: block; }
  .primary-nav ul { flex-direction: column; gap: 2px; }
  .primary-nav a { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 17px; }
  .brand-name { font-size: 16px; }
}
@media (max-width: 782px) { .admin-bar .site-header { top: 46px; } }

/* ---------- Accueil : héros ---------- */
.hero { position: relative; overflow: hidden; padding-block: clamp(48px, 9vw, 112px) clamp(48px, 7vw, 96px); }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(60rem 30rem at 85% -10%, var(--tint), transparent 60%),
    linear-gradient(var(--white), var(--white));
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: clamp(32px, 6vw, 80px); align-items: center; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 22px;
  font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--navy-soft);
}
:lang(ar) .hero-eyebrow { letter-spacing: 0; }
.hero-eyebrow::before { content: ""; width: 28px; height: 2px; background: var(--navy); }
.hero h1 { margin-bottom: 14px; }
.hero-tagline { font-size: clamp(1.1rem, 1.8vw, 1.3rem); color: var(--navy-soft); font-weight: 500; margin-bottom: 26px; }
.hero-bio { color: var(--muted); font-size: 1.05rem; max-width: 60ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 13px 22px; border-radius: 999px;
  font-weight: 600; font-size: 15px; text-decoration: none; transition: transform .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-deep); color: var(--white); transform: translateY(-1px); }
.btn-ghost { border: 1px solid var(--line); color: var(--navy); background: var(--white); }
.btn-ghost:hover { border-color: var(--navy); color: var(--navy); }
.btn svg { width: 16px; height: 16px; }
[dir="rtl"] .btn svg { transform: scaleX(-1); }
.portrait { position: relative; justify-self: end; width: 100%; max-width: 380px; }
[dir="rtl"] .portrait { justify-self: start; }
.portrait::before {
  content: ""; position: absolute; inset: 18px -18px -18px 18px; border-radius: 24px;
  border: 1px solid var(--line); background: var(--paper); z-index: -1;
}
[dir="rtl"] .portrait::before { inset: 18px 18px -18px -18px; }
.portrait img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 24px; box-shadow: var(--shadow); }

@media (max-width: 820px) {
  .hero-grid { grid-template-columns: 1fr; }
  .portrait { justify-self: start; max-width: 190px; order: -1; }
  .portrait::before { inset: 10px -10px -10px 10px; border-radius: 18px; }
  [dir="rtl"] .portrait::before { inset: 10px 10px -10px -10px; }
  .portrait img { border-radius: 18px; }
}

/* ---------- Sections ---------- */
.section { padding-block: clamp(48px, 7vw, 88px); }
.section-alt { background: var(--paper); border-block: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 28px; }

/* ---------- En-tête de page ---------- */
.page-hero { padding-block: clamp(48px, 7vw, 88px) clamp(28px, 4vw, 44px); background: linear-gradient(var(--paper), var(--white)); border-bottom: 1px solid var(--line); }
.page-hero h1 { font-size: clamp(2rem, 4.4vw, 3rem); margin-bottom: 10px; }
.page-lead { color: var(--muted); font-size: 1.1rem; max-width: 62ch; margin: 0; }
.breadcrumb { font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--navy); }

/* ---------- Contenu éditorial ---------- */
.entry { padding-block: clamp(36px, 5vw, 64px) clamp(56px, 8vw, 96px); }
.entry-content > * { max-width: var(--read); margin-inline: auto; }
.entry-content > .alignwide { max-width: var(--wrap); }
.entry-content > .alignfull { max-width: none; }
.entry-content h2 {
  margin-top: 2.4em; padding-top: 1.2em; border-top: 1px solid var(--line);
  font-size: clamp(1.35rem, 2.2vw, 1.7rem);
}
.entry-content > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.entry-content h3 { margin-top: 1.8em; }
.entry-content ul, .entry-content ol { padding-inline-start: 1.25em; margin-block: 0 1.4em; }
.entry-content li { margin-bottom: .45em; }
.entry-content li::marker { color: var(--navy-soft); }
.entry-content strong { color: var(--navy); font-weight: 650; }
.entry-content blockquote { margin: 1.6em auto; padding: 4px 0 4px 22px; border-inline-start: 3px solid var(--navy); color: var(--muted); font-style: normal; }
.entry-content .wp-block-image img { border-radius: var(--radius); }
.home-content { padding-block: 0; }

/* Style de liste « Cartes » */
.entry-content ul.is-style-cards {
  list-style: none; padding: 0; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.entry-content > ul.is-style-cards { max-width: var(--read); }
.entry-content ul.is-style-cards li {
  margin: 0; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--white); line-height: 1.5; font-weight: 500; color: var(--navy);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.entry-content ul.is-style-cards li:hover { border-color: #c9d3e1; transform: translateY(-2px); box-shadow: var(--shadow); }
.entry-content ul.is-style-cards li strong { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.entry-content ul.is-style-cards li span, .entry-content ul.is-style-cards li em { color: var(--muted); font-weight: 400; font-style: normal; font-size: .95rem; }

/* Style de liste « Bibliographie » */
.entry-content .is-style-biblio { list-style: none; padding: 0; counter-reset: none; }
.entry-content .is-style-biblio li {
  margin: 0; padding: 18px 0; border-bottom: 1px solid var(--line); line-height: 1.6;
}
.entry-content .is-style-biblio li:first-child { border-top: 1px solid var(--line); }
.entry-content .is-style-biblio li em { color: var(--ink); }
.entry-content .is-style-biblio a { word-break: break-word; }

/* Style de liste « Chronologie » */
.entry-content .is-style-timeline { list-style: none; padding: 0; position: relative; }
.entry-content .is-style-timeline::before {
  content: ""; position: absolute; inset-block: 8px; inset-inline-start: 5px; width: 2px; background: var(--line);
}
.entry-content .is-style-timeline li { position: relative; padding-inline-start: 32px; margin-bottom: 1.1em; }
.entry-content .is-style-timeline li::before {
  content: ""; position: absolute; inset-inline-start: 0; top: .55em; width: 12px; height: 12px;
  border-radius: 50%; background: var(--white); border: 2px solid var(--navy);
}
.entry-content .is-style-timeline li strong { display: block; font-size: 14px; letter-spacing: .04em; color: var(--navy-soft); }

/* Bloc Média et texte (ouvrage) */
.entry-content .wp-block-media-text {
  gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
  overflow: hidden; padding: clamp(18px, 3vw, 28px);
}
.entry-content .wp-block-media-text .wp-block-media-text__media img { border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.entry-content .wp-block-media-text .wp-block-media-text__content { padding: 0 0 0 clamp(18px, 3vw, 32px); }
[dir="rtl"] .entry-content .wp-block-media-text .wp-block-media-text__content { padding: 0 clamp(18px, 3vw, 32px) 0 0; }
.entry-content .wp-block-media-text h3 { margin-top: 0; }
@media (max-width: 600px) {
  .entry-content .wp-block-media-text .wp-block-media-text__content,
  [dir="rtl"] .entry-content .wp-block-media-text .wp-block-media-text__content { padding: 20px 0 0; }
  .entry-content .wp-block-media-text .wp-block-media-text__media { max-width: 200px; }
}

/* Boutons Gutenberg */
.entry-content .wp-block-button__link {
  background: var(--navy); color: var(--white); border-radius: 999px; padding: 11px 20px; font-weight: 600; font-size: 15px; text-decoration: none;
}
.entry-content .wp-block-button__link:hover { background: var(--navy-deep); color: var(--white); }
.entry-content .is-style-outline .wp-block-button__link { background: transparent; color: var(--navy); border: 1px solid var(--navy); }

/* Cartes de contact */
.entry-content .contact-card {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 14px; background: var(--white);
}
.entry-content .contact-card p { margin: 0; }
.entry-content .contact-card .contact-label { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.entry-content .contact-card a { font-size: clamp(1.05rem, 2.4vw, 1.3rem); font-weight: 600; text-decoration: none; word-break: break-all; }
.entry-content .contact-card a:hover { text-decoration: underline; }

/* ---------- Pied de page ---------- */
.site-footer { background: var(--navy); color: rgba(255, 255, 255, .78); padding-block: 48px 36px; font-size: 15px; }
.site-footer a { color: var(--white); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-grid { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 28px; align-items: flex-start; }
.footer-name { color: var(--white); font-weight: 650; font-size: 18px; margin: 0 0 4px; }
.footer-tagline { margin: 0; max-width: 46ch; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 22px; }
.footer-bottom { margin-top: 36px; padding-top: 22px; border-top: 1px solid rgba(255, 255, 255, .14); font-size: 13px; color: rgba(255, 255, 255, .6); }

/* ---------- 404 ---------- */
.not-found { padding-block: 120px; text-align: center; }

/* ---------- Animations discrètes ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
  .js .reveal.is-visible { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Impression ---------- */
@media print {
  .site-header, .site-footer, .hero-actions, .menu-toggle { display: none !important; }
  body { font-size: 12pt; }
}

/* Contenu de l'accueil : pleine largeur de la grille */
.home-content > *, .home-content > ul.is-style-cards { max-width: none; margin-inline: 0; }
.home-content > h2 { border-top: 0; padding-top: 0; margin-top: 2.2em; }
.home-content > h2:first-child { margin-top: 0; }
.home-content > p { max-width: 70ch; color: var(--muted); }
.home-content ul.is-style-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* Textes mêlant arabe et français : chaque référence suit le sens de sa propre langue */
.entry-content .is-style-biblio li { unicode-bidi: plaintext; text-align: start; }
.entry-content .contact-card a, .entry-content a[href^="mailto:"] { unicode-bidi: isolate; direction: ltr; }
