/* AttributionDrawer — bio-narrative attribution surface
 * dynamic-hugging-meerkat S4 D2
 *
 * Right-edge slide-in drawer. Layered above the presentation player but below
 * the unified media modal so a click on a supporting-doc thumbnail can open
 * this drawer, and a deeper drill-in can layer the UMI on top.
 */

.attr-drawer {
    position: fixed;
    inset: 0;
    z-index: 8800;            /* below .umm-overlay (9100), above .pres-* */
    pointer-events: none;
    visibility: hidden;
}

.attr-drawer.open {
    pointer-events: auto;
    visibility: visible;
}

.attr-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 6, 18, 0.45);
    opacity: 0;
    transition: opacity 180ms ease-out;
}

.attr-drawer.open .attr-drawer-backdrop {
    opacity: 1;
}

.attr-drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(440px, 92vw);
    background: var(--color-surface, #1a1828);
    color: var(--color-text, #e6e2f4);
    box-shadow: -16px 0 48px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 220ms ease-out;
    overflow: hidden;
}

.attr-drawer.open .attr-drawer-panel {
    transform: translateX(0);
}

.attr-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, #22203a, #1a1828);
    flex-shrink: 0;
}

.attr-drawer-title {
    margin: 0;
    font-size: calc(1rem * var(--type-scale, 1));
    font-weight: 600;
    letter-spacing: 0.01em;
}

.attr-drawer-close {
    background: transparent;
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    font-size: calc(1rem * var(--type-scale, 1));
    padding: 0.25rem 0.55rem;
    cursor: pointer;
    line-height: 1;
}
.attr-drawer-close:hover { background: rgba(255, 255, 255, 0.08); }

.attr-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    -webkit-overflow-scrolling: touch;
}

.attr-drawer-loading,
.attr-drawer-error {
    color: rgba(230, 226, 244, 0.65);
    font-size: calc(0.9rem * var(--type-scale, 1));
    padding: 0.75rem;
    text-align: center;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}

