/* ==========================================================================
   Atopic Dermatitis Feed - Design System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700&family=Source+Sans+3:wght@400;500;600&display=swap');

:root {
    /* --- Color: grounded in eczema care (oat baths, calm skin, not
       clinical/alarming) rather than a generic palette --- */
    --color-bg: #f5f6f1;
    --color-surface: #ffffff;
    --color-ink: #202b23;
    --color-ink-muted: #5b6660;
    --color-border: #dedbd0;

    --color-primary: #2f6f62;       /* sage/teal - "soothed skin" */
    --color-primary-dark: #204d43;
    --color-accent: #c98a3e;        /* oat/honey - literal care callback */
    --color-accent-soft: #f1e4cc;

    --color-focus: #1d5ee0;         /* kept distinct from brand colors so
                                        focus is always unambiguous */

    /* Per-item category color, overridden inline from Category.color_hex */
    --category-color: var(--color-primary);

    /* --- Type --- */
    --font-display: 'Sora', system-ui, -apple-system, sans-serif;
    --font-body: 'Source Sans 3', system-ui, -apple-system, sans-serif;

    --step--1: 0.9rem;
    --step-0: 1.0625rem;
    --step-1: 1.25rem;
    --step-2: 1.65rem;
    --step-3: 2.2rem;
    --step-4: 3rem;

    --leading-body: 1.65;
    --leading-heading: 1.18;

    /* --- Layout --- */
    --content-max: 100%;
    --measure: 66ch;

    --space-1: 0.5rem;
    --space-2: 1rem;
    --space-3: 1.5rem;
    --space-4: 2.5rem;
    --space-5: 4rem;
    --space-6: 6rem;

    --radius: 6px;
    --radius-sm: 4px;
}

/* --- Dark theme: same tokens, different values. Toggled via
   [data-theme="dark"] on <html>, set by newsportal.js. Falls back to the
   OS-level preference on first visit (see prefers-color-scheme below). --- */

[data-theme="dark"] {
    --color-bg: #171a17;
    --color-surface: #1f2320;
    --color-ink: #eceae4;
    --color-ink-muted: #a3aaa4;
    --color-border: #34392f;

    --color-primary: #6fbfae;
    --color-primary-dark: #93d3c4;
    --color-accent: #e0ab5f;
    --color-accent-soft: #3a3123;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: #171a17;
        --color-surface: #1f2320;
        --color-ink: #eceae4;
        --color-ink-muted: #a3aaa4;
        --color-border: #34392f;

        --color-primary: #6fbfae;
        --color-primary-dark: #93d3c4;
        --color-accent: #e0ab5f;
        --color-accent-soft: #3a3123;
    }
}

/* Visually hidden but still reachable by screen readers - used for
   headings that establish correct document structure (h1/h2) without
   adding a visible heading where the design doesn't call for one. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Reset & base --- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-ink);
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: var(--leading-body);
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.15s ease, color 0.15s ease;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    line-height: var(--leading-heading);
    font-weight: 600;
    margin: 0 0 var(--space-2);
    color: var(--color-ink);
}

p { margin: 0 0 var(--space-2); }

a {
    color: var(--color-primary);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}
a:hover { color: var(--color-primary-dark); }

img { max-width: 100%; display: block; }

/* Visible keyboard focus everywhere - never suppressed */
a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* --- Layout shell --- */

.wrap {
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding-inline: clamp(var(--space-2), 4vw, var(--space-5));
    box-sizing: border-box;
}

.site-header {
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.site-header__inner {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    justify-content: space-between;
    padding-block: var(--space-2);
    gap: var(--space-3);
}

.site-header__wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--step-1);
    color: var(--color-ink);
    text-decoration: none;
    letter-spacing: -0.01em;
}
.site-header__wordmark:hover { color: var(--color-ink); }
.site-header__wordmark span { color: var(--color-primary); }

