/* Redesign 2026-10-15, second handover: states. Built from tokens.css; shared components live in ui.css. */

/* ==========================================================================
   Loading and error states (README "Učitavanje i greške", StanjaGreske)
   ========================================================================== */

/* ── Skeleton: a pale grey from the tokens with a soft passing light ──── */
:root {
    --skeleton: color-mix(in srgb, var(--border) 60%, var(--ground));    /* the design's #E9EDF2 */
    --skeleton-light: color-mix(in srgb, var(--surface) 55%, transparent);
}
.skel {
    display: block;
    background-color: var(--skeleton);
    background-image: linear-gradient(90deg, transparent 0%, var(--skeleton-light) 50%, transparent 100%);
    background-size: 200% 100%;
    background-repeat: no-repeat;
    background-position: 150% 0;
    border-radius: var(--radius-sm);
    animation: skel-shimmer 1.4s ease-in-out infinite;
}
@keyframes skel-shimmer {
    from { background-position: 150% 0; }
    to   { background-position: -50% 0; }
}
.skel--line  { height: 12px; border-radius: var(--radius-pill); }
.skel--title { height: 22px; border-radius: var(--radius-sm); }
.skel--price { width: 45%; height: 22px; }
.skel--w25 { width: 25%; }
.skel--w35 { width: 35%; }
.skel--w50 { width: 55%; }
.skel--w60 { width: 60%; }
.skel--w80 { width: 90%; }

/* The lot card's frame and its body's boxes at their real heights (ui.css
   .lotcard): title and meta 63px, price row 43px, the seller line 32px
   under a hairline. Nothing clickable. */
