// URL.com/guidelines#layout
.pf-c-page {
  --pf-c-page--BackgroundColor: var(--pf-global--BackgroundColor--dark-100);

  // Header
  --pf-c-page__header--ZIndex: var(--pf-global--ZIndex--md);
  --pf-c-page__header--MinHeight: #{pf-size-prem(76px)}; // fixed height for header to ensure consistency across screen sizes.

  // Header brand
  --pf-c-page__header-brand--PaddingLeft: var(--pf-global--spacer--md);
  --pf-c-page__header-brand--md--PaddingRight: var(--pf-global--spacer--xl);
  --pf-c-page__header-brand--md--PaddingLeft: var(--pf-global--spacer--lg);

  @media (min-width: $pf-global--breakpoint--md) {
    --pf-c-page__header-brand--PaddingLeft: var(--pf-c-page__header-brand--md--PaddingLeft);
  }

  // Toggle
  --pf-c-page__header-sidebar-toggle__c-button--PaddingTop: var(--pf-global--spacer--sm);
  --pf-c-page__header-sidebar-toggle__c-button--PaddingRight: var(--pf-global--spacer--sm);
  --pf-c-page__header-sidebar-toggle__c-button--PaddingBottom: var(--pf-global--spacer--sm);
  --pf-c-page__header-sidebar-toggle__c-button--PaddingLeft: var(--pf-global--spacer--sm);
  --pf-c-page__header-sidebar-toggle__c-button--MarginRight: var(--pf-global--spacer--md);
  --pf-c-page__header-sidebar-toggle__c-button--MarginLeft: calc(var(--pf-c-page__header-sidebar-toggle__c-button--PaddingLeft) * -1);
  --pf-c-page__header-sidebar-toggle__c-button--md--MarginLeft: calc(var(--pf-c-page__header-sidebar-toggle__c-button--PaddingLeft) * -1); // remove in breaking change release
  --pf-c-page__header-sidebar-toggle__c-button--FontSize: var(--pf-global--FontSize--2xl);

  @media screen and (min-width: $pf-global--breakpoint--md) {
    --pf-c-page__header-sidebar-toggle__c-button--MarginLeft: var(--pf-c-page__header-sidebar-toggle__c-button--md--MarginLeft); // remove in breaking change release
  }

  // Header brand link
  --pf-c-page__header-brand-link--c-brand--MaxHeight: #{pf-size-prem(60px)};

  // Header nav
  --pf-c-page__header-nav--PaddingLeft: var(--pf-global--spacer--md);
  --pf-c-page__header-nav--md--PaddingLeft: var(--pf-global--spacer--lg);
  --pf-c-page__header-nav--lg--PaddingLeft: 0;
  --pf-c-page__header-nav--lg--MarginLeft: var(--pf-global--spacer--xl);
  --pf-c-page__header-nav--lg--MarginRight: var(--pf-global--spacer--xl);
  --pf-c-page__header-nav--BackgroundColor: var(--pf-global--BackgroundColor--dark-300);
  --pf-c-page__header-nav--lg--BackgroundColor: transparent;
  --pf-c-page__header-nav--c-nav__scroll-button--nth-of-type-1--Left: calc(-1 * (var(--pf-global--spacer--md) - var(--pf-global--spacer--xs))); // This sets the the button to the edge of its container with 4px clearance on the left
  --pf-c-page__header-nav--c-nav__scroll-button--nth-of-type-1--md--Left: calc(-1 * (var(--pf-global--spacer--md) - var(--pf-global--spacer--xs)));
  --pf-c-page__header-nav--c-nav__scroll-button--nth-of-type-1--lg--Left: 0;
  --pf-c-page__header-nav--c-nav__scroll-button--lg--BackgroundColor: var(--pf-c-page__header-nav--BackgroundColor);
  --pf-c-page__header-nav--c-nav__scroll-button--lg--Top: 0;

  @media screen and (min-width: $pf-global--breakpoint--md) {
    --pf-c-page__header-nav--PaddingLeft: var(--pf-c-page__header-nav--md--PaddingLeft);
    --pf-c-page__header-nav--c-nav__scroll-button--nth-of-type-1--Left: var(--pf-c-page__header-nav--c-nav__scroll-button--nth-of-type-1--md--Left);
  }

  @media screen and (min-width: $pf-global--breakpoint--lg) {
    --pf-c-page__header-nav--PaddingLeft: var(--pf-c-page__header-nav--lg--PaddingLeft);
    --pf-c-page__header-nav--BackgroundColor: var(--pf-c-page__header-nav--lg--BackgroundColor);
    --pf-c-page__header-nav--c-nav__scroll-button--nth-of-type-1--Left: var(--pf-c-page__header-nav--c-nav__scroll-button--nth-of-type-1--lg--Left);
  }

  // Header tools
  --pf-c-page__header-tools--MarginTop: var(--pf-global--spacer--sm);
  --pf-c-page__header-tools--MarginRight: var(--pf-global--spacer--md);
  --pf-c-page__header-tools--MarginBottom: var(--pf-global--spacer--sm);
  --pf-c-page__header-tools--md--MarginRight: var(--pf-global--spacer--lg);
  --pf-c-page__header-tools--c-avatar--MarginLeft: var(--pf-global--spacer--md);
  --pf-c-page__header-tools-group--MarginLeft: var(--pf-global--spacer--xl);

  // Header tools group button
  --pf-c-page__header-tools--c-button--m-selected--before--Width: #{pf-size-prem(36px)};
  --pf-c-page__header-tools--c-button--m-selected--before--Height: #{pf-size-prem(36px)};
  --pf-c-page__header-tools--c-button--m-selected--before--BackgroundColor: var(--pf-global--BackgroundColor--dark-200);
  --pf-c-page__header-tools--c-button--m-selected--before--BorderRadius: var(--pf-global--BorderRadius--lg);
  --pf-c-page__header-tools--c-button--m-selected--c-notification-badge--m-unread--after--BorderColor: var(--pf-global--BackgroundColor--dark-200);

  @media screen and (min-width: $pf-global--breakpoint--md) {
    --pf-c-page__header-tools--MarginRight: var(--pf-c-page__header-tools--md--MarginRight);
  }

  // Sidebar
  --pf-c-page__sidebar--ZIndex: var(--pf-global--ZIndex--sm);
  --pf-c-page__sidebar--Width: 80%;
  --pf-c-page__sidebar--md--Width: #{pf-size-prem(290px)};
  --pf-c-page__sidebar--BackgroundColor: var(--pf-global--BackgroundColor--light-100);
  --pf-c-page__sidebar--BoxShadow: var(--pf-global--BoxShadow--lg-right);
  --pf-c-page__sidebar--Transition: var(--pf-global--Transition);
  --pf-c-page__sidebar--Transform: translate3d(-100%, 0, 0);
  --pf-c-page__sidebar--m-expanded--Transform: translate3d(0, 0, 0);
  --pf-c-page__sidebar--md--Transform: translate3d(0, 0, 0);
  --pf-c-page__sidebar--m-dark--BackgroundColor: var(--pf-global--BackgroundColor--dark-300);
  --pf-c-page__sidebar-body--PaddingTop: var(--pf-global--spacer--sm);
  --pf-c-page__sidebar-body--PaddingBottom: var(--pf-global--spacer--md);

  @media screen and (min-width: $pf-global--breakpoint--md) {
    --pf-c-page__sidebar--Width: var(--pf-c-page__sidebar--md--Width); // hardcode sidebar based on design spec, must match pf-n-nav--Width
    --pf-c-page__sidebar--Transform: var(--pf-c-page__sidebar--md--Transform);
  }

  // Main section
  --pf-c-page__main-section--PaddingTop: var(--pf-global--spacer--md);
  --pf-c-page__main-section--PaddingRight: var(--pf-global--spacer--md);
  --pf-c-page__main-section--PaddingBottom: var(--pf-global--spacer--md);
  --pf-c-page__main-section--PaddingLeft: var(--pf-global--spacer--md);
  --pf-c-page__main-section--md--PaddingTop: var(--pf-global--spacer--lg);
  --pf-c-page__main-section--md--PaddingRight: var(--pf-global--spacer--lg);
  --pf-c-page__main-section--md--PaddingBottom: var(--pf-global--spacer--lg);
  --pf-c-page__main-section--md--PaddingLeft: var(--pf-global--spacer--lg);
  --pf-c-page__main-section--m-no-padding-mobile--md--PaddingTop: 0;
  --pf-c-page__main-section--m-no-padding-mobile--md--PaddingRight: 0;
  --pf-c-page__main-section--m-no-padding-mobile--md--PaddingBottom: 0;
  --pf-c-page__main-section--m-no-padding-mobile--md--PaddingLeft: 0;
  --pf-c-page__main-section--BackgroundColor: var(--pf-global--BackgroundColor--light-300);
  --pf-c-page__main--ZIndex: var(--pf-global--ZIndex--xs);

  @media screen and (min-width: $pf-global--breakpoint--md) {
    --pf-c-page__main-section--PaddingTop: var(--pf-c-page__main-section--md--PaddingTop);
    --pf-c-page__main-section--PaddingRight: var(--pf-c-page__main-section--md--PaddingRight);
    --pf-c-page__main-section--PaddingBottom: var(--pf-c-page__main-section--md--PaddingBottom);
    --pf-c-page__main-section--PaddingLeft: var(--pf-c-page__main-section--md--PaddingLeft);
  }

  // Main section horizontal nav
  --pf-c-page__main-nav--BackgroundColor: var(--pf-global--BackgroundColor--light-100);
  --pf-c-page__main-nav--PaddingTop: var(--pf-global--spacer--sm);
  --pf-c-page__main-nav--PaddingRight: var(--pf-global--spacer--md);
  --pf-c-page__main-nav--PaddingBottom: var(--pf-global--spacer--md);
  --pf-c-page__main-nav--PaddingLeft: var(--pf-global--spacer--md);
  --pf-c-page__main-nav--md--PaddingRight: var(--pf-global--spacer--lg);
  --pf-c-page__main-nav--md--PaddingLeft: var(--pf-global--spacer--lg);
  --pf-c-page__main-nav--c-nav__scroll-button--nth-of-type-1--Left: calc(-1 * (var(--pf-global--spacer--lg) - var(--pf-global--spacer--xs))); // This sets the the button to the edge of its container with 4px clearance on the left
  --pf-c-page__main-nav--c-nav__scroll-button--nth-of-type-1--md--Left: calc(-1 * (var(--pf-global--spacer--md) - var(--pf-global--spacer--xs)));
  --pf-c-page__main-nav--c-nav__scroll-button--nth-of-type-2--Right: calc(-1 * (var(--pf-global--spacer--lg) - var(--pf-global--spacer--xs))); // This sets the the button to the edge of its container with 4px clearance on the left
  --pf-c-page__main-nav--c-nav__scroll-button--nth-of-type-2--md--Right: calc(-1 * (var(--pf-global--spacer--md) - var(--pf-global--spacer--xs)));

  @media screen and (max-width: $pf-global--breakpoint--md) {
    --pf-c-page__main-nav--c-nav__scroll-button--nth-of-type-1--Left: var(--pf-c-page__main-nav--c-nav__scroll-button--nth-of-type-1--md--Left);
    --pf-c-page__main-nav--c-nav__scroll-button--nth-of-type-2--Right: var(--pf-c-page__main-nav--c-nav__scroll-button--nth-of-type-2--md--Right);
  }

  @media screen and (min-width: $pf-global--breakpoint--md) {
    --pf-c-page__main-nav--PaddingRight: var(--pf-c-page__main-nav--md--PaddingRight);
    --pf-c-page__main-nav--PaddingLeft: var(--pf-c-page__main-nav--md--PaddingLeft);
  }

  // Main section breadcrumb
  --pf-c-page__main-breadcrumb--BackgroundColor: var(--pf-global--BackgroundColor--light-100);
  --pf-c-page__main-breadcrumb--PaddingTop: var(--pf-global--spacer--md);
  --pf-c-page__main-breadcrumb--PaddingRight: var(--pf-global--spacer--md);
  --pf-c-page__main-breadcrumb--PaddingBottom: 0;
  --pf-c-page__main-breadcrumb--PaddingLeft: var(--pf-global--spacer--md);
  --pf-c-page__main-breadcrumb--md--PaddingTop: var(--pf-global--spacer--lg);
  --pf-c-page__main-breadcrumb--md--PaddingRight: var(--pf-global--spacer--lg);
  --pf-c-page__main-breadcrumb--md--PaddingLeft: var(--pf-global--spacer--lg);
  --pf-c-page__main-nav--main-breadcrumb--PaddingTop: 0;

  @media screen and (min-width: $pf-global--breakpoint--md) {
    --pf-c-page__main-breadcrumb--PaddingTop: var(--pf-c-page__main-breadcrumb--md--PaddingTop);
    --pf-c-page__main-breadcrumb--PaddingRight: var(--pf-c-page__main-breadcrumb--md--PaddingRight);
    --pf-c-page__main-breadcrumb--PaddingLeft: var(--pf-c-page__main-breadcrumb--md--PaddingLeft);
  }

  // Main section modifiers
  --pf-c-page__main-section--m-light--BackgroundColor: var(--pf-global--BackgroundColor--light-100);
  --pf-c-page__main-section--m-dark-100--BackgroundColor: var(--pf-global--BackgroundColor--dark-transparent-100);
  --pf-c-page__main-section--m-dark-200--BackgroundColor: var(--pf-global--BackgroundColor--dark-transparent-200);

  // Wizard main section
  --pf-c-page__main-wizard--BorderTopColor: var(--pf-global--BorderColor--100);
  --pf-c-page__main-wizard--BorderTopWidth: var(--pf-global--BorderWidth--sm);

  // Base
  display: grid;
  height: 100%;
  grid-template-columns: 1fr;
  grid-template-rows: max-content 1fr;
  grid-template-areas:
    "header"
    "main";
  background-color: var(--pf-c-page--BackgroundColor);

  @media (min-width: $pf-global--breakpoint--md) {
    grid-template-columns: max-content 1fr;
    grid-template-areas:
      "header header"
      "nav main";
  }
}


