/* Full-screen viewer (design board: Viewer.dc.html), quick look, and the inspector parts of js/inspector.js
   (colour swatches, multi-selection). Owner: the viewer/inspector builder (peek). A folder's peek inside quick
   look: css/peek.css. */

.viewer, .ql {
  --v-bg: #0b0b0c;                        /* the board's viewer background */
  --v-btn: rgba(255, 255, 255, .07);
  --v-btn-hover: rgba(255, 255, 255, .14);
  --v-nav: rgba(255, 255, 255, .08);
  --v-chip: rgba(11, 11, 12, .72);
  --v-psd: #a78bfa;                       /* PSD in the board's file-type colours */
  --v-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}

/* ---------- viewer: top bar | picture between previous / next (+ details) | context, filmstrip, keys ---------- */
.viewer { position: fixed; inset: 0; z-index: 59; display: flex; flex-direction: column; background: var(--v-bg); color: var(--text);
  overscroll-behavior: contain; animation: v-in .16s ease; }
@keyframes v-in { from { opacity: 0; } }
.viewer:focus { outline: none; }
/* the page keeps its scrollbar gutter under the viewer (the grid must not reflow): paint it like the viewer */
html:has(> body > .viewer:not([hidden])) { background: #0b0b0c; }

.v-top { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 14px max(20px, env(safe-area-inset-left)); }
.v-title { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.v-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.v-btn { height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; flex: none;
  border: 0; border-radius: 10px; background: var(--v-btn); color: var(--text); font: inherit; text-decoration: none; white-space: nowrap;
  cursor: pointer; transition: background .12s; }
.v-btn:hover { background: var(--v-btn-hover); color: var(--text); }
.v-btn.primary { background: var(--accent-strong); color: #fff; font-weight: 600; }
.v-btn.primary:hover { background: #3474f0; }
.v-btn.sq { width: 38px; padding: 0; }
.v-btn.sq .ic { width: 16px; height: 16px; stroke-width: 1.8; }
.v-btn.info .ic { stroke-width: 2.4; }   /* a 24-grid icon drawn at 16 px: same weight as the 16-grid ones */
.v-btn[aria-pressed=true] { background: var(--accent-soft); color: var(--accent-text); }

.v-body { flex: 1; min-height: 0; display: flex; }
.v-main { position: relative; flex: 1; min-width: 0; }
.v-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.v-zoom { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
/* the picture's box: the stage less the previous / next buttons (board: 20 padding + 48 button + 24 gap) */
.v-frame, .v-media { position: absolute; inset: 8px 92px; }
.v-pic { position: absolute; border-radius: 6px; overflow: hidden; background: var(--panel-2); box-shadow: var(--v-shadow); }
.v-pic.unsized { background: none; box-shadow: none; border-radius: 0; }
.v-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.v-hi { opacity: 0; transition: opacity .18s; }
.v-hi.ld { opacity: 1; }
.viewer:not([data-type=image]) .v-zoom { visibility: hidden; }
.v-media { display: grid; place-items: center; pointer-events: none; }
.v-media:empty { display: none; }
.v-media > * { pointer-events: auto; }
/* absolute: in the centring grid a tall video would size its own row and overflow the stage */
.v-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: transparent; border-radius: 6px; }
.v-card, .v-fallback { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 32px 36px; text-align: center; max-width: min(440px, 90vw);
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; }
.v-card-name { font-weight: 600; overflow-wrap: anywhere; }
.v-card-sub { color: var(--muted); font-size: 12.5px; }
.v-badge { position: absolute; left: 14px; top: 14px; display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  background: var(--v-chip); color: var(--text); font-size: 11.5px; font-weight: 500; white-space: nowrap; pointer-events: none; transition: opacity .15s; }
.v-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--v-psd); flex: none; }
.viewer.zoomed .v-badge { opacity: 0; }

.v-nav { position: absolute; top: 50%; z-index: 1; width: 48px; height: 48px; margin-top: -24px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--v-nav); color: var(--text); cursor: pointer; transition: background .12s, opacity .2s; }
.v-nav:hover { background: var(--v-btn-hover); }
.v-nav .ic { width: 20px; height: 20px; stroke-width: 1.7; }
.v-nav.prev { left: max(20px, env(safe-area-inset-left)); }
.v-nav.next { right: max(20px, env(safe-area-inset-right)); }
.viewer.zoomed .v-nav { opacity: .35; }

.v-info { flex: none; width: 320px; margin: 8px max(20px, env(safe-area-inset-right)) 8px 0; display: flex; flex-direction: column; gap: 14px;
  padding: 18px 20px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  background: var(--pane); border: 1px solid var(--line); border-radius: 14px; }
.v-info-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--faint); }
.v-info-name { font-size: 15px; font-weight: 650; overflow-wrap: anywhere; word-break: break-word; }
.v-info-path { margin-top: -8px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; text-decoration: none; }
a.v-info-path:hover { color: var(--accent-text); }
.v-info-colors { display: flex; flex-direction: column; gap: 8px; }
.v-rows { display: flex; flex-direction: column; gap: 9px; font-size: 12.5px; }
.v-row { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.v-row .v { color: var(--text); font-variant-numeric: tabular-nums; text-align: right; min-width: 0; overflow-wrap: anywhere; }

.v-bottom { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px max(20px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
.v-context, .v-keys { flex: 1 1 0; min-width: 140px; color: var(--faint); font-size: 12px; }
.v-context { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.v-where { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-pos { color: var(--dim); font-variant-numeric: tabular-nums; }
.v-film { flex: 0 1 auto; min-width: 0; height: 90px; display: flex; align-items: center; justify-content: center; gap: 10px; overflow: hidden; padding: 0 6px; }
.v-fthumb { position: relative; flex: none; height: 66px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 7px; overflow: hidden;
  background: var(--panel); color: var(--faint); opacity: .55; cursor: pointer; transition: opacity .12s; }
.v-fthumb:hover, .v-fthumb:focus-visible { opacity: 1; }
.v-fthumb.cur { height: 78px; border-radius: 8px; opacity: 1; outline: 2px solid var(--accent); outline-offset: 3px; cursor: default; }
.v-fthumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.v-fplay { position: absolute; right: 5px; bottom: 5px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, .6); color: #fff; }
.v-keys { display: flex; align-items: center; justify-content: flex-end; gap: 8px; white-space: nowrap; }
.v-keys kbd, .ql-keys kbd { font: inherit; border: 1px solid var(--line-2); border-radius: 6px; padding: 3px 8px; }
.v-keys span + kbd, .ql-keys span + kbd { margin-left: 6px; }

/* no mouse: no previous / next buttons (swipe), no key hints; the picture uses the width */
@media (hover: none) {
  .v-nav, .v-keys { display: none; }
  .v-frame, .v-media { inset: 8px 20px; }
}
/* tablets: the details float over the picture */
@media (max-width: 899px) {
  .v-info { position: absolute; top: 0; right: max(20px, env(safe-area-inset-right)); bottom: 0; z-index: 2; margin: 0; box-shadow: -24px 0 60px rgba(0,0,0,.5); }
  .v-body { position: relative; }
}

/* phones: the picture fills the screen, the bars float over it (a tap hides them), actions at the bottom */
@media (max-width: 767px) {
  .viewer { display: block; }
  .v-top { position: absolute; top: 0; left: 0; right: 0; z-index: 2; flex-wrap: nowrap; gap: 10px;
    padding: calc(8px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 22px max(10px, env(safe-area-inset-left));
    background: linear-gradient(rgba(0,0,0,.72), transparent); transition: opacity .2s; }
  .v-title { flex: 1 1 auto; }
  .v-btn { height: 44px; border-radius: 12px; background: rgba(29, 30, 34, .82); }
  .v-btn.sq { width: 44px; }
  .v-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; flex-wrap: nowrap; justify-content: center; gap: 8px;
    padding: 24px max(10px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    background: linear-gradient(transparent, rgba(0,0,0,.72)); transition: opacity .2s; }
  .v-actions .v-btn:not(.primary) { width: 44px; padding: 0; }
  .v-actions .v-btn:not(.primary) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .v-actions .v-btn.primary { padding: 0 18px; }
  .v-body { position: absolute; inset: 0; display: block; }
  .v-main { position: absolute; inset: 0; }
  .v-frame, .v-media { inset: 0; }
  .viewer:not([data-type=image]) .v-media { inset: calc(66px + env(safe-area-inset-top)) 0 calc(80px + env(safe-area-inset-bottom)); }
  .v-pic { border-radius: 0; box-shadow: none; background: none; }
  .v-badge { top: max(12px, calc(72px + env(safe-area-inset-top) - var(--pic-top, 0px))); left: 12px; }
  .v-bottom { display: none; }
  .v-info { position: absolute; left: 0; right: 0; top: auto; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 3; width: auto; max-height: 50vh;
    margin: 0; border-radius: 18px 18px 0 0; border-bottom: 0; background: var(--sheet); box-shadow: 0 -18px 50px rgba(0,0,0,.55); }
  .viewer.bare .v-top, .viewer.bare .v-actions, .viewer.bare .v-info, .viewer.bare .v-badge { opacity: 0; pointer-events: none; }
}

/* ---------- quick look: a card over the grid, sized to the picture ---------- */
.ql { position: fixed; inset: 0; z-index: 52; display: grid; place-items: center; padding: 24px; background: rgba(8, 9, 11, .5);
  animation: v-in .12s ease; }
.ql-card { display: flex; flex-direction: column; max-width: calc(100vw - 32px); background: var(--pane); border: 1px solid var(--line-3);
  border-radius: 16px; box-shadow: 0 40px 120px rgba(0, 0, 0, .7); overflow: hidden; animation: ql-pop .16s cubic-bezier(.2, .8, .2, 1); }
@keyframes ql-pop { from { transform: scale(.96); opacity: 0; } }
/* the name and meta never widen the card: it is as wide as the picture's stage */
.ql-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 16px; min-width: 0; contain: inline-size; }
.ql-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ql-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ql-meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ql-path { color: var(--faint); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ql-btn { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.ql-btn:hover { background: var(--raised); color: var(--text); }
.ql-stage { position: relative; align-self: center; margin: 0 10px; border-radius: 10px; overflow: hidden; background: var(--v-bg);
  transition: width .14s ease, height .14s ease; }
.ql-pic { position: absolute; }
.ql-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.ql-hi { opacity: 0; transition: opacity .16s; }
.ql-hi.ld { opacity: 1; }
.ql-media { position: absolute; inset: 0; display: grid; place-items: center; }
.ql-media:empty { display: none; }
.ql-file { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--faint); font-size: 12px; font-weight: 600; letter-spacing: .06em; }
.ql-mosaic { position: absolute; inset: 0; display: grid; gap: 2px; background: var(--mosaic); }
.ql-mosaic.n0 { place-items: center; }
.ql-mosaic.n2 { grid-template-columns: 1fr 1fr; }
.ql-mosaic.n3, .ql-mosaic.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.ql-mosaic.n3 img:first-child { grid-row: span 2; }
.ql-mosaic img { width: 100%; height: 100%; min-height: 0; display: block; object-fit: cover; opacity: 0; transition: opacity .2s; }
.ql-mosaic img.ld { opacity: 1; }
.ql-mosaic .folder-ic { width: 72px; height: 72px; color: var(--dim); stroke-width: 1.1; }
.ql-keys { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px; padding: 12px 16px 14px; color: var(--faint);
  font-size: 12px; white-space: nowrap; contain: inline-size; }
@media (hover: none) { .ql-keys { display: none; } }
/* quick look's and the peek's Open and Close: 44 px targets on touch screens */
@media (pointer: coarse) {
  .ql-btn { position: relative; }
  .ql-btn::before { content: ""; position: absolute; inset: -6px; }
}

/* ---------- inspector parts (js/inspector.js) ---------- */
.ins-k { color: var(--faint); font-size: 11.5px; }
.ins-colors { display: flex; flex-direction: column; gap: 8px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 26px; height: 26px; flex: none; padding: 0; border: 0; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
  cursor: pointer; transition: transform .12s; }
button.swatch:hover { transform: scale(1.12); }
.swatch.ph { background: var(--panel); cursor: default; }
.ins-multi { display: flex; align-items: center; gap: 14px; min-width: 0; }
.ins-multi .ins-title { min-width: 0; }
.ins-mosaic.sm { width: 88px; flex: none; align-self: auto; border-radius: 12px; }
.ins-mosaic.sm.n0 { color: var(--dim); }
@media (max-width: 767px) {
  .swatch { width: 32px; height: 32px; border-radius: 9px; }
}
