/* ============================================================
   popover.css — Generic anchored popover control
   Shared shell: trigger button, click-catcher backdrop, panel.
   Content styling lives with the component that fills the panel.
   ============================================================ */

/* ── Trigger — for callers that need an explicit button. A caller can also
      open a panel straight from its own click handler instead. ── */
.arion-popover-trigger {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--slate-50);
    color: var(--text-muted-dk);
    font-size: 11.5px;
    line-height: 1;
    cursor: pointer;
    transition: border-color .12s ease, background-color .12s ease, color .12s ease;
}

.arion-popover-trigger:hover:not(:disabled) {
    border-color: var(--slate-300);
    background: var(--slate-100);
    color: var(--text-color);
}

.arion-popover-trigger:focus-visible {
    outline: 2px solid var(--blue-500);
    outline-offset: 1px;
}

.arion-popover-trigger:disabled {
    opacity: .35;
    cursor: default;
}

/* ── Click catcher — dismisses the panel, stays invisible ── */
.arion-popover-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1060;
    background: transparent;
}

/* ── Panel ── */
.arion-popover-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1061;
    --pop-w: 640px;
    --pop-h: 420px;
    display: flex;
    flex-direction: column;
    width: var(--pop-w);
    max-width: calc(100vw - 32px);
    max-height: var(--pop-h);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    background: var(--form-bg-color);
    box-shadow: 0 12px 32px var(--shadow-color);
    text-align: left;
}

/* ── Anchored to a click point: --pop-x / --pop-y are the pointer's viewport
      coordinates. The clamps keep the panel fully on screen near an edge
      without needing to measure anything in JS. ── */
.arion-popover-panel--anchored {
    position: fixed;
    top: clamp(8px, var(--pop-y, 0px), calc(100vh - var(--pop-h) - 8px));
    left: clamp(8px, var(--pop-x, 0px), calc(100vw - var(--pop-w) - 8px));
    margin-top: 10px;
}

.arion-popover-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--slate-100);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.arion-popover-title {
    color: var(--text-color);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
}

.arion-popover-subtitle {
    margin-top: 2px;
    color: var(--text-muted-lt);
    font-family: var(--font-body);
    font-size: 11.5px;
    line-height: 1.3;
}

.arion-popover-body {
    overflow-y: auto;
    padding: 6px 14px 12px;
}

/* ── Below md the panel becomes a bottom sheet: an anchored 380px
      panel has nowhere to sit on a narrow screen. ── */
@media (max-width: 767.98px) {
    .arion-popover-backdrop {
        background: rgba(0, 0, 0, .4);
    }

    .arion-popover-panel,
    .arion-popover-panel--anchored {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        max-width: none;
        max-height: 72vh;
        margin-top: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .arion-popover-header {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}
