/*
 * ChillByte — blog: listing, post cards, single post and article
 * typography. Loaded after style.css on non-page views, and inside the post
 * editor (with blog-editor.css) so posts look the same while writing.
 */

/* ---------- listing ---------- */

  .cb-blog-head { padding-top: clamp(56px, 7vw, 100px); padding-bottom: 0; }
  .cb-blog-head .cb-lede { margin-top: 40px; }
  .cb-blog-list { padding-top: clamp(48px, 6vw, 80px); }

  .cb-blog-cats {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding-bottom: 32px; margin-bottom: 48px;
    border-bottom: 1px solid var(--rule-soft);
  }
  .cb-blog-cats a {
    display: inline-flex; align-items: center; gap: 8px;
    height: 36px; padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--rule-soft);
    font-family: var(--mono); font-size: 11px;
    letter-spacing: .1em; text-transform: uppercase;
    transition: background .18s, color .18s, border-color .18s;
  }
  .cb-blog-cats a span { color: var(--accent); }
  .cb-blog-cats a:hover { border-color: var(--ink); }
  .cb-blog-cats a.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
  .cb-blog-cats a.active span { color: var(--accent-2); }

  .cb-blog-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 24px; padding: 24px 0 8px; }

/* ---------- post cards ---------- */

  .cb-post-grid {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 56px 40px;
  }
  .cb-post { display: flex; flex-direction: column; min-width: 0; }
  .cb-post-media {
    display: block; position: relative; overflow: hidden;
    aspect-ratio: 16 / 10;
    background: var(--paper-2);
    border-radius: 4px;
  }
  .cb-post-media img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    transition: transform .5s cubic-bezier(.2,.7,.2,1);
  }
  .cb-post:hover .cb-post-media img { transform: scale(1.03); }

  /* No featured image: the logo ring on paper, with the topic. */
  .cb-post-ph {
    position: absolute; inset: 0;
    display: flex; align-items: flex-end; padding: 20px;
  }
  .cb-post-ph::before {
    content: ""; position: absolute;
    right: -12%; top: -22%;
    width: 62%; aspect-ratio: 1;
    border-radius: 50%;
    border: clamp(22px, 4vw, 44px) solid var(--accent);
    transition: transform .5s cubic-bezier(.2,.7,.2,1);
  }
  .cb-post:hover .cb-post-ph::before { transform: rotate(-12deg) scale(1.04); }
  .cb-post-ph .cb-mono { position: relative; color: var(--ink); }

  .cb-post-body { display: flex; flex-direction: column; flex: 1; padding-top: 24px; }
  .cb-post-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; }
  .cb-post-meta a { color: var(--accent); }
  .cb-post-meta a:hover { color: var(--ink); }
  .cb-post-title {
    font-family: var(--serif); font-weight: 800;
    font-size: clamp(22px, 1.9vw, 28px);
    line-height: 1.08; letter-spacing: -.025em;
    margin: 14px 0 12px;
    text-wrap: balance; overflow-wrap: break-word;
  }
  .cb-post-title a { transition: color .18s; }
  .cb-post:hover .cb-post-title a { color: var(--accent); }
  .cb-post-excerpt {
    font-family: var(--sans); font-size: 16px; line-height: 1.5;
    color: var(--ink-soft); margin: 0 0 20px;
  }
  .cb-post-foot {
    margin-top: auto; padding-top: 16px;
    border-top: 1px solid var(--rule-soft);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px;
  }
  .cb-post-more { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
  .cb-post-more .arr {
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--ink); color: var(--paper);
    display: inline-flex; align-items: center; justify-content: center;
    transition: transform .25s, background .25s;
  }
  .cb-post:hover .cb-post-more .arr { background: var(--accent); transform: translateX(2px) rotate(-45deg); }

  /* First post on the blog: wide, image left. */
  .cb-post.featured {
    display: grid; grid-template-columns: 1.25fr 1fr;
    gap: 56px; align-items: center;
    padding-bottom: 64px; margin-bottom: 64px;
    border-bottom: 1px solid var(--rule-soft);
  }
  .cb-post.featured .cb-post-body { padding-top: 0; }
  .cb-post.featured .cb-post-title { font-size: clamp(32px, 3.6vw, 56px); line-height: .98; letter-spacing: -.035em; }
  .cb-post.featured .cb-post-excerpt { font-size: clamp(17px, 1.3vw, 19px); }
  .cb-post.featured .cb-post-foot { margin-top: 12px; }

  /* Pagination */
  .cb-pager {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    margin-top: 72px; padding-top: 32px;
    border-top: 1px solid var(--rule-soft);
  }
  .cb-pager .page-numbers {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 44px; height: 44px; padding: 0 14px;
    border-radius: 999px; border: 1px solid var(--rule-soft);
    font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  }
  .cb-pager a.page-numbers:hover { border-color: var(--ink); }
  .cb-pager .current { background: var(--ink); border-color: var(--ink); color: var(--paper); }
  .cb-pager .dots { border-color: transparent; }
  .cb-pager .prev { margin-right: auto; }
  .cb-pager .next { margin-left: auto; }

