/*** Buttons and Links ***/

/* Button text styles */

body.wp-child-theme-graceatwork-divi.et-db #page-container,
body.wp-child-theme-graceatwork-divi.et-db #et-boc,
body.woocommerce.et-db #et-boc,
body.wp-child-theme-graceatwork-divi.et-db .bvi-flyout-sidebar,
body.woocommerce.et-db .bvi-flyout-sidebar {
  a:not(.et_pb_module_header > a):not(#wpadminbar a),
  button,
  .button,
  .et_pb_button,
  .gform_wrapper.gform-theme--foundation
    form
    input[type="submit"].gform-button {
    font-family: var(--body-font-family);
    font-weight: 600;
    font-style: normal;
    font-size: var(--body-font-size);
    line-height: var(--default-line-height) !important;
  }

  /* Button styles */
  .button,
  button.et_pb_button {
    text-decoration: none;
    border-radius: var(--button-radius);
    border: 2px solid var(--white);
    padding: 20px 30px;
    transition: all 0.3s ease;
    text-align: center;

    &.primary-button {
      background-color: var(--light-blue);
      border-color: var(--light-blue);
      color: var(--primary-color);
      text-transform: uppercase;

      &.primary-button-dark {
        color: var(--white);
        background-color: var(--primary-color);
        border-color: var(--primary-color);
      }

      &:hover {
        opacity: 0.9 !important;
        border-color: var(--light-blue);
      }

      &.primary-button-dark:hover {
        color: var(--white) !important;
        border-color: var(--primary-color) !important;
        background-color: var(--primary-color) !important;
      }
    }

    &.secondary-button {
      background-color: transparent;
      color: var(--white);

      &:hover {
        background-color: var(--white);
        color: var(--primary-color);
      }
    }
  }

  *.gaw-link-button,
  *.wl-add-but {
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;

    &::after {
      content: "";
      display: inline-block;
      width: 1rem;
      height: 1rem;
      background-image: url(/wp-content/uploads/2025/06/right-arrow.svg);
      background-size: contain;
      background-repeat: no-repeat;
      background-position: center;
      margin-left: 0.5rem;
      margin-top: -2px;
      transition: all 0.3s ease;
    }

    &.wl-add-but {
      background-color: transparent !important;
      padding: 0 !important;

      &::after {
        opacity: 1 !important;
        position: relative;
        right: 0;
      }
    }

    &:hover::after {
      transform: translateX(10px);
    }
  }

  .testimonials-slider {
    .swiper-wrapper {
      padding: 0 2rem;
    }

    .et_pb_post {
      .post-content {
        flex-direction: column-reverse;
        justify-content: space-between;
        padding: 36px 33px;
        border-radius: var(--radius-large);
        background-color: var(--light-blue);
        color: var(--brown);

        .post-data {
          text-align: center;
          margin-bottom: 1rem;
        }

        h2.entry-title {
          color: var(--primary-color);
        }
      }

      /* Disable all links in testimonial slider */
      a {
        pointer-events: none;
        cursor: default;
        text-decoration: none;
        color: inherit;
      }

      /* Remove hover effects on links */
      a:hover {
        text-decoration: none;
        color: inherit;
      }

      /* Make sure title links don't change color */
      h2.entry-title a {
        color: var(--primary-color);
      }

      h2.entry-title a:hover {
        color: var(--primary-color);
      }
    }

    .swiper-button-next,
    .swiper-button-prev {
      &::after {
        content: "";
        display: block;
        width: 2.2rem;
        height: 2.2rem;
        background-position: center;
        background-size: contain;
        background-repeat: no-repeat;
        background-image: url(/wp-content/uploads/2025/06/slider-right-arrow.svg);
      }

      &.swiper-button-prev::after {
        transform: rotate(180deg);
      }
    }

    .swiper-pagination-bullet.swiper-pagination-bullet-active {
      background-color: var(--primary-color);
    }
  }

  /* Divi's Blurb Module */
  .et_pb_blurb {
    .et_pb_blurb_content {
      .et_pb_main_blurb_image {
        margin-bottom: 30px;

        .et_pb_image_wrap {
          img {
            border-radius: var(--radius-large);
          }
        }
      }
      .et_pb_blurb_container {
        h3.et_pb_module_header {
          margin-bottom: 20px;
        }
        .et_pb_blurb_description {
          font-size: var(--body-font-size);
          color: var(--brown);
        }
      }
    }

    &.gaw-core-value-blurb {
      .et_pb_blurb_content {
        .et_pb_main_blurb_image {
          height: 76px;
          display: flex;
          justify-content: center;

          .et_pb_image_wrap {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100%;
          }

          img {
            border-radius: 0;
          }
        }

        .et_pb_module_header {
          max-width: 380px;
          margin: 0 auto;
        }
      }
    }
  }

  .gaw-breadcrumb {
    a,
    span {
      font-size: var(--t-body);
      font-weight: 500;
      line-height: 1.3;
    }

    a {
      text-decoration: none;
      font-weight: 700;

      &:hover {
        text-decoration: underline;
        text-underline-offset: 4px;
      }
    }

    #gaw-inner-page-hero-section & {
      text-align: center;

      a,
      span {
        color: var(--white);
      }
    }
  }

  .et_pb_video {
    .et_pb_video_overlay_hover {
      background: rgba(0, 0, 0, 0.2);

      &:hover {
        background: rgba(0, 0, 0, 0.3);
      }

      .et_pb_video_play {
        height: 52px;
        width: 52px;
        border-radius: 50%;
        box-shadow: 0 0 4px 4px rgba(0, 0, 0, 0.5);
        z-index: 1;
        margin: 0;
        top: 50%;
        left: 50%;
        transform: translateX(-50%) translateY(-50%);
        position: relative;
        line-height: 1 !important;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: var(--blue);

        &::before {
          border-radius: 50%;
          padding: 0;
          border: none;
          font-size: 18px;
          color: var(--primary-color);
        }
      }
    }
  }

  .gaw-team-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 60px 24px;

    .gaw-team-member {
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;

      img {
        width: 300px;
        height: 300px;
        object-fit: cover;
        border-radius: 20px;
        margin-bottom: 20px;
      }

      h3 {
        color: var(--primary-color);
      }

      h5 {
        color: var(--primary-color);
      }

      p.gaw-team-member-content {
        margin-bottom: 24px;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.5;
        max-height: 4.5em; /* 3 lines × 1.5 line-height */
      }
    }

    @media (max-width: 980px) {
      & {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px 20px;
      }
    }

    @media (max-width: 480px) {
      & {
        grid-template-columns: 1fr;
        gap: 30px;
      }

      .gaw-team-member {
        margin-bottom: 30px;
      }

      .gaw-team-member img {
        width: 250px;
        height: 250px;
      }
    }
  }

  /* Image and Text Split Component */
  .gaw-image-text-split {
    .gaw-image-text-split__image,
    .gaw-image-text-split__text {
      flex: 1;
    }

    .gaw-image-text-split__image img {
      width: 100%;
      /* height: 100%; */
      height: auto !important;
      object-fit: cover;
      border-radius: var(--radius-large);
    }

    /* Divi-specific adjustments using CSS Grid */
    &.et_pb_row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 24px;
      align-items: stretch;
    }

    &.et_pb_row .et_pb_column {
      width: auto; /* Let Grid control the width */
      display: flex;
      flex-direction: column;
      margin-right: 0;
    }

    &.et_pb_row .et_pb_image {
      flex-grow: 1;
      display: flex;
      flex-direction: column;
      height: 100%;
      width: 100%;
    }

    &.et_pb_row .et_pb_image_wrap {
      flex-grow: 1;
      position: relative;
    }

    &.et_pb_row .et_pb_image_wrap img {
      /* Position image absolutely to remove it from layout flow */
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    @media (max-width: 980px) {
      /* Mobile layout: single column */
      &,
      &.et_pb_row {
        flex-direction: column;
        grid-template-columns: 1fr;
        gap: 0;
        margin-bottom: 40px;
      }

      .et_pb_column {
        margin-bottom: 0;

        &:first-child {
          margin-bottom: 24px;
        }
      }

      /* On reversed rows, flip the columns to make the image appear first */
      &.gaw-image-text-split--reversed > .et_pb_column:first-child,
      &.gaw-image-text-split--reversed > div:first-child {
        order: 2;
        margin-bottom: 0;
      }
      &.gaw-image-text-split--reversed > .et_pb_column:last-child,
      &.gaw-image-text-split--reversed > div:last-child {
        order: 1;
        margin-bottom: 24px;
      }

      /* Image styling for mobile */
      .gaw-image-text-split__image img,
      &.et_pb_row .et_pb_image_wrap img {
        max-width: 400px;
        max-height: 400px;
        border-radius: var(--radius-medium);
        object-fit: contain;
        position: static;
        height: auto;
        width: 100%;
        margin: 0 auto;
        display: block;
      }
    }
  }

  /* Articles: Single column, large card results */
  .gaw-articles-listing--cards {
    display: flex;
    flex-direction: column;
    gap: 2rem;

    .gaw-article-card {
      background: var(--white);
      border-radius: var(--radius-large);
      overflow: hidden;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      transition: all 0.3s ease;
      text-decoration: none;
      color: inherit;
      display: flex;
      height: 340px;

      &:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
      }

      .gaw-article-card-thumbnail {
        position: relative;
        width: 50%;
        flex-shrink: 0;
        overflow: hidden;
        height: 100%;
      }

      .gaw-article-card-image {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.3s ease;
      }

      .gaw-article-card-placeholder {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--light-blue);

        svg {
          width: 3rem;
          height: 3rem;
          color: var(--primary-color);
        }
      }

      .gaw-article-card-content {
        padding: 2rem;
        display: flex;
        flex-direction: column;
        gap: 1rem;
        width: 50%;
        justify-content: space-between;
      }

      .gaw-article-card-title {
        font-size: var(--t-h3);
        color: var(--primary-color);
        font-weight: 700;
        line-height: 1.3;
        margin: 0;
        margin-bottom: 10px;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }

      .gaw-article-card-meta {
        display: flex;
        align-items: center;
        gap: 1rem;
        font-size: var(--t-small);
        margin-bottom: 20px;

        .gaw-article-card-author,
        .gaw-article-card-date,
        .gaw-article-card-bullet {
          color: var(--primary-color);
          font-weight: 600;
        }

        span {
          color: var(--brown);
        }
      }

      .gaw-article-card-excerpt {
        color: var(--brown);
        line-height: 1.5;
        margin: 0;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 4;
        -webkit-box-orient: vertical;
      }

      .gaw-article-card-readmore {
        color: var(--primary-color);
        font-weight: 600;
        text-transform: uppercase;
        font-size: var(--t-small);
        letter-spacing: 0.5px;
        transition: color 0.3s ease;
        align-self: flex-start;
      }
    }

    @media (max-width: 980px) {
      .gaw-article-card {
        height: auto;
        flex-direction: column;

        .gaw-article-card-thumbnail {
          width: 100%;
          height: auto;
          aspect-ratio: none;
          max-height: 300px;
        }

        .gaw-article-card-content {
          width: 100%;
          padding: 1.5rem;
        }
      }
    }
  }

  /* Hymn Resources Container Styling */
  .hymn-resources-container {
    margin: 0 auto;
    max-width: 800px;

    .hymn-resource-card {
      width: 100%;
      margin-bottom: 1.5rem;
      padding: 1.25rem;
      border: 1px solid var(--light-blue-2);
      border-radius: 8px;
      background: var(--blue);

      h2,
      h4 {
        color: var(--primary-color);
      }
    }

    .hymn-resource-title {
      margin-bottom: 1rem;
      font-size: 1.5rem;
    }

    .recordings-tabs {
      margin-top: 0.5rem;
    }

    .recordings-tab-nav {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      margin-bottom: 1rem;
      border-bottom: 2px solid var(--light-blue-2);

      .recording-tab-btn {
        display: flex;
        text-align: left;
        align-items: center;
        line-height: 1 !important;
        vertical-align: middle;
        padding: 0.75rem 1rem;
        background: var(--light-blue-2);
        border: 1px solid var(--light-blue-2);
        border-bottom: none;
        cursor: pointer;
        transition: all 0.3s ease;
        font-weight: 600;
        color: var(--brown);
        border-radius: 6px 6px 0 0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

        &:hover {
          background-color: var(--light-blue);
          color: var(--primary-color);
          transform: translateY(-1px);
          box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
        }

        &.active {
          color: var(--primary-color);
          background-color: var(--white);
          border-color: var(--light-blue);
          border-bottom-color: var(--white);
          transform: translateY(-1px);
          box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);

          .recording-icon {
            color: var(--primary-color);
          }
        }

        .recording-icon {
          height: 100%;
          display: flex;
          flex-direction: column;
          justify-content: center;
          font-size: 1.5rem;
          margin-right: 0.7rem;
          color: var(--brown);
        }
      }
    }

    .recordings-tab-content {
      .recording-tab-panel {
        display: none;
        animation: fadeIn 0.3s ease-in-out;

        &.active {
          display: block;
        }
      }
    }

    .recording-embed {
      margin-top: 0.5rem;

      .fluid-width-video-wrapper {
        border-radius: var(--radius-medium);
        overflow: hidden;
      }
    }

    .recording-link {
      margin-top: 0.5rem;

      .gaw-link-button .dashicons {
        font-size: 1.1em;
        line-height: 1;
        margin-right: 0.4rem;
        vertical-align: middle;
      }
    }

    .recording-no-media {
      color: var(--brown);
      font-style: italic;
      margin-top: 0.5rem;
    }
  }

  /* Back to Top Button Styling */
  .back-to-top-button {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 2px solid var(--light-blue);
    color: var(--primary-color);
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

    &:hover {
      background-color: var(--light-blue);
      color: var(--primary-color);
      transform: translateX(-50%) translateY(-2px);
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    }
  }

  /* Heros */

  #gaw-inner-page-hero-section {
    &.gaw-has-background-blob::after {
      background-size: 120%;
      background-position: 45% 100%;
    }
  }

  /* Divi Accordions and Toggles */
  .et_pb_accordion,
  .et_pb_toggle {
    &.et_pb_toggle_close,
    &.et_pb_toggle_open {
      background-color: transparent;
      border: none;
    }

    .et_pb_toggle_title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      color: var(--primary-color);
      font-size: var(--t-h3);
      padding-right: 0;

      &::after {
        content: "";
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;
        min-width: 16px;
        width: 16px;
        min-height: 16px;
        height: 16px;
        background-image: url(/wp-content/uploads/2025/06/arrow-right.svg);
      }

      .et_pb_toggle_open &::after {
        background-image: url(/wp-content/uploads/2025/06/arrow-up.svg);
      }

      &::before {
        display: none;
      }
    }

    .et_pb_toggle_content {
      li {
        font-size: var(--t-body);
        margin-bottom: 0.5rem;
      }

      ul,
      ol {
        padding-left: 2.5rem;
      }

      h5 {
        margin-bottom: 0.5rem;
      }

      p {
        font-size: var(--t-body);
        margin-bottom: 1rem;
      }

      p:last-of-type {
        padding-bottom: 1em;
      }

      img {
        border-radius: var(--radius-medium);
        overflow: hidden;
      }
    }
  }

  /* Display a row of images, probably in a WYSIWYG */
  .gaw-image-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1rem 0;
    justify-content: flex-start;
    align-items: flex-start;
  }

  .gaw-image-row img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    flex: 0 0 auto; /* Don't grow or shrink by default */
  }

  /* 2 columns max */
  .gaw-image-row--2 img {
    max-width: calc(50% - 1rem);
  }

  /* 3 columns max */
  .gaw-image-row--3 img {
    max-width: calc(33.333% - 1rem);
  }

  /* 4 columns max (default) */
  .gaw-image-row img {
    max-width: calc(25% - 1rem);
  }

  @media (max-width: 980px) {
    .gaw-image-row img,
    .gaw-image-row--2 img,
    .gaw-image-row--3 img {
      max-width: calc(50% - 1rem);
    }
  }

  @media (max-width: 480px) {
    .gaw-image-row img,
    .gaw-image-row--2 img,
    .gaw-image-row--3 img {
      max-width: 100%;
    }
  }

  .blue-card-text-module {
    border-radius: var(--radius-large);
    overflow: hidden;
    background-color: var(--light-blue);
    padding: 40px 30px;
    text-align: center;

    h4 {
      margin-bottom: 30px;
      color: var(--primary-color);
    }
  }

  .styled-icon-row {
    h3 {
      text-align: center;
      margin-bottom: 20px;
      color: var(--primary-color);
    }

    .styled-icon {
      margin: 0 auto 20px;
    }
  }

  .styled-icon {
    width: 93px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--pastel-orange);
    border-top-left-radius: var(--radius-large);
    overflow: hidden;
    padding: 8px;

    img {
      width: 100%;
      height: 100%;
      max-width: 100px;
      object-fit: contain;
    }
  }

  /* Single Post */
  .single-post & {
    .gaw-article-card-meta {
      display: flex;
      align-items: center;
      gap: 1rem;
      font-size: var(--t-small);
      margin-bottom: 40px;

      .gaw-article-card-author,
      .gaw-article-card-date,
      .gaw-article-card-bullet {
        color: var(--primary-color);
        font-weight: 600;
        margin: 0;
      }
    }
  }

  /* Divi overlays */
  .divioverlay {
    display: flex;
    align-items: center;

    .overlay-close {
      right: 30px;
      top: 30px;
      font-size: 6rem !important;
      font-weight: 300 !important;
      color: var(--primary-color);
    }
  }

  .bvi-large-numbered-list {
    ol {
      li {
        margin-bottom: 10px;

        &::marker {
          font-size: 1.5rem;
          color: var(--primary-color);
          font-weight: 600;
          margin-right: 10px;
        }
      }
    }
  }
}

