/* ===================================================================
   Blog Post Content (used as fragment inside Resources SPA)
   =================================================================== */

.post-container-wrapper {
    margin-top: 24px;
    display: flex;
    justify-content: center;
}

.post-container {
    max-width: 800px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 20px;
}

.post-image {
    width: 256px;
    height: 256px;
    image-rendering: pixelated;
    object-fit: cover;
    object-position: center;
    display: block;
    flex-shrink: 0;
}

/* Safely center standalone images in the middle of the article */
.post-content p:has(> .article-gallery-link:only-child) {
    text-align: center;
    margin: 32px 0;
    display: block;
    width: 100%;
}

/* Make sure figure block images stay aligned properly and don't get centered */
.figure-image p {
    margin: 0;
    line-height: 0;
    text-align: left !important;
}

.post-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: left;
    flex: 1;
    min-width: 0;
}

.post-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 22px;
    line-height: 1.4;
    color: var(--text-color);
}

.post-date {
    color: var(--text-color4-t);
    font-size: 14px;
    margin-top: 5px;
}

.post-content-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    margin-bottom: 64px;
}

.post-content {
    font-size: 17px;
    color: var(--text-color);
    line-height: 1.75;
    max-width: 720px;
    width: 100%;
    min-width: 0;
    text-align: left;
    overflow-wrap: break-word;
}

/* --- Paragraphs --- */
.post-content p {
    margin: 0 0 1.15em;
}

.post-content p + p {
    margin-top: 0;
}

/* --- Emphasis --- */
.post-content strong {
    color: inherit;
    font-weight: 700;
}

.post-content .pixie-brand {
    font-family: 'Press Start 2P', monospace;
    color: var(--contrast-color);
    text-transform: lowercase;
    font-size: 0.72em;
    letter-spacing: 0.02em;
    white-space: nowrap;
    vertical-align: -0.1em;
}

.post-content .pixie-brand--repeat {
    color: var(--text-color);
}

.post-content em {
    color: var(--text-color);
    opacity: 0.92;
}

/* --- Headings --- */
.post-content h2,
.post-content h3,
.post-content h4 {
    color: var(--text-color);
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.post-content h2 {
    font-size: 28px;
    font-weight: 700;
    margin: 2.4em 0 0.7em;
}

.post-content h3 {
    font-size: 21px;
    font-weight: 700;
    margin: 1.9em 0 0.55em;
}

.post-content h4 {
    font-size: 18px;
    font-weight: 600;
    margin: 1.6em 0 0.5em;
}

/* --- Lists --- */
.post-content ul,
.post-content ol {
    margin: 0 0 1.3em;
    padding-left: 1.5em;
}

.post-content li {
    margin: 0.45em 0;
    padding-left: 0.25em;
}

.post-content ol {
    list-style: none;
    padding-left: 2em;
    counter-reset: ol-counter;
}

.post-content ol > li {
    position: relative;
    counter-increment: ol-counter;
}

.post-content ol > li::before {
    content: counter(ol-counter) ".";
    position: absolute;
    left: -2em;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.75em;
    color: var(--contrast-color);
    white-space: nowrap;
}

.post-content ol ol > li::before {
    color: var(--text-color3-t);
}

.post-content ul {
    list-style: none;
    padding-left: 1.25em;
}

.post-content ul > li {
    position: relative;
}

.post-content ul > li::before {
    content: "";
    position: absolute;
    left: -1em;
    top: 0.7em;
    width: 7px;
    height: 7px;
    background: var(--contrast-color);
}

.post-content ul ul > li::before {
    background: var(--text-color3-t);
}

.post-content li > ul,
.post-content li > ol {
    margin: 0.4em 0 0.4em;
}


/* --- Resource link cards --- */
.post-content .resource-link-group {
    margin: 1.5em 0;
}

.post-content .resource-link-group .article-card-text h3 {
    margin: 8px 0 8px;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.post-content .resource-link-group .article-card-text p {
    margin: 0 0 4px;
    
}


/* --- Inline code & preformatted --- */
.post-content code {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 0.92em;
    padding: 0.12em 0.45em;
    background: var(--text-color2-t);
    border: 1px solid var(--text-color3-t);
    border-radius: 3px;
    color: var(--text-color);
    white-space: nowrap;
}

.post-content pre {
    background: var(--text-color2-t);
    border: 1px solid var(--text-color3-t);
    padding: 18px 20px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1.5em 0;
    font-size: 14px;
    line-height: 1.6;
    max-width: 100%;
    box-sizing: border-box;
    white-space: pre-wrap;
    word-break: break-all;
}

.post-content pre code {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    white-space: pre-wrap;
    font-size: inherit;
    vertical-align: baseline;
}

/* --- Blockquotes --- */
.post-content blockquote {
    margin: 1.5em 0;
    padding: 0.6em 1.2em;
    border: 1px solid var(--text-color4-t);
    border-radius: 8px;
    background: var(--text-color2-t);
    font-style: italic;
    color: var(--text-color4-t);
    opacity: 0.95;
}

.post-content blockquote p:last-child {
    margin-bottom: 0;
}

/* --- Links --- */
.post-content a {
    color: var(--text-color);
    text-decoration: none;
    cursor: cell;
}
.post-content a:hover {
    font-weight: 600;
}

/* --- Horizontal rule --- */
.post-content hr {
    border: none;
    height: 2px;
    margin: 2.5em auto;
    background: var(--text-color3-t);
}

/* --- Tables --- */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 15px;
    border: 1px solid var(--text-color-t);


    
}

.post-content th,
.post-content td {
    padding: 10px 14px;
    text-align: left;
}

.post-content th {
    font-weight: 700;
    background: var(--text-color2-t);
}

.post-content tbody tr:nth-child(even) {
    background: var(--text-color-t);
}

/* --- FAQ --- */
.post-content .faq-block {
    width: 100%;
    margin: 1.5em 0;
    border-radius: 8px;
    overflow: hidden;
    font-size: 15px;
    background: var(--text-color-t);
}

.post-content .faq-item {
    border-bottom: 1px solid var(--text-color3-t);
}

.post-content .faq-item:last-child {
    border-bottom: none;
}

.post-content .faq-question {
    position: relative;
    padding: 16px 48px 16px 24px;
    font-weight: 400;
    cursor: cell;
    list-style: none;
    user-select: none;
}

.post-content .faq-question::-webkit-details-marker {
    display: none;
}

.post-content .faq-question::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-color);
    border-bottom: 2px solid var(--text-color);
    transform: translateY(-50%) rotate(-45deg);
    transition: transform 0.1s ease;
}

