/* ============================================================
   Weky — blog.css
   Loaded *after* styles.css on /blog pages. Reuses the same
   tokens (ember / ivory / glass) so the blog reads as the same
   site, with a wider, quieter layout built for long reading.
   ============================================================ */

:root {
  --blog-maxw:  1180px;   /* listing grid */
  --read-maxw:  720px;    /* article measure — ~72 chars */
  --toc-w:      248px;
}

/* ---------- Reading progress bar (article pages) ---------- */

.read-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--ember), var(--ember-deep));
  z-index: 60; transition: width .1s linear;
}

/* ---------- Blog hero ---------- */

.blog-hero { padding: 68px 0 44px; text-align: center; }
.blog-hero h1 { font-size: clamp(40px, 6.6vw, 76px); line-height: 1.02; margin: 0 0 20px; }
.blog-hero .lede { max-width: 56ch; margin: 0 auto; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 16px 7px 13px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ember); background: var(--ember-soft);
  border: 1px solid color-mix(in srgb, var(--ember) 26%, transparent);
  margin-bottom: 22px;
}
.pill svg { width: 14px; height: 14px; }

/* ---------- Search + subscribe ---------- */

.blog-tools { display: grid; gap: 16px; justify-items: center; margin-top: 34px; }

.search-box { position: relative; width: min(460px, 100%); }
.search-box svg {
  position: absolute; left: 17px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--text-faint); pointer-events: none;
}
.search-box input {
  width: 100%; padding: 14px 44px 14px 46px;
  font: inherit; font-size: 15.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-firm);
  border-radius: 999px;
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.search-box input::placeholder { color: var(--text-faint); }
.search-box input:focus {
  outline: none; border-color: var(--ember);
  box-shadow: 0 0 0 4px var(--ember-soft);
}
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: none; place-items: center; width: 28px; height: 28px;
  border: 0; border-radius: 50%; cursor: pointer; font-size: 17px; line-height: 1;
  background: var(--surface-deep); color: var(--text-soft);
}
.search-box.has-value .search-clear { display: grid; }

/* ---------- Newsletter signup ---------- */

.sub-form { width: min(520px, 100%); }
.sub-row { display: flex; gap: 10px; }

.sub-field { position: relative; flex: 1; }
.sub-field svg {
  position: absolute; left: 17px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-faint); pointer-events: none;
}
.sub-field input {
  width: 100%; padding: 14px 20px 14px 46px;
  font: inherit; font-size: 15.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-firm);
  border-radius: 999px;
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.sub-field input::placeholder { color: var(--text-faint); }
.sub-field input:focus {
  outline: none; border-color: var(--ember);
  box-shadow: 0 0 0 4px var(--ember-soft);
}

.sub-btn { flex: none; padding: 14px 28px; font-size: 15.5px; }
.sub-form.is-busy .sub-btn { opacity: .65; cursor: progress; }
.sub-btn:disabled { transform: none; }

/* Off-screen, not display:none — bots skip hidden fields. */
.sub-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.sub-note { margin: 13px 0 0; font-size: 13px; line-height: 1.5; color: var(--text-faint); }
.sub-note a { color: var(--text-faint); text-decoration: underline; text-underline-offset: 2px; }
.sub-note a:hover { color: var(--ember); }

