/*
 * Single post (blog article) — single-post.php.
 *
 * Loaded only on is_singular('post') (see inc/blog.php). Uses the palette,
 * type scale and spacing tokens from the child theme; no new Tailwind
 * utilities, so no rebuild of the parent stylesheet is needed.
 */

body.single-post {
  background-color: var(--color-quartz-20);
}

.article {
  --article-gutter: clamp(16px, 5.2vw, 100px);
  --article-tint: color-mix(in srgb, var(--color-blue-20) 50%, transparent);
}

.article-container {
  margin-inline: auto;
  max-width: 1920px;
  padding-inline: var(--article-gutter);
}

/* ─────────────────────────────────────────────────────────
 * Hero
 * ───────────────────────────────────────────────────────── */

/* The desktop .page-header (navbar.css) sits in the flow above <main>:
   subtract its height so the text starts 191px from the top, as in the
   design. */
.article-hero {
  padding-top: 40px;
}

@media (min-width: 1024px) {
  .article-hero {
    padding-top: calc(191px - (var(--nav-top) * 2 + var(--nav-pill-h)));
  }
}

.article-hero__text {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1059px;
  padding-bottom: 53px;
}

.article-hero__breadcrumb {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: var(--text-xs);
  gap: 4px;
  line-height: 20px;
  opacity: 0.6;
}

.article-hero__breadcrumb-root {
  font-weight: 600;
}

.article-hero__breadcrumb a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article-hero__title {
  color: var(--color-navy-80);
  font-size: var(--text-5xl);
  font-weight: 500;
  line-height: 72px;
}

.article-hero__title span {
  color: var(--color-blue-50);
}

.article-hero__excerpt {
  font-size: var(--text-base);
  line-height: 20px;
  max-width: 737px;
}

.article-hero__meta {
  font-size: var(--text-xs);
  line-height: 20px;
  opacity: 0.6;
}

.article-hero__meta span {
  margin-inline: 4px;
}

.article-hero__meta a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Banner ratio from the design on desktop; on small screens a taller 16:9
   (a min-height combined with aspect-ratio would widen the box past the
   viewport instead of making it taller). */
.article-hero__media {
  aspect-ratio: 16 / 9;
  margin: 0;
  overflow: hidden;
  width: 100%;
}

@media (min-width: 768px) {
  .article-hero__media {
    aspect-ratio: 1920 / 558;
  }
}

.article-hero__image {
  height: 100%;
  object-fit: cover;
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  width: 100%;
}

.article-hero__media:hover .article-hero__image {
  transform: scale(1.05);
}

/* ─────────────────────────────────────────────────────────
 * Layout: content + sticky table of contents
 * ───────────────────────────────────────────────────────── */

.article-layout {
  display: grid;
  gap: 48px;
  grid-template-columns: minmax(0, 1fr);
  padding-block: var(--spacing-2xl);
}

@media (min-width: 1024px) {
  .article-layout {
    grid-template-columns: minmax(0, 1044px) minmax(260px, 406px);
    justify-content: space-between;
    padding-block: 120px;
  }

  .article-layout--no-toc {
    grid-template-columns: minmax(0, 1044px);
  }
}

.article-main {
  min-width: 0;
}

/* ── Table of contents ── */

.article-toc {
  display: none;
}

@media (min-width: 1024px) {
  .article-toc {
    align-self: start;
    display: block;
    position: sticky;
    top: 140px;
  }
}

.article-toc__title {
  color: var(--color-blue-50);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 24px;
}

