/* ---------- Piliers ---------- */
@layer components {
  .tabs {
    position: relative; display: flex; gap: 4px; margin-top: 48px;
    padding: 4px; border-radius: 999px; background: var(--surface-2);
    overflow-x: auto; scrollbar-width: none;
    -webkit-mask: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
            mask: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
    scroll-snap-type: x proximity; overscroll-behavior-x: contain;
  }
  @media (min-width: 900px) { .tabs { width: fit-content; -webkit-mask: none; mask: none; } }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-indicator {
    position: absolute; top: 0; left: 0; border-radius: 999px;
    background: var(--udem-bleu);
    transition: transform 350ms var(--ease-out), width 350ms var(--ease-out), height 350ms var(--ease-out);
  }
  /* Mobile : les quatre piliers visibles d’un coup, en grille 2 × 2 */
  @media (max-width: 720px) {
    .tabs {
      display: grid; grid-template-columns: 1fr 1fr; gap: 4px; border-radius: 18px;
      overflow: visible; -webkit-mask: none; mask: none;
    }
    .tab { display: flex; align-items: center; padding: 14px 10px; font-size: 14px; text-align: left; border-radius: 14px; line-height: 1.2; min-width: 0; }
    .tab::before { margin-right: 7px; }
    .tab .n { margin-right: 5px; }
    .tab::before { flex: none; }
    .tab .n { flex: none; }
    .tab-indicator { border-radius: 14px; }
  }
  .tab {
    position: relative; z-index: 1; flex: none;
    font: 600 15px/1 var(--sans); color: var(--ink-2);
    padding: 13px 18px; border: 0; background: none; border-radius: 999px; cursor: pointer;
    scroll-snap-align: start; user-select: none; -webkit-user-select: none;
    transition: color 200ms ease, transform 160ms var(--ease-out);
  }
  .tab:active { transform: scale(0.97); }
  .tab[aria-selected="true"] { color: #fff; }
  .tab .n { margin-right: 6px; font-weight: 500; font-variant-numeric: tabular-nums; }
  #tab-1, #p-1 { --pilier: var(--pilier-1); --pilier-ink: var(--pilier-1-ink); }
  #tab-2, #p-2 { --pilier: var(--pilier-2); --pilier-ink: var(--pilier-2-ink); }
  #tab-3, #p-3 { --pilier: var(--pilier-3); --pilier-ink: var(--pilier-3-ink); }
  #tab-4, #p-4 { --pilier: var(--pilier-4); --pilier-ink: var(--pilier-4-ink); }
  .tab::before {
    content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 8px; vertical-align: 1px;
    background: var(--pilier); box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0);
    transition: box-shadow 200ms ease;
  }
  .tab[aria-selected="true"]::before { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85); }

  .panels { position: relative; margin-top: 32px; }
  /* Sans JavaScript, les onglets ne servent à rien : les quatre piliers s’affichent à la suite. */
  html:not(.js) .tabs { display: none; }
  html:not(.js) .panel + .panel { margin-top: 64px; }
  .js .panel { display: none; }
  .js .panel.active { display: block; animation: panelIn 420ms var(--ease-out); }
  @keyframes panelIn { from { opacity: 0; transform: translateY(8px); filter: blur(3px); } }
  .panel-head { display: grid; gap: 12px; margin-bottom: 28px; }
  .panel-head h3 { font-family: var(--serif); font-weight: 400; font-size: clamp(28px, 4.2vw, 40px); line-height: 1.1; margin: 0; }
  .panel-head p { color: var(--ink-2); margin: 0; max-width: 640px; }

  .cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
  .card {
    background: var(--surface); border: 1.5px solid var(--line); border-radius: 4px;
    padding: 26px; min-width: 0;
    transition: transform 250ms var(--ease-out), border-color 200ms ease;
  }
  .panel.active .card { animation: cardIn 500ms var(--ease-out) backwards; }
  .panel.active .card:nth-child(2) { animation-delay: 50ms; }
  .panel.active .card:nth-child(3) { animation-delay: 100ms; }
  .panel.active .card:nth-child(4) { animation-delay: 150ms; }
  .panel.active .card:nth-child(5) { animation-delay: 200ms; }
  @keyframes cardIn { from { opacity: 0; transform: translateY(12px); } }
  @media (hover: hover) and (pointer: fine) {
    .card:hover { transform: translateY(-3px); border-color: var(--udem-bleu); }
  }
  /* Iconographie : contours larges, coins tantôt carrés, tantôt arrondis */
  .card .icon {
    width: 48px; height: 48px; display: grid; place-items: center;
    background: var(--udem-bleu); color: #fff; margin-bottom: 20px;
    border-radius: 0 14px 0 14px;
  }
  .card .icon svg { width: 24px; height: 24px; stroke-width: 2.4; }
  .card-title { margin: 0 0 10px; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
  .card a { color: var(--accent); font-weight: 500; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }

  .quote { margin: 4px 0 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--pilier, var(--accent)); max-width: 680px; }
  .quote p { margin: 0; font-family: var(--serif); font-style: italic; font-size: clamp(16px, 1.9vw, 18px); line-height: 1.55; color: var(--ink-2); }
  /* Repliée sur deux lignes tant que le lecteur ne demande pas la suite */
  .quote.is-collapsible:not(.is-expanded) p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .quote-toggle {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 6px 0; min-height: 28px;
    border: 0; background: none; cursor: pointer; font: 600 14px/1.2 var(--sans); color: var(--accent);
    user-select: none; -webkit-user-select: none; touch-action: manipulation;
  }
  .quote-toggle svg { transition: transform 250ms var(--ease-out); }
  .quote.is-expanded .quote-toggle svg { transform: rotate(180deg); }
  .quote.is-expanded p { animation: quoteOpen 300ms var(--ease-out); }
  @keyframes quoteOpen { from { opacity: 0.6; } }
  @media (hover: hover) and (pointer: fine) { .quote-toggle:hover span { text-decoration: underline; text-underline-offset: 3px; } }

  .quote cite { display: block; margin-top: 6px; font-style: normal; font-size: 14px; font-weight: 500; color: var(--ink-3); }
  .quote cite a { display: inline-block; padding-block: 4px; color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
  @media (hover: hover) and (pointer: fine) { .quote cite a:hover { color: var(--accent); } }

  .engage { margin: 0 0 16px; max-width: 680px; color: var(--ink-2); }
  .engage strong { color: var(--ink); }
  .engage a { color: var(--accent); text-underline-offset: 2px; }

  /* Contenu détaillé des piliers */
  .card .item + .item { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
  .card .item p { margin: 0; color: var(--ink-2); font-size: 15.5px; line-height: 1.5; }
  .card .subhead { margin: 20px 0 12px; padding-top: 16px; border-top: 1px solid var(--line); font: 600 15px/1.4 var(--sans); color: var(--ink); }
  .card-title + .subhead { margin-top: 0; padding-top: 0; border-top: 0; }
  .kpis { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
  .kpi { flex: 1 1 110px; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: var(--surface-2); border-radius: 6px; min-width: 0; }
  .kpi b { font: 700 24px/1.05 var(--sans); letter-spacing: -0.02em; color: var(--accent); font-variant-numeric: tabular-nums; }
  .kpi span { font-size: 13px; line-height: 1.35; color: var(--ink-2); }
  .links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
  .lchip {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
    font-size: 13.5px; font-weight: 600; text-decoration: none; color: var(--accent);
    border: 1.5px solid color-mix(in srgb, var(--accent) 35%, transparent);
    user-select: none; -webkit-user-select: none;
    transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease;
  }
  .lchip:active { transform: scale(0.97); }
  @media (hover: hover) and (pointer: fine) {
    .lchip:hover { background: var(--accent-soft); border-color: var(--accent); }
  }
  .group-title { font: 600 15px/1.3 var(--sans); color: var(--accent); margin: 32px 0 14px; display: flex; align-items: center; gap: 10px; }
  .group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
  .engage + .group-title { margin-top: 8px; }
  .panel .cards { display: block; columns: 2 340px; column-gap: 12px; }
  .panel .card { break-inside: avoid; margin-bottom: 12px; }
  .panel.active .card:nth-child(6) { animation-delay: 250ms; }
}