/* Video Lightbox */
.gaw-video-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 10010;

  &.is-open {
    opacity: 1;
    visibility: visible;
  }

  .gaw-video-modal__close {
    position: fixed;
    top: 40px;
    right: 20px;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 34px;
    line-height: 1;
    cursor: pointer;
    z-index: 10012;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);

    &:hover {
      background: rgba(255, 255, 255, 0.15);
    }
  }
}

.gaw-video-modal {
  position: fixed;
  z-index: 10011;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%);
  width: min(92vw, 960px);
  max-width: 96vw;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-medium);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;

  &.is-open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%);
  }

  &__content,
  &__content iframe,
  &__content video {
    width: 100%;
    height: 100%;
    display: block;
  }

  .gaw-video-modal__content,
  iframe {
    height: 100% !important;
    width: 100% !important;
  }

  /* close button now lives in overlay */
}

body.gaw-video-no-scroll {
  overflow: hidden;
  touch-action: none;
}

/*** Team Image Grid ***/
.gaw-team-image-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  max-width: 100%;
  margin: 0 auto;
}

.gaw-team-image-item {
  display: flex;
  justify-content: center;
  align-items: center;
}

.gaw-team-grid-link {
  display: block;
  text-decoration: none;
  transition: transform 0.3s ease;
}

.gaw-team-grid-link:hover {
  text-decoration: none;
}

.gaw-team-grid-image {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  border: 3px solid var(--light-blue, #e8f4f8);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gaw-team-grid-image:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .gaw-team-image-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
  }

  .gaw-team-grid-image {
    width: 100px;
    height: 100px;
  }
}

@media (max-width: 480px) {
  .gaw-team-image-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .gaw-team-grid-image {
    width: 80px;
    height: 80px;
  }
}
