/**
 * @file
 * Grid system definition for the content narrow layout.
 */

@import "../base/media-queries.pcss.css";

.layout--content-narrow,
.layout--pass--content-narrow > * {
  grid-column: 1 / 7;
  width: 100%;

  @media (--grid-md) {
    grid-column: 2 / 14;
  }

  @media (--lg) {
    grid-column: 3 / 11;
  }
}

/*
  If .layout--content-narrow is nested within any of the following, allocate the appropriate
  amount of columns within its parent .grid-full.
    - .layout--content-narrow class.
    - Element that's inheriting the layout--content-narrow styles from its parent region.
    - .layout--content-medium class.
    - Element that's inheriting the layout--content-medium styles from its parent region.
*/
.layout--content-narrow,
.layout--pass--content-narrow > *,
.layout--content-medium,
.layout--pass--content-medium > * {
  & .layout--content-narrow,
  & .layout--pass--content-narrow > * {
    @media (--grid-md) {
      grid-column: 1 / 13;
    }

    @media (--lg) {
      grid-column: 1 / 9;
    }
  }
}

/*
  Special grid-breaking treatment for text-content elements that
  reside in a content-narrow layout.
*/
.layout--content-narrow,
.layout--pass--content-narrow > * {
  &.text-content,
  & .text-content {
    & blockquote {
      &::before {
        @media (--grid-md) {
          inset-inline-start: calc(-1 * (var(--grid-col-width) + var(--grid-gap)));
        }
      }

      &::after {
        @media (--grid-md) {
          inset-inline-start: calc(-1 * (var(--grid-col-width) + var(--grid-gap)));
          width: var(--sp);
          height: calc(100% - 45px);
          margin-inline-start: 2px;
        }
      }

      @media (--grid-md) {
        width: calc(10 * var(--grid-col-width) + 9 * var(--grid-gap));
        margin-block: var(--sp3);
        padding-inline-start: 0;
      }
    }

    & pre {
      @media (--grid-md) {
        margin-block: var(--sp3);
      }

      @media (--lg) {
        width: calc(12 * var(--grid-col-width) + 11 * var(--grid-gap));
        margin-inline-start: calc(-1 * (var(--grid-col-width) + var(--grid-gap)));
      }
    }
  }
}

/**
 * <pre> and <blockquote> elements should not break containers and overflow
 * into sidebar region when present.
 */
.sidebar-grid {
  & .layout--content-narrow,
  & .layout--pass--content-narrow > * {
    &.text-content,
    & .text-content {
      & blockquote,
      & pre {
        width: auto;
      }
    }
  }
}
