/* ==========================================================================
   Blog pages (index + posts) on the studio design. Loaded after studio.css.
   ========================================================================== */

/* --- Post hero ----------------------------------------------------------- */
.post-hero { background: var(--ink); color: #fff; padding: clamp(120px, 14vw, 170px) 0 clamp(56px, 7vw, 88px); }
.post-hero .crumbs { display: flex; flex-wrap: wrap; gap: 10px; font: 500 12px/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted-inv); margin: 0 0 28px; }
.post-hero .crumbs a { display: inline-block; padding: 14px 0; margin: -14px 0; color: var(--accent-inv); text-decoration: none; }
.post-hero .crumbs a:hover { text-decoration: underline; }
.post-hero h1 { font: 700 clamp(34px, 5.4vw, 68px)/1.04 var(--f-display); letter-spacing: -.035em; margin: 0 0 24px; max-width: 18ch; }
.post-hero .lede { font-size: clamp(17px, 1.5vw, 20px); line-height: 1.6; color: #c9d7e4; max-width: 62ch; margin: 0 0 32px; }
.post-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.post-meta li { font: 500 12px/1 var(--f-mono); letter-spacing: .04em; padding: 9px 12px; border: 1px solid var(--line-inv); border-radius: 999px; color: #dbe7f2; }
.post-meta li b { color: var(--accent-inv); font-weight: 500; }

/* --- Layout: contents rail + reading column ------------------------------- */
.post-layout { display: grid; grid-template-columns: 240px minmax(0, 760px); column-gap: clamp(32px, 5vw, 80px); row-gap: 0; align-content: start; justify-content: center; padding-top: clamp(48px, 6vw, 88px); padding-bottom: clamp(64px, 8vw, 120px); }
.post-body > .table-of-contents { grid-column: 1; grid-row: 1 / span 999; align-self: start; position: sticky; top: 96px; max-height: calc(100vh - 120px); overflow: auto; }
.post-body > :not(.table-of-contents) { grid-column: 2; min-width: 0; }
.post-body > h2:first-of-type { margin-top: 0; }
.post-body img { border-radius: 14px; margin: 8px 0 28px; }
.post-body .face-demo-item img, .post-body .related-grid img { margin: 0; }

.table-of-contents { border-left: 2px solid var(--line); padding: 4px 0 4px 18px; }
.post-body .table-of-contents h2 { padding-left: 0; scroll-margin-top: 0; font: 500 12px/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.table-of-contents ul, .table-of-contents ol { list-style: none; margin: 0; padding: 0; }
.post-body .table-of-contents li { margin: 0 0 10px; }
.table-of-contents a { color: var(--muted); text-decoration: none; font-size: 14px; line-height: 1.4; display: block; padding: 6px 0; transition: color .2s; }
.table-of-contents a:hover, .table-of-contents a[aria-current="true"] { color: var(--accent); }
.table-of-contents a[aria-current="true"] { font-weight: 600; }

/* --- Prose ---------------------------------------------------------------- */
.post-body { font-size: 18px; line-height: 1.75; }
.post-body h2 { font: 700 clamp(26px, 2.6vw, 34px)/1.15 var(--f-display); letter-spacing: -.025em; margin: 64px 0 18px; scroll-margin-top: 96px; }
.post-body h3 { font: 600 clamp(20px, 1.8vw, 24px)/1.25 var(--f-display); letter-spacing: -.015em; margin: 40px 0 12px; scroll-margin-top: 96px; }
.post-body h4 { font: 600 18px/1.3 var(--f-display); margin: 28px 0 10px; }
.post-body p, .post-body ul, .post-body ol { margin: 0 0 20px; }
.post-body li { margin: 0 0 8px; }
.post-body a { color: var(--accent); text-underline-offset: 3px; }
.post-body strong { font-weight: 600; }
.post-body hr { border: 0; border-top: 1px solid var(--line); margin: 48px 0; }
.post-body blockquote { margin: 28px 0; padding: 4px 0 4px 22px; border-left: 3px solid var(--accent); color: var(--ink-2); }

.post-body :not(pre) > code, .post-body .code-highlight {
    font: 500 .86em/1 var(--f-mono); background: var(--paper-2); color: var(--ink); padding: .2em .45em; border-radius: 6px;
}
.post-body pre { margin: 24px 0 32px; border-radius: 14px; overflow: auto; font: 400 14px/1.65 var(--f-mono); }
.post-body pre[class*="language-"], .post-body pre > code[class*="language-"] { font-family: var(--f-mono); font-size: 14px; }
.post-body pre:has(> code[class*="language-"]) { background: #0d1b2b; padding: 22px 24px; border: 1px solid var(--line-inv); }
.post-body pre > code { background: none; padding: 0; text-shadow: none; }

/* Tables */
.feature-comparison, .api-comparison, .performance-table { margin: 28px 0 36px; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.post-body table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
.post-body th { text-align: left; font: 600 12px/1.3 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--paper-2); padding: 14px 16px; }
.post-body td { padding: 14px 16px; border-top: 1px solid var(--line); vertical-align: top; }

/* Callouts */
.info-box, .warning-box, .success-box, .tip-box { margin: 28px 0; padding: 20px 22px; border-radius: 14px; border: 1px solid; font-size: 16px; }
.info-box > :last-child, .warning-box > :last-child, .success-box > :last-child, .tip-box > :last-child { margin-bottom: 0; }
.info-box { background: var(--paper-2); border-color: #b9dcf3; }
.tip-box { background: #eef8f1; border-color: #bfe3cb; }
.success-box { background: #eef8f1; border-color: #bfe3cb; }
.warning-box { background: #fff6e8; border-color: #f2d6a6; }
.info-box h4, .warning-box h4, .success-box h4, .tip-box h4 { margin-top: 0; }

/* Diagrams and demos */
.architecture-diagram { margin: 28px 0; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper-2); overflow-x: auto; }
.architecture-diagram h3 { margin-top: 0; }
.architecture-diagram pre { background: transparent !important; color: var(--ink) !important; margin: 0; padding: 0; font-size: 13px; line-height: 1.35; }

.chat-interface-demo { margin: 28px 0; padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper-2); }
.chat-message { display: flex; margin: 10px 0; }
.chat-message.assistant { justify-content: flex-start; }
.chat-message:not(.assistant) { justify-content: flex-end; }
.chat-bubble { max-width: 80%; padding: 12px 16px; border-radius: 18px; font-size: 15px; line-height: 1.5; }
.chat-bubble.user { background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.chat-bubble.assistant { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 6px; }

.face-demo { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 20px; justify-content: center; margin: 28px 0; }
.face-demo-item { text-align: center; position: relative; }
.face-demo-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; }
.face-demo-item p { font: 500 12px/1.2 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 10px 0 0; }

/* Author */
.author-bio { display: flex; gap: 20px; align-items: flex-start; margin: 56px 0 0; padding: 24px; border: 1px solid var(--line); border-radius: 18px; }
.author-avatar { flex: none; width: 64px; height: 64px; border-radius: 50%; background: var(--ink) url("../if_logo.svg") center / 70% no-repeat; }
.author-bio h3, .author-bio h4 { margin: 0 0 6px; font-size: 18px; }
.author-bio p { margin: 0; font-size: 16px; color: var(--muted); }

/* Related */
.related-posts { margin: 72px 0 0; }
.related-posts > h3 { font: 500 12px/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 18px; }
.related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.related-grid .blog-card { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #fff; transition: transform .3s var(--ease), border-color .3s; }
.related-grid .blog-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.related-grid .blog-image img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.related-grid .blog-content { padding: 14px 16px 18px; }
.related-grid h4 { margin: 0 0 6px; font-size: 16px; line-height: 1.3; }
.related-grid h4 a { color: var(--ink); text-decoration: none; }
.related-grid h4 a::after { content: ''; position: absolute; inset: 0; }
.related-grid .blog-card { position: relative; }
.related-grid p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.5; }

/* Newsletter band */
.post-cta { background: var(--paper-2); border-top: 1px solid var(--line); padding: clamp(56px, 7vw, 96px) 0; }
.post-cta .wrap { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: end; }
.post-cta h2 { font: 700 clamp(26px, 3vw, 40px)/1.1 var(--f-display); letter-spacing: -.03em; margin: 10px 0 10px; }
.post-cta p { margin: 0; color: var(--muted); }
.post-cta-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* --- Blog index ----------------------------------------------------------- */
.blog-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 36px; }
.blog-filters button { font: 500 13px/1 var(--f-text); padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; transition: background .2s, color .2s, border-color .2s; }
.blog-filters button:hover { border-color: var(--ink); }
.blog-filters button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.post-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; padding-bottom: clamp(64px, 8vw, 120px); }
.post-card { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: #fff; transition: transform .35s var(--ease), border-color .3s, box-shadow .35s; }
.post-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 18px 40px -24px rgba(10, 23, 38, .35); }
.post-card img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; }
.post-card .body { padding: 20px 22px 24px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.post-card .topic { font: 500 12px/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.post-card h2, .post-card h3 { font: 600 20px/1.25 var(--f-display); letter-spacing: -.015em; margin: 0; }
.post-card h2 a, .post-card h3 a { color: var(--ink); text-decoration: none; }
.post-card h2 a::after, .post-card h3 a::after { content: ''; position: absolute; inset: 0; }
.post-card p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--muted); }
.post-card .when { margin-top: auto; padding-top: 8px; font: 400 12px/1.2 var(--f-mono); color: var(--muted); }
.post-card.is-featured { grid-column: 1 / -1; display: grid; grid-template-columns: 1.2fr 1fr; }
.post-card.is-featured img { height: 100%; aspect-ratio: auto; min-height: 280px; }
.post-card.is-featured .body { padding: clamp(24px, 3vw, 44px); justify-content: center; }
.post-card.is-featured h2 { font-size: clamp(26px, 2.6vw, 36px); }
.post-card.is-soon { opacity: .6; pointer-events: none; }
.post-card.is-soon .topic::after { content: ' · Coming soon'; color: var(--muted); }
.post-card[hidden] { display: none; }
.blog-listing { padding-top: clamp(40px, 5vw, 72px); }
.post-hero h1 em { font-style: normal; color: var(--accent-inv); }
.post-card.is-text { background: var(--paper-2); border-style: dashed; }
.post-card.is-text .body { padding-top: 26px; }
.post-list-empty { margin: 0 0 80px; color: var(--muted); }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 1080px) {
    .post-layout { grid-template-columns: minmax(0, 760px); }
    .post-body > .table-of-contents { grid-column: 1; grid-row: auto; position: static; max-height: none; margin-bottom: 28px; background: var(--paper-2); border: 0; border-radius: 14px; padding: 18px 20px; }
    .post-body > :not(.table-of-contents) { grid-column: 1; }
    .post-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .post-body { font-size: 17px; }
    .related-grid, .post-list { grid-template-columns: 1fr; }
    .post-card.is-featured { grid-template-columns: 1fr; }
    .post-card.is-featured img { min-height: 0; aspect-ratio: 16 / 10; }
    .post-cta .wrap { grid-template-columns: 1fr; }
    .author-bio { flex-direction: column; }
    .post-body pre:has(> code[class*="language-"]) { margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); border-radius: 0; border-left: 0; border-right: 0; }
}

/* Legal pages (privacy, terms): single readable column */
.post-body.legal > * { max-width: 720px; }
.post-body.legal { padding-top: clamp(48px, 6vw, 80px); padding-bottom: clamp(64px, 8vw, 120px); }
.post-body.legal h2 { font-size: clamp(22px, 2vw, 26px); margin: 40px 0 10px; }
.post-body.legal h2:first-child { margin-top: 0; }

/* =================== Cool pass: blog index + posts =================== */
.blog-filters button { border-radius: 999px; transition: background .2s var(--ease), color .2s var(--ease), transform .2s var(--ease); }
.blog-filters button:hover { transform: translateY(-2px); }
.post-card { border-radius: 20px; overflow: hidden; transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s var(--ease); }
.post-card:hover { transform: translateY(-6px); box-shadow: 0 26px 50px -26px rgba(19, 112, 176, .4); border-color: var(--accent); }
.post-card img { transition: transform .6s var(--ease); }
.post-card:hover img { transform: scale(1.04); }
.post-card .topic { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--paper-2); }
.post-card.is-soon { background: repeating-linear-gradient(135deg, var(--paper-2) 0 12px, #fff 12px 24px); }

.post-body h2 { position: relative; padding-left: 18px; }
.post-body .table-of-contents h2::before { content: none; }
.post-body h2::before { content: ""; position: absolute; left: 0; top: .2em; bottom: .2em; width: 4px; border-radius: 4px; background: linear-gradient(var(--accent), #67c8f5); }
.post-body pre { border-radius: 14px; box-shadow: 0 20px 40px -26px rgba(10, 23, 38, .6); }
.post-body blockquote { border-radius: 0 14px 14px 0; background: linear-gradient(90deg, rgba(103, 200, 245, .12), transparent); }
.post-body table { border-radius: 14px; overflow: hidden; }
.info-box, .tip-box, .warning-box, .success-box { border-radius: 14px; }
.table-of-contents { border-radius: 16px; }
.related-grid .blog-card { border-radius: 18px; transition: transform .3s var(--ease), box-shadow .3s var(--ease); }
.related-grid .blog-card:hover { transform: translateY(-4px); box-shadow: 0 20px 40px -24px rgba(19, 112, 176, .4); }
@media (prefers-reduced-motion: reduce) { .post-card, .post-card img, .related-grid .blog-card { transition: none; } }
