/* ============================================================
   IOCOS — Articolo singolo del blog: layout di lettura per argomento
   Estende blog-public.css. Il markup viene da blogRenderArticlePage() +
   blogPrepareArticleBody() (articles/_shared.php):
     .bp-layout-guida    Marketing, SEO, Ads, Social  → rivista, indice a destra
     .bp-layout-tecnico  Configurazione, WordPress    → documentazione, indice a sinistra
     .bp-layout-legale   Contratti / GDPR             → documento, sezioni numerate + FAQ
     .bp-layout-profilo  Aree di lavoro               → profilo, sezioni a schede
   --cat è il colore della categoria (blogCategoryColor).
   ============================================================ */

/* ---------- barra di avanzamento lettura ---------- */
.bp-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 200; pointer-events: none; }
.bp-progress span {
  display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(var(--p, 0));
  background: linear-gradient(90deg, var(--cat), var(--accent));
}

/* ---------- impianto comune ---------- */
.bp-article.has-toc { max-width: 1120px; }
.bp-article .bp-hero,
.bp-article .bp-featured { max-width: 820px; }
.bp-kind {
  display: inline-flex; align-items: center; gap: 8px; margin: 14px 0 2px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: color-mix(in srgb, var(--cat) 78%, #000);
}
.bp-kind-icon { font-size: 15px; letter-spacing: 0; }
.bp-body { max-width: 720px; overflow-wrap: break-word; }
.bp-body strong { color: var(--text); }
.bp-body [id] { scroll-margin-top: 96px; }
.bp-body p:empty, .bp-body div:empty { display: none; }

/* elenchi: pallini/numero nel colore della categoria */
.bp-body ul { list-style: none; margin-left: 0; padding-left: 0; }
.bp-body ul > li { position: relative; padding-left: 1.5em; }
.bp-body ul > li::before {
  content: ''; position: absolute; left: .3em; top: .72em; width: 7px; height: 7px; border-radius: 50%;
  background: var(--cat);
}
.bp-body ol { padding-left: 0; margin-left: 1.6em; }
.bp-body ol > li::marker { color: color-mix(in srgb, var(--cat) 80%, #000); font-weight: 700; }

/* elenchi "punto chiave": ogni voce diventa una scheda col grassetto come titolo */
.bp-body .bp-keylist { display: grid; gap: 10px; margin: 0 0 1.5em; padding: 0; list-style: none; counter-reset: bpk; }
.bp-body .bp-keylist > li {
  margin: 0; padding: 14px 18px 14px 20px; line-height: 1.6;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--cat);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
}
.bp-body .bp-keylist > li::before { display: none; }
.bp-body .bp-keylist > li > strong:first-child,
.bp-body .bp-keylist > li > b:first-child { display: block; margin-bottom: 2px; }
.bp-body ol.bp-keylist > li { counter-increment: bpk; padding-left: 58px; position: relative; }
.bp-body ol.bp-keylist > li::before {
  display: flex; content: counter(bpk); position: absolute; left: 16px; top: 14px;
  width: 28px; height: 28px; border-radius: 50%; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--cat) 14%, #fff); color: color-mix(in srgb, var(--cat) 75%, #000);
  font-size: 13px; font-weight: 800;
}

/* tabelle scorrevoli */
.bp-body .bp-table-wrap { overflow-x: auto; margin: 1.4em 0; border: 1px solid var(--border-2); border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; }
.bp-body .bp-table-wrap table { margin: 0; border: 0; min-width: 480px; }
.bp-body .bp-table-wrap th, .bp-body .bp-table-wrap td { border-width: 0 0 1px; }
.bp-body .bp-table-wrap tr:last-child td { border-bottom: 0; }
.bp-body .bp-table-wrap tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* citazioni */
.bp-body blockquote { border-left-color: var(--cat); background: color-mix(in srgb, var(--cat) 6%, transparent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 14px 22px; }
.bp-body blockquote p:last-child { margin-bottom: 0; }

/* codice: pulsante copia aggiunto da blog-article.js */
.bp-body .bp-code { position: relative; }
.bp-body .bp-code pre { margin: 1.4em 0; }
.bp-copy {
  position: absolute; top: 8px; right: 8px; padding: 4px 10px; border-radius: 7px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: #e6e6e6;
  font: 600 11.5px var(--font); cursor: pointer; opacity: .75; transition: opacity .15s, background .15s;
}
.bp-copy:hover, .bp-copy:focus-visible { opacity: 1; background: rgba(255,255,255,.16); }

/* blocchi colorati degli articoli migrati da WordPress: pannello tenue uniforme */
.bp-body .has-background { background: color-mix(in srgb, var(--cat) 6%, var(--surface)); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 20px 22px; margin: 1.4em 0; }
.bp-body .has-background .has-background { background: var(--surface); }
.bp-body p.has-background { padding: 10px 16px; font-family: var(--font-mono); font-size: 14.5px; font-weight: 600; text-align: center; }
.bp-body .wp-block-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin: 1.4em 0; }
.bp-body .wp-block-column > .has-background { margin: 0; height: 100%; }

/* sezioni */
.bp-body .bp-sec { margin-top: 2.6em; }
.bp-body .bp-h-sec { font-size: clamp(22px, 2.6vw, 28px); line-height: 1.25; margin: 0 0 .6em; }
.bp-body :not(section) > .bp-h-sec { margin-top: 1.8em; }
.bp-body .bp-h-sub { font-size: clamp(18.5px, 2.1vw, 21px); line-height: 1.3; margin: 1.5em 0 .4em; }

/* ---------- indice ---------- */
.bp-toc {
  margin: 0 0 32px; padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.bp-toc summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim);
}
.bp-toc summary::-webkit-details-marker { display: none; }
.bp-toc summary::after { content: '▾'; font-size: 14px; transition: transform .2s; }
.bp-toc:not([open]) summary::after { transform: rotate(-90deg); }
.bp-toc ol { list-style: none; margin: 12px 0 0; padding: 0; counter-reset: bpt; }
.bp-toc li { counter-increment: bpt; margin: 0; }
.bp-toc a {
  display: flex; gap: 10px; padding: 6px 0; font-size: 14.5px; line-height: 1.4;
  color: var(--text-dim); text-decoration: none; transition: color .15s;
}
.bp-toc a::before { content: counter(bpt, decimal-leading-zero); flex: none; font-family: var(--font-mono); font-size: 12px; padding-top: 2px; color: var(--text-mute); }
.bp-toc a:hover { color: var(--text); }
.bp-toc a.is-current { color: var(--text); font-weight: 600; }
.bp-toc a.is-current::before { color: var(--cat); }

