/* Blog Specific Styles - Distinct "Journal" Look
 *
 * The blog keeps the portal's chrome, layout, type and yellow accent, and keeps its own surfaces:
 * a light grey page with white paper in the light theme, a dark grey page with #2f2f2f paper in the
 * dark one. Both are declared as light-dark() pairs below, so the section follows the theme like
 * every other page instead of pinning one scheme.
 */

:root {
    /* The blog keeps its own greys, but they follow the theme now instead of forcing the dark set:
     * the light surface is its original light grey, the dark surface the dark grey it had, and every
     * pair is a light-dark() of the two. No color-scheme override, so the bar, the footer and the
     * embedded components show their light or dark values exactly like the rest of the portal. */
    --blog-bg: light-dark(#f0f0f0, #262626);
    --blog-paper: light-dark(#ffffff, #2f2f2f);
    --blog-text: light-dark(#1a1a1a, #f2f2f2);
    --blog-text-secondary: light-dark(#555555, #b0b0b0);
    --blog-accent: #FFC107;
    /* #FFC107 is 1.6:1 on the white paper and 11.3:1 on the dark grey, so it can only be the ink on
     * one of them - this token is the accent that is readable in either (see styles.css). */
    --blog-accent-ink: var(--accent-on-surface);
    --blog-line: light-dark(#e0e0e0, #3f3f3f);
    --blog-font-serif: var(--font-family);
}

body.blog-page {
    background-color: var(--blog-bg);
    color: var(--blog-text);
    --bg-color: var(--blog-bg); /* Override main variables */
    --text-primary: var(--blog-text);
    --border-color: var(--blog-line);
}

/* The blog header is the same bar as the rest of the portal, drawn from the same token - no
 * hard-coded rgba() here: that is what kept the blog bar white in dark mode (luma 234). */
.blog-page .site-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
}

/* Was a #222 box behind the wordmark, from when the bar was white and the glyphs light. The bar is
 * dark now, so the lockup is just the portal's: ink on the bar, no box. */
.blog-page .logo {
    color: var(--text-primary);
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.blog-page .logo-text-svg {
    background-color: transparent;
    padding: 0;
    height: 32px;
    width: auto;
}

.blog-page .main-nav a {
    color: var(--text-secondary);
}

.blog-page .main-nav a:hover {
    color: var(--blog-accent-ink);
}

/* Blog Layout */
.blog-hero {
    padding: 120px 0 60px;
    text-align: center;
    background-image: radial-gradient(var(--blog-line) 1px, transparent 1px);
    background-size: 20px 20px;
    border-bottom: 1px solid var(--blog-line);
}

.blog-hero h1 {
    font-family: var(--blog-font-serif);
    font-size: 4rem;
    margin-bottom: 16px;
    letter-spacing: -0.03em;
}

.blog-hero p {
    color: var(--blog-text-secondary);
    font-size: 1.2rem;
    max-width: 600px;
    margin: 0 auto;
}

.blog-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 40px;
    padding: 60px 0;
}

/* Featured Post (Spans full width) */
/* Regular Posts */
.post-card {
    grid-column: span 4;
    background: var(--blog-paper);
    border: 1px solid var(--blog-line);
    display: flex;
    flex-direction: column;
    transition: all 0.2s;
    cursor: pointer;
}

.post-card:hover {
    border-color: var(--blog-text);
    box-shadow: 5px 5px 0px light-dark(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.3));
    transform: translateY(-2px);
}

.post-image {
    position: relative;
}

.post-image .post-image__img {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: light-dark(#ddd, #3a3a3a);
    border-bottom: 1px solid var(--blog-line);
    filter: grayscale(100%);
    transition: filter 0.3s;
    display: block;
    position: relative;
}


.post-card:hover .post-image::after {
    inset: 0;
    position: absolute;
    /* filter: grayscale(0%) sepia(100%) brightness(90%); */
    content: ''; 
    /* rgba() of a custom property that holds a hex colour resolves to nothing; same 50% tint. */
    background-color: color-mix(in srgb, var(--accent-yellow) 50%, transparent);
    /* background-blend-mode: multiply; */
    /* pointer-events: none; */
    /* opacity: 0.6; */
}

.post-card [role="img"] {
    position: relative;
}

.post-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.post-meta {
    font-size: 0.8rem;
    color: var(--blog-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.post-tag {
    color: var(--blog-accent-ink);
    font-weight: 600;
}

.post-title {
    font-family: var(--blog-font-serif);
    font-size: 1.5rem;
    margin-bottom: 12px;
    line-height: 1.3;
}

.post-title a {
    color: var(--blog-text);
    text-decoration: none;
}

.post-excerpt {
    color: var(--blog-text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 20px;
    flex: 1;
}

.read-more {
    font-weight: 500;
    color: var(--blog-text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
}

.read-more:hover {
    color: var(--blog-accent-ink);
}

/* Footer Override */
.blog-page .site-footer {
    /* Was a hard-coded #e5e5e5, which is a second, unrelated grey next to the portal's chrome. */
    background: var(--chrome-bg);
    border-top: 1px solid var(--header-border);
}

.blog-page .footer-brand p, 
.blog-page .footer-links a {
    color: var(--blog-text-secondary);
}

.blog-page .footer-links a:hover {
    color: var(--blog-accent-ink);
}

@media (max-width: 900px) {
    .post-card {
        border-radius: 10px;
        overflow: hidden;
        /* Two columns on a tablet, one on a phone (below). The old span 6 / span 12 counted columns
         * that a single-column grid does not have - span 12 there creates implicit columns. */
        grid-column: span 1;
    }

    .post-image .post-image__img {
        aspect-ratio: 16 / 10;
    }

    .post-content {
        padding: 20px;
    }

    .post-title {
        font-size: 1.4rem;
        line-height: 1.25;
    }

    /* The tag becomes a pill: on a phone it is the first thing the eye lands on, and a bare line of
     * accent text was too easy to miss. */
    .post-tag {
        background-color: color-mix(in srgb, var(--blog-accent) 16%, transparent);
        border: 1px solid color-mix(in srgb, var(--blog-accent) 35%, transparent);
        border-radius: 999px;
        padding: 2px 8px;
    }

    /* Full-width tap target with the arrow pushed right, instead of a ~90px text link. The summary's
     * margin is evened out with the padding here (16px each side of the rule), so the divider sits
     * in the middle of its own whitespace instead of 20px above it and 14px below. */
    .post-excerpt {
        margin-bottom: 16px;
    }

    .read-more {
        justify-content: space-between;
        width: 100%;
        padding-top: 16px;
        border-top: 1px solid var(--blog-line);
    }
}

@media (max-width: 700px) {
    /* One card per row, edge to edge of the phone gutter. */
    .post-card {
        grid-column: 1 / -1;
    }
}

@media (max-width: 600px) {
    .blog-hero h1 {
        font-size: 2.5rem;
    }
}

/* Blog Detail Page Styles */
.blog-cover-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    margin-bottom: 40px;
    border-radius: 8px;
}

.blog-article-content {
    color: var(--blog-text);
    line-height: 1.8;
}

.blog-article-content h1,
.blog-article-content h2,
.blog-article-content h3,
.blog-article-content h4,
.blog-article-content h5,
.blog-article-content h6 {
    margin-top: 32px;
    margin-bottom: 16px;
    color: var(--blog-text);
}

.blog-article-content h1:first-child {
    margin-top: 0;
}

.blog-article-content p {
    margin-bottom: 16px;
    color: var(--blog-text);
}

.blog-article-content a {
    /* Outline treatment: the ink stays readable, the accent is the underline. */
    color: var(--accent-on-surface);
    text-decoration: underline;
    text-decoration-color: var(--accent-yellow);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

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

.blog-article-content code {
    background-color: color-mix(in srgb, var(--blog-accent) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--blog-accent) 18%, transparent);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--blog-text);
}

.blog-article-content pre {
    /* No background on purpose: .astro-code in styles.css sets background-color: var(--bg-color)
     * with !important, and inside the blog --bg-color *is* the page, so a code block reads as the
     * page colour with its own border - the same treatment it gets on the docs pages. A hard-coded
     * background here would be a dead declaration. */
    border: 1px solid var(--blog-line);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.blog-article-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.9rem;
    color: #e6e6e6;
}

.blog-article-content blockquote {
    border-left: 4px solid var(--accent-yellow);
    padding-left: 16px;
    margin-left: 0;
    margin-bottom: 16px;
    color: var(--blog-text-secondary);
    font-style: italic;
}

.blog-article-content ul,
.blog-article-content ol {
    margin-left: 20px;
    margin-bottom: 16px;
}

.blog-article-content li {
    margin-bottom: 8px;
    color: var(--blog-text);
}

.blog-article-content img {
    max-width: 100%;
    height: auto;
    margin-bottom: 16px;
    border-radius: 8px;
}

.blog-footer {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--blog-line);
    color: var(--blog-text-secondary);
}

.blog-footer a {
    /* Outline treatment: the ink stays readable, the accent is the underline. */
    color: var(--accent-on-surface);
    text-decoration: underline;
    text-decoration-color: var(--accent-yellow);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

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

/* Enhanced TOC Navigation Styling */
.blog-detail-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.blog-detail-toc li {
    margin: 0;
    padding: 0;
}

.blog-detail-toc a {
    display: block;
    padding: 10px 14px;
    color: var(--blog-text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    border-left: 3px solid transparent;
    transition: all 0.3s;
    position: relative;
}

.blog-detail-toc a:hover {
    color: var(--blog-accent-ink);
    border-left-color: var(--accent-yellow);
    padding-left: 20px;
    text-decoration: underline;
    text-decoration-color: var(--accent-yellow);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.blog-detail-toc a.active {
    color: var(--blog-accent-ink);
    border-left-color: var(--accent-yellow);
    background: color-mix(in srgb, var(--blog-accent) 8%, transparent);
    font-weight: 600;
}

/* View Transitions for Blog Posts */
/* Assign view-transition-name to the card on the blog overview page */
.post-card .post-image__img {
    view-transition-name: blog-image;
}

.post-card .post-title {
    view-transition-name: blog-title;
    width: fit-content;
}

/* Assign matching view-transition-name to elements on the blog detail page */
.blog-cover-image {
    view-transition-name: blog-image;
}

.blog-article-header h1 {
    view-transition-name: blog-title;
    width: fit-content;
}

/* Custom animation */
::view-transition-group(blog-image),
::view-transition-group(blog-title) {
    animation-duration: 0.4s;
    animation-timing-function: cubic-bezier(0.2, 0, 0.2, 1);
}