// Header
.pf-c-page__header {
  @include pf-t-dark; // force the container to follow the dark theme

  z-index: var(--pf-c-page__header--ZIndex);
  grid-template-columns: auto auto;
  display: grid;
  grid-area: header;
  align-items: center;
  min-width: 0;
  min-height: var(--pf-c-page__header--MinHeight);

  > * {
    display: flex;
    align-items: center;
  }

  @media screen and (min-width: $pf-global--breakpoint--lg) {
    grid-template-columns: auto 1fr auto;
  }
}

// Brand
.pf-c-page__header-brand {
  grid-column: 1 / 2;
  padding-left: var(--pf-c-page__header-brand--PaddingLeft);

  @media (min-width: $pf-global--breakpoint--md) {
    padding-right: var(--pf-c-page__header-brand--md--PaddingRight); // set padding right here to allow mobile view to accomodate tools
  }
}

// Link
.pf-c-page__header-brand-link {
  display: flex;
  flex: 1;
  align-items: center;

  .pf-c-brand {
    max-height: var(--pf-c-page__header-brand-link--c-brand--MaxHeight); // Hardcode brand image max-height so it always aligns with everthing else.
  }
}

// Sidebar toggle
.pf-c-page__header-brand-toggle {
  .pf-c-button {
    padding: var(--pf-c-page__header-sidebar-toggle__c-button--PaddingTop) var(--pf-c-page__header-sidebar-toggle__c-button--PaddingRight) var(--pf-c-page__header-sidebar-toggle__c-button--PaddingBottom) var(--pf-c-page__header-sidebar-toggle__c-button--PaddingLeft);
    margin-right: var(--pf-c-page__header-sidebar-toggle__c-button--MarginRight);
    margin-left: var(--pf-c-page__header-sidebar-toggle__c-button--MarginLeft);
    font-size: var(--pf-c-page__header-sidebar-toggle__c-button--FontSize);
    line-height: 1;
  }
}

