/*
 * CMS pages (footer content): pixel reveal for editor images.
 * "Soft meets hard": the clean store type mixed with bitmap blocks, 8-bit glyphs
 * and mono annotations. Markup is built by cms-pixel.js around each <img>.
 */

.cms-content .px-fig {
    position: relative;
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: 1.6em 0 2.2em;
}

.cms-content .px-fig__frame {
    position: relative;
    display: block;
    line-height: 0;
    background: var(--ux-ink, #26251E);
}

.cms-content .px-fig__frame img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Overlay canvas: ink blocks → stepped mosaic → gone */
.cms-content .px-fig__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    pointer-events: none;
}

.cms-content .px-fig.is-done .px-fig__canvas { visibility: hidden; }
.cms-content .px-fig.is-glitch .px-fig__canvas { visibility: visible; }

/* Corner ticks, like registration marks */
.cms-content .px-fig__frame::before,
.cms-content .px-fig__frame::after {
    content: "";
    position: absolute;
    z-index: 2;
    width: 14px;
    height: 14px;
    border: 2px solid var(--ux-accent, #F54E00);
    pointer-events: none;
}

.cms-content .px-fig__frame::before { top: -7px; left: -7px; border-right: 0; border-bottom: 0; }
.cms-content .px-fig__frame::after { right: -7px; bottom: -7px; border-left: 0; border-top: 0; }

/* 8-bit glyph sticker (top-right corner) */
.cms-content .px-fig__glyph {
    position: absolute;
    z-index: 3;
    top: -14px;
    right: -14px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    background: var(--ux-ink, #26251E);
    color: var(--ux-canvas, #F7F7F4);
    transform: scale(0);
    transition: transform .35s steps(4, end);
}

.cms-content .px-fig.px-in .px-fig__glyph { transform: none; transition-delay: .9s; }
.cms-content .px-fig__glyph svg { width: 24px; height: 24px; shape-rendering: crispEdges; }
.cms-content .px-fig:hover .px-fig__glyph { background: var(--ux-accent, #F54E00); }
.cms-content .px-fig:hover .px-fig__glyph svg { animation: px-beat 1.15s steps(1, end) infinite; }

/* "lub-dub": two hard pixel jumps, no easing */
@keyframes px-beat {
    0%   { transform: scale(1); }
    8%   { transform: scale(1.25); }
    16%  { transform: scale(1); }
    24%  { transform: scale(1.15); }
    32%  { transform: scale(1); }
}

/* Mono annotation under the image */
.cms-content .px-fig__cap {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--ux-line-strong, #CFCDC4);
    font-family: var(--ux-mono, ui-monospace, monospace);
    font-size: 11.5px;
    line-height: 1.4;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ux-muted, #807D72);
}

.cms-content .px-fig__num {
    flex: none;
    padding: 1px 6px;
    color: var(--ux-canvas, #F7F7F4);
    background: var(--ux-ink, #26251E);
}

.cms-content .px-fig__title {
    min-width: 0;
    overflow: hidden;
    color: var(--ux-ink, #26251E);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cms-content .px-fig__meta { flex: none; margin-left: auto; }

/* Blinking block cursor after the title while it decodes */
.cms-content .px-fig__cap.is-typing .px-fig__title::after {
    content: "";
    display: inline-block;
    width: .6em;
    height: 1em;
    margin-left: 3px;
    vertical-align: -2px;
    background: var(--ux-accent, #F54E00);
    animation: px-blink .5s steps(1, end) infinite;
}

@keyframes px-blink { 50% { opacity: 0; } }

/* Until the script wraps them, images stay hidden so they don't flash before the
   ink cover. Failsafe: they show up on their own after 3 s if the script never runs. */
.cms-content:not([data-px-ready]) img {
    visibility: hidden;
    animation: px-failsafe 0s linear 3s forwards;
}

@keyframes px-failsafe { to { visibility: visible; } }

@media (max-width: 640px) {
    .cms-content .px-fig__glyph { top: -10px; right: -6px; width: 36px; height: 36px; }
    .cms-content .px-fig__meta { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .cms-content:not([data-px-ready]) img { visibility: visible; animation: none; }
    .cms-content .px-fig__canvas { display: none; }
    .cms-content .px-fig__glyph { transform: none; transition: none; }
    .cms-content .px-fig:hover .px-fig__glyph svg { animation: none; }
    .cms-content .px-fig__cap.is-typing .px-fig__title::after { animation: none; }
}
