/* drawings.css 1.6.0 – gallery + viewer */

/* shared values – on the outer container so the gallery AND the buttons next to it get them */
#container-drawings {
    --u: clamp(32px, 3.4vmin, 38px);
    --list-w: clamp(150px, 32vw, 240px);
    --dur: .6s;
    --ease: cubic-bezier(.4, 0, .2, 1);
    --fg: #e6e2d8;
    --pic-bg: #14111a;
    position: relative; overflow: hidden; touch-action: pan-y pinch-zoom;
}

#container-gallery {
    font-size: var(--u);

    display: grid;
    height: 100dvh; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
    gap: .4em; align-content: start;
}
#container-gallery.collapsed { --list-w: 0px; }

/* ---------- cells ---------- */
#container-gallery .cell {
    position: relative; overflow: hidden; cursor: pointer;
    border-radius: .5em; user-select: none;
}
#container-gallery .ghosted { visibility: hidden !important; }

#container-gallery .box {
    position: absolute; inset: 0; z-index: 0;
    background: #0008; border: 1px solid #fff2; border-radius: .5em;
    pointer-events: none;
}
#container-gallery .cell.main .box { opacity: 0; }

#container-gallery .pics { position: relative; z-index: 1; }

/* ---------- main ---------- */
#container-gallery .cell.main {
    position: sticky; top: 0; z-index: 1;
    height: 100dvh; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
    padding-top: 80px; box-sizing: border-box; cursor: default;
}
#container-gallery .cell.main .pics {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(min(9em, 100%), 1fr));
    gap: .5em; padding: .5em;
}
#container-gallery .cell.main .pic { position: relative; aspect-ratio: 4 / 3; cursor: zoom-in; }
#container-gallery .cell.main .label {
    position: relative; inset: auto;
    display: block; font-size: min(2.2em, 9vw); text-align: left; padding: 0 .5em;
    overflow-wrap: anywhere;
}

/* images with process shots: stacked look + count badge */
#container-gallery .cell.main .pic.has-process {
    box-shadow: 4px -4px 0 -1px #3a3444, 8px -8px 0 -2px #26222e;
}
#container-gallery .cell.main .pic.has-process::after {
    content: "+" attr(data-process);
    position: absolute; right: .35em; top: .35em; z-index: 2;
    font: 600 .5em/1 system-ui, sans-serif; color: var(--fg);
    background: #000b; border: 1px solid #fff3; border-radius: 1em; padding: .3em .55em;
    pointer-events: none;
}

/* title + date on main tiles */
#container-gallery .pic .cap { display: none; }
#container-gallery .cell.main .pic .cap {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
    display: flex; flex-direction: column;
    padding: 1.4em .5em .4em; pointer-events: none;
    font: 500 .42em/1.3 system-ui, sans-serif; color: var(--fg);
    text-shadow: 0 1px 3px #000;
    background: linear-gradient(#0000, #000c);
    opacity: 0; transition: opacity var(--dur) var(--ease);
}
#container-gallery .cell.main .pic.loaded .cap { opacity: 1; }
#container-gallery .cap span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#container-gallery .cap-d { opacity: .7; }

/* album date range under the main title */
#container-gallery .range { display: none; }
#container-gallery .cell.main .range:not(:empty) {
    display: block; padding: 0 1.8em .3em;       /* lines up with the title's indent */
    font: 400 .6em/1.3 system-ui, sans-serif; color: var(--fg); opacity: .6;
}

/* ---------- sidebar ---------- */
#container-gallery .cell:not(.main) {
    transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
#container-gallery.collapsed .cell:not(.main) {
    transform: translateX(120%); opacity: 0; pointer-events: none;
}

