/* ── DAIU Public Styles ──────────────────────────────────────────────────── */

/* ══ POST-LEVEL BADGE ════════════════════════════════════════════════════ */

.daiu-badge {
    position: relative;          /* tooltip anchor */
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    margin: 1.75em 0;
    background: #f8f9ff;
    border: 1px solid #dde2f0;
    border-left: 4px solid #2c5fe6;
    border-radius: 6px;
    font-size: 0.875em;
    line-height: 1.5;
    color: inherit;
    box-sizing: border-box;
}

.daiu-badge__img-link {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none;
    border-radius: 3px;
}
.daiu-badge__img-link:focus-visible {
    outline: 2px solid #2c5fe6;
    outline-offset: 2px;
}
.daiu-badge__img {
    display: block;
    height: 38px;
    width: auto;
}
.daiu-badge__body {
    flex: 1;
    min-width: 0;
}
.daiu-badge__label {
    display: block;
    font-weight: 600;
    color: inherit;
    text-decoration: none;
    word-break: break-word;
}
.daiu-badge__label:hover,
.daiu-badge__label:focus { text-decoration: underline; }

.daiu-badge__desc {
    margin: 4px 0 0;
    color: #5a6474;
    font-size: 0.9em;
}

/* Style variants */
.daiu-badge--badge-only .daiu-badge__body { display: none; }
.daiu-badge--badge-only {
    display: inline-flex;
    padding: 6px;
    background: transparent;
    border: none;
    border-left: none;
    margin: 0.5em 0;
}
.daiu-badge--text-only .daiu-badge__img-link { display: none; }
.daiu-badge--text-only {
    background: #fafafa;
    border-left-color: #999;
}

/* ══ AUTHOR BYLINE BADGE ═════════════════════════════════════════════════ */
/*
 * Compact icon injected next to the author name.
 * position:relative needed so the tooltip anchors to this container.
 */
.daiu-author-badge {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    margin-left: 7px;
    line-height: 1;
}

.daiu-author-badge a {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    border-radius: 3px;
}
.daiu-author-badge a:focus-visible {
    outline: 2px solid #2c5fe6;
    outline-offset: 2px;
}

.daiu-author-badge__img {
    display: block;
    height: 22px;
    width: auto;
    vertical-align: middle;
}

/* ══ ACCESSIBLE TOOLTIP ══════════════════════════════════════════════════ */
/*
 * Positioned absolute inside .daiu-badge or .daiu-author-badge (both have
 * position:relative). Hidden by default; .daiu-tooltip--visible added by JS
 * on hover and focus.
 *
 * aria-hidden is toggled in JS so screen readers only announce it when visible.
 */
.daiu-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a2e;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
    padding: 5px 10px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

/* Downward arrow */
.daiu-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1a1a2e;
}

/* Visible state – toggled by JS via classList */
.daiu-tooltip.daiu-tooltip--visible {
    opacity: 1;
    visibility: visible;
}

/* In text-only badge, the trigger is the text label (lower in the flex row),
   so anchor tooltip relative to the whole badge strip instead */
.daiu-badge--text-only .daiu-tooltip {
    left: 16px;          /* align with the left padding of the badge */
    transform: none;
}

/* ══ BLOCK-LEVEL IMAGE BADGE ═════════════════════════════════════════════ */
/*
 * Inserted by daiu-frontend.js as a sibling AFTER the <figure>.
 * Never inside the figure, so overflow:hidden and image stacking
 * contexts cannot hide it.
 */
.daiu-img-badge {
    display: flex;
    align-items: center;
    padding: 5px 10px;
    margin-top: -2px;
    background: #f0f2fa;
    border: 1px solid #dde2f0;
    border-top: 2px solid #2c5fe6;
    border-radius: 0 0 5px 5px;
    font-size: 12px;
    line-height: 1;
    width: fit-content;
    max-width: 100%;
    box-sizing: border-box;
}
.daiu-img-badge__link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    color: #333;
}
.daiu-img-badge__link:hover,
.daiu-img-badge__link:focus { color: #2c5fe6; }
.daiu-img-badge__svg { display: block; height: 20px; width: auto; flex-shrink: 0; }
.daiu-img-badge__text { font-size: 11px; font-weight: 500; white-space: nowrap; }

/* ══ BLOCK-LEVEL INLINE TEXT LABEL ══════════════════════════════════════ */

.daiu-block-inline { display: inline; margin-left: 0.3em; }
.daiu-block-inline__link {
    font-size: 0.72em;
    font-weight: normal;
    color: #888;
    text-decoration: none;
    vertical-align: middle;
    border-radius: 2px;
    padding: 1px 4px;
    background: rgba(0, 0, 0, 0.05);
    white-space: nowrap;
}
.daiu-block-inline__link:hover,
.daiu-block-inline__link:focus { color: #2c5fe6; background: rgba(44,95,230,0.08); outline: none; }

/* ══ RESPONSIVE ══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .daiu-badge { flex-direction: column; gap: 8px; }
    .daiu-img-badge { width: 100%; border-radius: 0 0 4px 4px; }
    /* Keep tooltip on-screen on narrow viewports */
    .daiu-tooltip { white-space: normal; max-width: 220px; left: 0; transform: none; }
    .daiu-tooltip::after { left: 20px; transform: none; }
}

/* ══ DARK MODE ═══════════════════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
    .daiu-badge {
        background: rgba(44, 95, 230, 0.08);
        border-color: #2a2f44;
        border-left-color: #5b7fff;
    }
    .daiu-badge__desc { color: #9aa5b8; }
    .daiu-badge--text-only { background: rgba(255,255,255,0.04); border-left-color: #666; }

    .daiu-img-badge { background: rgba(44,95,230,0.1); border-color: #2a2f44; border-top-color: #5b7fff; }
    .daiu-img-badge__link { color: #ccc; }
    .daiu-img-badge__link:hover { color: #7ba4ff; }

    .daiu-block-inline__link { color: #666; background: rgba(255,255,255,0.06); }
    .daiu-block-inline__link:hover { color: #7ba4ff; }

    /* Tooltip has good contrast in both modes – dark bg works universally */
}
