/**
 * Zarovnanie obrázkov v obsahu (front + CKEditor).
 * three-row / two-row: float + % šírka na <img> alebo na <p> (1 obrázok/odstavec).
 * Oddelovač riadku: clear na začiatku nového riadku + ::after na konci bloku.
 */

.vnutro,
.we_news_item,
.cke_editable {
  display: flow-root;
}

img.vlavo {
  float: left;
  margin: 5px 15px;
  margin-left: 0;
  width: 35% !important;
  max-width: 35%;
  height: auto !important;
}

img.vpravo {
  float: right;
  margin: 5px 15px;
  margin-right: 0;
  position: relative;
  z-index: 5;
}

img.fullwidth {
  float: none;
  display: block;
  clear: both;
  width: 100% !important;
  max-width: 100%;
  height: auto !important;
}

/* --- three-row / two-row: viac obrázkov v jednom <p> --- */

.vnutro p:has(> img.three-row):not(:has(> img.three-row:only-child)),
.we_news_item p:has(> img.three-row):not(:has(> img.three-row:only-child)),
.cke_editable p:has(> img.three-row):not(:has(> img.three-row:only-child)) {
  display: flow-root;
  width: 100%;
  margin: 0 0 15px;
}

.vnutro p:has(> img.two-row):not(:has(> img.two-row:only-child)),
.we_news_item p:has(> img.two-row):not(:has(> img.two-row:only-child)),
.cke_editable p:has(> img.two-row):not(:has(> img.two-row:only-child)) {
  display: flow-root;
  width: 100%;
  margin: 0 0 15px;
}

img.three-row {
  float: left;
  width: 33.333% !important;
  max-width: 33.333%;
  height: auto !important;
  box-sizing: border-box;
  padding-right: 15px;
  margin: 0 0 15px;
}

img.two-row {
  float: left;
  width: 50% !important;
  max-width: 50%;
  height: auto !important;
  box-sizing: border-box;
  padding-right: 15px;
  margin: 0 0 15px;
}

/* Začiatok nového riadku */
.vnutro img.three-row:nth-child(3n + 1 of img.three-row),
.we_news_item img.three-row:nth-child(3n + 1 of img.three-row),
.cke_editable img.three-row:nth-child(3n + 1 of img.three-row) {
  clear: left;
}

.vnutro img.two-row:nth-child(2n + 1 of img.two-row),
.we_news_item img.two-row:nth-child(2n + 1 of img.two-row),
.cke_editable img.two-row:nth-child(2n + 1 of img.two-row) {
  clear: left;
}

/* Oddelovač: po poslednom obrázku v riadku (3 / 2 / 1 v riadku) → ďalší obrázok pod riadok */
.vnutro img.three-row:is(:nth-child(3n of img.three-row), :nth-last-child(1 of img.three-row)) + img.three-row,
.we_news_item img.three-row:is(:nth-child(3n of img.three-row), :nth-last-child(1 of img.three-row)) + img.three-row,
.cke_editable img.three-row:is(:nth-child(3n of img.three-row), :nth-last-child(1 of img.three-row)) + img.three-row {
  clear: left;
}

.vnutro img.two-row:is(:nth-child(2n of img.two-row), :nth-last-child(1 of img.two-row)) + img.two-row,
.we_news_item img.two-row:is(:nth-child(2n of img.two-row), :nth-last-child(1 of img.two-row)) + img.two-row,
.cke_editable img.two-row:is(:nth-child(2n of img.two-row), :nth-last-child(1 of img.two-row)) + img.two-row {
  clear: left;
}

.vnutro p:has(> img.three-row)::after,
.we_news_item p:has(> img.three-row)::after,
.vnutro p:has(> img.two-row)::after,
.we_news_item p:has(> img.two-row)::after,
.cke_editable p:has(> img.three-row)::after,
.cke_editable p:has(> img.two-row)::after {
  content: "";
  display: block;
  clear: both;
  height: 0;
}

/* --- CKEditor: jeden obrázok v <p> – float na odstavci --- */

