/*
 * Long-form (modules) template
 *
 * Image + text modules split exactly at the middle of the page: the image ends
 * at the centre line and the text takes the other half (as in the mockup).
 * Below 1200px the image runs from the page edge to the centre (half the page).
 * From 1200px the modules sit in a centred column of 60% of the width + 230px
 * (about 3/4 of the width), still split at the centre.
 *
 *   screen    column      square image
 *   576-1199  full page   half the page (288-600 px)
 *   1200      79%         475 px
 *   1440      76%         547 px
 *   1920      72%         691 px
 *
 * Image-only modules run edge to edge across the page, at the same height as the others (cropped).
 * Below 576px modules stack: image on top, text below; image-only is square.
 * Large text sits ~16% of the column down, small text at the foot.
 */

.starno-modules {
  overflow-x: hidden;
}

.m-module {
  position: relative;
  color: inherit;
}

/* Let modules grow past the theme's 1200px container */
.m-module > .container-fluid {
  max-width: none;
}
.m-module .m-col {
  container-type: inline-size; /* lets image-only modules size their height from the column */
  flex: 0 0 auto;
  width: min(100%, calc(60% + 230px));
  max-width: none;
  margin-left: auto;
  margin-right: auto;
}

.m-text-dark  { color: #111; }
.m-text-light { color: #fff; }
.m-text-dark a,
.m-text-light a {
  color: inherit;
  text-decoration: underline;
}

.m-row {
  display: flex;
  flex-direction: column;
}

/* Images */
.m-media {
  margin: 0;
  position: relative;
}
.m-image_left .m-media,
.m-image_right .m-media {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  align-self: flex-start; /* stays square even when the text runs longer */
}
.m-media .m-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}
/* Image only: edge to edge across the page, same height as the other modules, cropped to fill */
.m-image_only .m-media {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  height: 100cqw; /* phones: as tall as the stacked square images */
  overflow: hidden;
}

/* Text */
.m-body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.75rem 0 2.25rem;
}
.m-title {
  font-size: clamp(1.125rem, 1.89vw, 2.475rem); /* 10% smaller than before */
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.m-text {
  font-size: clamp(0.8125rem, 0.9vw, 1.0625rem);
  line-height: 1.55;
}
.m-text p:last-child,
.m-title p:last-child {
  margin-bottom: 0;
}
.m-text img {
  max-width: 100%;
  height: auto;
}

/* Text only: centred */
.m-text_only .m-body {
  align-items: center;
  text-align: center;
  padding-top: 3rem;
  padding-bottom: 3rem;
}
/* Text only: large text at 162.5% of the other modules' large text (130% x 125%) */
.m-text_only .m-title {
  font-size: clamp(1.828rem, 3.071vw, 4.022rem);
}
/* Text only without small text: large text centred vertically */
.m-text_only.m-no-small .m-body {
  justify-content: center;
}

/* Side by side from 576px up */
@media (min-width: 576px) {
  .m-image_left .m-row,
  .m-image_right .m-row {
    flex-direction: row;
  }
  .m-image_left .m-media,
  .m-image_right .m-media {
    flex: 0 0 50%;
    max-width: 50%;
  }
  .m-image_left .m-body,
  .m-image_right .m-body {
    flex: 0 0 50%;
    max-width: 50%;
    min-width: 0;
    /* % padding is relative to the full content column, like the mockup */
    padding: 16% 2% 7%;
  }
  .m-image_right .m-media {
    order: 2;
  }
  .m-image_right .m-body {
    text-align: right;
  }

  /* Text-only and image-only modules are as tall as the square images (half the column) */
  .m-image_only .m-media {
    height: 50cqw; /* half the column = the square image height */
  }
  .m-text_only .m-row {
    aspect-ratio: 2 / 1;
  }
  .m-text_only .m-body {
    flex: 1 1 auto;
    padding: 11% 2% 7%; /* large text a little below the top (between the original 16% and 7%) */
  }
  .m-text_only.m-no-small .m-body {
    padding-top: 7%;
    padding-bottom: 7%;
  }
  .m-text_only .m-title,
  .m-text_only .m-text {
    max-width: 75%;
  }
}


/* Below the largest breakpoint (1200px), image + text modules run edge to edge:
   the image fills its half of the page from the page edge to the centre line. */
@media (max-width: 1199.98px) {
  .m-module > .container-fluid {
    padding-left: 0;
    padding-right: 0;
  }
  .m-module > .container-fluid > .row {
    margin-left: 0;
    margin-right: 0;
  }
  .m-module .m-col {
    width: 100%;
    padding-left: 0;
    padding-right: 0;
  }
  /* keep text off the page edge on phones */
  .m-body {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}
@media (min-width: 576px) and (max-width: 1199.98px) {
  .m-image_left .m-body {
    padding-right: 5%;
  }
  .m-image_right .m-body {
    padding-left: 5%;
  }
  .m-text_only .m-body {
    padding-left: 5%;
    padding-right: 5%;
  }
}

/* Phones: image modules stack (image on top, text below).
   More space under the text before the next image, and any module colour
   becomes white so the stack reads as one column. Text-only modules keep their colour. */
@media (max-width: 575.98px) {
  .m-image_left .m-body,
  .m-image_right .m-body {
    padding-bottom: 6rem;
  }
  .m-module.has-bg:not(.m-text_only) {
    background-color: #fff !important;
    color: #111;
  }
  /* Text-only modules: at least as tall as the full-width square images */
  .m-text_only .m-row {
    min-height: 100cqw;
  }
  .m-text_only .m-body {
    flex: 1 1 auto;
    padding-top: 4.5rem;
    padding-bottom: 4.5rem;
  }
}

/* Night mode: module colours darken 60% (computed in module.php) and the type reverses */
.night .m-module.has-bg {
  background-color: var(--m-bg-night) !important;
}
.night .m-module.m-night-light { color: #fff; }
.night .m-module.m-night-dark  { color: #111; }

/* Night mode: white modules behave like modules with no colour (follow the page),
   and on phones image modules go dark instead of white. Other colours stay as set. */
.night .m-module.m-bg-white {
  background-color: transparent !important;
  color: inherit;
}
@media (max-width: 575.98px) {
  .night .m-module.has-bg:not(.m-text_only) {
    background-color: transparent !important;
    color: inherit;
  }
}

/* Editor helpers */
.m-empty-notice,
.m-edit-link {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

/*
 * Text-only module with small text: the large text sits in the middle of the module
 * (a little above the true middle, so it looks centred) and the small text at the bottom.
 */
.m-text_only:not(.m-no-small) .m-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 0.8fr auto 1.2fr;
  justify-items: center;
  row-gap: 0;
}
.m-text_only:not(.m-no-small) .m-title {
  grid-row: 2;
}
.m-text_only:not(.m-no-small) .m-text {
  grid-row: 3;
  align-self: end;
  padding-top: 2rem;
}
@media (min-width: 576px) {
  .m-text_only:not(.m-no-small) .m-body {
    padding-top: 7%;
  }
}

/*
 * Half image, half text modules: the small text takes 75% of the text side, so its lines
 * don't run too long. It stays on the text's own side (left, or right next to a right image).
 */
@media (min-width: 576px) {
  .m-image_left .m-text,
  .m-image_right .m-text {
    max-width: 75%;
  }
  .m-image_right .m-text {
    margin-left: auto;
  }
}

/*
 * Wide screens (1200px and up): no jump at 1200px. The module keeps the size it had at 1199px
 * (full width, same text margins) and the extra width shows the background colour at the sides.
 * It only grows again once the usual width (60% of the page + 230px) is larger than 1199px.
 */
@media (min-width: 1200px) {
  .m-module > .container-fluid {
    padding-left: 0;
    padding-right: 0;
  }
  .m-module > .container-fluid > .row {
    margin-left: 0;
    margin-right: 0;
  }
  .m-module .m-col {
    width: min(100%, max(1199px, 60% + 230px));
    padding-left: 0;
    padding-right: 0;
  }
  .m-image_left .m-body {
    padding-right: 5%;
  }
  .m-image_right .m-body {
    padding-left: 5%;
  }
  .m-text_only .m-body {
    padding-left: 5%;
    padding-right: 5%;
  }
}
