/* Webworks table of contents: mobile "On this page" bar, section links and the "Link copied" message.
   Colours come from the theme through UIkit classes chosen in the element (navbar, card or tile styles,
   uk-icon-link, uk-text-*); this file only handles layout. Resets use :where() so those classes win.
   Logical properties (start, inline-start), so it reads the right way on right-to-left pages. */

/* Mobile table of contents (built on <body> from the element's <template>) */
/* Hidden: off screen and, once it has slid away, out of reach of the keyboard and screen readers */
.ww-mtoc {
    position: fixed; top: var(--ww-mtoc-top, 0px); left: 0; right: 0; z-index: 975;
    transform: translateY(-100%); visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.3s;
}
.ww-mtoc.is-visible { transform: none; visibility: visible; transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s; }
:where(.ww-mtoc-bar, .ww-mtoc-panel) { border: 0; background: none; color: inherit; border-radius: 0; }
.ww-mtoc-bar {
    display: flex; align-items: center; gap: 12px; box-sizing: border-box; width: 100%; min-height: 52px; margin: 0;
    /* At the top of the screen it reaches up behind the notch (the safe area); under the navbar it needn't */
    padding: calc(8px + max(0px, env(safe-area-inset-top, 0px) - var(--ww-mtoc-top, 0px))) calc(16px + env(safe-area-inset-right, 0px)) 8px calc(16px + env(safe-area-inset-left, 0px));
    border-radius: 0; font: inherit; text-align: start; cursor: pointer;
}
/* Full width, so the ring is drawn inside the bar rather than clipped at the screen edge. Inside it, the ring is on
   the bar's own background (a Primary or Secondary card or tile can be dark), which the theme's ring colour isn't
   chosen for, so it takes the bar's text colour; its width and style stay the theme's. */
.ww-mtoc-bar:focus-visible { outline-color: currentColor; outline-offset: -4px; }
.ww-mtoc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.ww-mtoc-label { margin: 0; font-size: 12px; }
.ww-mtoc-current { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ww-mtoc-current:empty { display: none; }
.ww-mtoc-text:has(.ww-mtoc-current:empty) .ww-mtoc-label { font-size: 15px; font-weight: 500; }
.ww-mtoc-chevron { flex: none; transition: transform 0.2s ease; }
.ww-mtoc.is-open .ww-mtoc-chevron { transform: rotate(180deg); }
.ww-mtoc-panel {
    max-height: calc(100dvh - var(--ww-mtoc-top, 0px) - 52px - env(safe-area-inset-top, 0px) - 48px); overflow-y: auto; overscroll-behavior: contain;
    box-sizing: border-box; padding: 8px calc(16px + env(safe-area-inset-right, 0px)) 12px calc(16px + env(safe-area-inset-left, 0px)); border-radius: 0;
}
:where(.ww-mtoc-panel) { box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35); }
.ww-mtoc-panel[hidden] { display: none; }
/* Comfortable tap targets */
.ww-mtoc-panel .uk-nav > li > a { padding-top: 8px; padding-bottom: 8px; }
.ww-mtoc-panel .uk-nav-sub > li > a { padding-top: 6px; padding-bottom: 6px; }
.ww-mtoc-backdrop { position: fixed; inset: 0; z-index: 974; background: rgba(0, 0, 0, 0.5); opacity: 0; transition: opacity 0.2s ease; }
.ww-mtoc-backdrop.is-visible { opacity: 1; }
.ww-mtoc-backdrop[hidden] { display: none; }
/* The width blocks below and further down are for UIkit's default breakpoints. When the site's style changes one, Breakpoints::rewriteAll writes them again at the style's widths and the element gets ww-toc-bp, which the :where(:not(.ww-toc-bp)) in each selector skips (:where keeps their weight). */
@media (min-width: 960px) { .ww-mtoc:where(:not(.ww-toc-bp)), .ww-mtoc-backdrop:where(:not(.ww-toc-bp)) { display: none !important; } }

/* Section links (rendered on the server, so their space is there from the start): uk-icon-link
   colours, revealed on hover (always faintly on touch screens) */
.ww-anchor-wrap { white-space: nowrap; }
.ww-anchor {
    display: inline-flex; align-items: center; justify-content: center; width: 1.1em; height: 1.1em;
    margin-inline-start: 0.3em; vertical-align: middle; border-radius: 6px;
    opacity: 0; transition: opacity 0.15s ease, color 0.15s ease; text-decoration: none;
}
.ww-anchor svg { width: 0.7em; height: 0.7em; }
.ww-anchor [hidden] { display: none; }
:is(h2, h3, h4, h5, h6):hover .ww-anchor, .ww-anchor:focus-visible, .ww-anchor.is-copied { opacity: 1; }
.ww-anchor:focus-visible { outline-offset: 2px; }
@media (hover: none) { .ww-anchor { opacity: 0.5; } }

/* "Link copied": card default colours, pill shape */
.ww-toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 990;
    padding: 8px 14px; border-radius: 999px; font-size: 14px; pointer-events: none;
    opacity: 0; transform: translate(-50%, 8px); transition: opacity 0.2s ease, transform 0.2s ease;
}
:where(.ww-toast) { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
.ww-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
    .ww-mtoc, .ww-mtoc.is-visible, .ww-mtoc-chevron, .ww-mtoc-backdrop, .ww-anchor, .ww-toast { transition: none; }
}
