/* ═════════════════════════════════════════════════════════════════════════
   The demo guide (component/renderDemoGuide.jte, demoGuide.js).

   A public demo is a tool's own page drawn on a fixed example. This is what
   turns that page into a demonstration: a list of the tool's functions at the
   top, a numbered pin on the region each one is about, a ring round the region
   being talked about, and a caption that follows the reader down the page.

   It borrows the page it sits on rather than restyling it: the section's hue
   (the same one the site header and /site-info give this tool's group), the
   site's hexagon as the number badge, and the tooltip surfaces (--tt-*) that
   already exist per theme. Nothing here touches the tool's own layout — the
   pins live in a layer over the page and the caption floats.
   ═════════════════════════════════════════════════════════════════════════ */

.dg,
.dg-pins,
.dg-cap {
    --dg-hue: var(--hue, #f4c04e);
    --dg-ink-on-hue: hsl(225, 30%, 10%);
}

/* ── The block at the top ──────────────────────────────────────────────── */
.dg {
    margin: 14px auto 20px;
    padding: 14px 16px 12px;
    max-width: min(1344px, calc(100% - 24px));
    border: 1px solid color-mix(in srgb, var(--dg-hue) 42%, var(--tt-line));
    border-radius: 14px;
    background: color-mix(in srgb, var(--dg-hue) 7%, var(--tt-surface));
    color: var(--bulma-text);
    font-size: 0.9rem;
    line-height: 1.5;
    text-align: left;
}

.dg__top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
}

.dg__name {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
    margin: 0;
    font-size: 1.06rem;
    color: var(--bulma-text-strong);
}

.dg__name strong {
    color: inherit;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.dg__hex {
    flex: none;
    width: 11px;
    height: 12px;
    background: var(--dg-hue);
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}

.dg__tag {
    padding: 2px 8px;
    border-radius: 99px;
    background: color-mix(in srgb, var(--dg-hue) 26%, var(--tt-surface));
    color: var(--bulma-text-strong);
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.5;
}

.dg__what {
    flex: 1 1 340px;
    min-width: 0;
    margin: 0;
    text-wrap: pretty;
}

.dg__fixed {
    color: var(--sh-ink-quiet, var(--bulma-text-weak));
}

.dg__go {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

.dg__btn,
.dg-cap__nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--tt-line);
    border-radius: 8px;
    background: var(--tt-surface);
    color: var(--bulma-text-strong);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
}

.dg__btn:hover,
.dg-cap__nav:hover {
    border-color: color-mix(in srgb, var(--dg-hue) 70%, var(--tt-line));
    color: var(--bulma-text-strong);
}

.dg__btn--buy,
.dg__btn--buy:hover {
    border-color: transparent;
    background: var(--sh-cta-bg);
    color: var(--sh-cta-fg);
}

.dg__btn--buy:hover {
    filter: brightness(1.08);
}

/* The functions. Numbered because the numbers are the key to the pins on the
   page below, the way a figure's callouts are — not because they are a ranking. */
.dg__steps {
    display: grid;
    grid-template-columns: repeat(var(--dg-cols, 1), minmax(0, 1fr));
    gap: 2px 14px;
    margin: 12px 0 0;
    padding: 10px 0 0;
    border-top: 1px solid color-mix(in srgb, var(--tt-line) 75%, transparent);
    list-style: none;
    counter-reset: dg;
}

.dg__steps > li {
    position: relative;
    margin: 0;
    padding: 7px 8px 7px 38px;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.45;
    counter-increment: dg;
    text-wrap: pretty;
}

.dg__steps > li > strong {
    display: block;
    color: var(--bulma-text-strong);
    font-weight: 650;
}

/* With the script running a step is a way to its region. */
.dg.is-live .dg__steps > li {
    cursor: pointer;
}

.dg.is-live .dg__steps > li:hover {
    background: color-mix(in srgb, var(--dg-hue) 9%, transparent);
}

.dg__steps > li.is-on {
    background: color-mix(in srgb, var(--dg-hue) 16%, transparent);
}

/* A step whose region is not on the page (a part of the tool this example does
   not reach): still said, not offered as somewhere to go. */
.dg.is-live .dg__steps > li.is-absent {
    cursor: default;
    opacity: 0.6;
}

