/* OS-2045 Image Viewer App
 * ========================
 * Windows-Photos-style layout: toolbar / stage / gallery-strip.
 * Honors os2045 theme tokens (--theme-bg, --theme-color, etc).
 */

.os2045-imgv-root {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: var(--theme-bg, #0d0f12);
    color: var(--theme-color, #d8dee9);
    font-family: var(--theme-font, Inter, sans-serif);
    overflow: hidden;
}

/* ── Toolbar ─────────────────────────────────────────────────────────── */
.imgv-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--theme-surface, #1a1d22);
    border-bottom: 1px solid var(--theme-border, #2a2f37);
    flex: 0 0 auto;
    user-select: none;
    flex-wrap: wrap;
}
.imgv-path {
    font-size: 0.85rem;
    font-weight: 500;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--theme-color, #d8dee9);
    margin-right: 6px;
}
.imgv-spacer { flex: 1 1 auto; }
.imgv-divider {
    display: inline-block;
    width: 1px;
    height: 18px;
    background: var(--theme-border, #2a2f37);
    margin: 0 4px;
}
.imgv-tb-btn {
    appearance: none;
    background: transparent;
    border: 1px solid transparent;
    color: var(--theme-color, #d8dee9);
    padding: 4px 9px;
    border-radius: 4px;
    font-size: 0.95rem;
    line-height: 1;
    min-width: 28px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.imgv-tb-btn:hover {
    background: var(--theme-hover, rgba(255,255,255,0.06));
    border-color: var(--theme-border, #2a2f37);
}
.imgv-tb-btn:active { transform: translateY(1px); }
.imgv-zoom-label {
    min-width: 56px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.imgv-res {
    font-size: 0.78rem;
    color: var(--theme-color-dim, #8a92a0);
    margin-left: 8px;
    font-variant-numeric: tabular-nums;
}
.imgv-res.original {
    color: var(--theme-accent, #4aa8ff);
    font-weight: 600;
}

/* ── Stage (main image canvas) ───────────────────────────────────────── */
.imgv-stage {
    flex: 1 1 auto;
    position: relative;
    overflow: hidden;
    background:
        repeating-conic-gradient(#1c2026 0% 25%, #14171c 0% 50%) 50% / 24px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    cursor: default;
    touch-action: none;
}
.imgv-stage.imgv-zoomed { cursor: grab; }
.imgv-stage.imgv-dragging { cursor: grabbing; }
.imgv-image {
    max-width: none;
    max-height: none;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
    will-change: transform;
    transition: transform 0.06s linear;
    image-rendering: auto;
    visibility: hidden;
}
.imgv-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--theme-color-dim, #8a92a0);
    font-size: 0.95rem;
    pointer-events: none;
    background: rgba(0,0,0,0.25);
}
/* The HTML `hidden` attribute defaults to `display: none`, but `display:
   flex` above overrides it via specificity. Re-assert hidden explicitly. */
.imgv-loading[hidden] {
    display: none !important;
}
.imgv-error {
    position: absolute;
    inset: auto 0 50% 0;
    margin: 0 auto;
    width: max-content;
    max-width: 80%;
    padding: 10px 16px;
    background: var(--theme-surface, #1a1d22);
    border: 1px solid var(--theme-error, #c44);
    border-radius: 6px;
    color: var(--theme-error, #f88);
    font-size: 0.9rem;
    text-align: center;
}

/* ── Gallery strip ───────────────────────────────────────────────────── */
.imgv-strip {
    flex: 0 0 auto;
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    background: var(--theme-surface, #1a1d22);
    border-top: 1px solid var(--theme-border, #2a2f37);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    height: 84px;
}
.imgv-strip-hidden { display: none; }
.imgv-thumb {
    appearance: none;
    background: var(--theme-bg, #0d0f12);
    border: 2px solid transparent;
    border-radius: 4px;
    color: var(--theme-color-dim, #8a92a0);
    padding: 0;
    width: 84px;
    height: 70px;
    flex: 0 0 auto;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    transition: border-color 0.12s, transform 0.12s;
}
.imgv-thumb:hover { border-color: var(--theme-border, #2a2f37); }
.imgv-thumb.active {
    border-color: var(--theme-accent, #4aa8ff);
    transform: translateY(-1px);
}
.imgv-thumb img {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #000;
}
.imgv-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2px 4px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 0.65rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.imgv-thumb:not(.has-preview) .imgv-thumb-label {
    position: static;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--theme-bg, #0d0f12);
    color: var(--theme-color-dim, #8a92a0);
    font-size: 0.7rem;
    padding: 4px;
}

/* Reduced motion: drop transition on image transform */
@media (prefers-reduced-motion: reduce) {
    .imgv-image { transition: none; }
    .imgv-thumb { transition: none; }
}
