/* Workspace block polish: Smoove-like scroll reveal + side ribbon badges (no jQuery). */

.rd-item-card.rd-smoove {
    position: relative;
    overflow: visible;
    transition:
        opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.58s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.4s ease,
        box-shadow 0.2s ease;
    will-change: opacity, transform;
}

/*
 * Entrance (default when armed and not yet in / not exiting):
 * used on first paint and when re-entering after an exit.
 */
.rd-item-card.rd-smoove.rd-smoove--armed:not(.rd-smoove--in):not(.rd-smoove--out) {
    opacity: 0;
    transform: translate3d(0, 28px, 0) scale(0.96);
    transition-delay: calc(var(--rd-smoove-i, 0) * 40ms);
}

.rd-item-card.rd-smoove.rd-smoove--armed.rd-smoove--move:not(.rd-smoove--in):not(.rd-smoove--out) {
    transform: translate3d(-36px, 24px, 0);
}

.rd-item-card.rd-smoove.rd-smoove--armed.rd-smoove--rotate:not(.rd-smoove--in):not(.rd-smoove--out) {
    transform: translate3d(0, 20px, 0) rotate(-8deg) scale(0.94);
}

.rd-item-card.rd-smoove.rd-smoove--armed.rd-smoove--scale:not(.rd-smoove--in):not(.rd-smoove--out) {
    transform: translate3d(0, 16px, 0) scale(0.82);
    filter: blur(1.5px);
}

.rd-item-card.rd-smoove.rd-smoove--armed.rd-smoove--skew:not(.rd-smoove--in):not(.rd-smoove--out) {
    transform: translate3d(24px, 18px, 0) skewX(-8deg);
}

.rd-item-card.rd-smoove.rd-smoove--armed.rd-smoove--mix:not(.rd-smoove--in):not(.rd-smoove--out) {
    transform: translate3d(18px, 28px, 0) rotate(6deg) scale(0.9);
    filter: saturate(0.7);
}

/*
 * Exit — starts while card is still partially visible (JS rootMargin).
 * Scrolling down: shrink/fade upward; scrolling up: shrink/fade downward.
 */
.rd-item-card.rd-smoove.rd-smoove--armed.rd-smoove--out:not(.rd-smoove--in),
.rd-item-card.rd-smoove.rd-smoove--armed.rd-smoove--exit-down:not(.rd-smoove--in) {
    opacity: 0;
    transform: translate3d(0, -32px, 0) scale(0.88);
    filter: blur(1.2px);
    transition-delay: 0ms;
    pointer-events: none;
}

.rd-item-card.rd-smoove.rd-smoove--armed.rd-smoove--exit-up:not(.rd-smoove--in) {
    opacity: 0;
    transform: translate3d(0, 36px, 0) scale(0.88);
    filter: blur(1.2px);
    transition-delay: 0ms;
    pointer-events: none;
}

.rd-item-card.rd-smoove.rd-smoove--in {
    opacity: 1;
    transform: none;
    filter: none;
    transition-delay: calc(var(--rd-smoove-i, 0) * 40ms);
    pointer-events: auto;
}

.rd-item-card.rd-smoove.rd-smoove--in:hover {
    box-shadow: 0 6px 18px rgba(15, 40, 80, 0.14);
}

/* Beautify mark (sparkle) — bottom corner; clear of side ribbon */
.rd-beautify-mark {
    position: absolute;
    inset-inline-end: 6px;
    bottom: 4px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    pointer-events: none;
    opacity: 0.92;
}

.rd-beautify-mark .mud-icon-root,
.rd-beautify-mark svg {
    font-size: 11px !important;
    width: 11px !important;
    height: 11px !important;
}

