/* Long-form article (prose) styles — prepared for the upcoming blog.
   Wrap rendered post body in <div class="app-prose"> … </div>. */
.app-prose {
    max-width: var(--app-prose-width);
    color: var(--app-text);
    font-size: 1.05rem;
    line-height: 1.75;
}

.app-prose > * + * {
    margin-top: 1.1rem;
}

.app-prose h2,
.app-prose h3,
.app-prose h4 {
    margin-top: 2.25rem;
    scroll-margin-top: 5rem;
}

.app-prose a {
    text-decoration: underline;
}

/* Internal cross-reference whose target post is not published yet: shown as muted,
   non-clickable text with a "planned" badge (resolved on render, see
   apps/blog/markdown.py). Becomes a real link automatically once the target goes
   live, so no styling change is needed there. */
.app-link-planned {
    color: var(--app-muted);
    border-bottom: 1px dotted var(--app-muted);
    cursor: help;
}

.app-link-planned__badge {
    margin-left: 0.35em;
    padding: 0 0.35em;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    font-family: var(--app-font-mono);
    font-size: 0.78em;
    text-transform: lowercase;
}

.app-prose ul,
.app-prose ol {
    padding-left: 1.4rem;
}

.app-prose li + li {
    margin-top: 0.4rem;
}

.app-prose blockquote {
    margin: 1.5rem 0;
    padding: 0.6rem 1.2rem;
    border-left: 3px solid var(--app-green-strong);
    color: var(--app-muted);
    font-style: italic;
}

.app-prose pre {
    margin-block: 1.5rem;
}

.app-prose img {
    margin-block: 1.5rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
}

/* Detail page: keep the whole article (header, cover, prose, comments) in a
   single readable column, left-aligned, so the wide window frame doesn't strand
   a narrow text block beside empty space. */
.app-article {
    max-width: var(--app-article-width);
}

/* Mono metadata line for article headers (date · reading time · tags). */
.app-post-meta {
    color: var(--app-muted);
    font-family: var(--app-font-mono);
    font-size: 0.85rem;
}

/* Code blocks: keep the Pygments token colours, but the container matches the
   app surface instead of the theme's own (warm) background. */
.app-prose .codehilite {
    margin-block: 1.5rem;
    overflow: auto;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: var(--app-bg-soft);
}

.app-prose .codehilite pre {
    margin: 0;
    padding: 1rem 1.1rem;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
}

/* Post list (homepage) — terminal `ls -l` style rows. */
.app-post-list {
    margin-top: 1.75rem;
    border-top: 1px solid var(--app-border);
}

.app-post-row {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0 1.4rem;
    padding: 0.95rem 0.7rem;
    border-bottom: 1px solid var(--app-border);
    transition: background var(--app-transition);
}

/* Hover highlights the whole row, like a selected line in a file listing. */
.app-post-row:hover {
    background: var(--app-green-soft);
}

.app-post-row__meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding-top: 0.2rem;
    color: var(--app-muted);
    font-family: var(--app-font-mono);
    font-size: 0.8rem;
    white-space: nowrap;
}

.app-post-row__read {
    color: var(--app-faint);
}

.app-post-row__title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6rem;
    margin: 0;
    font-family: var(--app-font-mono);
    font-size: 1.15rem;
}

.app-post-row__title a {
    color: var(--app-text-strong);
    text-decoration: none;
}

.app-post-row__title a:hover {
    color: var(--app-link);
}

.app-post-row__file {
    color: var(--app-faint);
    font-size: 0.8rem;
    font-weight: 400;
}

.app-post-row__summary {
    margin-top: 0.4rem;
    color: var(--app-muted);
}

.app-post-row__summary::before {
    margin-right: 0.4ch;
    color: var(--app-green);
    content: ">";
}

/* Cover images. */
.app-post-cover {
    width: 100%;
    /* height:auto lets the browser derive the box height from the width/height
       attributes' aspect ratio, reserving space before load (prevents CLS)
       without distorting the image. */
    height: auto;
    max-height: 22rem;
    margin-bottom: 1.5rem;
    object-fit: cover;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-lg);
}

/* Row with a cover: insert a thumbnail column between meta and main. */
.app-post-row--has-cover {
    grid-template-columns: max-content 7rem 1fr;
}

.app-post-row__thumb img {
    width: 7rem;
    height: 4.6rem;
    object-fit: cover;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
}

@media (max-width: 575.98px) {
    .app-post-row,
    .app-post-row--has-cover {
        grid-template-columns: 1fr;
        gap: 0.5rem 0;
    }

    .app-post-row__meta {
        flex-direction: row;
        gap: 0.9rem;
        padding-top: 0;
    }

    .app-post-row__thumb img {
        width: 100%;
        height: 10rem;
    }
}

.app-post-detail-meta {
    margin-bottom: 1.75rem;
}

