/**
 * Glossary Styles
 * The Truth About Judaism
 */

/* ============================================
   Variables
   ============================================ */
:root {
    --glossary-primary: var(--wp--preset--color--primary, #a1b0d8);
    --glossary-contrast: var(--wp--preset--color--contrast, #0B0620);
    --glossary-tertiary: var(--wp--preset--color--tertiary, #f5f5f5);
    --glossary-border: #e0e0e0;
    --glossary-transition: 0.3s ease;
}

/* ============================================
   Container
   ============================================ */
.glossary-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   Search
   ============================================ */
.search-container {
    display: flex;
    max-width: 600px;
    margin: 2rem auto;
}

.search-container input {
    flex-grow: 1;
    padding: 0.8rem 1rem;
    border: 2px solid var(--glossary-border);
    border-radius: 5px 0 0 5px;
    font-size: 1rem;
    transition: border-color var(--glossary-transition);
}

.search-container input:focus {
    outline: none;
    border-color: var(--glossary-primary);
}

.search-container button {
    background-color: var(--glossary-primary);
    color: white;
    border: none;
    border-radius: 0 5px 5px 0;
    padding: 0 1.5rem;
    cursor: pointer;
    font-weight: 600;
    transition: background-color var(--glossary-transition);
}

.search-container button:hover {
    background-color: var(--glossary-contrast);
}

/* ============================================
   Alphabet Filters
   ============================================ */
.alphabet-filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 2rem 0;
}

.alpha-button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--glossary-tertiary);
    color: var(--glossary-contrast);
    border: none;
    border-radius: 50%;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--glossary-transition);
}

.alpha-button:hover {
    background-color: var(--glossary-primary);
    color: white;
    transform: translateY(-2px);
}

.alpha-button.active {
    background-color: var(--glossary-primary);
    color: white;
}

/* ============================================
   Category Filters
   ============================================ */
.category-filters {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
    flex-wrap: wrap;
    gap: 1rem;
}

.category-button {
    background-color: var(--glossary-tertiary);
    color: var(--glossary-contrast);
    border: 2px solid transparent;
    border-radius: 5px;
    padding: 0.6rem 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--glossary-transition);
}

.category-button:hover {
    background-color: var(--glossary-primary);
    color: white;
    transform: translateY(-2px);
}

.category-button.active {
    background-color: var(--glossary-primary);
    color: white;
    border-color: var(--glossary-primary);
}

/* ============================================
   Glossary Sections
   ============================================ */
.glossary-section {
    margin-bottom: 3rem;
}

.glossary-section h2 {
    color: var(--glossary-primary);
    border-bottom: 2px solid var(--glossary-primary);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

/* ============================================
   Terms
   ============================================ */
.term {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--glossary-border);
    transition: all var(--glossary-transition);
    cursor: pointer;
}

.term:hover {
    background-color: rgba(0, 0, 0, 0.02);
    padding: 1rem;
    margin: 0 -1rem 2rem -1rem;
    border-radius: 8px;
}

.term-title {
    color: var(--glossary-primary);
    font-weight: 700;
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
}

.term:hover .term-title {
    text-decoration: underline;
}

.term-title .hebrew {
    margin-left: 12px;
    font-weight: 400;
    font-size: 1rem;
    opacity: 0.8;
}

.term-category {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    background-color: var(--glossary-tertiary);
    color: var(--glossary-contrast);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.term-content {
    font-size: 1rem;
    line-height: 1.6;
}

.term-content p:first-of-type {
    font-weight: 500;
}

.term-content p + p {
    margin-top: 1rem;
}

.read-more-link {
    display: inline-block;
    margin-top: 1rem;
    color: var(--glossary-primary);
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s ease;
}

.read-more-link:hover {
    text-decoration: underline;
    color: var(--glossary-contrast);
}

/* ============================================
   Modal Overlay
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    overflow: auto;
    transition: opacity var(--glossary-transition);
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal - Force positioning outside WordPress containers */
#term-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: rgba(0, 0, 0, 0.85) !important;
    z-index: 999999 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    border: none !important;
    border-radius: 0 !important;
    overflow: auto !important;
    transform: none !important;
    box-sizing: border-box !important;
    pointer-events: auto !important;
}

