/* ============================================================
   news.css — News & Updates page styles
   Covers: listing mode (hero, tag bar, card grid, load more)
           and detail mode (featured image, article body, footer)
   ============================================================ */

/* ── Page Hero ─────────────────────────────────────────────── */

.news-page-hero {
    background-color: var(--dark-bg);
    margin-top: 70px; /* clear fixed navbar */
    padding: 72px 24px 56px;
    text-align: center;
    border-bottom: 1px solid #2a2a2a;
}

.news-page-hero-inner {
    max-width: 680px;
    margin: 0 auto;
}

.news-page-hero-inner h1 {
    font-family: 'Aboreto', serif;
    font-size: 3.6rem;
    color: var(--accent-gold);
    margin: 0 0 20px;
    letter-spacing: 0.04em;
    line-height: 1.1;
}

.news-page-hero-inner p {
    font-family: 'Lato', sans-serif;
    font-size: 1.15rem;
    color: var(--text-gray);
    margin: 18px 0 0;
    line-height: 1.6;
}

/* Gold ornament divider in hero */
.news-hero-ornament {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 0 auto;
    width: 240px;
}

.news-hero-line {
    flex: 1;
    height: 1px;
    background-color: var(--accent-gold);
    opacity: 0.7;
}

.news-hero-diamond {
    width: 8px;
    height: 8px;
    background-color: var(--accent-gold);
    transform: rotate(45deg);
    margin: 0 12px;
    flex-shrink: 0;
}

/* ── Admin bar (listing mode, admin-only) ─────────────────── */

.news-admin-bar {
    background-color: #111;
    border-bottom: 1px solid var(--accent-gold);
    padding: 10px 0;
}

.news-admin-bar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: flex-end;
}

.news-admin-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-gold);
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid var(--accent-gold);
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
    min-height: 44px;
}

.news-admin-link:hover,
.news-admin-link:focus-visible {
    background-color: var(--accent-gold);
    color: #000;
    outline: none;
}

/* ── Screen-reader-only live status region ────────────────── */
/* Visually hidden but exposed to assistive tech — news.js announces listing
   loading progress / result counts / errors through #newsStatus (role=status). */

.news-status-vh {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ── Listing layout container ─────────────────────────────── */

#newsListingView {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

/* ── Tag filter bar ───────────────────────────────────────── */

.news-tag-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 32px;
    /* Reserve one pill row (pills are min-height 44px) from first paint so the
       skeleton grid doesn't shift down when news.js injects the pills (tech debt
       3.181). If tags ever wrap to a second row, only that extra row shifts. */
    min-height: 44px;
}

.news-tag-pill {
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-gray);
    background: transparent;
    border: 1px solid #444;
    border-radius: 100px;
    padding: 8px 18px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.news-tag-pill:hover,
.news-tag-pill:focus-visible {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    outline: none;
}

.news-tag-pill--active {
    border-color: var(--accent-gold);
    color: #000;
    background-color: var(--accent-gold);
}

.news-tag-pill--active:hover,
.news-tag-pill--active:focus-visible {
    background-color: var(--accent-gold-hover);
    border-color: var(--accent-gold-hover);
    color: #000;
}

/* ── Post card grid ───────────────────────────────────────── */

.news-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    margin-bottom: 40px;
}

@media (min-width: 640px) {
    .news-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .news-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 32px;
    }
}

/* ── Post card ────────────────────────────────────────────── */

.news-card {
    display: flex;
    flex-direction: column;
    background-color: var(--dark-gray);
    border: 1px solid #2e2e2e;
    border-radius: 6px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, transform 0.2s;
}

.news-card:hover,
.news-card:focus-visible {
    border-color: var(--accent-gold);
    transform: translateY(-2px);
    outline: none;
}

.news-card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    background-color: #111;
}

.news-card-img-placeholder {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #111;
    color: #3a3a3a;
    font-size: 3rem;
}

.news-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 20px 22px 22px;
    gap: 8px;
}

