/**
 * Anchor panel
 *
 * The window attached to an element (js/assets/ui/anchor-panel.js): no border, a soft shadow and an arrow,
 * fading and sliding in from the side it opens on
 * Layer: Implementation
 * See: js/assets/ui/docs/anchor-panel.md
 * Last updated: 2026-10-29 by jack
 */

.anchor-panel {
    --anchor-panel-bg: #ffffff;
    --anchor-panel-text: #2d2f31;
    --anchor-panel-muted: #707070;
    --anchor-panel-shadow: 0 12px 32px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.06);
    position: fixed;
    z-index: 1080;
    top: 0;
    left: 0;
    width: var(--anchor-panel-width, 360px);
    max-width: calc(100vw - 16px);
    border-radius: 12px;
    background: var(--anchor-panel-bg);
    color: var(--anchor-panel-text);
    box-shadow: var(--anchor-panel-shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease-out, transform 0.16s ease-out;
}

.anchor-panel:focus {
    outline: none;
}

/* Starts a few pixels back towards its element, then settles */
.anchor-panel[data-side="bottom"]:not(.is-open) { transform: translateY(-6px); }
.anchor-panel[data-side="top"]:not(.is-open) { transform: translateY(6px); }
.anchor-panel[data-side="left"]:not(.is-open) { transform: translateX(6px); }
.anchor-panel[data-side="right"]:not(.is-open) { transform: translateX(-6px); }

.anchor-panel.is-open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.anchor-panel__body {
    position: relative;
    padding: 16px 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 12px;
}

/* The arrow: a turned square in the panel's colour, on the side facing the element */
.anchor-panel__arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--anchor-panel-bg);
    transform: rotate(45deg);
}

.anchor-panel[data-side="bottom"] .anchor-panel__arrow { top: -6px; margin-left: -6px; }
.anchor-panel[data-side="top"] .anchor-panel__arrow { bottom: -6px; margin-left: -6px; }
.anchor-panel[data-side="left"] .anchor-panel__arrow { right: -6px; margin-top: -6px; }
.anchor-panel[data-side="right"] .anchor-panel__arrow { left: -6px; margin-top: -6px; }

/* Bold text in Roboto, the site's bold (Open Sans bold renders blurry) */
.anchor-panel :is(b, strong, h1, h2, h3, h4, h5, h6) {
    font-family: 'Roboto', sans-serif;
    font-weight: 700;
}

.anchor-panel__loading,
.anchor-panel__error {
    margin: 0;
    font-size: 13px;
    color: var(--anchor-panel-muted);
}

.anchor-panel__error { color: #c0392b; }

@media (prefers-reduced-motion: reduce) {
    .anchor-panel,
    .anchor-panel:not(.is-open) {
        transition: none;
        transform: none;
    }
}

/* --- DARK MODE --- */

html[data-theme="dark"] .anchor-panel {
    --anchor-panel-bg: var(--dm-raised);
    --anchor-panel-text: var(--dm-text);
    --anchor-panel-muted: var(--dm-text-3);
    --anchor-panel-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .anchor-panel__error { color: #ec7e7e; }
