/* Kniste base styles.
   RTL-safe (logical properties), Almarai, readable defaults.
   Colors and corner rounding come from the tokens at the top (set by Ghost Admin custom settings). */

:root {
    /* ---- Look and feel: values below are the defaults. The theme's custom settings
       (Ghost Admin > Settings > Design) override --bg, --text, --band and --button
       through a style block in default.hbs. Everything else is derived from them. ---- */
    --bg: #ffffff;
    --text: #1d1d1f;
    --band: #f5f5f7;
    --button: #1d1d1f;
    --muted: color-mix(in srgb, var(--text) 65%, var(--bg));
    --line: color-mix(in srgb, var(--text) 10%, var(--bg));
    --overlay: color-mix(in srgb, var(--text) 50%, transparent);
    --overlay-strong: color-mix(in srgb, var(--text) 80%, transparent);
    --overlay-cover: color-mix(in srgb, var(--text) 65%, transparent);
    --accent: var(--button);

    /* corner rounding (changed by the corner style setting) */
    --r-card: 12px;
    --r-field: 8px;
    --r-button: 4px;
    --r-pill: 999px;

    --font: var(--gh-font-body, "Almarai"), system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
    --container: 1120px;
    --narrow: 680px;
    --gap: clamp(1rem, 3vw, 2rem);
}
.corner-square { --r-card: 0px; --r-field: 0px; --r-button: 0px; --r-pill: 0px; }
.corner-round { --r-card: 24px; --r-field: 16px; --r-button: 12px; --r-pill: 999px; }

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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1.125rem;
    line-height: 1.9;
    color: var(--text);
    background: var(--bg);
    text-align: start;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-main { flex: 1; }

img, svg, video { max-width: 100%; height: auto; display: block; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--muted); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

h1, h2, h3, h4 { font-family: var(--gh-font-heading, var(--font)); line-height: 1.4; margin-block: 0 0.6em; font-weight: 800; }

.container {
    width: 100%;
    max-inline-size: var(--container);
    margin-inline: auto;
    padding-inline: var(--gap);
}
.container--narrow { max-inline-size: calc(var(--narrow) + var(--gap) * 2); }

.visually-hidden {
    position: absolute !important;
    inline-size: 1px; block-size: 1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
    position: absolute;
    inset-inline-start: 1rem;
    inset-block-start: -4rem;
    background: var(--accent);
    color: var(--bg);
    padding: 0.5rem 1rem;
    border-radius: 0 0 var(--r-card) var(--r-card);
    z-index: 10;
}
.skip-link:focus { inset-block-start: 0; }

/* Header / nav / footer */
.site-header { padding-block: 0.75rem; }
.site-header__inner, .site-footer__inner {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.site-header__brand { font-weight: 800; text-decoration: none; font-size: 1.25rem; }
.site-header__brand img { block-size: 2rem; inline-size: auto; }

.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 1.25rem; flex-wrap: wrap; }
.site-nav a { text-decoration: none; font-size: 1rem; }
.site-nav .nav-current a { font-weight: 800; }

.site-footer {
    background: var(--band);
    border-block-start: 1px solid var(--line);
    padding-block: clamp(1.5rem, 4vw, 2.5rem);
    margin-block-start: clamp(2rem, 5vw, 3.5rem);
    color: var(--muted); font-size: 0.9375rem;
}
.site-footer p { margin: 0; }
.site-footer__inner { align-items: center; }
.site-footer__info { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.5rem; }

/* Homepage */
/* Header band (logo area) */
.site-header--home {
    position: relative; padding: 0;
    display: flex; flex-direction: column;
    background: var(--band);
    border-block-end: 1px solid var(--line);
}
.site-header--home .site-header__inner { position: absolute; inset-inline: 0; inset-block-start: 0; padding-block: 0.75rem; z-index: 1; }
.hero { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding-block: 3rem 1rem; }
.hero__inner { display: flex; flex-direction: column; align-items: center; gap: clamp(0.25rem, 0.8vh, 0.75rem); }
/* The logo: an uploaded image, or the site title as large text */
.hero__logo { max-block-size: clamp(3rem, 11vh, 6.5rem); inline-size: auto; }
.hero__title { font-size: clamp(2rem, 6vh, 4.5rem); line-height: 1.2; font-weight: 800; margin: 0; }
.hero__slogan { color: var(--muted); font-size: clamp(0.9375rem, 2.2vh, 1.25rem); line-height: 1.4; margin: 0; }