.news-card-meta {
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    color: #888;
    /* Exactly one line, always — a long author name ellipsizes instead of
       wrapping, so the meta row can never exceed its reserved height. */
    height: 1.7em;
    line-height: 1.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.news-card-author {
    color: #888;
}

.news-card-title {
    font-family: 'Lato', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-white);
    margin: 4px 0 0;
    line-height: 1.35;
    /* Clamp to 2 lines AND always reserve 2 lines so card height is deterministic.
       Deterministic card height is what lets a fixed-size skeleton reserve the
       exact same space → zero-CLS swap on fetch resolve (tech debt 3.181). */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.7em; /* 2 lines × 1.35 line-height */
    max-height: 2.7em; /* belt-and-braces: fixed height even if line-clamp is unsupported */
}

.news-card-excerpt {
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    color: var(--text-gray);
    line-height: 1.6;
    margin: 0;
    /* Clamp to 3 lines and always reserve 3 lines (even when the post has no
       excerpt) — see the note on .news-card-title above. */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 4.8em; /* 3 lines × 1.6 line-height */
    max-height: 4.8em; /* belt-and-braces: fixed height even if line-clamp is unsupported */
}

.news-card-tags {
    display: flex;
    /* Exactly one pill row, always — news.js caps the pill count (+N indicator
       for the rest) and any residual width overflow from very long tag text is
       clipped, so the tag row can never wrap taller than its reserved height.
       overflow:hidden clips visually only; clipped pills stay readable to
       assistive tech, and the article page shows the full tag list. */
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    height: 1.8rem;
    overflow: hidden;
}

.news-card-tag {
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 100px;
    padding: 2px 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.news-card-readmore {
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    color: var(--accent-gold);
    font-weight: 600;
    margin-top: auto;
    padding-top: 10px;
    /* Exactly one line + its top padding so the real "Read more →" row and the
       skeleton readmore row clamp to the same height (tech debt 3.181). */
    height: calc(1.7em + 10px);
    line-height: 1.7;
    white-space: nowrap;
    overflow: hidden;
}

/* ── Skeleton cards (loading placeholders) ─────────────────────
   A skeleton reuses .news-card and the body sub-element classes so its reserved
   height matches a real card exactly at every breakpoint — the swap on fetch
   resolve produces zero layout shift (tech debt 3.181). Skeletons carry
   aria-hidden; the grid's aria-busy is what announces loading to assistive tech. */

.news-card--skeleton {
    pointer-events: none;
    cursor: default;
}

.news-card--skeleton:hover,
.news-card--skeleton:focus-visible {
    border-color: #2e2e2e;
    transform: none;
}

/* Skeleton image block — matches the 200px real-card image height. */
.sk-img {
    height: 200px;
}

/* Neutralize the title/excerpt line-clamp so shimmer bars stack normally within
   the reserved height instead of being collapsed by -webkit-box. */
.news-card--skeleton .news-card-title,
.news-card--skeleton .news-card-excerpt {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

/* Center the shimmer bars inside the fixed-height meta/readmore rows (the real
   rows center their text via line-height; blocks need flex to match). */
.news-card--skeleton .news-card-meta,
.news-card--skeleton .news-card-readmore {
    display: flex;
    align-items: center;
}

.sk-bar,
.sk-pill,
.sk-img {
    background: linear-gradient(90deg, #1d1d1d 25%, #262626 37%, #1d1d1d 63%);
    background-size: 400% 100%;
    animation: news-sk-shimmer 1.4s ease infinite;
    border-radius: 4px;
}

.sk-bar {
    display: block;
    width: 100%;
    height: 0.8em;
}

.sk-bar--60 { width: 60%; }
.sk-bar--40 { width: 40%; }
.sk-bar--meta { width: 45%; height: 0.7em; }
.sk-bar--readmore { width: 32%; height: 0.9em; }

.sk-pill {
    width: 58px;
    height: 1.3rem;
    border-radius: 100px;
}

@keyframes news-sk-shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: 0 0; }
}

@media (prefers-reduced-motion: reduce) {
    .sk-bar,
    .sk-pill,
    .sk-img {
        animation: none;
    }
}

/* ── Empty state ──────────────────────────────────────────── */

.news-empty {
    font-family: 'Lato', sans-serif;
    font-size: 1.05rem;
    color: #888;
    text-align: center;
    padding: 60px 24px;
}

/* ── Load more ────────────────────────────────────────────── */

.news-load-more-wrap {
    display: flex;
    justify-content: center;
    padding-top: 8px;
}

.news-load-more-btn {
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-gold);
    background: transparent;
    border: 1px solid var(--accent-gold);
    border-radius: 4px;
    padding: 12px 36px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    min-height: 44px;
    min-width: 180px;
}