/* indice laterale fisso su desktop (guida a destra, tecnico a sinistra) */
@media (min-width: 1100px) {
  .bp-layout-guida.has-toc .bp-reader,
  .bp-layout-tecnico.has-toc .bp-reader { display: grid; gap: 56px; align-items: start; }
  .bp-layout-guida.has-toc .bp-reader { grid-template-columns: minmax(0, 720px) 280px; }
  .bp-layout-tecnico.has-toc .bp-reader { grid-template-columns: 250px minmax(0, 760px); }
  .bp-layout-guida.has-toc .bp-toc { order: 2; }
  .bp-layout-guida.has-toc .bp-toc,
  .bp-layout-tecnico.has-toc .bp-toc {
    position: sticky; top: 96px; margin: 0; max-height: calc(100vh - 120px); overflow-y: auto;
    background: none; border: 0; box-shadow: none; padding: 4px 0 4px 18px; border-left: 1px solid var(--border-2);
  }
  .bp-layout-guida.has-toc .bp-toc summary,
  .bp-layout-tecnico.has-toc .bp-toc summary { pointer-events: none; }
  .bp-layout-guida.has-toc .bp-toc summary::after,
  .bp-layout-tecnico.has-toc .bp-toc summary::after { display: none; }
  .bp-layout-guida.has-toc .bp-toc a,
  .bp-layout-tecnico.has-toc .bp-toc a { font-size: 13.5px; position: relative; }
  .bp-layout-guida.has-toc .bp-toc a.is-current::after,
  .bp-layout-tecnico.has-toc .bp-toc a.is-current::after {
    content: ''; position: absolute; left: -20px; top: 4px; bottom: 4px; width: 3px; border-radius: 2px; background: var(--cat);
  }
  .bp-layout-tecnico.has-toc .bp-hero,
  .bp-layout-tecnico.has-toc .bp-featured { margin-left: 306px; }
  .bp-layout-tecnico.has-toc .bp-tags,
  .bp-layout-tecnico.has-toc .bp-cta { margin-left: 306px; }
  .bp-layout-guida.has-toc .bp-tags,
  .bp-layout-guida.has-toc .bp-cta { max-width: 720px; }
}

