/*
  Predictable Innovation guides: the reading rhythm.
  Load on guide pages after blog.css and blog-chrome.css. Every rule sits under .blog and uses the blog.css tokens,
  so it can't touch the header, the footer or other pages. It only styles markup that rehype-rhythm.mjs, the
  numbered contents and the chapter bar add; a guide without the rhythm looks exactly as before.

  Color has one job each: red = Jose's voice and where you are (chapter numbers, mistakes); lime = things to use
  (questions, key numbers, step labels); ink band = a step of a process; paper = reference cards (mistakes, FAQ).
*/

/* Chapter opener: a hard stop. Thick rule, big red number, big title. */
.blog .prose > .ch-open.ch-open { margin-top: clamp(84px, 7vw, 116px); padding-top: 24px; border-top: 3px solid var(--ink); }
.blog .ch-open { display: grid; grid-template-columns: 96px minmax(0, 1fr); column-gap: 16px; align-items: start; }
.blog .ch-num { display: flex; flex-direction: column; align-items: flex-start; padding-top: 2px; }
.blog .ch-n { font-family: var(--f-display); font-size: 72px; line-height: .84; letter-spacing: 0; color: var(--red); }
.blog .ch-of { margin-top: 12px; font-size: 13px; font-weight: 600; line-height: 1; letter-spacing: .01em; color: var(--muted); }
.blog .ch-open h2 { position: relative; margin: 0; font-family: var(--f-serif); font-weight: 500; scroll-margin-top: 28px;
  font-size: clamp(32px, 1.3rem + 1.4vw, 44px); line-height: 1.08; letter-spacing: -0.022em; color: var(--ink); text-wrap: balance; }
.blog .ch-open .anchor { display: none; }
.blog .prose > .ch-open + * { margin-top: 28px; }
.blog .prose > .ch-open + .step-open.step-open { margin-top: 36px; }

/* The first paragraph of a section: the line a scanner reads */
.blog .prose > p.answer-line { font-size: var(--fs-lede); line-height: 1.5; font-weight: 500; letter-spacing: 0; color: var(--ink); }
.blog .prose .lead-in { font-weight: 700; color: var(--ink); }

/* Sub-chapter (H3) */
.blog .prose > h3.sub-h.sub-h { margin-top: 72px; font-family: var(--f-serif); font-weight: 500;
  font-size: clamp(26px, 1.1rem + 0.9vw, 32px); line-height: 1.14; letter-spacing: -0.016em; color: var(--ink); text-wrap: balance; }
.blog .prose > h3.sub-h::before { content: ""; display: block; width: 48px; height: 5px; margin-bottom: 18px; background: var(--red); }
.blog .prose > .ch-open + h3.sub-h.sub-h { margin-top: 40px; }
.blog .prose > h3.sub-h + * { margin-top: 18px; }

/* Small heading (H4) */
.blog .prose > h4.h-minor.h-minor { margin-top: 44px; font-family: var(--f-sans); font-size: 21px; font-weight: 700; line-height: 1.3; letter-spacing: -0.005em; color: var(--ink); }
.blog .prose > h4.h-minor + * { margin-top: 12px; }

/* Jose's voice: his own line, lifted out of the paragraph (not repeated), with a red accent and his face */
.blog .prose > .voice.voice { margin-top: 56px; margin-bottom: 18px; }
.blog .prose > .voice + * { margin-top: 40px; }
.blog .voice { position: relative; }
.blog .voice-mark { display: block; height: 58px; overflow: visible; font-family: var(--f-display); font-size: 132px; line-height: 1;
  letter-spacing: 0; color: var(--red); user-select: none; }
.blog .voice blockquote { margin: 0; }
.blog .voice blockquote p { margin: 0; font-family: var(--f-serif); font-weight: 500; font-size: clamp(30px, 1.2rem + 1.7vw, 43px);
  line-height: 1.12; letter-spacing: -0.024em; color: var(--ink); text-wrap: balance; }
.blog .voice .hit { color: var(--red); }
.blog .voice--short blockquote p { font-size: clamp(36px, 1.4rem + 2.6vw, 56px); line-height: 1.06; letter-spacing: -0.026em; }
.blog .voice figcaption { display: flex; align-items: center; gap: 14px; margin-top: 24px; }
.blog .voice-face { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%;
  background: var(--paper) url("/v2/blog/img/jose-avatar.webp") center / cover no-repeat;
  box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--red); }
