/* Custom Search Styles - Matching Figma Design Exactly */
/* Version: 15.2 */

/* Import Raleway font */
@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@400;500;600;700&display=swap');

/* Variables */
:root {
    --csp-primary-color: #1a273b;
    --csp-secondary-color: #59cace;
    --csp-text-color: #1a273b;
    --csp-background-color: #ffffff;
    --csp-item-background: #efefef;
    --csp-border-radius: 8px;
    --csp-transition-duration: 0.3s;
    --csp-box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
    --csp-font-family: 'Raleway', sans-serif;
    --csp-overlay-color: rgba(89, 202, 206, 0.85);
}

/* ========================================
   FULLSCREEN OVERLAY - Appears when search is active
   ======================================== */
.custom-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--csp-overlay-color);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--csp-transition-duration) ease, visibility var(--csp-transition-duration) ease;
    pointer-events: none;
}

.custom-search-overlay.custom-show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 40 !important; /* Lower than header */
}

/* Note: Body scroll lock removed to allow page scrolling when search is open */
/* The search results container handles its own scrolling via max-height and overflow-y */
body.custom-search-active {
    /* Allow normal scrolling - results area has its own scroll */
}

/* Base Styles - Figma: 571px max-width */
.custom-search-form {
    font-family: var(--csp-font-family);
    max-width: 571px;
    min-width: 280px;
    margin: inherit !important;
    padding: 0;
    position: relative;
    z-index: 1 !important;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.custom-search-form:has(.custom-search-bar[aria-expanded="true"]) {
    z-index: 50 !important; /* Lower than header so it scrolls behind it */
}

.custom-search-form * {
    font-family: var(--csp-font-family);
    box-sizing: border-box;
}

/* ========================================
   SEARCH BAR - Figma: 571x75px
   ======================================== */
.custom-search-bar {
    width: 100%;
    display: flex;
    align-items: center;
    background-color: var(--csp-background-color);
    color: var(--csp-text-color);
    border-radius: var(--csp-border-radius);
    padding: 0 35px 0 79px;
    box-shadow: var(--csp-box-shadow);
    cursor: pointer;
    position: relative;
    height: 75px;
}

/* Search Icon - Figma: 25x25px, 29px from left */
.custom-search-icon {
    width: 25px;
    height: 25px;
    position: absolute;
    left: 29px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
}

.custom-search-icon svg {
    width: 25px;
    height: 25px;
    fill: var(--csp-text-color);
}

.custom-search-icon .search-path,
.custom-search-icon .close-path {
    transition: opacity var(--csp-transition-duration) ease;
}

.custom-search-icon .close-path {
    opacity: 0;
}

.custom-search-form.custom-done .custom-search-icon .close-path {
    opacity: 1;
}

.custom-search-form.custom-done .custom-search-icon .search-path {
    opacity: 0;
}

/* Dropdown Arrow - Figma: right side, ~13x6px rotated */
.custom-dropdown-icon {
    position: absolute;
    right: 47px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--csp-text-color);
    transition: transform 0.3s ease;
}

.custom-search-form.custom-done .custom-dropdown-icon {
    transform: translateY(-50%) rotate(180deg);
}

/* Search heading - Figma: 16px Raleway Medium */
.custom-search-heading {
    color: var(--csp-text-color) !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 16px !important;
    line-height: normal !important;
    font-weight: 500 !important;
    font-family: var(--csp-font-family) !important;
}

/* ========================================
   RESULTS CONTAINER - Figma: 571x355px max, 8px radius
   ======================================== */
.custom-search-results {
    position: absolute;
    left: 0;
    top: calc(100% + 19px);
    width: 100%;
    background-color: var(--csp-background-color);
    border-radius: var(--csp-border-radius);
    box-shadow: var(--csp-box-shadow);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--csp-transition-duration) ease, visibility var(--csp-transition-duration) ease;
    z-index: 1001;
    max-height: 355px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* Custom Scrollbar - Figma: 7px wide, #8d8d8d color */
.custom-search-results::-webkit-scrollbar {
    width: 7px;
}

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

.custom-search-results::-webkit-scrollbar-thumb {
    background-color: #8d8d8d;
    border-radius: 0;
}

.custom-search-results {
    scrollbar-width: thin;
    scrollbar-color: #8d8d8d transparent;
}

.custom-search-results.custom-show {
    opacity: 1;
    visibility: visible;
}

