/* =========================================================
   Portail numérique APME
   ========================================================= */

:root {
    --navy: #1c3a6b;
    --navy-dark: #12284d;
    --green: #2e7d32;
    --text: #1b2333;
    --muted: #5d6677;
    --line: #e3e7ef;
    --bg: #f3f6fb;
    --portal-bg: #188413; /* fond vert de la zone du portail (cercle des applications) */
    --radius: 16px;
    --shadow: 0 2px 6px rgba(20, 40, 80, .06), 0 12px 32px rgba(20, 40, 80, .07);
    --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% 38%, rgba(46, 125, 50, .07), transparent 42%),
        radial-gradient(circle at 12% 0%, rgba(28, 58, 107, .08), transparent 40%),
        var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.45;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, p { margin: 0; }

a:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; border-radius: 10px; }

/* ---------- En-tête ---------- */
.pn-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 24px;
    max-width: 1560px;
    margin: 0 auto;
    padding: 22px 28px 10px;
}

.pn-brand { display: inline-flex; align-items: center; gap: 12px; justify-self: start; }
.pn-brand img { width: 58px; height: auto; }
.pn-brand strong { display: block; font-size: 22px; font-weight: 900; letter-spacing: .04em; color: var(--navy); }
.pn-brand small { display: block; font-size: 12px; line-height: 1.35; color: var(--muted); }

.pn-title { text-align: center; }
.pn-title h1 {
    font-size: clamp(24px, 2.6vw, 40px);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -.01em;
    text-transform: uppercase;
    color: var(--navy);
}
.pn-title p { margin-top: 6px; font-size: clamp(14px, 1.2vw, 18px); font-weight: 600; color: var(--green); }

.pn-flag { justify-self: end; width: 74px; height: auto; border-radius: 4px; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }

/* ---------- Grille principale ---------- */
.pn-main {
    display: grid;
    /* Cercle des applications APME sur toute la largeur, blocs 1 à 7 en dessous */
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
    max-width: 1560px;
    margin: 0 auto;
    padding: 14px 28px 28px;
}

.pn-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.pn-col-panels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; gap: 12px; }

/* ---------- Panneaux partenaires ---------- */
.pn-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1.5px solid color-mix(in srgb, var(--c) 35%, transparent);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
}

.pn-panel-head {
    background: var(--c);
    color: #fff;
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
}

/* Titre cliquable : les blocs sont repliés à l'affichage */
.pn-panel-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-align: left;
    text-transform: inherit;
    cursor: pointer;
}
.pn-panel-toggle:hover { background: rgba(255, 255, 255, .08); }
.pn-panel-toggle:focus-visible { outline: 3px solid #fff; outline-offset: -5px; }
.pn-panel-title { flex: 1; min-width: 0; }
.pn-panel-chevron { flex: none; width: 18px; height: 18px; transition: transform .2s; }
.pn-panel.is-open .pn-panel-chevron { transform: rotate(180deg); }
.pn-panel-body { display: flex; flex-direction: column; animation: pn-panel-open .2s ease-out; }
.pn-panel-body[hidden] { display: none; }
@keyframes pn-panel-open { from { opacity: 0; transform: translateY(-6px); } }

.pn-panel-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: #fff;
    color: var(--c);
    font-size: 12px;
}

.pn-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
    gap: 12px 8px;
    padding: 14px 12px 12px;
}

.pn-panel.is-wide .pn-items { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }

.pn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 100%;
    padding: 4px 2px;
    border-radius: 10px;
    text-align: center;
    transition: background-color .15s, transform .15s;
}

a.pn-item:hover { background: color-mix(in srgb, var(--c) 8%, #fff); transform: translateY(-2px); }

.pn-item-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--c) 10%, #fff);
    color: var(--c);
}
.pn-item-logo.has-image { background: #fff; }
.pn-item-logo img { width: 100%; height: 100%; object-fit: contain; }
.pn-item-icon { width: 26px; height: 26px; }

.pn-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    height: 50px;
    padding: 0 10px;
    border-radius: 6px;
    letter-spacing: -.01em;
}
.pn-mark.is-round { border-radius: 50%; min-width: 72px; }
.pn-mark.has-border { border: 1.5px solid var(--line); }

.pn-item-name { max-width: 100%; font-size: 10.5px; font-weight: 700; line-height: 1.2; color: var(--text); text-transform: uppercase; overflow-wrap: break-word; }

.pn-panel-desc {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: auto 12px 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--c) 9%, #fff);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.pn-panel-desc-icon {
    flex: none;
    width: 38px;
    height: 38px;
    padding: 8px;
    border-radius: 50%;
    background: var(--c);
    color: #fff;
}

/* ---------- Orbite des applications ---------- */
.pn-orbit-wrap {
    container-type: inline-size;
    padding: 28px 16px 4px;
    border-radius: var(--radius);
    background: var(--portal-bg);
}

