/*
|--------------------------------------------------------------------------
| Word Intelligence search overlay
|--------------------------------------------------------------------------
*/

body.search-modal-open {
    overflow: hidden;
}

.search-modal,
.search-modal * {
    box-sizing: border-box;
}

.search-modal [hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Main overlay */
.search-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;

    display: grid;
    place-items: center;

    padding: 30px 38px;

    visibility: hidden;
    opacity: 0;
    pointer-events: none;

    transition:
        opacity 180ms ease,
        visibility 180ms ease;
}

.search-modal.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.search-modal__overlay {
    position: absolute;
    inset: 0;

    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(1px);
}

/* White modal panel */
.search-modal__panel {
    position: relative;
    z-index: 1;

    display: flex;
    width: min(1460px, 100%);
    height: min(92vh, 920px);
    flex-direction: column;

    overflow: hidden;

    border-radius: 12px;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #222222);

    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);

    opacity: 0;
    transform: translateY(-16px) scale(0.99);

    transition:
        opacity 200ms ease,
        transform 200ms ease;
}

.search-modal.is-open .search-modal__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Search header */
.search-modal__header {
    position: relative;
    z-index: 3;

    display: flex;
    align-items: center;
    gap: 18px;

    flex: 0 0 auto;

    padding: 28px 44px 20px;

    border-bottom: 1px solid rgba(120, 120, 120, 0.12);
    background: var(--bg-primary, #ffffff);
}

.search-modal__search {
    position: relative;
    flex: 1;
}

.search-modal__input {
    display: block;
    width: 100%;
    min-height: 60px;

    padding: 15px 62px 15px 24px;

    border: 0;
    border-radius: 999px;
    outline: 0;

    background: var(--card-bg, #f1f1f1);
    color: var(--text-primary, #222222);

    font-family: "Inter", sans-serif;
    font-size: 1rem;
}

.search-modal__input::placeholder {
    color: var(--text-secondary, #777777);
    opacity: 1;
}

/* .search-modal__input:focus {
    box-shadow:
        0 0 0 3px rgba(249, 168, 37, 0.17),
        0 7px 22px rgba(0, 0, 0, 0.07);
} */

.search-modal__search-icon {
    position: absolute;
    top: 50%;
    right: 25px;

    transform: translateY(-50%);

    color: var(--text-secondary, #666666);
    font-size: 1.1rem;

    pointer-events: none;
}

.search-modal__clear {
    position: absolute;
    top: 50%;
    right: 20px;

    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;

    transform: translateY(-50%);

    border: 0;
    border-radius: 50%;

    background: rgba(100, 100, 100, 0.13);
    color: var(--text-primary, #222222);

    cursor: pointer;
}

/*
The search icon is hidden when the clear button becomes visible.
JavaScript will apply this class.
*/
.search-modal__search.has-value .search-modal__search-icon {
    display: none;
}

.search-modal__close {
    display: inline-flex;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 50%;

    background: var(--card-bg, #f1f1f1);
    color: var(--text-secondary, #ffffff);

    font-size: 1.25rem;
    cursor: pointer;
}

.search-modal__close:hover,
.search-modal__clear:hover {
    color: var(--text-primary, #111111);
    transform: scale(1.04);
}

.search-modal__clear:hover {
    transform: translateY(-50%) scale(1.04);
}

/* Scrollable modal content */
.search-modal__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 325px;
    gap: 30px;

    flex: 1 1 auto;

    min-height: 0;
    padding: 18px 44px 42px;

    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.search-modal__body::-webkit-scrollbar {
    width: 10px;
}

.search-modal__body::-webkit-scrollbar-track {
    background: transparent;
}

.search-modal__body::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: rgba(100, 100, 100, 0.42);
    background-clip: padding-box;
}

/* Main results column */
.search-modal__main {
    min-width: 0;
}

.search-modal__summary {
    min-height: 32px;
    margin-bottom: 5px;
}

.search-modal__summary p {
    margin: 0;
    color: var(--text-secondary, #666666);

    font-family: "Inter", sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
}

.search-modal__results {
    min-width: 0;
}

/* Individual post */
.search-modal__article {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 132px;
    grid-template-areas: "content image";
    gap: 25px;

    padding: 15px 0 22px;

    border-bottom: 1px solid rgba(120, 120, 120, 0.14);
}

.search-modal__article:last-child {
    border-bottom: 0;
}

.search-modal__article-content {
    grid-area: content;
    min-width: 0;
}

.search-modal__article-image-link {
    grid-area: image;
    display: block;
    align-self: start;
}

.search-modal__article-image {
    display: block;
    width: 132px;
    height: 162px;

    border-radius: 9px;

    object-fit: cover;
    background: var(--card-bg, #eeeeee);
}

.search-modal__article-title {
    margin: 0 0 4px;

    color: var(--text-primary, #111111);

    font-family: "PT Serif", Georgia, serif;
    font-size: clamp(1.65rem, 2vw, 2.05rem);
    font-weight: 700;
    line-height: 1.14;
}

.search-modal__article-title a {
    color: inherit;
    text-decoration: none;
}

.search-modal__article-title a:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

.search-modal__article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;

    margin-bottom: 16px;

    color: var(--text-secondary, #707070);

    font-family: "Inter", sans-serif;
    font-size: 0.76rem;
    font-weight: 650;
    letter-spacing: 0.015em;
    text-transform: uppercase;
}

.search-modal__read-time {
    display: inline-flex;
    min-height: 23px;
    align-items: center;

    padding: 3px 8px;

    border-radius: 4px;

    background: var(--card-bg, #eeeeee);
    color: var(--text-secondary, #666666);
}

.search-modal__article-excerpt {
    max-width: 820px;
    margin: 0 0 17px;

    color: var(--text-primary, #333333);

    font-family: "Inter", sans-serif;
    font-size: 1rem;
    line-height: 1.55;
}

.search-modal__article-link {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;

    padding: 8px 18px;

    border-radius: 999px;

    background: #050505;
    color: #ffffff;

    font-family: "PT Serif", Georgia, serif;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
}

.search-modal__article-link:hover {
    background: var(--accent-color);
    color: #111111;
}

/* Loading, empty and error messages */
.search-modal__message {
    display: flex;
    min-height: 260px;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    padding: 35px 20px;

    color: var(--text-secondary, #666666);
    text-align: center;
}

.search-modal__message > i {
    margin-bottom: 14px;
    font-size: 2rem;
}

.search-modal__message h3 {
    margin: 0 0 8px;

    color: var(--text-primary, #222222);

    font-family: "PT Serif", Georgia, serif;
    font-size: 1.55rem;
}

.search-modal__message p {
    max-width: 470px;
    margin: 0;

    font-family: "Inter", sans-serif;
    line-height: 1.55;
}

.search-modal__message--error > i {
    color: #b42318;
}

.search-modal__retry {
    margin-top: 18px;
    padding: 10px 18px;

    border: 0;
    border-radius: 999px;

    background: #111111;
    color: #ffffff;

    font-weight: 650;
    cursor: pointer;
}

.search-modal__load-more,
.search-modal__end {
    padding: 24px 12px;

    color: var(--text-secondary, #666666);

    font-family: "Inter", sans-serif;
    font-size: 0.9rem;
    font-style: italic;
    text-align: center;
}

.search-modal__load-more span {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.search-modal__sentinel {
    width: 100%;
    height: 2px;
}

/* Right sidebar */
.search-modal__sidebar {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 22px;

    align-self: start;
}

/*
|--------------------------------------------------------------------------
| Keep the desktop sidebar visible while article results scroll
|--------------------------------------------------------------------------
*/

@media (min-width: 761px) {
    .search-modal__sidebar {
        position: sticky;
        top: 0;

        max-height: calc(92vh - 145px);
        padding-right: 5px;

        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-gutter: stable;
    }

    .search-modal__sidebar::-webkit-scrollbar {
        width: 6px;
    }

    .search-modal__sidebar::-webkit-scrollbar-track {
        background: transparent;
    }

    .search-modal__sidebar::-webkit-scrollbar-thumb {
        border-radius: 999px;
        background: rgba(100, 100, 100, 0.35);
    }
}

.search-modal__widget {
    padding: 22px;

    border-radius: 9px;

    background: var(--card-bg, #f2f2f2);
}

.search-modal__widget h3 {
    margin: 0 0 19px;

    color: var(--text-primary, #111111);

    font-family: "Inter", sans-serif;
    font-size: 1.28rem;
    font-weight: 750;
}

.search-modal__category-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.search-modal__category-list li {
    border-bottom: 1px solid rgba(120, 120, 120, 0.2);
}

.search-modal__category-list li:last-child {
    border-bottom: 0;
}

.search-modal__category {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    padding: 12px 0;

    border: 0;

    background: transparent;
    color: var(--text-primary, #222222);

    font-family: "Inter", sans-serif;
    font-size: 0.98rem;
    text-align: left;

    cursor: pointer;
}

.search-modal__category small {
    color: var(--text-secondary, #777777);
}

.search-modal__category:hover,
.search-modal__category.active {
    color: #ffb534;
}

.search-modal__category.active {
    font-weight: 700;
}

.search-modal__see-more {
    display: block;
    margin-top: 14px;

    color: var(--text-secondary, #666666);

    font-family: "Inter", sans-serif;
    font-size: 0.84rem;
    text-align: right;
    text-decoration: none;
}

.search-modal__see-more:hover {
    color: #ffb534;
}

/* Most Read */
.search-modal__most-read {
    margin: 0;
    padding: 0;

    list-style: none;
    counter-reset: search-most-read;
}

.search-modal__most-read li {
    counter-increment: search-most-read;

    position: relative;

    min-height: 49px;
    padding: 0 0 15px 35px;
}

.search-modal__most-read li::before {
    content: counter(search-most-read);

    position: absolute;
    top: 0;
    left: 0;

    color: var(--text-primary, #111111);

    font-family: "Inter", sans-serif;
    font-size: 1.35rem;
    font-weight: 750;
}

.search-modal__most-read a {
    display: block;
    color: inherit;
    text-decoration: none;
}

.search-modal__most-read a:hover .search-modal__most-read-title {
    color: #ffb534;
}

.search-modal__most-read-title {
    display: block;

    color: var(--text-primary, #111111);

    font-family: "Inter", sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.25;
}

.search-modal__most-read-meta {
    display: block;
    margin-top: 3px;

    color: var(--text-secondary, #777777);

    font-family: "Inter", sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.3;
    text-transform: uppercase;
}

.search-modal__sidebar-empty {
    padding-left: 0 !important;
    color: var(--text-secondary, #777777);
}

.search-modal__sidebar-empty::before {
    display: none;
}



/* Dark mode adjustments */
.dark-mode .search-modal__overlay {
    background: rgba(0, 0, 0, 0.72);
}

.dark-mode .search-modal__article-link,
.dark-mode .search-modal__retry {
    background: #f5f5f5;
    color: #111111;
}

.dark-mode .search-modal__article-link:hover {
    background: #f9a825;
    color: #000;
}

.dark-mode .search-modal__input {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* Tablets */
@media (max-width: 1000px) {
    .search-modal {
        padding: 20px;
    }

    .search-modal__panel {
        height: calc(100vh - 40px);
    }

    .search-modal__body {
        grid-template-columns: minmax(0, 1fr) 280px;
        gap: 22px;

        padding-right: 28px;
        padding-left: 28px;
    }

    .search-modal__header {
        padding-right: 28px;
        padding-left: 28px;
    }

    .search-modal__article {
        grid-template-columns: minmax(0, 1fr) 118px;
        gap: 18px;
    }

    .search-modal__article-image {
        width: 118px;
        height: 150px;
    }
}

/* Mobile */
@media (max-width: 760px) {
    .search-modal {
        align-items: start;
        padding: 8px;
    }

    .search-modal__panel {
        width: 100%;
        height: calc(100dvh - 16px);

        border-radius: 13px;
    }

    .search-modal__header {
        gap: 10px;
        padding: 12px 12px 10px;
    }

    .search-modal__input {
        min-height: 50px;
        padding: 11px 50px 11px 18px;

        font-size: 0.95rem;
    }

    .search-modal__search-icon {
        right: 19px;
    }

    .search-modal__clear {
        right: 12px;
    }

    .search-modal__close {
        width: 40px;
        height: 40px;
        flex-basis: 40px;

        font-size: 1.05rem;
    }

    .search-modal__body {
        display: block;

        padding: 8px 20px 34px;

        overflow-y: auto;
    }

    .search-modal__sidebar {
        display: none;
    }

    .search-modal__summary {
        min-height: 26px;
    }

    .search-modal__article {
        grid-template-columns: minmax(0, 1fr) 126px;
        gap: 14px;

        padding: 16px 0 26px;
    }

    .search-modal__article-image {
        width: 126px;
        height: 170px;
    }

    .search-modal__article-title {
        font-size: 1.62rem;
    }

    .search-modal__article-meta {
        align-items: flex-start;
        margin-bottom: 12px;

        font-size: 0.72rem;
    }

    .search-modal__article-excerpt {
        font-size: 0.93rem;
        line-height: 1.48;
    }

    .search-modal__article-link {
        min-height: 38px;
        padding: 5px 17px;
        font-size: 0.68rem;
    }
}

/* Very small phones */
@media (max-width: 430px) {
    .search-modal__body {
        padding-right: 14px;
        padding-left: 14px;
    }

    .search-modal__article {
        grid-template-columns: minmax(0, 1fr) 108px;
        gap: 11px;
    }

    .search-modal__article-image {
        width: 108px;
        height: 150px;
    }

    .search-modal__article-title {
        font-size: 1.43rem;
    }

    .search-modal__article-excerpt {
        font-size: 0.88rem;
    }
}

/* Respect users who disable animations */
@media (prefers-reduced-motion: reduce) {
    .search-modal,
    .search-modal__panel {
        transition: none;
    }
}

/*
|--------------------------------------------------------------------------
| Longer desktop search excerpts
|--------------------------------------------------------------------------
*/

@media (min-width: 992px) {
    .search-modal__article-excerpt {
        display: block;

        max-height: none;

        overflow: visible;

        -webkit-box-orient: initial;
        -webkit-line-clamp: unset;
        line-clamp: unset;
    }
}

/*
|--------------------------------------------------------------------------
| Generic calendar inside the web search modal
|--------------------------------------------------------------------------
|
| The modal receives the same live .word-calendar-widget used by
| the normal sidebar and mobile navigation.
|
*/

.search-modal__generic-calendar[hidden],

.search-modal__generic-calendar {
    width: 100%;
    min-width: 0;
}

.search-modal__generic-calendar
.word-calendar-widget {
    width: 100%;
    max-width: none;

    margin-top: 0;
    margin-bottom: 0;
}

.search-modal__generic-calendar
.word-calendar-widget
.calendar-footer {
    margin:
        -10px
        12px
        16px;
}

/*
 * Prevent the generic calendar's modal version from
 * receiving an unnecessary second outer shadow.
 */
.search-modal__generic-calendar
.word-calendar-widget--search-modal {
    box-shadow: none;
    padding-bottom: 1rem;
}

/*
|--------------------------------------------------------------------------
| At mobile/tablet widths
|--------------------------------------------------------------------------
|
| The real calendar remains controlled by the mobile navigation.
| The search-modal sidebar is already hidden by the existing
| responsive search-modal design.
|
*/

@media (max-width: 1023px) {
    .search-modal__generic-calendar {
        display: none !important;
    }
}