// Header navigation
.pf-c-page__header-nav {
  grid-column: 1 / -1;
  grid-row: 2 / 3;
  min-width: 0;
  padding-left: var(--pf-c-page__header-nav--PaddingLeft);
  background-color: var(--pf-c-page__header-nav--BackgroundColor);

  > .pf-c-nav {
    min-width: 0;

    .pf-c-nav__scroll-button {
      @media screen and (max-width: #{$pf-global--breakpoint--lg - 1}) {
        top: var(--pf-c-page__header-nav--c-nav__scroll-button--lg--Top);
        background-color: var(--pf-c-page__header-nav--c-nav__scroll-button--lg--BackgroundColor);
      }

      &:nth-of-type(1) {
        left: var(--pf-c-page__header-nav--c-nav__scroll-button--nth-of-type-1--Left);
      }
    }
  }

  @media screen and (min-width: $pf-global--breakpoint--lg) {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    flex: 1;
    align-self: flex-end;
    order: initial;
    width: auto;
    margin-right: var(--pf-c-page__header-nav--lg--MarginRight);
    margin-left: var(--pf-c-page__header-nav--lg--MarginLeft);
  }
}

// Header tools
.pf-c-page__header-tools {
  grid-column: 2 / 3;
  align-items: center;
  margin-top: var(--pf-c-page__header-tools--MarginTop);
  margin-right: var(--pf-c-page__header-tools--MarginRight);
  margin-bottom: var(--pf-c-page__header-tools--MarginBottom);
  margin-left: auto; // to push it to the right

  .pf-m-icons {
    display: none;
    visibility: hidden;

    @media screen and (min-width: $pf-global--breakpoint--lg) {
      display: block;
      visibility: visible;
    }
  }

  .pf-c-button {
    &.pf-m-selected {
      &::before {
        position: absolute;
        top: 0;
        left: 50%;
        width: var(--pf-c-page__header-tools--c-button--m-selected--before--Width);
        height: var(--pf-c-page__header-tools--c-button--m-selected--before--Height);
        content: "";
        background-color: var(--pf-c-page__header-tools--c-button--m-selected--before--BackgroundColor);
        border-radius: var(--pf-c-page__header-tools--c-button--m-selected--before--BorderRadius);
        transform: translateX(-50%);
      }

      // stylelint-disable
      .pf-c-notification-badge {
        &.pf-m-unread {
          &::after {
            border-color: var(--pf-c-page__header-tools--c-button--m-selected--c-notification-badge--m-unread--after--BorderColor);
          }
        }
      }
      // stylelint-enable
    }

    > * {
      position: relative;
    }
  }

  .pf-m-mobile {
    margin-right: 0;

    @media screen and (min-width: $pf-global--breakpoint--lg) {
      display: none;
      visibility: hidden;
    }
  }

  .pf-m-user {
    display: none;
    visibility: hidden;

    @media screen and (min-width: $pf-global--breakpoint--md) {
      display: block;
      visibility: visible;
    }
  }

  .pf-c-avatar {
    margin-left: var(--pf-c-page__header-tools--c-avatar--MarginLeft);
  }

  @media screen and (min-width: $pf-global--breakpoint--lg) {
    grid-column: 3 / 4;
  }
}

