﻿/* WizReal Phase 2 - loading & feedback states (P9-a, 2026-11-05).
   Production version of the prototype's wizreal-loading.js states: shimmer skeletons, button
   spinners, image fade-in, upload progress, chat status line, top navigation bar, plus the
   skip-to-content link. Loaded by every layout after wz-components.css; behaviour lives in
   wwwroot/js/wz-loading.js (window.wzLoading). Every class is prefixed wz- so nothing collides
   with Bootstrap or site.css; colours fall back to literals because _ClientLayout (legacy) loads
   this file without wz-tokens.css. */

/* ---- Accessibility helpers -------------------------------------------------- */

.wz-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Skip link: first focusable element of every layout; visible only when focused. */
.wz-skip {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 2000;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--wz-ink, #111418);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-160%);
    transition: transform .15s ease;
}

    .wz-skip:focus,
    .wz-skip:focus-visible {
        color: #fff;
        transform: translateY(0);
        outline: 3px solid var(--wz-p, #3E7B27);
        outline-offset: 2px;
    }

/* The skip target is focused programmatically; no ring on the whole main region. */
#wz-main:focus {
    outline: none;
}

/* ---- Skeleton blocks ---------------------------------------------------------- */

.wz-sk {
    display: inline-block;
    max-width: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, #EEEEEB 0%, #F6F6F4 40%, #EEEEEB 80%);
    background-size: 220% 100%;
    animation: wz-sk-shimmer 1.3s ease-in-out infinite;
    vertical-align: middle;
}

.wz-sk-line {
    display: block;
    height: 12px;
    margin-top: 10px;
}

    .wz-sk-line.lg { height: 18px; }
    .wz-sk-line.xl { height: 24px; }
    .wz-sk-line.num { height: 28px; }
    .wz-sk-line.sm { height: 10px; }

.wz-sk-circle {
    flex: 0 0 auto;
    border-radius: 50%;
}

.wz-sk-media {
    display: block;
    width: 100%;
    height: 180px;
    border-radius: 14px;
}

.wz-sk-pill {
    height: 36px;
    border-radius: 18px;
}

.wz-sk-btn {
    flex: 0 0 auto;
    width: 72px;
    height: 32px;
    border-radius: 8px;
}

@keyframes wz-sk-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -120% 0; }
}

/* ---- Skeleton templates (dash | table | cards | listings | detail | chat) ---- */

.wz-sk-wrap {
    width: 100%;
}