.article-toc__list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.article-toc__link {
  border-left: 3px solid transparent;
  display: block;
  font-size: 18px;
  line-height: 1.5;
  padding: 5px 0 5px 21px;
  text-decoration: none;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.article-toc__link:hover {
  color: var(--color-blue-50);
}

.article-toc__link.is-active {
  background-color: var(--article-tint);
  border-left-color: var(--color-blue-50);
}

/* ── Table of contents, small screens: closed accordion after "In sintesi" ── */

.article-toc-mobile {
  background-color: var(--article-tint);
  border-left: 10px solid var(--color-blue-50);
  margin-bottom: 56px;
}

@media (min-width: 1024px) {
  .article-toc-mobile {
    display: none;
  }
}

/* Sits right below the summary box: tighter gap between the two. */
.article-summary + .article-toc-mobile {
  margin-top: -40px;
}

.article-toc-mobile__summary {
  align-items: center;
  color: var(--color-blue-50);
  cursor: pointer;
  display: flex;
  font-size: var(--text-lg);
  font-weight: 700;
  gap: 16px;
  justify-content: space-between;
  line-height: 1.5;
  list-style: none;
  padding: 20px 24px;
}

.article-toc-mobile__summary::-webkit-details-marker {
  display: none;
}

/* Same plus/minus icon as the Toggle/FAQ accordion. */
.article-toc-mobile__icon {
  background-color: currentColor;
  flex-shrink: 0;
  height: 24px;
  mask: url("../icons/plus.svg") center / contain no-repeat;
  -webkit-mask: url("../icons/plus.svg") center / contain no-repeat;
  width: 24px;
}

.article-toc-mobile[open] .article-toc-mobile__icon {
  mask-image: url("../icons/minus.svg");
  -webkit-mask-image: url("../icons/minus.svg");
}

.article-toc-mobile__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  list-style: none;
  margin: 0;
  padding: 0 24px 24px;
}

.article-toc-mobile__link {
  display: block;
  font-size: var(--text-base);
  line-height: 1.5;
  text-decoration: none;
}

.article-toc-mobile__link:hover {
  color: var(--color-blue-50);
}

/* ── "In sintesi" box ── */

.article-summary {
  background-color: var(--article-tint);
  border-left: 10px solid var(--color-blue-50);
  display: flex;
  flex-direction: column;
  gap: 32px;
  margin-bottom: 56px;
  padding: 32px 42px;
}

.article-summary__title {
  font-size: var(--text-2xl);
  font-weight: 500;
  line-height: 1.4;
}

.article-summary__list {
  font-size: var(--text-lg);
  line-height: 1.5;
  list-style: disc;
  padding-left: 32px;
}

/* ─────────────────────────────────────────────────────────
 * Article body — core blocks written in the editor
 * ───────────────────────────────────────────────────────── */

.article-body {
  font-size: var(--text-lg);
  line-height: 1.5;
}

.article-body > *:first-child {
  margin-top: 0;
}

.article-body > *:last-child {
  margin-bottom: 0;
}

.article-body p,
.article-body ul,
.article-body ol {
  margin-bottom: 1.5em;
}

.article-body ul,
.article-body ol {
  padding-left: 32px;
}

.article-body li + li {
  margin-top: 1em;
}

.article-body h2,
.article-body h3,
.article-body h4 {
  font-weight: 500;
  /* Below the fixed desktop navbar; on small screens the header scrolls away. */
  scroll-margin-top: 24px;
}

@media (min-width: 1024px) {
  .article-body h2,
  .article-body h3,
  .article-body h4 {
    scroll-margin-top: 140px;
  }
}

.article-body h2 {
  font-size: var(--text-4xl);
  line-height: 1.2;
  margin: 64px 0 30px;
}

.article-body h3 {
  font-size: var(--text-2xl);
  line-height: 1.25;
  margin: 48px 0 24px;
}

.article-body h4 {
  font-size: var(--text-xl);
  line-height: 1.3;
  margin: 32px 0 16px;
}

.article-body h2 + h3 {
  margin-top: 0;
}

.article-body a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}

.article-body a:hover {
  color: var(--color-secondary);
}

.article-body strong,
.article-body b {
  font-weight: 700;
}

.article-body em,
.article-body i {
  font-style: italic;
}

.article-body figure,
.article-body .wp-block-image {
  margin: 48px 0;
}

.article-body img {
  border-radius: 24px;
  height: auto;
  max-width: 100%;
}

.article-body figcaption {
  font-size: var(--text-sm);
  line-height: var(--text-sm--line-height);
  margin-top: 12px;
  opacity: 0.6;
}

/* ─────────────────────────────────────────────────────────
 * FAQ — reuses the Toggle block markup/script (assets/css/toggle.css)
 * ───────────────────────────────────────────────────────── */

