/* Article and page body. Markup is emitted by the engine (BlockRenderer); only styled here, never restructured.
   Wrapper: <div class="c-body"> (theme-owned). Column 760 px, running text 40rem inside it. */
@layer blocks {
  .c-body { font-size: var(--fs-body-sm); line-height: var(--lh-body); letter-spacing: -0.003em; }
  @media (min-width: 48em) {
    .c-body { font-size: var(--fs-body); }
  }
  .c-body > * { margin-block: 0 var(--space-5); }
  .c-body > :last-child { margin-block-end: 0; }
  .c-body > :is(p, ul, ol, h2, h3, h4, hr, blockquote, .blk-readalso) { max-inline-size: var(--measure); }

  .c-body p { text-wrap: pretty; }
  .c-body a { color: var(--brand-strong); text-decoration: underline; text-decoration-thickness: 0.0625em; text-underline-offset: 0.18em; }
  .c-body a:hover { color: var(--ink); }
  .c-body u { text-decoration-thickness: 0.0625em; text-underline-offset: 0.18em; }
  .c-body sub, .c-body sup { font-size: 0.7em; line-height: 0; }

  /* headings carry ids (anchor links, table of contents): keep them clear of the viewport edge */
  .c-body :is(h2, h3, h4) { scroll-margin-block-start: var(--space-6); }
  .c-body h2 { margin-block: var(--space-12) var(--space-4); font-size: var(--fs-h2-sm); line-height: 1.15; }
  .c-body h3 { margin-block: var(--space-10) var(--space-3); font-size: var(--fs-h3-sm); line-height: 1.2; }
  .c-body h4 { margin-block: var(--space-8) var(--space-2); font-size: var(--fs-h4-sm); font-weight: var(--fw-strong); letter-spacing: 0; line-height: 1.3; }
  @media (min-width: 48em) {
    .c-body h2 { font-size: var(--fs-h2); }
    .c-body h3 { font-size: var(--fs-h3); }
    .c-body h4 { font-size: var(--fs-h4); }
  }
  .c-body > :is(h2, h3, h4):first-child { margin-block-start: 0; }

  .c-body :is(ul, ol) { padding-inline-start: 1.5rem; }
  .c-body li { margin-block: 0.5rem; padding-inline-start: 0.25rem; }
  .c-body li > :is(p, ul, ol) { margin-block: 0.5rem 0; }
  .c-body ul { list-style: square; }
  .c-body ul > li::marker { font-size: 0.8em; }
  .c-body ol > li::marker { color: var(--ink-muted); }
  .c-body hr { margin-block: var(--space-10); }

  /* quote */
  .blk-quote {
    margin-inline: 0;
    padding-inline-start: var(--space-5);
    border-inline-start: 2px solid var(--ink);
  }
  .blk-quote p { margin: 0; font-size: 1.1875rem; font-weight: var(--fw-medium); line-height: 1.4; letter-spacing: var(--track-card); }
  .blk-quote p + p { margin-block-start: var(--space-3); }
  .blk-quote cite {
    display: block;
    margin-block-start: var(--space-3);
    font-size: var(--fs-xs);
    font-style: normal;
    font-stretch: var(--stretch-label);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--ink-muted);
  }
  @media (min-width: 48em) {
    .blk-quote p { font-size: 1.25rem; }
  }

  /* "Czytaj też" line inserted automatically between paragraphs */
  .blk-readalso { margin-block: var(--space-8); padding-block: var(--space-4); border-block: 1px solid var(--border); font-size: var(--fs-md); line-height: 1.4; }
  .blk-readalso strong {
    display: block;
    margin-block-end: var(--space-1);
    font-size: var(--fs-xs);
    font-weight: var(--fw-regular);
    font-stretch: var(--stretch-label);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--ink-muted);
  }
  .c-body .blk-readalso a { color: var(--ink); font-weight: var(--fw-medium); text-decoration: none; letter-spacing: var(--track-card); }
  .c-body .blk-readalso a:hover { text-decoration: underline; }

  /* captions and credits (body figures, cover, gallery) */
  .blk-caption, .blk-credit, figcaption { font-size: var(--fs-sm); line-height: 1.45; color: var(--ink-muted); }
  .blk-credit { font-size: var(--fs-xs); font-stretch: var(--stretch-label); letter-spacing: 0.05em; text-transform: uppercase; }

  /* image: never upscaled, never cropped. Small pictures keep their size and sit on the text edge; tall ones are
     held to 40rem and shown whole on a quiet plate; wide ones fill the column. */
  .blk-image { margin-block: var(--space-8); }
  .blk-image img {
    max-inline-size: 100%;
    block-size: auto;
    max-block-size: 40rem;
    object-fit: contain;
    background: var(--surface-alt);
  }
  .blk-image figcaption { margin-block-start: var(--space-3); }

  /* gallery in the text: native scroll-snap track; script adds controls, counter, zoom and a thumbnail strip */
  .blk-gallery { margin-block: var(--space-8); }
  .blk-gallery__carousel { display: grid; }
  .blk-gallery__track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--ink-muted) var(--surface-alt);
    touch-action: manipulation;
  }
  @media (prefers-reduced-motion: no-preference) {
    .blk-gallery__track { scroll-behavior: smooth; }
  }
  .blk-gallery__slide { flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 3 / 2; background: var(--surface-alt); }
  .blk-gallery__slide a { display: block; inline-size: 100%; block-size: 100%; }
  .blk-gallery__slide img { inline-size: 100%; block-size: 100%; object-fit: contain; }
  .blk-gallery figcaption { margin-block-start: var(--space-3); }
  .blk-gallery__carousel.is-enhanced .blk-gallery__track { scrollbar-width: none; }
  .blk-gallery__carousel.is-enhanced .blk-gallery__track::-webkit-scrollbar { display: none; }

  .blk-gallery__controls { display: flex; align-items: center; gap: var(--space-2); min-block-size: var(--tap); border-block-end: 1px solid var(--border); }
  .blk-gallery__btn, .blk-gallery__zoom {
    display: inline-grid;
    place-items: center;
    inline-size: var(--tap);
    block-size: var(--tap);
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
  }
  .blk-gallery__btn:hover, .blk-gallery__zoom:hover { color: var(--brand-strong); }
  .blk-gallery__counter { font-size: var(--fs-sm); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
  .blk-gallery__zoom { margin-inline-start: auto; }
  .blk-gallery__strip { display: flex; gap: var(--space-1); padding-block: var(--space-2); overflow-x: auto; scrollbar-width: thin; }
  .blk-gallery__thumb { flex: none; inline-size: 5rem; aspect-ratio: 3 / 2; padding: 0; border: 0; background: var(--surface-alt); outline: 2px solid transparent; outline-offset: 0; opacity: 0.8; }
  .blk-gallery__thumb img { inline-size: 100%; block-size: 100%; object-fit: cover; }
  .blk-gallery__thumb[aria-current="true"] { outline-color: var(--ink); opacity: 1; }
  .blk-gallery__thumb:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: var(--focus-offset); }

  /* video: nothing loads before the click */
  .blk-embed { position: relative; aspect-ratio: 16 / 9; margin-block: var(--space-8); background: var(--surface-inverse); }
  .blk-embed[data-shape="short"] { aspect-ratio: 9 / 16; max-inline-size: 22.5rem; margin-inline: auto; }
  .blk-embed__facade { position: absolute; inset: 0; display: grid; place-items: center; color: var(--on-inverse); text-decoration: none; overflow: hidden; }
  .blk-embed__facade img { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; object-fit: cover; }
  /* the title sits on a dark gradient over the picture */
  .blk-embed::before {
    content: attr(data-title);
    position: absolute;
    inset: 0 0 auto 0;
    z-index: 1;
    padding: var(--space-4) var(--space-4) var(--space-8);
    background: linear-gradient(rgb(17 20 23 / 0.62), rgb(17 20 23 / 0));
    color: var(--on-inverse);
    font-size: var(--fs-sm);
    pointer-events: none;
  }
  .blk-embed__play {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    min-block-size: 2.75rem;
    padding: 0.625rem 1.125rem;
    background: var(--surface);
    color: var(--ink);
    font-size: var(--fs-sm);
    font-weight: var(--fw-strong);
    font-stretch: var(--stretch-label);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
  }
  .blk-embed__play::before { content: ""; inline-size: 0.75rem; block-size: 0.875rem; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
  .blk-embed__facade:hover .blk-embed__play { background: var(--brand); }
  .blk-embed__frame { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; border: 0; }

  /* table: the wrapper scrolls sideways, the table keeps its natural width */
  .blk-table { margin-block: var(--space-8); overflow-x: auto; max-inline-size: 100%; scrollbar-width: thin; }
  .blk-table table { inline-size: 100%; min-inline-size: 32rem; font-size: 0.9375rem; line-height: 1.4; text-align: start; }
  .blk-table th, .blk-table td { padding: var(--space-3) var(--space-4) var(--space-3) 0; border-block-end: 1px solid var(--border); text-align: start; vertical-align: top; }
  .blk-table thead th {
    padding-block: var(--space-2);
    border-block-end: 1px solid var(--ink);
    font-size: var(--fs-xs);
    font-weight: var(--fw-strong);
    font-stretch: var(--stretch-label);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    white-space: nowrap;
  }
  .blk-table tbody th { font-weight: var(--fw-medium); }
  .blk-table td p { margin: 0; }
  .blk-table td p + p { margin-block-start: var(--space-2); }
  .blk-table:focus-visible { outline-offset: 0; }

  /* sanitised legacy HTML: contain whatever it brings */
  .blk-html { margin-block: var(--space-8); overflow-wrap: anywhere; }
  .blk-html img, .blk-html iframe, .blk-html video { max-inline-size: 100%; block-size: auto; }
  .blk-html > * { margin-block: 0 var(--space-5); }
  .blk-html > :last-child { margin-block-end: 0; }
  .blk-html :is(p, ul, ol, h2, h3, h4) { max-inline-size: var(--measure); }
  .blk-html :is(h2, h3, h4) { margin-block-start: var(--space-8); }
  .blk-html > :first-child { margin-block-start: 0; }
  .blk-html table { inline-size: 100%; max-inline-size: 100%; font-size: 0.9375rem; line-height: 1.4; }
  .blk-html :is(td, th) { padding: var(--space-2) var(--space-4) var(--space-2) 0; border-block-end: 1px solid var(--border); text-align: start; vertical-align: top; }
  .blk-html th { font-weight: var(--fw-strong); }
  .blk-html img { margin-block: var(--space-6); }
  .blk-html a { color: var(--brand-strong); }
}
