/* ═══════════════════════════════════════════════════════════════════
   MOTION LAYER — public site and console (owner, 2026-10-25: «tutto deve essere wow»)
   Loaded last by head.php and console_head.php, with /js/motion.js.
   · pages cross-fade into each other on phones and tablets (cross-document View Transitions; the bar stays put; not on a computer, where the page is zoomed)
   · page titles rise in from a blur; the console masthead rule draws itself
   · a light follows the cursor on cards (console plates, panels, contact channels, related services)
   · red buttons catch a sheen on hover
   · a hairline reading-progress bar on long public pages
   Everything is skipped under prefers-reduced-motion; without support the pages are simply static.
   ═══════════════════════════════════════════════════════════════════ */

/* Cross-fade between pages only where the page is not zoomed: on a computer the pages are at 90% (css/scale.css, `zoom` on <html>) and a view transition snapshots
   the zoomed root and the sidebar at the wrong size: for the first moments of every click the page showed 11% too big and the sidebar's bottom (the user's circle)
   cropped, until the new page was ready (about 2s on the hosting). Phones and tablets (no zoom) keep it. */
@media (prefers-reduced-motion: no-preference) and (not ((hover: hover) and (pointer: fine))) {
    @view-transition { navigation: auto; }
    ::view-transition-old(root) { animation: mvVtOut 180ms cubic-bezier(.4, 0, 1, 1) both; }
    ::view-transition-new(root) { animation: mvVtIn 420ms cubic-bezier(.16, 1, .3, 1) both; }
    #main-nav, .app-nav { view-transition-name: mv-bar; }
    ::view-transition-group(mv-bar) { animation: none; }
    /* the reading bar belongs to a page, not to the cross-fade: without its own name the old page's
       full-width bar fades out and rises over the new title, which looked like red bars flashing */
    .mv-progress { view-transition-name: mv-progress; }
    ::view-transition-group(mv-progress) { animation: none; }
    ::view-transition-old(mv-progress) { display: none; }
    ::view-transition-new(mv-progress) { animation: none; }
}
/* one reading bar on the public site: animations.js adds its own, motion.js this one */
body.pub #scroll-progress { display: none; }
@keyframes mvVtOut { to { opacity: 0; transform: translateY(-8px); } }
@keyframes mvVtIn { from { opacity: 0; transform: translateY(14px); } }

/* Titles: a short settle with the text already readable (no start delay, 2026-11-15), once per page (no blur: a blurred red title smeared into pink bars while the pages cross-fade) */
@keyframes mvTitleIn { from { opacity: .35; transform: translateY(.18em); } }
@keyframes mvRuleIn { from { width: 0; } }
@media (prefers-reduced-motion: no-preference) {
    body.pub .page-intro h1, body.pub .page-intro .label, body.pub .page-intro h1 + p { animation: mvTitleIn 420ms cubic-bezier(.16, 1, .3, 1) both; }
    .app-main > h1, .page-title-row h1 { animation: mvTitleIn 420ms cubic-bezier(.16, 1, .3, 1) both; }
    .app-main > h1::after, .page-title-row::after { animation: mvRuleIn 900ms 250ms cubic-bezier(.16, 1, .3, 1) both; }
}

/* Cursor light: motion.js sets --mx/--my on hover; a background layer, so the cards' own ::before/::after stay theirs.
   !important on the image only: several cards reset `background` (shorthand) on :hover, which would drop the light. */
.mv-spot {
    background-image: radial-gradient(380px circle at var(--mx, -999px) var(--my, -999px), rgba(var(--mv-spot-rgb, 34, 184, 207), .14), transparent 62%) !important;
    transition: border-color 220ms var(--ease-out), background-color 220ms var(--ease-out);
}
.mv-spot:hover { border-color: rgba(var(--mv-spot-rgb, 34, 184, 207), .38); }

/* Red buttons: a sheen crosses on hover (owner, 2026-11-18: «deve essere proposto su ogni tasto rosso simile»): the primary buttons, the console's round +,
   «Installa su ChatGPT» on /mcp-demo; the login loads this file for its «Accedi». The demos keep their own buttons. */
.btn-primary, .adm-plus, .mcp-install-btn { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::after, .adm-plus::after, .mcp-install-btn::after {
    content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .38) 50%, transparent 70%);
    transform: translateX(-120%);
}
@media (prefers-reduced-motion: no-preference) {
    .btn-primary:hover::after, .adm-plus:hover::after, .mcp-install-btn:hover::after { transform: translateX(120%); transition: transform 700ms cubic-bezier(.16, 1, .3, 1); }
}

/* Reading progress (public, long pages only: motion.js adds the bar) */
.mv-progress {
    position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 1001; pointer-events: none;
    background: linear-gradient(90deg, var(--mv-accent, #22b8cf), var(--mv-accent-text, #7dd3fc)); transform-origin: 0 50%; transform: scaleX(0);
}
@supports (animation-timeline: scroll()) {
    @media (prefers-reduced-motion: no-preference) {
        .mv-progress { animation: mvProgress linear both; animation-timeline: scroll(root); }
    }
}
@keyframes mvProgress { to { transform: scaleX(1); } }

/* Console hub: a numbered index (01 Users, 02 Projects…) */
.admin-grid--index { counter-reset: mv-hub; }
.admin-grid--index > .admin-card h2::before {
    counter-increment: mv-hub; content: counter(mv-hub, decimal-leading-zero);
    display: inline-block; min-width: 2.2rem; margin-right: .35rem; vertical-align: .45em;
    font: 500 .8125rem/1 var(--font-mono); letter-spacing: .08em; color: var(--mv-accent-text, var(--mv-accent));
}
.admin-grid--index > .admin-card .panel-cta { transition: letter-spacing 260ms var(--ease-out), background-size .25s var(--ease-out); }
.admin-grid--index > .admin-card:hover .panel-cta { letter-spacing: .12em; }
