/* =========================================================
   Components shared by archives and posts (Mubert Home look)
   ========================================================= */

.page-width {
    width: 100%;
    max-width: var(--page-max);
    margin-inline: auto;
    padding-inline: 10px;
    box-sizing: border-box;
}

/* ---------- Archive hero ---------- */

.archive-hero {
    padding: 48px 0 64px;
}

.archive-hero__inner {
    max-width: 760px;
    margin-inline: auto;
    padding-inline: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    text-align: center;
}

.archive-hero__intro {
    max-width: 640px;
    color: var(--c-text-muted);
    text-wrap: pretty;
}

/* ---------- "Generate Free Track" widget (Mubert Home composer) ---------- */

.generate-widget {
    width: 100%;
    max-width: 720px;
    margin: 16px auto 0;
    text-align: left;
}

.generate-widget .generate-form {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px 12px;
    padding: 12px 12px 12px 18px;
    border-radius: var(--r-lg);
    background: var(--c-surface);
    box-shadow: 0 0 0 1px rgb(85 93 255 / 0), 0 0 0 6px rgb(85 93 255 / 0), 0 8px 20px var(--c-shadow);
    transition: box-shadow 0.25s ease;
}

.generate-widget .generate-form:hover {
    box-shadow: 0 0 0 1px var(--c-line-strong), 0 0 0 6px rgb(85 93 255 / 0), 0 8px 20px var(--c-shadow);
}

.generate-widget .generate-form:focus-within {
    box-shadow: 0 0 0 2px var(--c-brand), 0 0 0 6px rgb(85 93 255 / 0.18), 0 10px 28px rgb(85 93 255 / 0.22);
}

.generate-widget #promptSection {
    flex: 1 1 260px;
    min-width: 0;
    align-self: stretch;
}

.generate-widget #prompt {
    display: block;
    width: 100%;
    height: 56px;
    padding: 6px 0 0;
    border: 0;
    outline: 0;
    background: none;
    resize: none;
    font: inherit;
    font-size: var(--fs-md);
    line-height: var(--lh-normal);
    color: var(--c-text);
    caret-color: var(--c-brand);
}

.generate-widget #generateBtn {
    height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    border: 0;
    border-radius: var(--r-md);
    background: var(--c-brand);
    color: #fff;
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 6px 20px -6px rgba(85, 93, 255, 0.5);
    transition: transform var(--ease), filter var(--ease);
}

.generate-widget #generateBtn:hover {
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.generate-widget #generateBtn img {
    width: 16px;
    height: 16px;
}

/* Cloudflare Turnstile debug status: kept in the DOM for the widget script, not shown */
.generate-widget #turnstile-status {
    display: none;
}

.generate-widget .generate-result:not(:empty) {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: var(--r-md);
    background: var(--c-surface);
    color: var(--c-text);
    font-size: var(--fs-sm);
    word-break: break-word;
}

/* Link to the prompt library (page /music-prompts) under the composer */
.generate-widget__ideas {
    display: block;
    width: fit-content;
    margin: 12px auto 0;
    font-size: var(--fs-sm);
    color: var(--c-text-muted);
    text-decoration: none;
    transition: color var(--ease);
}

.generate-widget__ideas:hover {
    color: var(--c-icon);
}

/* ---------- Feed: category pills, card grid, pagination, topics ---------- */

.feed {
    padding: 0 0 72px;
}

.category-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
}

.post-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--gap);
}

/* ---------- Post card ---------- */

.post-card {
    --tint: var(--c-brand);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 10px 10px 22px;
    border-radius: var(--r-md);
    background: var(--c-surface);
    transition: background-color var(--ease);
}

.post-card:hover {
    background: var(--c-surface-hover);
}

.post-card__cover {
    position: relative;
    display: block;
    aspect-ratio: 1.9 / 1;
    overflow: hidden;
    border-radius: 10px;
    background: var(--c-bg);
}

.post-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s cubic-bezier(0.2, 0, 0, 1);
}

.post-card:hover .post-card__cover img {
    transform: scale(1.03);
}

/* Posts without a featured image: the empty cover background, a flat ground with the isometric
   grid (lines at +/-30 degrees, ~18 diamonds across a card), as in tools/covers/background.mjs */
.post-card__cover--generated {
    background-color: var(--c-bg);
    background-image:
        repeating-linear-gradient(60deg, var(--c-grid) 0 1px, transparent 1px 11px),
        repeating-linear-gradient(120deg, var(--c-grid) 0 1px, transparent 1px 11px);
}