.dg__steps > li::before,
.dg-pin,
.dg-cap__n {
    display: grid;
    place-items: center;
    width: 22px;
    height: 24px;
    background: var(--dg-hue);
    color: var(--dg-ink-on-hue);
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
    font-size: 0.74rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.dg__steps > li::before {
    content: counter(dg);
    position: absolute;
    left: 8px;
    top: 7px;
}

/* A pin whose region is not on the page just now (a panel the reader closed, a view swapped for another)
   is hidden by the script. "display: grid" above would otherwise win over the hidden attribute and leave
   the pin standing where its region used to be. */
.dg-pin[hidden] {
    display: none;
}

.dg__steps > li:focus-visible,
.dg__btn:focus-visible,
.dg-cap__nav:focus-visible,
.dg-pin:focus-visible {
    outline: 2px solid var(--sh-cta-bg);
    outline-offset: 2px;
}

/* How many columns the list takes: enough to fill the width, and — on a wide
   screen — a number that leaves no step alone on the last row. */
@media (min-width: 620px) {
    .dg__steps {
        --dg-cols: 2;
    }
}

@media (min-width: 1000px) {
    .dg__steps {
        --dg-cols: 4;
    }

    .dg__steps:has(> li:nth-child(3):last-child),
    .dg__steps:has(> li:nth-child(5):last-child),
    .dg__steps:has(> li:nth-child(6):last-child),
    .dg__steps:has(> li:nth-child(9):last-child) {
        --dg-cols: 3;
    }
}

@media (min-width: 1280px) {
    .dg__steps:has(> li:nth-child(5):last-child) {
        --dg-cols: 5;
    }
}

/* ── The pins ──────────────────────────────────────────────────────────────
   One layer over the whole document, a pin per region, placed by demoGuide.js
   in page coordinates — so they scroll with the page for free and nothing is
   added inside the tool's own markup. */
.dg-pins {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    /* Over the tool, under the site header (30) and anything modal. */
    z-index: 24;
}

.dg-pin {
    position: absolute;
    padding: 0;
    border: 0;
    cursor: pointer;
    /* A clip-path cuts a shadow off, so the lift is a second hexagon behind. */
    filter: drop-shadow(0 1px 2px hsl(0, 0%, 0%, 0.45));
    transition: transform 0.13s;
}

.dg-pin:hover,
.dg-pin.is-on {
    transform: scale(1.18);
}

/* ── The region being talked about ─────────────────────────────────────── */
[data-demo-step] {
    scroll-margin-top: calc(var(--sh-h, 0px) + 56px);
}

[data-demo-on] {
    outline: 2px solid var(--dg-ring, #f4c04e);
    outline-offset: 5px;
    border-radius: 6px;
}

/* ── The caption ───────────────────────────────────────────────────────────
   Follows the reader once the block at the top has scrolled away: which
   function they are looking at, what it does, and the way to the next one.
   At the foot of the window, like a caption under a figure, so it never
   competes with the site header or a tool's own sticky bars for the top. */
.dg-cap {
    position: fixed;
    left: 50%;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px) + var(--dg-lift, 0px));
    z-index: 26;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 4px 12px;
    width: min(780px, calc(100% - 24px));
    padding: 11px 12px 11px 14px;
    border: 1px solid color-mix(in srgb, var(--dg-hue) 45%, var(--tt-line));
    border-radius: 14px;
    background: color-mix(in srgb, var(--dg-hue) 6%, var(--tt-surface));
    box-shadow: var(--tt-shadow);
    color: var(--bulma-text);
    font-size: 0.86rem;
    line-height: 1.45;
    text-align: left;
    transform: translate(-50%, 0);
    transition: opacity 0.18s, transform 0.18s;
}

.dg-cap[hidden] {
    display: grid;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 10px);
    visibility: hidden;
    transition: opacity 0.18s, transform 0.18s, visibility 0s 0.18s;
}

.dg-cap__n {
    margin-top: 1px;
}

.dg-cap__txt {
    min-width: 0;
    margin: 0;
    text-wrap: pretty;
}

.dg-cap__txt strong {
    color: var(--bulma-text-strong);
    font-weight: 650;
}

.dg-cap__of {
    margin-left: 6px;
    color: var(--sh-ink-quiet, var(--bulma-text-weak));
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dg-cap__navs {
    display: flex;
    gap: 6px;
}

.dg-cap__nav {
    width: 32px;
    padding: 0;
}

.dg-cap__nav svg {
    width: 14px;
    height: 14px;
}

.dg-cap__nav:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Inside /site-info's live window: the page around the frame introduces the
   tool, so only the pins and the caption are drawn. */
.is-embedded .dg {
    display: none;
}

@media (max-width: 640px) {
    .dg {
        padding: 12px 12px 10px;
    }

    /* On a phone the list is the steps' names only, two to a row: with every explanation written out
       it is a screen and a half before the tool begins. The explanation is what the caption says once
       a step is chosen. (font-size: 0 because the explanation is a bare text node — there is no
       element to hide.) */
    .dg__steps {
        --dg-cols: 2;
        gap: 0 8px;
    }

    .dg.is-live .dg__steps > li {
        padding: 6px 4px 6px 32px;
        font-size: 0;
        line-height: 0;
    }

    .dg.is-live .dg__steps > li > strong {
        font-size: 0.82rem;
        line-height: 1.3;
    }

    .dg__steps > li::before {
        left: 4px;
        top: 4px;
    }

    .dg-cap {
        grid-template-columns: auto minmax(0, 1fr);
        font-size: 0.84rem;
    }

    .dg-cap__navs {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dg-pin,
    .dg-cap,
    .dg-cap[hidden] {
        transition: none;
    }
}
