/* ==========================================================================
   Quick Look — Spacebar Peek Preview (macOS Style)
   ========================================================================== */

/* ── Backdrop ────────────────────────────────────────────────────────────
   Real macOS Quick Look does NOT blur or frost the desktop behind it — the
   Finder window and wallpaper stay perfectly sharp, with only the panel
   floating above. The previous 40px backdrop-filter turned the whole screen
   into a frosted sheet, which read as "a new viewing tab" rather than a
   peek at the file. */
.quicklook-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 90000;
    background: rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.quicklook-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* ── Preview Panel ── */
.quicklook-window {
    background: rgba(58, 58, 60, 0.86);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 0.5px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    overflow: hidden;
    max-width: min(84vw, 900px);
    max-height: 86vh;
    min-width: 380px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 32px 90px rgba(0, 0, 0, 0.55), 0 0 0 0.5px rgba(0, 0, 0, 0.3);
    transform: scale(0.96);
    transition: transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.quicklook-overlay.active .quicklook-window {
    transform: scale(1);
}

/* ── Header Bar — close on the left, title centred, action on the right,
   matching the real Quick Look chrome. ── */
.quicklook-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    background: rgba(48, 48, 50, 0.7);
    border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.ql-close {
    justify-self: start;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s ease;
}

.ql-close:hover { background: rgba(255, 255, 255, 0.28); }

.quicklook-title {
    justify-self: center;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 46vw;
}

.quicklook-title i { font-size: 12px; opacity: 0.8; }

.quicklook-actions {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 10px;
}

.quicklook-meta {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
}

.ql-open-btn {
    padding: 4px 12px;
    border-radius: 7px;
    border: 0.5px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s ease;
}

.ql-open-btn:hover { background: rgba(255, 255, 255, 0.24); }

/* ── Content ─────────────────────────────────────────────────────────────
   The scroll container is fixed-size; ONLY .ql-stage inside it scales when
   zooming. Scaling the panel instead (which is what used to happen) made
   the whole window grow rather than magnifying the document. */
.quicklook-content {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 200px;
    background: rgba(0, 0, 0, 0.18);
}

/* Zoomed past fit, the document behaves like a scrollable canvas and must
   stop being centre-justified or it clips symmetrically on both edges. */
.quicklook-content.is-zoomed {
    justify-content: flex-start;
    cursor: grab;
}

.ql-stage {
    width: 100%;
    flex-shrink: 0;
    transition: width 0.16s ease;
    transform-origin: top left;
}

/* A document stage is opaque paper. The preview PNG is exported from a PDF
   and carries an alpha channel, so without this the translucent panel
   chrome (and whatever window happens to be behind it) shows straight
   through the page. */
.ql-stage:has(img) {
    background: #fff;
}

.ql-stage img {
    width: 100%;
    height: auto;
    display: block;
    background: #fff;
}

.ql-stage-text { transition: none; }

/* ── Zoom controls ── */
.ql-zoom-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.10);
}

.ql-zoom-btn {
    width: 22px;
    height: 20px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    font-size: 9px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.ql-zoom-btn:hover { background: rgba(255, 255, 255, 0.18); }

.ql-zoom-level {
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.7);
    min-width: 34px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Text/Document preview */
.quicklook-content .ql-text-preview {
    padding: 24px 30px;
    color: #e0e0e0;
    font-size: 13.5px;
    line-height: 1.7;
    max-height: 65vh;
    overflow-y: auto;
    width: 100%;
}

.quicklook-content .ql-text-preview h1,
.quicklook-content .ql-text-preview h2,
.quicklook-content .ql-text-preview h3 {
    color: #fff;
    margin-bottom: 10px;
}

.quicklook-content .ql-text-preview ul {
    padding-left: 18px;
}

.quicklook-content .ql-text-preview li {
    margin-bottom: 6px;
}

/* Video preview */
.quicklook-content video {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 0;
}

/* ── Selected Item State ── */
.desktop-icon.selected {
    background: rgba(0, 122, 255, 0.25);
    border-radius: 8px;
    outline: 2px solid rgba(0, 122, 255, 0.5);
}

.desktop-icon.selected span {
    background: #007aff;
    color: #fff;
    border-radius: 4px;
    padding: 1px 6px;
}

/* ── Keyboard Hint ── */
.quicklook-hint {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #aaa;
    font-size: 11px;
    padding: 5px 14px;
    border-radius: 8px;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.quicklook-hint.visible {
    opacity: 1;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .quicklook-window {
        max-width: 95vw;
        min-width: 0;
        min-height: 200px;
    }
}
