/* ==========================================================================
   Pubblipro - Blog (elenco e articolo)
   Si aggiunge a base.css e home.css. Qui ci sono: articolo in evidenza, griglia di
   schede, paginazione, intestazione dell'articolo, testo, indice e articoli correlati.
   ========================================================================== */

/* ---------- Elenco ---------- */
.blog-index {
  position: relative;
  padding: 176px 0 136px;
  /* quaderno a quadretti, lo stesso della pagina Lavora con noi */
  background:
    linear-gradient(rgba(20, 20, 26, 0.055) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgba(20, 20, 26, 0.055) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--paper);
}
.blog-index__inner { display: flex; flex-direction: column; gap: 112px; }
.blog-index__empty { margin: 0; font-size: 22px; color: var(--muted); }

/* Articolo in evidenza: scheda orizzontale, copertina a sinistra */
.bfeat__link {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: center;
  gap: 48px clamp(40px, 5.5vw, 96px);
}
.bfeat__media { --cm: var(--ink); display: block; }
.bfeat__frame { display: block; aspect-ratio: 16 / 10; max-height: 420px; overflow: hidden; background: var(--paper-2); }
.bfeat__frame img { height: 100%; }
.bfeat__text { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; min-width: 0; }
.bfeat__text time { font-size: 18px; color: var(--muted); }
.bfeat__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(32px, 3.6vw, 54px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.bfeat__lead {
  max-width: 46ch;
  color: var(--muted);
  font-size: 21px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bfeat__btn { margin-top: 8px; }

/* Griglia di schede */
.bgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 72px clamp(28px, 3vw, 48px); }
.bcard { display: flex; min-width: 0; }
.bcard__link { display: flex; flex-direction: column; gap: 24px; width: 100%; }
.bcard__frame { display: block; aspect-ratio: 16 / 10; overflow: hidden; background: var(--paper-2); }
.bcard__frame img { height: 100%; }
.bcard__body { flex: 1; display: flex; flex-direction: column; gap: 10px; padding-top: 20px; border-top: 2px solid var(--ink); }
.bcard__body time { font-size: 17px; color: var(--muted); }
.bcard__title { margin: 0; font-weight: 500; font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; }
.bcard__text {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bcard__more { margin-top: auto; padding-top: 12px; display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; }

/* Paginazione */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.pager__a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 56px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1.5px solid var(--ink);
  font-weight: 600;
  font-size: 18px;
  transition: background-color 160ms var(--ease), color 160ms var(--ease), transform 140ms var(--ease);
}
a.pager__a:active { transform: scale(0.94); }
.pager__a.is-current { background: var(--ink); color: var(--paper-text); }
.pager__prev svg { transform: rotate(180deg); }
.pager__gap { min-width: 24px; text-align: center; color: var(--muted); font-size: 20px; }

/* ---------- Articolo: intestazione ---------- */
.post-hero { position: relative; overflow: hidden; background: var(--ink); color: var(--paper-text); }
.post-hero__inner { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 32px; padding-top: 48px; padding-bottom: 104px; }
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0; padding: 0; list-style: none; font-size: 17px; color: var(--muted-on-ink); }
.crumbs li + li::before { content: '›'; margin-right: 12px; opacity: 0.7; }
.crumbs a { text-decoration: underline; text-underline-offset: 4px; transition: color 160ms var(--ease); }
.crumbs [aria-current] { max-width: 44ch; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--paper-text); }
.post-hero__title {
  margin: 0;
  max-width: 24ch;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(36px, 5vw, 72px);
  line-height: 1.04;
  letter-spacing: -0.04em;
}
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0; font-size: 19px; color: var(--muted-on-ink); }

/* ---------- Articolo: corpo ---------- */
.post { position: relative; padding: 176px 0 128px; background: var(--paper); }
.post__inner { display: grid; grid-template-columns: minmax(0, 780px); justify-content: center; }
.post__inner.has-toc { grid-template-columns: minmax(0, 780px) 300px; column-gap: clamp(48px, 6vw, 96px); }
.post__main { min-width: 0; }
.post-cover { --cm: var(--ink); margin: 0 0 64px; }
.post-cover__img { display: block; width: 100%; height: auto; }

