/**
 * assets/css/news.css
 *
 * Styles for all news-related components:
 *   - .news-card           — atomic card (homepage strip + archive)
 *   - .news-strip          — homepage Jaunumi section (desktop grid + Splide mobile)
 *   - .news-grid           — all-news archive 3-col grid
 *   - .news-pagination     — archive pagination (prev/next + numbers)
 *   - .single-article      — single post template
 *   - .archive-news        — archive page wrapper
 *   - .back-link           — "← Atpakaļ / Visas ziņas" link
 *   - .share-btn           — social share row
 *
 * DESIGN TOKENS (from Figma / theme.json)
 * ----------------------------------------
 * Colours referenced here use CSS custom properties defined in theme.json.
 * See the full token list in assets/css/tokens.css (generated from theme.json).
 *
 * FIGMA MEASUREMENTS
 * ------------------
 * Desktop card width:  296px (Figma) → fluid in CSS grid
 * Card image ratio:    296×191px ≈ 16:10.3 (use padding-top: 64.5%)
 * Archive card width:  334px (Figma) → fluid in 3-col grid
 * Content column:      max-width 1172px (138px margins × 2 on 1440px canvas)
 *
 * BREAKPOINTS
 * -----------
 * --bp-mobile:  < 768px
 * --bp-tablet:  768px – 1023px
 * --bp-desktop: ≥ 1024px  (matches JS MOBILE_BREAKPOINT in news-strip.js)
 *
 * @package AICenterwp
 * @since   1.0.0
 */

/* ==========================================================================
   SHARED — CONTAINER
   ========================================================================== */

.container {
    width: 100%;
    max-width: 1172px;
    margin-inline: auto;
    padding-inline: 24px;
}

@media ( min-width: 1440px ) {
    .container {
        padding-inline: 0;
    }
}

/* ==========================================================================
   BACK-LINK  (← Atpakaļ / ← Visas ziņas)
   ========================================================================== */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--color--accent-primary-strong, #185fa5);  /* darker blue back link */
    text-decoration: none;
    padding-block: 4px;
    transition: opacity 0.15s ease;
}

.back-link:hover,
.back-link:focus-visible {
    opacity: 0.7;
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Arrow — real Figma left "Button icon" SVG, recoloured via mask. */
.back-link__arrow {
    display: inline-block;
    width: 12px;
    height: 14px;
    background-color: currentColor;
    -webkit-mask: url('../img/icon-arrow-left.svg') no-repeat center / contain;
            mask: url('../img/icon-arrow-left.svg') no-repeat center / contain;
}

/* ==========================================================================
   NEWS CARD  (.news-card)
   Figma: "Jaunums" frame — used in strip + archive
   ========================================================================== */

.news-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0; /* flex items default to min-width:auto (= content's min-content
                     size); without this, an unbreakable run of text (e.g. a title
                     pasted with non-breaking spaces) can stretch this card — and
                     the shared grid/carousel track every sibling card sits in —
                     wider than intended instead of wrapping. */
}

/* Headline */
.news-card__title {
    overflow-wrap: anywhere; /* force a wrap even inside an "unbreakable" run
                                 (e.g. words joined by pasted &nbsp; characters)
                                 rather than let the title overflow its card */
    font-size: 23px;            /* Figma 113:96 */
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 16px;
    color: var(--color--card-title, #ffffff);  /* WHITE on the lavender page bg */
}

.news-card__title-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
}

