/*
 * EdGEL page masthead
 * --------------------------------------------------
 */

@use "sass:math";

@use "../settings" as *;
@use "../tools" as *;

.masthead {
  background: #fff;

  [class*="col-"] {
    margin-top: auto;
    margin-bottom: auto;
  }

  &:not(.fluid &) {
    @include edgel-constrain-width();
  }
}

.container-branding,
.container-topnav,
.container-masthead {
  @include edgel-container();
}

.container-masthead {
  position: relative;
  padding-top: $masthead-padding-xs;
  padding-bottom: $masthead-padding-xs;

  @include media-breakpoint-up(md) {
    padding-top: $masthead-padding;
    padding-bottom: $masthead-padding;
  }
}

.masthead-heading {
  margin-bottom: space(1);
  font-family: $headings-font-family;
  @include font-size($h2-font-size);
  font-style: $headings-font-style;
  font-weight: $headings-font-weight;
  line-height: $headings-line-height;
  color: $headings-color;
  text-align: right;
}

.masthead-text {
  margin: $masthead-padding-xs 0;
  text-align: right;

  .list-inline {
    margin-bottom: 0;
  }

  @include media-breakpoint-up(md) {
    margin: 0 0 #{$masthead-padding-xs * 1.25};
  }
}

.masthead-logo {
  width: 100%;
  max-width: edgel-px-rem(332);
  height: auto;
  max-height: edgel-px-rem(79);
  vertical-align: top;
}

// Add padding to move the logo away from the search toggle button (class added in JS)
.masthead-logo-collapsible-search {
  padding-right: edgel-px-rem(45);
}

/* Show/hide the search form */
.btn-masthead-search-toggler {
  @include edgel-button-variant($white);
  position: absolute;
  top: .25rem;
  right: .25rem;
  width: 2.5rem;
  height: 2.5rem;
  background-image: escape-svg($uoe-btn-search-toggler-icon);
  background-repeat: no-repeat;
  background-position: 50% 50%;
  background-size: 55%;
}

.edgel-js .masthead-logo-collapsible-search {
  padding-right: 3rem;
}

@include media-breakpoint-up(md) {
  .edgel-js {
    .masthead-search {
      display: block;
    }

    .btn-masthead-search-toggler {
      display: none;
    }
  }
}

/* Hero banner image and title container */
.masthead-hero {
  position: relative;
  background-color: $brand-color;
}

.masthead-banner {
  position: relative;
  width: 100%;

  &::before {
    display: block;
    padding-top: (math.div(11, 60) * 100%);
    content: "";
  }

  @include edgel-shadow();
}

.masthead-hero-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* This container uses absolute positioning for the overlay, rather than flex and margins, to be consistent with the ratio setting of the hero image */
.container-branding {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

/* Branding image has a top line */
.masthead-branding {
  @include edgel-topline(4px);
  @include edgel-shadow();
  @include edgel-scale(max-height, 81, 245, px); // 241px + 4px topline
  //object-fit: contain;
  //object-position: top right;
  @include edgel-scale(max-width, 131, 241, px);
  float: right;
}

/* Title block */
.masthead-title {
  @include edgel-container();
  @include edgel-scale(min-height, edgel-px-rem-val(70), edgel-px-rem-val(120), rem);
  @include edgel-scale(padding-top, edgel-px-rem-val(11), edgel-px-rem-val(33), rem);
  @include edgel-scale(padding-bottom, edgel-px-rem-val(8), edgel-px-rem-val(32), rem);
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  justify-content: center;

  // Deliberately increasing specificity to counter margin-top in elements/_headings.scss
  &.masthead-title {
    h1 + h2,
    .h1 + h2 {
      margin-top: 0;
    }
  }

  h1,
  h2,
  .h1,
  .h2 {
    padding-bottom: 0;
    margin-bottom: 0;
    font-family: $font-family-serif;
    font-weight: $font-weight-normal;
    color: $brand-bg-text;
    --#{$prefix}link-color-rgb: #{to-rgb($brand-bg-text)};
    --#{$prefix}link-hover-color-rgb: #{to-rgb($brand-bg-text)};
    --#{$prefix}link-decoration-opacity: 0;
  }
  h1,
  .h1 {
    @include edgel-scale(font-size, edgel-px-rem-val(25), edgel-px-rem-val(42), rem);
    font-style: normal;
    line-height: 1.1;
    text-transform: uppercase;
    border-bottom: none;
  }
  h2,
  .h2 {
    @include edgel-scale(font-size, edgel-px-rem-val(22), edgel-px-rem-val(37), rem);
    @include edgel-scale(margin-bottom, edgel-px-rem-val(4), edgel-px-rem-val(8), rem);
    z-index: $stretched-link-z-index;
    font-style: italic;
  }
}
