/* Torn heritage / contemporary garment gallery (patch 118, layout reworked in patch 120). Class prefix hg-.
   CLEARANCE BUDGET (desktop): fixed header pill + margin = --hg-hdr (112px); title block 96-150px; index row under it; figures live in the band
   [--hg-top, 100% - --hg-bot] and are sized to fit it; captions sit under the figures, centred, inside the 11-39% / 61-89% columns; the three
   persistent assistants (bots.js: 125x190 left, 125x180 centre, 160x155 right, 16px from the bottom) therefore only ever meet empty paper.
   The Auto/Pause control sits top-right under the header, far from the assistants and from #scroll-top (bottom-right). */
#heritage-gallery{--hg-hdr:112px;--hg-top:192px;--hg-bot:204px;position:fixed;inset:0;z-index:5;pointer-events:none;overflow:hidden;display:none;contain:layout paint;will-change:transform;background:#f1ecdf}
#heritage-gallery .hg-item{position:absolute;inset:0;display:none}
#heritage-gallery .hg-layer{position:absolute;inset:0}
#heritage-gallery .hg-l{background-color:#e7dcc6;background-image:radial-gradient(120% 90% at 40% 46%,#f0e6d2 0,#e7dcc6 55%,#d9cdb4 100%),repeating-linear-gradient(0deg,#3c33200a 0 1px,transparent 1px 3px)}
#heritage-gallery .hg-r{background-color:#f4f3ef;background-image:radial-gradient(120% 90% at 60% 46%,#fbfaf6 0,#f4f3ef 55%,#e9e7df 100%)}
#heritage-gallery .hg-fig{position:absolute;top:calc((var(--hg-top) + 100% - var(--hg-bot)) / 2);height:max(190px,min(calc(100vh - var(--hg-top) - var(--hg-bot)),30vw,62vh));aspect-ratio:2/3;transform:translate(-50%,-50%) translateY(var(--hg-ty,0vh)) scale(var(--hg-s,1));transform-origin:50% 50%}
#heritage-gallery .hg-l .hg-fig{left:25%}#heritage-gallery .hg-r .hg-fig{left:75%}
#heritage-gallery .hg-fig img{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;display:block;opacity:0;visibility:hidden;filter:drop-shadow(0 22px 22px rgba(43,42,34,.28))}
#heritage-gallery .hg-fig img.ok{visibility:visible}
#heritage-gallery .hg-fibre{position:absolute;inset:0;background:#faf8f1}
#heritage-gallery .hg-shade{position:absolute;top:0;bottom:0;left:calc(50% - 60px);width:140px;filter:blur(5px)}
#heritage-gallery .hg-shade i{position:absolute;inset:0;background:#1f1d14;opacity:.3}
#heritage-gallery .hg-head{position:absolute;left:0;right:0;top:calc(var(--hg-hdr) - 14px);text-align:center;color:#2c2a22;font-family:Georgia,'Times New Roman',serif;opacity:0}
#heritage-gallery .hg-head small{display:block;font:10px Arial,sans-serif;letter-spacing:.24em;opacity:.7}
#heritage-gallery .hg-head h2{margin:.3em 0 0;font-weight:300;font-size:clamp(18px,2vw,30px);letter-spacing:.04em;line-height:1.15}
#heritage-gallery .hg-cap{position:absolute;bottom:112px;width:min(26%,290px);color:#2c2a22;font-family:Georgia,serif;opacity:0;text-align:center}
#heritage-gallery .hg-l .hg-cap{left:calc(25% - min(13%,145px))}#heritage-gallery .hg-r .hg-cap{left:calc(75% - min(13%,145px))}
#heritage-gallery .hg-cap small{display:block;font:10px Arial,sans-serif;letter-spacing:.24em;opacity:.65}
#heritage-gallery .hg-cap b{display:block;font-weight:400;font-size:clamp(15px,1.4vw,22px);margin:.3em 0 .15em}
#heritage-gallery .hg-cap span{display:block;font-size:clamp(11px,.9vw,14px);line-height:1.4;opacity:.75}
#heritage-gallery .hg-index{position:absolute;left:0;right:0;top:calc(var(--hg-top) - 34px);display:flex;justify-content:center;flex-wrap:nowrap;gap:12px;font:10px Arial,sans-serif;letter-spacing:.2em;color:#34493f;white-space:nowrap}
#heritage-gallery .hg-index b{font-weight:400;opacity:.35;transition:opacity .2s}#heritage-gallery .hg-index b.on{opacity:1}
#heritage-gallery .hg-status{position:absolute;left:0;right:0;top:50%;text-align:center;font:11px Arial,sans-serif;letter-spacing:.2em;text-transform:uppercase;color:#34493f;opacity:0;pointer-events:none}
#heritage-gallery .hg-status span{display:inline-block}
#heritage-gallery .hg-status .hg-retry{display:none;margin-left:14px;font:inherit;letter-spacing:.2em;text-transform:uppercase;color:#34493f;background:#faf8f1;border:1px solid #34493f;border-radius:20px;padding:6px 14px;cursor:pointer}
#heritage-gallery .hg-status.hg-err .hg-retry{display:inline-block;pointer-events:auto}
#heritage-gallery .hg-auto{position:absolute;right:max(18px,3vw);top:calc(var(--hg-hdr) - 8px);display:flex;align-items:center;gap:8px;pointer-events:auto;cursor:pointer;font:10px Arial,sans-serif;letter-spacing:.2em;color:#34493f;background:#faf8f1e6;border:1px solid #34493f55;border-radius:20px;padding:7px 13px 7px 11px}
#heritage-gallery .hg-auto:hover,#heritage-gallery .hg-auto:focus-visible{border-color:#34493f;outline:none}
#heritage-gallery .hg-auto i{display:block;width:9px;height:10px;position:relative}
#heritage-gallery .hg-auto i.p:before,#heritage-gallery .hg-auto i.p:after{content:'';position:absolute;top:0;width:3px;height:10px;background:#34493f}
#heritage-gallery .hg-auto i.p:before{left:0}#heritage-gallery .hg-auto i.p:after{right:0}
#heritage-gallery .hg-auto i.g{border-left:9px solid #34493f;border-top:5px solid transparent;border-bottom:5px solid transparent;width:0;height:0}
@media(max-height:560px){#heritage-gallery{--hg-top:176px;--hg-bot:150px}#heritage-gallery .hg-cap span{display:none}#heritage-gallery .hg-cap{bottom:100px}}
@media(max-width:1200px){#heritage-gallery{--hg-bot:172px}#heritage-gallery .hg-cap{width:min(20%,200px)}#heritage-gallery .hg-l .hg-cap{left:calc(25% - min(10%,100px))}#heritage-gallery .hg-r .hg-cap{left:calc(75% - min(10%,100px))}#heritage-gallery .hg-cap span{display:none}}
@media(max-width:800px){
 #heritage-gallery{--hg-top:176px;--hg-bot:208px}
 /* phone: assistants are 83px wide and up to 145px tall at the bottom; captions rise above them and keep only label + title */
 #heritage-gallery .hg-fig{height:max(150px,min(calc(100vh - var(--hg-top) - var(--hg-bot)),70vw,56vh))}
 #heritage-gallery .hg-cap{bottom:176px;width:44%}#heritage-gallery .hg-l .hg-cap{left:3%}#heritage-gallery .hg-r .hg-cap{left:53%}
 #heritage-gallery .hg-cap span{display:none}
 #heritage-gallery .hg-index{display:none}
 #heritage-gallery .hg-auto{right:auto;left:50%;transform:translateX(-50%);top:calc(var(--hg-hdr) + 38px);padding:6px 12px}
 #heritage-gallery .hg-head small{display:none}
 #heritage-gallery .hg-head h2{font-size:clamp(16px,5vw,22px)}
}
@media(prefers-reduced-motion:reduce){#heritage-gallery .hg-index b{transition:none}}

/* Actual 1265x720 header ends at 123px. Keep headings and pointer control clear. */
#heritage-gallery{--hg-hdr:154px;--hg-top:234px}
#heritage-gallery .hg-head{top:var(--hg-hdr)}
#heritage-gallery .hg-auto{top:calc(var(--hg-hdr) - 6px)}
@media(max-width:800px){#heritage-gallery{--hg-top:240px}#heritage-gallery .hg-auto{top:calc(var(--hg-hdr) + 38px)}}
