/* Blog editorial system (loaded only on the Blog views): content headings H5/H6, native Gallery, YouTube facade, archive thumbnails.
   Everything is additive to the locked Blog CSS (demo/blog/struttura.css): it only uses that file's tokens. */

/* --- H5 / H6 in the Block Editor content (H2-H4 are in the locked CSS) --- */
.w-entry :is(h5, h6) { overflow-wrap: break-word; color: var(--bone); scroll-margin-top: calc(var(--bar) + 24px); font: 500 .875rem/1.4 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; }
.w-entry h6 { color: var(--muted); }
.w-entry :is(h5, h6) { margin-top: var(--s4); }
.w-entry :is(h5, h6) + * { margin-top: var(--s2); }

/* --- figures: an empty caption never draws its rule; non-prose figures never overflow --- */
.w-entry figcaption:empty { display: none; }
.w-entry figure { max-width: 100%; }

/* --- Gallery (core block, "Expand on click") --- */
.w-entry > .wp-block-gallery { max-width: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); margin-block: var(--s6); }
.w-entry .wp-block-gallery > .wp-block-image { position: relative; margin: 0; width: auto; }
.w-entry .wp-block-gallery img { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; object-fit: cover; }
.w-entry .wp-block-gallery figcaption { margin-top: var(--s1); }
.w-entry .wp-block-gallery.columns-1 { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) {
  .w-entry .wp-block-gallery.columns-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .w-entry .wp-block-gallery.columns-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* the expand button of core: 44 px target, visible focus */
.w-entry .lightbox-trigger:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; opacity: 1; }

/* --- YouTube: click-to-load facade (no request to YouTube until the visitor starts the video) --- */
.w-entry .wp-block-embed { margin-block: var(--s6); }
.alb-yt { position: relative; aspect-ratio: 16 / 9; background: var(--black-2); outline: 1px solid var(--hair-2); outline-offset: -1px; }
.alb-yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.alb-yt-b { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; gap: var(--s2); width: 100%; padding: var(--s3); border: 0; background: none; color: var(--bone); text-align: left; cursor: pointer; font: 700 clamp(1.25rem, 2.4vw, 1.75rem)/1.15 var(--font-display); }
.alb-yt-b:focus-visible { outline: 3px solid var(--signal); outline-offset: -6px; }
.alb-yt-b::before { content: ""; position: absolute; top: 50%; left: 50%; width: 72px; height: 72px; margin: -36px 0 0 -36px; background: var(--signal); clip-path: circle(50%); }
.alb-yt-b::after { content: ""; position: absolute; top: 50%; left: 50%; margin: -14px 0 0 -9px; border-left: 24px solid var(--black); border-block: 14px solid transparent; }
.alb-yt-b:hover::before { background: var(--bone); }
.alb-yt-note { margin-top: var(--s2); font: 500 .75rem/1.55 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.w-entry .alb-yt-note a { color: var(--bone); }
@media (forced-colors: active) { .alb-yt-b::before { background: Highlight; } .alb-yt-b::after { border-left-color: HighlightText; } .alb-yt-b:hover::before { background: Highlight; } }

/* --- Featured image (archive rows, "Ultimo articolo", Single cover; only rendered when it exists, no placeholder).
   A-98: the covers are 1200 × 630 with graphic text, so the whole image is shown at its own ratio (no crop, no bands), at most 1200 px wide.
   The ratio comes from the img width / height attributes (exact per file; lazy `sizes="auto"` images ignore the natural ratio, so no CSS ratio may override it).
   Only the Single cover sets one, to undo the locked 2.4:1 crop of struttura.css (figure.w-cover outranks it); being eager, its own ratio wins once loaded. --- */
.w-th { display: block; max-width: 1200px; margin-bottom: var(--s3); }
.w-latest .w-th { margin: 0 0 var(--s4); }
.w-th img, figure.w-cover img { display: block; width: 100%; max-width: 1200px; height: auto; object-fit: fill; outline: 1px solid var(--hair-2); outline-offset: -1px; }
figure.w-cover img { aspect-ratio: auto 1200 / 630; }

/* --- Native lightbox (core Interactivity): site colours, 44 px controls, visible focus; navigation / Escape / focus return are core behaviour --- */
.wp-lightbox-overlay .scrim { background-color: var(--black) !important; opacity: 1 !important; }
.wp-lightbox-overlay :is(.close-button, .wp-lightbox-navigation-button) { min-width: 44px; min-height: 44px; }
.wp-lightbox-overlay :is(button) svg { fill: var(--bone); }
.wp-lightbox-overlay button:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
.wp-lightbox-overlay .wp-lightbox-navigation-button svg, .wp-lightbox-overlay .wp-lightbox-close-button svg { width: 28px; height: 28px; }
.w-entry .wp-block-image .lightbox-trigger { width: 44px; height: 44px; border-radius: 0; background: var(--black); color: var(--bone); backdrop-filter: none; }
.w-entry .wp-block-image .lightbox-trigger svg { fill: var(--bone); }

/* --- Archive empty state (no published article): one plain line and a link, no placeholder cards --- */
.w-sec--empty .w-empty { margin-top: var(--s5); max-width: 38ch; font-size: clamp(1.1875rem, 1.5vw, 1.375rem); line-height: 1.5; color: var(--soft); }
.w-sec--empty .w-cta { margin-top: var(--s4); }
.w-sec--empty .w-empty-link { color: inherit; text-decoration: none; }
.w-sec--empty .w-empty-link:hover { text-decoration: underline 2px var(--signal); text-underline-offset: .2em; }
.w-sec--empty .w-empty-link:focus-visible { outline: 3px solid var(--signal); outline-offset: 6px; }

/* --- CLS: below 1240 px blog.js collapses the index after load, which moved the whole article; with JS available the list starts collapsed and the label keeps the button's height --- */
@media (max-width: 1239px) {
  html.js .w-toc:not(.js-toc) > ul { display: none; }
  html.js .w-toc:not(.js-toc) { margin-bottom: var(--s5); }
  html.js .w-toc:not(.js-toc) .w-toc-h { box-sizing: border-box; min-height: 57px; }
}

/* --- Article index (.w-toc, sticky and scrollable on wide screens): the browser's default white, thick scrollbar with arrows did not belong to the site.
   Thin (5 px) bar, transparent track, discreet grey thumb, signal yellow when the thumb is hovered or dragged (Firefox: while the index is hovered or focused), no arrows. The index keeps its scrolling
   (never hidden), keyboard use and focus rings are untouched. Firefox only offers scrollbar-width: thin (about 8 px); Chrome / Safari take the exact 5 px.
   Chrome 121+ ignores ::-webkit-scrollbar when scrollbar-color is set, so each engine gets only its own rules. --- */
@supports not selector(::-webkit-scrollbar) {
  .w-toc { scrollbar-width: thin; scrollbar-color: rgb(241 238 230 / .3) transparent; }
  .w-toc:is(:hover, :focus-within) { scrollbar-color: var(--signal) transparent; }
}
@supports selector(::-webkit-scrollbar) {
  .w-toc::-webkit-scrollbar { width: 5px; height: 5px; background: transparent; }
  .w-toc::-webkit-scrollbar-track { background: transparent; }
  .w-toc::-webkit-scrollbar-corner { background: transparent; }
  .w-toc::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
  .w-toc::-webkit-scrollbar-thumb { background: rgb(241 238 230 / .3); border-radius: 3px; }
  .w-toc::-webkit-scrollbar-thumb:hover, .w-toc::-webkit-scrollbar-thumb:active { background: var(--signal); }
}