#term-modal.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Modal Content */
.modal-content {
    background-color: white;
    border-radius: 8px;
    max-width: 900px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
    box-sizing: border-box;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    margin: 0 auto;
}

#term-modal .modal-content {
    position: relative !important;
    background-color: white !important;
    max-width: 900px !important;
    width: 90% !important;
    margin: 30px auto !important;
    padding: 2rem !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
    overflow-y: auto !important;
    max-height: 80vh !important;
    transform: none !important;
}

/* Modal Close Button */
.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.5rem;
    color: #666;
    background: white;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.modal-close:hover {
    background-color: #f5f5f5;
    color: var(--glossary-primary);
    transform: scale(1.1);
}

#term-modal .modal-close {
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    font-size: 1.5rem !important;
    background: white !important;
    border: none !important;
    cursor: pointer !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 10 !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
}

#term-modal .modal-close:hover {
    background-color: #f5f5f5 !important;
    color: var(--glossary-primary) !important;
    transform: scale(1.1) !important;
}

/* Modal Title */
.modal-title {
    font-size: 1.8rem;
    color: var(--glossary-primary);
    margin-bottom: 0.5rem;
    padding-right: 40px;
}

.modal-hebrew {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 1.5rem;
    font-weight: normal;
}

/* ============================================
   Modal Tabs
   ============================================ */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    background: white;
    z-index: 5;
    padding-top: 0.5rem;
}

#term-modal .modal-tabs {
    position: sticky !important;
    top: 0 !important;
    background: white !important;
    z-index: 5 !important;
    padding-top: 0.5rem !important;
    margin-bottom: 1.5rem !important;
    display: flex !important;
    border-bottom: 1px solid #ddd !important;
    flex-wrap: wrap !important;
}

.modal-tab {
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    font-weight: 600;
    transition: all 0.25s ease;
    position: relative;
    text-align: center;
    flex: 1;
    max-width: 200px;
}

.modal-tab:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.modal-tab.active {
    border-bottom-color: var(--glossary-primary);
    color: var(--glossary-primary);
}

.modal-tab.active:after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background-color: var(--glossary-primary);
    border-radius: 50%;
}

#term-modal .modal-tab {
    padding: 0.8rem 1.2rem !important;
    cursor: pointer !important;
    border-bottom: 3px solid transparent !important;
    font-weight: 600 !important;
    transition: all 0.25s ease !important;
    position: relative !important;
    text-align: center !important;
    flex: 1 !important;
}

#term-modal .modal-tab.active {
    border-bottom-color: var(--glossary-primary) !important;
    color: var(--glossary-primary) !important;
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tab-content.active {
    display: block;
}

/* Modal Sections */
.modal-section {
    margin-bottom: 2rem;
}

.modal-section-title {
    font-size: 1.3rem;
    color: var(--glossary-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

/* ============================================
   Citations
   ============================================ */
.citations-list {
    background-color: #f9f9f9;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

#term-modal .citations-list {
    background-color: #f9f9f9 !important;
    padding: 1.5rem !important;
    border-radius: 8px !important;
    margin-top: 1rem !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

.citation-item {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e5e5e5;
    position: relative;
    transition: all 0.2s ease;
    background: white;
    border-radius: 6px;
    padding: 1.2rem;
    margin-top: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.citation-item:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.citation-item:last-child {
    margin-bottom: 0;
    padding-bottom: 1.2rem;
    border-bottom: none;
}

#term-modal .citation-item {
    margin-bottom: 1.5rem !important;
    padding-bottom: 1.5rem !important;
    border-bottom: 1px solid #e5e5e5 !important;
    position: relative !important;
    transition: all 0.2s ease !important;
    background: white !important;
    border-radius: 6px !important;
    padding: 1.2rem !important;
    margin-top: 1rem !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03) !important;
}

.citation-title {
    font-weight: 600;
    margin-bottom: 0.7rem;
    color: var(--glossary-primary);
    font-size: 1.05rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.1);
}

#term-modal .citation-title {
    font-weight: 600 !important;
    margin-bottom: 0.7rem !important;
    color: var(--glossary-primary) !important;
    font-size: 1.05rem !important;
    padding-bottom: 0.3rem !important;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.1) !important;
}