/* ============================================================
   GUIDA — rivista: capolettera, titoli con filetto, citazioni in evidenza
   ============================================================ */
.bp-layout-guida .bp-body { font-size: 18px; line-height: 1.8; }
.bp-layout-guida .bp-body .bp-first-p { font-size: 19.5px; line-height: 1.7; color: var(--text); }
.bp-layout-guida .bp-body .bp-first-p::first-letter {
  float: left; font-size: 3.3em; line-height: .9; font-weight: 800; padding: 6px 10px 0 0;
  color: var(--cat);
}
.bp-layout-guida .bp-body .bp-h-sec { position: relative; padding-top: 18px; }
.bp-layout-guida .bp-body .bp-h-sec::before {
  content: ''; position: absolute; top: 0; left: 0; width: 44px; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--cat), var(--accent));
}
.bp-layout-guida .bp-body blockquote {
  position: relative; margin: 2em 0; padding: 22px 26px 22px 64px; border-left: 0;
  background: color-mix(in srgb, var(--cat) 8%, var(--surface)); border-radius: var(--radius);
  font-size: 20px; line-height: 1.55; font-style: normal; font-weight: 500; color: var(--text);
}
.bp-layout-guida .bp-body blockquote::before {
  content: '“'; position: absolute; left: 20px; top: 4px; font-size: 64px; line-height: 1; font-family: Georgia, serif; color: var(--cat);
}

/* ============================================================
   TECNICO — documentazione: titoli con ancora, passaggi, note
   ============================================================ */
