/* article.news */

article.news {
  /* adjustments to main content width */
  .field--name-body,
  .field--name-field-if-story-source,
  .field--name-field-tags,
  .field--name-field-paragraph {
    max-width: 900px !important;

    @media (width >= 1000px) {
      margin: 0 auto !important;
    }
  }

  .field--name-field-if-subtitle {
    margin-bottom: 1.875rem;
    color: var(--il-orange);
    font-size: 2rem;
    font-weight: 600;
    line-height: 2.5rem;
  }

  .field--name-field-if-author {
    float: left;
    padding: 1rem 0;
    color: var(--il-blue);
    font-weight: 600;

    &::after {
      display: inline-block;
      width: 2px;
      height: 35px;
      margin: -10px 1rem;
      content: "";
      background-color: var(--il-orange);
    }
  }

  .field--name-field-if-date {
    margin: 0 0 1.875rem;
    padding: 1rem 0;
    color: var(--il-blue);
    border-top: 1px solid #d8d8d8;
    border-bottom: 1px solid #d8d8d8;
    font-weight: 600;
    line-height: 1.75rem;
  }

  .field--name-field-if-meda-featured-image {
    float: none;
    max-width: 600px;
    margin: 0 auto;
    padding: 1.875rem 1.5rem 0;

    .field__item {
      display: flex;

      img {
        margin: 0 auto;
      }
    }
  }

  .field--name-body {
    padding: 1.875rem 0 !important;
  }

  .field--name-field-if-story-source {
    display: flex;
    padding: 1.125rem 0;
    color: var(--il-blue);
    font-weight: 600;
    font-style: oblique;
    gap: 1rem;

    .field__label {
      &::after {
        content: ":";
      }
    }
  }

  .field--name-field-tags {
    display: flex;
    padding: 1.125rem 0;
    color: var(--il-blue);
    border-top: 1px solid #d8d8d8;
    font-weight: 600;
    font-style: oblique;
    gap: 1rem;

    .field__label {
      &::after {
        content: ":";
      }
    }

    .field__items {
      display: flex;
      gap: 1rem;
    }
  }

  @media (width >= 600px) {
    .paragraph {
      .fixed-width {
        padding: 0 2rem ;
      }
    }
  }

  /* hides featured image if featured_image_toggle field is true */
  &.hide-image {
    .field--name-field-if-meda-featured-image {
      display: none;
    }
  }
}

/* news archive page and news archive block */
.news-page .news-title {
  font-weight: 600;
}

.news-page .item-list ul {
  padding-inline-start: 0;
  list-style: none;
}

.news-page .item-list li {
  overflow: auto;
  margin: 0;
  padding: 1.875rem 0;
  list-style: none;
  border-bottom: 2px solid #d8d8d8;
}

.news-page .views-field-body {
  padding-left: 7.8125rem;
}

.news-page .views-field-field-if-meda-featured-image {
  float: left;
}

/* news blocks more news */
.news-block {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 var(--ilw-margin--side, 0);

  .item-list {
    width: auto;

    ul {
      padding-inline-start: 0;

      li {
        margin: 0;
        padding: 1rem 0;
        list-style: none;
        border-bottom: 1px solid #c6c7c7;

        &::before {
          float: left;
          padding-right: 1rem;
          content: "\25A0";
          color: #c6c7c7;
        }
      }

      li:last-child {
        border-bottom: none;
      }
    }

    .title {
      font-size: 1.25rem;
      font-weight: 400;
      line-height: 1.75rem;

      a {
        text-decoration: none;

        &:hover,
        &:focus {
          text-decoration: underline;
        }
      }
    }
  }

  .hidden {
    position: absolute;
    overflow: hidden;
    clip: rect(1px 1px 1px 1px);
    clip: rect(1px, 1px, 1px, 1px);
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    text-indent: -999em;
    border: 0;
  }

  @media (width >= 600px) {
    padding: 0;
  }
}

/* highlighted news block */
.highlighted-news {
  margin: 0 auto;

  .item-list {
    width: auto;

    ul {
      padding-inline-start: 0;
      list-style: none;

      li {
        overflow: auto;
        margin: 0;
        padding: 1.875rem 0;
        list-style: none !important;
        border-bottom: 2px solid var(--il-storm-lighter-4);
      }

      li:last-child {
        border-bottom: none;
      }
    }
  }

  a {
    &.readmore {
      &::after {
        display: inline-block;
        padding: 0 0.25rem;
        content: "\203A";
        vertical-align: bottom;
        text-decoration: none;
        font-size: 0.75rem;
      }

      &:hover {
        text-decoration: underline;
      }

      &:hover::after {
        text-decoration: none !important;
      }
    }
  }

  ul {
    li {
      clear: both;
    }
  }

  .highlighted-news-wrapper {
    display: flex;
    flex-direction: column; /* Stack elements vertically on mobile */

    .highlighted-news-image {
      order: -1; /* Forces the image above the content area on mobile */
      width: 100%;
      margin-bottom: 15px; /* Adds space between the mobile image and headline */

      /* Hides the entire div if it contains no content */
      &:empty {
        display: none;
      }

      img {
        display: block; /* Removes the slight gap browsers typically add below inline images */
        width: 100%;
        height: auto;
        object-fit: cover;
        object-position: center; /* Ensures cropping happens evenly on the top and bottom */
        aspect-ratio: 3 / 2;

        @media (width >= 600px) {
          height: 200px;
        }
      }

      @media (width >= 600px) {
        overflow: hidden;
        flex: 0 1 300px;
        order: 0; /* Restores normal DOM order (right side) on desktop */
        max-width: 300px;
        max-height: 200px;
        margin-bottom: 0; /* Removes mobile spacing */
      }
    }

    .highlighted-news-content {
      flex: 1;
      padding-right: 0; /* Remove padding on mobile to maximize space */

      .title h2 {
        margin-top: 0;
        font-size: 1.625rem;
        line-height: 2rem;
      }

      .button {
        margin: auto 0 0;
        padding-left: 0;
      }

      @media (width >= 600px) {
        padding-right: 50px; /* Restore right padding on desktop */
      }
    }

    @media (width >= 600px) {
      flex-direction: row; /* Switch back to side-by-side on desktop */
      align-items: flex-start;
    }
  }
}