.pf-c-page__header-tools-group {
  display: flex;

  & + & {
    margin-left: var(--pf-c-page__header-tools-group--MarginLeft);
  }
}

// Sidebar
.pf-c-page__sidebar {
  grid-area: nav;
  grid-row-start: 2;
  grid-column-start: 1;
  z-index: var(--pf-c-page__sidebar--ZIndex);
  width: var(--pf-c-page__sidebar--Width);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: var(--pf-c-page__sidebar--BackgroundColor);
  transition: var(--pf-c-page__sidebar--Transition);
  transform: var(--pf-c-page__sidebar--Transform);

  @media screen and (min-width: $pf-global--breakpoint--md) {
    max-width: var(--pf-c-page__sidebar--md--Width); // max-width value set for browser to calculate max-width while transitioning. sharing value to keep consistent
    box-shadow: var(--pf-c-page__sidebar--BoxShadow);
  }

  // Mobile
  // Expanded nav
  &.pf-m-expanded {
    --pf-c-page__sidebar--Transform: var(--pf-c-page__sidebar--m-expanded--Transform);

    box-shadow: var(--pf-c-page__sidebar--BoxShadow);
  }

  // Desktop
  // Collapse nav
  &.pf-m-collapsed {
    max-width: 0;
    overflow: hidden;
  }

  &.pf-m-dark {
    @include pf-t-dark;

    --pf-c-page__sidebar--BackgroundColor: var(--pf-c-page__sidebar--m-dark--BackgroundColor);
  }
}

