/* ─── GOOGLE FONTS ─── */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,600;1,400&family=Unbounded:wght@700;900&display=swap');
/* Couleurs de coloration syntaxique EduCode (reprises de l'éditeur) */
:root {
    --fn-color: #7856ff;
    --type-color: #ff7a00;
    --op-color: #ff7a00;
    --number: #7856ff;
    --debug-color: #e53935;
}

/* Lien « retour au site » dans le header (remplace l'entrée de la sidebar) */
.header-back {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    text-decoration: none;
    padding: 6px 14px;
    border: 1px solid var(--border2);
    border-radius: 999px;
    transition: color .15s, border-color .15s, background .15s;
}
.header-back:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(29, 155, 240, .06);
}

main {
    max-width: 1100px;
    margin: 0 auto;
}

.ex-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.card.hidden {
    display: none;
}

.ex-hero {
    padding: 44px 0 28px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
    background-image: url('../../../assets/image/pattern-bg.svg');
    background-repeat: repeat;
}

.ex-hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(29, 155, 240, .08);
    border: 1px solid rgba(29, 155, 240, .2);
    margin-bottom: 16px;
}

.ex-hero h1 {
    font-family: 'Unbounded', sans-serif;
    font-size: clamp(26px, 4vw, 38px);
    font-weight: 900;
    color: var(--text);
    letter-spacing: -1.5px;
    margin-bottom: 12px;
    line-height: 1.1;
}

.ex-hero h1 em {
    font-style: normal;
    color: var(--accent);
}

.ex-hero p {
    font-size: 13px;
    color: var(--text-dim);
    max-width: 640px;
    line-height: 1.75;
}

.ex-toolbar {
    position: sticky;
    top: var(--header-h);
    z-index: 50;
    background: var(--bg);
    padding: 14px 0;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.ex-kbd {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--text-dimmer);
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 2px 7px;
    pointer-events: none;
    transition: opacity .15s;
}

.ex-search input:focus~.ex-kbd {
    opacity: 0;
}

.ex-search .clear-btn.show~.ex-kbd,
.ex-search:focus-within .ex-kbd {
    opacity: 0;
}

.ex-empty {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-dim);
}

.ex-empty .mdi {
    font-size: 46px;
    color: var(--text-dimmer);
    display: block;
    margin-bottom: 14px;
}

.ex-empty strong {
    color: var(--text);
}

.ex-empty-hint {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-dimmer);
}

.ex-empty-hint code {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px 6px;
    font-size: 11px;
}

.cta {
    margin-top: 48px;
    padding: clamp(22px, 4vw, 36px);
    background: rgba(29, 155, 240, .04);
    border: 1px solid rgba(29, 155, 240, .18);
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.cta-icon img {
    height: 72px;
    display: block;
}

.cta-content {
    flex: 1;
    min-width: 240px;
}

.cta-content h2 {
    font-family: 'Unbounded', sans-serif;
    font-size: 18px;
    font-weight: 900;
    color: var(--text);
    border: none;
    padding: 0;
    margin: 0 0 6px;
    letter-spacing: -.5px;
}

.cta-content h2::before {
    display: none;
}

.cta-content p {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.7;
    margin: 0;
}

.cta-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cta a {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    padding: 9px 16px;
    border-radius: 8px;
    text-decoration: none;
    letter-spacing: .3px;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.cta a.primary {
    background: var(--accent);
    color: #fff;
}

.cta a.primary:hover {
    background: #1788d6;
}

.cta a.ghost {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border2);
}

.cta a.ghost:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.code-accordion {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin: 12px 16px 16px;
}

.code-accordion-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: var(--surface);
    border: none;
    border-bottom: 1px solid transparent;
    padding: 10px 14px;
    cursor: pointer;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .3px;
    color: var(--text-dim);
    text-align: left;
    transition: background .15s, color .15s;
}

.code-accordion-toggle:hover {
    color: var(--text);
    background: var(--surface3);
}

.code-accordion-toggle .mdi-chevron-right {
    transition: transform .2s ease;
    font-size: 18px;
    margin-left: auto;
}

.code-accordion.open .code-accordion-toggle {
    color: var(--text);
    border-bottom-color: var(--border);
}

.code-accordion.open .code-accordion-toggle .mdi-chevron-right {
    transform: rotate(90deg);
}

.code-accordion .code-block {
    display: none;
    margin: 0;
    border: none;
    border-radius: 0;
}

.code-accordion.open .code-block {
    display: block;
}
/* ============================================================= */
/*  EXPLORER : arborescence + visionneuse de code                */
/* ============================================================= */
.ex-explorer {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 18px;
    align-items: start;
    margin-bottom: 32px;
    /* Hauteur commune arbre / visionneuse */
    --explorer-h: 520px;
}

/* ---------- Arbre ---------- */
.ex-tree {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px;
    height: var(--explorer-h);
    overflow-y: auto;
}