.post-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 0 6px;
    color: var(--c-text-muted);
}

/* Neutral by default; the four rubrics (inc/categories.php) get a quiet colour-code pill: a light
   wash of the rubric colour, text in the rubric colour pulled towards the text colour so acid and
   yellow stay readable on the light theme */
.post-card__tag {
    position: relative;
    z-index: 1;
    padding: 2px 8px;
    border-radius: 100px;
    background: var(--c-overlay);
    color: var(--c-text-muted);
    text-decoration: none;
}

.post-card__tag--rubric {
    background: color-mix(in srgb, var(--tint) 14%, transparent);
    color: color-mix(in srgb, var(--tint) 50%, var(--c-text));
}

[data-theme="dark"] .post-card__tag--rubric {
    color: color-mix(in srgb, var(--tint) 85%, var(--c-text));
}

.post-card__title {
    padding: 0 6px;
    font-size: var(--fs-lg);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card__title a {
    color: inherit;
    text-decoration: none;
}

/* The whole card is clickable through the title link */
.post-card__title a::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--r-md);
}

.post-card__excerpt {
    padding: 0 6px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* The first post of a page: across the whole row, cover on the left, text on the right */
.post-card--featured {
    grid-column: 1 / -1;
}

@media (min-width: 769px) {
    .post-card--featured {
        display: grid;
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
        grid-template-rows: 1fr auto auto auto 1fr;
        column-gap: 40px;
        row-gap: 14px;
        padding: 10px 40px 10px 10px;
    }

    .post-card--featured .post-card__cover {
        grid-column: 1;
        grid-row: 1 / -1;
    }

    .post-card--featured .post-card__meta {
        grid-column: 2;
        grid-row: 2;
    }

    .post-card--featured .post-card__title {
        grid-column: 2;
        grid-row: 3;
        font-size: var(--fs-h2);
        line-height: var(--lh-snug);
        letter-spacing: -0.02em;
        -webkit-line-clamp: 3;
    }

    .post-card--featured .post-card__excerpt {
        grid-column: 2;
        grid-row: 4;
        font-size: var(--fs-md);
        -webkit-line-clamp: 4;
    }
}

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 40px;
}

.pagination a,
.pagination span {
    min-width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    padding: 0 12px;
    border-radius: var(--r-md);
    box-sizing: border-box;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--c-text);
    text-decoration: none;
    box-shadow: inset 0 0 0 1px var(--c-line);
    transition: background-color var(--ease), box-shadow var(--ease);
}

.pagination a:hover {
    background: var(--c-surface-hover);
    box-shadow: inset 0 0 0 1px var(--c-line-strong);
}

.pagination span {
    background: var(--c-brand);
    color: #fff;
    box-shadow: none;
}

/* ---------- Topics (tag cloud) ---------- */

.topics {
    margin-top: 72px;
    padding: 32px;
    border-radius: var(--r-lg);
    background: var(--c-surface);
}

.topics__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.topics__list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topics__list a {
    padding: 6px 12px;
    border-radius: 100px;
    background: var(--c-overlay);
    color: var(--c-text-muted);
    font-size: var(--fs-sm);
    line-height: 1.2;
    text-decoration: none;
    transition: color var(--ease), background-color var(--ease);
}

.topics__list a:hover {
    color: var(--c-text);
    background: var(--c-surface-hover);
}

.topics details summary {
    width: fit-content;
    margin-top: 16px;
    color: var(--c-brand);
    font-size: var(--fs-sm);
    cursor: pointer;
    list-style: none;
}

.topics details summary::-webkit-details-marker {
    display: none;
}

.topics details[open] summary {
    display: none;
}

.topics details .topics__list {
    margin-top: 8px;
}

/* ---------- Related posts (single) ---------- */

.related {
    padding: 72px 0;
}

.related__title {
    margin-bottom: 28px;
}

/* ---------- Responsive ---------- */

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

@media (max-width: 768px) {
    .archive-hero {
        padding: 24px 0 40px;
    }

    .category-nav {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        scrollbar-width: none;
        margin-inline: -10px;
        padding-inline: 10px;
    }

    .category-nav::-webkit-scrollbar {
        display: none;
    }

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

    .post-card {
        padding: 8px 8px 18px;
        gap: 12px;
    }

    .topics {
        margin-top: 48px;
        padding: 20px;
    }

    .generate-widget #generateBtn {
        width: 100%;
        justify-content: center;
    }
}
