/* Articles public surface.
   RTL-safe (CSS logical properties), mobile-responsive,
   accessibility-focused (focus-visible, contrast).
   Loaded from Views/Shared/Site/_Layout.cshtml.
*/


/* ── 1. Article listing grid (Index + RelatedArticles) ── */

/* Cards stack on mobile, 2-up on small tablet, 3-up on desktop. */
.list-cards-grid,
.article-list-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--sp-6);
}
@media (min-width: 576px) {
    .list-cards-grid,
    .article-list-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 992px) {
    .list-cards-grid,
    .article-list-grid { grid-template-columns: repeat(3, 1fr); }
}


/* ── 2. List card cover-image aspect ratio ── */

.list-card__img-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}
.list-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}


/* ── 3. Article detail page ── */

.article-detail {
    /* Logical width — works in both LTR and RTL. */
    margin-inline-start: auto;
    margin-inline-end: auto;
}
.article-detail__container {
    max-width: 720px;
    margin-inline-start: auto;
    margin-inline-end: auto;
    padding-inline-start: var(--sp-4);
    padding-inline-end: var(--sp-4);
}
.article-detail__cover {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    margin: 0 0 var(--sp-8);
}
.article-detail__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Hero with overlaid title/subtitle ──
   Full-bleed cover image, darkened with a gradient so the headline reads
   cleanly on top of any photo. Heading sits near the bottom (newspaper-style)
   on desktop and stays centered on small screens. */
.article-detail__hero {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 320px;
    max-height: 70vh;
    overflow: hidden;
    margin: 0 0 var(--sp-8);
    isolation: isolate;
}
.article-detail__hero-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    z-index: 1;
}
/* Two-stop gradient: subtle at the top, heavy at the bottom where the text
   lives. The base 35% rgba layer guarantees AA contrast even on bright covers. */
.article-detail__hero-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    background:
        linear-gradient(180deg,
            rgba(10, 20, 45, 0.35) 0%,
            rgba(10, 20, 45, 0.55) 55%,
            rgba(10, 20, 45, 0.82) 100%);
    pointer-events: none;
}
.article-detail__hero-content {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding-block: var(--sp-12) var(--sp-10);
    color: var(--text-inv);
}
.article-detail__hero-content .container {
    max-width: 960px;
}

.article-detail__title {
    font-size: var(--text-2xl);
    line-height: var(--lh-tight);
    color: var(--text-1);
    margin: 0 0 var(--sp-3);
}
.article-detail__subtitle {
    font-size: var(--text-md);
    line-height: var(--lh-snug);
    color: var(--text-2);
    margin: 0 0 var(--sp-4);
}

/* Variants used when the title/subtitle sit on top of the hero image instead
   of in the body container — light type, drop shadow for legibility. */
.article-detail__title--on-image {
    color: var(--text-inv);
    font-size: clamp(1.75rem, 4.2vw, 3rem);
    font-weight: var(--fw-black);
    letter-spacing: -0.01em;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
    margin: 0 0 var(--sp-3);
    max-width: 24ch;
}
.article-detail__subtitle--on-image {
    color: rgba(255, 255, 255, 0.92);
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
    margin: 0;
    max-width: 60ch;
}

@media (max-width: 767.98px) {
    .article-detail__hero {
        aspect-ratio: 4 / 5;
        min-height: 360px;
        max-height: 75vh;
    }
    .article-detail__hero-content {
        padding-block: var(--sp-8) var(--sp-6);
    }
}

.article-detail__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    font-size: var(--text-sm);
    color: var(--text-3);   /* WCAG AA ≥ 4.5:1 on white */
    margin-bottom: var(--sp-6);
}
.article-detail__meta-item i {
    margin-inline-end: var(--sp-1);
}

.article-detail__body {
    font-size: var(--text-base);
    line-height: var(--lh-relaxed);
    color: var(--text-2);
}
.article-detail__body h2,
.article-detail__body h3 {
    color: var(--text-1);
    margin-block-start: var(--sp-10);
    margin-block-end: var(--sp-3);
}
.article-detail__body p { margin: 0 0 var(--sp-5); }

