/*!
 * Blog Design System Stylesheet — consolidated per D-03.
 * Uses sg-* tokens from content-pages.css.
 *
 * Merges blog-index.css, blog-show.css, and blog-author.css into a single
 * stylesheet loaded by BlogController for all blog page methods (index, show,
 * category, author). Old CSS files remain on disk until Plan 08-04 cleanup.
 *
 * Sections:
 *   1.  Blog layout foundation (ported from blog-index.css)
 *   2.  sg-card post variant (NEW, per D-04)
 *   3.  Article header styles for blog post pages (NEW, per D-01)
 *   4.  Post body content styles (ported from blog-show.css .post-content)
 *   5.  Post author box styles (ported from blog-show.css .post-author)
 *   6.  Post footer and related posts (ported from blog-show.css)
 *   7.  Author hero complementary styles (NEW, per D-02)
 *   8.  Author biography and posts section (ported from blog-author.css)
 *   9.  Responsive media queries (merged from all sources)
 *   10. Reduced motion (merged from all sources)
 */

/* ============================================================
 * Section 1 — Blog layout foundation (ported from blog-index.css)
 * ============================================================ */

.blog-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem 4rem;
}

.blog-filters {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 3rem;
}

/* Blog filter pills aligned to shared sg-pill design tokens */
.blog-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    padding: 12px 18px;
    border-radius: var(--sg-radius-md, 14px);
    background: rgba(255, 255, 255, 0.7);
    color: var(--sg-ink, #031E47);
    text-decoration: none;
    font-weight: 800;
    font-size: 0.95rem;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    border: 1px solid var(--sg-border, #e6edf5);
    box-shadow: 0 6px 18px rgba(3, 30, 71, 0.06);
}

.blog-filter:focus-visible {
    outline: 2px solid var(--sg-accent, #00DF7A);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0, 223, 122, 0.15);
}

.blog-filter:hover {
    background: var(--sg-ink, #031E47);
    color: #ffffff;
    border-color: var(--sg-ink, #031E47);
    box-shadow: 0 8px 24px rgba(3, 30, 71, 0.15);
    transform: translateY(-1px);
}

.blog-filter.active {
    background: var(--sg-ink, #031E47);
    color: #ffffff;
    border-color: var(--sg-ink, #031E47);
    box-shadow: 0 8px 24px rgba(3, 30, 71, 0.15);
}

.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: 2rem;
}

/* Legacy blog-card styles — backward-compatible port.
   Kept until Plan 08-04 converts index views to sg-card--post. */
.blog-card {
    background: var(--sg-surface);
    border-radius: var(--sg-radius-sm);
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--sg-border-soft);
}

.blog-card__image {
    height: 200px;
    background: var(--sg-surface-alt);
    overflow: hidden;
    display: block;
}

.blog-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.blog-card__image--placeholder {
    width: 100%;
    height: 100%;
    background: var(--sg-surface-alt);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--sg-border);
}

.blog-card__image--placeholder svg {
    width: 48px;
    height: 48px;
    margin-bottom: 0.5rem;
}

.blog-card__content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.blog-card__meta {
    font-size: 0.85rem;
    color: var(--sg-muted);
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.blog-card__category {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.blog-card__author {
    color: var(--sg-muted);
}

.blog-card__author a {
    color: inherit;
}

.blog-card__author a:hover {
    color: var(--sg-ink);
}

.blog-card__title {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--sg-ink);
}

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

.blog-card__excerpt {
    color: var(--sg-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    flex: 1;
    line-height: 1.6;
}

.blog-card__link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--sg-ink);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    min-height: 44px;
}

.blog-card__link:hover {
    color: var(--sg-accent);
}

.blog-empty {
    text-align: center;
    padding: 4rem 1rem;
    background: var(--sg-surface-alt);
    border-radius: var(--sg-radius-sm);
}

.blog-empty h3 {
    color: var(--sg-ink);
}

.blog-empty p {
    color: var(--sg-muted);
    margin-bottom: 2rem;
}

.blog-empty svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    color: var(--sg-border);
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 3rem;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    text-decoration: none;
    color: var(--sg-ink);
    background: var(--sg-surface-alt);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.page-link.active {
    background: var(--sg-accent);
    color: var(--sg-ink);
    font-weight: 700;
}

.page-link:hover:not(.active) {
    background: #e0e0e0;
}

/* ============================================================
 * Section 2 — sg-card post variant (NEW, per D-04)
 * Blog-specific variant of the sg-card base from content-pages.css.
 * Blog cards have full-bleed images, so padding is overridden to 0.
 * ============================================================ */

.sg-card--post {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
}

.sg-card__media {
    height: 200px;
    background: var(--sg-surface-alt);
    overflow: hidden;
    display: block;
}

.sg-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sg-card__media--placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--sg-surface-alt);
    color: var(--sg-border);
}

.sg-card__media--placeholder svg {
    width: 48px;
    height: 48px;
    margin-bottom: 0.5rem;
}

.sg-card__body {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sg-card__meta {
    font-size: 0.85rem;
    color: var(--sg-muted);
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.sg-card__category {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.sg-card__author {
    color: var(--sg-muted);
}

.sg-card__author a {
    color: inherit;
}

.sg-card__title {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--sg-ink);
}

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

.sg-card__excerpt {
    color: var(--sg-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    flex: 1;
    line-height: 1.6;
}

.sg-card__link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--sg-ink);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    min-height: 44px;
}

.sg-card__link:hover {
    color: var(--sg-accent);
}

/* ============================================================
 * Section 3 — Article header styles for blog post pages (NEW, D-01)
 * Article-style header (NOT sg-hero--dark) with sg-badge category,
 * sg-title headline, meta row, then featured image below.
 * ============================================================ */

.sg-article-header {
    padding: calc(3rem + var(--header-height, 100px)) 1rem 2.5rem;
    text-align: center;
    background: var(--sg-surface);
    border-bottom: 1px solid var(--sg-border-soft);
}

.sg-article-header__content {
    max-width: 800px;
    margin: 0 auto;
}

.sg-article-meta {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--sg-muted);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.sg-article-meta__category {
    background: rgba(0, 223, 122, 0.12);
    border: 1px solid rgba(0, 223, 122, 0.25);
    color: #00a65a;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-decoration: none;
}

.sg-article-meta__date {
    color: var(--sg-muted);
}

.sg-article-meta__reading-time {
    color: var(--sg-muted);
}

.sg-article-image {
    max-width: 1000px;
    margin: -1.5rem auto 3rem;
    padding: 0 1rem;
    position: relative;
    z-index: 3;
}

.sg-article-image img {
    width: 100%;
    border-radius: var(--sg-radius-md);
    box-shadow: var(--sg-shadow);
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: var(--sg-surface-alt);
}

.sg-article-image--placeholder {
    max-width: 720px;
}

/* ============================================================
 * Section 4 — Post body content styles (ported from blog-show.css)
 * Typography for article body. Hardcoded colours replaced with
 * sg-* tokens where equivalent tokens exist.
 * ============================================================ */

.post-content {
    max-width: 800px;
    margin: 0 auto 4rem;
    padding: 0 1rem;
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    line-height: 1.8;
    color: var(--sg-muted);
}

.post-content h2 {
    color: var(--sg-ink);
    margin-top: 2.5rem;
    margin-bottom: 1.25rem;
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    font-weight: 700;
}

.post-content h3 {
    color: var(--sg-ink);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: clamp(1.2rem, 2.5vw, 1.5rem);
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 2rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.post-content iframe,
.post-content iframe.youtube-embed {
    display: block;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    border: 0;
    border-radius: var(--sg-radius-sm);
    margin: 2rem 0;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.post-content iframe.youtube-embed--shorts {
    width: min(100%, 420px);
    aspect-ratio: 9 / 16;
    margin-inline: auto;
}

.post-content a {
    color: var(--sg-accent);
    font-weight: 600;
}

.post-content a:hover {
    color: var(--sg-ink);
}

.post-content blockquote {
    border-left: 4px solid var(--sg-accent);
    margin: 2rem 0;
    padding: 1rem 1.5rem;
    background: var(--sg-surface-alt);
    font-style: italic;
    color: var(--sg-muted);
    font-size: 1.1rem;
    border-radius: 0 8px 8px 0;
}

.post-content ul,
.post-content ol {
    margin-bottom: 2rem;
    padding-left: 1.5rem;
}

.post-content li {
    margin-bottom: 0.5rem;
}

.post-content table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.9rem;
    min-width: 640px;
}

.post-content th,
.post-content td {
    padding: 0.75rem;
    border: 1px solid var(--sg-border);
    text-align: left;
}

.post-content th {
    background: var(--sg-surface-alt);
    font-weight: 600;
    color: var(--sg-ink);
    white-space: nowrap;
}

.post-content pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 2rem 0;
}

.post-content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.875em;
}

.post-content :not(pre) > code {
    background: var(--sg-surface-alt);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: var(--sg-ink);
}

/* ============================================================
 * Section 5 — Post author box styles (ported from blog-show.css)
 * Author bio card shown at the foot of a blog post.
 * ============================================================ */

.post-author {
    max-width: 800px;
    margin: 0 auto 2.5rem;
    padding: 0 1rem;
}

.post-author__card {
    display: grid;
    gap: 1rem;
    grid-template-columns: auto 1fr;
    align-items: start;
    background: var(--sg-surface-alt);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius-lg);
    padding: 1.5rem;
}