/* ---------- single post ---------- */

  .cb-article-head { padding-top: clamp(56px, 7vw, 100px); padding-bottom: clamp(48px, 6vw, 80px); }
  a.cb-pill { transition: background .18s, color .18s; }
  a.cb-pill:hover { background: var(--ink); color: var(--paper); }
  .cb-article-title {
    font-family: var(--serif); font-weight: 900;
    font-size: clamp(calc(44px * var(--fs-post-title-scale, 1)), calc(6.4vw * var(--fs-post-title-scale, 1)), calc(96px * var(--fs-post-title-scale, 1)));
    line-height: .94; letter-spacing: -.04em;
    margin: 0; max-width: 18ch;
    text-wrap: balance; overflow-wrap: break-word;
  }
  .cb-article-lede { margin-top: 32px; }
  .cb-article-head .cb-hero-meta { margin-top: 56px; }
  .cb-article-head .cb-hero-meta .v { font-size: 18px; }

  .cb-article-media { margin: 0 auto; }
  .cb-article-media img { display: block; width: 100%; height: auto; border-radius: 4px; }
  .cb-article-media figcaption,
  .cb-prose figcaption,
  .cb-prose .wp-element-caption {
    font-family: var(--sans); font-size: 14px; line-height: 1.45;
    color: var(--ink-muted); margin-top: 12px; text-align: left;
  }

  .cb-article-foot {
    max-width: calc(720px + 2 * var(--gutter));
    margin: 0 auto; padding: 48px var(--gutter) clamp(80px, 10vw, 120px);
    display: flex; flex-wrap: wrap; gap: 24px; align-items: center; justify-content: space-between;
  }
  .cb-article-tags { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
  .cb-article-tags a { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); }
  .cb-article-tags a:hover { color: var(--accent); }

  .cb-related .cb-post-media { background: var(--paper); }
  .cb-related .two-up-end { align-items: end; }
  .cb-related-all { justify-self: end; }

