/* ==========================================================================
   Ohms Law Wheel — blog.css
   Guides archive (post cards) and the single-guide reading layout with its
   sticky sidebar. Loaded only by /guides/ pages; nothing here touches the
   calculator or marketing styles in main.css / calculators.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Reading progress rail
   The header sits at z-index 90, so 95 keeps the rail on top of it while
   staying under the skip link (200).
   -------------------------------------------------------------------------- */
.read-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  z-index: 95;
  background: transparent;
  pointer-events: none;
}
.read-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green-deep), var(--green));
  border-radius: 0 var(--r-pill) var(--r-pill) 0;
  transition: width 90ms linear;
}

/* --------------------------------------------------------------------------
   2. Archive — filter chips
   No-JS keeps every card visible, so the grid is complete either way.
   -------------------------------------------------------------------------- */
.guide-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: clamp(22px, 2.6vw, 32px);
}
.guide-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  background: var(--white);
  color: var(--charcoal-2);
  border-radius: var(--r-pill);
  padding: 9px 16px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.guide-filter svg { color: var(--green-dark); flex: none; transition: color var(--t-fast); }
.guide-filter .gf-count {
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--bg-sink);
  border-radius: var(--r-pill);
  padding: 2px 8px;
  color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.guide-filter:hover { border-color: var(--green); color: var(--green-ink); }
.guide-filter[aria-pressed="true"] {
  background: var(--green-deep);
  border-color: var(--green-deep);
  color: var(--white);
  box-shadow: var(--shadow-green);
}
.guide-filter[aria-pressed="true"] svg { color: var(--white); }
.guide-filter[aria-pressed="true"] .gf-count {
  background: rgba(255, 255, 255, 0.22);
  color: var(--white);
}

.guide-count-line {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 18px;
}
.guide-count-line strong { color: var(--charcoal-dark); font-weight: 700; }

.guide-empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  padding: 40px 22px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

/* --------------------------------------------------------------------------
   3. Archive — post cards
   The whole card is one <a>, so the click target is the full tile.
   -------------------------------------------------------------------------- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(316px, 1fr));
  gap: clamp(20px, 2.4vw, 28px);
}
.post-grid > * { min-width: 0; }

.post-card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
  height: 100%;
}
.post-card:hover {
  transform: translateY(-4px);
  border-color: var(--line-green);
  box-shadow: var(--shadow-lg);
}
.post-card:focus-visible {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(4, 185, 98, 0.22), var(--shadow-md);
}

.post-card-media {
  position: relative;
  aspect-ratio: 1200 / 630;
  background: var(--bg-sink);
  overflow: hidden;
  flex: none;
}
/* aspect-ratio fallback for older engines */
@supports not (aspect-ratio: 1 / 1) {
  .post-card-media { height: 0; padding-bottom: 52.5%; }
  .post-card-media img { position: absolute; inset: 0; }
}
.post-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--t-slow);
}
.post-card:hover .post-card-media img { transform: scale(1.045); }

.post-card-cat {
  position: absolute;
  left: 12px;
  top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--green-ink);
  border: 1px solid var(--line-green);
  border-radius: var(--r-pill);
  padding: 5px 11px;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  backdrop-filter: blur(4px);
}
.post-card-cat svg { flex: none; }

.post-card-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 18px 19px 19px;
  gap: 9px;
}
.post-card-body h2, .post-card-body h3 {
  font-family: var(--font-display);
  font-size: 1.06rem;
  line-height: 1.34;
  font-weight: 750;
  color: var(--charcoal-dark);
  margin: 0;
  transition: color var(--t-fast);
}
.post-card:hover .post-card-body h2,
.post-card:hover .post-card-body h3 { color: var(--green-dark); }
.post-card-body p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.62;
  color: var(--muted);
}

.post-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 13px;
  margin-top: auto;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted-soft);
}
.post-card-meta span { display: inline-flex; align-items: center; gap: 5px; }
.post-card-meta svg { flex: none; color: var(--green-dark); }
.post-card-go {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--green-dark);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
}
.post-card-go svg { transition: transform var(--t-fast); }
.post-card:hover .post-card-go svg { transform: translateX(3px); }