/* Styles for the news teaser template. */
.news-list-item {
  .media--view-mode-news-teaser {
    float: left;
    padding-right: calc(var(--il-content-margin) * 1.5);
  }

  .field--name-field-if-date {
    float: left;
    font-style: italic;
  }

  .field--name-field-if-date::after {
    display: table;
    float: right;
    padding: 0 0.2em;
    content: "-";
  }
}

/* news cards */
.hvrbox-card {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem 3%;
  flex-basis: 100%;

  &.hvrbox-col-2 {
    > div {
      @media (width >= 600px) {
        flex-basis: 48%;
      }
    }

    header {
      flex: 0 0 100%;
      margin-bottom: -2.25rem; /* overrides flex gap to remove excess space between header and news cards */
    }

    footer {
      flex: 0 0 100%;

      p {
        margin-bottom: 2.25rem;
        text-align: center;
      }
    }

    .hvrbox {
      .hvrbox-title {
        font-size: 1.25rem;
        font-weight: 700;
        line-height: 1.6875rem;

        @media (width >= 992px) {
          font-size: 1.8125rem;
          line-height: 2.1875rem;
        }
      }

      .hvrbox-body {
        display: -webkit-box;
        overflow: hidden;
        text-overflow: ellipsis;
        -webkit-line-clamp: 6; /* number of lines to show */
        line-clamp: 6;
        -webkit-box-orient: vertical;

        .field--name-body {
          padding: 0;
        }
      }
    }
  }

  &.hvrbox-col-3 {
    > div {
      flex-basis: 100%;

      @media (width >= 768px) {
        flex-basis: 48%;
      }

      @media (width >= 600px) {
        flex-basis: 31%;
      }
    }

    header {
      flex: 0 0 100%;
      margin-bottom: -2.25rem; /* overrides flex gap to remove excess space between header and news cards */
    }

    footer {
      flex: 0 0 100%;

      p {
        margin-bottom: 2.25rem;
        text-align: center;
      }
    }

    .hvrbox {
      .hvrbox-title {
        font-size: 1.25rem;
        font-weight: 700;
        line-height: 1.6875rem;
      }

      .hvrbox-body {
        display: -webkit-box;
        overflow: hidden;
        text-overflow: ellipsis;
        -webkit-line-clamp: 3; /* number of lines to show */
        line-clamp: 3;
        -webkit-box-orient: vertical;
      }

      .hvrbox-layer_slideup {
        transform: translateY(50%);
      }
    }
  }

  .hvrbox {
    position: relative;
    overflow: hidden;
    height: auto;
    border: 1px solid #707070;

    .field--name-field-if-meda-featured-image {
      float: none;
      padding: 0;
    }

    img {
      width: 100%;
      max-width: 100%;
      height: auto;
    }

    .hvrbox-title {
      margin-bottom: 1.25rem;
      color: #13294b;

      &::after {
        position: absolute;
        padding: 0 0.5rem;
        content: "\BB";
        vertical-align: bottom;
      }
    }

    .hvrbox-body {
      transition: all 0.4s ease-in-out 0s;
      opacity: 0;
      font-size: 1.25rem;
      font-weight: 500;
      line-height: 1.6875rem;

      .field--name-body {
        padding: 0 !important;
      }
    }

    .hvrbox-layer_bottom {
      display: block;
    }

    .hvrbox-layer_top {
      position: absolute;
      width: 100%;
      height: 100%;
      padding: 10px 15px 0;
      transition: all 0.4s ease-in-out 0s;
      background: rgb(255 255 255 / 80%);
      inset: 0;

      > a {
        position: absolute;
        z-index: 1001;
        display: block;
        width: 100%;
        height: 100%;
        text-decoration: none;
        background-color: transparent;
      }
    }

    .hvrbox-layer_slideup {
      transform: translateY(65%);
    }

    &:hover,
    &:focus-within,
    &:active {
      .hvrbox-layer_slideup {
        transform: translateY(0);
        background: rgb(255 255 255 / 100%);
      }

      .hvrbox-body {
        opacity: 1;
      }

      .hvrbox-title {
        transition: all 0.4s;
        color: var(--il-orange);
      }
    }
  }

  @media (width >= 768px) {
    gap: 2.25rem 3%;
  }
}

.hvrbox,
.hvrbox * {
  box-sizing: border-box;
}

.related-news.embedded-block .news-sub-title {
  font-size: 1rem;
  line-height: 1.5rem;
}