.news-card__title-link:hover,
.news-card__title-link:focus-visible {
    color: var(--color--card-title, #ffffff);
    opacity: 0.85;
    outline: none;
}

.news-card__title:has(.news-card__title-link:focus-visible) {
    outline: 2px solid var(--color--card-title, #ffffff);
    outline-offset: 2px;
}

/* Image — aspect-ratio box matching Figma "Frame 31" proportions */
.news-card__image-link {
    display: block;
    margin-bottom: 24px;
    border-radius: 15px;            /* Figma 113:97 */
    overflow: hidden;
}

.news-card__image {
    display: block;
    width: 100%;
    aspect-ratio: 334 / 191;        /* Figma card image 334×191 */
    object-fit: cover;
    border-radius: 15px;
    background-color: var(--color--base-surface-2, #aeb4c1); /* Figma placeholder grey */
}

/* Excerpt */
.news-card__excerpt {
    font-size: 17px;            /* Figma 113:99 */
    font-weight: 300;
    line-height: 1.45;
    color: var(--color--base-foreground-2, #000000);  /* black */
    margin-bottom: auto; /* pushes link to bottom */
    flex-grow: 1;
}

/* Divider — Figma "Line 5" */
.news-card__rule {
    border: none;          /* Figma cards separate by spacing, not a rule line */
    margin-block: 16px 0;
    height: 0;
}

/* "Lasīt vairāk →" link — Figma instance "Lasit vairāk blue" */
.news-card__readmore {
    display: inline-flex;
    align-items: center;
    gap: 8px;                    /* Figma Lasit vairāk blue gap */
    font-size: 15px;
    font-weight: 400;
    color: var(--color--accent-primary, #7189bd);   /* periwinkle */
    text-decoration: none;
}

.news-card__readmore:hover .news-card__arrow,
.news-card__readmore:focus-visible .news-card__arrow {
    transform: translateX( 3px );
}

.news-card__readmore:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Arrow — real Figma "Button icon" SVG (8×14), recoloured via mask to follow
   the link colour. assets/img/icon-arrow-right.svg is a currentColor chevron. */
.news-card__arrow {
    display: inline-block;
    width: 12px;
    height: 14px;
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask: url('../img/icon-arrow-right.svg') no-repeat center / contain;
            mask: url('../img/icon-arrow-right.svg') no-repeat center / contain;
    transition: transform 0.15s ease;
}

/* ==========================================================================
   NEWS STRIP  (.news-strip)
   Homepage Jaunumi section — desktop 3-col grid + mobile Splide
   ========================================================================== */

.news-strip {
    padding-block: 80px;
    background-color: var(--color--base-surface, #eeeef2); /* Figma section bg */
}

.news-strip__inner {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
}

@media ( min-width: 1024px ) {
    .news-strip__inner {
        grid-template-columns: 220px 1fr;
        gap: 48px;
        align-items: start;
    }
}

/* Section heading — "Jaunumi no MIC" */
.news-strip__heading {
    font-size: clamp( 28px, 3vw, 40px );
    font-weight: 700;
    line-height: 1.15;
    color: var(--color--base-foreground, #0d1b2a);
}

/* --- DESKTOP GRID (≥ 1024px) --- */

.news-strip__desktop-grid {
    display: none; /* hidden on mobile — Splide shows instead */
    list-style: none;
    padding: 0;
    margin: 0;
}

@media ( min-width: 1024px ) {
    .news-strip__desktop-grid {
        display: grid;
        grid-template-columns: repeat( 3, 1fr );
        gap: 24px;
        align-items: start;
    }

    /* Hide 4th card on desktop (it's the spare for the mobile carousel) */
    .news-strip__item--desktop-hidden {
        display: none;
    }
}

/* --- MOBILE CAROUSEL (< 1024px) --- */

.news-strip__carousel {
    display: block; /* visible on mobile */
    overflow: hidden; /* Splide needs this */
}

@media ( min-width: 1024px ) {
    .news-strip__carousel {
        display: none; /* hidden on desktop — grid shows instead */
    }
}

/* CSS fallback for when Splide fails to load */
.news-strip__carousel.splide--fallback .splide__list {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
}

.news-strip__carousel.splide--fallback .splide__slide {
    min-width: 80%;
    scroll-snap-align: start;
    flex-shrink: 0;
}

/* Override Splide dot colours to match Figma */
.news-strip__carousel .splide__pagination__page {
    background: var(--color--base-border, #c0c4cc);
    opacity: 1;
    width: 32px;
    height: 4px;
    border-radius: 2px;
    transition: background 0.2s ease;
}

.news-strip__carousel .splide__pagination__page.is-active {
    background: var(--color--accent-primary, #1a4b8a);
    transform: none; /* Splide adds scale on active by default — disable */
}

/* ==========================================================================
   ALL-NEWS ARCHIVE GRID  (.news-grid)
   Figma: "visas ziņas" — 3-col, 4 rows
   ========================================================================== */

.archive-news {
    padding-block: 60px 80px;
}

.archive-news__back-wrap {
    margin-bottom: 24px;
}

.news-grid {
    list-style: none;
    padding: 0;
    margin: 0 0 48px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px 24px;
}

.news-grid__item {
    display: flex;        /* make the card a flex child... */
    flex-direction: column;
    min-width: 0; /* same auto-min-width guard as .news-card — otherwise one
                     card's oversized content can widen the whole grid track,
                     which every row in this single-column grid shares. */
}
 
.news-grid__item > .news-card {
    flex: 1 1 auto;       /* ...so .news-card{height:100%} fills the grid cell */
}

@media ( min-width: 640px ) {
    .news-grid {
        grid-template-columns: repeat( 2, 1fr );
    }
}

@media ( min-width: 1024px ) {
    .news-grid {
        grid-template-columns: repeat( 3, 1fr );
    }
}

.archive-news__empty {
    font-size: 16px;
    color: var(--color--base-foreground-2, #3a4a5c);
    padding-block: 48px;
    text-align: center;
}

/* ==========================================================================
   ARCHIVE PAGINATION  (.news-pagination)
   Figma: "Numbers" frame — prev ‹, numbers 1 2 3 4 5 6, next ›
   ========================================================================== */

.news-pagination .page-numbers {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}

.news-pagination .nav-links {
    display: flex;
    justify-content: center;
}

.news-pagination a.page-numbers,
.news-pagination span.page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding-inline: 8px;
    font-size: 15px;
    color: var(--color--accent-primary-strong, #185fa5);
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;
}

.news-pagination a.page-numbers:hover,
.news-pagination a.page-numbers:focus-visible {
    background: var(--color--base-surface-2, #e0e4ef);
    outline: 2px solid var(--color--accent-primary, #1a4b8a);
    outline-offset: 1px;
}

.news-pagination span.page-numbers.current {
    font-weight: 700;
    color: var(--color--accent-primary-strong, #185fa5);
    background: transparent;
}

.news-pagination span.page-numbers.dots {
    color: var(--color--base-foreground-3, #8a94a6);
    pointer-events: none;
}

/* Prev/next arrows — render the real chevron SVGs instead of the ‹ › glyphs.
   archive.php wraps the glyph in <span aria-hidden>; we hide that text and draw
   the SVG via mask so it inherits colour. */
.news-pagination .prev.page-numbers,
.news-pagination .next.page-numbers {
    color: var(--color--accent-primary-strong, #185fa5);
    position: relative;
    font-size: 0;                 /* hide the ‹ › text glyph */
}
.news-pagination .prev.page-numbers::after,
.news-pagination .next.page-numbers::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 14px;
    background-color: currentColor;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: center;  mask-position: center;
    -webkit-mask-size: contain;     mask-size: contain;
}
.news-pagination .prev.page-numbers::after {
    -webkit-mask-image: url('../img/icon-arrow-left.svg');
            mask-image: url('../img/icon-arrow-left.svg');
}
.news-pagination .next.page-numbers::after {
    -webkit-mask-image: url('../img/icon-arrow-right.svg');
            mask-image: url('../img/icon-arrow-right.svg');
}

/* ==========================================================================
   SINGLE ARTICLE  (.single-article)
   Figma: "Jaunums vai raksts" frame
   ========================================================================== */

.single-article {
    padding-block: 40px 80px;
}

.single-article__back-wrap {
    margin-bottom: 28px;
}

.single-article__body {
    max-width: 960px; /* Figma content column ≈ 858px + padding */
}

.single-article__title {
    font-size: clamp( 28px, 4vw, 52px );
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 32px;
    color: var(--color--base-foreground, #0d1b2a);
}

/* CONTENT — block editor output */
.single-article__content {
    font-size: 18px;
    line-height: 1.7;
    color: var(--color--base-foreground, #0d1b2a);
}

/* Lead paragraph style — applied via block style selector in editor */
.single-article__content .wp-block-paragraph.is-style-lead {
    font-size: clamp( 18px, 2vw, 22px );
    line-height: 1.55;
    color: var(--color--accent-primary, #1a4b8a);
    font-weight: 400;
    margin-bottom: 2em;
}

/* Inline images */
.single-article__content figure.wp-block-image {
    margin-block: 2em;
}

.single-article__content figure.wp-block-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

.single-article__content figure.wp-block-image figcaption {
    font-size: 13px;
    color: var(--color--base-foreground-3, #8a94a6);
    margin-top: 8px;
    text-align: center;
}

/* Pull-quote block — .wp-block-aicenter-pullquote */
.wp-block-aicenter-pullquote,
.single-article__content blockquote.is-style-pullquote {
    position: relative;
    border-top: 2px solid var(--color--accent-primary, #1a4b8a);
    border-bottom: 2px solid var(--color--accent-primary, #1a4b8a);
    padding-block: 32px;
    margin-block: 2em;
    text-align: left;
}

.wp-block-aicenter-pullquote p,
.single-article__content blockquote.is-style-pullquote p {
    font-size: clamp( 20px, 2.5vw, 28px );
    font-weight: 700;
    line-height: 1.3;
    color: var(--color--base-foreground, #0d1b2a);
    font-style: normal;
    margin: 0;
}

/* Decorative quotation mark — matches Figma "Quote" SVG element */
.wp-block-aicenter-pullquote::before,
.single-article__content blockquote.is-style-pullquote::before {
    content: '"';
    display: block;
    font-size: 72px;
    line-height: 0.8;
    color: var(--color--accent-primary, #1a4b8a);
    margin-bottom: 16px;
    font-family: Georgia, serif;
}

/* FOOTER */
.single-article__rule {
    border: none;
    border-top: 1px solid var(--color--base-border, #c8cdd6);
    margin-block: 48px 24px;
}

.single-article__byline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 14px;
    color: var(--color--base-foreground-2, #3a4a5c);
    margin-bottom: 24px;
}

/* ==========================================================================
   SOCIAL SHARE BAR  (.share-btn)
   Figma: frame 2298:46 — X, Instagram, LinkedIn, link
   ========================================================================== */

.single-article__share {
    display: flex;
    align-items: center;
    gap: 16px;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color--base-foreground, #0d1b2a);
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: color 0.15s ease, background 0.15s ease;
    text-decoration: none;
}

.share-btn:hover,
.share-btn:focus-visible {
    color: var(--color--accent-primary, #1a4b8a);
    background: var(--color--base-surface-2, #e0e4ef);
    outline: none;
}

.share-btn:focus-visible {
    outline: 2px solid var(--color--accent-primary, #1a4b8a);
    outline-offset: 2px;
}

/* "Copied!" toast — positioned above the button */
.share-btn__copied-msg {
    position: absolute;
    bottom: calc( 100% + 6px );
    left: 50%;
    transform: translateX( -50% );
    background: var(--color--base-foreground, #0d1b2a);
    color: var(--color--base-background, #ffffff);
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    /* Only visible when non-empty */
}

.share-btn__copied-msg:empty {
    display: none;
}
/* ==========================================================================
   GRID ITEM (added) — make the <li> a full-height flex context so the card's
   height:100% engages and rows align their rule + "Lasīt vairāk".
   ========================================================================== */
.news-grid__item {
    display: flex;
    flex-direction: column;
}
.news-grid__item > .news-card {
    flex: 1 1 auto;
}