/* =========================================================
   UI PRO LAYER (all portals)
   Loaded on every page by includes/portal_theme.php, after
   css/ui-polish.css. Additive only: no markup or layout changes.
   - :where() rules have zero specificity, so a page's own
     styles always win where they define the same thing.
   - Works with js/ui-pro.js (reveal, count-up, ripple, scroll
     shadow). Without JS, nothing is hidden or broken.
   To switch everything off, delete the <link> / <script> lines
   for ui-pro in includes/portal_theme.php.
========================================================= */


/* ---------- App-like page transitions ---------- */
/* Sidebar and top bar stay in place; only the page content
   cross-fades (Chrome/Edge; other browsers load normally). */

.sidebar {
    view-transition-name: sdis-sidebar;
}

.topbar {
    view-transition-name: sdis-topbar;
}

::view-transition-group(sdis-sidebar),
::view-transition-group(sdis-topbar) {
    animation-duration: 0s;
}

::view-transition-old(root) {
    animation: uiProFadeOut .16s cubic-bezier(.4, 0, 1, 1) both;
}

::view-transition-new(root) {
    animation: uiProFadeUp .28s cubic-bezier(.2, .8, .2, 1) both;
}

/* After an in-app navigation the sidebar doesn't re-play its
   entrance animation (set by js in <head>). */
.ui-vt .sidebar,
.ui-vt .sidebar * {
    animation: none !important;
}


/* ---------- Top bar gains depth when the page scrolls ---------- */

.ui-scrolled :where(.topbar, .navbar.sticky-top, header.sticky-top) {
    box-shadow: 0 10px 30px rgba(15, 23, 42, .08);
}


/* ---------- Scroll reveal (classes added by ui-pro.js) ---------- */

.ui-reveal {
    opacity: 0;
    transform: translate3d(0, 16px, 0);
}

.ui-reveal.ui-reveal-in {
    opacity: 1;
    transform: none;
    transition:
        opacity .55s cubic-bezier(.2, .8, .2, 1),
        transform .55s cubic-bezier(.2, .8, .2, 1);
    transition-delay: var(--ui-reveal-delay, 0s);
}


/* ---------- Click ripple (element added by ui-pro.js) ---------- */

.ui-ripple-wrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
    pointer-events: none;
    z-index: 0;
}

.ui-ripple {
    position: absolute;
    border-radius: 50%;
    background: currentColor;
    opacity: .18;
    transform: scale(0);
    animation: uiProRipple .6s cubic-bezier(.2, .8, .2, 1) forwards;
    pointer-events: none;
}


/* ---------- Buttons ---------- */

:where(.btn-primary, .btn-success, .btn-danger, .btn-warning, .btn-info, .btn-dark, .btn-secondary):not(:disabled):not(.disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, .14);
}

:where(.btn-outline-primary, .btn-outline-secondary, .btn-outline-success, .btn-outline-danger, .btn-outline-warning, .btn-outline-info, .btn-light):not(:disabled):not(.disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(15, 23, 42, .08);
}

:where(.btn) .bi {
    transition: transform .2s cubic-bezier(.2, .8, .2, 1);
}

:where(.btn):hover .bi-arrow-right,
:where(.btn):hover .bi-chevron-right {
    transform: translateX(2px);
}

:where(.btn, .portal-back-btn):hover .bi-arrow-left {
    transform: translateX(-2px);
}

:where(.portal-back-btn) .bi {
    transition: transform .2s cubic-bezier(.2, .8, .2, 1);
}


/* ---------- Clickable cards lift gently ---------- */

:where(a.card, a[class*="-card"], .stat-link > [class*="-card"]) {
    transition:
        transform .25s cubic-bezier(.2, .8, .2, 1),
        box-shadow .25s cubic-bezier(.2, .8, .2, 1),
        border-color .25s ease;
}

:where(a.card, a[class*="-card"]):hover,
:where(.stat-link):hover > :where([class*="-card"]) {
    transform: translateY(-3px);
    box-shadow: 0 16px 34px rgba(15, 23, 42, .10);
}


/* ---------- Forms ---------- */

:where(.form-control, .form-select):hover:not(:focus):not(:disabled):not([readonly]) {
    border-color: rgba(var(--accent-rgb, 37, 99, 235), .45);
}

:where(.form-control, .form-select):focus {
    transition: border-color .15s ease, box-shadow .2s ease;
}

:where(.form-check-input) {
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

:where(.form-control)::placeholder {
    transition: opacity .2s ease;
}

:where(.form-control):focus::placeholder {
    opacity: .55;
}


/* ---------- Tables ---------- */

:where(.table) {
    --bs-table-hover-bg: rgba(var(--accent-rgb, 37, 99, 235), .05);
    --bs-table-active-bg: rgba(var(--accent-rgb, 37, 99, 235), .08);
}


/* ---------- Badges & pills ---------- */

:where(.badge, .status-pill, .status-badge) {
    transition: transform .2s ease, box-shadow .2s ease;
}


/* ---------- Data visuals animate in ---------- */

/* Admin dashboard rings fill from 0 to their value */
@property --chart-progress {
    syntax: '<percentage>';
    inherits: false;
    initial-value: 0%;
}

.stat-chart[style*="--chart-progress"] {
    animation: uiProRingFill 1.1s cubic-bezier(.2, .8, .2, 1) .15s backwards;
}

/* Bars grow from the left */
:where(.report-bar-fill, .progress-bar:not(.progress-bar-animated)) {
    animation: uiProGrow .9s cubic-bezier(.2, .8, .2, 1) .1s backwards;
}


/* ---------- Empty states ---------- */

:where(.empty-icon, .empty-state-icon) {
    animation: uiProFloat 3.6s ease-in-out infinite;
}


/* ---------- Spinners ---------- */

:where(.spinner-border) {
    --bs-spinner-animation-speed: .65s;
}


/* ---------- Keyframes ---------- */

@keyframes uiProFadeOut {
    to {
        opacity: 0;
    }
}

@keyframes uiProFadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@keyframes uiProRipple {
    to {
        transform: scale(1);
        opacity: 0;
    }
}

@keyframes uiProRingFill {
    from {
        --chart-progress: 0%;
    }
}

@keyframes uiProGrow {
    from {
        width: 0;
    }
}

@keyframes uiProFloat {
    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}


/* ---------- Reduced motion & print safety ---------- */

@media (prefers-reduced-motion: reduce) {
    .ui-reveal {
        opacity: 1 !important;
        transform: none !important;
    }

    .ui-ripple-wrap {
        display: none !important;
    }
}

@media print {
    .ui-reveal {
        opacity: 1 !important;
        transform: none !important;
    }

    .ui-ripple-wrap {
        display: none !important;
    }

    .ui-scrolled :where(.topbar) {
        box-shadow: none;
    }
}
