/* ==========================================================================
   BLOG — listing (blog.html) + article (functions/blog/[slug].js)
   Inherits the global design system from main.css
   ========================================================================== */

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 24px; }

/* ---------- Hero ---------- */
.blog-hero {
    padding: 140px 0 28px;
    border-bottom: 1px solid var(--line-dark);
}
.blog-hero .kicker {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--teal);
    margin-bottom: 14px;
}
.blog-hero h1 {
    font-family: "Instrument Serif", serif;
    font-weight: 400;
    font-size: clamp(2.4rem, 5vw, 3.8rem);
    line-height: 1.05;
    margin: 0 0 18px;
    color: var(--ink);
}
.blog-lede {
    max-width: 1080px;
    color: var(--muted-dark);
    font-size: 1.05rem;
    margin: 0 0 30px;
}

/* ---------- AI Search ---------- */
.blog-search-wrap { max-width: 680px; }
.blog-search {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--paper-2);
    border: 1px solid var(--line-dark);
    border-radius: 14px;
    padding: 4px 14px 4px 16px;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.blog-search:focus-within {
    border-color: var(--teal);
    box-shadow: 0 0 0 4px rgba(40, 198, 168, 0.14);
}
.search-spark { color: var(--teal); flex-shrink: 0; }
.blog-search input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    color: var(--ink);
    padding: 14px 0;
}
.search-clear {
    border: none;
    background: transparent;
    color: var(--muted-dark);
    cursor: pointer;
    display: flex;
    padding: 6px;
    border-radius: 8px;
}
.search-clear:hover { background: rgba(127,127,127,0.12); }
.search-meta {
    font-size: 0.85rem;
    color: var(--muted-dark);
    min-height: 20px;
    margin: 12px 2px 0;
}
.search-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.search-tag {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--line-dark);
    background: transparent;
    color: var(--muted-dark);
    cursor: pointer;
    transition: all 0.18s;
}
.search-tag:hover, .search-tag.active {
    border-color: var(--teal);
    color: var(--teal);
    background: rgba(40, 198, 168, 0.08);
}

/* ---------- Grid ---------- */
.blog-section { padding: 44px 0 80px; }
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 26px;
}

/* ---------- Liquid-glass card (shared by Blog + Series) ---------- */
.post-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    /* frosted translucent glass */
    background: linear-gradient(155deg, rgba(255,255,255,0.55), rgba(255,255,255,0.28));
    border: 1px solid rgba(255,255,255,0.55);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    backdrop-filter: blur(16px) saturate(150%);
    box-shadow: 0 8px 30px rgba(11,16,20,0.10), inset 0 1px 0 rgba(255,255,255,0.65);
    transition: transform 0.30s cubic-bezier(0.16,1,0.3,1), box-shadow 0.30s, border-color 0.30s, background 0.30s;
}
/* glossy top sheen */
.post-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 45%;
    background: linear-gradient(180deg, rgba(255,255,255,0.45), rgba(255,255,255,0));
    pointer-events: none;
    opacity: 0.7;
}
html[data-theme="dark"] .post-card {
    background: linear-gradient(155deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 8px 30px rgba(0,0,0,0.40), inset 0 1px 0 rgba(255,255,255,0.10);
}
html[data-theme="dark"] .post-card::before {
    background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0));
    opacity: 0.5;
}
.post-card:hover {
    transform: translateY(-6px);
    border-color: rgba(40,198,168,0.55);
    box-shadow: 0 22px 60px rgba(11,16,20,0.20), 0 0 0 1px rgba(40,198,168,0.18), inset 0 1px 0 rgba(255,255,255,0.7);
}
html[data-theme="dark"] .post-card:hover {
    box-shadow: 0 22px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(40,198,168,0.25), inset 0 1px 0 rgba(255,255,255,0.12);
}
/* keep card content above the glass sheen */
.post-card > * { position: relative; z-index: 1; }

/* ---------- Series card (shows latest 3 episodes) ---------- */
#series-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.series-card { padding: 0; }
.series-card-head { display: block; text-decoration: none; color: inherit; }
.series-card .post-body { padding-bottom: 8px; }