.app-draft-flag {
    color: var(--app-warning);
}

/* Staff-only status chip in the drafts & scheduled listing. */
.app-post-row__status {
    align-self: start;
    padding: 0.05rem 0.4rem;
    border: 1px solid var(--app-border-strong);
    border-radius: var(--app-radius-sm);
    color: var(--app-warning);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.app-post-row__status--scheduled {
    color: var(--app-info);
}

/* Page-level staff action row (e.g. "edit series" on a series page). */
.app-page-actions {
    margin: -0.5rem 0 1.5rem;
}

/* Search form (on the /search/ page). */
.app-search-form {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 2rem;
}

.app-search-input {
    flex: 1;
}

/* Tags (chips). */
.app-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.app-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    color: var(--app-muted);
    font-family: var(--app-font-mono);
    font-size: 0.78rem;
    text-decoration: none;
}

.app-tag::before {
    margin-right: 0.15rem;
    color: var(--app-green);
    content: "#";
}

.app-tag:hover {
    border-color: var(--app-green);
    color: var(--app-text-strong);
}

.app-post-footer {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--app-border);
}

/* Public profile page. */
.app-profile-meta {
    margin-top: 0.5rem;
}

.app-profile-actions {
    margin-top: 1.5rem;
}

.app-profile-comments {
    margin-top: 2.5rem;
}

/* Comments. */
.app-comments {
    max-width: var(--app-prose-width);
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--app-border);
}

.app-comments__title {
    margin-bottom: 1.25rem;
    font-family: var(--app-font-mono);
    font-size: 1.1rem;
}

.app-comments__title::before {
    margin-right: 0.5ch;
    color: var(--app-green);
    content: "//";
}

.app-comment {
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--app-border);
}

.app-comment__meta {
    margin-bottom: 0.35rem;
    color: var(--app-muted);
    font-family: var(--app-font-mono);
    font-size: 0.8rem;
}

.app-comment__author {
    color: var(--app-text-strong);
}

.app-comment-form {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.app-comment-login {
    margin-top: 1.25rem;
}

/* --- Comment replies (one level) ----------------------------------------- */
.app-comment--reply {
    margin-top: 0.9rem;
    margin-left: 1.25rem;
    padding-left: 0.9rem;
    border-left: 2px solid var(--app-border-strong);
}

.app-reply {
    margin-top: 0.6rem;
}

.app-reply__toggle {
    display: inline-block;
    color: var(--app-link);
    font-family: var(--app-font-mono);
    font-size: 0.8rem;
    cursor: pointer;
}

.app-reply__toggle::before {
    content: "↳ ";
    color: var(--app-faint);
}

.app-reply__form {
    margin-top: 0.75rem;
}

.app-reply__input {
    width: 100%;
    box-sizing: border-box;
}

/* --- Table of contents --------------------------------------------------- */
.app-toc {
    margin: 1.5rem 0;
    padding: 0.85rem 1.1rem;
    border: 1px solid var(--app-border);
    border-left: 2px solid var(--app-green);
    border-radius: var(--app-radius);
    background: var(--app-bg-soft);
}

.app-toc__title {
    margin: 0 0 0.4rem;
    color: var(--app-muted);
    font-family: var(--app-font-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.app-toc .toc {
    font-size: 0.92rem;
}

.app-toc .toc ul {
    margin: 0;
    padding-left: 1.1rem;
    list-style: none;
}

.app-toc .toc > ul {
    padding-left: 0;
}

.app-toc .toc li {
    margin: 0.15rem 0;
}

.app-toc .toc a {
    color: var(--app-link);
}

.app-toc .toc a:hover {
    color: var(--app-link-hover);
}

/* --- Related posts ------------------------------------------------------- */
.app-related {
    margin-top: 2.5rem;
}

.app-related__title {
    margin: 0 0 0.9rem;
    font-size: 1.05rem;
    color: var(--app-text-strong);
}

.app-related__title::before {
    content: "// ";
    color: var(--app-green);
}

.app-related__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.app-related__item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--app-border);
}

.app-related__item:last-child {
    border-bottom: 0;
}

.app-related__link {
    color: var(--app-link);
    font-weight: 600;
}

.app-related__summary {
    color: var(--app-muted);
    font-size: 0.88rem;
}

/* --- Series navigation --------------------------------------------------- */
.app-series {
    margin: 1.5rem 0;
    padding: 0.75rem 1.1rem;
    border: 1px solid var(--app-border);
    border-left: 2px solid var(--app-link);
    border-radius: var(--app-radius);
    background: var(--app-bg-soft);
}

.app-series__meta {
    margin: 0;
    font-family: var(--app-font-mono);
    font-size: 0.85rem;
    color: var(--app-muted);
}

.app-series__pos {
    color: var(--app-text-strong);
}

.app-series__name {
    color: var(--app-link);
}

.app-series__nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin: 0.5rem 0 0;
    font-size: 0.88rem;
}