.wz-sk-card {
    min-width: 0;
    padding: 4px;
    background: var(--wz-bg, #fff);
    border: 1px solid var(--wz-line, #E8E8E5);
    border-radius: var(--wz-r-lg, 18px);
}

    .wz-sk-card.pad {
        padding: 18px 20px;
    }

.wz-sk-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

    .wz-sk-row > .grow {
        flex: 1 1 auto;
        min-width: 0;
    }

.wz-sk-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 4px 0 18px;
}

.wz-sk-li {
    padding: 12px 0;
    border-bottom: 1px solid var(--wz-line, #E8E8E5);
}

    .wz-sk-li:last-child {
        border-bottom: 0;
    }

.wz-sk-tr {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--wz-line, #E8E8E5);
}

    .wz-sk-tr:last-child {
        border-bottom: 0;
    }

    .wz-sk-tr > .c2 { flex: 2 1 0; min-width: 0; }
    .wz-sk-tr > .c1 { flex: 1 1 0; min-width: 0; }

.wz-sk-grid3,
.wz-sk-grid4 {
    display: grid;
    gap: var(--wz-grid-gap, 20px);
}

/* Auto-fill so the same template works in a full page and in the narrow map results column. */
.wz-sk-grid4 {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.wz-sk-grid3 {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.wz-sk-2col {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: var(--wz-grid-gap, 20px);
    margin-top: var(--wz-grid-gap, 20px);
}

.wz-sk-chat {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: var(--wz-grid-gap, 20px);
}

.wz-sk-bub {
    display: flex;
    margin: 14px 0;
}

    .wz-sk-bub.me {
        justify-content: flex-end;
    }

    .wz-sk-bub .wz-sk {
        height: 44px;
        border-radius: 14px;
    }

@media (max-width: 991.98px) {
    .wz-sk-2col,
    .wz-sk-chat {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---- Fetch regions (wzLoading.start / .end) ---------------------------------- */

/* While a region loads, its real children are hidden (not removed) and the skeleton shows. */
[data-wz-ld-on] > :not(.wz-ld-sk) {
    display: none;
}

.wz-ld-sk {
    width: 100%;
}

/* ---- Button busy state + spinners ------------------------------------------- */

.wz-spin {
    display: inline-block;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -0.2em;
    animation: wz-spin .7s linear infinite;
}

    .wz-spin.xs { width: 12px; height: 12px; border-width: 2px; }
    .wz-spin.sm { width: 14px; height: 14px; }
    .wz-spin.lg { width: 32px; height: 32px; border-width: 3px; }

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

.is-busy {
    cursor: progress;
    pointer-events: none;
}

    .is-busy > .wz-spin {
        margin-right: 6px;
    }

/* Design-system buttons already lay their content out with a gap. */
.wz-btn.is-busy > .wz-spin {
    margin-right: 0;
}

/* Disabled design buttons fade to .5; a busy one stays readable. */
body.wz2 .wz-btn.is-busy:disabled {
    opacity: .75;
}

/* ---- Images: reserve space, fade in ---------------------------------------- */

.wz-lz {
    transition: opacity .3s ease;
}

.wz-lz-wait {
    opacity: 0;
}

/* Listing cards already reserve the photo box (aspect-ratio) and animate the hover zoom. */
body.wz2 .wz-lc-img > img.wz-lz {
    transition: transform .5s ease, opacity .3s ease;
}

/* ---- Upload progress --------------------------------------------------------- */

.wz-up {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

.wz-up-bar {
    position: relative;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--wz-soft, #F2F2EF);
}

    .wz-up-bar > i {
        position: absolute;
        inset: 0 auto 0 0;
        width: 0;
        border-radius: inherit;
        background: var(--wz-p, #3E7B27);
        transition: width .2s ease;
    }

    /* fetch() and native posts report no progress: an indeterminate sweep instead. */
    .wz-up-bar.ind > i {
        width: 35%;
        animation: wz-up-ind 1.1s ease-in-out infinite;
    }

.wz-up-pct {
    color: var(--wz-muted, #6B7176);
    font-size: 12px;
}

@keyframes wz-up-ind {
    0% { left: -35%; }
    100% { left: 100%; }
}

/* ---- Chat status line + typing dots ---------------------------------------- */

.wz-chat-st {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin: -8px 0 12px;
    color: var(--wz-muted, #6B7176);
    font-size: 12px;
}

    .wz-chat-st.failed {
        color: var(--wz-err, #A3312A);
    }

    .wz-chat-st .wz-spin {
        color: var(--wz-faint, #9A9EA3);
    }

.wz-chat-typing {
    display: inline-flex;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--wz-soft, #F2F2EF);
}

    .wz-chat-typing > i {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--wz-faint, #9A9EA3);
        animation: wz-typing 1.2s ease-in-out infinite;
    }

        .wz-chat-typing > i:nth-child(2) { animation-delay: .15s; }
        .wz-chat-typing > i:nth-child(3) { animation-delay: .3s; }

@keyframes wz-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ---- Full-page navigation bar ------------------------------------------------ */

.wz-navbar-progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2100;
    width: 0;
    height: 3px;
    background: var(--wz-p, #3E7B27);
    opacity: 0;
    pointer-events: none;
    transition: width 8s cubic-bezier(.1, .7, .2, 1), opacity .2s ease;
}

    .wz-navbar-progress.on {
        width: 85%;
        opacity: 1;
    }

/* ---- Reduced motion ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .wz-sk,
    .wz-chat-typing > i {
        animation: none;
    }

    .wz-spin {
        animation-duration: 1.6s;
    }

    .wz-up-bar.ind > i {
        left: 0;
        width: 100%;
        opacity: .45;
        animation: none;
    }

    .wz-lz,
    .wz-skip,
    .wz-up-bar > i {
        transition: none;
    }

    .wz-navbar-progress {
        transition: opacity .2s ease;
    }

        .wz-navbar-progress.on {
            width: 100%;
            opacity: .6;
        }
}

/* ---- PM 2026-11-06: shimmer in every listing photo box while the picture loads ----
   The card reserves the box (aspect-ratio) and wz-loading.js keeps the <img> at opacity 0
   (.wz-lz-wait) until it has loaded, so the animated gradient underneath shows through.
   Browsers without :has() keep the static gradient. */
body.wz2 .wz-lc-img {
    background: #EEEFEC linear-gradient(90deg, #EAEBE8 0%, #F6F6F4 40%, #EAEBE8 80%);
    background-size: 220% 100%;
}

body.wz2 .wz-lc-img:has(> img.wz-lz-wait) {
    animation: wz-sk-shimmer 1.3s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    body.wz2 .wz-lc-img:has(> img.wz-lz-wait) { animation: none; }
}
