/* Blog post page (shared/templates/blog/post.html), on top of pages.css.
   Post bodies come from the Blog Store; blog_render.py wraps tables in
   .g-table and adds heading ids, so these rules cover every post. */

.g-post { padding-bottom: 0; }
.g-post h1 {
    font-size: 46px; line-height: 1.08; letter-spacing: -0.035em;
    margin: 0 0 16px; text-wrap: balance;
}
.g-post-back {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 15px; font-weight: 500; color: var(--blue); text-decoration: none;
    margin-bottom: 28px;
}
.g-post-back:hover { text-decoration: underline; }

.g-post-meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
    font-size: 15px; color: var(--mute); margin: 0 0 32px;
}
.g-post-meta > .g-post-meta-sep:first-child { display: none; }
.g-post-meta-sep { color: #c7c7cc; }

.g-post-hero {
    width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block;
    border-radius: 20px; margin: 0 0 40px; background: var(--panel);
}

/* "In this guide" list of the post's sections */
.g-toc {
    background: var(--panel); border-radius: 16px; margin: 0 0 44px;
}
.g-toc details { padding: 4px 22px; }
.g-toc details[open] { padding-bottom: 18px; }
.g-toc summary {
    cursor: pointer; list-style: none; padding: 14px 0;
    display: flex; align-items: center; gap: 10px;
    font-size: 15px; font-weight: 600; color: var(--ink);
}
.g-toc summary::-webkit-details-marker { display: none; }
.g-toc summary::after {
    content: ""; margin-left: auto; width: 8px; height: 8px;
    border-right: 2px solid var(--mute); border-bottom: 2px solid var(--mute);
    transform: rotate(45deg); transition: transform 0.2s ease;
}
.g-toc details[open] summary::after { transform: rotate(-135deg); }
.g-toc-count { font-weight: 400; color: var(--mute); font-size: 14px; }
.g-toc ul {
    list-style: none; margin: 0; padding: 0; font-size: 15px; line-height: 1.45;
}
.g-toc ul.g-toc--cols { columns: 2; column-gap: 32px; }
.g-toc li { margin: 0 0 8px; break-inside: avoid; }
.g-toc a { color: var(--ink); text-decoration: none; }
.g-toc a:hover { color: var(--blue); text-decoration: underline; }

/* Article body */
.g-post-body {
    font-size: 18px; line-height: 1.75; color: #3a3a3c;
    overflow-wrap: break-word;
}
.g-post-body > :first-child { margin-top: 0; }
.g-post-body h1, .g-post-body h2, .g-post-body h3, .g-post-body h4 {
    color: var(--ink); font-weight: 700; line-height: 1.22;
    scroll-margin-top: 96px; text-wrap: balance;
}
.g-post-body h1, .g-post-body h2 {
    font-size: 31px; letter-spacing: -0.03em; margin: 2.1em 0 0.55em;
}
.g-post-body h3 { font-size: 22px; letter-spacing: -0.02em; margin: 1.8em 0 0.5em; }
.g-post-body h4 { font-size: 18px; letter-spacing: -0.01em; margin: 1.6em 0 0.4em; }
.g-post-body h2 + h3 { margin-top: 0.8em; }
.g-post-body p { margin: 0 0 1.2em; }
.g-post-body strong, .g-post-body b { color: var(--ink); font-weight: 600; }
.g-post-body a {
    color: var(--blue); text-decoration: underline;
    text-decoration-thickness: 1px; text-underline-offset: 3px;
    text-decoration-color: rgba(69, 142, 255, 0.45);
}
.g-post-body a:hover { text-decoration-color: currentColor; }

.g-post-body ul, .g-post-body ol { margin: 0 0 1.4em; padding-left: 1.35em; }
.g-post-body li { margin: 0 0 0.6em; padding-left: 0.25em; }
.g-post-body li > ul, .g-post-body li > ol { margin: 0.6em 0 0; }
.g-post-body ul > li::marker { color: var(--blue); }
.g-post-body ol > li::marker { color: var(--blue); font-weight: 600; }

.g-post-body img {
    max-width: 100%; height: auto; display: block;
    border-radius: 14px; margin: 32px auto;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.g-post-body figure { margin: 32px 0; }
.g-post-body figure img { margin: 0 auto; }
.g-post-body figcaption {
    font-size: 14px; color: var(--mute); text-align: center; margin-top: 10px;
}
.g-post-body iframe, .g-post-body video {
    display: block; width: 100%; height: auto; aspect-ratio: 16 / 9;
    border: 0; border-radius: 14px; margin: 32px 0; background: #000;
}

.g-post-body hr {
    border: 0; height: 1px; background: #e5e5ea; margin: 48px 0;
}

/* Callouts such as "Our Take:" */
.g-post-body blockquote {
    margin: 32px 0; padding: 20px 24px;
    background: #f3f7ff; border-left: 4px solid var(--blue);
    border-radius: 4px 16px 16px 4px;
    color: #2c2c30; font-size: 17px; line-height: 1.65;
    font-style: normal; letter-spacing: 0;
}
.g-post-body blockquote p:last-child { margin-bottom: 0; }
.g-post-body blockquote > p:first-child > strong:first-child {
    display: block; margin: 0 0 4px;
    font-size: 12px; font-weight: 700; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--blue);
}

.g-post-body pre {
    background: var(--panel); border-radius: 14px; padding: 16px; overflow-x: auto;
    font-size: 15px; line-height: 1.55;
}
.g-post-body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.88em; background: var(--panel); padding: 0.12em 0.4em; border-radius: 6px;
}
.g-post-body pre code { background: none; padding: 0; }