.blog .voice-who { display: flex; flex-direction: column; gap: 2px; font-size: 15px; line-height: 1.3; letter-spacing: 0; color: var(--muted); }
.blog .voice-who cite { font-style: normal; font-weight: 700; color: var(--ink); }

/* Number strip: figures already in the text, marked like the rest of the site's highlights */
.blog .prose > .numbers.numbers { margin-top: 36px; margin-bottom: 8px; }
.blog .prose > .numbers + * { margin-top: 36px; }
.blog .numbers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 3px solid var(--ink); border-bottom: 1px solid var(--line-2); }
.blog .numbers--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.blog .n-item { min-width: 0; padding: 22px 18px 24px 0; }
.blog .n-item + .n-item { padding-left: 20px; border-left: 1px solid var(--line); }
.blog .n-big { display: inline-block; margin-left: -4px; padding: 0 5px; font-family: var(--f-display); font-size: clamp(50px, 2rem + 2vw, 66px);
  line-height: 1.02; letter-spacing: 0; color: var(--ink);
  background: linear-gradient(180deg, transparent 56%, var(--lemon) 56%, var(--lemon) 90%, transparent 90%); }
.blog .n-label { display: block; margin-top: 10px; font-size: 15.5px; line-height: 1.42; letter-spacing: 0; color: var(--text); text-wrap: pretty; }

/* Step opener: a dark band you can't scroll past without noticing */
.blog .prose > .step-open.step-open { margin-top: 72px; }
.blog .step-open { padding: 20px 28px 28px; border-radius: 12px; background: var(--dark); color: var(--white); }
.blog .so-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.blog .so-label { font-size: 14px; font-weight: 700; line-height: 1.2; letter-spacing: .01em; color: var(--lemon); }
.blog .so-dots { display: flex; gap: 4px; }
.blog .so-dots i { display: block; width: 12px; height: 5px; border-radius: 1px; background: var(--dark-line); }
.blog .so-dots i.is-done { background: var(--dark-muted); }
.blog .so-dots i.is-now { width: 22px; background: var(--lemon); }
.blog .so-main { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 18px; align-items: start; margin-top: 18px; }
.blog .so-num { font-family: var(--f-display); font-size: 76px; line-height: .8; letter-spacing: 0; color: var(--lemon); }
.blog .step-open h3 { margin: 0; padding-top: 2px; font-family: var(--f-serif); font-weight: 500; font-size: clamp(25px, 1.1rem + 0.9vw, 31px);
  line-height: 1.14; letter-spacing: -0.016em; color: var(--white); text-wrap: balance; scroll-margin-top: 60px; }
.blog .prose > .step-open + * { margin-top: 28px; }

/* Questions to answer: a lime card, folded to the first three questions when the page has JavaScript */
.blog .prose > .qcard.qcard { margin-top: 36px; }
.blog .qcard { padding: 24px 28px 22px; border: 1px solid var(--wash-line); border-radius: 12px; background: var(--wash); }
.blog .qcard h4 { display: flex; align-items: flex-start; gap: 12px; margin: 0; font-family: var(--f-sans); font-size: 18px; font-weight: 700;
  line-height: 1.3; letter-spacing: 0; color: var(--ink); }
.blog .q-badge { flex: 0 0 auto; display: grid; place-items: center; width: 32px; height: 32px; margin-top: -4px; border-radius: 7px; background: var(--ink);
  font-family: var(--f-display); font-size: 19px; line-height: 1; color: var(--lemon); }
.blog .qcard ul { margin: 14px 0 0; padding: 0; list-style: none; }
.blog .qcard li { position: relative; padding: 12px 0 12px 30px; border-top: 1px solid var(--wash-line); font-size: 17px; line-height: 1.5;
  letter-spacing: 0; color: var(--ink); }
.blog .qcard li::before { content: ""; position: absolute; left: 1px; top: 18px; width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 3px; }
.blog .qcard.is-folded li:nth-child(n+4) { display: none; }
.blog .q-more { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; padding: 10px 0 2px; border: 0; background: none; cursor: pointer;
  font: 700 15px/1.3 var(--f-sans); letter-spacing: 0; color: var(--ink); text-decoration: underline; text-decoration-color: var(--red);
  text-decoration-thickness: 2px; text-underline-offset: 5px; }
