/* Panneau de détail (dialog) */
@layer components {
  .sheet { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; overflow: hidden; color: var(--ink); }
  .sheet::backdrop { background: transparent; }
  .sheet-scrim {
    position: absolute; inset: 0; background: rgba(11, 17, 58, .42);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    opacity: 0; transition: opacity 400ms ease;
  }
  .sheet.open .sheet-scrim { opacity: 1; }
  .sheet.closing .sheet-scrim { transition-duration: 220ms; }
  .sheet-panel {
    position: absolute; top: 0; right: 0; bottom: 0; width: min(580px, 100vw);
    display: flex; flex-direction: column; background: var(--bg);
    box-shadow: -24px 0 60px -30px rgba(11, 17, 58, .5);
    transform: translateX(100%);
    transition: transform 480ms var(--ease-drawer);
    will-change: transform;
  }
  .sheet.open .sheet-panel { transform: none; }
  .sheet.closing .sheet-panel { transition-duration: 260ms; transition-timing-function: cubic-bezier(0.4, 0, 1, 1); }
  .sheet-grab { padding: calc(20px + env(safe-area-inset-top)) 24px 18px; border-bottom: 1px solid var(--line); flex: none; }
  .sheet-handle { display: none; }
  .sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
  .sheet-kicker { font-size: 13px; font-weight: 600; color: var(--accent); display: flex; align-items: center; gap: 8px; min-width: 0; }
  .sheet-kicker::before { content: ""; width: 9px; height: 9px; background: var(--pilier, currentColor); flex: none; }
  .sheet-kicker span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sheet-close {
    flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
    display: grid; place-items: center; background: var(--surface-2); color: var(--ink);
    transition: transform 160ms var(--ease-out), background-color 150ms ease;
  }
  .sheet-close:active { transform: scale(0.94); }
  @media (hover: hover) and (pointer: fine) { .sheet-close:hover { background: var(--line); } }
  .sheet-title { display: flex; align-items: center; gap: 14px; }
  .sheet-title .icon { width: 48px; height: 48px; display: grid; place-items: center; flex: none; background: var(--pilier, var(--udem-bleu)); color: var(--pilier-ink, #fff); border-radius: 0 14px 0 14px; }
  .sheet-title .icon svg { width: 24px; height: 24px; stroke-width: 2.4; }
  .sheet-title h2 { margin: 0; max-width: none; font: 400 clamp(24px, 3vw, 30px)/1.15 var(--serif); letter-spacing: -0.01em; }
  .sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 22px 24px 28px; -webkit-overflow-scrolling: touch; }
  .sheet-body .card { border: 0; padding: 0; background: transparent; transform: none !important; animation: none !important; }
  .sheet-body .card .icon, .sheet-body .card-title { display: none; }
  .sheet-body .card .item p { font-size: 16px; }
  .sheet-foot {
    flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
  }
  .sheet-nav {
    display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 10px 14px; border-radius: 8px;
    border: 0; cursor: pointer; font: inherit; text-align: left; color: var(--ink); background: var(--surface-2);
    user-select: none; -webkit-user-select: none; touch-action: manipulation;
    transition: transform 160ms var(--ease-out), background-color 150ms ease, opacity 150ms ease;
  }
  .sheet-nav.next { text-align: right; align-items: flex-end; }
  .sheet-nav:active { transform: scale(0.97); }
  .sheet-nav:disabled { opacity: 0.35; cursor: default; transform: none; }
  .sheet-nav small { font-size: 12px; font-weight: 600; color: var(--accent); }
  .sheet-nav span { font-size: 14px; font-weight: 600; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  @media (hover: hover) and (pointer: fine) { .sheet-nav:not(:disabled):hover { background: var(--accent-soft); } }

  /* Mobile : feuille qui monte du bas, qu'on peut glisser pour fermer */
  @media (max-width: 720px) {
    .sheet-panel {
      top: auto; left: 0; width: 100%; max-height: 90dvh;
      border-radius: 20px 20px 0 0; box-shadow: 0 -20px 50px -25px rgba(11, 17, 58, .5);
      transform: translateY(100%);
    }
    .sheet-grab { padding-top: 10px; touch-action: none; cursor: grab; }
    .sheet-handle { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
    .sheet-top { margin-bottom: 14px; }
  }
  /* Ordinateur : panneau flottant centré, haut comme son contenu (plus de grand vide sous un court texte).
     Centré par inset + margin auto et non par transform : transform sert aux animations d’entrée et de sortie. */
  @media (min-width: 721px) {
    .sheet-panel {
      inset: 0; margin: auto; width: min(640px, 100vw - 48px);
      height: -webkit-fit-content; height: fit-content; max-height: calc(100dvh - 48px);
      border-radius: 16px; box-shadow: 0 30px 80px -30px rgba(11, 17, 58, .55);
      opacity: 0; transform: translateY(16px) scale(0.97);
      transition: transform 420ms var(--ease-drawer), opacity 260ms ease;
    }
    .sheet.open .sheet-panel { opacity: 1; }
    .sheet-body { flex: 0 1 auto; }
    .sheet-grab { padding-top: 20px; }
  }
  .sheet.dragging .sheet-panel { transition: none; }
  .sheet-morph { display: none; position: absolute; inset: 0; pointer-events: none; will-change: clip-path; }
  .sheet.morph .sheet-morph { display: block; }
  .sheet.morph .sheet-panel { transition: none; transform: none; }
  .sheet-fly { position: fixed; z-index: 2; margin: 0; display: grid; place-items: center; background: var(--pilier, var(--udem-bleu)); color: var(--pilier-ink, #fff); border-radius: 0 14px 0 14px; transform-origin: 0 0; pointer-events: none; will-change: transform; }
  .sheet-fly svg { width: 24px; height: 24px; stroke-width: 2.4; }


  @media (prefers-reduced-motion: reduce) {
    .sheet-panel, .sheet.open .sheet-panel { transform: none !important; opacity: 0; transition: opacity 200ms ease; }
    .sheet.open .sheet-panel { opacity: 1; }
    .panel.active .tile { animation: fadeOnly 200ms ease; }
  }
  @media (prefers-reduced-transparency: reduce) {
    .sheet-scrim { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(11, 17, 58, .6); }
  }
}