.citation-description {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 0.7rem;
    color: #333;
}

#term-modal .citation-description {
    font-size: 0.95rem !important;
    line-height: 1.6 !important;
    margin-bottom: 0.7rem !important;
    color: #333 !important;
}

.citation-source {
    font-style: italic;
    font-size: 0.85rem;
    padding-top: 0.5rem;
    color: #666;
    display: flex;
    align-items: center;
}

.citation-source a {
    color: var(--glossary-primary);
    text-decoration: none;
    position: relative;
    padding-bottom: 2px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.citation-source a:after {
    content: '';
    position: absolute;
    width: 100%;
    height: 1px;
    bottom: 0;
    left: 0;
    background-color: var(--glossary-primary);
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease;
}

.citation-source a:hover:after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

#term-modal .citation-source a {
    color: var(--glossary-primary) !important;
    text-decoration: none !important;
    position: relative !important;
    padding-bottom: 2px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
}

.no-citations {
    color: #666;
    font-style: italic;
    padding: 1rem;
    text-align: center;
}

/* ============================================
   Back to Top
   ============================================ */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--glossary-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all var(--glossary-transition);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    border: none;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-5px);
    background-color: var(--glossary-contrast);
}

/* ============================================
   Loading
   ============================================ */
.loading {
    display: none;
    text-align: center;
    padding: 3rem 0;
}

.loading-spinner {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 5px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--glossary-primary);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   No Results / Error
   ============================================ */
.no-results,
.error-message {
    text-align: center;
    padding: 3rem;
    background-color: var(--glossary-tertiary);
    border-radius: 8px;
    margin: 2rem 0;
}

.no-results h3,
.error-message h3 {
    color: var(--glossary-contrast);
    margin-bottom: 1rem;
}

.reset-filters-btn {
    margin-top: 1rem;
    background-color: var(--glossary-primary);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--glossary-transition);
}

.reset-filters-btn:hover {
    background-color: var(--glossary-contrast);
}

/* ============================================
   Body Modal Open State
   ============================================ */
body.modal-open {
    overflow: hidden !important;
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .alphabet-filters {
        gap: 0.3rem;
    }

    .alpha-button {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }

    .category-filters {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 1rem;
        justify-content: flex-start;
    }

    .category-button {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .term-title {
        font-size: 1.2rem;
        flex-direction: column;
        align-items: flex-start;
    }

    .term-title .hebrew {
        margin-left: 0;
        margin-top: 4px;
    }

    .modal-overlay {
        align-items: center;
    }

    .modal-content {
        padding: 1.5rem;
        width: 95%;
        max-height: 80vh;
        border-radius: 6px;
    }

    #term-modal .modal-content {
        width: 95% !important;
        padding: 1.5rem !important;
        margin: 20px auto !important;
    }

    .modal-title {
        font-size: 1.5rem;
        padding-right: 50px;
    }

    .modal-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
    }

    .modal-tab {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    .citation-item {
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }

    .citations-list {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .search-container {
        flex-direction: column;
    }

    .search-container input {
        border-radius: 5px;
        margin-bottom: 0.5rem;
    }

    .search-container button {
        border-radius: 5px;
        padding: 0.8rem;
    }

    .alpha-button {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
}
