/* ==========================================================================
   SUJASMIN — SHARED LAYOUT HELPERS + MOTION (loaded on every page)
   1. Centred card grids: one line when the cards fit, wrapped rows centred.
   2. Scroll reveal / stagger / hover motion. Honours prefers-reduced-motion.
   ========================================================================== */

/* ---- 1. Centred card grids (class + vars are applied by motion.js) ----- */
.is-centered-grid {
    --gap: 1rem;
    --cols: min(var(--n, 3), var(--max, 4));
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--gap);
}
.is-centered-grid > * {
    flex: 0 0 calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
    max-width: calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols));
    min-width: 0;
    margin-top: 0;
}
@media (max-width: 1099px) { .is-centered-grid { --cols: min(var(--n, 3), var(--max, 4), var(--tab, 3)); } }
@media (max-width: 799px)  { .is-centered-grid { --cols: min(var(--n, 3), var(--max, 4), 2); } }
@media (max-width: 559px)  { .is-centered-grid { --cols: 1; } }

/* ---- 2. Motion --------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
    @keyframes mo-page-in { from { opacity: 0; } to { opacity: 1; } }
    body { animation: mo-page-in .55s ease-out both; }

    /* Pre-reveal state (only exists once motion.js has tagged the element) */
    html.mo-on .mo {
        opacity: 0;
        transform: translate3d(0, 28px, 0);
        transition: opacity .8s cubic-bezier(.22, 1, .36, 1), transform .8s cubic-bezier(.22, 1, .36, 1);
        transition-delay: var(--mo-delay, 0ms);
        will-change: opacity, transform;
    }
    html.mo-on .mo.mo-left  { transform: translate3d(-32px, 0, 0); }
    html.mo-on .mo.mo-right { transform: translate3d(32px, 0, 0); }
    html.mo-on .mo.mo-zoom  { transform: scale(.94); }
    html.mo-on .mo.mo-in    { opacity: 1; transform: none; }

    /* Images inside revealed media ease from a slight zoom */
    html.mo-on .mo-img { transform: scale(1.08); transition: transform 1.4s cubic-bezier(.22, 1, .36, 1); }
    html.mo-on .mo-in .mo-img, html.mo-on .mo-in.mo-img { transform: scale(1); }

    /* Hover polish for linked cards / buttons */
    .btn { transition: transform .25s ease, box-shadow .25s ease, background-color .25s ease, color .25s ease, border-color .25s ease; }
    .btn:hover { transform: translateY(-2px); }
    .site-footer a { transition: color .2s ease, transform .2s ease; }
    .nav-link { transition: color .2s ease; }
}
@media (prefers-reduced-motion: reduce) {
    html.mo-on .mo, html.mo-on .mo-img { opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* Stacked layouts: reveal vertically only (avoids sideways overflow) */
@media (max-width: 900px) {
    html.mo-on .mo.mo-left, html.mo-on .mo.mo-right { transform: translate3d(0, 28px, 0); }
}
@media (max-width: 900px) {
    html.mo-on .mo.mo-left.mo-in, html.mo-on .mo.mo-right.mo-in { transform: none; }
}
