/* Tape-specific extension layer (phase-2 consolidation target). */

.headline-stack.archive-loading {
    position: relative;
    min-height: 460px;
    pointer-events: none;
}

.headline-stack .tape-archive-skeleton {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: none;
    padding: 6px 2px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.92), rgba(248, 250, 252, 0.98));
}

.headline-stack.archive-loading .tape-archive-skeleton {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tape-archive-skeleton-row {
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 12px;
    padding: 12px 14px;
    min-height: 56px;
    display: grid;
    grid-template-columns: 154px minmax(0, 1fr);
    align-items: center;
    gap: 12px 16px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
}

.tape-archive-skeleton-time,
.tape-archive-skeleton-line {
    display: block;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        rgba(226, 232, 240, 0.52) 22%,
        rgba(203, 213, 225, 0.94) 40%,
        rgba(226, 232, 240, 0.52) 60%
    );
    background-size: 220% 100%;
    animation: tape-archive-skeleton-shimmer 1.08s ease-in-out infinite;
}

.tape-archive-skeleton-time {
    width: 122px;
    height: 11px;
}

.tape-archive-skeleton-lines {
    min-width: 0;
}

.tape-archive-skeleton-line {
    height: 12px;
    width: 78%;
}

.tape-archive-skeleton-line.short {
    margin-top: 8px;
    width: 52%;
}

@keyframes tape-archive-skeleton-shimmer {
    0% {
        background-position: 100% 0;
    }
    100% {
        background-position: -100% 0;
    }
}

.cb-speaker-anchor {
    display: inline;
    border-bottom: 1px dotted rgba(30, 64, 175, 0.55);
    color: #084c38;
    cursor: help;
}

.cb-speaker-anchor:focus {
    outline: 2px solid rgba(30, 64, 175, 0.25);
    outline-offset: 1px;
}

.cb-speaker-tooltip {
    position: absolute;
    z-index: 2200;
    min-width: 260px;
    max-width: min(380px, 92vw);
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.42);
    background: rgba(15, 23, 42, 0.96);
    color: #e2e8f0;
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.35);
    transform: translate(-50%, 4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease, transform 0.12s ease;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.mr-chip-tooltip {
    position: absolute;
    z-index: 2200;
    min-width: 280px;
    max-width: min(420px, 92vw);
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.42);
    background: rgba(15, 23, 42, 0.96);
    color: #e2e8f0;
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.35);
    transform: translate(-50%, 4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease, transform 0.12s ease;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.cb-speaker-tooltip.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.mr-chip-tooltip.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.cb-hover-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

.cb-hover-line {
    font-size: 12px;
    line-height: 1.35;
    margin-bottom: 2px;
}

.cb-hover-summary {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.4;
    color: #cbd5e1;
}

.cb-hover-signals {
    margin: 6px 0 0;
    padding-left: 16px;
    font-size: 12px;
    line-height: 1.35;
}

.cb-hover-footnote {
    margin-top: 6px;
    font-size: 11px;
    color: #94a3b8;
}

.mr-hover-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

.mr-hover-line {
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 4px;
}

.mr-hover-summary {
    margin: 6px 0;
    font-size: 12px;
    line-height: 1.4;
    color: #cbd5e1;
}

.mr-hover-footnote {
    margin-top: 6px;
    font-size: 11px;
    color: #94a3b8;
}

/* ── Arabic translation action (subtle inline text, not a pill) ── */
.headline-translation-action {
    display: inline-block;
    margin-top: 0.26rem;
    padding: 0 3px;
    font-size: 11px;
    font-weight: 700;
    color: #084c38;
    background: transparent;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1.3;
    vertical-align: baseline;
    text-decoration: none;
    opacity: 0.82;
}
.headline-translation-action:hover {
    text-decoration: underline;
    opacity: 1;
}
.headline-translation-action.is-pending {
    color: #94a3b8;
    cursor: default;
}
.headline-translation-action[aria-expanded="true"] {
    color: #084c38;
    text-decoration: underline;
}

/* Legacy pill — keep for older WS-delivered rows during cache rollover */
.headline-arabic-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin-top: 0.3rem;
    padding: 0;
    border-radius: 0;
    border: none;
    background: transparent;
    color: #084c38;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    cursor: pointer;
    opacity: 0.82;
}
.headline-arabic-toggle:hover { opacity: 1; text-decoration: underline; }
.headline-arabic-toggle.is-loading {
    color: #94a3b8;
    cursor: default;
}
.headline-arabic-toggle[aria-expanded="true"] {
    color: #084c38;
    text-decoration: underline;
}

/* ── Arabic expansion block ── */
.headline-arabic-expansion,
.headline-arabic-panel {
    margin-top: 5px;
    padding: 6px 10px 8px 10px;
    border-top: 1px solid #eef2f7;
    background: #fbfdff;
}

.headline-arabic-label {
    font-size: 11px;
    font-weight: 800;
    color: #64748b;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.headline-arabic-text {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: #0f172a;
    text-align: right;
    unicode-bidi: plaintext;
}

.headline-arabic-expansion.is-long {
    padding-bottom: 7px;
}


/* Tickers/prices inside Arabic text stay LTR */
.headline-arabic-text .ar-ltr {
    direction: ltr;
    unicode-bidi: isolate;
    display: inline;
}