.site-nav { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.site-nav a {
    color: var(--color-ink-muted);
    text-decoration: none;
    font-size: var(--step--1);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.site-nav a:hover { color: var(--category-color, var(--color-primary)); }

/* Right-hand header group: Partners, About, translate dropdown, theme
   toggle - flex-shrink:0 + nowrap keep this as one row regardless of
   .site-nav's width on the left. */
.site-header__right {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
    white-space: nowrap;
}
.site-header__right > a {
    color: var(--color-ink-muted);
    text-decoration: none;
    font-size: var(--step--1);
    font-weight: 500;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.site-header__right > a:hover { color: var(--color-primary); }

/* GTranslate (replacement for Google's discontinued Website Translator
   widget - see base.html). Injects a real <select class="gt_selector">,
   styled directly below. NO max-width/overflow:hidden here - that
   clipped the widget's right edge in an earlier version; let it size
   naturally, .site-header__right's nowrap keeps the row stable. */
.google-translate {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    overflow: visible;
}

/* Defensively un-clip anything GTranslate wraps the select in - we
   don't control that markup or its CDN-loaded styling. */
.google-translate * {
    overflow: visible !important;
}

/* GTranslate injects this <select> itself; !important wins over its
   own inline/default styling. */
.gt_selector {
    appearance: none !important;
    -webkit-appearance: none !important;
    font-family: var(--font-body) !important;
    font-size: var(--step--1) !important;
    font-weight: 500 !important;
    color: var(--color-ink-muted) !important;
    background-color: var(--color-surface) !important;
    border: 1px solid var(--color-border) !important;
    border-radius: 999px !important;
    padding: 0.35em 1.6em 0.35em 0.75em !important;
    margin: 0 !important;
    cursor: pointer;
    white-space: nowrap;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6660' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.4em center !important;
    background-size: 1em !important;
}
.gt_selector:hover {
    color: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
}
.gt_selector:focus-visible {
    outline: 2px solid var(--color-focus) !important;
    outline-offset: 2px;
}

.theme-toggle {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-ink-muted);
    font-family: var(--font-body);
    padding: 0;
}
.theme-toggle:hover { color: var(--color-primary); border-color: var(--color-primary); }
.theme-toggle svg { width: 1.1rem; height: 1.1rem; }

/* Show sun in dark mode (click to go light), moon in light mode (click to go dark) */
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* --- Category filter tabs (News index page) --- */

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-3);
    overflow-x: unset;
}

.category-tabs__tab {
    display: inline-block;
    padding: 0.6em 0.1em;
    font-size: var(--step--1);
    font-weight: 600;
    color: var(--color-ink-muted);
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.category-tabs__tab:hover {
    color: var(--category-color, var(--color-primary));
}
.category-tabs__tab--active {
    color: var(--category-color, var(--color-primary));
    border-bottom-color: var(--category-color, var(--color-primary));
}

/* --- Pagination --- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding-block: var(--space-4) var(--space-6);
    color: var(--color-ink-muted);
    font-size: var(--step--1);
}
.pagination a {
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
}
.pagination a:hover { color: var(--color-primary-dark); }

.site-footer {
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-6);
    padding-block: var(--space-4);
    color: var(--color-ink-muted);
    font-size: var(--step--1);
}

.site-footer__note {
    /* full width - the note used to be capped at the article text measure */
    max-width: none;
}

/* --- Category badge: the color_hex field made visible --- */

.category-badge {
    display: inline-block;
    font-size: var(--step--1);
    font-weight: 600;
    color: var(--category-color);
    border: 1px solid var(--category-color);
    border-radius: 999px;
    padding: 0.15em 0.75em;
}

/* Solid/vivid variant, used on photo-overlay cards where an outline badge
   wouldn't have enough contrast against arbitrary images. */