.sub-msg { margin: 10px 0 0; font-size: 14px; font-weight: 600; min-height: 1.2em; color: var(--text-soft); }
.sub-msg.is-ok { color: var(--ember); }
.sub-msg.is-error { color: #C0392B; }
@media (prefers-color-scheme: dark) { .sub-msg.is-error { color: #F0776A; } }

/* The form when it sits inside a glass card rather than the hero */
.sub-card .sub-form { margin: 0 auto; }
.sub-card .sub-note { text-align: center; }
.sub-card .sub-msg { text-align: center; }

@media (max-width: 520px) {
  .sub-row { flex-direction: column; }
  .sub-btn { width: 100%; }
}

/* ---------- Category filter ---------- */

.cat-bar {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 9px;
  margin: 0 0 42px; padding: 0; list-style: none;
}
.cat {
  padding: 8px 17px; border-radius: 999px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; font-family: inherit;
  color: var(--text-soft); background: var(--surface);
  border: 1px solid var(--border); backdrop-filter: blur(10px);
  transition: all .2s ease;
}
.cat:hover { color: var(--text); border-color: var(--border-firm); }
.cat[aria-pressed="true"] { background: var(--ember); border-color: var(--ember); color: #fff; }

/* ---------- Cards ---------- */

.post-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  color: var(--text-faint); font-size: 13.5px; margin-bottom: 14px;
}
.post-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }
.post-meta .tag {
  padding: 4px 11px; border-radius: 999px; font-weight: 700; font-size: 11.5px;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ember); background: var(--ember-soft);
}

/* Featured — image left, copy right; stacks on tablet down. */
.featured {
  color: inherit;
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 0;
  border-radius: var(--radius-lg); overflow: hidden;
  margin-bottom: 56px; position: relative;
  transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease;
}
.featured:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg);
                  border-color: color-mix(in srgb, var(--ember) 40%, transparent); }
.featured-art {
  position: relative; min-height: 320px; overflow: hidden;
  background: linear-gradient(150deg,
              color-mix(in srgb, var(--ember) 26%, var(--surface-deep)),
              var(--surface-deep));
}
.featured-art img { width: 100%; height: 100%; object-fit: cover;
                    transition: transform .5s cubic-bezier(.2,.7,.3,1); }
.featured:hover .featured-art img { transform: scale(1.04); }
.featured-flag {
  position: absolute; top: 18px; left: 18px; z-index: 2;
  padding: 6px 14px; border-radius: 999px; font-size: 11.5px; font-weight: 800;
  letter-spacing: .09em; text-transform: uppercase;
  background: var(--charcoal); color: #fff;
}
.featured-body { padding: 40px 38px; display: flex; flex-direction: column; justify-content: center; }
.featured-body h2 { font-size: clamp(24px, 3vw, 34px); margin-bottom: 14px; }
.featured-body p { color: var(--text-soft); margin: 0 0 26px; font-size: 16px;
                   display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: auto; }

.author { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff;
  background: linear-gradient(140deg, var(--ember), var(--ember-deep));
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.author-name { font-size: 14.5px; font-weight: 650; line-height: 1.25; }
.author-role { font-size: 12.5px; color: var(--text-faint); line-height: 1.25; }

.read-more { display: inline-flex; align-items: center; gap: 7px; color: var(--ember);
             font-weight: 700; font-size: 14.5px; white-space: nowrap; }
.read-more span { transition: transform .2s ease; }
.featured:hover .read-more span, .post-card:hover .read-more span { transform: translateX(4px); }

/* Grid of posts */
.post-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; }
.post-card {
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--radius); color: inherit;
  transition: transform .28s ease, box-shadow .28s ease, border-color .28s ease;
}
.post-card:hover { transform: translateY(-6px); box-shadow: var(--shadow);
                   border-color: color-mix(in srgb, var(--ember) 40%, transparent); }
.post-art {
  aspect-ratio: 16 / 10; overflow: hidden;
  background: linear-gradient(150deg,
              color-mix(in srgb, var(--ember) 20%, var(--surface-deep)), var(--surface-deep));
}
.post-art img { width: 100%; height: 100%; object-fit: cover;
                transition: transform .5s cubic-bezier(.2,.7,.3,1); }
