/* ==== The product's one motion language ===========================================================
   Linked by every host: the website (Blazor Server, WebAssembly and MAUI) and the Partner portal,
   which reaches it through its reference to Cim360.cloud.Shared. One stylesheet rather than a copy
   in each, so the two sites cannot drift. Colours are NOT set here - only movement - which is why
   it is safe to load beside the portal's own palette.

   The feel is soft. Hover, focus and press answer in 120-240 ms on a standard ease-out. Arrival is
   slower and gentler: tiles rise into place one after another (520 ms on a long, decelerating
   curve, 55 ms apart), and headline figures count up over 650 ms. Nothing is springy and nothing
   overshoots.

   Four rules every animation here obeys:
     - Content is readable and every control usable from the first frame. Entry animations start
       from a visible state (a tile or mark already 55-60% there), never from opacity 0, and nothing sets
       pointer-events.
     - It runs when something is CREATED, or when a real change reaches the DOM (see
       cim360-motion.js). A re-render that changes nothing writes nothing and so replays nothing.
     - A reader who asked for no motion gets none: prefers-reduced-motion zeroes every duration and
       the lift below, so any rule written with the tokens is already correct for them.
     - A focus ring is never clipped: nothing here sets overflow, and the lift is a translate that
       moves the ring with the element.
   ================================================================================================ */

:root {
    --cim360-motion-fast: 120ms;   /* colour and opacity: hover, focus, press */
    --cim360-motion-base: 180ms;   /* a mark or surface moving: bars, lift, reorder */
    --cim360-motion-slow: 240ms;   /* the largest single movement: pop-out, chart draw-in */
    --cim360-motion-count: 650ms;  /* a headline figure counting to its value */
    --cim360-motion-enter: 520ms;  /* a tile, and the marks inside it, arriving */
    --cim360-stagger: 55ms;        /* the gap between one tile arriving and the next */
    --cim360-ease-out: cubic-bezier(0, 0, 0.2, 1);
    /* Entry only: decelerates long and gently, so a tile lands rather than stops. */
    --cim360-ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
    --cim360-lift: -2px;           /* how far a hovered tile rises */
    --cim360-lift-shadow: 0 0.375rem 1rem rgba(15, 23, 42, .12), 0 1px 0.1875rem rgba(15, 23, 42, .08);

    /* The transition a tile wears, so a stylesheet that already has its own tile declares
       `transition: var(--cim360-tile-transition)` instead of its own list. */
    --cim360-tile-transition:
        transform var(--cim360-motion-base) var(--cim360-ease-out),
        box-shadow var(--cim360-motion-base) var(--cim360-ease-out),
        border-color var(--cim360-motion-fast) var(--cim360-ease-out),
        background-color var(--cim360-motion-fast) var(--cim360-ease-out);
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --cim360-motion-fast: 0ms;
        --cim360-motion-base: 0ms;
        --cim360-motion-slow: 0ms;
        --cim360-motion-count: 0ms;
        --cim360-motion-enter: 0ms;
        --cim360-stagger: 0ms;
        --cim360-lift: 0px;
    }
}

/* ---- chart draw-in ---------------------------------------------------------------------------
   Plays when a mark is created, which is the first time a tile shows data and any change that
   replaces the chart. A change that patches the same <svg> in place is replayed by
   cim360-motion.js. Only `from` is written: the end state is the mark as drawn, so a mark with its
   own opacity (a stacked band at .85) finishes at its own value. */

/* ---- tiles arrive one after another -----------------------------------------------------------
   Every tile animating at the same instant read as one jolt. Each tile instead rises a little
   way into place, a beat after the one before it. cim360-motion.js gives each new tile its place
   among its siblings as --c360-i, capped so the last tile of a long list is never kept waiting.
   The property inherits, so every mark and figure inside a tile starts with its own tile.

   `backwards` holds the start frame through the delay. That frame is a tile already 60% there,
   so nothing waiting is ever blank or unreadable. */

@keyframes c360-tile-enter { from { opacity: .6; transform: translateY(.5rem); } }

.c360-dash-tile,
.cim-kpi-strip > .cim-kpi-tile,
.c360-card-tile,
.qic-tile,
.stk-rec-tile,
.bss-kpi,
.wh-tile,
.onb-tile,
.viz-tile,
.onb-pt {
    animation: c360-tile-enter var(--cim360-motion-enter) var(--cim360-ease-soft) backwards;
    animation-delay: calc(var(--c360-i, 0) * var(--cim360-stagger));
}

/* A tile being dragged, or one that has been dropped, is placed by FLIP rather than entering. */
.c360-dash-tile.is-dragging { animation: none; }

/* ---- chart draw-in ---------------------------------------------------------------------------
   The marks inside a tile follow it in: the same delay, plus a short beat, and they start most of
   the way drawn, so they settle into place rather than shoot out. */

@keyframes c360-mark-grow-y { from { transform: scaleY(.55); opacity: .55; } }
@keyframes c360-mark-grow-x { from { transform: scaleX(.55); opacity: .55; } }
@keyframes c360-mark-reveal { from { clip-path: inset(0 25% 0 0); opacity: .55; } }
@keyframes c360-mark-fade { from { opacity: .45; } }

.c360-mark-col, .viz-bar-mark,
.c360-bar-fill, .c360-stack, .bdc-fill, .bdc-cap-fill, .bdc-tl-fill, .onb-bar > i,
.c360-chart-line, .c360-chart-series, .c360-chart-area, .c360-mark-area, .c360-mark-line, .viz-spark-line,
.c360-chart-marker, .c360-chart-marker-hollow, .c360-chart-series-marker, .c360-chart-connector,
.c360-chart-prior, .c360-chart-prior-marker, .c360-pie-slice, .viz-spark-dot, .viz-end-dot {
    animation-duration: var(--cim360-motion-enter);
    animation-timing-function: var(--cim360-ease-soft);
    animation-fill-mode: backwards;
    animation-delay: calc(var(--c360-i, 0) * var(--cim360-stagger) + var(--cim360-motion-fast));
}

