/*
    Competition Blog: posts from the ladder and competition organisers, for members only.
    docs/competition-blog-design.md; the screens are on the design canvas it links to.

    Linked from _Layout beside club-year.css. Colours come from site.css's :root tokens, the
    pale ones included (--club-main-tint, --club-main-soft, --club-main-line), so they follow the
    club's main colour.

    No inline styles anywhere: the CSP is style-src-attr 'none', and HtmlContentSanitizer.Sanitize
    strips style="" from a post's body, so everything a post shows is drawn from here.
*/

/* ---------- Hub tile: the "New" marker on Competition/Index ---------- */

.competition-primary-link__new {
    align-self: center;
    margin-left: auto;
    padding: 0.15rem 0.5rem;
    color: #ffffff;
    background: var(--club-main);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    line-height: 1.4;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ---------- The list of posts (CompetitionBlog/Index) ---------- */

.blog-intro {
    max-width: 46rem;
    margin: -0.25rem 0 1.5rem;
    color: var(--club-muted);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.6;
}

.blog-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
    margin-bottom: 2rem;
}

@media (min-width: 992px) {
    .blog-layout {
        grid-template-columns: minmax(0, 1fr) 300px;
        gap: 2rem;
    }
}

.blog-feed {
    display: grid;
    gap: 1rem;
}

.blog-filter-note {
    margin: 0;
    color: var(--club-muted);
    font-weight: 600;
}

.blog-card {
    position: relative;
    display: grid;
    gap: 0.6rem;
    padding: 1.35rem 1.5rem;
    background: var(--club-surface);
    border: 1px solid var(--club-line);
    border-radius: var(--club-radius);
    box-shadow: 0 5px 20px rgba(21, 37, 52, 0.07);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.blog-card:hover,
.blog-card:focus-within {
    border-color: var(--club-main-line);
    box-shadow: var(--club-shadow);
    transform: translateY(-1px);
}

.blog-card--pinned {
    background: #f7fbf9;
    border-color: #cfe6db;
}

.blog-card__top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.75rem;
}

.blog-card__title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.blog-card--lead .blog-card__title {
    font-size: 1.6rem;
    line-height: 1.22;
}

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

/* The whole card is the link, through the title's own anchor: one tab stop, one accessible name. */
.blog-card__title a::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

.blog-card__title a:hover {
    color: var(--club-main-dark);
}

.blog-card__title a:focus-visible {
    outline: none;
}

.blog-card__title a:focus-visible::after {
    outline: 3px solid rgba(23, 122, 87, 0.4);
    outline-offset: 2px;
}

.blog-card__excerpt {
    margin: 0;
    color: #3b4a5c;
    font-size: 1rem;
    line-height: 1.6;
}

.blog-card__more {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--club-main-dark);
    font-size: 0.92rem;
    font-weight: 750;
}

/* ---------- Date, author, reading time ---------- */

.blog-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem 1rem;
    margin: 0;
    padding: 0;
    color: var(--club-muted);
    font-size: 0.86rem;
    font-weight: 600;
    list-style: none;
}

.blog-meta li {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* ---------- Category and pinned tags ---------- */

.blog-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    color: #3b4a5c;
    background: #eef2f6;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    line-height: 1.4;
    text-transform: uppercase;
    text-decoration: none;
}

a.blog-tag:hover {
    text-decoration: underline;
}

/* The modifier is the category's key (CompetitionBlogVocabulary.Key), never its label. General has none. */
.blog-tag--rule-change {
    color: #6b4700;
    background: #fcefd2;
}

.blog-tag--rollover {
    color: #11606b;
    background: #e0f2f4;
}

.blog-tag--results {
    color: var(--club-main-dark);
    background: var(--club-main-tint);
}

.blog-tag--pinned {
    color: #ffffff;
    background: var(--club-main-dark);
}

/* ---------- Side column: categories and months ---------- */

.blog-aside {
    display: grid;
    gap: 1rem;
}

.blog-aside__panel {
    padding: 1.1rem 1.2rem;
    background: var(--club-surface);
    border: 1px solid var(--club-line);
    border-radius: var(--club-radius);
}

.blog-aside__panel h2 {
    margin: 0 0 0.7rem;
    color: var(--club-muted);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.blog-filter {
    display: grid;
    gap: 0.15rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.blog-filter a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 40px;
    padding: 0.4rem 0.6rem;
    color: var(--club-ink);
    border-radius: 6px;
    font-weight: 650;
    text-decoration: none;
}

.blog-filter a:hover {
    color: var(--club-main-dark);
    background: var(--club-main-soft);
}

.blog-filter a[aria-current="page"] {
    color: var(--club-main-dark);
    background: var(--club-main-tint);
}

.blog-filter__count {
    min-width: 1.7rem;
    padding: 0.05rem 0.45rem;
    color: #3b4a5c;
    background: #eef2f6;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 750;
    text-align: center;
}

/* ---------- Paging and the empty state ---------- */

.blog-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.blog-pagination a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.55rem 1rem;
    color: var(--club-main-dark);
    background: var(--club-surface);
    border: 1px solid var(--club-line);
    border-radius: var(--club-radius);
    font-weight: 700;
    text-decoration: none;
}