.post-card:hover .post-art img { transform: scale(1.05); }
.post-body { padding: 24px 22px 22px; display: flex; flex-direction: column; flex: 1; }
.post-body h3 { font-size: 19.5px; line-height: 1.28; margin-bottom: 10px; }
.post-body p { color: var(--text-soft); font-size: 14.8px; line-height: 1.55; margin: 0 0 22px;
               display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Empty state — what the listing shows before the first post ships. */
.empty {
  text-align: center; padding: 76px 30px; border-radius: var(--radius-lg);
  border: 1px dashed var(--border-firm); background: var(--surface);
  backdrop-filter: blur(14px);
}
.empty-icon { width: 60px; height: 60px; border-radius: 20px; margin: 0 auto 20px;
              display: grid; place-items: center; font-size: 27px;
              background: var(--ember-soft); color: var(--ember); }
.empty h3 { font-size: 22px; margin-bottom: 10px; }
.empty p { color: var(--text-soft); margin: 0 auto; max-width: 44ch; font-size: 15.5px; }

/* ---------- Newsletter card ---------- */

.subscribe { text-align: center; padding: 54px 34px; border-radius: var(--radius-lg); }
.subscribe h2 { margin-bottom: 12px; }
.subscribe p { color: var(--text-soft); margin: 0 auto 26px; max-width: 46ch; }

/* ============================================================
   Article page
   ============================================================ */

.article-head { padding: 44px 0 8px; }
.article-head .back-link { margin-bottom: 26px; }
.article-head h1 { font-size: clamp(34px, 5.4vw, 60px); line-height: 1.05; margin: 14px 0 22px; }
.article-head .lede { max-width: 68ch; margin: 0 0 28px; }
.article-head .post-meta { font-size: 14.5px; }

.byline {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  flex-wrap: wrap; padding: 22px 0 0; border-top: 1px solid var(--border); margin-top: 26px;
}
.byline .avatar { width: 46px; height: 46px; font-size: 17px; }
.share-row { display: flex; gap: 9px; flex-wrap: wrap; }
.share-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--text-soft);
  background: var(--surface); border: 1px solid var(--border); backdrop-filter: blur(10px);
  transition: all .2s ease;
}
.share-btn:hover { color: var(--ember); border-color: var(--ember); transform: translateY(-1px); }
.share-btn svg { width: 14px; height: 14px; }

.hero-art {
  margin: 38px 0 0; border-radius: var(--radius-lg); overflow: hidden;
  aspect-ratio: 21 / 9; border: 1px solid var(--border);
  background: linear-gradient(150deg,
              color-mix(in srgb, var(--ember) 22%, var(--surface-deep)), var(--surface-deep));
}
.hero-art img { width: 100%; height: 100%; object-fit: cover; }

/* Two-column: sticky TOC, then the prose column. */
.article-layout {
  display: grid; grid-template-columns: var(--toc-w) minmax(0, 1fr);
  gap: 56px; align-items: start; padding: 54px 0 0;
}
.toc { position: sticky; top: 96px; max-height: calc(100vh - 130px); overflow-y: auto; }
.toc h4 { margin: 0 0 14px; font-size: 12px; letter-spacing: .13em;
          text-transform: uppercase; color: var(--text-faint); }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px;
          border-left: 1px solid var(--border); }
.toc a {
  display: block; padding: 7px 0 7px 16px; margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-soft); font-size: 14px; line-height: 1.4;
  transition: color .2s ease, border-color .2s ease;
}
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--ember); border-left-color: var(--ember); font-weight: 650; }
.toc .lvl-3 a { padding-left: 28px; font-size: 13.3px; color: var(--text-faint); }

/* ---------- Prose ---------- */

.prose { max-width: var(--read-maxw); font-size: 17.5px; line-height: 1.75; color: var(--text-soft); }
.prose > * + * { margin-top: 1.35em; }
.prose h2 {
  font-size: clamp(25px, 3.1vw, 32px); line-height: 1.2; color: var(--text);
  margin-top: 2.1em; margin-bottom: .55em; scroll-margin-top: 100px;
}
.prose h3 {
  font-size: 21px; line-height: 1.3; color: var(--text);
  margin-top: 1.7em; margin-bottom: .45em; scroll-margin-top: 100px;
}
.prose p { margin-bottom: 0; }
.prose strong { color: var(--text); font-weight: 700; }
.prose a { color: var(--ember); font-weight: 500; text-decoration: underline;
           text-underline-offset: 3px; text-decoration-thickness: 1px;
           text-decoration-color: color-mix(in srgb, var(--ember) 40%, transparent); }
.prose a:hover { text-decoration-color: var(--ember); }
.prose ul, .prose ol { padding-left: 4px; margin-left: 18px; display: grid; gap: .55em; }
.prose li { padding-left: 6px; }
.prose li::marker { color: var(--ember); }
.prose img, .prose figure img { border-radius: 18px; border: 1px solid var(--border); }
.prose figure { margin-left: 0; margin-right: 0; }
.prose figcaption { margin-top: 12px; font-size: 14px; color: var(--text-faint); text-align: center; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.4em 0; }