.article-faq {
  background-color: var(--color-ice-20);
  padding: var(--spacing-2xl) var(--article-gutter);
}

.article-faq__inner {
  display: grid;
  gap: 48px;
  margin-inline: auto;
  max-width: 1427px;
}

@media (min-width: 1024px) {
  .article-faq__inner {
    grid-template-columns: minmax(0, 552px) minmax(0, 839px);
    justify-content: space-between;
  }
}

.article-faq__intro {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.article-faq__eyebrow {
  color: var(--color-blue-50);
  font-size: var(--text-base);
  line-height: 24px;
}

.article-faq__title {
  color: var(--color-navy-80);
  font-size: var(--text-4xl);
  font-weight: 500;
  line-height: var(--text-4xl--line-height);
}

.article-faq__title span {
  color: var(--color-blue-50);
}

.article-faq__subtitle {
  font-size: var(--text-lg);
  line-height: 28px;
}

.article-faq .toggle-item {
  border-radius: 32px;
}

/* ─────────────────────────────────────────────────────────
 * CTA with form — same visual as the Contact Us block
 * ───────────────────────────────────────────────────────── */

.article-cta {
  padding: var(--spacing-xl) var(--article-gutter);
}

.article-cta__box {
  background-color: var(--color-ice-20);
  margin-inline: auto;
  max-width: 1720px;
  padding: var(--spacing-2xl) var(--spacing-md);
}

.article-cta__content {
  display: flex;
  flex-direction: column;
  gap: 32px;
  margin-inline: auto;
  max-width: 843px;
}

.article-cta__title {
  color: var(--color-blue-50);
  font-size: var(--text-5xl);
  font-weight: 500;
  line-height: 72px;
  text-align: center;
}

.article-cta__title span {
  color: var(--color-pink-80);
}

.article-cta__subtitle {
  font-size: var(--text-lg);
  line-height: 28px;
  margin-inline: auto;
  max-width: 551px;
}

.article-cta .wpcf7-form {
  gap: 32px;
}

.article-cta .wpcf7-form-control-wrap {
  margin-top: 0;
}

.article-cta .cf7-row {
  display: grid;
  gap: 24px;
}

/* CF7 autop wraps the row's fields in a <p>: flatten it so the fields are
   the grid items. */
.article-cta .cf7-row > p {
  display: contents;
}

@media (min-width: 640px) {
  .article-cta .cf7-row {
    grid-template-columns: 1fr 1fr;
  }
}

.article-cta .wpcf7-form p:has(.wpcf7-submit) {
  display: flex;
  justify-content: center;
}

/* ─────────────────────────────────────────────────────────
 * Mobile
 * ───────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .article-hero__title,
  .article-cta__title {
    line-height: var(--text-5xl--line-height);
  }

  .article-hero__title {
    font-size: var(--text-4xl);
    line-height: var(--text-4xl--line-height);
  }

  .article-summary {
    gap: 20px;
    padding: 24px;
  }

  .article-body h2 {
    margin-top: 48px;
  }

  .article-cta__box {
    border-radius: 32px;
    padding-block: var(--spacing-xl);
  }

  .article-cta__title {
    font-size: var(--text-3xl);
    line-height: var(--text-3xl--line-height);
  }
}

/* ─────────────────────────────────────────────────────────
 * Share — trigger in the hero meta + <dialog> modal
 * (template-parts/share-modal.php, assets/js/single-post.js)
 * ───────────────────────────────────────────────────────── */

/* Icons: masked SVGs from ../icons/, colored with currentColor (same
   technique as the Toggle plus/minus icons). */
.share-icon {
  background-color: currentColor;
  display: inline-block;
  flex-shrink: 0;
  height: 24px;
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  width: 24px;
}

.share-icon--share { mask-image: url("../icons/share.svg"); -webkit-mask-image: url("../icons/share.svg"); }
.share-icon--facebook { mask-image: url("../icons/facebook.svg"); -webkit-mask-image: url("../icons/facebook.svg"); }
.share-icon--linkedin { mask-image: url("../icons/linkedin.svg"); -webkit-mask-image: url("../icons/linkedin.svg"); }
.share-icon--x { mask-image: url("../icons/x.svg"); -webkit-mask-image: url("../icons/x.svg"); }
.share-icon--mail { mask-image: url("../icons/mail.svg"); -webkit-mask-image: url("../icons/mail.svg"); }
.share-icon--sms { mask-image: url("../icons/sms.svg"); -webkit-mask-image: url("../icons/sms.svg"); }
.share-icon--link { mask-image: url("../icons/link.svg"); -webkit-mask-image: url("../icons/link.svg"); }
.share-icon--check { mask-image: url("../icons/check.svg"); -webkit-mask-image: url("../icons/check.svg"); }
.share-icon--google { mask-image: url("../icons/google.svg"); -webkit-mask-image: url("../icons/google.svg"); }
.share-icon--close {
  mask-image: url("../icons/plus.svg");
  -webkit-mask-image: url("../icons/plus.svg");
  transform: rotate(45deg);
}

/* Trigger: underlined link look, inline with the meta line. */
.article-hero__share {
  align-items: center;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  gap: 4px;
  text-decoration: underline;
  text-underline-offset: 2px;
  vertical-align: bottom;
}

.article-hero__share .share-icon {
  height: 14px;
  width: 14px;
}

.article-hero__share:hover {
  color: var(--color-blue-50);
}

/* Modal */
.share-modal {
  background-color: var(--color-quartz-20);
  border: 0;
  border-radius: 32px;
  box-shadow: 0 24px 64px rgba(21, 32, 55, 0.18);
  color: var(--color-text);
  /* Tailwind preflight sets margin:0 on everything; <dialog> centers itself
     with margin:auto. */
  margin: auto;
  max-height: calc(100dvh - 32px);
  max-width: min(480px, calc(100vw - 32px));
  overflow-y: auto;
  padding: 32px;
  width: 100%;
}

.share-modal::backdrop {
  background-color: rgba(21, 32, 55, 0.45);
}

.share-modal[open] {
  animation: share-modal-in 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes share-modal-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .share-modal[open] {
    animation: none;
  }
}

.share-modal__header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
}