.blog-pagination a:hover {
    background: var(--club-main-soft);
    border-color: var(--club-main-line);
}

.blog-pagination__position {
    color: var(--club-muted);
    font-size: 0.9rem;
    font-weight: 650;
}

.blog-empty {
    display: grid;
    justify-items: center;
    gap: 0.5rem;
    padding: 3rem 1.5rem;
    color: var(--club-muted);
    background: var(--club-surface);
    border: 1px dashed var(--club-line);
    border-radius: var(--club-radius);
    font-weight: 600;
    text-align: center;
}

.blog-empty .bi {
    color: var(--club-main);
    font-size: 2rem;
}

.blog-empty strong {
    color: var(--club-ink);
    font-size: 1.1rem;
}

/* ---------- One post (CompetitionBlog/Post, and the administrator's preview) ---------- */

.blog-reading {
    display: grid;
    gap: 1.25rem;
    width: 100%;
    max-width: 50rem;
    margin: 0 auto 2.5rem;
}

.blog-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    justify-self: start;
    color: var(--club-main-dark);
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
}

.blog-back:hover {
    text-decoration: underline;
}

/* Shown only to an administrator of Competitions; the draft variant is the preview's. */
.blog-admin-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1rem;
    padding: 0.6rem 0.6rem 0.6rem 1rem;
    color: #3b4a5c;
    background: var(--club-surface);
    border: 1px solid var(--club-line);
    border-radius: var(--club-radius);
    font-size: 0.9rem;
    font-weight: 650;
}

.blog-admin-bar--draft {
    color: #5c4200;
    background: #fff8e6;
    border-color: #f1d9a0;
}

.blog-article {
    background: var(--club-surface);
    border: 1px solid var(--club-line);
    border-radius: var(--club-radius);
    box-shadow: 0 5px 20px rgba(21, 37, 52, 0.07);
    overflow: hidden;
}

.blog-article__header {
    display: grid;
    gap: 0.9rem;
    padding: 2.5rem 3rem 1.75rem;
    border-bottom: 1px solid var(--club-line);
}

.blog-article__title {
    margin: 0;
    color: var(--club-ink);
    font-size: 2.35rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.blog-article__standfirst {
    margin: 0;
    color: #3b4a5c;
    font-size: 1.18rem;
    line-height: 1.55;
}

.blog-byline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.blog-byline__avatar {
    display: grid;
    flex: none;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    color: var(--club-main-dark);
    background: var(--club-main-tint);
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: 800;
}

.blog-byline__name {
    display: block;
    color: var(--club-ink);
    font-weight: 750;
    line-height: 1.3;
}

.blog-article__body {
    padding: 2.25rem 3rem 2.5rem;
}

.blog-article__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 3rem;
    color: var(--club-muted);
    background: #f8fafc;
    border-top: 1px solid var(--club-line);
    font-size: 0.88rem;
    font-weight: 600;
}

