/* =========================================================================
   Timely Blog
   Sits on top of individual-home.css (tokens, header, footer, buttons) so the
   blog reads as part of the marketing site rather than a separate template.
   Flat colours only — the covers are solid tiles with a line drawing on top.
   ========================================================================= */

/* No dark hero on blog pages: the header wears its scrolled skin from the
   first pixel. blog.js never removes .is-scrolled. */
.blog-page .site-header { color: var(--ink); }
.blog-page .desktop-nav a[aria-current="page"]::after { transform: scaleX(1); }

.blog-shell { width: var(--shell); margin-inline: auto; }

/* --- Cover tiles ---------------------------------------------------------
   Each post owns one solid colour and one drawing. Used at three sizes:
   featured, card and the wide article cover. */
.cover {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  color: var(--brown-deep);
  background: var(--cream-deep);
}

.cover svg {
  width: 46%;
  height: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.cover .fill { fill: currentColor; stroke: none; }

.cover-tan { background: #e6c6aa; }
.cover-espresso { color: var(--cream); background: var(--brown-deep); }
.cover-brown { color: var(--cream); background: var(--brown); }
.cover-sand { background: var(--cream-deep); }

/* --- Shared bits ---------------------------------------------------------- */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.post-meta .dot { opacity: 0.5; }

.post-category {
  color: var(--brown);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.read-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--brown);
  font-size: 0.9rem;
  font-weight: 600;
}

.read-link svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 220ms ease;
}

/* =========================================================================
   Index
   ========================================================================= */
.blog-intro { padding: clamp(130px, 15vw, 170px) 0 0; }

.blog-intro h1 {
  max-width: 13ch;
  margin: 0 0 22px;
  font-family: var(--display);
  font-size: clamp(2.8rem, 6.4vw, 5.4rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.065em;
}

.blog-intro h1 em { color: var(--brown); font-style: normal; }

.blog-intro .lead {
  max-width: 54ch;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: clamp(40px, 5vw, 60px) 0 clamp(28px, 3vw, 40px);
}

.filter-chip {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, transform 140ms ease;
}

.filter-chip:hover { border-color: var(--brown-soft); }
.filter-chip:active { transform: scale(0.97); }

.filter-chip[aria-pressed="true"] {
  border-color: var(--brown-deep);
  color: var(--cream);
  background: var(--brown-deep);
}

.filter-chip .count { margin-left: 4px; opacity: 0.55; font-weight: 500; }

/* Featured post */
.featured-post {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  padding-bottom: clamp(48px, 6vw, 80px);
  border-bottom: 1px solid var(--line);
}

.featured-post .cover { aspect-ratio: 16 / 11; border-radius: 22px; }

.featured-post h2 {
  margin: 16px 0 16px;
  font-family: var(--display);
  font-size: clamp(2rem, 3.6vw, 3.1rem);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.05em;
}

.featured-post p.excerpt {
  max-width: 46ch;
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.featured-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--brown-soft);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.featured-label::before {
  width: 18px;
  height: 1px;
  background: currentColor;
  content: "";
}

/* Post grid */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(36px, 4vw, 56px) clamp(24px, 3vw, 40px);
  padding: clamp(48px, 6vw, 80px) 0 clamp(90px, 10vw, 140px);
}

.post-card { display: flex; flex-direction: column; gap: 14px; }
.post-card .cover { margin-bottom: 6px; }

.post-card h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.32rem;
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.035em;
}

.post-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.6;
}

.post-card .post-meta { margin-top: auto; padding-top: 4px; }

@media (hover: hover) {
  .featured-post:hover .cover svg,
  .post-card:hover .cover svg { transform: scale(1.06) rotate(-2deg); }
  .featured-post:hover .read-link svg,
  .post-card:hover .read-link svg { transform: translateX(4px); }
  .post-card:hover h3,
  .featured-post:hover h2 { color: var(--brown); }
}

.post-card h3,
.featured-post h2 { transition: color 200ms ease; }

[data-post][hidden] { display: none !important; }

.featured-post .post-meta { margin-bottom: 22px; }

