@use "../../styles/variables.scss" as *;

.search {
  min-width: fit-content;
  max-width: 14rem;
  flex-grow: 0.3;

  & > #search-icon {
    background-color: var(--lightgray);
    border-radius: 4px;
    height: 2rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    white-space: nowrap;

    & > div {
      flex-grow: 1;
    }

    & > p {
      display: inline;
      padding: 0 1rem;
    }

    & svg {
      cursor: pointer;
      width: 18px;
      min-width: 18px;
      margin: 0 0.5rem;

      .search-path {
        stroke: var(--darkgray);
        stroke-width: 2px;
        transition: stroke 0.5s ease;
      }
    }
  }

  & > #search-container {
    position: fixed;
    contain: layout;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    overflow-y: auto;
    display: none;
    backdrop-filter: blur(4px);

    &.active {
      display: inline-block;
    }

    & > #search-space {
      width: 50%;
      margin-top: 12vh;
      margin-left: auto;
      margin-right: auto;

      @media all and (max-width: $fullPageWidth) {
        width: 90%;
      }

      & > * {
        width: 100%;
        border-radius: 5px;
        background: var(--light);
        box-shadow:
          0 14px 50px rgba(27, 33, 48, 0.12),
          0 10px 30px rgba(27, 33, 48, 0.16);
        margin-bottom: 2em;
      }

      & > input {
        box-sizing: border-box;
        padding: 0.5em 1em;
        font-family: var(--bodyFont);
        color: var(--dark);
        font-size: 1.1em;
        border: 1px solid var(--lightgray);

        &:focus {
          outline: none;
        }
      }

      & > #search-layout {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        opacity: 0;

        & > * {
          height: calc(75vh - 20em);
          background: none;
          border-radius: 5px;
          border: 1px solid var(--lightgray); // Border to define the box
        }

        @media all and (max-width: $mobileBreakpoint) {
          display: block;
          & > *:not(#results-container) {
            display: none !important;
          }

          & > #results-container {
            width: 100%;
            height: auto;
          }
        }

        & > #preview-container {
          display: block;
          box-sizing: border-box;
          overflow: hidden;

          & .preview-inner {
            padding: 1em;
            height: 100%;
            box-sizing: border-box;
            overflow-y: auto;
            font-family: inherit;
            font-size: 1.1em;
            color: var(--dark);
            line-height: 1.5em;
            font-weight: 400;
            background: var(--light);
            border-radius: 5px;
            box-shadow:
              0 14px 50px rgba(27, 33, 48, 0.12),
              0 10px 30px rgba(27, 33, 48, 0.16);
          }
        }

        & > #results-container {
          overflow-y: auto;

          & .result-card {
            padding: 1em;
            cursor: pointer;
            transition: background 0.2s ease;
            width: 100%;
            display: block;
            box-sizing: border-box;

            // normalize card props
            font-family: inherit;
            font-size: 100%;
            line-height: 1.15;
            margin: 0;
            text-transform: none;
            text-align: left;
            background: var(--light);
            outline: none;
            font-weight: inherit;

            & .highlight {
              color: var(--secondary);
              font-weight: 700;
            }

            &:hover,
            &:focus {
              background: var(--lightgray);
            }

            & > h3 {
              margin: 0;
            }

            & > ul > li {
              margin: 0;
              display: inline-block;
              white-space: nowrap;
              margin: 0;
              overflow-wrap: normal;
            }

            & > ul {
              list-style: none;
              display: flex;
              padding-left: 0;
              gap: 0.4rem;
              margin: 0;
              margin-top: 0.45rem;
              box-sizing: border-box;
              overflow: hidden;
              background-clip: border-box;
            }

            & > ul > li > p {
              border-radius: 8px;
              background-color: var(--highlight);
              overflow: hidden;
              background-clip: border-box;
              padding: 0.03rem 0.4rem;
              margin: 0;
              color: var(--secondary);
              opacity: 0.85;
            }

            & > ul > li > .match-tag {
              color: var(--tertiary);
              font-weight: bold;
              opacity: 1;
            }

            & > p {
              margin-bottom: 0;
            }
          }
        }
      }
    }
  }
}