@import "../base";

////
/// @group objects/layout
////

// Example usage with Breadcrumbs, phase banners, back links:
// <div class="moaland-width-container">
//   <!-- Breadcrumbs, phase banners, back links are placed in here. -->
//   <div class="moaland-main-wrapper">
//       <!-- Wrapper for the main content of your page which applies padding
//            to the top / bottom -->
//   </div>
// </div>
//
// Example usage without Breadcrumbs, phase banners, back links:
// <div class="moaland-width-container">
//   <div class="moaland-main-wrapper moaland-main-wrapper--l">
//       <!-- Wrapper for the main content of your page which applies padding
//            to the top / bottom -->
//   </div>
// </div>

/// @deprecated Replace this mixin with more direct references to the [spacing
/// mixins](https://design-system.service.gov.uk/styles/spacing/#spacing-on-custom-components).
@mixin moaland-main-wrapper {
  // In IE11 the `main` element can be used, but is not recognized  –
  // meaning it's not defined in IE's default style sheet,
  // so it uses CSS initial value, which is inline.
  display: block;
  padding-top: moaland-spacing(4);
  padding-bottom: moaland-spacing(4);

  @include moaland-media-query($from: tablet) {
    // This spacing is manually adjusted to replicate the margin of
    // moaland-heading-xl (50px) minus the spacing of back link and
    // breadcrumbs (10px)
    padding-top: moaland-spacing(7);
    padding-bottom: moaland-spacing(7);
  }
}

/// Use moaland-main-wrapper--l when you page does not have Breadcrumbs, phase
/// banners or back links.
///
/// @deprecated Replace this mixin with more direct references to the [spacing
/// mixins](https://design-system.service.gov.uk/styles/spacing/#spacing-on-custom-components).
@mixin moaland-main-wrapper--l {
  @include moaland-responsive-padding(8, "top");
}

@include moaland-exports("moaland/objects/main-wrapper") {
  .moaland-main-wrapper {
    @include moaland-main-wrapper;
  }

  // Using the `.moaland-main-wrapper--auto-spacing` modifier should apply the
  // correct spacing depending on whether there are any elements
  // (such the back link, breadcrumbs or phase banner components) before the
  // `.moaland-main-wrapper` in the `moaland-width-container`.
  //
  // If you need to control the spacing manually, use the
  // `moaland-main-wrapper--l` modifier instead.
  .moaland-main-wrapper--auto-spacing:first-child,
  .moaland-main-wrapper--l {
    @include moaland-main-wrapper--l;
  }
}