.app-series__link {
    color: var(--app-link);
}

.app-series__link--next {
    margin-left: auto;
    text-align: right;
}

/* --- Detail outline rail — a floating mini terminal window ---------------- */
/* The rail is taken OUT OF FLOW (position: fixed) so the article column is
   byte-for-byte identical whether or not a rail exists — no reserved column,
   no reflow. It sits OUTSIDE the centred main window, in the right margin —
   which only fits on wide viewports, so the breakpoint is high; below it the
   inline TOC takes over. */
.app-detail__rail {
    display: none;
}

/* Breakpoint = main window (--app-content-width: 1020px) + rail (16rem) + gaps;
   keep it in sync if --app-content-width changes (media queries can't read vars). */
@media (min-width: 1580px) {
    .app-detail__rail {
        display: block;
        position: fixed;
        /* Flush with the main window's top edge: sticky navbar (3.5rem + 1px
           border) + the window's 1.75rem top margin. Stays fixed while scrolling. */
        top: calc(3.5rem + 1.75rem + 1px);
        /* Anchor just past the centred window's right edge (half its width from
           centre) so the panel lives outside the main window. Tied to the token
           so it follows --app-content-width. fixed is not clipped by overflow. */
        left: calc(50vw + var(--app-content-width) / 2 + 6px);
        width: var(--app-rail-width);
        max-height: calc(100vh - 7rem);
        overflow-y: auto;
        z-index: 40;
        /* Its own little terminal window: frame + lift, mirroring .app-window. */
        border: 1px solid var(--app-border-strong);
        border-radius: var(--app-radius-lg);
        background: var(--app-bg-soft);
        box-shadow: var(--app-shadow);
    }

    /* The floating rail carries the TOC, so the inline one steps aside. */
    .app-toc--inline {
        display: none;
    }
}

/* Mini-window chrome for the rail (title bar + traffic-light dots + body). */
.app-rail__bar {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.7rem;
    border-bottom: 1px solid var(--app-border);
    background: var(--app-term-titlebar);
    font-family: var(--app-font-mono);
    font-size: 0.72rem;
    color: var(--app-muted);
}

.app-rail__dots {
    display: inline-flex;
    flex-shrink: 0;
    gap: 0.35rem;
}

.app-rail__dots i {
    display: block;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: var(--app-radius-pill);
    background: var(--app-faint);
}

.app-rail__dots i:nth-child(1) {
    background: var(--app-danger);
}

.app-rail__dots i:nth-child(2) {
    background: var(--app-warning);
}

.app-rail__dots i:nth-child(3) {
    background: var(--app-success);
}

.app-rail__label::before {
    color: var(--app-faint);
    content: "geekblog:";
}

.app-rail__body {
    padding: 0.95rem 1rem 1.1rem;
}

/* Rail series part-list — mono, current part highlighted. */
.app-series-rail {
    margin: 0 0 1.25rem;
    padding: 0 0 1.1rem;
    border-bottom: 1px solid var(--app-border);
    font-family: var(--app-font-mono);
    font-size: 0.82rem;
    line-height: 1.5;
}

.app-series-rail__title {
    margin: 0 0 0.45rem;
    color: var(--app-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.app-series-rail__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.app-series-rail__item {
    margin: 0.25rem 0;
    color: var(--app-muted);
}

.app-series-rail__item::before {
    content: "· ";
    color: var(--app-faint);
}

.app-series-rail__item a {
    color: var(--app-link);
}

.app-series-rail__item.is-current {
    color: var(--app-text-strong);
}

.app-series-rail__item.is-current::before {
    content: "› ";
    color: var(--app-green);
}

/* Rail TOC — drop the boxed look of the inline TOC (the rail frame contains it). */
.app-toc--rail {
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
}

.app-toc--rail .toc {
    font-size: 0.84rem;
}

/* Google-style SERP snippet preview in the post editor (enhanced by app.js). */
.app-serp {
    margin: 2.5rem 0 1rem;
}

.app-serp__label {
    margin-bottom: 0.5rem;
    color: var(--app-muted);
    font-family: var(--app-font-mono);
    font-size: 0.8rem;
}

.app-serp__card {
    max-width: 600px;
    padding: 0.9rem 1rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-lg);
    background: var(--app-surface);
}

.app-serp__url {
    display: block;
    color: var(--app-green);
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-serp__title {
    display: block;
    margin: 0.2rem 0;
    color: var(--app-link);
    font-size: 1.15rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-serp__desc {
    display: block;
    color: var(--app-text);
    font-size: 0.9rem;
    line-height: 1.4;
}

.app-serp__warn {
    margin-top: 0.5rem;
    color: var(--app-warning);
    font-size: 0.82rem;
}