.post-author__avatar {
    width: 64px;
    height: 64px;
    border-radius: 999px;
    background: linear-gradient(135deg, #031E47 0%, #0A2A5C 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    overflow: hidden;
}

.post-author__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-author__eyebrow {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sg-muted);
}

.post-author__name {
    margin: 0;
    color: var(--sg-ink);
    font-size: 1.15rem;
}

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

.post-author__role {
    margin: 0.25rem 0 0.75rem;
    color: var(--sg-muted);
    font-size: 0.95rem;
}

.post-author__bio {
    margin: 0;
    color: var(--sg-muted);
    font-size: 0.95rem;
}

.post-author__links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.85rem;
}

.post-author__links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--sg-ink);
    font-weight: 600;
}

/* ============================================================
 * Section 6 — Post footer and related posts (ported from blog-show.css)
 * Back link, related-posts section, and related-post card styling.
 * ============================================================ */

.post-footer {
    max-width: 800px;
    margin: 0 auto 3rem;
    padding: 0 1rem;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 44px;
    color: var(--sg-ink);
    font-weight: 600;
}

.btn-back:hover {
    color: var(--sg-accent);
}

.post-related {
    background: var(--sg-surface-alt);
    padding: 4rem 1rem;
}

.post-related__container {
    max-width: 1200px;
    margin: 0 auto;
}

