/* ===== Google Font ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600&display=swap');

/* ===== Corps de page ===== */
body {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    background: #f5f7fa;
    color: #333;
    position: relative;
    overflow-x: hidden;
}

/* ===== Background décoratif ===== */
body::before, body::after, .bg-shape {
    content: '';
    position: absolute;
    border-radius: 50%;
    opacity: 0.1;
    z-index: 0;
}
body::before {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    top: -150px;
    left: -150px;
}
body::after {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #3498db, #2980b9);
    bottom: -100px;
    right: -100px;
}
.bg-shape.shape1 {
    width: 250px; height: 250px;
    background: linear-gradient(135deg, #e67e22, #d35400);
    top: 200px; left: 50px;
}
.bg-shape.shape2 {
    width: 180px; height: 180px;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    top: 400px; right: 80px;
}

/* ===== Titres ===== */
h1 {
    color: #2c3e50;
    font-size: 2.5em;
    text-align: center;
    margin-bottom: 0.5em;
}
h2 {
    color: #34495e;
    font-size: 2em;
    text-align: center;
    margin-top: 2em;
    margin-bottom: 0.5em;
}
h3 {
    color: #4a6274;
    font-size: 1.3em;
    text-align: center;
    margin-bottom: 0.6em;
}

/* ===== Paragraphes ===== */
p {
    margin: 0.6em 0;
    text-align: center;
    color: #555;
}

/* ===== Grille & Cards ===== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    justify-items: center;
    margin: 2rem 0;
}

.card {
    background: #ffffff;
    border-radius: 18px;
    padding: 2rem 1.5rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 220px;
    width: 100%;
    max-width: 320px;
    position: relative;
    overflow: hidden;
}

/* Hover effect */
.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}

/* Card headers & text */
.card h3 {
    font-size: 1.4em;
    font-weight: 700;
    margin-bottom: 1rem;
    text-align: center;
}
.card p {
    font-size: 1em;
    line-height: 1.4;
    text-align: center;
}

/* Card buttons */
.card a {
    margin-top: auto;
    padding: 12px 18px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    text-align: center;
    transition: 0.2s;
    color: #fff;
}
.CYB a { background-color: #FF6B6B; }
.ISNB a { background-color: #4ECDC4; }
.ISNL a { background-color: #FFD93D; color: #333; }
.MIA a { background-color: #1E90FF; }
.SHSJC a { background-color: #9B59B6; }

.card a:hover {
    filter: brightness(1.1);
}

/* Cards non prêtes */
.card.not-ready {
    background: #f0f0f0;
    color: #999;
    border: 2px dashed #ccc;
}
.card.not-ready a {
    background: #bbb;
    cursor: not-allowed;
    pointer-events: none;
}

/* Decorative card shapes */
.card::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 100px;
    height: 100px;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 50%;
    z-index: 0;
}
.card > * {
    position: relative;
    z-index: 1;
}

/* ===== Code blocks modernisés ===== */
pre {
    display: block;
    background: linear-gradient(145deg, #1e1e2f, #2c2c3f);
    color: #f8f8f2;
    padding: 20px 25px;
    border-radius: 16px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.95em;
    line-height: 1.5;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow-x: auto;       /* scroll horizontal si nécessaire */
    white-space: pre;       /* respecte les retours et l'indentation */
}

/* Hover subtil */
pre:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
}

/* Inline code (dans le texte) */
code {
    background: #272833;
    color: #f8f8f2;
    padding: 3px 6px;
    border-radius: 6px;
    font-family: 'Fira Code', monospace;
    font-size: 0.95em;
    white-space: pre-wrap;  /* permet de revenir à la ligne si le code est long */
    display: inline-block;
}

/* Line numbers for code blocks (optional) */
pre[data-line-numbers] {
    counter-reset: line;
}
pre[data-line-numbers] code {
    display: block;
}
pre[data-line-numbers] code::before {
    counter-increment: line;
    content: counter(line);
    display: inline-block;
    width: 2em;
    margin-right: 10px;
    text-align: right;
    color: rgba(255,255,255,0.3);
}

/* ===== MathJax / Formules ===== */
.math {
    font-family: 'Inter', sans-serif;
    font-size: 1.25em;
    line-height: 1.5;
    color: #2c3e50;
    background: rgba(230, 230, 250, 0.2);
    padding: 4px 8px;
    border-radius: 8px;
    margin: 0 2px;
    display: inline-block;
}

mjx-container[jax="CHTML"] {
    background: rgba(245, 245, 255, 0.3);
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 1.15em !important;
    line-height: 1.4 !important;
}

/* Block formulas */
.math-block {
    display: block;
    margin: 1em 0;
    text-align: center;
    background: rgba(240, 248, 255, 0.3);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

/* ===== Tableaux ===== */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.2em 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

th, td {
    border: 1px solid #ccc;
    padding: 12px;
    text-align: left;
}

th {
    background-color: #f0f4f8;
    font-weight: bold;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

tr:hover {
    background-color: #dbe9f4;
}

/* Listes et blockquote */
ul, ol {
    margin: 0.5em 0 0.5em 2em;
}
blockquote {
    border-left: 4px solid #ccc;
    margin: 1em 0;
    padding-left: 1em;
    color: #555;
    font-style: italic;
    background-color: #f5f5f5;
    border-radius: 4px;
}

/* Séparateurs */
hr {
    border: 0;
    height: 1px;
    background: #ccc;
    margin: 2em 0;
}

/* Liens */
a {
    color: #2980b9;
    text-decoration: none;
    font-weight: bold;
}
a:hover {
    text-decoration: underline;
}

.back-btn {
    display: inline-block;
    padding: 10px 16px;
    background-color: #3498db;
    color: #fff;
    border-radius: 10px;
    font-weight: 600;
    text-decoration: none;
    transition: 0.2s;
}
.back-btn:hover {
    filter: brightness(1.1);
}

/* ===== Responsive ===== */
@media screen and (max-width: 768px) {
    body { font-size: 15px; }
    h1 { font-size: 2em; }
    h2 { font-size: 1.6em; }
    h3 { font-size: 1.2em; }
    .grid { gap: 1.5rem; }
    .card { padding: 1.5rem; min-height: 200px; }
    pre { font-size: 0.9em; padding: 12px; }
}
