/*
 * Live-blog enterprise rebuild — stylesheet for all P1-P5 + A1-A10
 * markup classes. Loaded on:
 *   - Article reader pages (via header.php gated on $isArticleExperiencePage)
 *   - /live hub index (direct <link> in live/index.php)
 *   - Admin manage / desk / desk_mobile (direct <link>)
 *
 * Split into 3 sections:
 *   §1  Bootstrap 5.3+ utility polyfill (project loads Bootstrap < 5.3 in
 *       parts; these classes appeared in 5.3 and the templates depend on
 *       them. Subtle background + emphasis text + .vr separator.)
 *   §2  Public reader-surface classes (P1-P5)
 *   §3  Admin authoring-surface classes (A1-A10)
 *
 * All keyframes consolidated here so the inline <style> blocks in
 * the admin views (desk.php, desk_mobile.php, /live index.php) can
 * be retired in a future cleanup pass.
 */

/* =====================================================================
   §1 — Bootstrap 5.3+ utility polyfill
   ===================================================================== */

.bg-primary-subtle  { background-color: #cfe2ff !important; }
.bg-secondary-subtle{ background-color: #e2e3e5 !important; }
.bg-success-subtle  { background-color: #d1e7dd !important; }
.bg-danger-subtle   { background-color: #f8d7da !important; }
.bg-warning-subtle  { background-color: #fff3cd !important; }
.bg-info-subtle     { background-color: #cff4fc !important; }
.bg-light-subtle    { background-color: #fcfcfd !important; }
.bg-dark-subtle     { background-color: #ced4da !important; }

.text-primary-emphasis  { color: #052c65 !important; }
.text-secondary-emphasis{ color: #2b2f32 !important; }
.text-success-emphasis  { color: #0a3622 !important; }
.text-danger-emphasis   { color: #842029 !important; }
.text-warning-emphasis  { color: #664d03 !important; }
.text-info-emphasis     { color: #055160 !important; }

.border-primary-subtle  { border-color: #9ec5fe !important; }
.border-secondary-subtle{ border-color: #c4c8cb !important; }
.border-success-subtle  { border-color: #a3cfbb !important; }
.border-danger-subtle   { border-color: #f1aeb5 !important; }
.border-warning-subtle  { border-color: #ffe69c !important; }
.border-info-subtle     { border-color: #9eeaf9 !important; }

/* Vertical separator (Bootstrap 5.1+). Falls back gracefully when
   already defined by a newer Bootstrap bundle. */
.vr {
    display: inline-block;
    align-self: stretch;
    width: 1px;
    min-height: 1em;
    background-color: currentColor;
    opacity: 0.25;
}

/* =====================================================================
   §2 — Public reader-surface classes (P1-P5)
   ===================================================================== */

/* P1/P2 — per-update timeline cards
   ----------------------------------------------------------------- */
.live-update-card-highlight {
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}
.live-update-card-highlight:target {
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.3);
}

.live-update-meta-row {
    row-gap: 0.5rem;
}

.live-update-byline {
    line-height: 1.2;
}
.live-update-byline img {
    object-fit: cover;
    flex-shrink: 0;
}

.live-update-latest-anchor {
    /* Scroll anchor only; no visual paint. */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}
.live-update-latest-badge {
    letter-spacing: 0.04em;
    font-size: 0.72rem;
}

.live-update-permalink-anchor {
    transition: color 0.15s ease;
}
.live-update-permalink-anchor:hover {
    color: #0d6efd !important;
    text-decoration: underline !important;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
.live-update-permalink-btn {
    transition: color 0.15s ease, transform 0.15s ease;
}
.live-update-permalink-btn:hover {
    color: #0d6efd !important;
    transform: translateY(-1px);
}

.live-update-relative-time {
    font-variant-numeric: tabular-nums;
    /* CLS defensive — reserve a stable inline width so the JS ticker
       can swap "Just now" → "5 min ago" → "1 hr ago" without
       reflowing surrounding meta-row items. min-width caps to
       the longest expected label ("Yesterday" / "N days ago"). */
    display: inline-block;
    min-width: 5.5rem;
    text-align: left;
}
.live-hero-duration-text {
    /* Same CLS reservation for the hero/briefing "Live for X" widget. */
    display: inline-block;
    min-width: 6rem;
}

/* P2 — filter chips + end-of-coverage + subscribe
   ----------------------------------------------------------------- */
.live-filter-bar {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 0.25rem;
}
.live-filter-bar::-webkit-scrollbar {
    height: 4px;
}
.live-filter-bar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}
.live-filter-chip {
    flex-shrink: 0;
    white-space: nowrap;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.live-filter-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.live-filter-chip.active {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.live-coverage-ended-banner {
    border-radius: 0.5rem;
}
.live-coverage-ended-banner .badge {
    font-size: 0.78rem;
    padding: 0.4rem 0.65rem;
}

.live-subscribe-card {
    border-left: 4px solid #ffc107;
}
.live-subscribe-push-btn:not([disabled]):hover {
    background-color: #ffca2c !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.35);
}

.live-jump-select {
    max-width: 280px;
    min-width: 180px;
    font-size: 0.875rem;
}

/* P3 — sticky breaking banner + iframe shell
   ----------------------------------------------------------------- */
.live-breaking-banner {
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}
.live-breaking-banner .live-pulse-dot {
    width: 8px;
    height: 8px;
    background: currentColor;
    border-radius: 50%;
    display: inline-block;
    animation: liveBlogPulseDot 1.4s ease-in-out infinite;
}
.live-banner-headline {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
@media (max-width: 575.98px) {
    .live-banner-headline {
        font-size: 0.85rem;
    }
}

.live-embed-shell {
    background: #000;
    border-radius: 0.5rem;
    overflow: hidden;
}
.live-embed-shell iframe {
    border: 0;
}

/* P4 — hero + briefing enrichments
   ----------------------------------------------------------------- */
.live-hero-kicker {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.2;
}

/* Replaces the legacy .fst-italic subtitle treatment. NYT/Reuters-style
   deck: regular weight, generous line height, subtle on dark bg. */
.live-hero-deck {
    font-size: 1.05rem;
    line-height: 1.5;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.75) !important;
    margin-bottom: 0;
}

.live-hero-meta-row {
    column-gap: 1rem;
    row-gap: 0.5rem;
}
/* FRONT-VIEW FIX — replaced inline-flex with inline-block to preserve
   whitespace between text and child <time>. The previous inline-flex
   rule collapsed the space between "Started" and the <time> element so
   the visible text read "Started6 days ago" instead of "Started 6 days
   ago". inline-block keeps the icon centred via vertical-align without
   eating whitespace. */
.live-hero-meta-row > span {
    display: inline-block;
    vertical-align: middle;
}
.live-hero-meta-row > span > .bi {
    vertical-align: -0.125em;
}

.live-hero-duration {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.live-hero-duration-text {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.live-hero-share-row {
    margin-top: 0.5rem;
}
.live-hero-share-row .btn {
    transition: transform 0.15s ease, background-color 0.15s ease,
                border-color 0.15s ease, color 0.15s ease;
    /* FRONT-VIEW FIX — explicit colour + border so the circle buttons
       are visible against the black hero background and the Bootstrap
       Icons glyph inside renders in white. Without this, btn-outline-
       light buttons could inherit a transparent border on some Bootstrap
       builds and the icon character was invisible inside an outline-
       only circle. */
    color: #fff !important;
    border-color: rgba(255, 255, 255, 0.6) !important;
    background-color: transparent;
}
.live-hero-share-row .btn:hover {
    transform: translateY(-2px);
    background-color: rgba(255, 255, 255, 0.15) !important;
    border-color: #fff !important;
}
.live-hero-share-row .btn .bi {
    /* Ensure the icon glyph sits centred and visible (no inherit-
       transparent fill). */
    color: inherit;
    font-size: 1rem;
    line-height: 1;
}

/* P5 — /live hub card classes
   ----------------------------------------------------------------- */
.live-index-card-thumb {
    aspect-ratio: 16 / 9;
    object-fit: cover;
    width: 100%;
    transition: transform 0.4s ease;
}
.directory-card:hover .live-index-card-thumb,
.live-spotlight-card:hover .live-index-card-thumb,
.search-result-card:hover .live-index-card-thumb {
    transform: scale(1.03);
}
.live-index-card-thumb {
    /* Older browsers without aspect-ratio support. */
    height: auto;
}

.live-index-pulse-dot {
    width: 7px;
    height: 7px;
    background: currentColor;
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
    animation: liveBlogPulseDot 1.4s ease-in-out infinite;
}

.live-index-relative-time {
    font-variant-numeric: tabular-nums;
}

.live-card-preview {
    background: #f8f9fa;
    border-left: 3px solid rgba(220, 53, 69, 0.35);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
}
.live-card-preview-headline {
    font-size: 0.92rem;
    line-height: 1.35;
}
.live-card-preview-text {
    font-size: 0.82rem;
    line-height: 1.4;
}

/* =====================================================================
   §2a-fix — Hero caption overlay readability
   The shared .article-hero-overlay gradient (article-critical.css
   line 1627) tops out at 72% opacity which leaves the caption text
   barely readable against light photographs. On the live blog hero
   the caption usually mentions photographer credit + a long
   description — readability matters. Strengthen the gradient + add
   a text-shadow specifically inside the live-hero-shell scope so we
   don't affect non-live article pages.
   ===================================================================== */

.live-hero-shell .article-hero-overlay {
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.55) 40%,
        rgba(0, 0, 0, 0.85) 100%
    );
    padding-top: 3rem !important;
    padding-bottom: 1rem;
}
.live-hero-shell .article-hero-meta,
.live-hero-shell .article-hero-date {
    color: #fff !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
    font-weight: 500;
}
.live-hero-shell .article-hero-meta {
    line-height: 1.4;
}

/* =====================================================================
   §2b — Live briefing card (P4) — FRONT-VIEW FIX
   The base partial uses BEM selectors (.live-reader-briefing__*) but
   the legacy stylesheet had no rules for them, so the briefing rendered
   as plain text + default-style anchors with no visual hierarchy. This
   section adds enterprise-grade card styling.
   ===================================================================== */

.live-reader-briefing {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.live-reader-briefing__status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #b91c1c;
    margin-bottom: 0.5rem;
}
.live-reader-briefing__status--ended,
.live-reader-briefing__status--paused {
    color: #475569;
}
.live-reader-briefing__pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: liveBlogPulseDot 1.4s ease-in-out infinite;
}

.live-reader-briefing__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    font-size: 0.92rem;
    color: #334155;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}
.live-reader-briefing__meta strong {
    color: #0f172a;
    font-weight: 600;
}

.live-reader-briefing__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-top: 1px solid #e2e8f0;
    padding-top: 0.75rem;
}
.live-reader-briefing__actions a,
.live-reader-briefing__share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #1e293b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    text-decoration: none;
    line-height: 1.3;
    transition: background-color 0.15s ease, color 0.15s ease,
                border-color 0.15s ease, transform 0.15s ease;
    cursor: pointer;
}
.live-reader-briefing__actions a:hover,
.live-reader-briefing__share-btn:hover {
    background: #1e293b;
    color: #ffffff;
    border-color: #1e293b;
    text-decoration: none;
    transform: translateY(-1px);
}
.live-reader-briefing__share-btn {
    font-family: inherit;
}
.live-reader-briefing__noscript {
    font-size: 0.82rem;
    color: #64748b;
    margin: 0.5rem 0 0;
}

/* =====================================================================
   §2c — Dual .article-story-shell reconciliation (FRONT-VIEW FIX)
   For live-blog pages, the page renders two stacked .article-story-shell
   containers — one inside .live-family-shell (max-width 1180px from
   article-critical.css line 1565) and one outside (max-width 1240px
   from article-critical.css line 1255). Without alignment, readers see
   a visible width-step between sections. Match the outer container
   width to the live experience so the column edges line up.
   ===================================================================== */

.live-family-shell ~ main .article-story-shell,
.article-page-shell .article-story-shell:has(~ .article-story-shell.live-reader-experience),
main:has(> section.live-family-shell) > .article-story-shell {
    max-width: 1180px !important;
}
/* Fallback for browsers without :has() — also constrain any
   .article-story-shell that sits within a page that began with a
   .live-family-shell sibling above. */
section.live-family-shell + .article-story-shell,
section.live-family-shell ~ .article-story-shell {
    max-width: 1180px !important;
}

/* =====================================================================
   §3 — Admin authoring-surface classes (A1-A10)
   ===================================================================== */

/* A1/A5 — Keyboard hint bar
   ----------------------------------------------------------------- */
#liveblog-keyboard-hint kbd {
    background: #f1f3f5;
    color: #212529;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    padding: 0.15rem 0.4rem;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.75rem;
    box-shadow: 0 1px 0 #adb5bd;
}

/* A7 — Moderation queue filter chips
   ----------------------------------------------------------------- */
.live-moderation-filter-bar {
    row-gap: 0.5rem;
}
.live-moderation-filter-chip {
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.live-moderation-filter-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.live-moderation-filter-chip.active {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

/* A8 — Recent contributors presence chips
   ----------------------------------------------------------------- */
.live-presence-chip {
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.live-presence-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.live-presence-chip img,
.live-presence-chip > span:first-child {
    flex-shrink: 0;
}

/* =====================================================================
   §3b — Utility classes replacing inline style="..." attributes
   (CSP fix — Content-Security-Policy 'style-src 'self' 'nonce-...''
   was flagging 12+ violations from inline style attributes added in
   P1-P5 + A1-A10. Each class below covers one inline-style use case.)
   ===================================================================== */

/* 32x32 rounded share button (hero share row — P4). */
.live-share-circle {
    width: 32px !important;
    height: 32px !important;
}

/* Initial-letter avatar fallback (medium 32px — timeline byline P1). */
.live-avatar-fallback-md {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Initial-letter avatar fallback (small 22px — A8 presence chip). */
.live-avatar-fallback-sm {
    width: 22px;
    height: 22px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* 8x8 pulse dot in the sticky LIVE breaking banner (P3). */
.live-banner-pulse-dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    background: currentColor;
    border-radius: 50%;
    animation: liveBlogPulseDot 1.4s ease-in-out infinite;
}

/* 7x7 pulse dot for /live hub status chips (P5) + desk.php status
   badge (A5) + desk_mobile (A6). */
.live-status-pulse-dot {
    width: 7px;
    height: 7px;
    display: inline-block;
    background: currentColor;
    border-radius: 50%;
    vertical-align: middle;
    animation: liveBlogPulseDot 1.4s ease-in-out infinite;
}

/* Sticky top z-index for the LIVE breaking banner — below site
   nav (~1040) but above all article content. */
.live-banner-z { z-index: 1030; }

/* Sticky toolbar z-index — bulk-action bars on admin manage.php (A4)
   + moderation bulk bar (A7) + bottom bar on desk_mobile.php (A6). */
.live-bulk-bar-z { z-index: 1020; }
.live-bulk-bar-z-with-top {
    top: 12px;
    z-index: 1020;
}

/* JS-dynamic live-update card style — replaces inline
   "border-top: 3px solid #ffc107" on cards built by
   LiveBlog.buildUpdateHtml. */
.live-update-card-js-amber-top {
    border-top: 3px solid #ffc107 !important;
}

/* JS-dynamic media-timestamp badge — replaces inline
   "background-color:#ffc107;font-size:0.9rem" on the timestamp pill. */
.live-update-timestamp-pill {
    background-color: #ffc107;
    font-size: 0.9rem;
}

/* JS-dynamic update content typography. */
.live-update-content-body {
    font-size: 1.05rem;
    line-height: 1.6;
}

/* =====================================================================
   §4 — Shared keyframes (consolidated from inline <style> blocks)
   ===================================================================== */

@keyframes liveBlogPulseDot {
    0%   { opacity: 1;    transform: scale(1); }
    50%  { opacity: 0.35; transform: scale(1.35); }
    100% { opacity: 1;    transform: scale(1); }
}

/* Backwards-compat alias for the inline `livePulseDot` name used by
   /live hub (P5), desk.php (A5), and desk_mobile.php (A6). Keeping the
   alias means we can retire those inline <style> blocks later without
   breaking the cascade in the meantime. */
@keyframes livePulseDot {
    0%   { opacity: 1;    transform: scale(1); }
    50%  { opacity: 0.35; transform: scale(1.35); }
    100% { opacity: 1;    transform: scale(1); }
}

/* =====================================================================
   §5 — Reduced-motion preference
   ===================================================================== */

@media (prefers-reduced-motion: reduce) {
    .live-index-pulse-dot,
    .live-breaking-banner .live-pulse-dot,
    .live-filter-chip,
    .live-moderation-filter-chip,
    .live-presence-chip,
    .live-update-card-highlight,
    .live-update-permalink-btn,
    .live-hero-share-row .btn {
        animation: none !important;
        transition: none !important;
    }
}