/* Closing band — same tan field as the homepage close */
.blog-closing {
  padding: clamp(80px, 10vw, 130px) 0;
  color: var(--brown-deep);
  background: #e6c6aa;
  text-align: center;
}

.blog-closing h2 {
  max-width: 16ch;
  margin: 0 auto 18px;
  font-family: var(--display);
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.blog-closing p {
  max-width: 46ch;
  margin: 0 auto 34px;
  color: rgba(53, 30, 19, 0.72);
  line-height: 1.6;
}

.closing-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 14px 22px;
}

.blog-closing .app-store-button { color: var(--cream); background: var(--brown-deep); }

.closing-actions .text-link {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

/* =========================================================================
   Article
   ========================================================================= */
.reading-progress {
  position: fixed;
  z-index: 101;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--brown);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

.article-head {
  max-width: 980px;
  padding: clamp(120px, 14vw, 160px) 0 0;
}

.article-head > * { max-width: 820px; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 26px;
  padding: 0;
  color: var(--muted);
  font-size: 0.82rem;
  list-style: none;
}

.breadcrumb a:hover { color: var(--brown); }
.breadcrumb li + li::before { margin-right: 8px; opacity: 0.5; content: "/"; }

.article-head h1 {
  margin: 0 0 20px;
  font-family: var(--display);
  font-size: clamp(2.3rem, 5.2vw, 4.1rem);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.article-dek {
  max-width: 60ch;
  margin: 0 0 32px;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  line-height: 1.6;
}

.byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 24px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.author {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
}

.author-avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--cream);
  background: var(--brown);
  font-family: var(--display);
  font-weight: 700;
}

.author strong { display: block; font-size: 0.92rem; }
.author div span { color: var(--muted); font-size: 0.8rem; }

.share-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 180ms ease, transform 140ms ease;
}

.share-button:hover { border-color: var(--brown-soft); }
.share-button:active { transform: scale(0.97); }

.share-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.article-cover { max-width: 980px; margin-top: clamp(32px, 4vw, 48px); }
.article-cover .cover { aspect-ratio: 21 / 8; border-radius: 24px; }
.article-cover .cover svg { width: min(26%, 220px); }

/* Body: sticky contents on the left, the reading column on the right */
.article-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 680px);
  justify-content: center;
  gap: clamp(40px, 6vw, 80px);
  padding: clamp(44px, 5vw, 64px) 0 clamp(80px, 9vw, 120px);
}

.toc { position: sticky; top: 110px; align-self: start; }