.series-eps { padding: 4px 18px 6px; display: flex; flex-direction: column; gap: 4px; }
.series-eps-label {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--muted-dark); margin: 6px 4px 6px;
}
.series-eps-label i { width: 13px; height: 13px; color: var(--teal); }
.series-ep {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 10px;
    text-decoration: none; color: var(--ink);
    background: rgba(255,255,255,0.30);
    border: 1px solid rgba(255,255,255,0.40);
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
html[data-theme="dark"] .series-ep {
    background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.08);
}
.series-ep:hover { background: rgba(40,198,168,0.12); border-color: rgba(40,198,168,0.35); transform: translateX(2px); }
.series-ep-num {
    flex-shrink: 0; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.04em;
    color: var(--teal); background: rgba(40,198,168,0.12); border: 1px solid rgba(40,198,168,0.22);
    padding: 3px 7px; border-radius: 6px; min-width: 40px; text-align: center;
}
.series-ep-title {
    flex: 1; font-size: 0.88rem; font-weight: 700; line-height: 1.2;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.series-ep > i { width: 15px; height: 15px; color: var(--muted-dark); flex-shrink: 0; }
.series-eps--empty { color: var(--muted-dark); font-size: 0.85rem; padding: 10px 22px 4px; }

.series-card-foot {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: auto; padding: 14px 22px; text-decoration: none;
    border-top: 1px solid rgba(255,255,255,0.35); color: var(--muted-dark); font-size: 0.84rem;
}
html[data-theme="dark"] .series-card-foot { border-top-color: rgba(255,255,255,0.08); }
.series-card-foot span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.series-card-foot i { width: 15px; height: 15px; }
.series-card-foot .read-more { display: inline-flex; align-items: center; gap: 5px; color: var(--teal); font-weight: 700; }

/* ---------- Series hero: full-width + shine heading ---------- */
.series-hero .wrap { max-width: 100%; }
.series-hero h1 {
    font-size: clamp(2.8rem, 7vw, 5.6rem);
    max-width: 18ch;
    background: linear-gradient(100deg, var(--ink) 18%, var(--teal) 38%, #7fe6d2 50%, var(--teal) 62%, var(--ink) 82%);
    background-size: 220% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: shine-sweep 6s linear infinite;
}
@keyframes shine-sweep {
    to { background-position: 220% center; }
}
@media (prefers-reduced-motion: reduce) {
    .series-hero h1 { animation: none; }
}

.post-cover {
    aspect-ratio: 16 / 9;
    width: 100%;
    object-fit: cover;
    background: linear-gradient(135deg, #172229, #28c6a8);
    display: block;
}
.post-cover-fallback {
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--night), #1c3b3a);
    color: var(--teal);
}
.post-cover-fallback i { width: 40px; height: 40px; opacity: 0.5; }
.post-body { padding: 22px 22px 24px; display: flex; flex-direction: column; flex: 1; }
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.post-tag {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--teal);
    background: rgba(40, 198, 168, 0.1);
    border: 1px solid rgba(40, 198, 168, 0.2);
    padding: 3px 9px;
    border-radius: 6px;
}
.post-card h3 {
    font-family: "Instrument Serif", serif;
    font-weight: 400;
    font-size: 1.5rem;
    line-height: 1.18;
    margin: 0 0 10px;
    color: var(--ink);
}
.post-excerpt { color: var(--muted-dark); font-size: 0.95rem; margin: 0 0 18px; flex: 1; }
.post-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--muted-dark);
    border-top: 1px solid var(--line-dark);
    padding-top: 14px;
}
.post-foot .read-more {
    display: inline-flex; align-items: center; gap: 5px;
    color: var(--teal); font-weight: 700;
}
.post-foot .read-more i { width: 15px; height: 15px; }
mark.hl { background: rgba(244, 184, 74, 0.4); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---------- Skeleton ---------- */
.post-card.skeleton {
    min-height: 360px;
    background: linear-gradient(100deg, var(--paper-2) 30%, rgba(127,127,127,0.08) 50%, var(--paper-2) 70%);
    background-size: 200% 100%;
    animation: shimmer 1.3s infinite;
    border-color: transparent;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Empty ---------- */
.blog-empty { text-align: center; padding: 80px 20px; color: var(--muted-dark); }
.blog-empty i { width: 46px; height: 46px; opacity: 0.4; margin-bottom: 14px; }
.blog-empty h3 { font-family: "Instrument Serif", serif; font-weight: 400; font-size: 1.8rem; margin: 0 0 8px; color: var(--ink); }

/* ---------- Footer ---------- */
.blog-footer { border-top: 1px solid var(--line-dark); padding: 30px 0; color: var(--muted-dark); font-size: 0.88rem; }
.blog-footer a { color: var(--teal); text-decoration: none; }

/* ==========================================================================
   ARTICLE PAGE (server-rendered /blog/:slug)
   ========================================================================== */
.article-wrap { max-width: 1040px; margin: 0 auto; padding: 0 24px; }
.article-head { padding: 130px 0 0; }
.article-back {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--muted-dark); text-decoration: none; font-weight: 700; font-size: 0.9rem;
    margin-bottom: 26px;
}
.article-back:hover { color: var(--teal); }
.article-head .post-tags { margin-bottom: 16px; }
.article-head h1 {
    font-family: "Instrument Serif", serif;
    font-weight: 400;
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    line-height: 1.08;
    margin: 0 0 16px;
    color: var(--ink);
}
/* Post / episode description shown under the title — the "standfirst". */
.article-standfirst {
    font-size: 1.2rem;
    line-height: 1.6;
    color: var(--muted-dark);
    margin: 0 0 20px;
}
.article-meta { display: flex; align-items: center; gap: 16px; color: var(--muted-dark); font-size: 0.9rem; margin-bottom: 30px; }
.article-cover {
    width: 100%; border-radius: 16px; margin: 0 0 38px;
    aspect-ratio: 16/9; object-fit: cover; box-shadow: var(--shadow);
}
.article-body {
    font-size: 1.12rem; line-height: 1.75; color: var(--ink); padding-bottom: 40px;
    overflow-wrap: break-word;   /* break very long URLs/strings instead of overflowing */
    word-break: break-word;
}
.article-body > * { max-width: 100%; }
.article-body a { overflow-wrap: anywhere; }
.article-body h2 { font-family: "Instrument Serif", serif; font-weight: 400; font-size: 2rem; margin: 42px 0 14px; }
.article-body h3 { font-weight: 800; font-size: 1.3rem; margin: 32px 0 10px; }
.article-body p { margin: 0 0 22px; }
.article-body a { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }
.article-body img, .article-body video, .article-body iframe {
    max-width: 100%; height: auto; border-radius: 12px; margin: 24px 0; display: block;
}
/* Embedded video players: YouTube/Vimeo 16:9 full width, TikTok 9:16 centred.
   !important + .ql-video target so Quill's bare iframe can't shrink to 300px. */
.article-body iframe,
.article-body .ql-video {
    display: block;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 12px;
    margin: 24px 0;
}
.article-body iframe[src*="tiktok"],
.article-body iframe[src*="instagram"] {
    width: 100% !important;
    max-width: 325px;
    aspect-ratio: 9 / 16;
    margin-left: auto;
    margin-right: auto;
}
.article-body ul, .article-body ol { margin: 0 0 22px; padding-left: 24px; }
.article-body li { margin-bottom: 8px; }
.article-body blockquote {
    margin: 26px 0; padding: 4px 22px; border-left: 3px solid var(--teal);
    color: var(--muted-dark); font-style: italic;
}
.article-body pre {
    background: var(--night); color: #a5d6ff; padding: 18px; border-radius: 12px;
    overflow-x: auto; font-size: 0.9rem; margin: 0 0 22px;
}
.article-body code { font-family: monospace; }
.article-body :not(pre) > code {
    background: var(--paper-2); padding: 2px 6px; border-radius: 5px; font-size: 0.9em;
}
/* Section headings use a gradient "shine" (transparent text-fill clipped to the
   text). Inline <code> inside a heading has its own background, so it inherits
   the transparent fill and would show only its grey box — restore a solid,
   readable colour so words like SUBTOTAL stay visible in headings. */
.article-body h1 code, .article-body h2 code, .article-body h3 code,
.article-body h4 code, .article-body h5 code, .article-body h6 code {
    -webkit-text-fill-color: currentColor;
    color: var(--ink);
}

/* Episode prev/next pager */
.ep-pager { display: flex; justify-content: space-between; gap: 14px; margin: 12px 0 8px; }
.ep-pager-link {
    display: inline-flex; align-items: center; gap: 10px;
    max-width: 48%; padding: 14px 16px; border-radius: 12px;
    border: 1px solid var(--line-dark); text-decoration: none; color: var(--ink);
    transition: border-color 0.2s, transform 0.2s;
}
.ep-pager-link.next { margin-left: auto; text-align: right; }
.ep-pager-link:hover { border-color: var(--teal); transform: translateY(-2px); }
.ep-pager-link span { display: flex; flex-direction: column; font-weight: 700; font-size: 0.92rem; line-height: 1.2; }
.ep-pager-link small { color: var(--muted-dark); font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 3px; }
.ep-pager-link i { width: 18px; height: 18px; color: var(--teal); flex-shrink: 0; }

/* Author bio (E-E-A-T signal under each post/episode) */
.article-author {
    display: flex; gap: 18px; align-items: flex-start;
    margin: 40px 0 8px; padding: 22px 24px;
    border: 1px solid var(--line-dark); border-radius: 16px; background: var(--paper-2);
}
.article-author .aa-avatar {
    width: 54px; height: 54px; border-radius: 50%;
    background: var(--teal); color: #08130f;
    display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; flex-shrink: 0;
}
.article-author .aa-name { font-weight: 800; font-size: 1.05rem; }
.article-author .aa-role { color: var(--muted-dark); font-size: 0.85rem; margin-top: 2px; }
.article-author .aa-bio { margin: 10px 0 12px; color: var(--ink); font-size: 0.95rem; line-height: 1.6; }
.article-author .aa-link { display: inline-flex; align-items: center; gap: 7px; color: var(--teal); font-weight: 700; text-decoration: none; font-size: 0.9rem; }
.article-author .aa-link i { width: 16px; height: 16px; }

/* Share + related */
.article-share { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 26px 0; border-top: 1px solid var(--line-dark); }
.article-share span { font-weight: 800; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-dark); }
.share-btn {
    display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid var(--line-dark); background: transparent; color: var(--ink);
    padding: 9px 15px; border-radius: 10px; cursor: pointer; text-decoration: none;
    font-weight: 700; font-size: 0.86rem; transition: all 0.2s;
}
.share-btn:hover { border-color: var(--teal); color: var(--teal); }
.share-btn i { width: 16px; height: 16px; }