.news-load-more-btn:hover,
.news-load-more-btn:focus-visible {
    background-color: var(--accent-gold);
    color: #000;
    outline: none;
}

.news-load-more-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.news-load-more-error {
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    color: #e07a7a;
    text-align: center;
    margin: 14px 0 0;
}

/* ── Detail view container ────────────────────────────────── */

#newsDetailView {
    /* no max-width — hero image is full bleed; article is constrained inside */
    min-height: 80vh;
}

/* ── Featured image hero (detail mode) ───────────────────── */

.news-detail-hero {
    width: 100%;
    max-height: 480px;
    overflow: hidden;
    margin-top: 70px; /* clear fixed navbar */
    background-color: #0a0a0a;
}

.news-detail-hero-img {
    width: 100%;
    height: 480px;
    object-fit: cover;
    display: block;
}

/* ── Article layout ───────────────────────────────────────── */

.news-article {
    max-width: 760px;
    margin: 0 auto;
    padding: 48px 24px 72px;
}

#newsDetailHero[hidden] ~ .news-article {
    padding-top: 80px; /* extra top padding when no hero image (clears navbar) */
    margin-top: 0;
}

/* ── Article header ───────────────────────────────────────── */

.news-article-header {
    margin-bottom: 36px;
    padding-bottom: 28px;
    border-bottom: 1px solid #2a2a2a;
}

/* Admin edit shortcut in article header */
.news-article-admin-bar {
    margin-bottom: 16px;
}

.news-admin-edit-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-gold);
    text-decoration: none;
    padding: 7px 14px;
    border: 1px solid var(--accent-gold);
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
    min-height: 44px;
}

.news-admin-edit-link:hover,
.news-admin-edit-link:focus-visible {
    background-color: var(--accent-gold);
    color: #000;
    outline: none;
}

.news-article-title {
    font-family: 'Aboreto', serif;
    font-size: 2.4rem;
    color: var(--text-white);
    line-height: 1.2;
    margin: 0 0 16px;
    word-break: break-word;
}

.news-article-byline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    color: #888;
    margin-bottom: 14px;
}

.news-byline-author {
    color: var(--text-gray);
    font-weight: 600;
}

.news-byline-date {
    color: #888;
}

.news-article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.news-article-tag {
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 100px;
    padding: 4px 14px;
    text-decoration: none;
    transition: background-color 0.15s;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.news-article-tag:hover,
.news-article-tag:focus-visible {
    background-color: rgba(212, 175, 55, 0.2);
    outline: none;
}

/* ── Article body (Markdown typography) ───────────────────── */

/* max-width from .governance-document (800px) must not fight the article column */
.news-article .governance-document {
    max-width: none;
}

.news-article-body {
    font-family: 'Lato', sans-serif;
    /* font-size is inherited from .governance-document (1.125rem) so that
       GovDocViewer.applyFontScale() scales all article text correctly */
    color: var(--text-gray);
    line-height: 1.8;
}

.news-article-body h1,
.news-article-body h2,
.news-article-body h3,
.news-article-body h4,
.news-article-body h5,
.news-article-body h6 {
    font-family: 'Lato', sans-serif;
    color: var(--text-white);
    margin: 1.8em 0 0.6em;
    line-height: 1.3;
    font-weight: 700;
}

/* em units so headings scale with GovDocViewer font-size changes */
.news-article-body h2 { font-size: 1.38em; }
.news-article-body h3 { font-size: 1.16em; }
.news-article-body h4 { font-size: 0.98em; }
.news-article-body h5,
.news-article-body h6 { font-size: 0.89em; }

.news-article-body p {
    margin: 0 0 1.3em;
}

.news-article-body a {
    color: var(--accent-gold);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.news-article-body a:hover,
.news-article-body a:focus-visible {
    color: var(--accent-gold-hover);
    outline: none;
}

.news-article-body ul,
.news-article-body ol {
    margin: 0 0 1.3em 1.6em;
    padding: 0;
}

.news-article-body li {
    margin-bottom: 0.4em;
}

.news-article-body blockquote {
    margin: 1.5em 0;
    padding: 16px 20px;
    border-left: 4px solid var(--accent-gold);
    background-color: rgba(212, 175, 55, 0.05);
    color: var(--text-gray);
    font-style: italic;
}

.news-article-body blockquote p {
    margin: 0;
}

.news-article-body code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    background-color: #1e1e1e;
    border: 1px solid #333;
    border-radius: 3px;
    padding: 2px 6px;
    color: #e0e0e0;
}

.news-article-body pre {
    background-color: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 18px 20px;
    overflow-x: auto;
    margin-bottom: 1.3em;
}

.news-article-body pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.95em;
}