.share-modal__title {
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: var(--text-xl--line-height);
}

.share-modal__close {
  align-items: center;
  border-radius: 9999px;
  color: var(--color-blue-50);
  cursor: pointer;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  transition: background-color 0.2s ease;
  width: 40px;
}

.share-modal__close:hover {
  background-color: var(--color-ice-20);
}

.share-modal__list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.share-modal__item {
  align-items: center;
  background-color: var(--color-ice-20);
  border-radius: 9999px;
  color: var(--color-navy-80);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: var(--text-base);
  gap: 12px;
  height: 52px;
  padding: 0 20px;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
  width: 100%;
}

.share-modal__item .share-icon {
  color: var(--color-blue-50);
  height: 20px;
  width: 20px;
}

.share-modal__item:hover {
  background-color: var(--color-blue-50);
  color: var(--color-quartz-20);
}

.share-modal__item:hover .share-icon {
  color: inherit;
}

.share-modal__item.is-copied {
  background-color: var(--color-success);
  color: var(--color-quartz-20);
}

.share-modal__item.is-copied .share-icon {
  color: inherit;
}

.share-modal__google {
  align-items: center;
  border: 1px solid var(--color-quartz-60);
  border-radius: 24px;
  color: var(--color-navy-80);
  display: flex;
  gap: 16px;
  margin-top: 24px;
  padding: 16px 20px;
  text-decoration: none;
  transition: border-color 0.2s ease;
}

.share-modal__google:hover {
  border-color: var(--color-blue-50);
}

.share-modal__google .share-icon {
  color: var(--color-blue-50);
}

.share-modal__google strong {
  display: block;
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 22px;
}

.share-modal__google-note {
  display: block;
  font-size: var(--text-sm);
  line-height: var(--text-sm--line-height);
  margin-top: 2px;
  opacity: 0.7;
}

.share-modal__status:empty {
  display: none;
}

.share-modal__status {
  font-size: var(--text-sm);
  margin-top: 16px;
  text-align: center;
}

@media (max-width: 480px) {
  .share-modal {
    padding: 24px;
  }

  .share-modal__list {
    grid-template-columns: minmax(0, 1fr);
  }
}