/* Grows from the baseline. */
.c360-mark-col,
.viz-bar-mark {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation-name: c360-mark-grow-y;
}

/* Grows from the left, the way a horizontal bar is read. */
.c360-bar-fill,
.c360-stack,
.bdc-fill,
.bdc-cap-fill,
.bdc-tl-fill,
.onb-bar > i {
    transform-origin: 0 50%;
    animation-name: c360-mark-grow-x;
}

/* A bar that already exists and changes length slides to its new length. */
.c360-bar-fill,
.onb-bar > i {
    transition: width var(--cim360-motion-base) var(--cim360-ease-out),
                background-color var(--cim360-motion-fast) var(--cim360-ease-out);
}

.c360-bar-fill.is-stacked > i,
.c360-stack > * {
    transition: flex-grow var(--cim360-motion-base) var(--cim360-ease-out),
                filter var(--cim360-motion-fast) var(--cim360-ease-out);
}

/* Lines and areas are revealed left to right. */
.c360-chart-line,
.c360-chart-series,
.c360-chart-area,
.c360-mark-area,
.c360-mark-line,
.viz-spark-line {
    animation-name: c360-mark-reveal;
}

/* Points, rings and connectors fade in. */
.c360-chart-marker,
.c360-chart-marker-hollow,
.c360-chart-series-marker,
.c360-chart-connector,
.c360-chart-prior,
.c360-chart-prior-marker,
.c360-pie-slice,
.viz-spark-dot,
.viz-end-dot {
    animation-name: c360-mark-fade;
}

/* ---- inside a SIZE container a tile arrives by script ------------------------------------------
   The BOM and build cards' main column is `container-type: size` (the summary strip asks how tall
   the card is). In there, Chromium starts a CSS entry again with nothing in the DOM or the
   stylesheets changing - every time it ends, and on every change to the container's content (each
   tab switch) - so the Commercials, Build from and Supply tiles kept rising from 60% opacity:
   motion that never stopped (2.2.2) and captions under 4.5:1 while it ran (1.4.3, measured 3.44:1).
   cim360-motion.js finds any tile inside a size container, plays the same entry once with
   element.animate(), which no style pass can restart, and marks the tile so the CSS entry is off. */
[data-c360-enter="script"] {
    animation: none !important;
}

/* cim360-motion.js sets this for one frame, with a style flush while it is on, so that removing it
   restarts every animation above. */
.is-redrawing * { animation: none !important; }

/* ---- a headline figure counting up -------------------------------------------------------------
   The real text stays in place and is what a screen reader and a copy-paste get; it is only made
   transparent while the overlay (aria-hidden, added and removed by cim360-motion.js) draws the
   intermediate values on top of it. */
[data-c360-counting] {
    position: relative;
    color: transparent !important;
}

.c360-count-face {
    position: absolute;
    inset: 0;
    text-align: inherit;
    white-space: nowrap;
    overflow: visible;
    pointer-events: none;
}

/* ---- tiles that can be pressed -------------------------------------------------------------
   A soft lift on hover and keyboard focus, a small dip on press. Only tiles that DO something:
   a tile that is a button, a link, a label wrapping a radio or an action card. A tile that is only
   a figure gets no hover at all, because a hover promises a click.

   A selected tile keeps its own ring (it is a state, not a hover), so the lift shadow is not laid
   over it. transform rather than top or margin: nothing around it reflows, and a focus ring moves
   with the tile instead of being clipped. */
:is(.wh-tile, .onb-tile, .gs-tile, .c360-radiocard, .onb-pt, .co-role-tile, .co-theme-tile, .btk-tile, .sof-tile):is(button, a, label, [role="button"], [role="radio"], [role="tab"]):not(:disabled):not(.is-disabled):not([aria-disabled="true"]) {
    transition: var(--cim360-tile-transition);
}

:is(.wh-tile, .onb-tile, .gs-tile, .c360-radiocard, .onb-pt, .co-role-tile, .co-theme-tile, .btk-tile, .sof-tile):is(button, a, label, [role="button"], [role="radio"], [role="tab"]):not(:disabled):not(.is-disabled):not([aria-disabled="true"]):is(:hover, :focus-visible, :focus-within) {
    transform: translateY(var(--cim360-lift));
}

:is(.wh-tile, .onb-tile, .gs-tile, .c360-radiocard, .onb-pt, .co-role-tile, .co-theme-tile, .btk-tile, .sof-tile):is(button, a, label, [role="button"], [role="radio"], [role="tab"]):not(:disabled):not(.is-disabled):not([aria-disabled="true"]):not(.on):not(.is-on):not(.is-selected):not(.active):is(:hover, :focus-visible) {
    box-shadow: var(--cim360-lift-shadow);
}

:is(.wh-tile, .onb-tile, .gs-tile, .c360-radiocard, .onb-pt, .co-role-tile, .co-theme-tile, .btk-tile, .sof-tile):is(button, a, label, [role="button"], [role="radio"], [role="tab"]):not(:disabled):not(.is-disabled):not([aria-disabled="true"]):active {
    transform: translateY(1px);
    box-shadow: none;
}

/* The KPI strip's clickable tiles sit in a banded strip, so they do not rise; they answer in place. */
.cim-kpi-btn:not(.is-static) {
    transition: background-color var(--cim360-motion-fast) var(--cim360-ease-out),
                transform var(--cim360-motion-fast) var(--cim360-ease-out);
}

.cim-kpi-btn:not(.is-static):active { transform: translateY(1px); }