.blog .q-more[hidden] { display: none; }
.blog .q-more .icon { width: 16px; height: 16px; stroke-width: 2.4; transition: transform .15s; }
.blog .q-more[aria-expanded="true"] .icon { transform: rotate(180deg); }
.blog .q-more:hover { color: var(--red-ink); }

/* Sub-opener: a numbered red marker for a short series (sources of confusion, key models, tests) */
.blog .prose > .sub-open.sub-open { margin-top: 60px; padding-top: 22px; border-top: 1px solid var(--line-2); }
.blog .sub-open { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 16px; align-items: start; }
.blog .sub-n { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--red); color: var(--white);
  font-family: var(--f-display); font-size: 23px; line-height: 1; }
.blog .sub-label { display: block; font-size: 14px; font-weight: 700; line-height: 1.3; letter-spacing: .01em; color: var(--red-ink); }
.blog .sub-open h4 { margin: 6px 0 0; font-family: var(--f-serif); font-weight: 500; font-size: clamp(23px, 1rem + 0.8vw, 28px);
  line-height: 1.18; letter-spacing: -0.014em; color: var(--ink); text-wrap: balance; }
.blog .prose > .sub-open + * { margin-top: 22px; }

/* Mistake cards: one card per mistake, red edge, where you are in the series */
.blog .prose > .mcard.mcard { margin-top: 30px; }
.blog .prose > .mcard + .mcard.mcard { margin-top: 22px; }
.blog .mcard { padding: 22px 30px 30px; border-radius: 12px; background: var(--paper); box-shadow: inset 0 5px 0 var(--red); }
.blog .mc-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 4px; }
.blog .mc-label { font-size: 14px; font-weight: 700; line-height: 1.2; letter-spacing: .01em; color: var(--red-ink); }
.blog .mc-dots { display: flex; gap: 5px; }
.blog .mc-dots i { display: block; width: 9px; height: 9px; border-radius: 2px; background: var(--line-2); }
.blog .mc-dots i.is-done { background: var(--ink); }
.blog .mc-dots i.is-now { background: var(--red); }
.blog .mc-head { display: grid; grid-template-columns: 50px minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 16px; }
.blog .mc-num { font-family: var(--f-display); font-size: 66px; line-height: .8; letter-spacing: 0; color: var(--red); }
.blog .mcard h4 { margin: 0; padding-top: 1px; font-family: var(--f-serif); font-weight: 500; font-size: clamp(23px, 1rem + 0.8vw, 28px);
  line-height: 1.16; letter-spacing: -0.014em; color: var(--ink); text-wrap: balance; }
.blog .mcard > p { margin: 14px 0 0; font-size: 18px; line-height: 1.62; }
.blog .mcard > .mc-head + p { margin-top: 20px; }

/* A list that is a sequence (the five adopter profiles): one numbered panel */
.blog .prose > ul.lcard { margin-top: 26px; padding: 6px 26px; border-radius: 12px; background: var(--paper); counter-reset: lc; }
.blog .prose > ul.lcard > li { padding: 16px 0 16px 40px; border-bottom: 1px solid var(--line-2); counter-increment: lc; }
.blog .prose > ul.lcard > li + li { margin-top: 0; }
.blog .prose > ul.lcard > li:last-child { border-bottom: 0; }
.blog .prose > ul.lcard > li::before { content: counter(lc); left: 0; top: 15px; width: auto; height: auto; background: none;
  font-family: var(--f-display); font-size: 24px; line-height: 1; color: var(--red); }

/* FAQ: a panel with a red Q per question (no markup change) */
.blog .prose > .faq.faq { margin-top: 30px; padding: 6px 30px; border-top: 0; border-radius: 12px; background: var(--paper); }
.blog .faq .faq-item { position: relative; padding: 24px 0 24px 46px; border-bottom: 1px solid var(--line-2); }
.blog .faq .faq-item:last-child { border-bottom: 0; }
.blog .faq .faq-item::before { content: "Q"; position: absolute; left: 0; top: 22px; font-family: var(--f-display); font-size: 30px; line-height: 1; color: var(--red); }
.blog .faq .faq-item h3 { font-size: 20px; line-height: 1.3; }

/* Closer: the last line, big (no markup change) */
.blog .prose > .closer.closer { margin-top: 40px; font-size: clamp(32px, 1.3rem + 1.6vw, 44px); line-height: 1.12; letter-spacing: -0.022em; }