.post-content .faq-question:hover {
 transform: scale(1.005);
}


.post-content .faq-question:hover::after {
    border-color: var(--contrast-color);
}

.post-content .faq-item[open] > .faq-question {
    font-weight: 460;
}

.post-content .faq-item[open] > .faq-question::after {
    border-color: var(--contrast-color);
    transform: translateY(-50%) rotate(45deg);
}

.post-content .faq-answer {
    padding: 14px 16px;
    background: var(--text-color2-t);
}

.post-content .faq-answer > :first-child { margin-top: 0; }
.post-content .faq-answer > :last-child  { margin-bottom: 0; }

/* --- Figures --- */
.post-content figure {
    margin: 2em 0;
}

.post-content figcaption {
    margin-top: 0.6em;
    font-size: 14px;
    text-align: center;
    color: var(--text-color4-t, rgba(0, 0, 0, 0.55));
    font-style: italic;
}

/* --- Text selection --- */
.post-content ::selection {
    background: var(--contrast-color);
    color: var(--text-color2, #fff);
}

/* ===================================================================
   Callouts: :::tip / :::note / :::warning / :::info
   =================================================================== */
.post-content .callout {
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 14px;
    align-items: start;
    margin: 1.8em 0;
    padding: 18px 22px;
    border-radius: 0 8px 8px 0;
    border-left: 4px solid var(--contrast-color);
    background: var(--text-color2-t);
}

.post-content .callout-icon {
    font-size: 22px;
    line-height: 1.2;
    padding-top: 2px;
}

.post-content .callout-body > :first-child {
    margin-top: 0;
}

.post-content .callout-body > :last-child {
    margin-bottom: 0;
}

.post-content .callout-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
    color: var(--contrast-color);
}

.post-content .callout-icon img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    display: block;
}

.post-content .callout p {
    margin: 0.35em 0;
    font-size: 16px;
}


/* ===================================================================
   Image Sizes & Perfect Square Wrappers
   =================================================================== */

/* Lock the <a> wrapper to the exact size of the image inside it. */
.article-gallery-link:has(.img-s)  { width: 32px !important;  height: 32px !important;  flex: 0 0 32px !important;  max-width: 32px !important; }
.article-gallery-link:has(.img-m)  { width: 64px !important;  height: 64px !important;  flex: 0 0 64px !important;  max-width: 64px !important; }
.article-gallery-link:has(.img-l)  { width: 128px !important; height: 128px !important; flex: 0 0 128px !important; max-width: 128px !important; }
.article-gallery-link:has(.img-xl) { width: 256px !important; height: 256px !important; flex: 0 0 256px !important; max-width: 256px !important; }
.article-gallery-link:has(.img-xxl){ width: 512px !important; height: 512px !important; flex: 0 0 512px !important; max-width: 512px !important; }