.pn-orbit {
    position: relative;
    width: 70%; /* place laissée de chaque côté pour les descriptions des applications */
    max-width: 680px;
    aspect-ratio: 1;
    margin: 0 auto 56px;
}

.pn-orbit-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pn-ring { fill: none; transform-origin: 50% 50%; }
.pn-ring-outer { stroke: rgba(255, 255, 255, .7); stroke-width: .35; stroke-dasharray: 1.2 1.4; animation: pn-spin 90s linear infinite; }
.pn-ring-inner { stroke: rgba(255, 255, 255, .3); stroke-width: .25; }
.pn-spoke { stroke-width: .35; stroke-dasharray: .8 .9; opacity: .55; }

@keyframes pn-spin { to { transform: rotate(360deg); } }

.pn-hub {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 40%;
    aspect-ratio: 1;
    padding: 4%;
    border-radius: 50%;
    background: #fff;
    text-align: center;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 7px #fff, 0 0 0 11px #007a5e, 0 0 0 15px #ce1126, 0 0 0 19px #fcd116, 0 18px 50px rgba(20, 40, 80, .25);
}

.pn-hub-logo { display: block; width: 38%; transition: transform .2s; }
.pn-hub-logo:hover { transform: scale(1.06); }
.pn-hub-logo img { display: block; width: 100%; height: auto; }

.pn-hub-title {
    margin-top: 4%;
    font-size: clamp(14px, 3.6cqi, 26px);
    font-weight: 900;
    line-height: 1.05;
    text-transform: uppercase;
    color: var(--navy);
}
.pn-hub-title span { display: block; color: var(--green); }

.pn-hub-desc {
    min-height: 3.2em;
    margin-top: 4%;
    font-size: clamp(11px, 1.8cqi, 14px);
    line-height: 1.35;
    color: var(--muted);
}
.pn-hub-desc strong { display: block; color: var(--navy); }

.pn-app {
    position: absolute;
    left: var(--x);
    top: var(--y);
    z-index: 3;
    width: 19%;
    transform: translate(-50%, -50%);
    animation: pn-pop .5s ease-out both;
    animation-delay: calc(var(--i) * 60ms);
}

@keyframes pn-pop { from { opacity: 0; transform: translate(-50%, -50%) scale(.7); } }