/* Contents with numbers: rail, fold and chapter bar */
.blog .toc-list, .blog .toc-subs { margin: 0; padding: 0; list-style: none; }
.blog .toc .toc-list a, .blog .toc-fold .toc-list a { display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 6px; align-items: baseline; }
.blog .toc-n { font-family: var(--f-display); font-size: 15px; line-height: 1; letter-spacing: .02em; color: var(--faint); }
.blog .toc-list a[aria-current="true"] .toc-n, .blog .toc-list a.is-parent .toc-n { color: var(--red); }
.blog .toc .toc-list a.is-parent { color: var(--ink); font-weight: 600; }
.blog .toc-subs { margin: 0 0 6px; border-left: 0 !important; }
.blog .toc .toc-subs a { padding: 4px 0 4px 54px; font-size: 14px; line-height: 1.35; grid-template-columns: 22px minmax(0, 1fr); }
.blog .toc .toc-subs a:not(:has(.toc-sn)) { grid-template-columns: minmax(0, 1fr); }
.blog .toc-sn { font-size: 13px; font-weight: 700; color: var(--faint); }
.blog .toc-subs a[aria-current="true"] .toc-sn { color: var(--red-ink); }
.blog .toc-extra .toc-n { display: none; }
.blog .toc .toc-extra a, .blog .toc-fold .toc-extra a { grid-template-columns: minmax(0, 1fr); }
.blog .toc .toc-extra a { padding-left: 54px; }
.blog .toc-fold .toc-extra a { padding-left: 40px; }
.blog .rail .toc { max-height: calc(100vh - var(--header-h) - 150px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.blog .toc-fold .toc-list a { column-gap: 10px; }
.blog .toc-fold .toc-subs a { padding: 7px 0 7px 40px; font-size: 15px; color: var(--soft); grid-template-columns: 24px minmax(0, 1fr); }
.blog .toc-fold .toc-subs a:not(:has(.toc-sn)) { grid-template-columns: minmax(0, 1fr); }

/* Chapter bar: phones and tablets only, under the header, from the first chapter to the end of the article */
.blog .chapter-bar { display: none; }
@media (max-width: 1179px) {
  html:has(.blog .chapter-bar) { scroll-padding-top: calc(var(--header-h) + 64px); }
  .blog .chapter-bar { display: block; position: fixed; z-index: 19; top: var(--header-h); left: 0; right: 0;
    background: var(--white); border-bottom: 1px solid var(--line); box-shadow: 0 8px 18px rgba(8, 10, 9, .07);
    transform: translateY(-110%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; }
  .blog .chapter-bar.is-on { transform: none; visibility: visible; transition: transform .22s ease, visibility 0s; }
  .blog .cb-btn { display: flex; align-items: center; gap: 10px; width: 100%; max-width: calc(var(--measure) + 2 * var(--gutter)); min-height: 46px;
    margin: 0 auto; padding: 0 var(--gutter); border: 0; background: none; cursor: pointer; text-align: left; color: var(--ink);
    font: 600 15px/1.2 var(--f-sans); letter-spacing: 0; }
  .blog .cb-n { flex: 0 0 auto; font-family: var(--f-display); font-weight: 400; font-size: 19px; line-height: 1; color: var(--red); }
  .blog .cb-sub { flex: 0 0 auto; padding: 3px 6px; border-radius: 4px; background: var(--ink); font-size: 12px; font-weight: 700; line-height: 1.2; color: var(--lemon); }
  .blog .cb-sub:empty { display: none; }
  .blog .cb-t { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .blog .cb-btn .icon { width: 18px; height: 18px; color: var(--muted); transition: transform .15s; }
  .blog .chapter-bar.is-open .cb-btn .icon { transform: rotate(180deg); }
  .blog .cb-panel { display: none; max-height: min(64vh, 560px); overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--line); }
  .blog .chapter-bar.is-open .cb-panel { display: block; }
  .blog .cb-panel .toc-list { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto; padding: 6px var(--gutter) 14px; }
  .blog .cb-panel .toc-list a { display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 10px; align-items: baseline; padding: 10px 0;
    border-bottom: 1px solid var(--line); font-size: 16px; line-height: 1.35; color: var(--ink); text-decoration: none; }
  .blog .cb-panel .toc-subs a { padding: 8px 0 8px 40px; font-size: 15px; color: var(--soft); grid-template-columns: 24px minmax(0, 1fr); }
  .blog .cb-panel .toc-subs a:not(:has(.toc-sn)) { grid-template-columns: minmax(0, 1fr); }
  .blog .cb-panel .toc-extra a { grid-template-columns: minmax(0, 1fr); }
  .blog .cb-panel a[aria-current="true"] { font-weight: 700; }
  .blog .cb-panel a[aria-current="true"] .toc-n { color: var(--red); }
}

/* Phones */
@media (max-width: 700px) {
  .blog .prose > .ch-open.ch-open { margin-top: 76px; padding-top: 18px; }
  .blog .ch-open { grid-template-columns: minmax(0, 1fr); }
  .blog .ch-num { flex-direction: row; align-items: baseline; gap: 10px; margin-bottom: 14px; padding: 0; }
  .blog .ch-n { font-size: 56px; }
  .blog .ch-of { margin: 0; }
  .blog .ch-open h2 { font-size: clamp(29px, 5.4vw + 9px, 34px); line-height: 1.1; scroll-margin-top: 82px; }
  .blog .prose > .ch-open + * { margin-top: 22px; }
  .blog .prose > p.answer-line { font-size: 20px; line-height: 1.5; }

  .blog .prose > h3.sub-h.sub-h { margin-top: 60px; }
  .blog .prose > h4.h-minor.h-minor { margin-top: 38px; font-size: 20px; }

  .blog .prose > .voice.voice { margin-top: 48px; margin-bottom: 10px; }
  .blog .prose > .voice + * { margin-top: 34px; }
  .blog .voice-mark { height: 46px; font-size: 108px; }
  .blog .voice blockquote p { font-size: clamp(28px, 6.4vw + 3px, 33px); line-height: 1.14; }
  .blog .voice figcaption { margin-top: 20px; }
  .blog .voice--short blockquote p { font-size: clamp(33px, 8vw + 2px, 40px); line-height: 1.08; }

  .blog .numbers, .blog .numbers--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .blog .n-item { padding: 18px 14px 20px 0; }
  .blog .n-item + .n-item { padding-left: 16px; }
  .blog .n-item:nth-child(3) { grid-column: 1 / -1; padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .blog .n-big { font-size: 48px; }
  .blog .n-label { font-size: 15px; }

  .blog .prose > .step-open.step-open { margin-top: 64px; margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); }
  .blog .step-open { padding: 20px var(--gutter) 26px; border-radius: 0; }
  .blog .so-main { grid-template-columns: 52px minmax(0, 1fr); gap: 14px; margin-top: 16px; }
  .blog .so-num { font-size: 64px; }
  .blog .so-dots i { width: 8px; }
  .blog .so-dots i.is-now { width: 16px; }
  .blog .step-open h3 { font-size: clamp(23px, 4.6vw + 6px, 27px); scroll-margin-top: 58px; }

  .blog .qcard { padding: 20px 18px 18px; }
  .blog .qcard li { font-size: 16.5px; padding-left: 28px; }

  .blog .prose > .sub-open.sub-open { margin-top: 52px; }
  .blog .sub-open { grid-template-columns: 40px minmax(0, 1fr); gap: 14px; }
  .blog .sub-n { width: 40px; height: 40px; font-size: 20px; }

  .blog .mcard { padding: 20px 20px 24px; }
  .blog .mc-head { grid-template-columns: 40px minmax(0, 1fr); gap: 14px; }
  .blog .mc-num { font-size: 56px; }
  .blog .mcard > p { font-size: 17px; }

  .blog .prose > ul.lcard { padding: 4px 18px; }
  .blog .prose > ul.lcard > li { padding-left: 32px; }
  .blog .prose > .faq.faq { padding: 4px 20px; }
  .blog .faq .faq-item { padding: 20px 0 20px 38px; }
  .blog .faq .faq-item::before { top: 19px; font-size: 26px; }
  .blog .faq .faq-item h3 { font-size: 19px; }

  .blog .prose > .closer.closer { font-size: clamp(30px, 6vw + 6px, 36px); }
}

@media (prefers-reduced-motion: reduce) {
  .blog .chapter-bar, .blog .chapter-bar.is-on, .blog .q-more .icon, .blog .cb-btn .icon { transition: none; }
}

@media print {
  .blog .chapter-bar, .blog .q-more { display: none !important; }
  .blog .qcard.is-folded li:nth-child(n+4) { display: list-item; }
}