.attr-drawer-error { color: #f6b8b0; }

.attr-drawer-sentence {
    margin: 0;
    padding: 0.65rem 0.85rem;
    border-left: 3px solid var(--color-accent, #c9b6ff);
    background: rgba(255, 255, 255, 0.04);
    font-style: italic;
    font-size: calc(0.92rem * var(--type-scale, 1));
    color: rgba(230, 226, 244, 0.92);
    border-radius: 0 6px 6px 0;
}

/* ── Per-claim section ──────────────────────────────────────────────────── */

.attr-claim {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.025);
    border-radius: 10px;
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

.attr-claim-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.attr-claim-pred {
    font-size: calc(0.78rem * var(--type-scale, 1));
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(230, 226, 244, 0.6);
}

.attr-claim-value {
    font-size: calc(1rem * var(--type-scale, 1));
    line-height: 1.4;
    color: var(--color-text, #e6e2f4);
}

.attr-claim-language {
    font-size: calc(0.84rem * var(--type-scale, 1));
    color: rgba(230, 226, 244, 0.72);
    font-style: italic;
    padding: 0.3rem 0.5rem;
    background: rgba(201, 182, 255, 0.06);
    border-left: 2px solid rgba(201, 182, 255, 0.4);
    border-radius: 0 6px 6px 0;
}

.attr-claim-sources {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.attr-claim-error,
.attr-claim-blocked {
    border-color: rgba(246, 184, 176, 0.25);
    background: rgba(246, 184, 176, 0.05);
}

/* ── Source popover (inline, not modal) ─────────────────────────────────── */

.attr-source-popover {
    margin-top: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: calc(0.85rem * var(--type-scale, 1));
}

.attr-source-popover-title {
    margin: 0 0 0.4rem;
    font-size: calc(0.92rem * var(--type-scale, 1));
    font-weight: 600;
}

.attr-source-popover-meta {
    margin: 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.2rem 0.6rem;
}

.attr-source-popover-meta dt {
    color: rgba(230, 226, 244, 0.6);
    font-size: calc(0.75rem * var(--type-scale, 1));
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.attr-source-popover-meta dd {
    margin: 0;
    color: var(--color-text, #e6e2f4);
    word-break: break-word;
}

/* ── Clickable source detail card (recasting-pocket-stagecraft S5) ───────────
   Each source pill is clickable → this card: the supporting document (the
   cited vault media, opened in the UMI) when one exists, else the attribution
   in detail (full provenance). Mirrors the S3 mobile Sources behavior. */

.attr-source-detail {
    margin-top: 0.5rem;
    padding: 0.65rem 0.75rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(201, 182, 255, 0.22);
    border-radius: 8px;
    font-size: calc(0.85rem * var(--type-scale, 1));
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    animation: attr-source-detail-in 160ms ease-out;
}

@keyframes attr-source-detail-in {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* The supporting-document affordance — the cited vault media → the UMI. */
.attr-source-open {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    align-self: flex-start;
    padding: 0.5rem 0.85rem;
    background: var(--color-accent, #c9b6ff);
    color: #1a1828;
    border: 0;
    border-radius: 8px;
    font-weight: 600;
    font-size: calc(0.88rem * var(--type-scale, 1));
    cursor: pointer;
    line-height: 1;
    transition: filter 120ms ease, transform 120ms ease;
}
.attr-source-open:hover { filter: brightness(1.08); transform: translateY(-1px); }
.attr-source-open svg { flex-shrink: 0; }

.attr-source-detail-body { display: block; }

/* renderSourcePopover output, scoped inside the card so the detail is styled
   regardless of whether attribution-modal.css is present on this surface. */
.attr-source-detail .am-popover-title {
    margin: 0 0 0.4rem;
    font-size: calc(0.92rem * var(--type-scale, 1));
    font-weight: 600;
    color: var(--color-text, #e6e2f4);
}
.attr-source-detail .am-popover-fields {
    margin: 0;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.2rem 0.6rem;
}
.attr-source-detail .am-popover-fields dt {
    color: rgba(230, 226, 244, 0.6);
    font-size: calc(0.74rem * var(--type-scale, 1));
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.attr-source-detail .am-popover-fields dd {
    margin: 0;
    color: var(--color-text, #e6e2f4);
    word-break: break-word;
}
.attr-source-detail .am-popover-fields a {
    color: var(--color-accent, #c9b6ff);
    word-break: break-all;
}
.attr-source-detail .am-popover-quote {
    margin: 0;
    padding: 0.4rem 0.6rem;
    border-left: 3px solid rgba(201, 182, 255, 0.45);
    background: rgba(255, 255, 255, 0.03);
    font-style: italic;
    color: rgba(230, 226, 244, 0.9);
    border-radius: 0 6px 6px 0;
}
.attr-source-detail .am-popover-source-id {
    font-size: calc(0.72rem * var(--type-scale, 1));
    color: rgba(230, 226, 244, 0.45);
    word-break: break-all;
}
.attr-source-detail .am-warn { color: #f6b8b0; }

/* Subtle "leads to a document" cue on pills whose source has a cited media. */
.am-source-pill.attr-has-doc {
    box-shadow: inset 0 0 0 1px rgba(201, 182, 255, 0.55);
}
.am-source-pill.attr-has-doc::after {
    content: '';
    width: 5px;
    height: 5px;
    margin-left: 0.15rem;
    border-radius: 50%;
    background: var(--color-accent, #c9b6ff);
    flex: 0 0 auto;
}

/* ── Document mode ──────────────────────────────────────────────────────── */

.attr-doc-thumb,
.attr-doc-thumb-placeholder {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(230, 226, 244, 0.5);
    font-weight: 700;
    letter-spacing: 0.1em;
    height: 160px;
}

.attr-doc-thumb {
    height: auto;
}

.attr-doc-title {
    margin: 0;
    font-size: calc(1.05rem * var(--type-scale, 1));
    font-weight: 600;
}

.attr-doc-description {
    margin: 0;
    font-size: calc(0.92rem * var(--type-scale, 1));
    color: rgba(230, 226, 244, 0.78);
    line-height: 1.5;
}

.attr-doc-meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.2rem 0.65rem;
    margin: 0;
    padding: 0.6rem 0.75rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
}

.attr-doc-meta dt {
    color: rgba(230, 226, 244, 0.55);
    font-size: calc(0.74rem * var(--type-scale, 1));
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.attr-doc-meta dd {
    margin: 0;
    color: var(--color-text, #e6e2f4);
    font-size: calc(0.85rem * var(--type-scale, 1));
    word-break: break-word;
}

.attr-doc-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.attr-doc-open {
    align-self: flex-start;
    padding: 0.55rem 0.95rem;
    background: var(--color-accent, #c9b6ff);
    color: #1a1828;
    border: 0;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: calc(0.9rem * var(--type-scale, 1));
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
}

.attr-doc-open:hover {
    background: #d6c5ff;
}

/* External raw-file link is the quiet secondary next to the in-vault viewer. */
.attr-doc-open-ext {
    background: transparent;
    color: var(--color-accent, #c9b6ff);
    border: 1px solid rgba(201, 182, 255, 0.45);
}
.attr-doc-open-ext:hover {
    background: rgba(201, 182, 255, 0.12);
    color: #d6c5ff;
}

/* ── Per-sentence attribution badge in subtitle bar (S4 D3) ────────────── */

.pres-subtitles {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    justify-content: center;
}

.pres-subtitle-text {
    flex: 0 1 auto;
    min-width: 0;
}

.pres-attribution-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.18rem 0.45rem;
    background: rgba(201, 182, 255, 0.14);
    color: rgba(230, 226, 244, 0.9);
    border: 1px solid rgba(201, 182, 255, 0.35);
    border-radius: 999px;
    font-size: calc(0.7rem * var(--type-scale, 1));
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    flex: 0 0 auto;
    line-height: 1;
    transition: background 120ms ease, transform 120ms ease;
}

.pres-attribution-badge:hover {
    background: rgba(201, 182, 255, 0.24);
    transform: translateY(-1px);
}

.pres-attribution-badge.hidden {
    display: none !important;
}

.pres-attribution-badge svg {
    flex-shrink: 0;
}

.pres-attribution-count {
    line-height: 1;
}

/* Document thumbnails marked as "supporting" get a small flag overlay so
   readers can distinguish a chapter photo from a source document. */
.media-item.media-supporting-doc::after {
    content: 'SOURCE';
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(201, 182, 255, 0.92);
    color: #1a1828;
    font-size: calc(0.62rem * var(--type-scale, 1));
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 2;
    pointer-events: none;
}

/* ── Mobile tweaks ─────────────────────────────────────────────────────── */

@media (max-width: 540px) {
    /* fluffy-puzzling-dongarra S1 D1 (Iron-Law audit-all-peers): 100vw → 100%
       + box-sizing on the attribution-drawer mobile panel. iOS Safari
       scrollbar-gutter Iron Law. */
    .attr-drawer-panel {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    .attr-claim-value { font-size: calc(0.95rem * var(--type-scale, 1)); }
    .attr-doc-meta dd { font-size: calc(0.8rem * var(--type-scale, 1)); }
}

/* ── Suggest-a-correction (S5 D7) — retired by unifying-portrait-voice S3: the story player's
   one Say It carries the sentence instead (PresentationPlayer.js § Suggest-a-correction). ── */

/* ── Media-mode sections (openMedia / Issue #4 — meticulous-tailoring-canvas S3, 2026-05-10) ── */
.attr-person-tag-list,
.attr-pipeline-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.attr-person-tag,
.attr-pipeline-run {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
}
.attr-person-tag-name,
.attr-pipeline-stage {
    font-weight: 600;
    color: rgba(245, 246, 248, 0.94);
    font-size: calc(0.92rem * var(--type-scale, 1));
}
.attr-person-tag-meta,
.attr-pipeline-meta {
    font-size: calc(0.78rem * var(--type-scale, 1));
    color: rgba(230, 226, 244, 0.62);
    letter-spacing: 0.01em;
}

