/* =====================================================================
   Explore page (Explore_Page.php + js/explore.js). Scoped under
   .explore-page; navigation and footer styles live in common.css.
   ===================================================================== */

.explore-page .explore-title {
    text-align: center;
    font-size: 1.75rem;
    margin: 4px 0 16px;
}

/* ---------------------------------------------------------------------
   Search (the original black pill search box)
   --------------------------------------------------------------------- */

.explore-search {
    max-width: 520px;
    margin: 0 auto 20px;
}

.explore-search-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    text-align: center;
}

.explore-search-box {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    padding-inline-start: 20px;
    background: #000;
    border-radius: 50px;
}

.explore-search-box:focus-within {
    outline: 3px solid var(--color-focus-ink);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px var(--color-focus);
}

.explore-search-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 44px;
    padding: 10px 4px;
    border: none;
    background: none;
    color: #fff;
    font: inherit;
    font-size: 1rem;
    -webkit-appearance: none;
    appearance: none;
}

.explore-search-input::placeholder {
    color: #c4c4c4;
    opacity: 1;
}

/* The whole pill shows the focus ring (see :focus-within above). */
.explore-search-input:focus,
.explore-search-input:focus-visible {
    outline: none;
    box-shadow: none;
}

.explore-search-button {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0 20px;
    border: 0;
    border-radius: 40px;
    background: linear-gradient(90deg, #2f3a3d 0%, #1f2628 100%);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.explore-search-button:hover {
    background: #4a4a4a;
    box-shadow: rgba(255, 255, 255, 0.15) 0 0 0 2px;
}

/* Inset yellow ring: the button sits on the black pill, which already shows the
   two-tone ring of :focus-within on the light page. */
.explore-search-button:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: -3px;
    box-shadow: none;
}

/* ---------------------------------------------------------------------
   Genre tabs (red pills, active tab black)
   --------------------------------------------------------------------- */

.genre-tabs ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
}

.genre-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 18px;
    border-radius: 20px;
    background-color: var(--color-accent);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.2s;
}

.genre-tab:visited,
.genre-tab:hover {
    color: #fff;
}

.genre-tab:hover {
    background-color: var(--color-accent-hover);
}

.genre-tab.is-active,
.genre-tab[aria-current="page"] {
    background-color: #000;
}

/* ---------------------------------------------------------------------
   Results
   --------------------------------------------------------------------- */

.explore-status {
    margin: 0 0 16px;
    text-align: center;
    color: var(--color-text-muted);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.explore-status.is-loading::before {
    content: "";
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    margin-inline-end: 8px;
    vertical-align: -0.1em;
    border: 2px solid currentColor;
    border-inline-end-color: transparent;
    border-radius: 50%;
    animation: explore-spin 0.8s linear infinite;
}

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

.explore-results {
    min-height: 200px;
}

.explore-results.is-loading .explore-grid,
.explore-results.is-loading .explore-empty,
.explore-results.is-loading .explore-error {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 0.2s;
}

.explore-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 14px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.explore-card {
    min-width: 0;
}

.explore-card-link {
    display: grid;
    grid-template-areas:
        "cover"
        "body";
    grid-template-rows: auto 1fr;
    height: 100%;
    border-radius: 10px;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    color: var(--color-text);
    text-decoration: none;
    transition: transform 0.3s, box-shadow 0.3s;
}

.explore-card-link:visited,
.explore-card-link:hover {
    color: var(--color-text);
}

.explore-card-link:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.15);
}

.explore-card-link:focus-visible {
    outline: 3px solid var(--color-focus-ink);
    outline-offset: 2px;
    box-shadow: 0 0 0 5px var(--color-focus);
}

.explore-card-cover {
    grid-area: cover;
}

.explore-card-cover img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 380 / 605;
    object-fit: cover;
    background-color: #e3e3e3;
}

/* Price pill sits on the cover's bottom corner at the end of the line
   (bottom-right, or bottom-left in Arabic; original "heart" badge). */
.explore-card-price {
    grid-area: cover;
    align-self: end;
    justify-self: end;
    margin: 0;
    margin-inline-end: 10px;
    margin-block-end: 10px;
    padding: 5px 12px;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.92);
    color: #000;
    font-size: 0.875rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.explore-card-body {
    grid-area: body;
    padding: 10px 12px 12px;
}

.explore-card-title {
    margin: 0 0 2px;
    font-size: 1rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.explore-card-author {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    overflow-wrap: anywhere;
}

/* Empty and error states */
.explore-empty {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.explore-empty-title,
.explore-error-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
}

.explore-error {
    text-align: center;
    padding: 32px 20px;
    border: 1px solid #f5c2c0;
    border-radius: var(--radius);
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

.explore-error p {
    margin: 0 0 12px;
}

.explore-error .explore-error-title {
    color: var(--color-error-text);
}

/* ---------------------------------------------------------------------
   Availability badges ("In stock", "Only N left", "Out of stock")
   --------------------------------------------------------------------- */

.explore-page .stock-badge {
    display: inline-block;
    margin: 6px 0 0;
    padding: 2px 10px;
    border-radius: var(--radius-lg);
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.5;
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.explore-page .stock-badge.stock-low {
    background: #fff4e5;
    color: #7a4100;
}

.explore-page .stock-badge.stock-out {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

/* ---------------------------------------------------------------------
   Pager (24 books per page)
   --------------------------------------------------------------------- */

.explore-pager .pager {
    margin: 28px 0 0;
}

.explore-pager .pager-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.explore-pager .pager-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 6px 16px;
    border-radius: 22px;
    background-color: var(--color-accent);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.2s;
}

.explore-pager .pager-link:visited,
.explore-pager .pager-link:hover {
    color: #fff;
}

.explore-pager .pager-link:hover {
    background-color: var(--color-accent-hover);
}

.explore-pager .pager-link[aria-current="page"] {
    background-color: #000;
}

.explore-pager .pager-link.is-disabled {
    background-color: transparent;
    border: 1px solid var(--color-border);
    color: #5c5c5c;
    cursor: not-allowed;
}

.explore-pager .pager-gap {
    padding: 0 2px;
    color: var(--color-text-muted);
}

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */

@media (min-width: 600px) {
    .explore-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
        gap: 20px;
    }
}

@media (min-width: 1024px) {
    .explore-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 480px) {
    .explore-page .explore-title {
        font-size: 1.45rem;
    }

    .explore-search-box {
        padding-inline-start: 16px;
    }

    .explore-search-button {
        padding: 0 14px;
    }

    .genre-tab {
        min-height: 36px;
        padding: 6px 14px;
        font-size: 0.875rem;
    }

    .explore-card-price {
        margin-inline-end: 6px;
        margin-block-end: 6px;
        padding: 4px 10px;
        font-size: 0.8rem;
    }
}