.vnutro p:has(> img.three-row:only-child),
.we_news_item p:has(> img.three-row:only-child),
.cke_editable p:has(> img.three-row:only-child) {
  float: left;
  width: 33.333%;
  box-sizing: border-box;
  padding-right: 15px;
  margin: 0 0 15px;
}

.vnutro p:has(> img.two-row:only-child),
.we_news_item p:has(> img.two-row:only-child),
.cke_editable p:has(> img.two-row:only-child) {
  float: left;
  width: 50%;
  box-sizing: border-box;
  padding-right: 15px;
  margin: 0 0 15px;
}

.vnutro p:has(> img.three-row:only-child) img.three-row,
.we_news_item p:has(> img.three-row:only-child) img.three-row,
.cke_editable p:has(> img.three-row:only-child) img.three-row,
.vnutro p:has(> img.two-row:only-child) img.two-row,
.we_news_item p:has(> img.two-row:only-child) img.two-row,
.cke_editable p:has(> img.two-row:only-child) img.two-row {
  float: none;
  width: 100% !important;
  max-width: 100%;
  padding-right: 0;
  margin: 0;
  clear: none;
}

.vnutro p:has(> img.three-row:only-child):nth-child(3n + 1 of p:has(> img.three-row:only-child)),
.we_news_item p:has(> img.three-row:only-child):nth-child(3n + 1 of p:has(> img.three-row:only-child)),
.cke_editable p:has(> img.three-row:only-child):nth-child(3n + 1 of p:has(> img.three-row:only-child)) {
  clear: left;
}

.vnutro p:has(> img.two-row:only-child):nth-child(2n + 1 of p:has(> img.two-row:only-child)),
.we_news_item p:has(> img.two-row:only-child):nth-child(2n + 1 of p:has(> img.two-row:only-child)),
.cke_editable p:has(> img.two-row:only-child):nth-child(2n + 1 of p:has(> img.two-row:only-child)) {
  clear: left;
}

.vnutro p:has(> img.three-row:only-child):is(
    :nth-child(3n of p:has(> img.three-row:only-child)),
    :nth-last-child(1 of p:has(> img.three-row:only-child))
  )
  + p:has(> img.three-row:only-child),
.we_news_item p:has(> img.three-row:only-child):is(
    :nth-child(3n of p:has(> img.three-row:only-child)),
    :nth-last-child(1 of p:has(> img.three-row:only-child))
  )
  + p:has(> img.three-row:only-child),
.cke_editable p:has(> img.three-row:only-child):is(
    :nth-child(3n of p:has(> img.three-row:only-child)),
    :nth-last-child(1 of p:has(> img.three-row:only-child))
  )
  + p:has(> img.three-row:only-child) {
  clear: left;
}

.vnutro p:has(> img.two-row:only-child):is(
    :nth-child(2n of p:has(> img.two-row:only-child)),
    :nth-last-child(1 of p:has(> img.two-row:only-child))
  )
  + p:has(> img.two-row:only-child),
.we_news_item p:has(> img.two-row:only-child):is(
    :nth-child(2n of p:has(> img.two-row:only-child)),
    :nth-last-child(1 of p:has(> img.two-row:only-child))
  )
  + p:has(> img.two-row:only-child),
.cke_editable p:has(> img.two-row:only-child):is(
    :nth-child(2n of p:has(> img.two-row:only-child)),
    :nth-last-child(1 of p:has(> img.two-row:only-child))
  )
  + p:has(> img.two-row:only-child) {
  clear: left;
}

.vnutro p:has(> img.three-row:only-child):last-child::after,
.we_news_item p:has(> img.three-row:only-child):last-child::after,
.vnutro p:has(> img.two-row:only-child):last-child::after,
.we_news_item p:has(> img.two-row:only-child):last-child::after,
.cke_editable p:has(> img.three-row:only-child):last-child::after,
.cke_editable p:has(> img.two-row:only-child):last-child::after {
  content: "";
  display: block;
  clear: both;
  height: 0;
}