.prose blockquote {
  margin-left: 0; margin-right: 0; padding: 4px 0 4px 24px;
  border-left: 3px solid var(--ember);
  font-size: 19.5px; line-height: 1.55; color: var(--text); font-style: italic;
}
.prose blockquote cite { display: block; margin-top: 12px; font-size: 14.5px;
                         font-style: normal; color: var(--text-faint); }

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em;
  padding: 2px 7px; border-radius: 6px;
  background: var(--ember-soft); color: var(--ember-deep);
}
.prose pre {
  padding: 20px 22px; border-radius: 16px; overflow-x: auto;
  background: var(--surface-deep); border: 1px solid var(--border); font-size: 14.5px;
}
.prose pre code { background: none; padding: 0; color: var(--text); }

.prose .table-scroll { overflow-x: auto; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
.prose th, .prose td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.prose th { color: var(--text); font-weight: 700; font-size: 13px;
            letter-spacing: .06em; text-transform: uppercase; }

/* Pull-out boxes for the body copy */
.takeaways {
  padding: 26px 28px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--ember);
  backdrop-filter: saturate(160%) blur(16px);
}
.takeaways h4 { margin: 0 0 14px; font-size: 12.5px; letter-spacing: .12em;
                text-transform: uppercase; color: var(--ember); }
.takeaways ul { margin: 0 0 0 18px; }

.note {
  padding: 20px 24px; border-radius: 18px; font-size: 16px;
  background: var(--ember-soft); border: 1px solid color-mix(in srgb, var(--ember) 22%, transparent);
}
.note p:first-child { margin-top: 0; }
.note p:last-child { margin-bottom: 0; }

/* ---------- Below the article ---------- */

.article-cta {
  margin-top: 64px; padding: 40px 34px; border-radius: var(--radius-lg);
  text-align: center; max-width: var(--read-maxw);
}
.article-cta h3 { font-size: 24px; margin-bottom: 10px; }
.article-cta p { color: var(--text-soft); margin: 0 auto 24px; max-width: 42ch; font-size: 15.5px; }

.author-box {
  display: flex; gap: 18px; align-items: flex-start;
  margin-top: 28px; padding: 26px 28px; border-radius: var(--radius);
  max-width: var(--read-maxw);
}
.author-box .avatar { width: 54px; height: 54px; font-size: 20px; }
.author-box h4 { margin: 0 0 4px; font-size: 17px; }
.author-box p { margin: 0; color: var(--text-soft); font-size: 14.8px; line-height: 1.6; }

.related { padding-top: 84px; }
.related h2 { text-align: center; margin-bottom: 34px; }

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .article-layout { grid-template-columns: 1fr; gap: 0; }
  .toc {
    position: static; max-height: none; max-width: var(--read-maxw);
    margin-bottom: 34px; padding: 20px 22px;
    border-radius: 18px; background: var(--surface); border: 1px solid var(--border);
  }
  .prose, .article-cta, .author-box { margin-left: auto; margin-right: auto; }
}

@media (max-width: 940px) {
  .post-grid { grid-template-columns: repeat(2, 1fr); }
  .featured { grid-template-columns: 1fr; }
  .featured-art { min-height: 0; aspect-ratio: 16 / 9; }
  .featured-body { padding: 30px 26px 32px; }
}

@media (max-width: 640px) {
  .post-grid { grid-template-columns: 1fr; }
  .blog-hero { padding: 46px 0 34px; }
  .article-layout { padding-top: 34px; }
  .prose { font-size: 17px; }
  .byline { gap: 16px; }
  .share-row { width: 100%; }
  .share-btn { flex: 1; justify-content: center; }
  .hero-art { aspect-ratio: 16 / 10; }
}

/* ---------- Utilities ---------- */

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

/* ---------- Print (the article's Print button) ---------- */

@media print {
  .site-header, .site-footer, .liquid-bg, .read-progress,
  .toc, .share-row, .back-link, .article-cta, .related { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .article-layout { display: block; padding-top: 0; }
  .prose { max-width: none; color: #000; }
  .prose a { color: #000; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; }
  .hero-art { break-inside: avoid; }
}

.post-meta .meta-when { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
