/* ============================================================
   FNP — Table of Contents + content frame
   Standalone. Loads on listing, city and native blog posts.

   Inherits the plugin's tokens when the main stylesheet is present
   (listing/city pages) and falls back to its own values when it isn't
   (blog posts), so it never depends on load order and never imposes
   a font on the theme.
   ============================================================ */

.fnp-toc,
.fnp-content-box {
  --toc-brand:  var(--fnp-brand,      #1a6b3c);
  --toc-tint:   var(--fnp-brand-xlight, #f4faf6);
  --toc-line:   var(--fnp-brand-light,  #e4f2ea);
  --toc-border: var(--fnp-border,     #e4e8ee);
  --toc-text:   var(--fnp-text,       #16202b);
  --toc-muted:  var(--fnp-muted,      #64748b);
  --toc-radius: var(--fnp-r-panel,    20px);
  box-sizing: border-box;
}

.fnp-toc *,
.fnp-content-box *,
.fnp-toc *::before,
.fnp-content-box *::before { box-sizing: border-box; }

/* ── Contents box ────────────────────────────────────────── */
.fnp-toc {
  margin: 0 0 clamp(20px, 3vw, 28px);
  background: var(--toc-tint);
  border: 1px solid var(--toc-line);
  border-radius: var(--toc-radius);
  overflow: hidden;
  font-size: 15px;
  line-height: 1.6;
  color: var(--toc-text);
}

/* On plugin pages the flex-column container owns the rhythm. */
.fnp-container > .fnp-toc { margin-bottom: 0; }

/* ── Summary row ─────────────────────────────────────────── */
.fnp-toc__summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px clamp(16px, 2.4vw, 22px);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background-color .15s ease;
}

/* Kill the native disclosure triangle in every engine */
.fnp-toc__summary::-webkit-details-marker { display: none; }
.fnp-toc__summary::marker { content: ''; }

.fnp-toc__summary:hover { background: rgba(0, 0, 0, .02); }

.fnp-toc__summary:focus-visible {
  outline: 2px solid var(--toc-brand);
  outline-offset: -2px;
}

.fnp-toc__label {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--toc-text);
}

.fnp-toc__count {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--toc-brand);
  background: #fff;
  border: 1px solid var(--toc-line);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}

.fnp-toc__chevron {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--toc-brand);
  transition: transform .2s ease;
}

.fnp-toc[open] .fnp-toc__chevron { transform: rotate(180deg); }

/* ── Panel ───────────────────────────────────────────────── */
.fnp-toc__panel {
  padding: 4px clamp(16px, 2.4vw, 22px) 18px;
  border-top: 1px solid var(--toc-line);
}

.fnp-toc__list,
.fnp-toc__panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.fnp-toc__panel ul ul {
  margin-top: 2px;
  padding-left: 16px;
  border-left: 1px solid var(--toc-line);
  margin-left: 4px;
}

.fnp-toc__item { margin: 0; padding: 0; }
.fnp-toc__item::before { content: none; }   /* beat theme list-marker styles */

.fnp-toc__link {
  display: block;
  padding: 6px 2px;
  color: var(--toc-text);
  font-size: 14.5px;
  line-height: 1.5;
  text-decoration: none;
  border-radius: 6px;
  transition: color .15s ease;
}

.fnp-toc__link:hover,
.fnp-toc__link:focus-visible {
  color: var(--toc-brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Top-level entries carry slightly more weight than their children */
.fnp-toc__list > .fnp-toc__item > .fnp-toc__link { font-weight: 600; }
.fnp-toc__panel ul ul .fnp-toc__link { font-size: 14px; color: var(--toc-muted); }
.fnp-toc__panel ul ul .fnp-toc__link:hover { color: var(--toc-brand); }

/* ── Anchor offset ───────────────────────────────────────── */
/*
 * Jumping to a heading must not park it under a sticky header. Applied to the
 * headings themselves rather than html{scroll-padding} so we don't change
 * scrolling behaviour for the rest of the theme.
 */
.fnp-content :is(h1, h2, h3, h4)[id],
.fnp-content-box :is(h1, h2, h3, h4)[id] { scroll-margin-top: 90px; }

@media (prefers-reduced-motion: no-preference) {
  html:has(.fnp-toc) { scroll-behavior: smooth; }
}

/* ── Content frame ───────────────────────────────────────── */
/*
 * Blog-post wrapper. The equivalent for listing/city pages is defined on
 * .fnp-content in the main stylesheet, where the tokens already exist.
 */
.fnp-content-box {
  padding: clamp(20px, 3vw, 34px);
  background: #fff;
  border: 1px solid var(--toc-border);
  border-radius: var(--toc-radius);
  box-shadow: 0 1px 2px rgba(16, 32, 43, .04);
}

.fnp-content-box > *:first-child { margin-top: 0; }
.fnp-content-box > *:last-child  { margin-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
  .fnp-toc__chevron,
  .fnp-toc__summary,
  .fnp-toc__link { transition: none; }
}