.category-badge--solid {
    color: #fff;
    background: var(--category-color);
    border-color: transparent;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* --- Homepage hero mosaic: 4 articles as 1 big + 1 wide + 2 small tiles
   (fixed layout, not repeating). Reuses .article-card's overlay look. --- */

.hero-mosaic {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: clamp(170px, 22vw, 380px);
    gap: var(--space-3);
    padding-block: var(--space-4);
}

.hero-mosaic > .article-card:nth-child(1) { grid-column: 1 / 3; grid-row: 1 / 3; }
.hero-mosaic > .article-card:nth-child(2) { grid-column: 3 / 5; grid-row: 1 / 2; }
.hero-mosaic > .article-card:nth-child(3) { grid-column: 3 / 4; grid-row: 2 / 3; }
.hero-mosaic > .article-card:nth-child(4) { grid-column: 4 / 5; grid-row: 2 / 3; }

/* Tiles 5-6 are fetched up front but stay hidden until there's enough
   width for their own columns - see the min-width query below. */
.hero-mosaic > .article-card:nth-child(5),
.hero-mosaic > .article-card:nth-child(6) {
    display: none;
}

/* !important here guards against the base .article-card rules below */
.hero-mosaic .article-card {
    aspect-ratio: auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    min-width: 0 !important;
    align-self: stretch !important;
    justify-self: stretch !important;
}

/* The big tile earns a bigger title and a bit more summary, since it has
   much more room than the other three. */
.hero-mosaic > .article-card:nth-child(1) .article-card__title { font-size: var(--step-3); }
.hero-mosaic > .article-card:nth-child(1) .article-card__summary { -webkit-line-clamp: 3; }

/* On wide screens, grow the mosaic to 6 columns and reveal 2 extra tall
   tiles on the right instead of just stretching the original 4 wider.
   Every tile below uses EXPLICIT grid line numbers (not just `span`) so
   the layout can't be reshuffled by the browser's auto-placement when
   the column count changes - span-only placement looked fine at 4
   columns but scrambled once a 5th/6th column became available. */
@media (min-width: 1400px) {
    .hero-mosaic { grid-template-columns: repeat(6, 1fr); }

    .hero-mosaic > .article-card:nth-child(1) { grid-column: 1 / 3; grid-row: 1 / 3; }
    .hero-mosaic > .article-card:nth-child(2) { grid-column: 3 / 5; grid-row: 1 / 2; }
    .hero-mosaic > .article-card:nth-child(3) { grid-column: 3 / 4; grid-row: 2 / 3; }
    .hero-mosaic > .article-card:nth-child(4) { grid-column: 4 / 5; grid-row: 2 / 3; }

    .hero-mosaic > .article-card:nth-child(5),
    .hero-mosaic > .article-card:nth-child(6) {
        display: block;
    }
    .hero-mosaic > .article-card:nth-child(5) { grid-column: 5 / 6; grid-row: 1 / 3; }
    .hero-mosaic > .article-card:nth-child(6) { grid-column: 6 / 7; grid-row: 1 / 3; }
}

/* --- Article card grid (index page & homepage "more news") --- */

.article-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    padding-block: var(--space-3) var(--space-5);
}

.article-grid--4col { grid-template-columns: repeat(4, 1fr); }

.load-more-wrap {
    display: flex;
    justify-content: center;
    padding-block: var(--space-2) var(--space-6);
}

.button-outline {
    background: transparent;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--step--1);
    padding: 0.65em 1.75em;
    border-radius: 999px;
    cursor: pointer;
}
.button-outline:hover { background: var(--color-primary); color: #fff; }
.button-outline:disabled { opacity: 0.5; cursor: default; }

/* --- Article card: full-bleed image with title/summary overlaid on a
   gradient scrim at the bottom - livelier and more "news portal" than a
   plain image-on-top-text-below card. --- */

.article-card {
    position: relative;
    display: block;
    aspect-ratio: 3 / 4;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-ink);
    text-decoration: none;
    color: inherit;
    isolation: isolate;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.article-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}

.article-card__image {
    position: absolute;
    inset: 0;
}
.article-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}
.article-card:hover .article-card__image img { transform: scale(1.07); }

/* Gradient scrim so title/summary text stays legible over any photo */
.article-card::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        to top,
        rgba(10, 12, 10, 0.92) 0%,
        rgba(10, 12, 10, 0.55) 42%,
        rgba(10, 12, 10, 0) 75%
    );
}
/* Cards with no image are already a solid dark background, so they don't
   need (and shouldn't get) the extra darkening scrim on top. */
.article-card--no-image::after { content: none; }

.article-card__content {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.5em;
    padding: var(--space-2);
}

.article-card__meta {
    display: flex;
    gap: 0.6em;
    align-items: center;
    flex-wrap: wrap;
    font-size: var(--step--1);
    color: rgba(255, 255, 255, 0.85);
}

.article-card__title {
    font-family: var(--font-display);
    font-size: var(--step-1);
    font-weight: 600;
    line-height: 1.25;
    color: #fff;
    margin: 0;
}

.article-card__summary {
    color: rgba(255, 255, 255, 0.82);
    font-size: var(--step--1);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: var(--space-1);
    margin-top: var(--space-5);
}
.section-heading h2 { margin: 0; font-size: var(--step-2); }

/* --- Single article page --- */

.article {
    padding-block: var(--space-4) var(--space-6);
    max-width: var(--measure);
    margin-inline: auto;
}

.article__image {
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: var(--space-3);
    max-width: var(--content-max);
    margin-inline: auto;
}
.article__image img { width: 100%; max-height: 480px; object-fit: cover; }

.article__title {
    font-size: var(--step-3);
}

.article__meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-ink-muted);
    font-size: var(--step--1);
    margin-bottom: var(--space-3);
}

.article__body {
    font-size: var(--step-0);
}