.pf-c-page__sidebar-body {
  padding-top: var(--pf-c-page__sidebar-body--PaddingTop);
  padding-bottom: var(--pf-c-page__sidebar-body--PaddingBottom);
}

// Main & Drawer
.pf-c-page__main,
.pf-c-page__drawer {
  grid-area: main;
  z-index: var(--pf-c-page__main--ZIndex);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  &:focus {
    outline: 0;
  }
}

.pf-c-page__main-nav {
  padding: var(--pf-c-page__main-nav--PaddingTop) var(--pf-c-page__main-nav--PaddingRight) var(--pf-c-page__main-nav--PaddingBottom) var(--pf-c-page__main-nav--PaddingLeft);
  background-color: var(--pf-c-page__main-nav--BackgroundColor);

  .pf-c-nav {
    .pf-c-nav__scroll-button {
      &:nth-of-type(1) {
        left: var(--pf-c-page__main-nav--c-nav__scroll-button--nth-of-type-1--Left);
      }

      &:nth-of-type(2) {
        right: var(--pf-c-page__main-nav--c-nav__scroll-button--nth-of-type-2--Right);
      }
    }
  }
}

.pf-c-page__main-breadcrumb {
  padding: var(--pf-c-page__main-breadcrumb--PaddingTop) var(--pf-c-page__main-breadcrumb--PaddingRight) var(--pf-c-page__main-breadcrumb--PaddingBottom) var(--pf-c-page__main-breadcrumb--PaddingLeft);
  background-color: var(--pf-c-page__main-breadcrumb--BackgroundColor);

  .pf-c-page__main-nav + & {
    --pf-c-page__main-breadcrumb--PaddingTop: var(--pf-c-page__main-nav--main-breadcrumb--PaddingTop);
  }
}

