/* glance.css
 *
 * The "Bolt at a glance" poster on /bolt and its full screen viewer.
 *
 * WHY THIS IS A FILE AND NOT A PAGE <style> BLOCK
 * -----------------------------------------------
 * check-design-system.mjs budgets bespoke blocks declared in per page <style>
 * elements, and says plainly: lower the number, do not raise the budget. This
 * viewer is a real component with a zoom state and a scroll lock, so it does
 * not fit in that budget. /bolt already links trust-callout.css the same way,
 * so this follows a pattern the page had rather than inventing one.
 */

/* ---------- the poster in the page ---------- */
/* id="glance" lives on this section, so /bolt/#glance lands on the poster. The nav
   is fixed, so without scroll-margin the heading of the section sits under it. */
.glance { margin: 2.5rem auto 0; max-width: var(--w-page); scroll-margin-top: calc(var(--nav-height, 80px) + 1rem); }

.glance__frame {
    margin: 0;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-surface-solid);
}

.glance__trigger { display: block; cursor: zoom-in; }
.glance__video { display: block; width: 100%; height: auto; }
/* The still is the reduced-motion substitute, and the thing the viewer opens. */
.glance__still { display: none; }

.glance__cap {
    padding: .85rem 1rem 1rem;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* ---------- the viewer ---------- */
/* Fills the viewport rather than sizing to the image. A dialog sized to a
   poster that is taller than the screen pushes its own controls off the top,
   which is what happened when the bar was positioned against the image. */
.glance-modal {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    overflow: hidden;
}

.glance-modal::backdrop { background: rgba(0, 0, 0, .95); }

.glance-modal__stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 4.5rem 2rem 2rem;
    overflow: auto;
}

/* Fit state: the whole poster is visible, click to zoom in. */
.glance-modal__stage img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    cursor: zoom-in;
}

/* Zoomed state: natural size, the stage scrolls, click to zoom back out. */
.glance-modal.is-zoomed .glance-modal__stage { align-items: flex-start; justify-content: flex-start; }
.glance-modal.is-zoomed .glance-modal__stage img {
    max-width: none;
    max-height: none;
    width: auto;
    cursor: zoom-out;
}

/* Controls sit against the viewport, so they stay reachable at any zoom. */
.glance-modal__bar {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    z-index: 1;
    display: flex;
    gap: .6rem;
    transition: opacity .15s ease;
}

/* Idle auto-hide. The controls are shown on open and on any pointer movement,
   then fade after a short idle so they stop sitting on top of the diagram.
   Deliberately opacity-only, NOT display/visibility/hidden: a tab-stop that is
   removed from the tree cannot be reached by keyboard at all, and the Close
   button is the only pointer-free way out besides Escape. Opacity keeps it in
   the tab order, and :focus-within below brings it back into view the moment
   it is focused, so it can never be both focused and invisible. */
.glance-modal.is-idle .glance-modal__bar {
    opacity: 0;
    pointer-events: none;
}

/* Any of these outrank idle, so the controls cannot hide out from under a
   pointer that is already on them or a key press that just landed. */
.glance-modal .glance-modal__bar:hover,
.glance-modal .glance-modal__bar:focus-within {
    opacity: 1;
    pointer-events: auto;
}

/* Touch and other coarse pointers never emit the movement that reveals these,
   so idle-hiding there would strand the controls permanently. */
@media (hover: none) {
    .glance-modal.is-idle .glance-modal__bar { opacity: 1; pointer-events: auto; }
}

/* Someone who asked the OS for less motion gets the still, not a paused video.
   CSS cannot stop autoplay, so the video is removed and the image takes its place. */
@media (prefers-reduced-motion: reduce) {
    .glance__video { display: none; }
    .glance__still { display: block; }
}

@media (prefers-reduced-motion: reduce) {
    .glance-modal__bar { transition: none; }
}

.glance-modal__btn {
    font-size: var(--text-sm);
    font-weight: 650;
    color: #fff;
    background: rgba(0, 0, 0, .55);
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 8px;
    padding: .35rem .9rem;
    cursor: pointer;
    text-decoration: none;
}

.glance-modal__btn:hover { background: rgba(0, 0, 0, .8); }

/* The page behind a modal must not scroll, or the reader scrolls the document
   out from under the overlay and the controls go with it. */
html.glance-locked, html.glance-locked body { overflow: hidden; }

@media (max-width: 760px) {
    .glance-modal__stage { padding: 4rem 1rem 1rem; }
    .glance-modal__bar { top: .75rem; right: .75rem; }
}