/* --------------------------------------------------------------------------
   4. Single guide — hero meta + feature image
   -------------------------------------------------------------------------- */
.post-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  margin-top: 20px;
  font-size: 0.86rem;
  color: var(--muted);
}
.post-meta-row > span { display: inline-flex; align-items: center; gap: 7px; }
.post-meta-row svg { flex: none; color: var(--green-dark); }
.post-meta-row .pm-author { font-weight: 650; color: var(--charcoal-2); }

.post-hero-media {
  margin: 0 0 clamp(26px, 3vw, 38px);
  border-radius: var(--r-xl);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  background: var(--bg-sink);
  aspect-ratio: 1200 / 630;
}
@supports not (aspect-ratio: 1 / 1) {
  .post-hero-media { aspect-ratio: auto; }
}
.post-hero-media img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* --------------------------------------------------------------------------
   5. Single guide — two-column shell
   align-items: start is what actually lets the aside stick; no ancestor of
   the aside may set overflow, so the shell deliberately leaves it alone.
   -------------------------------------------------------------------------- */
.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  gap: clamp(28px, 3.4vw, 46px);
  align-items: start;
}
.post-layout > * { min-width: 0; }

.post-side {
  position: sticky;
  top: calc(var(--header-h) + 18px);
  display: grid;
  gap: 16px;
  /* Never let a tall sidebar trap its own tail out of reach. */
  max-height: calc(100vh - var(--header-h) - 36px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding-right: 2px;
}
.post-side::-webkit-scrollbar { width: 6px; }
.post-side::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-pill); }

.side-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 17px 18px;
  box-shadow: var(--shadow-sm);
}
.side-card h2, .side-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--green-ink);
  margin: 0 0 13px;
}
.side-card h2 svg, .side-card h3 svg { color: var(--green); flex: none; }

/* Table of contents + scroll spy */
.post-toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: toc; }
.post-toc li { margin: 0; }
.post-toc a {
  display: block;
  position: relative;
  padding: 8px 10px 8px 14px;
  border-radius: var(--r-sm);
  font-size: 0.855rem;
  line-height: 1.45;
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.post-toc a:hover { background: var(--green-tint); color: var(--green-dark); }
.post-toc li.is-sub a { padding-left: 26px; font-size: 0.81rem; }
.post-toc a.is-current {
  background: var(--green-pale);
  border-left-color: var(--green);
  color: var(--green-ink);
  font-weight: 650;
}

/* Sidebar calculator CTA */
.side-cta { background: var(--green-tint); border-color: var(--line-green); }
.side-cta p { margin: 0 0 13px; font-size: 0.875rem; line-height: 1.6; color: var(--charcoal-2); }
.side-cta .btn { width: 100%; justify-content: center; }

.side-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.side-links li { margin: 0; }
.side-links a {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 9px;
  border-radius: var(--r-sm);
  font-size: 0.855rem;
  line-height: 1.45;
  color: var(--charcoal-2);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}
.side-links a svg { flex: none; margin-top: 3px; color: var(--green-dark); }
.side-links a:hover { background: var(--green-tint); color: var(--green-dark); }

.side-facts { display: grid; gap: 9px; }
.side-fact {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 9px 11px;
  background: var(--bg-light);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.side-fact dt { font-size: 0.78rem; color: var(--muted); margin: 0; }
.side-fact dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--green-ink);
  text-align: right;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   6. Single guide — article typography
   -------------------------------------------------------------------------- */
.post-body { font-size: 1.005rem; line-height: 1.78; color: var(--charcoal-2); min-width: 0; }
.post-body > *:first-child { margin-top: 0; }
.post-body > *:last-child { margin-bottom: 0; }

.post-body p { margin: 0 0 18px; }

.post-body h2 {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.2vw, 1.62rem);
  line-height: 1.28;
  font-weight: 780;
  color: var(--charcoal-dark);
  margin: clamp(34px, 3.6vw, 46px) 0 14px;
  padding-top: 4px;
}
.post-body h3 {
  font-family: var(--font-display);
  font-size: clamp(1.09rem, 1.6vw, 1.22rem);
  line-height: 1.34;
  font-weight: 750;
  color: var(--charcoal-dark);
  margin: 28px 0 11px;
}
.post-body h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 700;
  color: var(--green-ink);
  margin: 22px 0 9px;
}

