/*
 * Blog pages for visitors (/blog, /blog/<post>, /blog/tag/<topic>). The server writes the HTML (server/blog.js).
 * Tokens and buttons come from src/ui/brand.css; the top bar and footer from src/home/home.css.
 */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.blog-page main { padding-bottom: clamp(80px, 10vw, 140px); }
.nav-links a[aria-current="page"] { color: var(--graphite); }
.foot-note a { margin-left: 20px; }

/* ---------- list pages ---------- */

.blog-head,
.blog-wrap,
.related {
    max-width: 1320px;
    margin: 0 auto;
    padding-left: var(--gutter);
    padding-right: var(--gutter);
}

.blog-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: end;
    gap: 24px 48px;
    padding-top: clamp(40px, 7vw, 104px);
    padding-bottom: clamp(28px, 4vw, 48px);
}
.blog-title {
    font-size: clamp(44px, 6.2vw, 100px);
    font-weight: 470;
    letter-spacing: -0.035em;
    line-height: 0.95;
}
.blog-intro { max-width: 34em; margin: 20px 0 0; color: var(--slate); font-size: 18px; }
.blog-crumb { margin: 0 0 14px; color: var(--slate); font-size: 14px; }
.blog-crumb a { color: var(--graphite); }
.blog-search { display: flex; gap: 8px; width: min(400px, 100%); }
.blog-search .input { flex: 1; min-width: 0; }

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: clamp(28px, 4vw, 44px);
    border-bottom: 1px solid var(--hair);
}
.tag-row a {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--hair-2);
    border-radius: 999px;
    color: var(--graphite);
    font-size: 14px;
    text-decoration: none;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.tag-row a:hover { border-color: var(--graphite); }
.tag-row a[aria-current="page"] { background: var(--graphite); border-color: var(--graphite); color: var(--porcelain); }

.kicker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 8px;
    margin: 0;
    color: var(--slate);
    font-size: 14px;
}
.kicker a { color: var(--graphite); font-weight: 560; text-decoration: none; }
.kicker a:hover { text-decoration: underline; text-underline-offset: 3px; }
.kicker .sep { color: var(--hair-2); }

