.page {
  display: block;
  min-height: 0;
  margin-left: $typo3-gutter-default * -1;
  margin-right: $typo3-gutter-default * -1;
  margin-bottom: spacing($page-padding-bottom);

  @include breakpoint("medium") {
    margin-left: $typo3-gutter-medium * -1;
    margin-right: $typo3-gutter-medium * -1;
  }

  //full width
  .layout16 & {
    //subtract the default top padding
    margin-top: spacing($page-padding-top, $subtract: $typo3-padding-top-default);

    //subtract the height of the breadcrumb
    @include breakpoint("medium") {
      margin-top: spacing($page-padding-top, $subtract: $typo3-breadcrumb-height);
    }

    //constrain content and padding within the page max width
    @media (min-width: $typo3-page-container-max-width) {
      margin-left: 0;
      margin-right: 0;
    }

    //pop paddings over sides of page max width
    @media (min-width: $typo3-page-max-width-including-delphinus-padding) {
      margin-left: spacing("side", $times: -1);
      margin-right: spacing("side", $times: -1);
    }
  }

  //left-menu
  .layout15 & {
    //substract default top padding and space taken up by hidden left menu
    margin-top: spacing($page-padding-top, $subtract: "#{$typo3-padding-top-default} + #{$typo3-left-menu-hidden-height} + #{$typo3-left-menu-margin-bottom}");

    //align top with rest of content, when left menu is shown
    @include breakpoint("medium") {
      margin-top: 0;
    }

    //constrain content and padding within the page max width
    @media (min-width: $typo3-page-container-max-width) {
      margin-right: 0;
    }

    //pop paddings over right side of page max width
    @media (min-width: $typo3-page-max-width-including-delphinus-padding) {
      margin-right: spacing("side", $times: -1);
    }
  }

  //right column
  .layout17 & {
    margin-top: spacing($page-padding-top, $subtract: $typo3-padding-top-default);

    //align top with rest of content, when column is shown
    @include breakpoint("medium") {
      margin-top: 0;
    }

    //constrain content and padding within the page max width
    @media (min-width: $typo3-page-container-max-width) {
      margin-left: 0;
    }

    //pop paddings over right side of page max width
    @media (min-width: $typo3-page-max-width-including-delphinus-padding) {
      margin-left: spacing("side", $times: -1);
    }
  }

  //left menu and right column
  .layout14 & {
    //substract default top padding and space taken up by hidden left menu
    margin-top: spacing($page-padding-top, $subtract: "#{$typo3-padding-top-default} + #{$typo3-left-menu-hidden-height} + #{$typo3-left-menu-margin-bottom}");

    //align top with rest of content, when left menu is shown
    @include breakpoint("medium") {
      margin-top: 0;
    }

    //because space is limited in layout 14 we're setting things to use the side padding from typo3 in stead of Delphinus
    @include breakpoint("wide") {
      --spacing-side: #{$typo3-gutter-medium};
    }
  }

  &__content {
    padding-top: 0;
    padding-bottom: 0;
    min-height: 0;

    //overwrite the delphiunus way of constraining page width
    @include breakpoint("max-width") {
      padding-left: 0;
      padding-right: 0;
    }
  }
}


//FRAMED SITES
@at-root {
  body.universe,
  body.omnibus,
  body.aarhus-bss {
    .typo3-delphinus {
      .page {
        //in narrow viewports the framed sites have both a default gutter on the .main wrapper and a 1rem gutter on the out .row wrapper
        margin-left: ($typo3-gutter-default + $typo3-gutter-framed-sites-mobile) * -1 ;
        margin-right: ($typo3-gutter-default + $typo3-gutter-framed-sites-mobile) * -1;

        //in wieder viewport the outer .row wrapper has the same gutter as the .main wrapper
        @include breakpoint("medium") {
          margin-left: $typo3-gutter-medium * -2;
          margin-right: $typo3-gutter-medium * -2;
        }
      }
    }

    //full width
    &.layout16 .typo3-delphinus .page {
      @media (min-width: $typo3-page-container-max-width) {
        margin-left: $typo3-gutter-medium * -1;
        margin-right: $typo3-gutter-medium * -1;
      }
    }

    //left-menu
    &.layout15 .typo3-delphinus .page {
      @include breakpoint("medium") {
        margin-left: $typo3-gutter-medium * -1;
      }

      @media (min-width: $typo3-page-container-max-width) {
        margin-right: $typo3-gutter-medium * -1;
      }
    }

    //right-column
    &.layout17 .typo3-delphinus .page {
      @include breakpoint("medium") {
        margin-right: $typo3-gutter-medium * -1;
      }

      @media (min-width: $typo3-page-container-max-width) {
        margin-left: $typo3-gutter-medium * -1;
      }
    }

    //left menu and right column
    &.layout14 .typo3-delphinus .page {
      @include breakpoint("medium") {
        margin-left: $typo3-gutter-medium * -1;
      }
    }
  }
}