.news-article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
    margin: 1.5em auto;
}

.news-article-body hr {
    border: none;
    border-top: 1px solid #2a2a2a;
    margin: 2em 0;
}

.news-article-body strong {
    color: var(--text-white);
    font-weight: 700;
}

.news-article-body em {
    font-style: italic;
}

.news-article-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.3em;
    font-size: 0.98rem;
}

.news-article-body th,
.news-article-body td {
    border: 1px solid #333;
    padding: 10px 14px;
    text-align: left;
}

.news-article-body th {
    background-color: #1a1a1a;
    color: var(--text-white);
    font-weight: 700;
}

/* Detail spinner (inside article body while fetching) */
.news-detail-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--accent-gold);
    font-size: 2rem;
}

/* ── Article footer ───────────────────────────────────────── */

.news-article-footer {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid #2a2a2a;
}

.news-article-updated {
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    color: #666;
    margin: 0 0 24px;
    font-style: italic;
}

/* Archive link callout box */
.news-archive-callout {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background-color: rgba(212, 175, 55, 0.06);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-left: 4px solid var(--accent-gold);
    border-radius: 0 6px 6px 0;
    padding: 18px 20px;
    margin-top: 8px;
}

.news-archive-callout > .fa-archive,
.news-archive-callout > [class^="fa-"] {
    color: var(--accent-gold);
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.news-archive-callout strong {
    display: block;
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    color: var(--text-white);
    font-weight: 700;
    margin-bottom: 6px;
}

.news-archive-callout p {
    font-family: 'Lato', sans-serif;
    font-size: 0.98rem;
    color: var(--text-gray);
    margin: 0;
    line-height: 1.5;
}

.news-archive-link {
    color: var(--accent-gold);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
}

.news-archive-link:hover,
.news-archive-link:focus-visible {
    color: var(--accent-gold-hover);
    outline: none;
}

/* ── Detail error / not-found state ──────────────────────── */

.news-detail-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 24px;
    text-align: center;
    min-height: 300px;
    margin-top: 70px; /* clear navbar */
}

.news-detail-error-icon {
    font-size: 3rem;
    color: #444;
}

.news-detail-error p {
    font-family: 'Lato', sans-serif;
    font-size: 1.1rem;
    color: #888;
    max-width: 420px;
}

.news-back-link {
    font-family: 'Lato', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-gold);
    text-decoration: none;
    padding: 10px 24px;
    border: 1px solid var(--accent-gold);
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.news-back-link:hover,
.news-back-link:focus-visible {
    background-color: var(--accent-gold);
    color: #000;
    outline: none;
}

/* ── Responsive adjustments ───────────────────────────────── */

@media (max-width: 767px) {
    .news-page-hero {
        padding: 52px 20px 44px;
    }

    .news-page-hero-inner h1 {
        font-size: 2.4rem;
    }

    .news-article-title {
        font-size: 1.8rem;
    }

    .news-article {
        padding: 36px 20px 56px;
    }

    .news-detail-hero {
        max-height: 260px;
    }

    .news-detail-hero-img {
        height: 260px;
    }

    .news-archive-callout {
        flex-direction: column;
        gap: 10px;
    }

    #newsListingView {
        padding: 28px 16px 48px;
    }
}

@media (max-width: 480px) {
    .news-page-hero-inner h1 {
        font-size: 2rem;
    }

    .news-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 1280px) {
    #newsListingView {
        padding: 48px 40px 72px;
    }

    .news-article {
        padding: 56px 0 80px;
    }
}

/* Hide the floating accessibility cluster when the page footer scrolls into view.
   Prevents the cluster from overlapping the footer when reading to the bottom of a post.
   is-footer-visible is added/removed by the IntersectionObserver in news.js. */
.dash-gov-float-ctrl.is-footer-visible {
    opacity: 0;
    pointer-events: none;
}
