document.addEventListener("DOMContentLoaded", function () { function applyTopBorders() { // On cible le conteneur d'informations de chaque produit dans le slider const infoBlocks = document.querySelectorAll('.swiper-wrapper .product-block-outer .product-block__info'); infoBlocks.forEach((el, index) => { let remainder = index % 3; el.style.borderTopWidth = "5px"; el.style.borderTopStyle = "solid"; if (remainder === 0) { el.style.borderTopColor = "#2ecc71"; // 1er, 4ème, 7ème... : Vert } else if (remainder === 1) { el.style.borderTopColor = "#e74c3c"; // 2ème, 5ème, 8ème... : Rouge } else if (remainder === 2) { el.style.borderTopColor = "#f1c40f"; // 3ème, 6ème, 9ème... : Jaune } }); } // Exécuter immédiatement et en différé pour contrer SwiperJS applyTopBorders(); setTimeout(applyTopBorders, 500); setTimeout(applyTopBorders, 1500); // Observer les changements du slider const targetNode = document.querySelector('.swiper-wrapper'); if (targetNode) { const observer = new MutationObserver(function () { applyTopBorders(); }); observer.observe(targetNode, { childList: true, subtree: true }); } }); /* */ document.addEventListener("DOMContentLoaded", function () { // 1. Injecter le CSS dynamiquement dans le
de la page const styleElement = document.createElement("style"); styleElement.innerHTML = ` .mood-container { direction: rtl; background-color: #f7f5ef; padding: 40px 20px; margin: 0 auto; } .mood-header { text-align: right; margin-bottom: 30px; } .mood-header h2 { font-size: 2.2rem; font-weight: 900; color: #1a1a1a; margin: 0 0 8px 0; } .mood-header p { font-size: 1rem; color: #666; margin: 0; } .mood-grid { display: flex; gap: 24px; justify-content: flex-end; flex-wrap: wrap; } .mood-card { position: relative; width: 320px; height: auto; border-radius: 24px; padding: 30px; display: flex; flex-direction: column; justify-content: space-between; text-decoration: none; box-sizing: border-box; transition: transform 0.3s ease, box-shadow 0.3s ease; } .mood-card:hover { transform: translateY(-8px); box-shadow: 0 15px 30px rgba(0, 0, 0, 0.12); } .card-number { position: absolute; top: 20px; left: 30px; font-size: 4.5rem; font-weight: 900; color: rgba(255, 255, 255, 0.18); line-height: 1; user-select: none; } .pattern-box { margin-top: 60px; } .zigzag { width: 100%; height: 16px; background: linear-gradient(135deg, white 25%, transparent 25%) -10px 0, linear-gradient(225deg, white 25%, transparent 25%) -10px 0; background-size: 20px 20px; background-repeat: repeat-x; margin-bottom: 12px; opacity: 0.9; } .line { width: 100%; height: 2px; background-color: white; margin-bottom: 8px; opacity: 0.9; } .card-content { margin-bottom: 20px; } .card-content h3 { color: white; font-size: 1.8rem; font-weight: 800; margin: 0 0 10px 0; } .card-content p { color: rgba(255, 255, 255, 0.85); font-size: 0.95rem; margin: 0; } .arrow-icon { align-self: flex-start; color: white; font-size: 1.2rem; font-weight: bold; border: 1px solid rgba(255, 255, 255, 0.4); border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; transition: background 0.2s; } .mood-card:hover .arrow-icon { background: rgba(255, 255, 255, 0.2); } .mood-card.yellow { background-color: #D0C432; } .mood-card.black { background-color: #000; } .mood-card.red { background-color: #962222; } .mood-card.green { background-color: #275635; } @media (max-width: 1024px) { .mood-grid { justify-content: center; } } @media (max-width: 600px) { .mood-card { width: 100%; height: 380px; } } `; document.head.appendChild(styleElement); // 2. Le code HTML à injecter const htmlContent = `أربعة مسارات، وكل مسار يحكي جانبًا مختلفًا من جبلية.