/* Blockquote — flipped indent direction on RTL via logical border. */
.article-detail__body blockquote {
    margin-inline-start: 0;
    margin-inline-end: 0;
    padding-inline-start: var(--sp-5);
    padding-inline-end: var(--sp-4);
    border-inline-start: 4px solid var(--blue);
    font-style: italic;
    color: var(--text-2);
    background: var(--bg-alt);
}

/* Figure / image caption — indent + alignment respect direction. */
.article-detail__body figure {
    margin: var(--sp-8) 0;
}
.article-detail__body figcaption {
    font-size: var(--text-sm);
    color: var(--text-3);
    padding-inline-start: var(--sp-2);
    margin-block-start: var(--sp-2);
    text-align: start;
}

.article-detail__body img {
    max-width: 100%;
    height: auto;
}


/* ── 4. Author byline ── */

.author-byline {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-4);
    padding: var(--sp-5);
    background: var(--bg-alt);
    border-radius: var(--r-md);
    margin-block: var(--sp-10);
}
.author-byline__avatar {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-muted);
    display: grid;
    place-items: center;
    color: var(--text-3);
}
.author-byline__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.author-byline__name {
    /* Author byline name stays h3-level: detail page has one h1 (title),
       sanitizer body can produce h2s, byline never outranks them. */
    font-size: var(--text-md);
    margin: 0 0 var(--sp-1);
    color: var(--text-1);
}
.author-byline__title {
    font-size: var(--text-sm);
    color: var(--text-3);
    margin: 0 0 var(--sp-2);
}
.author-byline__brief {
    font-size: var(--text-base);
    color: var(--text-2);
    margin: 0 0 var(--sp-3);
}
.author-byline__social {
    display: flex;
    gap: var(--sp-3);
    list-style: none;
    padding: 0;
    margin: 0;
}


/* ── 5. Topic chips ── */

.article-detail__topics,
.article-filters__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-block: var(--sp-3) var(--sp-6);
}

/* On mobile the filter row becomes horizontally scrollable rather than
   wrapping, so a long topic list stays accessible without dominating the
   viewport. */
@media (max-width: 575.98px) {
    .article-filters__chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-block-end: var(--sp-2);
        scrollbar-width: thin;
    }
    .article-filters__chips .article-chip {
        flex: 0 0 auto;
    }
}

.article-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: var(--r-pill);
    background: var(--bg-muted);
    color: var(--text-1);          /* navy ink on pale = AA ≥ 4.5:1 */
    font-size: var(--text-sm);
    font-weight: var(--fw-medium);
    text-decoration: none;
    border: 1px solid transparent;
    transition: background-color var(--t-fast), color var(--t-fast);
}
.article-chip:hover {
    background: var(--blue-pale);
    color: var(--navy);
}
.article-chip.is-active,
.article-chip[aria-current="page"] {
    background: var(--navy);
    color: var(--text-inv);        /* white on navy = AAA */
    border-color: var(--navy);
}


/* ── 6. CTA bar (Contact us prompt) ── */

.article-detail__cta-bar {
    background: var(--bg-alt);
    border-block-start: 1px solid var(--border);
    padding-block: var(--sp-8);
    margin-block-start: var(--sp-12);
}
.article-detail__cta-bar .container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-3);
    text-align: center;
}
.article-detail__cta-text {
    color: var(--text-2);
    margin: 0;
}
.article-detail__cta-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 12px 24px;
    background: var(--navy);
    color: var(--text-inv);
    border-radius: var(--r-pill);
    text-decoration: none;
    font-weight: var(--fw-semi);
}
.article-detail__cta-btn:hover { background: var(--blue); color: var(--text-inv); }

/* On mobile, pin the CTA to the bottom of the viewport so it stays in reach
   on long detail pages. */
@media (max-width: 767.98px) {
    .article-detail__cta-bar {
        position: fixed;
        bottom: 0;
        inset-inline: 0;
        margin: 0;
        padding-block: var(--sp-3);
        box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
        z-index: var(--z-nav);
        background: var(--bg-page);
    }
    .article-detail__cta-bar .container {
        flex-direction: row;
        justify-content: center;
    }
    .article-detail__cta-text { display: none; }
    /* Keep enough trailing space inside the article so the fixed bar does
       not cover the last paragraph or related-articles strip. */
    body { padding-block-end: 80px; }
}