/* ---------- article typography (front end + editor) ---------- */

  .cb-prose {
    max-width: calc(720px + 2 * var(--gutter));
    margin: 0 auto;
    padding: clamp(56px, 7vw, 96px) var(--gutter) 0;
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) {
    font-family: var(--sans);
    font-size: var(--fs-prose, 19px); line-height: 1.65;
    color: var(--ink);
  }
  .cb-prose > * { margin-top: 0; margin-bottom: 1.3em; }
  .cb-prose > :last-child { margin-bottom: 0; }

  :is(.cb-prose, .editor-styles-wrapper .is-root-container) :is(h2, h3, h4, h5, h6) {
    font-family: var(--serif); color: var(--ink);
    text-wrap: balance; overflow-wrap: break-word;
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) h2 {
    font-weight: 800; font-size: clamp(30px, 3.2vw, 44px);
    line-height: 1.02; letter-spacing: -.03em;
    margin: 2em 0 .6em;
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) h3 {
    font-weight: 800; font-size: clamp(23px, 2.1vw, 29px);
    line-height: 1.1; letter-spacing: -.02em;
    margin: 1.8em 0 .5em;
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) h4 {
    font-family: var(--sans); font-weight: 700; font-size: 20px;
    line-height: 1.3; letter-spacing: -.01em;
    margin: 1.6em 0 .4em;
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) :is(h2, h3, h4) em { font-style: normal; font-weight: 900; color: var(--accent); }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) > :is(h2, h3, h4):first-child { margin-top: 0; }

  :is(.cb-prose, .editor-styles-wrapper .is-root-container) a:not(.cb-btn):not(.wp-block-button__link) {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    transition: color .18s;
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) a:not(.cb-btn):not(.wp-block-button__link):hover { color: var(--accent); }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) strong { font-weight: 700; }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) :is(mark, .hl) {
    background: var(--accent-2); color: #141414; padding: 0 .12em;
    box-decoration-break: clone; -webkit-box-decoration-break: clone;
  }

  :is(.cb-prose, .editor-styles-wrapper .is-root-container) :is(ul, ol):not(.cb-list) { padding-left: 1.3em; }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) li { margin-bottom: .4em; }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) li::marker { color: var(--accent); }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) ol li::marker { font-family: var(--mono); font-size: .8em; }

  :is(.cb-prose, .editor-styles-wrapper .is-root-container) blockquote:not(.wp-block-pullquote blockquote) {
    margin: 2em 0; padding: 4px 0 4px 28px;
    border-left: 3px solid var(--accent);
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) blockquote p {
    font-family: var(--serif); font-weight: 800;
    font-size: clamp(23px, 2.2vw, 30px);
    line-height: 1.2; letter-spacing: -.02em;
    margin: 0 0 .5em;
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) blockquote :is(cite, footer) {
    display: block; font-family: var(--mono); font-style: normal;
    font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
    color: var(--ink-muted);
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) .wp-block-pullquote {
    margin: 2.4em 0; padding: 40px 0;
    border-top: 1.5px solid var(--ink); border-bottom: 1px solid var(--rule-soft);
    text-align: left;
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) .wp-block-pullquote blockquote { margin: 0; padding: 0; border: 0; }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) .wp-block-pullquote p {
    font-size: clamp(30px, 3.4vw, 46px); line-height: 1.02; letter-spacing: -.035em;
  }

  :is(.cb-prose, .editor-styles-wrapper .is-root-container) code {
    font-family: var(--mono); font-size: .86em;
    background: var(--paper-2); padding: .12em .36em; border-radius: 4px;
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) pre {
    font-family: var(--mono); font-size: 14px; line-height: 1.6;
    background: var(--ink); color: var(--paper);
    padding: 24px 28px; border-radius: 4px;
    overflow-x: auto;
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) pre code { background: none; padding: 0; font-size: inherit; color: inherit; }

  :is(.cb-prose, .editor-styles-wrapper .is-root-container) img { max-width: 100%; height: auto; }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) .wp-block-image img { border-radius: 4px; }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) :is(figure, .wp-block-image, .wp-block-embed, .wp-block-gallery, .wp-block-table) { margin: 2em 0; }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) .wp-block-embed iframe { max-width: 100%; }

  :is(.cb-prose, .editor-styles-wrapper .is-root-container) :is(hr, .wp-block-separator) {
    border: 0; border-top: 1px solid var(--rule-soft);
    margin: 3em 0; opacity: 1;
  }

  :is(.cb-prose, .editor-styles-wrapper .is-root-container) table { width: 100%; border-collapse: collapse; font-size: 16px; }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) :is(th, td) {
    text-align: left; padding: 12px 16px 12px 0;
    border: 0; border-bottom: 1px solid var(--rule-soft);
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) th {
    font-family: var(--mono); font-weight: 500; font-size: 11px;
    letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted);
    border-bottom-color: var(--rule);
  }

  /* Core Buttons block → the site's pill buttons. */
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) .wp-block-buttons { gap: 14px; margin: 2em 0; }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) .wp-block-button__link {
    display: inline-flex; align-items: center;
    height: 56px; padding: 0 26px;
    border-radius: 999px;
    font-family: var(--sans); font-weight: 600; font-size: 15px; letter-spacing: -.005em;
    background: var(--accent); color: #fff;
    border: 1.5px solid var(--accent);
    text-decoration: none;
    transition: transform .18s, background .18s, color .18s, border-color .18s;
  }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) .wp-block-button__link:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); transform: translateY(-1px); }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) .is-style-outline .wp-block-button__link { background: transparent; color: var(--ink); border-color: var(--rule); }
  :is(.cb-prose, .editor-styles-wrapper .is-root-container) .is-style-outline .wp-block-button__link:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }

  /* Wide / full images and ChillByte sections break out of the text column. */
  .cb-prose .alignwide {
    width: min(1080px, 100vw - 2 * var(--gutter));
    max-width: none;
    margin-left: calc(50% - min(540px, 50vw - var(--gutter)));
  }
  .cb-prose :is(.alignfull, .cb-breakout) {
    width: 100vw; max-width: none;
    margin-left: calc(50% - 50vw);
  }
  .cb-prose .cb-breakout { margin-top: 3em; margin-bottom: 3em; }
  .cb-prose .alignfull img { border-radius: 0; }
  .cb-prose .alignleft { float: left; margin: .3em 32px 1em 0; max-width: 50%; }
  .cb-prose .alignright { float: right; margin: .3em 0 1em 32px; max-width: 50%; }
  .cb-prose::after { content: ""; display: block; clear: both; }

/* ---------- responsive ---------- */

  @media (max-width: 1024px) {
    .cb-post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cb-post.featured { grid-template-columns: 1fr; gap: 28px; }
  }
  @media (max-width: 760px) {
    .cb-post-grid { grid-template-columns: 1fr; gap: 48px; }
    .cb-post.featured { padding-bottom: 48px; margin-bottom: 48px; }
    .cb-blog-cats { margin-bottom: 36px; padding-bottom: 24px; }
    .cb-pager .prev, .cb-pager .next { margin: 0; }
    :is(.cb-prose, .editor-styles-wrapper .is-root-container) { font-size: calc(var(--fs-prose, 19px) - 1px); }
    .cb-prose .alignleft, .cb-prose .alignright { float: none; margin: 2em 0; max-width: 100%; }
    .cb-related-all { justify-self: start; }
  }