/* Tables (wrapped by blog_render.py) */
.g-table { position: relative; margin: 32px 0 36px; }
.g-table-scroll {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border: 1px solid #e5e5ea; border-radius: 16px; background: #fff;
}
.g-table-scroll:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.g-table::after {
    content: ""; position: absolute; top: 1px; right: 1px; bottom: 1px; width: 40px;
    border-radius: 0 15px 15px 0; pointer-events: none;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
    opacity: 0; transition: opacity 0.2s ease;
}
.g-table.is-scrollable::after { opacity: 1; }

.g-post-body table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    font-size: 15px; line-height: 1.55; color: #3a3a3c;
}
.g-post-body th, .g-post-body td {
    text-align: left; padding: 14px 16px; vertical-align: top;
    border-bottom: 1px solid #ececf0;
}
.g-post-body th {
    background: var(--panel); color: var(--ink);
    font-size: 13px; font-weight: 600; line-height: 1.35; letter-spacing: 0.01em;
    vertical-align: bottom; padding-top: 12px; padding-bottom: 12px;
    border-bottom-color: #e5e5ea;
}
.g-post-body td { background: #fff; }
.g-post-body tbody tr:nth-child(even) td { background: #fafafc; }
.g-post-body tbody tr:last-child td { border-bottom: 0; }
.g-post-body td:first-child { color: var(--ink); font-weight: 600; }
.g-post-body td.g-stars { color: #f5a524; letter-spacing: 0.08em; white-space: nowrap; }
.g-post-body td p:last-child, .g-post-body th p:last-child { margin: 0; }

/* Keep the first column in view when a table scrolls sideways. */
.g-table--cols-3 :is(th, td):first-child,
.g-table--cols-4 :is(th, td):first-child,
.g-table--wide :is(th, td):first-child {
    position: sticky; left: 0; z-index: 1;
    box-shadow: 1px 0 0 #ececf0;
}
.g-table--cols-4 :is(th, td),
.g-table--wide :is(th, td) { min-width: 150px; }
.g-table--wide :is(th, td):first-child { min-width: 140px; }

/* Wide tables get more room than the text column on larger screens. */
@media (min-width: 900px) {
    .g-table--wide {
        width: min(1040px, calc(100vw - 64px));
        margin-left: calc((100% - min(1040px, calc(100vw - 64px))) / 2);
    }
}

/* Related posts and tags */
.g-post-tags { margin-top: 44px; }
.g-post-tags .g-blog-tag { background: var(--panel); }

@media (max-width: 980px) {
    .g-post h1 { font-size: 38px; }
}

/* Phones: comfortable type and tables as stacked cards. */
@media (max-width: 640px) {
    .g-post h1 { font-size: 32px; letter-spacing: -0.03em; }
    .g-post-meta { font-size: 14px; margin-bottom: 24px; }
    .g-post-hero { border-radius: 16px; margin-bottom: 28px; }
    .g-toc { margin-bottom: 32px; }
    .g-toc details { padding: 2px 18px; }
    .g-toc ul.g-toc--cols { columns: 1; }

    .g-post-body { font-size: 17px; line-height: 1.7; }
    .g-post-body h1, .g-post-body h2 { font-size: 25px; }
    .g-post-body h3 { font-size: 20px; }
    .g-post-body h4 { font-size: 17px; }
    .g-post-body img, .g-post-body iframe, .g-post-body video { margin: 24px 0; border-radius: 12px; }
    .g-post-body blockquote { padding: 16px 18px; font-size: 16px; margin: 28px 0; }

    .g-table--stack .g-table-scroll {
        overflow: visible; border: 0; border-radius: 0; background: none;
    }
    .g-table--stack::after { display: none; }
    .g-table--stack table,
    .g-table--stack tbody,
    .g-table--stack tr,
    .g-table--stack td { display: block; width: 100%; }
    .g-table--stack thead {
        position: absolute; width: 1px; height: 1px; overflow: hidden;
        clip: rect(0 0 0 0); white-space: nowrap;
    }
    .g-table--stack tbody tr {
        background: var(--panel); border-radius: 16px;
        padding: 16px 18px 6px; margin: 0 0 12px;
    }
    .g-post-body .g-table--stack td,
    .g-post-body .g-table--stack tbody tr:nth-child(even) td {
        background: none; border: 0; padding: 0 0 12px;
        min-width: 0; position: static; box-shadow: none;
    }
    .g-post-body .g-table--stack tbody tr td:first-child {
        font-size: 17px; line-height: 1.35; padding-bottom: 12px; margin-bottom: 12px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }
    .g-table--stack td[data-label]:not(:first-child)::before {
        content: attr(data-label); display: block; margin: 0 0 2px;
        font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
        text-transform: uppercase; color: var(--mute);
    }

    /* Two-column tables stay tables; keep them tight. */
    .g-post-body table { font-size: 14px; }
    .g-post-body th, .g-post-body td { padding: 12px; }
}