/* :not(.btn) matters — this rule scores (0,2,1) and would otherwise beat
   .btn--primary (0,1,0), repainting button labels green-on-green and
   underlining them. Buttons keep the styling main.css gives them. */
.post-body a:not(.btn) {
  color: var(--green-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: color var(--t-fast);
}
.post-body a:not(.btn):hover { color: var(--green-ink); text-decoration-thickness: 2px; }
.post-body strong { color: var(--charcoal-dark); font-weight: 680; }

.post-body ul, .post-body ol { margin: 0 0 18px; padding-left: 0; display: grid; gap: 9px; }
.post-body ul { list-style: none; }
.post-body ul li {
  position: relative;
  padding-left: 26px;
  margin: 0;
}
.post-body ul li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0.66em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-pale);
}
.post-body ol { list-style: decimal; padding-left: 22px; }
.post-body ol li { margin: 0; padding-left: 4px; }
.post-body ol li::marker { color: var(--green-dark); font-weight: 700; }
.post-body li > ul, .post-body li > ol { margin: 9px 0 0; }

.post-body figure { margin: 0 0 20px; }
.post-body figcaption {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
}

/* Inline formula chip */
.post-body .eq {
  font-family: var(--font-mono);
  font-size: 0.94em;
  font-weight: 600;
  background: var(--green-tint);
  border: 1px solid var(--line-green);
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--green-ink);
  white-space: nowrap;
}

/* Callout — reuses the .note look from main.css but scoped for article flow */
.post-note {
  display: flex;
  gap: 12px;
  background: var(--green-tint);
  border: 1px solid var(--line-green);
  border-left: 3px solid var(--green);
  border-radius: var(--r-md);
  padding: 15px 17px;
  margin: 0 0 20px;
}
.post-note svg { flex: none; margin-top: 3px; color: var(--green-deep); }
.post-note p { margin: 0; font-size: 0.925rem; line-height: 1.65; }
.post-note p + p { margin-top: 9px; }
.post-note--warn { background: var(--red-soft); border-color: rgba(182, 42, 4, 0.28); border-left-color: var(--red); }
.post-note--warn svg { color: var(--red); }

/* Key-takeaway block */
.post-key {
  background: var(--bg-light);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin: 0 0 24px;
}
.post-key h2, .post-key h3 {
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--green-ink);
  margin: 0 0 11px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.post-key h2 svg, .post-key h3 svg { color: var(--green); flex: none; }
.post-key ul { margin: 0; }
.post-key p:last-child { margin-bottom: 0; }

/* Tables — always scrollable rather than breaking the page width */
.post-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--white);
}
.post-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 460px;
}
.post-body caption {
  caption-side: top;
  text-align: left;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  padding: 12px 14px 10px;
}
.post-body thead th {
  background: var(--bg-sink);
  color: var(--green-ink);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 750;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.post-body tbody td, .post-body tbody th {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-weight: 400;
  color: var(--charcoal-2);
  vertical-align: top;
}
.post-body tbody th { font-weight: 650; color: var(--charcoal-dark); }
.post-body tbody tr:last-child td, .post-body tbody tr:last-child th { border-bottom: 0; }
.post-body tbody tr:nth-child(even) { background: var(--bg-light); }
.post-body td.num, .post-body th.num { font-family: var(--font-mono); white-space: nowrap; }

/* Inline CTA inside the article */
.post-inline-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  background: var(--green-pale);
  border: 1px solid var(--line-green);
  border-radius: var(--r-lg);
  padding: 17px 19px;
  margin: 0 0 24px;
}
.post-inline-cta .pic-icon {
  flex: none;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  background: var(--white);
  color: var(--green-deep);
  border: 1px solid var(--line-green);
}
.post-inline-cta div { flex: 1 1 220px; min-width: 0; }
.post-inline-cta p { margin: 0; font-size: 0.92rem; line-height: 1.55; }
.post-inline-cta p strong { display: block; font-family: var(--font-display); color: var(--green-ink); margin-bottom: 2px; }
.post-inline-cta .btn { flex: none; }