/* ── 7. Focus-visible — visible 2-px outline for every interactive element ── */

.article-chip:focus-visible,
.article-detail__cta-btn:focus-visible,
.list-card a:focus-visible,
.article-hero__card:focus-visible,
.article-filters__search input:focus-visible,
.author-byline a:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}


/* ── 8. Reduced-motion: respect prefers-reduced-motion ── */

@media (prefers-reduced-motion: reduce) {
    .article-chip,
    .article-detail__cta-btn,
    .list-card__img,
    .list-card { transition: none !important; }
}


/* ═══════════════════════════════════════════════════
   9. LISTING-PAGE POLISH  (Index.cshtml)
   Overrides the legacy `.article-hero` block from
   css/style.css and adds the missing rules for the new
   featured-card layout, filter bar, pager, and related
   articles strip so the page no longer breaks below the
   fold.
   ═══════════════════════════════════════════════════ */

/* 9.1 — List-page header: brighter, modern gradient + spacing. */
.list-page-header {
    padding-block: var(--sp-16) var(--sp-10);
    background:
        radial-gradient(circle at 20% 0%, rgba(72,151,255,0.18) 0%, transparent 55%),
        radial-gradient(circle at 90% 100%, rgba(150,234,232,0.22) 0%, transparent 60%),
        linear-gradient(135deg, var(--bg-alt) 0%, var(--color-surface-2) 100%);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
}
.list-page-header__title {
    font-size: clamp(1.85rem, 3.6vw, var(--text-3xl));
    font-weight: var(--fw-black);
    line-height: var(--lh-tight);
    letter-spacing: -0.01em;
    color: var(--navy);
    margin: 0 0 var(--sp-3);
}
.list-page-header__sub {
    font-size: var(--text-md);
    color: var(--text-3);
    max-width: 640px;
    line-height: var(--lh-snug);
    margin: 0;
}

/* 9.2 — Featured hero card: image left, content right, modern card. */
.article-hero {
    /* Override the legacy `.article-hero {min-height:420px;display:flex;...}`
       block from css/style.css. The new listing hero is a card, not a
       full-bleed banner. */
    position: relative;
    min-height: 0;
    display: block;
    overflow: visible;
    background: transparent;
    padding-block: var(--sp-10) var(--sp-6);
}
.article-hero__card {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 0;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: transform var(--t-base), box-shadow var(--t-base);
}
.article-hero__card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
    text-decoration: none;
    color: inherit;
}
.article-hero__media {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--bg-alt);
}
.article-hero__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--t-slow);
}
.article-hero__card:hover .article-hero__media img { transform: scale(1.04); }
.article-hero__body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--sp-10) var(--sp-12);
    gap: var(--sp-3);
}
.article-hero__eyebrow {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    padding: 4px 12px;
    background: var(--grad-brand);
    color: var(--text-inv);
    font-size: var(--text-xs);
    font-weight: var(--fw-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-radius: var(--r-pill);
    margin-bottom: var(--sp-2);
}
.article-hero__title {
    font-size: clamp(1.4rem, 2.4vw, 1.85rem);
    font-weight: var(--fw-black);
    line-height: var(--lh-tight);
    color: var(--text-1);
    margin: 0;
    letter-spacing: -0.01em;
}
.article-hero__excerpt {
    font-size: var(--text-md);
    color: var(--text-3);
    line-height: var(--lh-snug);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.article-hero__cta {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    margin-top: var(--sp-3);
    color: var(--blue);
    font-weight: var(--fw-semi);
    font-size: var(--text-base);
    transition: gap var(--t-fast);
}
.article-hero__card:hover .article-hero__cta { gap: var(--sp-4); }

@media (max-width: 767.98px) {
    .article-hero__card { grid-template-columns: 1fr; }
    .article-hero__body { padding: var(--sp-6) var(--sp-5) var(--sp-8); }
}

/* 9.3 — Filter bar: chips + search pill share a single row. */
.article-filters {
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(255,255,255,0.92);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-block-end: 1px solid var(--color-border);
    padding-block: var(--sp-3);
    margin-block-start: var(--sp-2);
}
.article-filters .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
}
.article-filters__chips {
    margin-block: 0;
    flex: 1 1 auto;
    min-width: 0;
}

/* Single self-contained pill: search icon inside the input, no
   external label and no separate submit button. Height matches the
   category chips above. */
.article-filters__search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    width: clamp(220px, 32vw, 360px);
}
.article-filters__search-icon {
    position: absolute;
    inset-inline-start: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--color-text-muted);
    pointer-events: none;
}
.article-filters__search input[type="search"] {
    flex: 1 1 auto;
    width: 100%;
    padding-block: 10px;
    padding-inline-start: 44px;
    padding-inline-end: 16px;
    line-height: 1.2;
    border: 1px solid var(--color-border);
    border-radius: var(--r-pill);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: var(--text-sm);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.article-filters__search input[type="search"]:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--brand-100);
}
.article-filters__search input[type="search"]::placeholder { color: var(--color-text-subtle); }
.article-filters__search input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