.toc-title {
  margin: 0 0 14px;
  color: var(--brown-soft);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.toc ol {
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
  list-style: none;
}

.toc a {
  display: block;
  margin-left: -1px;
  padding: 7px 0 7px 14px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  transition: color 180ms ease, border-color 180ms ease;
}

.toc a:hover { color: var(--ink); }
.toc a.is-active { border-left-color: var(--brown); color: var(--ink); font-weight: 600; }

/* Phones get the contents as a fold-out instead of a sidebar */
.toc-mobile { display: none; }

.prose { font-size: 1.06rem; line-height: 1.75; color: #3a2f27; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.25em; }
.prose strong { color: var(--ink); }

.prose h2 {
  margin: 2.2em 0 0.6em;
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(1.55rem, 2.4vw, 1.9rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.prose [id] { scroll-margin-top: 110px; }

.prose h3 {
  margin: 1.8em 0 0.45em;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.prose ul,
.prose ol { margin: 0 0 1.4em; padding-left: 1.3em; }
.prose li { margin-bottom: 0.55em; padding-left: 0.2em; }
.prose li::marker { color: var(--brown-soft); }

.prose a:not(.button):not(.app-store-button) {
  color: var(--brown);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.prose a:not(.button):not(.app-store-button):hover { color: var(--brown-deep); }

.takeaways {
  margin: 0 0 2.2em;
  padding: 24px 26px 8px;
  border-radius: 18px;
  background: var(--paper);
}

.takeaways h2 {
  margin: 0 0 12px;
  color: var(--brown-soft);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.takeaways ul { padding-left: 1.1em; font-size: 0.98rem; }

.callout {
  margin: 1.8em 0;
  padding: 18px 22px;
  border-left: 3px solid var(--brown);
  border-radius: 0 14px 14px 0;
  background: var(--paper);
  font-size: 0.98rem;
}

.callout p:last-child { margin-bottom: 0; }

/* Worked example table */
.math-table {
  width: 100%;
  margin: 0 0 1.6em;
  border-collapse: collapse;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.math-table th,
.math-table td { padding: 11px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.math-table th { color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.math-table td:last-child,
.math-table th:last-child { text-align: right; }
.math-table tfoot td { color: var(--ink); font-weight: 700; border-bottom: 0; }

.math-table.is-text td:last-child,
.math-table.is-text th:last-child { text-align: left; }

.table-scroll { overflow-x: auto; }

/* App comparison cards (best-apps post) */
.app-entry {
  margin: 0 0 1.4em;
  padding: 24px 26px 6px;
  border-radius: 18px;
  background: var(--paper);
}

.app-entry h3 { margin-top: 0; }
.app-entry.is-ours { box-shadow: inset 0 0 0 1.5px var(--brown); }

.app-entry .verdict {
  margin: 0 0 1.2em;
  color: var(--brown);
  font-size: 0.92rem;
  font-weight: 600;
}

/* Inline call to action */
.inline-cta {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 20px 28px;
  margin: 2.4em 0;
  padding: 28px 30px;
  border-radius: 22px;
  color: var(--cream);
  background: var(--brown-deep);
}

.inline-cta strong {
  display: block;
  margin-bottom: 6px;
  color: var(--cream);
  font-family: var(--display);
  font-size: 1.3rem;
  letter-spacing: -0.03em;
}

.inline-cta p { margin: 0; color: rgba(247, 240, 229, 0.7); font-size: 0.94rem; line-height: 1.55; }

.inline-cta .app-store-button {
  color: var(--brown-deep);
  background: var(--cream);
}

.inline-cta .web-link {
  grid-column: 1 / -1;
  color: rgba(247, 240, 229, 0.75);
  font-size: 0.85rem;
}

.prose .inline-cta a.web-link { color: rgba(247, 240, 229, 0.8); }
.prose .inline-cta a.web-link:hover { color: var(--cream); }

.disclaimer {
  margin-top: 2.4em;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

/* Related posts */
.related {
  padding: clamp(60px, 7vw, 90px) 0 clamp(90px, 10vw, 130px);
  border-top: 1px solid var(--line);
}

.related-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  margin-bottom: 36px;
}

.related-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 600;
  letter-spacing: -0.045em;
}

.related .post-grid { padding: 0; }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 980px) {
  .featured-post { grid-template-columns: 1fr; }
  .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }

  .toc-mobile {
    display: block;
    margin: 0 0 28px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .toc-mobile summary {
    display: flex;
    justify-content: space-between;
    padding: 16px 0;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
  }

  .toc-mobile summary::-webkit-details-marker { display: none; }
  .toc-mobile summary span { color: var(--brown-soft); transition: transform 180ms ease; }
  .toc-mobile[open] summary span { transform: rotate(45deg); }
  .toc-mobile ol { margin: 0 0 16px; padding-left: 1.2em; color: var(--muted); font-size: 0.92rem; }
  .toc-mobile li { margin-bottom: 8px; }
  .toc-mobile a:hover { color: var(--brown); }
}

@media (max-width: 640px) {
  .post-grid { grid-template-columns: minmax(0, 1fr); }
  .featured-post .cover { aspect-ratio: 4 / 3; }
  .article-cover .cover { aspect-ratio: 16 / 9; }
  .article-cover .cover svg { width: 34%; }
  .byline { gap: 14px; }
  .inline-cta { grid-template-columns: 1fr; padding: 24px; }
  .takeaways,
  .app-entry { padding-inline: 20px; }
  .prose { font-size: 1.02rem; }
  .related-head { flex-direction: column; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .cover svg,
  .read-link svg,
  .filter-chip,
  .share-button { transition: none; }
  .featured-post:hover .cover svg,
  .post-card:hover .cover svg { transform: none; }
  .reading-progress { display: none; }
}