.skelcard {
    display: flex; flex-direction: column;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.skelcard__media { aspect-ratio: 1 / 1; border-radius: 0; }
.skelcard__body { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 12px; }
.skelcard__head { min-height: 63px; display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.skelcard__meta { margin-top: 5px; }
.skelcard__pricerow { min-height: 43px; display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-2); }
.skelcard__pricerow > .skel { margin-bottom: 5px; }
.skelcard__price { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.skelcard__price .skel--price { width: 60%; height: 24px; }
.skelcard__seller {
    margin-top: auto;
    min-height: 32px; padding-top: 10px;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: var(--space-2);
}
.skelcard__avatar { flex: none; width: 22px; height: 22px; border-radius: var(--radius-pill); }
@media (max-width: 600px) {
    /* the compact card: no meta, no seller line, the price stacked */
    .cardgrid .skelcard__body { padding: 10px 10px 12px; gap: 6px; }
    .cardgrid .skelcard__head { min-height: 34px; gap: 6px; padding-top: 2px; }
    .cardgrid .skelcard__head > .skel--line { height: 11px; }
    .cardgrid .skelcard__meta,
    .cardgrid .skelcard__seller { display: none; }
    .cardgrid .skelcard__pricerow { min-height: 36px; flex-direction: column; align-items: flex-start; gap: 4px; }
    .cardgrid .skelcard__price { width: 100%; gap: 4px; }
    .cardgrid .skelcard__price .skel--price { height: 20px; }
    .cardgrid .skelcard__pricerow > .skel { margin-bottom: 2px; }
}

/*
   The bid panel while it resyncs after a stale spell (live_listing_controller.js
   sets aria-busy). `bidpanel_skeleton()` sits in the panel and shows only then.
   The panel keeps its size and its content stays in the DOM (a typed amount
   survives), hidden under the skeleton. `body .listing` matches ui.css's own
   weight, which makes the panel `position: static`.
*/
.bidpanel__skel { display: none; }
body .listing .bidpanel[aria-busy="true"] { position: relative; }
body .listing .bidpanel[aria-busy="true"] > .bidpanel__skel {
    position: absolute; inset: var(--space-5);
    z-index: 2;
    display: flex; flex-direction: column; gap: var(--space-4);
    overflow: hidden;
    background: var(--surface);
}
.bidpanel[aria-busy="true"] > :not(.bidpanel__skel) { visibility: hidden; }
/* Each block at the height of the real one it stands for (head 109px,
   Prati and Podijeli 40px, clock 124px, price 89px, the form), so the
   panel's own foot lines up with the skeleton's. */
.bidpanel__skel > span { flex: none; }
.bidpanel__skelhead { min-height: 109px; display: flex; flex-direction: column; gap: var(--space-2); }
.bidpanel__skelhead .skel--title { height: 26px; }
.bidpanel__skelhead .skel--line { margin-top: var(--space-2); }
.bidpanel__skelactions { display: flex; gap: var(--space-2); }
.bidpanel__skelactions .skel { width: 30%; height: 40px; border-radius: var(--radius-md); }
.bidpanel__skelclock { height: 124px; border-radius: var(--radius-md); }
.bidpanel__skelprice { min-height: 89px; display: flex; flex-direction: column; justify-content: center; gap: var(--space-3); }
.bidpanel__skelamount { width: 60%; height: 36px; }
.bidpanel__skelform { display: flex; flex-direction: column; gap: var(--space-3); }
.bidpanel__skelfield { height: var(--input-height); border-radius: var(--radius-md); }
.bidpanel__skelquick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.bidpanel__skelquick .skel { height: var(--touch-target); border-radius: var(--radius-md); }
.bidpanel__skelbutton { height: var(--input-height); border-radius: var(--radius-md); }
/* The foot fills down to the panel's bottom, where its own foot (help, delivery) sits. */
.bidpanel__skel > .bidpanel__skelfoot {
    flex: 1 0 auto;
    display: flex; flex-direction: column; justify-content: flex-end; gap: var(--space-3);
    padding-top: var(--space-4);
}

/* Phone: the panel is a grid of in-flow boxes (heading, then the price and
   clock box in row 2) with the form in a bottom sheet behind a sticky bar.
   Only the price and clock box turns grey; the heading, the foot, the bar
   (Licitiraj) and the sheet stay usable. The skeleton takes row 2's own
   area, so it is exactly as tall as the box it covers. */
@media (max-width: 700px) {
    body .listing .bidpanel[aria-busy="true"] > .bidpanel__skel {
        inset: 0;
        grid-row: 2 / 3; grid-column: 1 / -1;
        flex-direction: row; align-items: center; gap: var(--space-4);
        padding: var(--space-4);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
    }
    .bidpanel[aria-busy="true"] > :not(.bidpanel__skel) { visibility: visible; }
    .bidpanel[aria-busy="true"] > :is(.bidbox__price, .bidbox__clock) { visibility: hidden; }
    .bidpanel__skelhead, .bidpanel__skelactions, .bidpanel__skelform,
    .bidpanel__skel > .bidpanel__skelfoot { display: none; }
    .bidpanel__skel > .bidpanel__skelprice { flex: 1; min-height: 0; gap: var(--space-2); }
    .bidpanel__skelamount { width: 70%; height: 28px; }
    .bidpanel__skel > .bidpanel__skelclock { order: 2; flex: 0 0 30%; height: 40px; border-radius: var(--radius-sm); }
}

@media (prefers-reduced-motion: reduce) {
    .skel { animation: none; background-image: none; }
}

/* ── The state card: 404, error pages, "nije dostupan", "uklonjen", list error ── */
.statepage {
    display: flex; justify-content: center;
    padding: var(--space-12) 0;
}
.statecard {
    width: 100%; max-width: 560px;
    display: flex; flex-direction: column; align-items: center;
    padding: var(--space-8) var(--space-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-align: center;
}
.statecard--inline { max-width: none; margin: var(--space-6) 0; }
.statecard__code {
    margin: 0 0 var(--space-3);
    font: 800 44px/1 var(--font-sans);
    letter-spacing: -0.01em;
    color: var(--muted);   /* the design draws it paler; the owner rule keeps text at --muted or darker */
}
.stateicon { display: block; margin: 0 0 var(--space-4); color: var(--muted); flex: none; }
.stateicon--danger { color: var(--red-700); }
.statecard__title {
    margin: 0;
    font: 800 22px/1.25 var(--font-sans);
    color: var(--ink);
    text-wrap: balance;
}
.statecard__lede {
    margin: var(--space-2) 0 0;
    max-width: 46ch;
    font: 500 15px/1.55 var(--font-sans);
    color: var(--muted);
    text-wrap: pretty;
}
.statecard__actions {
    margin: var(--space-5) 0 0;
    display: flex; flex-direction: column; align-items: center; gap: var(--space-1);
}
.statecard__actions form { margin: 0; }
.statecard__minor { font-size: 14px; }

.statecard__search {
    position: relative;
    width: 100%; max-width: 360px;
    margin: var(--space-5) 0 0;
}
.statecard__search svg {
    position: absolute; left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.statecard__input {
    width: 100%;
    height: var(--input-height);
    padding: 0 var(--space-4) 0 40px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    font: 500 15px/1.2 var(--font-sans);
    color: var(--ink);
}
.statecard__input::placeholder { color: var(--muted); }
.statecard__input:focus-visible { outline: 2px solid var(--blue-700); outline-offset: 2px; }
.statecard__search + .statecard__actions { margin-top: var(--space-3); }

@media (max-width: 600px) {
    .statepage { padding: var(--space-6) 0; }
    .statecard { padding: var(--space-6) var(--space-4); }
    .statecard__title { font-size: 20px; }
    .statecard__code { font-size: 38px; }
}

/* ── "Nema veze": the dark bar at the top while offline ───────────────── */
.offlinebar {
    position: sticky; top: 0;   /* in flow, so it pushes the masthead down instead of covering it */
    z-index: 1000;
    padding: var(--space-2) var(--space-4);
    background: var(--navy-900);
    color: var(--surface);
    border-bottom: 1px solid color-mix(in srgb, var(--surface) 14%, transparent);   /* its own element, not the masthead's top */
    box-shadow: var(--shadow-float);
}
.offlinebar[hidden] { display: none; }
.offlinebar__inner {
    max-width: var(--content-max);
    margin: 0 auto;
    min-height: 44px;
    display: flex; align-items: center; gap: var(--space-3);
}
.offlinebar .stateicon { margin: 0; color: var(--peach-200); }
.offlinebar__text { margin: 0; flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.offlinebar__title { font: 700 15px/1.3 var(--font-sans); }
.offlinebar__body { font: 500 13px/1.4 var(--font-sans); color: color-mix(in srgb, var(--surface) 82%, transparent); }
.offlinebar__retry {
    margin: 0;
    display: inline-flex; align-items: center; gap: var(--space-2);
    font: 700 13px/1.3 var(--font-sans);
    white-space: nowrap;
}
.offlinebar__retry[hidden] { display: none; }
.offlinebar__spinner {
    width: 16px; height: 16px;
    border: 2px solid color-mix(in srgb, var(--surface) 30%, transparent);
    border-top-color: var(--surface);
    border-radius: 50%;
    animation: offline-spin 1s linear infinite;
}
@keyframes offline-spin { to { transform: rotate(360deg); } }
.offlinebar[data-back] { background: var(--green-700); }
.offlinebar[data-back] .stateicon { display: none; }
@media (prefers-reduced-motion: reduce) {
    .offlinebar__spinner { animation: none; border-top-color: color-mix(in srgb, var(--surface) 30%, transparent); }
}
@media (max-width: 600px) {
    .offlinebar__inner { flex-wrap: wrap; row-gap: var(--space-1); align-items: flex-start; }
    .offlinebar__text { flex-basis: calc(100% - 36px); }
    .offlinebar__retry { margin-left: 36px; min-height: 24px; }
}

/* The bar already says the connection is gone, so the lot page's own
   "reconnecting" line stays quiet meanwhile; "stale" (the price may be wrong)
   still shows, because that is about the number, not the network. */
html[data-offline] .connection-notice[data-state="reconnecting"] { display: none; }
