/* 

Setting global spacing variables as equal to the --two-spacer variable as that's what's used in the header and footer currently;
this can change to match any desired general spacing/margins.

Default width is set as 800px with a global horiz. spacing margin on each side;
for screens above 1600px, this is instead set to 1200px with the same guaranteed margins.

Wide widths, 'alignfull' elements, are given full-width minus a standard horiz. margin on each side;
for screens above 1600px, this is changed to assign a width of 1600px while maintaining the same margins.

*/

:root {
  --global--spacing-horizontal: var(--two-spacer);
  --global--spacing-vertical: var(--two-spacer);
  --responsive--aligndefault-width: calc(800px - (4 * var(--global--spacing-horizontal)));;
  --responsive--alignwide-width: calc(100vw - (4 * var(--global--spacing-horizontal)));
  --responsive--alignfull-width: 100%;
  --responsive--alignright-margin: var(--global--spacing-horizontal);
  --responsive--alignleft-margin: var(--global--spacing-horizontal);
}

@media only screen and (min-width: 1600px) {
  :root {
    --responsive--aligndefault-width: calc(1200px - (2 * var(--global--spacing-horizontal)));;
    --responsive--alignwide-width: calc(1600px - (2 * var(--global--spacing-horizontal)));
  }
}

.post-thumbnail,
.entry-content .wp-audio-shortcode,
.entry-content > *:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.wp-block-separator):not(.woocommerce),
*[class*=inner-container] > *:not(.entry-content):not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.wp-block-separator):not(.woocommerce),
.default-max-width {
  max-width: var(--responsive--aligndefault-width);
  width: var(--responsive--aligndefault-width);
  margin-left: auto;
  margin-right: auto;
}

.widget-area,
.pagination,
.comments-pagination,
.post-navigation,
.site-footer,
.site-header,
.alignwide,
.is-style-alignwide,
.wide-max-width {
  max-width: var(--responsive--alignwide-width);
  width: var(--responsive--alignwide-width);
  margin-left: auto;
  margin-right: auto;
}

.alignfull,
.wp-block-group .wp-block-group__inner-container > *.alignfull,
.full-max-width {
  max-width: var(--responsive--alignfull-width);
  width: var(--responsive--alignfull-width);
  margin-left: auto;
  margin-right: auto;
}

.entry-header .post-thumbnail,
.singular .post-thumbnail,
.alignfull [class*=inner-container] > .alignwide,
.alignwide [class*=inner-container] > .alignwide {
  width: var(--responsive--alignwide-width);
  max-width: var(--responsive--alignfull-width);
  margin-left: auto;
  margin-right: auto;
}

.entry-content > .alignleft {
  margin-left: var(--responsive--alignleft-margin);
  margin-right: auto;
  }

.entry-content > .alignright {
  margin-left: auto;
  margin-right: var(--responsive--alignright-margin);
}

/*

Setting vertical margins and responsive widths on top-level wrappers and content wrappers.

*/

.site-header,
.site-main,
.widget-area,
.site-footer {
  padding-top: var(--global--spacing-vertical);
  padding-bottom: var(--global--spacing-vertical);
  margin-left: auto;
  margin-right: auto;
}

/*

'Main' children margin exceptions

*/

.site-main > *:first-child {
  margin-top: 0;
}
.site-main > *:last-child {
  margin-bottom: 0;
}

/* 
Overhauling spacing to rely only on margin-top
in order to enable more dynamic layout control with just CSS 
*/
.site-main > article > *,
.site-main > .not-found > *,
.entry-content > *:not(:first-child),
[class*=inner-container] > *,
.wp-block-template-part > *,
.site-footer > *,
.widget-area > *,
.entry-header > *,
.post-thumbnail > *,
.page-content > *,
.comment-content > *,
.widget > *  {
  margin-top: var(--four-spacer);
}

/* Slightly tighter spacing w/in groups and columns */
.entry-content .wp-block-column > *:not(.wp-block-columns):not(:first-child),
.wp-block-cover__inner-container > *:not(:first-child),
.entry-content .wp-block-group > *:not(:first-child) {
  margin-top: var(--four-spacer);
}

/* Much tighter spacing w/in single columns */
/* .is-style-tighter-spacing > *:not(:first-child), */
.entry-content .wp-block-column > *:not(:first-child):not(.wp-block-image):not(.wp-block-image + p),
.entry-content .wp-block-column > *:not(:first-child):not(.wp-block-image):not(.wp-block-image + p) {
  margin-top: var(--two-spacer) !important;
}

/* Tightest spacing for 3-up query loop cards */
.entry-content ul.columns-3 .wp-block-post > *:not(:first-child) {
  margin-top: var(--one-spacer) !important;
}

/* Special spacing for small text */
.entry-content .wp-block-column > *:not(:first-child):not(.wp-block-image):not(.wp-block-image + p).has-small-font-size {
  margin-top: var(--one-spacer) !important;
}

/* No top margin if the first element in the 'entry-content' container has a background */
.entry-content > *:first-child.has-background,
.entry-content > *:first-child.has-custom-background {
  margin-top: 0 !important;
}