#container-gallery .cell:not(.main) .pics {
    position: relative; display: flex; height: 3em; padding-left: .4em;
}
#container-gallery .cell:not(.main) .pic {
    width: 4em; height: 3em; flex: none;
    margin-right: -2em; border-radius: .3em; box-shadow: 2px 0 4px #0008;
    background: var(--pic-bg);
}
#container-gallery .cell:not(.main) .pic.loaded img { opacity: .45; }
#container-gallery .cell:not(.main):hover .pic.loaded img { opacity: 1; }
#container-gallery .cell:not(.main):hover .label { opacity: .5; }

/* left image on top */
#container-gallery .cell:not(.main) .pic:nth-child(1) { z-index: 4; }
#container-gallery .cell:not(.main) .pic:nth-child(2) { z-index: 3; }
#container-gallery .cell:not(.main) .pic:nth-child(3) { z-index: 2; }
#container-gallery .cell:not(.main) .pic:nth-child(4) { z-index: 1; }
/* rest stays in layout (lazy-loads) but invisible */
#container-gallery .cell:not(.main) .pic:nth-child(n+5) {
    position: absolute; left: 0; top: 0; visibility: hidden;
}

/* ---------- label ---------- */
#container-gallery .label {
    position: absolute; inset: 0; z-index: 5;
    display: flex; align-items: center; justify-content: center;
    padding: .15em .6em;
    font-weight: 500; line-height: 1.4; font-family: system-ui, sans-serif;
    color: var(--fg); text-shadow: 0 1px 4px #000, 0 0 12px #000;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
}

/* ---------- sidebar toggle ---------- */
#button-toggle_list {
    position: absolute; top: .4em; right: .4em; z-index: 10;
    display: grid; place-items: center;
    width: 1.6em; height: 1.6em; padding: 0; font: 400 var(--u)/1 system-ui, sans-serif;
    border: 1px solid #fff2; border-radius: .3em; background: #0008; color: var(--fg);
    cursor: pointer; opacity: .8; transition: opacity .3s;
}
#button-toggle_list:hover { opacity: 1; }
#button-toggle_list svg {
    width: .4em; height: .64em; display: block;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- loading spinner ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner, #container-gallery .pic::before {
    content: ""; position: absolute; left: 50%; top: 50%;
    width: .8em; height: .8em; margin: -.4em 0 0 -.4em; box-sizing: border-box;
    border: 2px solid #e6e2d833; border-top-color: #e6e2d8bb; border-radius: 50%;
    animation: spin .9s linear infinite; pointer-events: none;
    transition: opacity .3s, visibility 0s .3s;
}
/* tiles: visible until the image is there, then fades out under the fading-in image */
#container-gallery .pic.loaded::before,
#container-gallery .pic.error::before { opacity: 0; visibility: hidden; }

/* ---------- images ---------- */
#container-gallery .pic { position: relative; overflow: hidden; background: #111; }
#container-gallery .pic img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    opacity: 0; transition: opacity var(--dur) var(--ease);
}
#container-gallery .pic.loaded img { opacity: 1; }