.pn-app a { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pn-app-head { position: relative; display: flex; justify-content: center; width: 74%; }

.pn-app-disc {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    border: 4px solid var(--c);
    border-radius: 50%;
    background: #fff;
    color: var(--c);
    box-shadow: 0 8px 22px color-mix(in srgb, var(--c) 30%, transparent);
    transition: transform .2s, box-shadow .2s, background-color .2s, color .2s;
}
.pn-app-disc { overflow: hidden; }
/* Logos détourés et rognés (assets/apps/disc) : centrés dans le disque, sans déborder du cercle */
.pn-app-disc img { display: block; width: 76%; height: 46%; object-fit: contain; object-position: center; }
/* Logo plutôt carré (pictogramme + nom) */
.pn-app-disc img.is-large { width: 68%; height: 64%; }
/* Logo déjà rond : il remplit tout le disque */
.pn-app-disc img.is-round { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.pn-app-icon { width: 46%; height: 46%; }

.pn-app-name {
    max-width: none; /* libellés longs (easybusiness.cm) : la pastille peut déborder du disque */
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--c);
    color: #fff;
    font-size: clamp(10px, 1.75cqi, 13.5px);
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Description de l'application, à côté du disque, vers l'extérieur du cercle */
.pn-app-desc {
    position: absolute;
    top: 50%;
    width: clamp(112px, 15cqi, 172px);
    padding: 8px 11px;
    border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
    border-radius: 12px;
    background: rgba(255, 255, 255, .86);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    box-shadow: 0 6px 18px rgba(20, 40, 80, .1);
    font-size: clamp(11px, 1.5cqi, 13px);
    font-weight: 600;
    -webkit-hyphens: auto;
    hyphens: auto;
    overflow-wrap: break-word;
    line-height: 1.35;
    color: var(--text);
    transition: transform .25s, box-shadow .25s, background-color .25s, border-color .25s;
    animation: pn-desc-in .55s cubic-bezier(.2, .8, .2, 1) both;
    animation-delay: calc(.35s + var(--i) * 90ms);
}
/* Liseré coloré côté disque */
.pn-app-desc::before {
    content: '';
    position: absolute;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 3px;
    background: var(--c);
}
.pn-app.is-right .pn-app-desc { left: calc(100% + 12px); transform: translateY(-50%); --from: translate(-10px, -50%); padding-left: 15px; }
.pn-app.is-right .pn-app-desc::before { left: 6px; }
.pn-app.is-left .pn-app-desc { right: calc(100% + 12px); transform: translateY(-50%); --from: translate(10px, -50%); padding-right: 15px; text-align: right; }
.pn-app.is-left .pn-app-desc::before { right: 6px; }
/* Application du bas : description sous son nom */
.pn-app.is-bottom .pn-app-desc { top: calc(100% + 40px); left: 50%; transform: translateX(-50%); --from: translate(-50%, -8px); text-align: center; }
.pn-app.is-bottom .pn-app-desc::before { top: 0; bottom: auto; left: 30%; right: 30%; width: auto; height: 3px; }

@keyframes pn-desc-in { from { opacity: 0; transform: var(--from); } }

.pn-app a:hover .pn-app-desc,
.pn-app a:focus-visible .pn-app-desc {
    border-color: color-mix(in srgb, var(--c) 55%, transparent);
    background: color-mix(in srgb, var(--c) 7%, #fff);
    box-shadow: 0 10px 26px color-mix(in srgb, var(--c) 28%, transparent);
}
.pn-app.is-right a:hover .pn-app-desc, .pn-app.is-right a:focus-visible .pn-app-desc { transform: translate(4px, -50%); }
.pn-app.is-left a:hover .pn-app-desc, .pn-app.is-left a:focus-visible .pn-app-desc { transform: translate(-4px, -50%); }
.pn-app.is-bottom a:hover .pn-app-desc, .pn-app.is-bottom a:focus-visible .pn-app-desc { transform: translate(-50%, 4px); }

.pn-app a:hover .pn-app-disc,
.pn-app a:focus-visible .pn-app-disc { transform: scale(1.1); box-shadow: 0 12px 30px color-mix(in srgb, var(--c) 45%, transparent); }
.pn-app a:hover .pn-app-disc:not(.has-image),
.pn-app a:focus-visible .pn-app-disc:not(.has-image) { background: var(--c); color: #fff; }

.pn-noscript { padding: 20px; border-radius: var(--radius); background: #fff; }

/* ---------- Pied de page ---------- */
.pn-footer {
    max-width: 1560px;
    margin: 0 auto;
    padding: 6px 28px 26px;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
}
.pn-footer p + p { margin-top: 4px; }
.pn-footer a { color: var(--navy); font-weight: 700; }
.pn-footer a:hover { text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
    .pn-col-panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .pn-header { grid-template-columns: 1fr auto; padding: 16px 16px 6px; gap: 12px; }
    .pn-title { grid-column: 1 / -1; grid-row: 2; }
    .pn-brand img { width: 46px; }
    .pn-flag { width: 54px; }
    /* Une seule colonne : les panneaux sont remis dans l'ordre 1 → 7 (order posé par le JS) */
    .pn-main { display: flex; flex-direction: column; padding: 12px 16px 24px; gap: 18px; }
    .pn-col { display: contents; }

    /* L'orbite devient une grille de tuiles */
    .pn-orbit { width: 100%; aspect-ratio: auto; max-width: none; margin-bottom: 0; }
    .pn-orbit-lines { display: none; }
    .pn-orbit-wrap { padding: 12px; }
    .pn-hub {
        position: static;
        width: auto;
        aspect-ratio: auto;
        margin: 0 0 18px;
        padding: 20px 16px;
        border-radius: var(--radius);
        transform: none;
        box-shadow: inset 0 -6px 0 #fcd116, inset 0 -12px 0 #ce1126, inset 0 -18px 0 #007a5e, var(--shadow);
        padding-bottom: 34px;
    }
    .pn-hub-logo { width: 88px; }
    .pn-hub-title { font-size: 24px; }
    .pn-hub-desc { font-size: 14px; min-height: 0; }
    .pn-apps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
    .pn-app { position: static; width: auto; transform: none; animation: none; }
    .pn-app a { height: 100%; padding: 14px 6px 12px; border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
    .pn-app-head { display: contents; }
    .pn-app-disc { width: 64px; border-width: 3px; }
    .pn-app-desc,
    .pn-app.is-left .pn-app-desc,
    .pn-app.is-right .pn-app-desc,
    .pn-app.is-bottom .pn-app-desc {
        position: static; order: 3; width: auto; padding: 0; border: 0; background: none; box-shadow: none;
        -webkit-backdrop-filter: none; backdrop-filter: none; transform: none; animation: none;
        font-size: 11px; font-weight: 500; text-align: center; color: var(--muted);
    }
    .pn-app-desc::before { display: none; }
    .pn-app-name { font-size: 10.5px; padding: 3px 8px; white-space: normal; line-height: 1.2; text-align: center; }
}

@media (max-width: 340px) {
    .pn-apps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    .pn-ring-outer, .pn-app, .pn-app-desc { animation: none; }
    .pn-app-disc, .pn-item, .pn-hub-logo, .pn-panel-chevron { transition: none; }
    .pn-panel-body { animation: none; }
}