/*
No gap if two consecutive elements have a background color
Added 'has-custom-background so that bespoke blocks
don't inherit all of the core styles that come with 'has-background'
*/
.entry-content > .has-background + .has-background,
.entry-content > .has-custom-background + .has-background,
.entry-content > .has-background + .has-custom-background,
.entry-content > .has-custom-background + .has-custom-background,
.entry-content > .has-background + .wp-block-cover,
.entry-content > .wp-block-cover + .has-background,
/* Closing the margin if a full-width image follows an element with a background color */
.entry-content > .has-background + .alignfull,
.entry-content > .has-custom-background + .alignfull {
  margin-top: 0 !important;
}

/* 
Managing 'Cover' block spacing
*/
.entry-content > .has-background + .wp-block-cover,
.wp-block-cover__inner-container *:first-child {
  margin-top: 0 !important;
}

@media screen and (max-width: 1200px) {
  .widget-area,
  .pagination,
  .comments-pagination,
  .post-navigation,
  .site-footer,
  .site-header,
  .alignwide,
  .wide-max-width {
      max-width: 100%;
      width: auto;
      margin-left: calc(2 * var(--global--spacing-horizontal));
      margin-right: calc(2 * var(--global--spacing-horizontal));
  }
}

@media screen and (max-width: 991px) {
  .widget-area,
  .pagination,
  .comments-pagination,
  .post-navigation,
  .site-footer,
  .site-header,
  .alignwide,
  .wide-max-width {
      max-width: 100%;
      width: auto;
      margin-left: var(--global--spacing-horizontal);
      margin-right: var(--global--spacing-horizontal);
  }
}

@media screen and (max-width: 991px) {
  .post-thumbnail,
  .entry-content .wp-audio-shortcode, 
  .entry-content > *:not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright):not(.wp-block-separator):not(.woocommerce),
  *[class*=inner-container] > *:not(.entry-content):not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright) {
    max-width: 100%;
    width: auto;
    margin-left: var(--global--spacing-horizontal);
    margin-right: var(--global--spacing-horizontal);
  }

  .wp-block-cover, .wp-block-cover-image {
    width: inherit;
  }

  .wp-block-columns.alignfull {
    margin: 0;
  }

  /* Eliminating margins on 'alignwide' elements inside groups with backgrounds */
  .has-background .alignwide {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

.entry-content .has-background:not(.wp-block-button__link),
.entry-content .has-border-color {
  padding: calc(2 * var(--global--spacing-vertical)) calc(2 * var(--global--spacing-horizontal));
}
@media screen and (max-width: 991px) {
  .entry-content .has-background:not(.wp-block-button__link),
  .entry-content .has-border-color {
    padding: calc(2 * var(--global--spacing-vertical)) var(--global--spacing-horizontal);
  }
}

/* Effectively getting rid of 'alignwide' and 'alignfull' on Person detail pages */
.entry-content.narrow > * {
  width: 100% !important;
  max-width: 100% !important;
}

.wp-block-column {
  align-items: flex-start;
}

/* Robust separator overrides */
/* All widths, dot style */
.wp-block-separator.is-style-dots {
  border-bottom: 1px dotted currentColor !important;
}
.wp-block-separator.is-style-dots:before {
  content: none;
}
/* Default width, default style */
.wp-block-separator {
  border-width: 1px;
  max-width: calc(0.5 * var(--responsive--aligndefault-width)) !important;
  width: calc(0.5 * var(--responsive--aligndefault-width)) !important;
  margin-left: calc((100vw - var(--responsive--aligndefault-width))/2);
}
/* Default width, wide style */
.wp-block-separator.is-style-wide {
  border-width: 1px;
  max-width: var(--responsive--aligndefault-width) !important;
  width: var(--responsive--aligndefault-width) !important;
  margin-left: auto !important;
}
/* Wide width, default style */
.wp-block-separator.alignwide {
  border-width: 1px;
  max-width: calc(0.5 * var(--responsive--alignwide-width)) !important;
  width: calc(0.5 * var(--responsive--alignwide-width)) !important;
  margin-left: calc((100vw - var(--responsive--alignwide-width))/2);
}
/* Wide width, wide style */
.wp-block-separator.is-style-wide.alignwide {
  border-width: 1px;
  max-width: var(--responsive--alignwide-width) !important;
  width: var(--responsive--alignwide-width) !important;
  margin-left: auto !important;
}
/* Full width, default and wide style */
.wp-block-separator.alignfull,
.wp-block-separator.is-style-wide.alignfull {
  border-width: 1px;
  max-width: 100% !important;
  width: 100% !important;
  margin-left: 0;
}
@media screen and (max-width: 991px) {
  .wp-block-separator,
  .wp-block-separator.is-style-wide,
  .wp-block-separator.alignwide,
  .wp-block-separator.is-style-wide.alignwide {
    margin-left: var(--global--spacing-horizontal) !important;
    margin-right: var(--global--spacing-horizontal) !important;
    width: calc(100% - 2 * var(--global--spacing-horizontal)) !important;
    max-width: calc(100% - 2 * var(--global--spacing-horizontal)) !important;
  }
  .wp-block-separator.alignfull {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}