@media (max-width: 767.98px) {
    .article-filters { position: static; backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg-page); }
    .article-filters .container { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
    .article-filters__search { width: 100%; }
}

/* 9.4 — List cards: lift the legacy card to feel modern. */
.list-card {
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}
.list-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(0,71,171,0.18);
}
.list-card__img-wrap {
    /* Override components.css's fixed `height: 200px` so the cover
       is responsive on every breakpoint. */
    height: auto;
    aspect-ratio: 16 / 9;
}
.list-card__body {
    padding: var(--sp-5) var(--sp-6) var(--sp-6);
    gap: var(--sp-2);
}
.list-card__title a {
    color: inherit;
    text-decoration: none;
    transition: color var(--t-fast);
}
.list-card:hover .list-card__title a { color: var(--blue); }
.list-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-xs);
    color: var(--text-3);
    margin-block: var(--sp-2) var(--sp-3);
}
.list-card__dot { color: var(--text-4); }
.list-card__cta {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    margin-top: auto;
    padding-top: var(--sp-3);
    border-top: 1px solid var(--border);
    color: var(--navy);
    font-weight: var(--fw-semi);
    font-size: var(--text-sm);
    text-decoration: none;
    transition: gap var(--t-fast), color var(--t-fast);
}
.list-card:hover .list-card__cta { gap: var(--sp-4); color: var(--blue); }

/* 9.5 — Pagination strip. */
.article-pager {
    padding-block: var(--sp-8) var(--sp-16);
    display: flex;
    justify-content: center;
}
.article-pager__list {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    list-style: none;
    padding: 0;
    margin: 0;
}
.article-pager__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding-inline: var(--sp-3);
    border: 1.5px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--bg-page);
    color: var(--text-2);
    font-size: var(--text-sm);
    font-weight: var(--fw-semi);
    text-decoration: none;
    transition: background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.article-pager__link:hover {
    background: var(--bg-muted);
    border-color: var(--blue-light);
    color: var(--navy);
    transform: translateY(-1px);
}
.article-pager__link.is-active,
.article-pager__link[aria-current="page"] {
    background: var(--navy);
    border-color: var(--navy);
    color: var(--text-inv);
}

/* 9.6 — Related articles strip on detail page. */
.related-articles {
    padding-block: var(--sp-16) var(--sp-12);
    background: var(--bg-alt);
}
.related-articles__title {
    font-size: var(--text-xl);
    font-weight: var(--fw-bold);
    color: var(--navy);
    margin: 0 0 var(--sp-8);
    position: relative;
    padding-inline-start: var(--sp-4);
}
.related-articles__title::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 1.1em;
    background: var(--grad-brand);
    border-radius: var(--r-pill);
}

/* 9.7 — Preview banner. */
.preview-banner {
    background: var(--accent-gold);
    color: var(--navy);
    font-weight: var(--fw-semi);
    padding-block: var(--sp-3);
    text-align: center;
}
.preview-banner i { margin-inline-end: var(--sp-2); }

/* 9.8 — Reduced-motion: keep new transitions polite. */
@media (prefers-reduced-motion: reduce) {
    .article-hero__card,
    .article-hero__media img,
    .article-hero__cta,
    .article-pager__link,
    .list-card,
    .list-card__cta { transition: none !important; }
    .article-hero__card:hover { transform: none; }
    .list-card:hover { transform: none; }
}