/* FIX: Target ONLY the art image (.article-img). Do NOT target the heart icon! */
.article-gallery-link:has([class*="img-"]) img.article-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    margin: 0 !important;
    aspect-ratio: 1 / 1;
}

/* Fallback for any standalone sized images not wrapped in links */
.post-content img.article-img.img-s  { width: 32px !important;  height: 32px !important; }
.post-content img.article-img.img-m  { width: 64px !important;  height: 64px !important; }
.post-content img.article-img.img-l  { width: 128px !important; height: 128px !important; }
.post-content img.article-img.img-xl { width: 256px !important; height: 256px !important; }
.post-content img.article-img.img-xxl{ width: 512px !important; height: 512px !important; }

/* ===================================================================
   Consecutive Image Rows
   =================================================================== */
.image-row {
    display: flex;
    margin: 32px 0;
    justify-content: center;
    align-items: flex-end; /* Bottom-aligns images of varying sizes so they sit on a nice baseline */
    flex-wrap: wrap;       /* Allows the 512px image to properly drop to the next row */
    gap: 16px;
}

/* Normal, un-sized images in a row share space natively (side-by-side halves) */
.image-row .article-gallery-link:not(:has([class*="img-"])) {
    flex: 1;
    max-width: 45%;
    display: flex;
}

/* FIX: Only target .article-img, never the bare 'img', to protect the like button */
.image-row .article-gallery-link:not(:has([class*="img-"])) img.article-img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1; /* Keeps them perfectly square! */
    object-fit: cover;
}


/* ===================================================================
   Transition Rows
   =================================================================== */
.transition-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 32px 0;
    flex-wrap: wrap;
}

.transition-item .article-gallery-link img {
    max-width: 200px;
    height: auto;
}

.transition-arrow {
    font-family: 'Press Start 2P', monospace;
    font-size: 20px;
    color: var(--contrast-color);
    user-select: none;
    line-height: 1;
}

/* ===================================================================
   Gallery Grids
   =================================================================== */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(var(--gallery-cols, 3), 1fr);
    gap: 10px;
    margin: 32px auto;
    max-width: fit-content;
}

.image-gallery p {
    margin: 0;
    line-height: 0;
}

/* Ensure links act as grid cells and force square images */
.image-gallery .article-gallery-link {
    width: 100%;
    height: 100%;
    display: flex;
}

.image-gallery .article-gallery-link img {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

/* ===================================================================
   Snake Gallery Grid
   =================================================================== */
.gallery-snake {
    display: grid;
    justify-content: center;
    align-items: center;
    justify-items: center;
    gap: 12px;
    margin: 32px 0;
    max-width: 100%;
}

.snake-cell .article-gallery-link img {
    max-width: 200px;
    height: auto;
}

.snake-arrow,
.snake-down {
    font-family: 'Press Start 2P', monospace;
    font-size: 20px;
    color: var(--contrast-color);
    user-select: none;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.snake-down {
    transform: rotate(90deg);
}

/* ===================================================================
   Figure Blocks
   =================================================================== */
.figure-block {
    display: flex;
    gap: 24px;
    margin: 32px 0;
    align-items: flex-start;
}

.figure-block.figure-right {
    flex-direction: row-reverse;
}

.figure-image {
    flex-shrink: 0;
}

.figure-image p {
    margin: 0;
    line-height: 0;
}

.figure-text {
    flex: 1;
    min-width: 0;
}

.figure-text p:first-child {
    margin-top: 0;
}

/* ===================================================================
   Mobile Overrides
   =================================================================== */
@media (max-width: 768px) {
    .snake-cell .article-gallery-link img {
        max-width: 120px;
    }

    .snake-arrow,
    .snake-down {
        font-size: 14px;
    }

    .post-content {
        font-size: 16px;
        line-height: 1.7;
        max-width: 95%;
    }

    .post-content h2 {
        font-size: 23px;
    }

    .post-content h3 {
        font-size: 19px;
    }

    .post-content .callout {
        grid-template-columns: 32px 1fr;
        padding: 14px 16px;
        gap: 10px;
        border-radius: 0 6px 6px 0;
    }

    .image-row .article-gallery-link {
        max-width: 100%;
    }

    .transition-row {
        gap: 8px;
    }

    .transition-item .article-gallery-link img {
        max-width: 120px;
    }

    .transition-arrow {
        font-size: 14px;
    }

    .image-gallery {
        grid-template-columns: repeat(2, 1fr);
    }

    .figure-block,
    .figure-block.figure-right {
        flex-direction: column;
    }

    .post-image {
        width: 128px;
        height: 128px;
    }

    .post-title {
        font-size: 16px;
    }

    .post-container-wrapper {
        padding: 16px;
    }
}