.ex-tree-loading {
    padding: 20px 12px;
    font-size: 13px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ex-cat + .ex-cat {
    margin-top: 2px;
}
.ex-cat.hidden {
    display: none;
}

.ex-cat-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 9px 10px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    text-align: left;
    transition: background .15s;
}
.ex-cat-head:hover {
    background: var(--surface3);
}
.ex-cat-caret {
    font-size: 18px;
    color: var(--text-dimmer);
    transition: transform .2s;
}
.ex-cat.collapsed .ex-cat-caret {
    transform: rotate(-90deg);
}
.ex-cat-icon {
    font-size: 17px;
    color: var(--accent);
}
.ex-cat-name {
    flex: 1;
}
.ex-cat-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    background: var(--surface3);
    border-radius: 999px;
    padding: 1px 8px;
    min-width: 20px;
    text-align: center;
}

.ex-file-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
    padding-left: 6px;
}
.ex-cat.collapsed .ex-file-list {
    display: none;
}

.ex-file {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    border-left: 2px solid transparent;
    cursor: pointer;
    padding: 8px 10px 8px 14px;
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    color: var(--text-dim);
    text-align: left;
    transition: background .15s, color .15s, border-color .15s;
}
.ex-file:hover {
    background: var(--surface3);
    color: var(--text);
}
.ex-file .mdi {
    font-size: 16px;
    color: var(--text-dimmer);
    flex-shrink: 0;
}
.ex-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ex-file.active {
    background: rgba(29, 155, 240, .10);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}
.ex-file.active .mdi {
    color: var(--accent);
}
.ex-file.hidden {
    display: none;
}

/* ---------- Visionneuse ---------- */
.ex-viewer {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: var(--explorer-h);
}

.ex-viewer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: #ffffff;
}
.ex-viewer-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
}
.ex-viewer-title .mdi {
    font-size: 18px;
    color: var(--accent);
    flex-shrink: 0;
}
.ex-viewer-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ex-viewer-body {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: auto;
}
.ex-viewer-placeholder {
    margin: auto;
    text-align: center;
    color: var(--text-dimmer);
    padding: 40px 24px;
    max-width: 320px;
}
.ex-viewer-placeholder .mdi {
    font-size: 40px;
    display: block;
    margin-bottom: 12px;
    opacity: .5;
}
.ex-viewer-placeholder div {
    font-size: 13px;
    line-height: 1.6;
}

.ex-viewer-code {
    margin: 0;
    padding: 18px 20px;
    width: 100%;
    overflow-x: auto;
    background: #f0f4f8;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11.5px;
    line-height: 1.7;
    color: var(--text);
    white-space: pre;
    tab-size: 3;
}
.ex-viewer-code code {
    font-family: inherit;
}

/* Bouton copier — état de base (CETTE RÈGLE MANQUAIT) */
.copy-btn,
.viewer-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 7px 14px;
    font-size: 12.5px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1;
    color: #fff;
    background: var(--accent, #2563eb);
    border: 1px solid var(--accent, #2563eb);
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s ease, transform .1s ease, opacity .15s ease;
    position: relative;
    z-index: 5;
}
.copy-btn:hover:not(:disabled),
.viewer-copy-btn:hover:not(:disabled) {
    filter: brightness(1.08);
}
.copy-btn:active:not(:disabled),
.viewer-copy-btn:active:not(:disabled) {
    transform: translateY(1px);
}
/* Empêche les enfants éventuels d'intercepter le clic */
.copy-btn *,
.viewer-copy-btn * { pointer-events: none; }

/* État « copié » */
.copy-btn.copied,
.viewer-copy-btn.copied {
    background: var(--accent2, #16a34a);
    color: #fff;
    border-color: var(--accent2, #16a34a);
}

/* État désactivé */
.copy-btn:disabled,
.viewer-copy-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.mdi-spin {
    animation: ex-spin 1s linear infinite;
}

/* ---- Card derniers ajouts ---- */
.ex-recent-card {
    margin-top: 1.5rem;
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 12px;
    overflow: hidden;
    background: var(--card-bg, #fff);
}
.ex-recent-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .9rem 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border, #e0e0e0);
}
.ex-recent-list { display: flex; flex-direction: column; }
.ex-recent-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.1rem;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border, #f0f0f0);
    text-align: left;
    cursor: pointer;
    width: 100%;
    transition: background .15s;
}
.ex-recent-item:last-child { border-bottom: none; }
.ex-recent-item:hover { background: var(--hover, #f5f5f5); }
.ex-recent-icon { font-size: 1.3rem; opacity: .8; }
.ex-recent-info { display: flex; flex-direction: column; }
.ex-recent-name { font-weight: 500; }
.ex-recent-meta { font-size: .8em; opacity: .7; }
.ex-recent-loading { padding: 1rem 1.1rem; opacity: .7; }

/* ---- Compteur de copies ---- */
.ex-copy-counter {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .9em;
    opacity: .8;
    margin-top: .5rem;
}

@keyframes ex-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
    .ex-explorer {
        grid-template-columns: 1fr;
        --explorer-h: 380px;
    }
    .ex-tree {
        height: 300px;
    }
}