/*
 * Frontend styles for the Ingredient Glossary plugin.
 * Version 1.3.1
 */

/* =========================================================================
   Archive page
   ========================================================================= */

.ig-glossary-archive-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
}

.ig-glossary-header {
    text-align: center;
    margin-bottom: 1rem;
}

/* Search form */
.ig-glossary-search {
    margin-bottom: 1rem;
    text-align: center;
}
.ig-glossary-search-field {
    width: 60%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}
.ig-glossary-search-submit {
    margin-left: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    background: #0073aa;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
}
.ig-glossary-search-submit:hover {
    background: #006799;
}

/* A–Z filter */
.ig-glossary-filter {
    margin-bottom: 1rem;
    text-align: center;
}
.ig-glossary-filter-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}
.ig-glossary-filter-item {
    margin: 0 0.25rem 0.5rem;
}
.ig-glossary-filter-item a {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    font-size: 0.9rem;
}
.ig-glossary-filter-item.active a,
.ig-glossary-filter-item a:hover {
    background: #0073aa;
    color: #fff;
}

/* -------------------------------------------------------------------------
   Entry list – desktop: side-by-side thumbnail + text
   ------------------------------------------------------------------------- */
.ig-glossary-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.ig-glossary-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}

/* Thumbnail in archive list */
.ig-glossary-thumb {
    flex: 0 0 auto; /* never shrink */
    width: 120px;
}
.ig-glossary-thumb img {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.ig-glossary-content {
    flex: 1 1 auto;
    min-width: 0; /* prevent overflow in flex child */
}

.ig-glossary-title {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}
.ig-glossary-excerpt {
    color: #555;
    font-size: 0.9rem;
}

/* -------------------------------------------------------------------------
   Load more button
   The .loading class adds a simple CSS spinner via ::after so no external
   icon font is needed. The spinner is centred relative to the button text.
   ------------------------------------------------------------------------- */
.ig-load-more-wrap {
    text-align: center;
    margin-top: 1.5rem;
}

.ig-load-more,
.ig-load-more.button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border: none;
    border-radius: 4px;
    background: #0073aa;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.ig-load-more:hover,
.ig-load-more.button:hover {
    background: #006799;
}

/* Loading state */
.ig-load-more.loading,
.ig-load-more.button.loading {
    opacity: 0.75;
    cursor: default;
    pointer-events: none;
}

/* Spinner via ::after – appears inline to the left of the button text */
.ig-load-more.loading::before {
    content: '';
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ig-spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* =========================================================================
   Single entry page
   ========================================================================= */

.ig-single-glossary-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Featured image on the single entry page:
   constrained to a reasonable max-width so it doesn't dominate on large screens. */
.ig-single-thumbnail {
    margin-bottom: 1.5rem;
    text-align: center;
}
.ig-single-thumbnail img {
    max-width: 480px;   /* cap at 480 px on desktop */
    width: 100%;        /* shrink naturally on smaller viewports */
    height: auto;
    border-radius: 4px;
    display: inline-block;
}

.ig-glossary-meta p {
    margin: 0.5rem 0;
}

/* Related products */
.ig-related-products {
    margin-top: 2rem;
}
.ig-products-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.ig-product {
    width: calc(33.333% - 0.75rem);
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 0.5rem;
    text-align: center;
    box-sizing: border-box;
}
.ig-product-image img {
    max-width: 100%;
    height: auto;
    margin-bottom: 0.5rem;
}
.ig-product-title {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.ig-product-price {
    color: #0073aa;
    font-weight: 700;
}

/* =========================================================================
   Auto-link styling
   ========================================================================= */

.ig-glossary-link {
    text-decoration: underline;
    cursor: help;
    color: #0073aa;
}
.ig-glossary-link:hover {
    color: #005077;
}

/* =========================================================================
   Responsive – mobile (max 600 px)
   ========================================================================= */

@media (max-width: 600px) {

    /* Search field full-width */
    .ig-glossary-search-field {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    .ig-glossary-search-submit {
        margin-left: 0;
        width: 100%;
    }

    /* Archive list: stack thumbnail above text */
    .ig-glossary-item {
        flex-direction: column;
        align-items: stretch;
    }
    .ig-glossary-thumb {
        width: 100%;
    }
    .ig-glossary-thumb img {
        width: 100%;
        height: 200px;  /* fixed height, object-fit crops nicely */
        object-fit: cover;
    }

    /* Single entry: featured image full-width */
    .ig-single-thumbnail img {
        max-width: 100%;
    }

    /* Product grid: 2 columns on mobile */
    .ig-product {
        width: calc(50% - 0.5rem);
    }
}

/* Extra small (max 400 px): product grid single column */
@media (max-width: 400px) {
    .ig-product {
        width: 100%;
    }
}