.rd-chip-query .rd-beautify-mark { color: #5F8F99; }
.rd-chip-composite .rd-beautify-mark { color: #B8894E; }
.rd-chip-form .rd-beautify-mark { color: #8B7399; }

/*
 * Side type label ribbon (flat strip):
 *   - flush INSIDE the card start edge (RTL → right)
 *   - same height as the block (top + bottom aligned)
 *   - rectangular (no fold triangle, no swallowtail tip)
 *   - start-corner radii match the card so nothing protrudes
 */
.rd-item-card {
    overflow: visible !important;
}

/* Ribbon owns the start accent — no leftover thick / mismatched border edge. */
.rd-item-card:has(> .rd-label-ribbon) {
    --rd-ribbon-w: 1.35rem;
    border-inline-start-width: 0;
    border-inline-start-color: transparent;
    /* Continuity with ribbon strip — avoid a light gap on the start edge */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.rd-label-ribbon {
    --rd-ribbon: #6FA8B4;
    --rd-ribbon-deep: #4E7A84;
    --rd-ribbon-w: 1.35rem;
    --rd-ribbon-radius: 10px;
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    z-index: 6;
    width: var(--rd-ribbon-w);
    height: auto;
    max-height: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    border-start-start-radius: var(--rd-ribbon-radius);
    border-end-start-radius: var(--rd-ribbon-radius);
}

.rd-label-ribbon__band {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 100%;
    box-sizing: border-box;
    padding: 0.28rem 0.1rem;
    color: #fff;
    text-align: center;
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 1.15;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
    background-color: var(--rd-ribbon);
    background-image: linear-gradient(
        180deg,
        color-mix(in srgb, var(--rd-ribbon) 78%, #ffffff) 0%,
        var(--rd-ribbon) 42%,
        color-mix(in srgb, var(--rd-ribbon) 86%, #000000) 100%
    );
    /* Flat rectangle — no clip-path swallowtail */
    border-radius: 0;
    filter: none;
    box-shadow: none;
    overflow: hidden;
}

.rd-label-ribbon__text {
    position: relative;
    z-index: 3;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    max-height: calc(100% - 0.35rem);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Legacy fold markup (if any) — fully suppressed; no triangular tip. */
.rd-label-ribbon__fold {
    display: none !important;
}

.rd-panel,
.rd-accessible-morph,
.rd-workspace-morph,
.rd-drop-root,
.rd-drop-folder,
.rd-tree-folder {
    overflow: visible !important;
}

.rd-drop-root,
.rd-drop-folder {
    /* Ribbon is inside the card — only modest grid breathing room */
    padding-inline: 12px;
    padding-block-start: 8px;
}

.rd-label-ribbon__color {
    position: relative;
    z-index: 3;
    pointer-events: auto;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.rd-label-ribbon__color .mud-icon-button {
    padding: 0 !important;
    width: 14px !important;
    height: 14px !important;
    color: rgba(255, 255, 255, 0.94) !important;
}

.rd-label-ribbon__color .mud-icon-root,
.rd-label-ribbon__color svg {
    font-size: 11px !important;
    width: 11px !important;
    height: 11px !important;
}

.rd-label-ribbon-picker {
    padding: 10px 12px;
    min-width: 200px;
    max-width: 240px;
}

.rd-label-ribbon-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.rd-label-ribbon-swatch {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    padding: 0;
}

.rd-label-ribbon-swatch--on {
    box-shadow: 0 0 0 2px var(--mud-palette-primary);
}

/* Per-type subtle defaults (overridden by --rd-ribbon* when user picks a color) */
.rd-label-ribbon--query {
    --rd-ribbon: #6FA8B4;
    --rd-ribbon-deep: #4E7A84;
}

.rd-label-ribbon--composite {
    --rd-ribbon: #D4A06A;
    --rd-ribbon-deep: #A87840;
}

.rd-label-ribbon--form {
    --rd-ribbon: #A78BB8;
    --rd-ribbon-deep: #7A6288;
}

/* Content clears the in-card side ribbon strip. */
.rd-item-card:has(> .rd-label-ribbon) > .rd-card-main {
    padding-inline-start: calc(var(--rd-ribbon-w, 1.35rem) + 0.45rem);
}

.rd-item-card > .rd-card-main {
    padding-top: 0.4rem;
    margin-bottom: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .rd-item-card.rd-smoove {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
        transition: none !important;
    }
}