.post-related__heading {
    color: var(--sg-ink);
    margin-bottom: 2rem;
    text-align: center;
    font-size: clamp(1.5rem, 3vw, 2rem);
}

.post-related__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.post-related__card {
    background: var(--sg-surface);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius-lg);
    box-shadow: var(--sg-shadow);
    overflow: hidden;
}

.post-related__card a {
    display: block;
    height: 100%;
}

.post-related__image {
    background: var(--sg-border);
    min-height: 180px;
}

.post-related__image img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.post-related__body {
    padding: 1.25rem;
}

.post-related__title {
    margin: 0 0 0.75rem;
    color: var(--sg-ink);
    font-size: 1.05rem;
}

.post-related__excerpt {
    color: var(--sg-muted);
    font-size: 0.92rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.post-related__link {
    color: var(--sg-ink);
    font-weight: 600;
}

/* ============================================================
 * Section 7 — Author hero complementary styles (NEW, per D-02)
 * Complements the sg-hero--dark base from content-pages.css for
 * the author page. Avatar, meta, and links sit inside the dark hero.
 * ============================================================ */

.sg-author-avatar {
    width: 120px;
    height: 120px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    margin: 0 auto 1.5rem;
}

.sg-author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sg-author-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin-top: 1.25rem;
    color: rgba(234, 245, 255, 0.75);
    justify-content: center;
}

.sg-author-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
    justify-content: center;
}

.sg-author-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
}

.sg-author-links a:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================================
 * Section 8 — Author biography and posts section (ported from blog-author.css)
 * Biography card and posts listing header below the author hero.
 * ============================================================ */

.author-biography {
    padding: 2rem 1rem 0;
}

.author-biography__container {
    max-width: 1100px;
    margin: 0 auto;
}

.author-biography__card {
    background: var(--sg-surface-alt);
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius-lg);
    padding: 1.5rem;
    color: var(--sg-muted);
}

.author-biography__card h2 {
    margin: 0 0 1rem;
    color: var(--sg-ink);
}

.author-biography__card p {
    margin: 0;
    line-height: 1.8;
}

.author-posts {
    padding: 2.5rem 0 4rem;
}

.author-posts__header {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.author-posts__header h2 {
    margin: 0;
    color: var(--sg-ink);
}

/* ============================================================
 * Section 9 — Responsive media queries (merged from all sources)
 * ============================================================ */

/* blog-index.css — small screens reduce card image height and content padding */
@media (max-width: 480px) {
    .blog-card__image,
    .sg-card__media {
        height: 180px;
    }

    .blog-card__content,
    .sg-card__body {
        padding: 1.25rem;
    }

    .blog-card__title,
    .sg-card__title {
        font-size: 1.1rem;
    }
}

/* blog-show.css — author card single column, related posts padding */
@media (max-width: 767px) {
    .post-author__card {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .post-author__avatar {
        margin: 0 auto;
    }

    .post-author__links {
        justify-content: center;
    }

    .post-related {
        padding: 3rem 1rem;
    }
}

/* blog-author.css — author hero avatar centred on small screens.
   sg-author-avatar is already margin-centred, so this ensures the
   hero card layout stacks cleanly. */
@media (max-width: 767px) {
    .sg-author-meta,
    .sg-author-links {
        justify-content: center;
    }
}

/* ============================================================
 * Section 10 — Reduced motion (merged from all sources)
 * ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .blog-filter,
    .page-link,
    .sg-card__link,
    .btn-back {
        transition: none;
    }
}