/* UL container - Figma: 16px padding */
.custom-search-form ul {
    list-style: none;
    margin: 0;
    padding: 16px;
}

/* Subject Areas Heading - Figma: 16px bold */
h4.custom-subject-heading {
    color: var(--csp-text-color) !important;
    font-size: 16px !important;
    line-height: 1.4 !important;
    padding: 0 !important;
    margin: 0 0 15px 0 !important;
    font-weight: 700 !important;
    font-family: var(--csp-font-family) !important;
}

/* ========================================
   FIRST STEP - Study Areas
   Figma specs:
   - Card: 538x157px, #efefef background
   - Left border: 9px wide colored stripe
   - Gap between cards: 11px
   - Title: 20px Raleway Bold, 32px from top, 30px from left border
   - Description: 14px/20px, 36px below title top
   ======================================== */
.custom-study-areas li {
    margin: 0 0 11px 0;
    background-color: var(--csp-item-background);
    border-radius: 0;
    padding: 0;
    display: flex;
    align-items: stretch;
    transition: background-color var(--csp-transition-duration) ease;
    overflow: hidden;
    position: relative;
    height: 157px;
}

.custom-study-areas li:last-child {
    margin-bottom: 0;
}

/* Left color border - Figma: 9px wide */
.custom-study-areas li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 9px;
    background-color: var(--accent-color, #5d769d);
}

/* Card link padding - Figma: 32px top, 39px from border, 80px right for arrow */
.custom-study-areas li a {
    padding: 32px 80px 32px 39px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
}

.custom-study-areas li:hover {
    background-color: #e5e5e5;
}

/* Study area title - Figma: 20px Raleway Bold */
.custom-study-areas .custom-text-content h5 {
    font-size: 20px !important;
    font-weight: 700 !important;
    margin: 0 0 4px !important;
    line-height: 23px !important;
    color: var(--csp-text-color) !important;
}

/* Study area description - Figma: 14px Raleway Medium, 20px line-height */
.custom-study-areas .custom-text-content p {
    font-size: 14px !important;
    line-height: 20px !important;
    font-weight: 500 !important;
    margin: 0 !important;
    color: var(--csp-text-color) !important;
    max-width: 422px;
}

/* Arrow for study areas - Figma: 21x16px, vertically centered, 39px from right */
.custom-study-areas .custom-arrow {
    position: absolute;
    right: 39px !important;
    top: 50%;
    transform: translateY(-50%);
}

/* ========================================
   SECOND STEP - Subject Areas
   Figma: 538x123px each, with icon
   10px gap between cards
   ======================================== */
.custom-subject-areas li {
    margin: 0 0 10px 0;
    background-color: var(--csp-item-background);
    border-radius: 0;
    padding: 0;
    display: flex;
    align-items: center;
    transition: background-color var(--csp-transition-duration) ease;
    height: 123px;
}

.custom-subject-areas li:last-child {
    margin-bottom: 0;
}

.custom-subject-areas li a {
    padding: 0 24px 0 35px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
}

.custom-subject-areas li:hover {
    background-color: #e5e5e5;
}

/* Subject area title - Figma: 16px Raleway Bold */
.custom-subject-areas .custom-text-content h5 {
    font-size: 16px !important;
    font-weight: 700 !important;
    margin: 0 0 6px !important;
    line-height: 19px !important;
    color: var(--csp-text-color) !important;
}

/* Subject area description - Figma: 14px, line-height 20px */
.custom-subject-areas .custom-text-content p {
    font-size: 14px !important;
    line-height: 20px !important;
    font-weight: 500 !important;
    margin: 0 !important;
    color: var(--csp-text-color) !important;
    max-width: 347px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Link styles */
.custom-search-form li a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--csp-text-color);
    flex: 1;
}

/* Icon for subject areas - Figma: 48x43px */
.custom-result-icon {
    width: 48px;
    height: 43px;
    margin-right: 35px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
    object-fit: contain;
}

.custom-result-icon.svg-icon {
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
}

/* Text content */
.custom-text-content {
    display: flex !important;
    flex-direction: column;
    flex: 0 0 auto !important;
    gap: 10px;
    min-width: 0;
}

/* Arrow - Figma: 21x16px */
.custom-arrow {
    margin-left: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    right: 39px !important;
}

.custom-arrow svg {
    width: 21px;
    height: 16px;
    transition: transform var(--csp-transition-duration) ease;
}

.custom-search-form li:hover .custom-arrow svg {
    transform: translateX(5px);
}