.pf-c-page__main-section {
  padding: var(--pf-c-page__main-section--PaddingTop) var(--pf-c-page__main-section--PaddingRight) var(--pf-c-page__main-section--PaddingBottom) var(--pf-c-page__main-section--PaddingLeft);
  background-color: var(--pf-c-page__main-section--BackgroundColor);

  &:last-of-type,
  &:only-child,
  &.pf-m-fill {
    flex: 1;
  }

  &.pf-m-no-fill {
    flex: 0 0 auto;
  }

  &.pf-m-light {
    --pf-c-page__main-section--BackgroundColor: var(--pf-c-page__main-section--m-light--BackgroundColor);
  }

  &[class*="pf-m-dark-"] {
    @include pf-t-dark; // force the container to follow the dark theme
  }

  &.pf-m-dark-100 {
    --pf-c-page__main-section--BackgroundColor: var(--pf-c-page__main-section--m-dark-100--BackgroundColor);
  }

  &.pf-m-dark-200 {
    --pf-c-page__main-section--BackgroundColor: var(--pf-c-page__main-section--m-dark-200--BackgroundColor);
  }

  &.pf-m-no-padding {
    padding: 0;
  }

  &.pf-m-no-padding-mobile {
    @media screen and (max-width: $pf-global--breakpoint--md) {
      --pf-c-page__main-section--PaddingTop: var(--pf-c-page__main-section--m-no-padding-mobile--md--PaddingTop);
      --pf-c-page__main-section--PaddingRight: var(--pf-c-page__main-section--m-no-padding-mobile--md--PaddingRight);
      --pf-c-page__main-section--PaddingBottom: var(--pf-c-page__main-section--m-no-padding-mobile--md--PaddingBottom);
      --pf-c-page__main-section--PaddingLeft: var(--pf-c-page__main-section--m-no-padding-mobile--md--PaddingLeft);
    }
  }
}

.pf-c-page__main-wizard {
  flex: 1 0 0;
  border-top: var(--pf-c-page__main-wizard--BorderTopWidth) solid var(--pf-c-page__main-wizard--BorderTopColor);
}

.pf-c-page__drawer {
  grid-area: main;

  > .pf-c-drawer {
    flex: 1 0 auto;
  }
}