/* ==========================================================================
   MOBILE — article / project / episode reading experience
   ========================================================================== */
@media (max-width: 760px) {
    /* Pull the title up closer to the topbar; 130px is too much on phones. */
    .article-head { padding: 100px 0 0; }
    .article-meta { flex-wrap: wrap; gap: 6px 12px; margin-bottom: 24px; }
    .article-body { font-size: 1.06rem; }

    /* Wide tables (comp sheets, KPI grids) and code scroll sideways inside the
       column instead of stretching the whole page — no more horizontal jiggle. */
    .article-body table {
        display: block; width: 100%; overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .article-body pre { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 640px) {
    .blog-hero { padding: 110px 0 24px; }
    .blog-grid { grid-template-columns: 1fr; }

    /* Episode prev/next stacks so long titles stay readable. */
    .ep-pager { flex-direction: column; }
    .ep-pager-link, .ep-pager-link.next { max-width: 100%; margin-left: 0; text-align: left; }
    .ep-pager-link.next { flex-direction: row-reverse; justify-content: flex-end; }
}

@media (max-width: 440px) {
    .article-wrap { padding: 0 16px; }
    .article-head { padding: 88px 0 0; }
}

/* On mobile, show only the "AA" mark in the brand — hide the long name/tagline,
   matching the home and projects pages. */
@media (max-width: 680px) {
    .brand .brand-copy { display: none; }
}
