/* =============================================================================
   CLIP-REVEAL — Circle-expand animation token
   Design system primitive. Works on any element.

   Origin set via --clip-x / --clip-y custom properties.
   Durations/easing from tokens.css (--reveal-duration-*, --reveal-easing-*).
   ============================================================================= */

/* Step 1: Set origin, clip to zero — no transition (instant) */
.clip-reveal--preparing {
    clip-path: circle(0% at var(--clip-x, 50%) var(--clip-y, 50%));
    transition: none;
    opacity: 1;
    visibility: visible;
}

/* Step 2: Expand to full — smooth open */
.clip-reveal--open {
    clip-path: circle(var(--reveal-radius, 150%) at var(--clip-x, 50%) var(--clip-y, 50%));
    transition: clip-path var(--reveal-duration-open, 0.4s) var(--reveal-easing-open, cubic-bezier(.4, .0, .2, 1));
    opacity: 1;
    visibility: visible;
}

/* Step 3: Collapse back to origin — faster close */
.clip-reveal--collapsing {
    clip-path: circle(0% at var(--clip-x, 50%) var(--clip-y, 50%));
    transition: clip-path var(--reveal-duration-close, 0.3s) var(--reveal-easing-close, cubic-bezier(.4, .0, .8, 1));
}

/* When clip-reveal is active on a fullscreen-panel, pin to translateX(0) instead of
   removing the transform. Using translateX(0) instead of 'none' keeps the GPU
   compositing layer stable and prevents a white flash from layer creation/destruction. */
.fullscreen-panel.clip-reveal--open,
.fullscreen-panel.clip-reveal--preparing,
.fullscreen-panel.clip-reveal--collapsing {
    transform: translateX(0) !important;
    max-width: 100%;
    inset: 0;
    right: 0;
    width: 100%;
}

@keyframes clip-reveal-spin {
    to { transform: rotate(360deg); }
}

html.app-shell-return-loading {
    background: var(--surface-app);
}

html.app-shell-return-loading::before {
    content: "";
    position: fixed;
    z-index: 0;
    top: 50%;
    left: 50%;
    width: calc(var(--size-16) + var(--space-3));
    height: calc(var(--size-16) + var(--space-3));
    margin: calc((var(--size-16) + var(--space-3)) / -2) 0 0 calc((var(--size-16) + var(--space-3)) / -2);
    border: var(--space-1) solid color-mix(in srgb, var(--text-primary) 12%, transparent);
    border-top-color: var(--accent-primary);
    border-radius: var(--radius-full);
    animation: clip-reveal-spin var(--duration-slow) linear infinite;
}

html.app-shell-return-loading::after {
    content: "Loading...";
    position: fixed;
    z-index: 0;
    top: calc(50% + var(--size-12));
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    letter-spacing: 0;
    text-transform: uppercase;
}

body.app-shell-closing {
    position: relative;
    z-index: 1;
    overflow: hidden;
}
