/*
 * Homepage layout (index.php), modelled on bbc.com/arabic.
 * Colours and fonts come from the tokens in refresh.css.
 */

div#mep_0 {
    display: none;
}

.home-shell {
    max-width: 1080px;
    padding-top: 28px;
    padding-bottom: 48px;
}

/* ---------- Shared bits ---------- */

.home-time {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--muted);
}

.home-heading {
    margin: 0 0 16px;
    font-family: var(--font);
    font-style: normal;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--ink);
}

.home-heading a {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
}

.home-heading a:hover {
    color: var(--brand-dark);
}

/* "›" pointing in the reading direction. */
.home-heading__chevron {
    width: 9px;
    height: 9px;
    border-top: 2.5px solid currentColor;
    border-left: 2.5px solid currentColor;
    transform: rotate(-45deg);
}

[dir="ltr"] .home-heading__chevron,
html:not([dir="rtl"]) .home-heading__chevron {
    transform: rotate(135deg);
}

.home-section {
    margin-top: 48px;
}

/* ---------- Card ---------- */

.home-card {
    position: relative;
    min-width: 0;
}

.home-card__media {
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--surface-alt);
}

.home-card__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s ease;
}

.home-card__media img.post-image-placeholder {
    object-fit: contain;
}

.home-card:hover .home-card__media img {
    transform: scale(1.03);
}

.home-card__body {
    padding-top: 10px;
}

/* style.css sets "h3 { font-family: new; font-size: 20px; ... !important }" site-wide. */
.home .home-card__title {
    margin: 0;
    font-family: var(--font) !important;
    font-size: 17px !important;
    font-weight: 700 !important;
    line-height: 1.55 !important;
}

.home-card__title a {
    color: var(--ink);
    text-decoration: none;
}

/* Whole card is the link target. */
.home-card__title a:after {
    content: '';
    position: absolute;
    inset: 0;
}

.home-card:hover .home-card__title a {
    color: var(--brand-dark);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

.home-card__excerpt {
    margin: 10px 0 0;
    font-size: 15px;
    line-height: 1.7;
    color: var(--ink-soft);
}

.home .home-card--lead .home-card__title {
    font-size: 30px !important;
    line-height: 1.4 !important;
}

.home-card--text .home-card__body {
    padding-top: 0;
}

/* ---------- Top stories ---------- */

/* Lead takes the first two columns (right side in RTL) over two rows. */
.home-top__grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 24px;
}

.home-top__grid .home-card--lead {
    grid-column: span 2;
    grid-row: span 2;
}

.home-top__headlines {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 24px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.home-top__headlines .home-card + .home-card:before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-start: -12px;
    border-inline-start: 1px solid var(--line);
}

.home-banner {
    margin-top: 40px;
}

.home-banner img {
    display: block;
    width: 100%;
    height: auto;
}

/* ---------- Category rows ---------- */

.home-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 32px 24px;
}

/* ---------- Most read ---------- */

.home-popular {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(2, auto);
    grid-auto-flow: column;
    gap: 0 24px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: popular;
}

.home .home-popular li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 0;
    margin: 0;
    border-top: 1px solid var(--line);
    counter-increment: popular;
}

/* style.css styles "ol li:before" as an absolutely positioned counter. */
.home .home-popular li:before {
    content: counter(popular);
    position: static;
    transform: none;
    counter-increment: none;
    font-family: var(--font);
    font-style: normal;
    flex: none;
    min-width: 1.1em;
    font-size: 40px;
    font-weight: 700;
    line-height: 1;
    color: var(--brand-dark);
}

html[lang="ar"] .home .home-popular li:before {
    content: counter(popular, arabic-indic);
}

.home-popular a {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.55;
    color: var(--ink);
}

.home-popular a:hover {
    color: var(--brand-dark);
}

/* ---------- Search + widgets ---------- */

.home-extras {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 32px;
    padding-top: 32px;
    border-top: 1px solid var(--line);
}

.home-search {
    display: flex;
    gap: 10px;
}

.home-search input {
    flex: 1;
    min-width: 0;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
}

.home-extras__widgets img {
    max-width: 100%;
    height: auto;
}

/* ---------- Tablet ---------- */

@media (max-width: 991px) {
    .home-top__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .home-top__grid .home-card--lead {
        grid-row: auto;
    }

    .home-top__headlines,
    .home-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .home-top__headlines .home-card:nth-child(odd):before {
        display: none;
    }

    .home-popular {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: repeat(5, auto);
    }

    .home-extras {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- Phone: small cards become rows with a thumbnail at the side ---------- */

@media (max-width: 575px) {
    .home-shell {
        padding-top: 16px;
    }

    .home-section {
        margin-top: 36px;
    }

    .home-heading {
        font-size: 21px;
    }

    .home .home-card--lead .home-card__title {
        font-size: 22px !important;
    }

    .home-top__grid,
    .home-top__headlines,
    .home-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .home-top__grid .home-card--lead {
        grid-column: auto;
    }

    .home-top__headlines .home-card:before {
        display: none;
    }

    .home-top__headlines .home-card + .home-card {
        padding-top: 16px;
        border-top: 1px solid var(--line);
    }

    .home-card--tile {
        display: flex;
        gap: 12px;
        align-items: flex-start;
    }

    .home-card--tile .home-card__media {
        flex: 0 0 38%;
    }

    .home-card--tile .home-card__body {
        padding-top: 0;
    }

    .home .home-card--tile .home-card__title {
        font-size: 15px !important;
    }

    .home-popular {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        grid-auto-flow: row;
    }
}

/* ---------- Category page (category.php), after a bbc.com/arabic topic page ---------- */

.topic-title {
    margin: 8px 0 28px;
    font-family: var(--font);
    font-style: normal;
    font-size: 40px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--ink);
}

.home .topic-grid .home-card__title {
    font-size: 16px !important;
}

.topic-empty {
    font-size: 17px;
    color: var(--ink-soft);
}

.topic-pagination {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
}

.topic-pagination__summary {
    font-size: 15px;
    color: var(--muted);
}

.topic-pagination ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.topic-pagination li {
    margin: 0;
}

.topic-pagination .page-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 10px;
    border-bottom: 3px solid transparent;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
}

.topic-pagination a.page-numbers:hover {
    border-bottom-color: var(--ink);
}

.topic-pagination .page-numbers.current {
    border-bottom-color: var(--brand);
    color: var(--ink);
}

.topic-pagination .page-numbers.dots {
    font-weight: 400;
    color: var(--muted);
}

.topic-pagination .prev,
.topic-pagination .next {
    font-weight: 400;
}

@media (max-width: 575px) {
    .topic-title {
        margin-bottom: 20px;
        font-size: 28px;
    }

    .topic-pagination .page-numbers {
        min-width: 38px;
        height: 40px;
        padding: 0 6px;
    }
}
