/* ============================================================
   news.css — the News section (layout A, Card grid): /news, the post pages and the home block.
   Loaded after home.css (hm-section, hm-title, hm-btn) and, on the post pages, app-page.css (the image viewer and
   the tap-to-play video). Every class is prefixed nw-, and every colour, size and space comes from variables.css.
   Design: aidlc-docs/construction/news-section/functional-design/frontend-components.md.
   ============================================================ */

/* Both languages of a post are in the HTML ([data-l] pairs); show the page's (site-i18n.js sets <html lang>). */
html:not([lang^="es"]) [data-l="es"],
html[lang^="es"] [data-l="en"] { display: none !important; }

.nw-icon { flex: none; display: inline-block; vertical-align: middle; }

/* ---- NewsMeta: category (dot + name), date, place ---- */
.nw-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-body-sm-size);
    line-height: 20px;
    color: var(--ink-muted);
}
.nw-cat { display: inline-flex; align-items: center; gap: 6px; font-weight: var(--weight-semibold); color: var(--ink); }
.nw-cat::before,
.nw-chip-dot { content: ""; flex: none; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--nw-cat-color); }
.nw-cat--event { --nw-cat-color: var(--accent); }
.nw-cat--partnership { --nw-cat-color: var(--success); }
.nw-cat--product { --nw-cat-color: var(--info); }
.nw-cat--recognition { --nw-cat-color: var(--warning); }
.nw-place { display: inline-flex; align-items: center; gap: 2px; }
.nw-meta--dark { color: var(--home-hero-subtitle-ink); }
.nw-meta--dark .nw-cat { color: var(--white); }
.nw-meta--dark .nw-cat--event { --nw-cat-color: var(--dracode); }

/* ---- CategoryFilter: hidden until news.js shows it (it can't work without JavaScript) ---- */
.nw-filter {
    display: flex;
    gap: var(--space-2);
    margin: 0 0 var(--space-6);
    padding: 2px;
    overflow-x: auto;
    scrollbar-width: none;
}
.nw-filter[hidden] { display: none; }
.nw-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex: none;
    min-height: var(--target-min);
    padding: 0 var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--ink-muted-alt);
    font-family: var(--font-sans);
    font-size: var(--text-label-size);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.nw-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--ink-on-accent); }
.nw-chip[aria-pressed="true"] .nw-chip-dot { box-shadow: 0 0 0 2px var(--white); }
.nw-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nw-item[hidden] { display: none; }

/* ---- Grid of NewsCards: 3 / 2 / 1 columns; one or two cards keep their column width ---- */
.nw-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-6) var(--space-5);
}
@media (max-width: 991px) { .nw-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575px) { .nw-grid { grid-template-columns: 1fr; } }

/* The title is the link (a screen reader hears just the title); its ::after stretches over the whole card. */
.nw-card {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--border);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.nw-card-media { aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-alt); }
/* cropped a little above the middle, like the share image: in event photos the faces sit in the upper part */
.nw-card-media img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 25%; }
.nw-card-body { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4) var(--space-5) var(--space-5); }
.nw-card-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--text-display-sm-size);
    font-weight: var(--weight-bold);
    line-height: 1.25;
    text-align: left;
}
.nw-card-link,
.nw-card-link:visited,
.nw-card-link:hover,
.nw-card-link:focus { color: var(--ink); text-decoration: none; }
.nw-card-link::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: var(--radius-lg); }
.nw-card-link:focus-visible { outline: none; }
.nw-card-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 3px; }
.nw-card-text {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-family: var(--font-sans);
    font-size: var(--text-body-size);
    line-height: 1.5;
    color: var(--ink-muted);
}
@media (hover: hover) {
    .nw-card:hover { box-shadow: var(--shadow); transform: translateY(-3px); }
    .nw-card:hover .nw-card-link { color: var(--accent); }
}

/* ---- EmptyState (no posts yet) ---- */
.nw-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    max-width: 560px;
    margin: 0 auto;
    padding: var(--space-8) 0;
    text-align: center;
}
.nw-empty-icon { color: var(--accent); }
.nw-empty .hm-title { margin: 0; text-align: center; }

