/*
 * O1 · Modale e sheet (docs/ui/COMPONENTI.md). Base: <dialog> nativo + wwwroot/js/components/hy-modal.js.
 */
dialog.hy-modal {
    width: 600px; max-width: calc(100vw - 32px); max-height: 90vh; padding: 0; margin: auto;
    border: 1px solid var(--hy-glass-border); border-radius: var(--hy-radius-lg);
    background: var(--hy-surface-raised); color: var(--hy-text); box-shadow: var(--hy-shadow-3);
    font-family: var(--hy-font-sans); font-size: var(--hy-text-md);
}
dialog.hy-modal[open] { display: flex; flex-direction: column; }
dialog.hy-modal::backdrop { background: var(--hy-backdrop); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
/* "dialog." come la regola base, altrimenti la larghezza delle varianti non vince mai (corretto il 2026-10-21) */
dialog.hy-modal--sm { width: 420px; }
dialog.hy-modal--lg { width: 800px; }
dialog.hy-modal--xl { width: min(1080px, calc(100vw - 32px)); }

/* Senza linee tra intestazione, contenuto e bottoni (richiesta dell'utente 2026-10-23): la separazione la danno gli spazi */
.hy-modal__head { display: flex; align-items: center; gap: 8px; padding: 16px 16px 4px 24px; }
.hy-modal__title { flex: 1; margin: 0; font: var(--hy-weight-strong) var(--hy-text-xl)/1.3 var(--hy-font-heading); color: var(--hy-text); overflow: hidden; text-overflow: ellipsis; }
.hy-modal__body { flex: 1; overflow: auto; padding: 12px 24px 16px; }
.hy-modal__body > p:last-child { margin-bottom: 0; }
.hy-modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 24px 20px; }
.hy-modal__handle { display: none; }

html.hy-modal-open { overflow: hidden; }

/* Smartphone: form a schermo intero, conferme e menu come sheet dal basso */
@media (max-width: 767.98px) {
    dialog.hy-modal {
        width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0;
        border-radius: 0; border: 0;
        padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    }
    dialog.hy-modal.hy-modal--sm {
        height: fit-content; max-height: 85dvh; margin: auto 0 0; border-radius: var(--hy-radius-lg) var(--hy-radius-lg) 0 0;
    }
    .hy-modal--sm .hy-modal__handle { display: block; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--hy-border-control); }
    .hy-modal__head { padding-left: 16px; }
    .hy-modal__body { padding: 16px; }
    .hy-modal__foot { padding: 12px 16px; }
    .hy-modal__foot .hy-btn { flex: 1; }
}
