/* Überschriften: etwas engerer Zeichenabstand (alle Viewports) */
h1,
h2,
.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6 {
  letter-spacing: 0.01em;
}

/* Erste H1 nicht unter den Header schieben / oben abschneiden */
.contentpartPage .entry-content > h1:first-child,
.contentpartPage .entry-content > .wp-block-heading:first-child {
  padding-top: 24px;
  overflow: visible;
  line-height: 1.3;
}

/* Mobile: kompaktere Schriften, weniger Leerraum, schmalere Seitenränder.
   Gilt nur für Smartphones. Desktop/Tablet bleiben unverändert. */

@media screen and (max-width: 767px) {
  /* Seitlicher Abstand zum Displayrand (Text) */
  .contentpartCenter {
    width: 100%;
    max-width: 100%;
    padding-left: 12px;
    padding-right: 12px;
  }

  .contentpart-singleproduct .contentpartCenter {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  html,
  body {
    font-size: 15px;
    line-height: 1.45;
  }

  .contentpartPage .entry-content,
  .contentpartHome .entry-content,
  .entry-content {
    font-size: 15px;
    line-height: 1.45;
    --wp--preset--font-size--small: 13px;
    --wp--preset--font-size--medium: 15px;
    --wp--preset--font-size--large: 16px;
    --wp--preset--font-size--x-large: 20px;
    --wp--preset--font-size--xx-large: 22px;
    --wp--preset--font-size--huge: 22px;
  }

  /* Reset: globale figure/article-Margins verursachen Überlappung */
  .entry-content article,
  .entry-content aside,
  .entry-content figure,
  .entry-content section,
  .contentpartPage article {
    margin-top: 0;
  }

  /* Fließtext inkl. Gutenberg-Presets und Inline-Größen */
  .entry-content p,
  .entry-content .wp-block-paragraph,
  .entry-content li,
  .wp-block-cover__inner-container p,
  .wp-block-media-text__content p,
  .wp-block-group p {
    font-size: 15px !important;
    line-height: 1.45 !important;
    margin: 0 0 12px 0;
  }

  .entry-content .has-small-font-size {
    font-size: 13px !important;
    line-height: 1.4 !important;
  }

  .entry-content .has-medium-font-size {
    font-size: 15px !important;
    line-height: 1.45 !important;
  }

  .entry-content .has-large-font-size,
  .wp-block-cover__inner-container .has-large-font-size {
    font-size: 16px !important;
    line-height: 1.3 !important;
  }

  .entry-content .has-x-large-font-size,
  .entry-content .has-huge-font-size,
  .entry-content .has-xx-large-font-size {
    font-size: 20px !important;
    line-height: 1.25 !important;
  }

  .entry-content .has-custom-font-size,
  .entry-content [style*="font-size"] {
    font-size: 15px !important;
    line-height: 1.45 !important;
  }

  .entry-content ul,
  .entry-content ol {
    margin: 10px 0;
  }

  .entry-content li {
    margin: 4px 0;
  }

  .entry-content h1,
  .wp-block-cover__inner-container h1,
  .entry-content h1.has-custom-font-size,
  .entry-content h1[style*="font-size"] {
    font-size: 20px !important;
    line-height: 1.3 !important;
    letter-spacing: 0.01em !important;
    margin: 16px 0 8px 0;
    overflow: visible;
    hyphens: none;
    -webkit-hyphens: none;
    word-break: normal;
    overflow-wrap: normal;
  }

  .entry-content h2,
  .wp-block-cover__inner-container h2,
  .entry-content h2.has-custom-font-size,
  .entry-content h2[style*="font-size"] {
    font-size: 18px !important;
    line-height: 1.3 !important;
    letter-spacing: 0.01em !important;
    margin: 14px 0 8px 0;
    overflow: visible;
    hyphens: none;
    -webkit-hyphens: none;
    word-break: normal;
    overflow-wrap: normal;
  }

  .entry-content h3,
  .wp-block-cover__inner-container h3,
  .entry-content h3.has-custom-font-size,
  .entry-content h3[style*="font-size"],
  .entry-content h4,
  .entry-content h4.has-custom-font-size,
  .entry-content h4[style*="font-size"],
  .entry-content h5,
  .entry-content h6 {
    letter-spacing: 0.01em !important;
    hyphens: none;
    -webkit-hyphens: none;
    word-break: normal;
    overflow-wrap: normal;
  }

  .entry-content h3,
  .wp-block-cover__inner-container h3,
  .entry-content h3.has-custom-font-size,
  .entry-content h3[style*="font-size"] {
    font-size: 16px !important;
    line-height: 1.3 !important;
    margin: 12px 0 6px 0;
    overflow: visible;
  }

  .entry-content h4,
  .entry-content h4.has-custom-font-size,
  .entry-content h4[style*="font-size"] {
    font-size: 15px !important;
    line-height: 1.3 !important;
    margin: 12px 0 6px 0;
  }

  .entry-content h5,
  .entry-content h6 {
    font-size: 14px !important;
    line-height: 1.3 !important;
    margin: 10px 0 6px 0;
  }

  /* Blöcke: Abstand halten, aber nicht ineinander schieben */
  .entry-content > * {
    margin-top: 12px;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
  }

  .entry-content > *:first-child {
    margin-top: 0;
  }

  .entry-content > h1:first-child,
  .entry-content > .wp-block-heading:first-child {
    margin-top: 0;
    padding-top: 20px;
  }

  .entry-content > .alignwide + *,
  .entry-content > .alignfull + * {
    margin-top: 12px;
  }

  .entry-content .wp-block-group,
  .entry-content .wp-block-media-text,
  .entry-content .wp-block-cover,
  .entry-content .wp-block-quote,
  .entry-content .wp-block-separator,
  .entry-content .wp-block-buttons,
  .entry-content .wp-block-gallery,
  .entry-content .wp-block-table,
  .entry-content .wp-block-embed,
  .entry-content .wp-block-video,
  .entry-content .wp-block-columns {
    margin-top: 12px;
    margin-bottom: 12px;
  }

  /* Bilder: voll sichtbar, natürliches Seitenverhältnis (kein 100vw-Zuschnitt).
     Gutenberg nutzt teils figure.wp-block-image, teils div.wp-block-image > figure.align* */
  .entry-content .wp-block-image,
  .entry-content .wp-block-image.alignfull,
  .entry-content .wp-block-image.alignwide,
  .entry-content .wp-block-image.aligncenter,
  .entry-content .wp-block-image.alignleft,
  .entry-content .wp-block-image.alignright,
  .entry-content figure.wp-block-image,
  .entry-content .wp-block-image figure,
  .entry-content .wp-block-image .alignleft,
  .entry-content .wp-block-image .alignright,
  .entry-content .wp-block-image .aligncenter,
  .entry-content .wp-block-image .alignwide,
  .entry-content .wp-block-image .alignfull,
  .contentpartPage .post-thumbnail {
    float: none !important;
    clear: both;
    display: block !important;
    width: calc(100% + 24px) !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    position: relative !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    margin-top: 12px !important;
    margin-bottom: 8px !important;
    margin-left: -12px !important;
    margin-right: -12px !important;
    overflow: visible !important;
  }

  /* Kein aspect-ratio:auto – das killt width/height-Attribute und lässt
     sizes="auto"/Lazy-Load auf contain-intrinsic-size (z.B. 3000×1500) fallen → Letterboxing.
     object-fit nicht mit !important überschreiben: Gutenberg setzt oft cover + aspect-ratio
     inline (sonst initial=fill → Verzerrung von Hochformat in 16:9). */
  .entry-content .wp-block-image a,
  .entry-content .wp-block-image img,
  .entry-content .wp-block-image figure img,
  .entry-content figure.wp-block-image img,
  .contentpartPage .post-thumbnail img,
  .entry-content .wp-block-media-text__media img {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
  }

  .entry-content .wp-block-image a {
    line-height: 0 !important;
    height: auto !important;
  }

  /* Innere figure nicht noch einmal aus dem Kasten schieben */
  .entry-content .wp-block-image figure,
  .entry-content .wp-block-image .alignleft,
  .entry-content .wp-block-image .alignright,
  .entry-content .wp-block-image .aligncenter,
  .entry-content .wp-block-image .alignwide,
  .entry-content .wp-block-image .alignfull {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Bildunterschrift: volle Textbreite, nicht 1–3 Zeichen pro Zeile */
  .entry-content .wp-block-image figcaption,
  .entry-content figure.wp-block-image figcaption,
  .entry-content figcaption {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    margin: 8px 0 0 0 !important;
    padding: 0 12px;
    float: none !important;
    white-space: normal !important;
    hyphens: none;
    -webkit-hyphens: none;
    word-break: normal;
    overflow-wrap: break-word;
    font-size: 14px !important;
    line-height: 1.45 !important;
  }

  /* Bilder in Spalten: im Spaltenkasten, aber nicht zuschneiden */
  .entry-content .wp-block-columns .wp-block-image,
  .entry-content .wp-block-column .wp-block-image,
  .entry-content .wp-block-columns figure.wp-block-image,
  .entry-content .wp-block-column .wp-block-image figure,
  .entry-content .wp-block-column .wp-block-image .alignleft,
  .entry-content .wp-block-column .wp-block-image .alignright,
  .entry-content .wp-block-column .wp-block-image .aligncenter {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    left: auto !important;
    transform: none !important;
    overflow: visible !important;
    z-index: auto;
    position: static !important;
    float: none !important;
    height: auto !important;
  }

  .entry-content .wp-block-columns .wp-block-image img,
  .entry-content .wp-block-column .wp-block-image img,
  .entry-content .wp-block-column .wp-block-image figure img {
    width: 100% !important;
    height: auto !important;
  }

  .entry-content .wp-block-columns .wp-block-image figcaption,
  .entry-content .wp-block-column .wp-block-image figcaption {
    padding-left: 0;
    padding-right: 0;
  }

  /* Gestapelte Spalten: Bild darf Text der vorherigen Spalte nicht überdecken */
  .entry-content .wp-block-columns {
    align-items: flex-start;
  }

  .entry-content .wp-block-column {
    overflow: hidden;
    position: relative;
    z-index: auto;
  }

  .entry-content .wp-block-media-text__media {
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Galerie: ein Bild ~75% Displaybreite, Hochformat 3:4, zugeschnitten */
  .entry-content .wp-block-gallery,
  .entry-content .wp-block-gallery.alignfull,
  .entry-content .wp-block-gallery.alignwide,
  .blocks-gallery-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    left: auto !important;
    transform: none !important;
    height: auto !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    gap: 12px !important;
  }

  .entry-content .wp-block-gallery .wp-block-image,
  .entry-content .wp-block-gallery figure.wp-block-image,
  .entry-content .wp-block-gallery .blocks-gallery-item,
  .blocks-gallery-grid .blocks-gallery-item {
    flex: 0 0 75% !important;
    width: 75% !important;
    min-width: 75% !important;
    max-width: 75% !important;
    height: auto !important;
    margin: 0 !important;
    left: auto !important;
    transform: none !important;
    overflow: hidden !important;
  }

  .entry-content .wp-block-gallery .wp-block-image figure,
  .entry-content .wp-block-gallery .blocks-gallery-item figure,
  .entry-content .wp-block-gallery .wp-block-image a {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
  }

  .entry-content .wp-block-gallery .wp-block-image img,
  .entry-content .wp-block-gallery .blocks-gallery-item img,
  .entry-content .wp-block-gallery img,
  .blocks-gallery-grid img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 3 / 4 !important;
    object-fit: cover !important;
    object-position: center center !important;
    max-height: none !important;
    margin: 0 !important;
  }

  .entry-content .wp-block-gallery figcaption {
    padding: 8px 4px 0;
    width: 100% !important;
    max-width: 100% !important;
  }

  .pk-gallery-carousel,
  .entry-content .pk-gallery-carousel {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .pk-gallery-carousel__slide {
    flex: 0 0 75% !important;
    width: 75% !important;
    max-width: 75% !important;
    min-width: 0 !important;
  }

  /* YouTube / Embeds: volle Textbreite (wie zuvor), korrektes 16:9 */
  .entry-content .wp-block-embed,
  .entry-content .wp-block-embed-youtube,
  .entry-content .wp-block-embed.alignwide,
  .entry-content .wp-block-embed.alignfull,
  .entry-content figure.wp-block-embed,
  .entry-content figure.wp-block-embed-youtube {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
  }

  .entry-content .wp-block-embed .wp-block-embed__wrapper,
  .entry-content .wp-block-embed-youtube .wp-block-embed__wrapper {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    padding: 0 !important;
    aspect-ratio: 16 / 9 !important;
    overflow: hidden !important;
  }

  .entry-content .wp-block-embed .wp-block-embed__wrapper::before,
  .entry-content .wp-block-embed-youtube .wp-block-embed__wrapper::before {
    content: none !important;
    display: none !important;
    padding: 0 !important;
  }

  .entry-content .wp-block-embed iframe,
  .entry-content .wp-block-embed-youtube iframe,
  .entry-content .wp-block-embed .wp-block-embed__wrapper iframe {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    border: 0 !important;
  }

  .pk-gallery-carousel .wp-block-image,
  .pk-gallery-carousel figure {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  .pk-gallery-carousel__media,
  .pk-gallery-carousel__media-link {
    overflow: hidden !important;
    aspect-ratio: 3 / 4 !important;
    width: 100% !important;
  }

  .contentpartPage .entry-content .pk-gallery-carousel__image,
  .contentpartHome .entry-content .pk-gallery-carousel__image,
  .pk-gallery-carousel__image,
  .pk-gallery-carousel img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center center !important;
    margin: 0 !important;
  }

  /* Media & Text: untereinander, ohne Überlappung */
  .entry-content .wp-block-media-text {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .entry-content .wp-block-media-text .wp-block-media-text__media,
  .entry-content .wp-block-media-text .wp-block-media-text__content {
    width: 100% !important;
    max-width: 100% !important;
    grid-column: auto !important;
    padding: 0 !important;
  }

  .entry-content .wp-block-cover {
    overflow: hidden;
  }

  .wp-block-group.has-background {
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .home .entry-content > .wp-block-cover.alignfull:first-of-type .wp-block-cover__inner-container {
    padding: 0.75rem 12px;
  }

  .contentpart3boxen .contentpartwrapper,
  .contentparticonboxen .contentpartwrapper {
    padding: 12px 0;
  }

  .featuredBox,
  .featuredBoxOn {
    padding: 12px 0 !important;
    margin: 0 0 12px 0 !important;
  }

  .contentpart .sectionHLsub h2 {
    font-size: 20px;
    line-height: 1.3;
    margin: 10px 0 0 0;
  }

  .contentparticonboxen .sectionHL h2,
  .contentpartLogos h2 {
    font-size: 20px;
    line-height: 1.3;
    margin: 0 0 12px 0;
  }

  .contentpart3boxen .sectionHL h2 {
    font-size: 24px;
    line-height: 1.25;
    margin: 12px 0;
  }

  .mainHL {
    font-size: 24px;
    line-height: 1.25;
    margin: 12px 0 10px 0;
  }

  .teasertext {
    font-size: 15px;
    line-height: 1.45;
    margin: 24px 0 12px 0;
  }

  .contentpart3boxen .featuredBox .boxHL {
    font-size: 18px;
    line-height: 1.3;
    margin: 8px 0;
  }

  .pk-blog-carousel {
    margin: 1.25rem 0;
  }

  body.single-post .contentpartPage .post-thumbnail {
    margin: 12px -12px !important;
  }

  /* Shop: Produktkarten nicht abschneiden, Abstand zum Displayrand */
  body.woocommerce .contentpartCenter,
  body.woocommerce-page .contentpartCenter,
  body.shop-main-page .contentpartCenter,
  body.post-type-archive-product .contentpartCenter,
  body.tax-product_cat .contentpartCenter,
  body.tax-product_tag .contentpartCenter {
    width: 100%;
    max-width: 100%;
    padding-left: 16px;
    padding-right: 16px;
    box-sizing: border-box;
    overflow: visible;
  }

  body.shop-main-page .woocommerce ul.products,
  body.shop-main-page .woocommerce ul.products.columns-4,
  body.woocommerce-shop .woocommerce ul.products,
  body.woocommerce-page .woocommerce ul.products,
  body.post-type-archive-product .woocommerce ul.products,
  body.tax-product_cat .woocommerce ul.products,
  body.tax-product_tag .woocommerce ul.products,
  .contentpartInner ul.products.columns-4,
  div.contentpartCenter div.contentpartInner ul.products.columns-4 {
    margin: 1.25rem 0 0 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  body.shop-main-page .woocommerce .shop-category-heading,
  body.woocommerce-shop .woocommerce .shop-category-heading,
  .woocommerce .shop-category-heading {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
  }

  .woocommerce ul.products li.product,
  .woocommerce-page ul.products li.product {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box;
  }
}
