/* image-viewer.css — the full-screen single-image viewer
 * (js/controls/image-viewer/image-viewer.js).
 *
 * Layout: a top bar (file name + size on the left, actions on the right), the
 * stage that holds the fitted image, and a zoom bar floating over the bottom of
 * the stage. Colours come from the --image-viewer-* tokens in shell.css,
 * which stay dark in every theme on purpose.
 *
 * z-index 10100 is the leaf-modal layer (dialog.css: --confirm / --nested): the
 * viewer opens nothing on top of itself, and stays under toasts (99999) so the
 * "Image copied" confirmation is visible over it. */

.lp-image-viewer {
    position: fixed;
    inset: 0;
    z-index: 10100;
    display: flex;
    flex-direction: column;
    background: var(--image-viewer-backdrop);
    color: var(--image-viewer-fg);
    font-family: var(--font-sans);
    outline: none;
    animation: lp-image-viewer-in 160ms ease-out;
}

/* The page behind must not scroll while the viewer is up. */
html.lp-image-viewer-open,
html.lp-image-viewer-open body {
    overflow: hidden;
}

/* ── Top bar ─────────────────────────────────────── */

.lp-image-viewer__bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 64px;
    padding: 8px 12px 8px 24px;
    box-sizing: border-box;
}

.lp-image-viewer__info {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.lp-image-viewer__name {
    font-size: var(--fs-body);
    font-weight: 600;
    line-height: var(--lh-snug);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lp-image-viewer__meta {
    font-size: var(--fs-meta);
    line-height: var(--lh-snug);
    color: var(--image-viewer-fg-muted);
}

.lp-image-viewer__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
}

.lp-image-viewer__btn,
.lp-image-viewer__level {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--image-viewer-fg);
    cursor: pointer;
    transition: background 0.15s;
}

.lp-image-viewer__btn {
    width: 36px;
    padding: 0;
}

.lp-image-viewer__level {
    min-width: 64px;
    padding: 0 10px;
    font-family: inherit;
    font-size: var(--fs-ui);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.lp-image-viewer__btn:hover:not(:disabled),
.lp-image-viewer__level:hover:not(:disabled) {
    background: var(--image-viewer-control-hover);
}

.lp-image-viewer__btn:disabled,
.lp-image-viewer__level:disabled {
    opacity: 0.4;
    cursor: default;
}

.lp-image-viewer__btn:focus-visible,
.lp-image-viewer__level:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.lp-image-viewer__sep {
    width: 1px;
    height: 20px;
    margin: 0 6px;
    background: var(--image-viewer-rule);
}

/* ── Stage ───────────────────────────────────────── */

.lp-image-viewer__stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 16px 24px 72px;   /* the bottom keeps a fitted image clear of the zoom bar */
    box-sizing: border-box;
    touch-action: none;   /* pinch and pan are handled by the viewer, not the page */
}

.lp-image-viewer__stage.is-zoomed { cursor: grab; }
.lp-image-viewer__stage.is-panning { cursor: grabbing; }

.lp-image-viewer__img {
    display: block;
    flex-shrink: 0;
    max-width: none;
    border-radius: 4px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    user-select: none;
    opacity: 0;
    transition: opacity 160ms ease-out;
}

.lp-image-viewer__img.is-loaded { opacity: 1; }

.lp-image-viewer__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--image-viewer-rule);
    border-top-color: var(--image-viewer-fg);
    border-radius: 50%;
    animation: lp-image-viewer-spin 800ms linear infinite;
}

.lp-image-viewer__msg {
    max-width: 480px;
    padding: 16px 20px;
    border-radius: var(--radius);
    background: var(--image-viewer-control-bg);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    text-align: center;
}

/* ── Zoom bar ──────────────────────────────────── */

.lp-image-viewer__zoombar {
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-radius: var(--radius);
    background: var(--image-viewer-control-bg);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* ── Phone width ─────────────────────────────────── */

@media (max-width: 600px) {
    .lp-image-viewer__bar { padding: 4px 4px 4px 16px; gap: 8px; }
    .lp-image-viewer__btn,
    .lp-image-viewer__level { height: 44px; }
    .lp-image-viewer__btn { width: 44px; }
    .lp-image-viewer__stage { padding: 8px 0 72px; }
}

/* ── Motion ──────────────────────────────────────── */

@keyframes lp-image-viewer-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes lp-image-viewer-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .lp-image-viewer,
    .lp-image-viewer__img { animation: none; transition: none; }
    .lp-image-viewer__spinner { animation-duration: 2400ms; }
}