/* Text / hr pod floatmi */
.vnutro p:not(:has(> img.three-row)):not(:has(> img.two-row)),
.we_news_item p:not(:has(> img.three-row)):not(:has(> img.two-row)),
.cke_editable p:not(:has(> img.three-row)):not(:has(> img.two-row)),
.vnutro hr,
.we_news_item hr {
  clear: both;
}

.cke_editable::after {
  content: "";
  display: block;
  clear: both;
}

@media screen and (max-width: 768px) {
  img.vlavo {
    width: 50% !important;
    max-width: 50%;
  }
  img.vpravo {
    width: 50% !important;
    max-width: 50%;
  }

  /* three-row: 2 v riadku */
  img.three-row {
    width: 50% !important;
    max-width: 50%;
  }
  .vnutro p:has(> img.three-row:only-child),
  .we_news_item p:has(> img.three-row:only-child),
  .cke_editable p:has(> img.three-row:only-child) {
    width: 50%;
  }
  .vnutro img.three-row:nth-child(3n + 1 of img.three-row),
  .we_news_item img.three-row:nth-child(3n + 1 of img.three-row),
  .cke_editable img.three-row:nth-child(3n + 1 of img.three-row) {
    clear: none;
  }
  .vnutro img.three-row:nth-child(2n + 1 of img.three-row),
  .we_news_item img.three-row:nth-child(2n + 1 of img.three-row),
  .cke_editable img.three-row:nth-child(2n + 1 of img.three-row) {
    clear: left;
  }
  .vnutro img.three-row:is(:nth-child(3n of img.three-row), :nth-last-child(1 of img.three-row)) + img.three-row,
  .we_news_item img.three-row:is(:nth-child(3n of img.three-row), :nth-last-child(1 of img.three-row)) + img.three-row,
  .cke_editable img.three-row:is(:nth-child(3n of img.three-row), :nth-last-child(1 of img.three-row)) + img.three-row {
    clear: none;
  }
  .vnutro img.three-row:is(:nth-child(2n of img.three-row), :nth-last-child(1 of img.three-row)) + img.three-row,
  .we_news_item img.three-row:is(:nth-child(2n of img.three-row), :nth-last-child(1 of img.three-row)) + img.three-row,
  .cke_editable img.three-row:is(:nth-child(2n of img.three-row), :nth-last-child(1 of img.three-row)) + img.three-row {
    clear: left;
  }
  .vnutro p:has(> img.three-row:only-child):nth-child(3n + 1 of p:has(> img.three-row:only-child)),
  .we_news_item p:has(> img.three-row:only-child):nth-child(3n + 1 of p:has(> img.three-row:only-child)),
  .cke_editable p:has(> img.three-row:only-child):nth-child(3n + 1 of p:has(> img.three-row:only-child)) {
    clear: none;
  }
  .vnutro p:has(> img.three-row:only-child):nth-child(2n + 1 of p:has(> img.three-row:only-child)),
  .we_news_item p:has(> img.three-row:only-child):nth-child(2n + 1 of p:has(> img.three-row:only-child)),
  .cke_editable p:has(> img.three-row:only-child):nth-child(2n + 1 of p:has(> img.three-row:only-child)) {
    clear: left;
  }
  .vnutro p:has(> img.three-row:only-child):is(
      :nth-child(3n of p:has(> img.three-row:only-child)),
      :nth-last-child(1 of p:has(> img.three-row:only-child))
    )
    + p:has(> img.three-row:only-child),
  .we_news_item p:has(> img.three-row:only-child):is(
      :nth-child(3n of p:has(> img.three-row:only-child)),
      :nth-last-child(1 of p:has(> img.three-row:only-child))
    )
    + p:has(> img.three-row:only-child),
  .cke_editable p:has(> img.three-row:only-child):is(
      :nth-child(3n of p:has(> img.three-row:only-child)),
      :nth-last-child(1 of p:has(> img.three-row:only-child))
    )
    + p:has(> img.three-row:only-child) {
    clear: none;
  }
  .vnutro p:has(> img.three-row:only-child):is(
      :nth-child(2n of p:has(> img.three-row:only-child)),
      :nth-last-child(1 of p:has(> img.three-row:only-child))
    )
    + p:has(> img.three-row:only-child),
  .we_news_item p:has(> img.three-row:only-child):is(
      :nth-child(2n of p:has(> img.three-row:only-child)),
      :nth-last-child(1 of p:has(> img.three-row:only-child))
    )
    + p:has(> img.three-row:only-child),
  .cke_editable p:has(> img.three-row:only-child):is(
      :nth-child(2n of p:has(> img.three-row:only-child)),
      :nth-last-child(1 of p:has(> img.three-row:only-child))
    )
    + p:has(> img.three-row:only-child) {
    clear: left;
  }

  /* two-row: 2 v riadku (50 % ako na desktope) */
  img.two-row {
    width: 50% !important;
    max-width: 50%;
  }
  .vnutro p:has(> img.two-row:only-child),
  .we_news_item p:has(> img.two-row:only-child),
  .cke_editable p:has(> img.two-row:only-child) {
    width: 50%;
  }
  .vnutro img.two-row:nth-child(2n + 1 of img.two-row),
  .we_news_item img.two-row:nth-child(2n + 1 of img.two-row),
  .cke_editable img.two-row:nth-child(2n + 1 of img.two-row) {
    clear: left;
  }
  .vnutro img.two-row:is(:nth-child(2n of img.two-row), :nth-last-child(1 of img.two-row)) + img.two-row,
  .we_news_item img.two-row:is(:nth-child(2n of img.two-row), :nth-last-child(1 of img.two-row)) + img.two-row,
  .cke_editable img.two-row:is(:nth-child(2n of img.two-row), :nth-last-child(1 of img.two-row)) + img.two-row {
    clear: left;
  }
  .vnutro p:has(> img.two-row:only-child):nth-child(2n + 1 of p:has(> img.two-row:only-child)),
  .we_news_item p:has(> img.two-row:only-child):nth-child(2n + 1 of p:has(> img.two-row:only-child)),
  .cke_editable p:has(> img.two-row:only-child):nth-child(2n + 1 of p:has(> img.two-row:only-child)) {
    clear: left;
  }
  .vnutro p:has(> img.two-row:only-child):is(
      :nth-child(2n of p:has(> img.two-row:only-child)),
      :nth-last-child(1 of p:has(> img.two-row:only-child))
    )
    + p:has(> img.two-row:only-child),
  .we_news_item p:has(> img.two-row:only-child):is(
      :nth-child(2n of p:has(> img.two-row:only-child)),
      :nth-last-child(1 of p:has(> img.two-row:only-child))
    )
    + p:has(> img.two-row:only-child),
  .cke_editable p:has(> img.two-row:only-child):is(
      :nth-child(2n of p:has(> img.two-row:only-child)),
      :nth-last-child(1 of p:has(> img.two-row:only-child))
    )
    + p:has(> img.two-row:only-child) {
    clear: left;
  }
}