/* ---- Post page ---- */
.nw-back,
.nw-back:visited {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: var(--target-min);
    margin-bottom: var(--space-2);
    font-family: var(--font-sans);
    font-size: var(--text-body-sm-size);
    font-weight: var(--weight-semibold);
    color: var(--home-hero-subtitle-ink);
    text-decoration: none;
}
.nw-back:hover,
.nw-back:focus { color: var(--white); text-decoration: none; }
.nw-back:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }
.nw-post-hero .nw-meta { margin-bottom: var(--space-3); }
/* post titles run longer than other heroes': a step smaller (home.css sets .slide.hm-hero .inner h1.hm-hero-title) */
.slide.hm-hero .inner h1.hm-hero-title.nw-post-title {
    max-width: 24ch;
    font-size: var(--text-display-lg-size);
    line-height: 1.15;
}
@media (max-width: 767px) {
    .slide.hm-hero .inner h1.hm-hero-title.nw-post-title { font-size: 30px; }
}
.nw-post-inner { max-width: 960px; }

/* PhotoGallery: the lead photo whole (never cropped), the others as square thumbnails; each opens the viewer */
.nw-gallery {
    list-style: none;
    margin: 0 0 var(--space-8);
    padding: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: var(--space-2);
}
.nw-gallery > li { aspect-ratio: 1; min-width: 0; }
.nw-gallery > .nw-gallery-lead { grid-column: 1 / -1; aspect-ratio: auto; margin-bottom: var(--space-2); }
@media (max-width: 575px) { .nw-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.nw-photo { display: block; height: 100%; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-alt); }
.nw-photo img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.nw-photo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nw-gallery-lead .nw-photo { display: flex; justify-content: center; height: auto; border-radius: var(--radius-lg); }
.nw-gallery-lead .nw-photo img { width: auto; max-width: 100%; height: auto; max-height: min(640px, 70vh); object-fit: contain; }
@media (hover: hover) { .nw-gallery > li:not(.nw-gallery-lead) .nw-photo:hover img { transform: scale(1.04); } }
.nw-caption { margin-top: var(--space-2); font-family: var(--font-sans); font-size: var(--text-body-sm-size); line-height: 20px; color: var(--ink-muted); }

/* PostBody: paragraphs, lists, bold, italic, links */
.nw-body { max-width: 720px; }
.nw-body p,
.nw-body li {
    font-family: var(--font-sans);
    font-size: var(--text-body-lg-size);
    line-height: 1.65;
    color: var(--ink);
}
.nw-body p { margin: 0 0 var(--space-4); }
.nw-body ul { margin: 0 0 var(--space-4); padding-left: 1.4em; list-style: disc; }
.nw-body li { margin: 0 0 var(--space-1); list-style: disc; }
.nw-body a,
.nw-body a:visited { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.nw-body a:hover,
.nw-body a:focus { color: var(--accent); text-decoration-thickness: 2px; }
.nw-body strong { font-weight: var(--weight-bold); }
.nw-video { max-width: 960px; }
.nw-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-6); }
.nw-actions .hm-btn { gap: var(--space-2); cursor: pointer; }
.nw-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--header-tabbar-height) + var(--space-5));
    z-index: 1000;
    transform: translateX(-50%);
    padding: 10px 18px;
    border-radius: var(--radius-pill);
    background: var(--gray-dark);
    color: var(--white);
    font-family: var(--font-sans);
    font-size: var(--text-body-sm-size);
    box-shadow: var(--shadow);
}

/* ---- Home block and "More news": the section title with "All news" on its right (below it on phones) ---- */
.nw-home-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.nw-home-head .hm-title { margin: 0; }
.nw-more .hm-title { margin-bottom: var(--space-6); }

@media (prefers-reduced-motion: reduce) {
    .nw-card,
    .nw-photo img { transition: none; }
    .nw-card:hover { transform: none; }
    .nw-gallery > li:not(.nw-gallery-lead) .nw-photo:hover img { transform: none; }
}