@media (max-width: 768px) {
    .cb-speaker-tooltip,
    .mr-chip-tooltip {
        min-width: 0;
        width: min(92vw, 360px);
        padding: 9px 10px;
    }

    .cb-hover-title,
    .mr-hover-title {
        font-size: 12px;
    }

    .cb-hover-line,
    .cb-hover-summary,
    .cb-hover-signals,
    .mr-hover-line,
    .mr-hover-summary {
        font-size: 11px;
    }

    .cb-hover-footnote,
    .mr-hover-footnote {
        font-size: 10px;
    }

    .headline-arabic-expansion,
    .headline-arabic-panel {
        padding: 5px 8px 7px 8px;
    }
    .headline-arabic-text {
        font-size: 12px;
    }
    .headline-translation-action,
    .headline-arabic-toggle {
        font-size: 10px;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE PHONE  (≤ 640 px)
   Target: Saudi/UAE/Qatar users on iPhone / Android arriving via Google Ads.
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

    /* ── Header row 1: compact ── */
    /* Keep search reachable at 390px; it becomes its own full-width row. */
    #search-bar-wrapper {
        display: block !important;
        order: 3;
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        max-height: none !important;
    }

    #search-bar-wrapper form {
        width: 100%;
        position: relative;
    }

    #search-bar {
        min-height: 36px;
        font-size: 13px;
    }
    /* Hide broker + research tabs — keep only Live Tape tab */
    .header-main-row .mode-tabs {
        display: flex !important;
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .header-main-row .mode-tabs::-webkit-scrollbar { display: none; }
    .header-main-row .mode-tabs .tab-btn {
        display: inline-flex !important;
        flex: 0 0 auto;
        white-space: nowrap;
    }
    /* Hide "CAUSE BEFORE CONSENSUS" tagline — logo mark + name only */
    .brand-lockup-sub { display: none !important; }
    .ws-status-text, .tier-label, .locale-switcher-label { display: none; }
    .header-main-row { gap: 6px; padding: 4px 8px; }

    /* ── Header row 2: filter chips — horizontal scroll ── */
    .header-secondary-row {
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        padding: 3px 8px;
        flex-wrap: nowrap;
    }
    .header-secondary-row::-webkit-scrollbar { display: none; }
    .filter-chips, .mode-tabs {
        flex-wrap: nowrap;
        gap: 6px;
        min-width: max-content;
    }
    .filter-chips button {
        flex-shrink: 0;
        font-size: 11px;
        padding: 4px 9px;
        white-space: nowrap;
    }

    /* ── Market radar: compact horizontal scroll ── */
    .radar-inline-shell .radar-assets-grid {
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    .radar-inline-shell .radar-tile {
        flex: 0 0 130px;
        min-width: 130px;
        scroll-snap-align: start;
    }

    /* ── HEADLINE CARD: vertical stack layout ──────────────────────────
       The 3-column grid (meta/category/title) gives the title <100px at
       390px, causing characters to break mid-word. Switch to flex-column
       so the full width is available for the headline text.
       ────────────────────────────────────────────────────────────────── */
    .headline-main-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 3px !important;
    }
    .card-meta {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        row-gap: 4px !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        flex-direction: row-reverse; /* RTL: time right, category left */
        /* Narrow cards: let category/priority/time chips WRAP instead of
           overlapping (audit: pale high-priority badge hidden behind a chip). */
        flex-wrap: wrap !important;
    }
    .card-meta > * { min-width: 0; }
    .headline-category-slot {
        flex: 0 0 auto;
    }
    .headline-title-wrap {
        width: 100% !important;
        min-width: 0 !important;
        flex-wrap: wrap !important;
    }
    .headline-title {
        flex: 1 1 100% !important;
        font-size: 14px !important;
        line-height: 1.4 !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }
    .headline-card { padding: 8px 10px !important; }

    /* Clamp all headlines to 3 lines — "عرض النص الكامل" to expand */
    .headline-title:not(.is-expanded) {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* ── Translation action: tap-friendly ── */
    .headline-translation-action,
    .headline-arabic-toggle {
        font-size: 12px;
        font-weight: 700;
        min-height: 34px;
        padding: 4px 8px;
        display: inline-flex;
        align-items: center;
    }

    /* ── Arabic expansion: full width, readable ── */
    .headline-arabic-expansion,
    .headline-arabic-panel {
        padding: 8px 10px 10px;
        margin-top: 5px;
        border-radius: 6px;
    }
    .headline-arabic-text { font-size: 13.5px; line-height: 1.5; }

    /* ── Market reaction chips: wrap so they don't force horizontal scroll ── */
    .headline-mr-burst-chips,
    .mr-chip-row,
    .mr-mover-pill-row { flex-wrap: wrap !important; gap: 4px !important; }

    /* ── Chips and tags: compact ── */
    .classification-chip, .tag { font-size: 10px; padding: 2px 5px; }
    .headline-formatted-timestamp { font-size: 10px; }

    /* ── Arc narrative row: compact + fix icon/label gap ── */
    .narrative-row-label, .arc-label { font-size: 10px; }
    .arc-toggle-btn { gap: 4px !important; }
    .arc-history-icon { flex-shrink: 0; margin-inline-end: 3px; }
    .arc-history-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }

    /* ── Eco float button: always accessible on phone ── */
    .eco-float-btn {
        display: flex !important;
        bottom: 16px; right: 16px;
        width: 46px; height: 46px;
    }
    [dir="rtl"] .eco-float-btn { right: auto; left: 16px; }

    /* ── New-updates pill ── */
    #pendingPill, .pending-pill, [id*="pendingPill"] {
        font-size: 12px; padding: 6px 14px; min-height: 36px;
    }
}