/* ---------- ghost layer (during a switch) ---------- */
.ghost-layer { position: absolute; inset: 0; z-index: 1000; pointer-events: none; overflow: visible; }
.ghost       { position: absolute; box-sizing: border-box; transform-origin: 0 0; will-change: transform, opacity; }
.ghost-box   { background: #0008; border: 1px solid #fff2; border-radius: .5em; }
.ghost-pic   { overflow: hidden; border-radius: .3em; background: #14111a; }
.ghost-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ghost-label {
    white-space: nowrap; line-height: normal;
    font-weight: 500; font-family: system-ui, sans-serif; color: #e6e2d8;
    text-shadow: 0 1px 4px #000, 0 0 12px #000;
}

/* ---------- viewer ---------- */
#viewer {
    position: fixed; inset: 0; z-index: 2000; display: none; flex-direction: column;
    touch-action: pinch-zoom; user-select: none;
    font: 500 clamp(14px, 2.2vmin, 18px)/1.35 system-ui, sans-serif; color: #e6e2d8;
}
#viewer.open { display: flex; }
#viewer [hidden] { display: none !important; }

.viewer-backdrop { position: absolute; inset: 0; background: #000e; }
.viewer-stage    { position: relative; flex: 1; min-height: 0; margin: 3.5em .5em .5em; }
.viewer-img      { width: 100%; height: 100%; object-fit: contain; display: block; cursor: pointer; }
.viewer-img:not([src]) { visibility: hidden; }                  /* no empty frame before the first image */
/* viewer: only when loading takes a moment, so cached images don't flash a spinner */
.viewer-spinner  { font-size: 2.4em; opacity: 0; visibility: hidden; }
#viewer.loading .viewer-spinner { opacity: 1; visibility: visible; transition: opacity .3s .2s, visibility 0s .2s; }

.viewer-bottom {
    position: relative; display: flex; flex-direction: column; align-items: center;
    gap: .5em; padding: 0 .5em .8em;
}
.viewer-caption { text-align: center; max-width: 40em; }
.vc-title { font-size: 1.15em; font-weight: 600; }
.vc-sub   { opacity: .7; font-size: .9em; }
.vc-info  { opacity: .8; font-size: .9em; margin-top: .3em; white-space: pre-line; max-height: 6.5em; overflow-y: auto; }
.vc-title:empty, .vc-sub:empty, .vc-info:empty { display: none; }

.viewer-strip { display: flex; gap: .4em; max-width: 100%; overflow-x: auto; padding: .2em; scrollbar-width: none; }
.vs-thumb {
    flex: none; width: 3.2em; height: 2.4em; padding: 0;
    border: 1px solid #fff3; border-radius: .3em; overflow: hidden; background: #14111a;
    opacity: .5; cursor: pointer; transition: opacity .3s, border-color .3s;
}
.vs-thumb:first-child { margin-right: .5em; }           /* drawing | process shots */
.vs-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vs-thumb.active { opacity: 1; border-color: #e6e2d8; }

.viewer-counter { opacity: .6; font-size: .9em; }
.viewer-counter:empty { display: none; }

.viewer-close, .viewer-share, .viewer-prev, .viewer-next, .viewer-up, .viewer-down {
    position: absolute; z-index: 2;
    font: inherit; font-size: 1.5em; line-height: 1; padding: .3em .6em;
    color: inherit; background: #0008; border: 1px solid #fff2; border-radius: .4em;
    cursor: pointer; opacity: .7; transition: opacity .3s;
}
.viewer-close { top: .5em; right: .5em; }
.viewer-share { top: .5em; left: .5em; font-size: 1em; padding: .45em .8em; }
.viewer-toast {
    position: absolute; top: .8em; left: 50%; transform: translateX(-50%); z-index: 3;
    padding: .4em .9em; border-radius: .4em; background: #000c; border: 1px solid #fff2;
    opacity: 0; pointer-events: none;
}
.viewer-prev  { left: .5em;  top: 50%; transform: translateY(-50%); }
.viewer-next  { right: .5em; top: 50%; transform: translateY(-50%); }
/* up/down: wide, easy to hit, drawn chevrons (no rotated text glyph) */
.viewer-up, .viewer-down { left: 50%; transform: translateX(-50%); width: 4.2em; height: 1.9em; padding: 0; }
.viewer-up    { top: .3em; }
.viewer-down  { bottom: .3em; }
.viewer-up svg, .viewer-down svg {
    display: block; width: 1em; height: .65em; margin: auto;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.viewer-close:hover, .viewer-share:hover, .viewer-prev:hover, .viewer-next:hover,
.viewer-up:hover, .viewer-down:hover { opacity: 1; }
.viewer-up, .viewer-down { display: none; }
#viewer.has-stack .viewer-up, #viewer.has-stack .viewer-down { display: grid; place-items: center; }
#viewer.single .viewer-prev, #viewer.single .viewer-next { display: none; }