.blog-pager {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.blog-pager a {
    display: grid;
    gap: 0.25rem;
    padding: 1rem 1.2rem;
    color: var(--club-ink);
    background: var(--club-surface);
    border: 1px solid var(--club-line);
    border-radius: var(--club-radius);
    text-decoration: none;
}

.blog-pager a:hover {
    background: #f7fbf9;
    border-color: var(--club-main-line);
}

.blog-pager__label {
    color: var(--club-muted);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.blog-pager__title {
    color: var(--club-main-dark);
    font-weight: 750;
    line-height: 1.35;
}

/* The newer post sits on the right, even when there is no older one on the left. */
.blog-pager__next {
    grid-column: 2;
    text-align: right;
}

/* ---------- The post body: what the organiser typed in the editor ---------- */

.blog-prose {
    max-width: 42rem;
    color: #243241;
    font-size: 1.0625rem;
    line-height: 1.75;
    overflow-wrap: break-word;
}

.blog-prose > :first-child {
    margin-top: 0;
}

.blog-prose > :last-child {
    margin-bottom: 0;
}

.blog-prose p {
    margin: 0 0 1.2rem;
}

.blog-prose h2 {
    margin: 2.4rem 0 0.8rem;
    color: var(--club-ink);
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.blog-prose h3 {
    margin: 2rem 0 0.6rem;
    color: var(--club-ink);
    font-size: 1.18rem;
    font-weight: 800;
    line-height: 1.35;
}

.blog-prose h4 {
    margin: 1.6rem 0 0.5rem;
    color: var(--club-ink);
    font-size: 1rem;
    font-weight: 800;
}

.blog-prose a {
    color: var(--club-main-dark);
    font-weight: 650;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.blog-prose a:hover {
    color: var(--club-main);
    text-decoration-thickness: 2px;
}

.blog-prose strong {
    color: var(--club-ink);
    font-weight: 750;
}

.blog-prose ul,
.blog-prose ol {
    margin: 0 0 1.2rem;
    padding-left: 1.4rem;
}

.blog-prose li {
    margin: 0 0 0.45rem;
    padding-left: 0.2rem;
}

.blog-prose li::marker {
    color: var(--club-main);
    font-weight: 700;
}

/*
    A quotation, and the Coloured panel an organiser picks from the editor's Styles menu. The
    panel's colours are site.css's (.content-callout and its --blue and --red); a colour set here
    would outrank them and turn every panel one colour.
*/
.blog-prose blockquote,
.blog-prose .content-callout {
    margin: 1.75rem 0;
    padding: 1.1rem 1.35rem;
    border-radius: var(--club-radius);
}

.blog-prose blockquote {
    background: var(--club-surface-soft);
    border: 1px solid var(--club-line);
}

.blog-prose blockquote > :last-child,
.blog-prose .content-callout > :last-child {
    margin-bottom: 0;
}

.blog-prose table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    font-size: 0.95rem;
    line-height: 1.5;
}

.blog-prose th,
.blog-prose td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--club-line);
    text-align: left;
    vertical-align: top;
}

.blog-prose th {
    color: var(--club-ink);
    background: #f8fafc;
    border-bottom-width: 2px;
    font-weight: 750;
}

.blog-prose tbody tr:nth-child(even) td {
    background: #fbfcfd;
}

/*
    Images, as the editor shows them (editor-content.css): a shadow unless marked Plain, and the
    Centred section and Framed image formats from the Styles menu. site.css draws those formats
    only inside .home-content and .content-section.
*/
.blog-prose img {
    max-width: 100%;
    height: auto;
}

.blog-prose .rich-content-image {
    display: block;
    margin: 1.5rem 0;
}

.blog-prose img:not(.content-image-plain) {
    border-radius: 12px;
    box-shadow: 0 14px 32px rgba(7, 23, 46, 0.22), 0 3px 8px rgba(7, 23, 46, 0.12);
}

.blog-prose .content-center {
    text-align: center;
}

.blog-prose .content-center .rich-content-image {
    margin-left: auto;
    margin-right: auto;
}

.blog-prose .content-image-frame {
    display: inline-block;
    max-width: 100%;
    margin: 1rem 0;
    padding: 0.75rem;
    background: #fff;
    border: 1px solid #d7e1ec;
    box-shadow: 0 8px 24px rgba(21, 37, 52, 0.08);
}

.blog-prose .content-image-frame img {
    display: block;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

.blog-prose figure {
    margin: 1.75rem 0;
}

.blog-prose figcaption {
    margin-top: 0.6rem;
    color: var(--club-muted);
    font-size: 0.88rem;
    text-align: center;
}

.blog-prose hr {
    margin: 2.5rem 0;
    border: 0;
    border-top: 1px solid var(--club-line);
    opacity: 1;
}

/* ---------- Phones ---------- */

@media (max-width: 575.98px) {
    .blog-intro {
        font-size: 1rem;
    }

    .blog-card,
    .blog-card--lead {
        padding: 1.1rem;
    }

    .blog-card__title {
        font-size: 1.15rem;
    }

    .blog-card--lead .blog-card__title {
        font-size: 1.3rem;
    }

    .blog-article__header {
        padding: 1.5rem 1.25rem 1.25rem;
    }

    .blog-article__title {
        font-size: 1.7rem;
    }

    .blog-article__standfirst {
        font-size: 1.05rem;
    }

    .blog-article__body {
        padding: 1.5rem 1.25rem 1.75rem;
    }

    .blog-article__footer {
        padding: 0.9rem 1.25rem;
    }

    .blog-prose {
        font-size: 1rem;
        line-height: 1.7;
    }

    .blog-prose h2 {
        margin-top: 2rem;
        font-size: 1.25rem;
    }

    /* A table wider than the phone scrolls inside the post rather than pushing the page sideways. */
    .blog-prose table {
        display: block;
        overflow-x: auto;
    }

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

    .blog-pager__next {
        grid-column: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .blog-card {
        transition: none;
    }

    .blog-card:hover,
    .blog-card:focus-within {
        transform: none;
    }
}

@media print {
    .app-header,
    .blog-aside,
    .blog-pager,
    .blog-admin-bar,
    .blog-back {
        display: none !important;
    }

    .blog-article {
        border: 0;
        box-shadow: none;
    }

    .blog-article__header,
    .blog-article__body {
        padding: 0 0 1rem;
    }
}