/* Page grid on larger screens: header 20% / main 70% / footer 10% of the page height.
   A row never gets smaller than its content, so nothing is clipped. On phones the
   cards stack, so the page flows normally and grows as tall as it needs. */
@media (min-width: 800px) and (min-height: 600px) {
    .home-template {
        display: grid;
        min-height: 100vh; min-height: 100dvh;
        grid-template-rows: minmax(min-content, 20fr) minmax(min-content, 70fr) minmax(min-content, 10fr);
    }
    .home-template .site-main {
        display: flex; flex-direction: column; justify-content: center;
        padding-block: clamp(0.75rem, 2vh, 2rem);
    }
    .home-template .hero { padding-block: 0.75rem; }
    .home-template .site-footer { margin-block-start: 0; padding-block: clamp(0.5rem, 1.5vh, 2.5rem); display: flex; align-items: center; }
    .home-template .site-footer__inner { inline-size: 100%; }
}

.intro { padding-block: 0 clamp(1rem, 3vh, 2.5rem); }
.intro__text { max-inline-size: 42rem; margin: 0 auto; text-align: center; font-size: 1.25rem; line-height: 2; }

.types__list {
    list-style: none; margin: 0; padding: 0;
    display: grid; gap: var(--gap);
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.type-card {
    display: flex; flex-direction: column; gap: 1rem;
    block-size: 100%;
    padding: 1.5rem;
    border: 1px solid var(--line);
    border-radius: var(--r-card);
}
/* the fallback card is hidden when a real card (built from the tag) comes right before it */
.type-card--real + .type-card--fallback { display: none; }
.type-card__graphic {
    display: grid; place-items: center;
    aspect-ratio: 4 / 3;
    background: var(--band); border-radius: max(0px, calc(var(--r-card) - 4px));
    font-size: 3rem; font-weight: 800; color: var(--muted);
    text-decoration: none;
}
.type-card__media {
    position: relative; flex: 1; overflow: hidden;
    border-radius: max(0px, calc(var(--r-card) - 4px));
}
.type-card__media .type-card__graphic { block-size: 100%; transition: transform 0.4s ease; overflow: hidden; }
.type-card__graphic img { inline-size: 100%; block-size: 100%; object-fit: cover; }
/* card style setting */
.card-filled .type-card { background: var(--band); border-color: transparent; }
.card-borderless .type-card { border-color: transparent; padding: 0; }
.card-borderless .type-card__media, .card-borderless .type-card__graphic { border-radius: var(--r-card); }
/* Tagline is centred over the image */
.type-card__tagline {
    position: absolute; inset: 0; margin: 0;
    display: flex; align-items: center; justify-content: center; text-align: center;
    padding: 1.25rem;
    background: var(--overlay);
    color: var(--bg);
    font-size: 1.25rem; font-weight: 700; line-height: 1.7;
    transition: background 0.3s ease;
    pointer-events: none;
}
/* Small action button in the lower corner on the left (inline-end in RTL) */
.type-card__button {
    position: absolute; inset-block-end: 0.75rem; inset-inline-end: 0.75rem;
    padding: 0.2rem 0.9rem; font-size: 0.9375rem; line-height: 1.7;
    background: var(--bg); color: var(--text); border-color: var(--bg);
}
.type-card__button:hover { background: transparent; color: var(--bg); }
/* Mouse over / keyboard focus: image zooms, overlay deepens */
.type-card:hover .type-card__graphic,
.type-card:focus-within .type-card__graphic { transform: scale(1.06); }
.type-card:hover .type-card__tagline,
.type-card:focus-within .type-card__tagline { background: var(--overlay-strong); }
@media (prefers-reduced-motion: reduce) { .type-card__tagline, .type-card__graphic, .button { transition: none; } .type-card:hover .type-card__graphic, .type-card:focus-within .type-card__graphic { transform: none; } }

.button {
    display: inline-block; text-align: center;
    padding: 0.6rem 1.5rem;
    background: var(--accent); color: var(--bg);
    border: 1px solid var(--accent); border-radius: var(--r-pill);
    font-weight: 800; font-size: 1.125rem; text-decoration: none;
    transition: background 0.2s, color 0.2s;
}
.button:hover { background: var(--bg); color: var(--accent); }

/* Question box (homepage): one third of the cards row, theme colours only */
.ask { padding-block: clamp(1rem, 3vh, 2.5rem) 0; }
.ask--post { padding-block: 2rem 2.5rem; }
.ask__form {
    display: flex; gap: 0.5rem; align-items: stretch;
    inline-size: max(33.333%, 26rem); max-inline-size: 100%;
    margin-inline: auto;
}
.ask__input {
    flex: 1; min-inline-size: 0;
    min-block-size: 3rem;
    padding: 0.6rem 0.9rem;
    font: inherit; font-size: 0.9375rem; line-height: 1.6; color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line); border-radius: var(--r-field);
    resize: vertical;
}
.ask__input::placeholder { color: var(--muted); opacity: 1; }
.ask__input:focus { outline: none; border-color: var(--text); }
.ask__button {
    flex: 0 0 4.5rem; align-self: center; block-size: 2.25rem;
    font: inherit; font-size: 1.25rem; line-height: 1; font-weight: 800; color: var(--bg);
    background: var(--accent);
    border: 1px solid var(--accent); border-radius: var(--r-button); cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.ask__button:hover { background: var(--bg); color: var(--accent); }
.ask__button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Newsletter signup (footer, left side in RTL) */
.signup { text-align: start; max-inline-size: 100%; }
.signup__form {
    display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: stretch;
    inline-size: 26rem; max-inline-size: 100%;
}
.signup__field { position: relative; flex: 1; min-inline-size: 0; display: flex; }
.signup__hint {
    position: absolute; inset-block: 0; inset-inline: calc(0.9rem + 1px);
    display: flex; align-items: center;
    color: var(--muted); font-size: 0.9375rem; white-space: nowrap; overflow: visible;
    pointer-events: none;
}
.signup__input:not(:placeholder-shown) + .signup__hint { display: none; }
.signup__input {
    direction: rtl; text-align: start;
    inline-size: 100%; min-inline-size: 0;
    min-block-size: 3rem;
    padding: 0.6rem 0.9rem;
    font: inherit; font-size: 0.9375rem; line-height: 1.6; color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line); border-radius: var(--r-field);
}
.signup__input:focus { outline: none; border-color: var(--text); }
.signup__button {
    flex: 0 0 4.5rem; align-self: center; block-size: 2.25rem;
    display: grid; place-items: center;
    color: var(--bg); background: var(--accent);
    border: 1px solid var(--accent); border-radius: var(--r-button); cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.signup__button:hover { background: var(--bg); color: var(--accent); }
.signup__button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
/* Ghost adds .loading / .success / .error to the form */
.signup__form.loading .signup__button { opacity: 0.5; pointer-events: none; }
.signup__message { display: none; flex-basis: 100%; margin: 0.25rem 0 0; font-size: 0.9375rem; }
.signup__form.success .signup__message--success,
.signup__form.error .signup__message--error { display: block; }
.signup__form.success .signup__input,
.signup__form.success .signup__button { display: none; }

/* Landing pages and archives */
.landing-header { padding-block: 2rem 1.5rem; }
.landing-header__title { font-size: clamp(2rem, 6vw, 3rem); }
.landing-header__desc { color: var(--muted); max-inline-size: var(--narrow); margin: 0; }

.post-list { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.post-card { display: flex; flex-direction: column; gap: 0.75rem; }
.post-card__image img { inline-size: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--r-card); }
.post-card__title { font-size: 1.25rem; margin: 0; }
.post-card__title a { text-decoration: none; }
.post-card__excerpt { margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.8; }
.post-card__date { font-size: 0.875rem; color: var(--muted); }

.pagination { display: flex; justify-content: center; gap: 1rem; padding-block: 2.5rem; font-size: 1rem; }

/* Posts */
.post { padding-block: 2rem 1rem; }
.post__header { margin-block-end: 2rem; }
.post__type { margin: 0 0 0.5rem; font-weight: 700; font-size: 1rem; color: var(--muted); }
.post__type a { text-decoration: none; }
.post__title { font-size: clamp(2rem, 6vw, 3rem); }
.post__subtitle { font-size: 1.25rem; color: var(--muted); margin: 0 0 1rem; }
.post__meta { color: var(--muted); font-size: 0.9375rem; margin: 0; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.post__meta a { text-decoration: none; }
.post__image { margin: 0 0 2rem; }
.post__image img { inline-size: 100%; border-radius: var(--r-card); }
.post__image figcaption, .gh-content figcaption { text-align: center; color: var(--muted); font-size: 0.875rem; margin-block-start: 0.5rem; }

/* Content (Ghost editor output) */
.gh-content > * + * { margin-block-start: 1.5rem; }
.gh-content h2 { margin-block-start: 2.5rem; font-size: 1.75rem; }
.gh-content h3 { margin-block-start: 2rem; font-size: 1.375rem; }
.gh-content ul, .gh-content ol { padding-inline-start: 1.5rem; }
.gh-content blockquote {
    margin-inline: 0; padding-inline-start: 1.25rem;
    border-inline-start: 3px solid var(--text); color: var(--muted);
}
.gh-content pre, .gh-content code { direction: ltr; text-align: left; unicode-bidi: plaintext; }
.gh-content pre { overflow-x: auto; padding: 1rem; background: var(--band); border-radius: var(--r-card); }
.gh-content hr { border: 0; border-block-start: 1px solid var(--line); }
.gh-content table { inline-size: 100%; border-collapse: collapse; }
.gh-content th, .gh-content td { padding: 0.5rem; border-block-end: 1px solid var(--line); text-align: start; }

/* Koenig editor card widths (required by Ghost) */
.kg-width-wide, .kg-width-full { margin-inline: auto; }
@media (min-width: 900px) {
    .kg-width-wide { inline-size: min(var(--container), 90vw); margin-inline: calc(50% - min(var(--container), 90vw) / 2); }
    .kg-width-full { inline-size: 100vw; margin-inline: calc(50% - 50vw); }
}
.kg-width-full img { inline-size: 100%; }
.kg-image-card img, .kg-gallery-image img { margin-inline: auto; }
.kg-gallery-container { display: flex; flex-direction: column; gap: 0.5rem; }
.kg-gallery-row { display: flex; gap: 0.5rem; }
.kg-gallery-image { flex: 1 1 0; }
.kg-gallery-image img { inline-size: 100%; block-size: 100%; object-fit: cover; }
.kg-bookmark-card { border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.kg-bookmark-container { display: flex; text-decoration: none; }
.kg-bookmark-content { padding: 1rem; flex: 1; }
.kg-bookmark-title { font-weight: 800; }
.kg-bookmark-description, .kg-bookmark-metadata { color: var(--muted); font-size: 0.9375rem; line-height: 1.6; }
.kg-bookmark-thumbnail { flex: 0 0 30%; position: relative; }
.kg-bookmark-thumbnail img { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; object-fit: cover; }

/* Learn type: ordered list in the body is shown as a learning path */
.post--learn .gh-content > ol {
    list-style: none; padding: 0; margin-block: 2rem; counter-reset: step;
    border-inline-start: 2px solid var(--line); padding-inline-start: 1.5rem;
}
.post--learn .gh-content > ol > li { position: relative; counter-increment: step; padding-block: 0.75rem; }
.post--learn .gh-content > ol > li::before {
    content: counter(step, arabic-indic);
    position: absolute; inset-inline-start: calc(-1.5rem - 1px); inset-block-start: 0.85rem;
    transform: translateX(50%);
    inline-size: 2rem; block-size: 2rem; display: grid; place-items: center;
    background: var(--text); color: var(--bg); border-radius: 50%; font-size: 0.875rem; font-weight: 800;
}
[dir="rtl"] .post--learn .gh-content > ol > li::before { transform: translateX(50%); }

/* Progression to the next content type */
.next-step { margin-block: 3rem 1rem; padding: 1.5rem; border: 1px solid var(--line); border-radius: var(--r-card); }
.next-step__label { margin: 0 0 0.25rem; color: var(--muted); font-size: 1rem; }
.next-step__title { margin: 0 0 0.5rem; font-size: 1.5rem; line-height: 1.5; font-weight: 800; }
.next-step__link { font-weight: 800; font-size: 1.25rem; text-decoration: none; }

/* Know posts */
.post--know { padding-block-start: 2rem; }
/* No image: the title on the plain page */
.know-hero--no-image { margin-block-end: 2.5rem; }
.know-hero--no-image .know-hero__text { max-inline-size: 48rem; }
.know-hero__title { font-size: clamp(2.25rem, 5.5vw, 4.25rem); line-height: 1.25; font-weight: 800; margin: 0; }
/* With a feature image: full-width cover, title inset on top. The overlay is the text color at 65%,
   so white text keeps a contrast of about 5:1 or better even on a pure white picture. */
.know-hero--cover {
    position: relative; isolation: isolate;
    display: flex; align-items: flex-end;
    min-block-size: clamp(18rem, 55vh, 34rem);
    padding-block: clamp(1.5rem, 4vw, 3rem);
    color: var(--bg);
}
.know-hero--cover::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--overlay-cover); }
.know-hero__bg { position: absolute; inset: 0; z-index: -2; inline-size: 100%; block-size: 100%; object-fit: cover; }
.know-hero--cover .know-hero__text { max-inline-size: var(--container); }
.know-hero--cover .post__topics a { color: var(--bg); border-color: color-mix(in srgb, var(--bg) 70%, transparent); }
.know-hero--cover .post__topics a:hover { border-color: var(--bg); }
.post--know .know-hero--cover + .container--narrow { margin-block-start: 2.5rem; }
@media (max-width: 799px) { .know-hero__title { font-size: clamp(2rem, 9vw, 2.75rem); } }
/* the body text spans the full width of the page container (same width as the mosaic grid); */
.post--know > .container--narrow { max-inline-size: var(--container); }
.post--know .gh-content > p:first-child { font-size: 1.375rem; line-height: 1.8; font-weight: 700; }
.post__topics { list-style: none; margin: 0.75rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.post__topics a {
    display: inline-block; padding: 0 0.75rem; font-size: 0.875rem; line-height: 1.9; text-decoration: none;
    color: var(--muted); border: 1px solid var(--line); border-radius: var(--r-pill);
}
.post__topics a:hover { color: var(--text); border-color: var(--text); }
.link-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.link-list a { font-weight: 700; text-decoration: none; }
.link-list a:hover { text-decoration: underline; }

/* Related Discover posts mosaic (Know posts): up to six tiles that always fill one rectangle with aligned borders.
   The slots go from large to small (nth-child). assets/js/mosaic.js orders the tiles by reading time,
   so the longest post takes the largest slot; without the script they keep publishing order.
   The layout depends on the number of tiles (class mosaic--n1 ... mosaic--n6, set by the template).
   Desktop is a 4-column grid, phone a 2-column grid; rows are a fixed height.
   Desktop   n1: 4x2 | n2: 3x2 + 1x2 | n3: 2x2 + 2x1 + 2x1 | n4: 2x2 + 1x2 + 1x1 + 1x1
             n5: 3x2, 1x2 / 2x2, 1x2, 1x2 | n6: 3x2, 1x2 / 2x2, 1x2, 1x1 + 1x1 */
.related { margin-block: 3rem 0; }
.related__title { font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.5; font-weight: 800; margin: 0 0 1rem; }
.related__divider { border: 0; border-block-start: 1px solid var(--line); margin: 2.5rem 0 0; }
.related__divider--top { margin: 0 0 2rem; }
.related-end { margin-block-end: 1rem; }
.mosaic {
    --row: clamp(6.5rem, 15vw, 11rem);
    display: grid; gap: 0.75rem;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, var(--row));
}
.mosaic--n5, .mosaic--n6 { grid-template-rows: repeat(4, var(--row)); }
/* n1 */
.mosaic--n1 > :nth-child(1) { grid-column: 1 / span 4; grid-row: 1 / span 2; }
/* n2 */
.mosaic--n2 > :nth-child(1) { grid-column: 1 / span 3; grid-row: 1 / span 2; }
.mosaic--n2 > :nth-child(2) { grid-column: 4; grid-row: 1 / span 2; }
/* n3 */
.mosaic--n3 > :nth-child(1) { grid-column: 1 / span 2; grid-row: 1 / span 2; }
.mosaic--n3 > :nth-child(2) { grid-column: 3 / span 2; grid-row: 1; }
.mosaic--n3 > :nth-child(3) { grid-column: 3 / span 2; grid-row: 2; }
/* n4 */
.mosaic--n4 > :nth-child(1) { grid-column: 1 / span 2; grid-row: 1 / span 2; }
.mosaic--n4 > :nth-child(2) { grid-column: 3; grid-row: 1 / span 2; }
.mosaic--n4 > :nth-child(3) { grid-column: 4; grid-row: 1; }
.mosaic--n4 > :nth-child(4) { grid-column: 4; grid-row: 2; }
/* n5 and n6 share the first four slots */
.mosaic--n5 > :nth-child(1), .mosaic--n6 > :nth-child(1) { grid-column: 1 / span 3; grid-row: 1 / span 2; }
.mosaic--n5 > :nth-child(2), .mosaic--n6 > :nth-child(2) { grid-column: 1 / span 2; grid-row: 3 / span 2; }
.mosaic--n5 > :nth-child(3), .mosaic--n6 > :nth-child(3) { grid-column: 4; grid-row: 1 / span 2; }
.mosaic--n5 > :nth-child(4), .mosaic--n6 > :nth-child(4) { grid-column: 3; grid-row: 3 / span 2; }
.mosaic--n5 > :nth-child(5) { grid-column: 4; grid-row: 3 / span 2; }
.mosaic--n6 > :nth-child(5) { grid-column: 4; grid-row: 3; }
.mosaic--n6 > :nth-child(6) { grid-column: 4; grid-row: 4; }
/* Phone: 2 columns */
@media (max-width: 799px) {
    .mosaic { --row: clamp(7rem, 27vw, 8.75rem); grid-template-columns: repeat(2, 1fr); }
    .mosaic--n1 { grid-template-rows: repeat(2, var(--row)); }
    .mosaic--n2 { grid-template-rows: repeat(3, var(--row)); }
    .mosaic--n3 { grid-template-rows: repeat(4, var(--row)); }
    .mosaic--n4, .mosaic--n5 { grid-template-rows: repeat(5, var(--row)); }
    .mosaic--n6 { grid-template-rows: repeat(6, var(--row)); }
    .mosaic--n5 { grid-template-rows: repeat(6, var(--row)); }
    /* the first tile is always 2x2 across the top */
    .mosaic > :nth-child(1) { grid-column: 1 / span 2; grid-row: 1 / span 2; }
    .mosaic--n2 > :nth-child(2) { grid-column: 1 / span 2; grid-row: 3; }
    .mosaic--n3 > :nth-child(2) { grid-column: 1; grid-row: 3 / span 2; }
    .mosaic--n3 > :nth-child(3) { grid-column: 2; grid-row: 3 / span 2; }
    .mosaic--n4 > :nth-child(2) { grid-column: 1 / span 2; grid-row: 3; }
    .mosaic--n4 > :nth-child(3) { grid-column: 1; grid-row: 4 / span 2; }
    .mosaic--n4 > :nth-child(4) { grid-column: 2; grid-row: 4 / span 2; }
    .mosaic--n5 > :nth-child(2) { grid-column: 1 / span 2; grid-row: 3; }
    .mosaic--n5 > :nth-child(3) { grid-column: 1; grid-row: 4 / span 2; }
    .mosaic--n5 > :nth-child(4) { grid-column: 2; grid-row: 4 / span 2; }
    .mosaic--n5 > :nth-child(5) { grid-column: 1 / span 2; grid-row: 6; }
    .mosaic--n6 > :nth-child(2) { grid-column: 1 / span 2; grid-row: 3; }
    .mosaic--n6 > :nth-child(3) { grid-column: 1; grid-row: 4 / span 2; }
    .mosaic--n6 > :nth-child(4) { grid-column: 2; grid-row: 4 / span 2; }
    .mosaic--n6 > :nth-child(5) { grid-column: 1; grid-row: 6; }
    .mosaic--n6 > :nth-child(6) { grid-column: 2; grid-row: 6; }
}
.mosaic > :nth-child(n + 7) { display: none; }
.mosaic__tile { position: relative; overflow: hidden; border-radius: var(--r-card); background: var(--band); display: block; text-decoration: none; }
.mosaic__tile img { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; object-fit: cover; transition: transform 0.4s ease; }
.mosaic__tile:hover img, .mosaic__tile:focus-visible img { transform: scale(1.05); }
/* Title centered in the middle of the tile, in a box (text color at 65% behind white text: contrast 5:1 or better on any picture) */
.mosaic__label {
    position: absolute; inset-block-start: 50%; inset-inline: 0; margin-inline: auto; transform: translateY(-50%);
    inline-size: max-content; max-inline-size: 88%; text-align: center;
    padding: 0.4rem 0.9rem; border-radius: var(--r-field);
    background: var(--overlay-cover); color: var(--bg);
    font-weight: 700; font-size: 0.9375rem; line-height: 1.6;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.mosaic > :nth-child(1) .mosaic__label { font-size: 1.5rem; padding: 0.6rem 1.25rem; }
.mosaic--n1 > :nth-child(1) .mosaic__label { font-size: 1.75rem; }
.mosaic--n5 > :nth-child(2) .mosaic__label, .mosaic--n6 > :nth-child(2) .mosaic__label, .mosaic--n4 > :nth-child(1) .mosaic__label, .mosaic--n3 > :nth-child(1) .mosaic__label { font-size: 1.25rem; }
/* the small 1x1 tiles (n4: 3 and 4, n6: 5 and 6): a compact title, a little above the center, so it never touches the duration; */
.mosaic--n4 > :nth-child(n + 3) .mosaic__label, .mosaic--n6 > :nth-child(n + 5) .mosaic__label { inset-block-start: 42%; font-size: 0.875rem; padding: 0.3rem 0.7rem; -webkit-line-clamp: 2; }
/* Duration at the lower left corner (inline-end in RTL), hourglass first, same colors as the title box */
.mosaic__time {
    position: absolute; inset-block-end: 0.5rem; inset-inline-end: 0.5rem;
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.125rem 0.6rem; border-radius: var(--r-pill);
    background: var(--overlay-cover); color: var(--bg);
    font-size: 0.8125rem; line-height: 1.7; white-space: nowrap;
}
.mosaic__hourglass { flex: none; }
/* a post without a picture: a solid tile in the button color, text in the page background color, no boxes */
.mosaic__tile--no-image { background: var(--button); }
.mosaic__tile--no-image .mosaic__label, .mosaic__tile--no-image .mosaic__time { background: none; color: var(--bg); }
@media (prefers-reduced-motion: reduce) { .mosaic__tile img { transition: none; } .mosaic__tile:hover img { transform: none; } }

/* Error */
.error { text-align: center; padding-block: 5rem; }
.error__code { font-size: 4rem; font-weight: 800; margin: 0; color: var(--muted); }
.error__home { font-weight: 700; }

/* Owner-only check line under the related posts mosaic (setting "Show related posts check") */
.related__check { margin: 1rem 0 0; padding: 0.5rem 0.75rem; background: var(--band); border-radius: var(--r-field); color: var(--muted); font-size: 0.8125rem; line-height: 1.8; }
/* With placeholders off and no related posts, the whole section (divider, heading, grid) is left out */
.related:has(.mosaic[data-empty]) { display: none; }
/* further rectangles of the "all posts" mosaic (section Discover) */
.mosaic--next { margin-block-start: 0.75rem; }