/* the lead post: the featured one, or the newest */
.lead-post {
    display: grid;
    grid-template-columns: 7fr 5fr;
    gap: clamp(24px, 4vw, 64px);
    align-items: center;
    padding: clamp(32px, 4vw, 56px) 0;
    border-bottom: 1px solid var(--hair);
}
.lead-pic {
    display: block;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    border-radius: var(--r-m);
    background: radial-gradient(120% 90% at 50% 35%, var(--paper) 0%, #e3e7ea 100%);
}
.lead-pic img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
.lead-post:hover .lead-pic img { transform: scale(1.02); }
.lead-title {
    margin: 16px 0 0;
    font-size: clamp(32px, 3.7vw, 58px);
    font-weight: 480;
    letter-spacing: -0.028em;
    line-height: 1.02;
}
.lead-title a { text-decoration: none; }
.lead-title a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.lead-excerpt { max-width: 30em; margin: 18px 0 28px; color: var(--slate); font-size: 18px; }

/* cards */
.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
    gap: clamp(40px, 4vw, 60px) clamp(16px, 2vw, 28px);
    margin: 0;
    padding: clamp(36px, 4vw, 56px) 0 0;
    list-style: none;
}
.card-link { display: block; color: inherit; text-decoration: none; }
.card-pic {
    aspect-ratio: 3 / 2;
    margin-bottom: 16px;
    overflow: hidden;
    border-radius: var(--r-m);
    background: radial-gradient(120% 90% at 50% 35%, var(--paper) 0%, #e3e7ea 100%);
}
.card-pic img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
.card-link:hover .card-pic img { transform: scale(1.035); }
.card-blank { display: grid; place-items: center; width: 100%; height: 100%; color: var(--hair-2); }
.card-blank svg { width: 56px; height: 56px; }
.card-title { margin: 10px 0 0; font-size: 22px; font-weight: 560; line-height: 1.18; }
.card-link:hover .card-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.card-excerpt {
    display: -webkit-box;
    margin: 10px 0 0;
    overflow: hidden;
    color: var(--slate);
    font-size: 16px;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: clamp(48px, 6vw, 80px);
    padding-top: 24px;
    border-top: 1px solid var(--hair);
}
.pager-n { color: var(--slate); font-size: 14px; }

.blog-empty { max-width: 520px; padding: 48px 0 0; }
.blog-empty .dim { width: 120px; }
.blog-empty p { margin: 20px 0 24px; color: var(--slate); font-size: 18px; }

/* ---------- a post ----------
 * One grid for the whole article: text sits in a 680 px reading column; pictures can go wide or full width. */

.post-head,
.post-cover,
.post-body,
.post-foot {
    display: grid;
    grid-template-columns:
        [full-start] minmax(var(--gutter), 1fr)
        [wide-start] minmax(0, 180px)
        [text-start] min(680px, calc(100% - 2 * var(--gutter)))
        [text-end] minmax(0, 180px)
        [wide-end] minmax(var(--gutter), 1fr)
        [full-end];
}
.post-head > *, .post-body > *, .post-foot > * { grid-column: text; }
.post-body > .wide, .post-cover > * { grid-column: wide; }
.post-body > .full { grid-column: full; }

.post { padding-top: clamp(36px, 6vw, 96px); }
.post-title {
    grid-column: text-start / wide-end;
    max-width: 15em;
    margin: 18px 0 0;
    font-size: clamp(40px, 5.4vw, 80px);
    font-weight: 470;
    letter-spacing: -0.034em;
    line-height: 0.98;
}
.post-standfirst { margin: 26px 0 0; color: var(--slate); font-size: clamp(19px, 1.6vw, 22px); line-height: 1.5; }
.post-byline { margin: 24px 0 0; padding-top: 18px; border-top: 1px solid var(--hair); color: var(--graphite); font-size: 15px; font-weight: 520; }

.post-cover { margin: clamp(32px, 4vw, 56px) 0 0; }
.post-cover img { width: 100%; height: auto; border-radius: var(--r-m); background: var(--paper); }

.post-body {
    margin-top: clamp(36px, 4vw, 56px);
    font-size: 19px;
    line-height: 1.7;
}
.post-body > p { margin: 0 0 1.2em; }
.post-body a { text-decoration-thickness: 1px; text-underline-offset: 3px; }
.post-body a:hover { text-decoration-thickness: 2px; }
.post-body h2 { margin: 1.9em 0 0.55em; font-size: 31px; font-weight: 560; line-height: 1.15; scroll-margin-top: calc(var(--nav-h) + 16px); }
.post-body h3 { margin: 1.6em 0 0.45em; font-size: 23px; font-weight: 560; line-height: 1.2; scroll-margin-top: calc(var(--nav-h) + 16px); }
.post-body > :first-child { margin-top: 0; }
.post-body ul, .post-body ol { margin: 0 0 1.3em; padding-left: 1.3em; }
.post-body li { margin: 0.35em 0; padding-left: 0.2em; }
.post-body li::marker { color: var(--slate); }
.post-body code {
    padding: 0.12em 0.36em;
    border-radius: 4px;
    background: rgba(29, 34, 38, 0.07);
    font: 0.86em/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.post-body pre.code {
    margin: 1.6em 0;
    padding: 20px 22px;
    overflow: auto;
    border-radius: var(--r-m);
    background: var(--graphite);
    color: #e7ebee;
    font: 14.5px/1.65 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    tab-size: 4;
}
.post-body pre.code code { padding: 0; background: none; font: inherit; }

.post-body blockquote {
    margin: 1.7em 0;
    padding: 2px 0 2px 26px;
    border-left: 2px solid var(--graphite);
}
.post-body blockquote p {
    margin: 0;
    font-size: clamp(22px, 2vw, 26px);
    font-stretch: var(--wide);
    font-weight: 450;
    letter-spacing: -0.012em;
    line-height: 1.38;
}
.post-body blockquote cite { display: block; margin-top: 14px; color: var(--slate); font-size: 15px; font-style: normal; }

.post-body figure { margin: 2.1em 0; }
.post-body figure img { width: 100%; height: auto; border-radius: var(--r-m); background: var(--paper); }
.post-body figure.full img { border-radius: 0; }
.post-body figcaption { margin-top: 12px; color: var(--slate); font-size: 14px; line-height: 1.5; }
.post-body figure.full figcaption { padding: 0 var(--gutter); }

.gallery-grid { display: grid; gap: 10px; }
.gallery-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gallery-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gallery-grid img { aspect-ratio: 1; object-fit: cover; }
.gallery-grid.cols-2 img { aspect-ratio: 4 / 3; }
.gallery-grid.cols-1 img { aspect-ratio: auto; }

/* videos and 3D products: a picture and a play button until the visitor asks for them */
.frame {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--r-m);
    background: var(--graphite);
    color: inherit;
    text-decoration: none;
}
.post-model .frame { aspect-ratio: 4 / 3; background: radial-gradient(120% 90% at 50% 35%, var(--paper) 0%, #e3e7ea 100%); }
.post-model.wide .frame { aspect-ratio: 16 / 9; }
.full .frame { border-radius: 0; }
.post-body .frame img, .frame video, .frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; background: none; }
.post-body .frame img { object-fit: cover; transition: transform 0.6s var(--ease), opacity 0.2s; }
.frame video { object-fit: contain; background: #000; }
.frame.play:hover img { transform: scale(1.02); }
.play-btn {
    position: absolute;
    left: 50%;
    top: 50%;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 50px;
    padding: 0 22px 0 18px;
    border-radius: 999px;
    background: var(--graphite);
    color: var(--porcelain);
    font-size: 15px;
    font-weight: 560;
    white-space: nowrap;
    transform: translate(-50%, -50%);
    box-shadow: 0 10px 30px -10px rgba(29, 34, 38, 0.6);
    transition: transform 0.2s var(--ease), background-color 0.15s;
}
.play-btn svg { width: 20px; height: 20px; }
.frame.play:hover .play-btn { transform: translate(-50%, -50%) scale(1.04); background: var(--graphite-2); }

.post-cta { margin: 1.8em 0; }
.link-card {
    display: grid;
    gap: 6px;
    margin: 1.7em 0;
    padding: 20px 22px;
    border: 1px solid var(--hair-2);
    border-radius: var(--r-m);
    background: var(--paper);
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s;
}
.post-body a.link-card { text-decoration: none; }
.link-card:hover { border-color: var(--graphite); }
.lc-title { font-stretch: var(--wide); font-size: 18px; font-weight: 560; line-height: 1.3; }
.lc-text { color: var(--slate); font-size: 15px; line-height: 1.5; }
.lc-host { color: var(--slate); font-size: 13px; }

.post-divider { justify-self: center; width: 120px; margin: 2.4em 0; }

.post-foot { margin-top: clamp(48px, 5vw, 72px); }
.post-foot > * { border-top: 1px solid var(--hair); }
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 24px 0 0; }
.post-tags + .share { border-top: 0; }
.post-tags .tag { text-decoration: none; height: 30px; padding: 0 12px; font-size: 13.5px; }
.post-tags .tag:hover { background: rgba(29, 34, 38, 0.12); }
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 22px 0 0; }
.share-label { margin-right: 6px; color: var(--slate); font-size: 14px; }

.related { margin-top: clamp(80px, 9vw, 130px); padding-top: clamp(40px, 5vw, 64px); border-top: 1px solid var(--hair); }
.related-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 16px; }
.related-title { font-size: clamp(30px, 3.4vw, 50px); font-weight: 480; letter-spacing: -0.026em; }

.preview-bar {
    position: sticky;
    top: var(--nav-h);
    z-index: 15;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px var(--gutter);
    background: var(--amber-soft);
    color: var(--amber-ink);
    font-size: 14px;
}
.preview-bar .btn { margin-left: auto; }

@media (max-width: 900px) {
    .lead-post { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .post-body { font-size: 18px; }
    .post-body h2 { font-size: 26px; }
    .gallery-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .play-btn { height: 44px; font-size: 14px; }
    .pager .btn { padding: 0 14px; }
    .foot-note a { margin-left: 14px; }
}