.bp-layout-tecnico .bp-body { font-size: 16.5px; line-height: 1.75; }
.bp-layout-tecnico .bp-body .bp-sec { border-top: 1px solid var(--border); padding-top: 1.6em; margin-top: 2.2em; }
.bp-layout-tecnico .bp-body .bp-h-sec,
.bp-layout-tecnico .bp-body .bp-h-sub { position: relative; }
.bp-layout-tecnico .bp-body .bp-anchor {
  margin-left: 8px; font-family: var(--font-mono); font-weight: 400; text-decoration: none;
  color: var(--text-mute); opacity: 0; transition: opacity .15s;
}
.bp-layout-tecnico .bp-body .bp-h-sec:hover .bp-anchor,
.bp-layout-tecnico .bp-body .bp-h-sub:hover .bp-anchor,
.bp-layout-tecnico .bp-body .bp-anchor:focus-visible { opacity: 1; }
.bp-layout-tecnico .bp-body .bp-h-step {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--cat) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--cat) 25%, transparent);
  font-size: 17.5px;
}
.bp-layout-tecnico .bp-body blockquote {
  font-style: normal; font-size: 15.5px; color: var(--text); border-left-width: 3px;
}
.bp-layout-tecnico .bp-body code { background: color-mix(in srgb, var(--cat) 10%, var(--surface-2)); color: #0b3d36; }
.bp-layout-tecnico .bp-body pre { border: 1px solid #2a2e3d; box-shadow: var(--shadow-sm); line-height: 1.6; }
.bp-layout-tecnico .bp-body pre code { color: inherit; }
.bp-layout-tecnico .bp-body .bp-table-wrap th { font-family: var(--font-mono); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.bp-layout-tecnico .bp-body .bp-table-wrap td { font-size: 14.5px; }

/* ============================================================
   LEGALE — documento: sezioni numerate, titoli serif, indice in testa, FAQ
   ============================================================ */
.bp-layout-legale .bp-hero h1,
.bp-layout-legale .bp-body .bp-h-sec,
.bp-layout-legale .bp-body .bp-h-sub { font-family: Georgia, 'Times New Roman', serif; font-weight: 700; letter-spacing: -.005em; }
.bp-layout-legale .bp-reader,
.bp-layout-legale .bp-toc { max-width: 720px; }
.bp-layout-legale .bp-toc { background: var(--surface-2); box-shadow: none; padding: 20px 24px; }
.bp-layout-legale .bp-toc ol { columns: 2 260px; column-gap: 28px; }
.bp-layout-legale .bp-toc li { break-inside: avoid; }
.bp-layout-legale .bp-toc a::before { content: counter(bpt) '.'; }
.bp-layout-legale .bp-body { counter-reset: bpsec; }
/* numero in posizione assoluta, non flex: i titoli contengono anche span
   inline (riferimenti di legge) che in un flex diventerebbero colonne */
.bp-layout-legale .bp-body .bp-h-sec { counter-increment: bpsec; position: relative; padding-left: 48px; }
.bp-layout-legale .bp-body .bp-h-sec::before {
  content: counter(bpsec); position: absolute; left: 0; top: -2px; display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid var(--cat); color: color-mix(in srgb, var(--cat) 70%, #000);
  font-family: var(--font-mono); font-size: 14px; font-weight: 700;
}
.bp-layout-legale .bp-body .bp-sec { padding-bottom: .4em; border-bottom: 1px solid var(--border); }
.bp-layout-legale .bp-body .bp-sec:last-child { border-bottom: 0; }
.bp-layout-legale .bp-body .bp-sec > :not(.bp-h-sec) { margin-left: 48px; }
.bp-layout-legale .bp-body blockquote {
  font-style: normal; font-size: 16.5px; color: var(--text);
  border: 1px solid var(--border-2); border-left: 4px solid var(--cat); border-radius: var(--radius-sm);
  background: var(--surface); padding: 16px 22px;
}
.bp-layout-legale .bp-body .law-ref-btn { color: color-mix(in srgb, var(--cat) 60%, #000); font-weight: 600; }
@media (max-width: 640px) {
  .bp-layout-legale .bp-body .bp-sec > :not(.bp-h-sec) { margin-left: 0; }
  .bp-layout-legale .bp-body .bp-h-sec { padding-left: 44px; }
  .bp-layout-legale .bp-body .bp-h-sec::before { width: 30px; height: 30px; font-size: 13px; }
}

/* FAQ a fisarmonica (tutti i layout, frequenti nei contratti e nei profili) */
.bp-body .bp-faq {
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  margin: 0 0 10px; transition: border-color .2s, box-shadow .2s;
}
.bp-body .bp-faq[open] { border-color: color-mix(in srgb, var(--cat) 40%, var(--border)); box-shadow: var(--shadow-sm); }
.bp-body .bp-faq summary {
  cursor: pointer; list-style: none; position: relative; padding: 14px 48px 14px 18px;
  font-weight: 700; font-size: 16px; line-height: 1.45; color: var(--text); font-family: var(--font);
}
.bp-body .bp-faq summary::-webkit-details-marker { display: none; }
.bp-body .bp-faq summary::after {
  content: '+'; position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--cat) 12%, #fff); color: color-mix(in srgb, var(--cat) 75%, #000); font-weight: 700;
}
.bp-body .bp-faq[open] summary::after { content: '−'; }
.bp-body .bp-faq-a { padding: 0 18px 4px; font-size: .95em; color: var(--text-dim); }
.bp-body .bp-sec-faq > :not(.bp-h-sec) { margin-left: 0; }

/* ============================================================
   PROFILO — ruolo professionale: sezioni a schede, liste a spunta
   ============================================================ */
.bp-layout-profilo .bp-reader,
.bp-layout-profilo .bp-toc { max-width: 760px; }
.bp-layout-profilo .bp-body { max-width: 760px; }
.bp-layout-profilo .bp-toc ol { display: flex; flex-wrap: wrap; gap: 8px; }
.bp-layout-profilo .bp-toc a {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border-2); font-size: 13.5px;
  background: var(--surface);
}
.bp-layout-profilo .bp-toc a::before { display: none; }
.bp-layout-profilo .bp-toc a:hover,
.bp-layout-profilo .bp-toc a.is-current { border-color: var(--cat); color: var(--text); }
.bp-layout-profilo .bp-body .bp-intro {
  font-size: 18.5px; line-height: 1.7; padding: 4px 0 4px 20px; border-left: 4px solid var(--cat); margin-bottom: 8px;
}
.bp-layout-profilo .bp-body .bp-intro p:last-child { margin-bottom: 0; }
.bp-layout-profilo .bp-body .bp-sec {
  margin-top: 22px; padding: 26px 30px 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.bp-layout-profilo .bp-body .bp-h-sec { font-size: clamp(20px, 2.3vw, 24px); position: relative; padding-left: 22px; }
.bp-layout-profilo .bp-body .bp-h-sec::before {
  content: ''; position: absolute; left: 0; top: .5em; width: 10px; height: 10px; border-radius: 3px; background: var(--cat); transform: rotate(45deg);
}
.bp-layout-profilo .bp-body .bp-h-sub { font-size: 17.5px; margin-top: 1.2em; }
.bp-layout-profilo .bp-body ul:not(.bp-keylist) > li::before {
  content: '✓'; width: auto; height: auto; background: none; top: 0; left: 0;
  color: color-mix(in srgb, var(--cat) 80%, #000); font-weight: 800;
}
.bp-layout-profilo .bp-body ol:not(.bp-keylist) { list-style: none; margin-left: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.bp-layout-profilo .bp-body ol:not(.bp-keylist) > li {
  margin: 0; padding: 6px 14px; border-radius: 999px; font-size: 14.5px; line-height: 1.45;
  background: color-mix(in srgb, var(--cat) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--cat) 25%, transparent);
}
.bp-layout-profilo .bp-body .bp-keylist > li { box-shadow: none; background: var(--surface-2); }
.bp-layout-profilo .bp-body .bp-sec-faq { background: none; border: 0; box-shadow: none; padding: 0; }
@media (max-width: 640px) {
  .bp-layout-profilo .bp-body .bp-sec { padding: 20px 18px 8px; }
}

/* ---------- schermi stretti ---------- */
@media (max-width: 640px) {
  .bp-layout-guida .bp-body { font-size: 17px; }
  .bp-layout-guida .bp-body .bp-first-p { font-size: 18px; }
  .bp-layout-guida .bp-body blockquote { padding: 18px 18px 18px 50px; font-size: 18px; }
  .bp-layout-guida .bp-body blockquote::before { left: 14px; font-size: 52px; }
  .bp-body .has-background { padding: 16px; }
  .bp-body ol.bp-keylist > li { padding-left: 52px; }
}

@media print {
  .bp-progress, .bp-toc, .bp-copy, .bp-cta { display: none !important; }
  .bp-body .bp-faq-a { display: block; }
}

/* voci di sottolivello nell'indice (quando le sezioni sono meno di 3) */
.bp-toc li.is-sub { counter-increment: none; }
.bp-toc li.is-sub a { padding-left: 16px; font-size: .93em; }
.bp-toc li.is-sub a::before { content: '–'; }
.bp-layout-legale .bp-toc li.is-sub a::before { content: '–'; }