/* No Results Styles */
.custom-no-results {
    text-align: center;
    padding: 0 16px 16px;
    background-color: transparent;
    margin: 0;
}

.custom-no-results p {
    margin: 10px 0;
    color: var(--csp-text-color);
    font-family: var(--csp-font-family);
    font-size: 14px;
}

.custom-no-results a {
    color: var(--csp-secondary-color);
    text-decoration: underline;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-search-form ul.custom-show li {
    animation: fadeInUp var(--csp-transition-duration) ease forwards;
    animation-delay: calc(0.05s * var(--item-index));
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.custom-search-form *:focus {
    outline: 2px solid var(--csp-secondary-color);
    outline-offset: 2px;
}

/* Results container flex layout */
.custom-search-results.custom-study-areas,
.custom-search-results.custom-subject-areas.custom-show {
    display: flex;
    flex-direction: column;
}

/* UL list flex layout */
ul#studyAreaList,
ul#customSubjectList {
    display: flex;
    flex-direction: column;
    gap: 0px;
}

/* Subject areas icon margin */
.custom-search-results.custom-subject-areas.custom-show .custom-result-icon.svg-icon {
    margin-right: 25px !important;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media screen and (max-width: 768px) {
    .custom-search-form {
        max-width: 100%;
        padding: 0 10px;
    }

    .custom-search-bar {
        height: 65px;
        padding: 0 30px 0 65px;
    }

    .custom-search-icon {
        width: 22px;
        height: 22px;
        left: 22px;
    }

    .custom-search-icon svg {
        width: 22px;
        height: 22px;
    }

    .custom-dropdown-icon {
        right: 25px;
    }

    .custom-study-areas li {
        height: auto;
        min-height: 140px;
    }

    .custom-study-areas li a {
        padding: 24px 50px 24px 30px;
    }

    .custom-study-areas .custom-text-content h5 {
        font-size: 18px !important;
    }

    .custom-study-areas .custom-text-content p {
        font-size: 13px !important;
        max-width: 100%;
    }

    .custom-study-areas .custom-arrow {
        right: 20px !important;
    }

    .custom-subject-areas li {
        height: auto;
        min-height: 110px;
    }

    .custom-subject-areas li a {
        padding: 20px;
    }

    .custom-result-icon {
        width: 40px;
        height: 36px;
        margin-right: 20px;
    }

    .custom-subject-areas .custom-text-content h5 {
        font-size: 15px !important;
    }

    .custom-subject-areas .custom-text-content p {
        font-size: 13px !important;
        max-width: 100%;
    }

    .custom-search-heading {
        font-size: 15px !important;
    }
}

/* Mobile breakpoint - 600px as specified */
@media (max-width: 600px) {
    .custom-study-areas li a {
        padding: 20px 50px 20px 25px;
    }
    
    .custom-arrow {
        right: 20px !important;
    }
    
    .custom-text-content {
        gap: 5px;
    }
    
    ul#customSubjectList li a .custom-result-icon.svg-icon {
        margin-right: 15px !important;
    }
    
    ul#customSubjectList li a .custom-text-content {
        width: 70% !important;
    }
}

@media screen and (max-width: 480px) {
    .custom-search-form {
        padding: 0 8px;
    }

    .custom-search-bar {
        height: 60px;
        padding: 0 25px 0 55px;
    }

    .custom-search-icon {
        width: 20px;
        height: 20px;
        left: 18px;
    }

    .custom-search-icon svg {
        width: 20px;
        height: 20px;
    }

    .custom-dropdown-icon {
        right: 20px;
    }

    .custom-study-areas li {
        min-height: 120px;
    }

    .custom-study-areas .custom-text-content h5 {
        font-size: 16px !important;
    }

    .custom-study-areas .custom-text-content p {
        font-size: 12px !important;
        line-height: 18px !important;
    }

    .custom-subject-areas li {
        min-height: 100px;
    }

    .custom-subject-areas li a {
        padding: 16px;
    }

    .custom-result-icon {
        width: 36px;
        height: 32px;
    }

    .custom-subject-areas .custom-text-content h5 {
        font-size: 14px !important;
    }

    .custom-subject-areas .custom-text-content p {
        font-size: 12px !important;
        line-height: 18px !important;
    }

    .custom-search-heading {
        font-size: 14px !important;
    }

    .custom-arrow svg {
        width: 18px;
        height: 14px;
    }
}