@media screen and (max-width: 480px) {
  img.vlavo,
  img.vpravo {
    float: none;
    margin: 15px 0;
    width: 100% !important;
    max-width: 100%;
  }
  img.three-row,
  img.two-row {
    float: none;
    clear: both !important;
    width: 100% !important;
    max-width: 100%;
    padding-right: 0;
    margin: 0 0 15px;
  }
  .vnutro p:has(> img.three-row:only-child),
  .we_news_item p:has(> img.three-row:only-child),
  .cke_editable p:has(> img.three-row:only-child),
  .vnutro p:has(> img.two-row:only-child),
  .we_news_item p:has(> img.two-row:only-child),
  .cke_editable p:has(> img.two-row:only-child) {
    float: none;
    width: 100%;
    padding-right: 0;
    clear: both !important;
  }
}

/* CKEditor – náhľad ako desktop (% na img) */
@media screen {
  body.cke_editable img.three-row,
  .cke_editable img.three-row {
    float: left !important;
    width: 33.333% !important;
    max-width: 33.333% !important;
    height: auto !important;
    padding-right: 15px !important;
    margin: 0 0 15px !important;
  }

  body.cke_editable img.two-row,
  .cke_editable img.two-row {
    float: left !important;
    width: 50% !important;
    max-width: 50% !important;
    height: auto !important;
    padding-right: 15px !important;
    margin: 0 0 15px !important;
  }

  body.cke_editable img.vlavo,
  .cke_editable img.vlavo {
    float: left !important;
    width: 35% !important;
    max-width: 35% !important;
  }

  body.cke_editable img.fullwidth,
  .cke_editable img.fullwidth {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  body.cke_editable p:has(> img.three-row:only-child),
  .cke_editable p:has(> img.three-row:only-child) {
    width: 33.333% !important;
  }

  body.cke_editable p:has(> img.two-row:only-child),
  .cke_editable p:has(> img.two-row:only-child) {
    width: 50% !important;
    float: left !important;
    box-sizing: border-box;
    padding-right: 15px !important;
    margin: 0 0 15px !important;
  }

  body.cke_editable p:has(> img.three-row:only-child),
  .cke_editable p:has(> img.three-row:only-child) {
    float: left !important;
    box-sizing: border-box;
    padding-right: 15px !important;
    margin: 0 0 15px !important;
  }

  body.cke_editable p:has(> img.three-row:only-child) img.three-row,
  .cke_editable p:has(> img.three-row:only-child) img.three-row,
  body.cke_editable p:has(> img.two-row:only-child) img.two-row,
  .cke_editable p:has(> img.two-row:only-child) img.two-row {
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-right: 0 !important;
    margin: 0 !important;
  }

  body.cke_editable img.three-row:nth-child(3n + 1 of img.three-row),
  .cke_editable img.three-row:nth-child(3n + 1 of img.three-row) {
    clear: left !important;
  }

  body.cke_editable img.three-row:is(:nth-child(3n of img.three-row), :nth-last-child(1 of img.three-row)) + img.three-row,
  .cke_editable img.three-row:is(:nth-child(3n of img.three-row), :nth-last-child(1 of img.three-row)) + img.three-row {
    clear: left !important;
  }

  body.cke_editable img.two-row:nth-child(2n + 1 of img.two-row),
  .cke_editable img.two-row:nth-child(2n + 1 of img.two-row) {
    clear: left !important;
  }

  body.cke_editable img.two-row:is(:nth-child(2n of img.two-row), :nth-last-child(1 of img.two-row)) + img.two-row,
  .cke_editable img.two-row:is(:nth-child(2n of img.two-row), :nth-last-child(1 of img.two-row)) + img.two-row {
    clear: left !important;
  }

  body.cke_editable p:has(> img.three-row:only-child):nth-child(3n + 1 of p:has(> img.three-row:only-child)),
  .cke_editable p:has(> img.three-row:only-child):nth-child(3n + 1 of p:has(> img.three-row:only-child)) {
    clear: left !important;
  }

  body.cke_editable p:has(> img.three-row:only-child):is(
      :nth-child(3n of p:has(> img.three-row:only-child)),
      :nth-last-child(1 of p:has(> img.three-row:only-child))
    )
    + p:has(> img.three-row:only-child),
  .cke_editable p:has(> img.three-row:only-child):is(
      :nth-child(3n of p:has(> img.three-row:only-child)),
      :nth-last-child(1 of p:has(> img.three-row:only-child))
    )
    + p:has(> img.three-row:only-child) {
    clear: left !important;
  }

  body.cke_editable p:has(> img.two-row:only-child):nth-child(2n + 1 of p:has(> img.two-row:only-child)),
  .cke_editable p:has(> img.two-row:only-child):nth-child(2n + 1 of p:has(> img.two-row:only-child)) {
    clear: left !important;
  }

  body.cke_editable p:has(> img.two-row:only-child):is(
      :nth-child(2n of p:has(> img.two-row:only-child)),
      :nth-last-child(1 of p:has(> img.two-row:only-child))
    )
    + p:has(> img.two-row:only-child),
  .cke_editable p:has(> img.two-row:only-child):is(
      :nth-child(2n of p:has(> img.two-row:only-child)),
      :nth-last-child(1 of p:has(> img.two-row:only-child))
    )
    + p:has(> img.two-row:only-child) {
    clear: left !important;
  }
}