/* --------------------------------------------------------------------------
   7. Article foot — FAQ, tags, prev/next, related
   -------------------------------------------------------------------------- */
.post-faq { margin-top: clamp(34px, 3.6vw, 46px); }
.post-faq .faq-item { margin-bottom: 10px; }

.post-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.post-tags .pt-label {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin-right: 2px;
}
.post-tag {
  display: inline-flex;
  align-items: center;
  background: var(--bg-light);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 5px 12px;
  font-size: 0.78rem;
  color: var(--charcoal-2);
}

.post-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  margin-top: 26px;
}
.post-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.post-nav a:hover { border-color: var(--line-green); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.post-nav a svg { flex: none; color: var(--green-dark); }
.post-nav .pn-next { text-align: right; justify-content: flex-end; }
.post-nav .pn-next svg { order: 2; }
.post-nav span { display: block; min-width: 0; }
.post-nav .pn-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-soft);
  margin-bottom: 3px;
}
.post-nav .pn-title { font-size: 0.9rem; font-weight: 650; line-height: 1.4; color: var(--charcoal-dark); }

/* --------------------------------------------------------------------------
   8. Mobile TOC — the sidebar collapses into a disclosure above the article
   -------------------------------------------------------------------------- */
.toc-mobile { display: none; margin-bottom: 22px; }
.toc-mobile > summary {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  list-style: none;
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 13px 16px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--green-ink);
}
.toc-mobile > summary::-webkit-details-marker { display: none; }
.toc-mobile > summary svg:first-child { color: var(--green); flex: none; }
.toc-mobile > summary::after {
  content: "";
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--t-fast);
}
.toc-mobile[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.toc-mobile[open] > summary { border-radius: var(--r-md) var(--r-md) 0 0; border-bottom-color: transparent; }
.toc-mobile .post-toc {
  border: 1px solid var(--line-strong);
  border-top: 0;
  border-radius: 0 0 var(--r-md) var(--r-md);
  padding: 12px 14px;
  background: var(--white);
}

/* --------------------------------------------------------------------------
   9. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .post-layout { grid-template-columns: minmax(0, 1fr) 276px; }
}

@media (max-width: 940px) {
  .post-layout { grid-template-columns: minmax(0, 1fr); }
  /* Sticky is meaningless once the aside is stacked below the article. */
  .post-side {
    position: static;
    max-height: none;
    overflow: visible;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    display: grid;
    margin-top: 34px;
  }
  .post-side .post-toc-card { display: none; }
  .toc-mobile { display: block; }
}

@media (max-width: 640px) {
  .post-grid { grid-template-columns: minmax(0, 1fr); }
  .post-body { font-size: 0.975rem; }
  .post-inline-cta { flex-direction: column; align-items: stretch; }
  /* Once the row becomes a column, flex-basis governs HEIGHT — leaving the
     220px basis would open a tall empty gap above the button. */
  .post-inline-cta div { flex: 0 1 auto; }
  .post-inline-cta .btn { width: 100%; justify-content: center; }
  .post-nav .pn-next { text-align: left; justify-content: flex-start; }
  .post-nav .pn-next svg { order: 0; }
  .post-hero-media { border-radius: var(--r-lg); }
  .guide-filters { gap: 7px; }
  .guide-filter { padding: 8px 13px; font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  .post-card, .post-card-media img, .post-card-go svg, .post-nav a { transition: none; }
  .post-card:hover { transform: none; }
  .post-card:hover .post-card-media img { transform: none; }
  .read-progress span { transition: none; }
}

@media print {
  .read-progress, .post-side, .toc-mobile, .post-nav, .post-inline-cta { display: none !important; }
  .post-layout { display: block; }
}