/* the short summary: bold lead directly under the title/dates */
.article__lead {
    font-size: var(--step-1);
    line-height: 1.45;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--color-border);
}
.article__lead p { margin: 0; }

.article__source {
    margin-top: var(--space-4);
    padding: var(--space-3);
    background: var(--color-accent-soft);
    border-radius: var(--radius-sm);
}
.article__source p {
    margin: 0 0 var(--space-1);
    color: var(--color-ink-muted);
    font-size: var(--step--1);
}
.article__source a {
    font-weight: 600;
    color: var(--color-primary-dark);
}

/* --- Article page layout: article 2/3, sidebar 1/3 (full width) --- */

.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: var(--space-5);
    align-items: start;
    padding-top: var(--space-4);
}
/* inside the 2/3 column the text uses the whole column, not the narrow measure */
.article-main .article {
    max-width: none;
    margin-inline: 0;
    padding-top: 0;
}
.article-main .article__image { margin-inline: 0; }

.article__dates {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-4);
    margin: 0 0 var(--space-3);
    color: var(--color-ink-muted);
    font-size: var(--step--1);
}
.article__date dt {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.article__date dd { margin: 0; font-weight: 600; color: var(--color-ink); }

/* previous / next article under the text */
.article-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-border);
}
.article-pager__link {
    display: flex;
    flex-direction: column;
    gap: 0.25em;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-ink);
}
.article-pager__link:hover { border-color: var(--color-primary); }
.article-pager__link--next { grid-column: 2; text-align: right; }
.article-pager__label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-ink-muted);
}
.article-pager__title { font-weight: 600; line-height: 1.3; }

/* sidebar cards */
.article-aside { display: flex; flex-direction: column; gap: var(--space-4); }
.aside-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
}
.aside-card__title {
    margin: 0 0 var(--space-2);
    font-size: var(--step-0);
    padding-bottom: var(--space-1);
    border-bottom: 1px solid var(--color-border);
}
.aside-card__more { display: inline-block; margin-top: var(--space-2); font-size: var(--step--1); font-weight: 600; }

.partner-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.partner-list__item a { display: block; }
.partner-list__item img { max-width: 100%; height: auto; margin-inline: auto; }
.partner-list__name { font-weight: 600; }

.recent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.recent-list__link { display: flex; gap: var(--space-2); text-decoration: none; color: var(--color-ink); }
.recent-list__link:hover .recent-list__title { color: var(--color-primary); }
.recent-list__thumb { flex: 0 0 88px; border-radius: var(--radius-sm); overflow: hidden; }
.recent-list__thumb img { width: 100%; height: 100%; object-fit: cover; }
.recent-list__text { display: flex; flex-direction: column; gap: 0.2em; min-width: 0; }
.recent-list__title { font-weight: 600; line-height: 1.3; font-size: var(--step--1); }
.recent-list__date { color: var(--color-ink-muted); font-size: 0.78rem; }

/* Partners page */
.partner-grid-section { padding-bottom: var(--space-6); }
.partner-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-3);
}
.partner-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
}
.partner-card__link { text-decoration: none; color: inherit; }
.partner-card__logo { display: flex; align-items: center; justify-content: center; min-height: 100px; }
.partner-card__logo img { max-width: 100%; height: auto; }
.partner-card__name { font-size: var(--step-0); margin: var(--space-2) 0 var(--space-1); }
.partner-card__name-fallback { font-weight: 700; font-size: var(--step-1); }
.partner-card__description { color: var(--color-ink-muted); font-size: var(--step--1); margin: 0; }

/* --- Standard content pages (About, Partners, ...) --- */

.standard-page {
    padding-block: var(--space-4) var(--space-6);
    /* full width, like the article layout and footer (was capped at the
       66ch reading measure) */
    max-width: none;
}
.standard-page__title { font-size: var(--step-3); margin-bottom: var(--space-3); }
.standard-page__body { font-size: var(--step-0); }
.standard-page__body p { margin-bottom: var(--space-2); }

/* --- Responsive --- */

@media (max-width: 860px) {
    .article-layout { grid-template-columns: 1fr; }
    .article-pager { grid-template-columns: 1fr; }
    .article-pager__link--next { grid-column: auto; }
    .hero-mosaic { grid-template-columns: repeat(2, 1fr); }
    .hero-mosaic > .article-card {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
    }
    .hero-mosaic > .article-card:nth-child(1) .article-card__title { font-size: var(--step-1); }
    .article-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
    .article-grid { grid-template-columns: 1fr; }
    .hero-mosaic { grid-template-columns: 1fr; }
    .site-nav { display: none; }
}