.post__body { font-size: 20px; line-height: 1.75; }
.post__body > :first-child { margin-top: 0; }
.post__body p { margin: 0 0 1.15em; }
.post__body h2, .post__body h3 { font-family: var(--font-display); font-weight: 600; scroll-margin-top: 32px; }
.post__body h2 { margin: 2.1em 0 0.6em; font-size: clamp(28px, 2.9vw, 38px); line-height: 1.12; letter-spacing: -0.03em; }
.post__body h3 { margin: 1.8em 0 0.5em; font-size: clamp(23px, 2.2vw, 29px); line-height: 1.2; letter-spacing: -0.02em; }
.post__body strong { font-weight: 700; }
.post__body a { color: var(--red-dark); font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }
.post__body ul, .post__body ol { margin: 0 0 1.3em; padding-left: 1.3em; }
.post__body ul { list-style: disc; }
.post__body ol { list-style: decimal; }
.post__body li { margin: 0.4em 0; padding-left: 0.3em; }
.post__body li::marker { color: var(--red); font-weight: 700; }
.post__body blockquote { margin: 1.8em 0; padding: 4px 0 4px 28px; border-left: 4px solid var(--red); font-family: var(--font-display); font-size: 1.15em; line-height: 1.5; }
.post__body blockquote p:last-child { margin-bottom: 0; }
.post__body img { display: block; max-width: 100%; height: auto; margin: 2em 0; }
.post__body figure { margin: 2em 0; }
.post__body figcaption { margin-top: 10px; font-size: 16px; color: var(--muted); }
.post__body table { display: block; max-width: 100%; margin: 0 0 1.4em; overflow-x: auto; border-collapse: collapse; font-size: 17px; }
.post__body th, .post__body td { padding: 10px 14px; border: 1px solid rgba(20, 20, 26, 0.3); text-align: left; }
.post__body hr { margin: 2.4em 0; border: 0; border-top: 2px solid var(--ink); }
.post__back { margin: 72px 0 0; }

/* ---------- Indice dell'articolo ---------- */
.post__side { align-self: start; position: sticky; top: 32px; }
.toc { display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 64px); overflow-y: auto; padding: 28px 24px; border: 2px solid var(--ink); border-radius: var(--radius); }
.toc__title, .toc summary { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--red-dark); }
.toc ol { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.toc a { display: block; padding: 7px 0 7px 14px; border-left: 3px solid transparent; font-size: 17px; line-height: 1.35; color: var(--muted); transition: color 160ms var(--ease), border-color 160ms var(--ease); }
.toc a.is-active { border-left-color: var(--red); color: var(--ink); font-weight: 600; }

/* versione ripiegabile per telefono e tablet: sopra il testo */
.toc--inline { display: none; margin: 0 0 48px; padding: 0; overflow: visible; max-height: none; }
.toc--inline summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; list-style: none; cursor: pointer; }
.toc--inline summary::-webkit-details-marker { display: none; }
.toc--inline summary::after { content: '+'; font-size: 26px; line-height: 1; letter-spacing: 0; }
.toc--inline[open] summary::after { content: '−'; }
.toc--inline nav { padding: 0 24px 20px; }
.toc--inline summary:focus-visible { outline-offset: -4px; }

/* ---------- Articoli correlati ---------- */
.related { padding: 120px 0 136px; background: var(--paper-2); }
.related__title { margin: 0 0 56px; font-family: var(--font-display); font-weight: 600; font-size: clamp(34px, 4vw, 56px); line-height: 1; letter-spacing: -0.04em; }

/* ---------- Effetti solo con il mouse ---------- */
@media (hover: hover) and (pointer: fine) {
  .bcard__link:hover .slot, .bfeat__link:hover .slot { transform: scale(1.06); }
  .bcard__link:hover .arrow, .bfeat__link:hover .arrow { transform: translateX(6px); }
  .bfeat__link:hover .bfeat__btn { background: var(--ink); color: var(--paper-text); }
  a.pager__a:hover { background: var(--ink); color: var(--paper-text); }
  .toc a:hover { color: var(--ink); }
  .crumbs a:hover { color: #E8777C; }
  .post__body a:hover { color: var(--red); }
}

/* ---------- Schermi medi e piccoli ---------- */
@media (min-width: 1181px) {
  html:has(.post) { scroll-behavior: smooth; }
}
@media (max-width: 1180px) {
  .post__inner.has-toc { grid-template-columns: minmax(0, 780px); }
  .post__side { display: none; }
  .toc--inline { display: block; border: 2px solid var(--ink); border-radius: var(--radius); }
  .bgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .bfeat__link { grid-template-columns: minmax(0, 1fr); }
  .blog-index__inner { gap: 88px; }
}
@media (max-width: 700px) {
  .bgrid { grid-template-columns: minmax(0, 1fr); gap: 64px; }
}
@media (max-width: 640px) {
  .blog-index { padding: 152px 0 96px; }
  .post { padding: 152px 0 96px; }
  .post-hero__inner { padding-bottom: 80px; }
  .post__body { font-size: 18px; }
  .post-cover { margin-bottom: 48px; }
  .bcard__title { font-size: 26px; }
  .related { padding: 96px 0; }
  .crumbs [aria-current] { max-width: 28ch; }
  .pager__a { min-width: 48px; height: 48px; padding: 0 12px; }
}

/* ---------- Movimento ridotto ---------- */
@media (prefers-reduced-motion: reduce) {
  .pager__a, .toc a, .crumbs a { transition: none; }
}


/* ---------- Anteprima dall'area riservata ---------- */
.preview-bar { position: relative; z-index: 45; padding: 12px clamp(16px, 4vw, 48px); background: var(--amber); color: var(--ink); font-size: 17px; font-weight: 600; text-align: center; }
.preview-bar a { margin-left: 10px; text-decoration: underline; text-underline-offset: 4px; }
