/**
 * HW Library — Front-end Styles
 *
 * Uses the design tokens from the HW child theme.
 * Color palette inherits from the site: earthy greens, warm neutrals.
 *
 * @package HW_Library
 */

/* ── Variables (fallbacks if theme tokens missing) ────────── */
:root {
    --hw-lib-green: #3d6b4f;
    --hw-lib-green-light: #e8f0eb;
    --hw-lib-gold: #826200;
    --hw-lib-gold-light: #faf3e0;
    --hw-lib-text: #2c2c2c;
    --hw-lib-text-light: #666;
    --hw-lib-border: #e2ddd5;
    --hw-lib-bg: #faf9f7;
    --hw-lib-white: #fff;
    --hw-lib-radius: 8px;
    --hw-lib-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --hw-lib-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --hw-lib-transition: 0.2s ease;
}

/* ── Hero ─────────────────────────────────────────────────── */
.hw-library-hero {
    background: var(--hw-lib-green-light);
    padding: 3rem 1.5rem;
    text-align: center;
    margin-bottom: 2rem;
    border-bottom: 3px solid var(--hw-lib-green);
}

/* Photo hero variant */
.hw-library-hero--photo {
    position: relative;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-color: #1a1a1a;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 3px solid var(--hw-lib-green);
}

.hw-library-hero__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 0;
}

.hw-library-hero--photo .hw-library-hero__inner {
    position: relative;
    z-index: 1;
    max-width: 740px;
    margin: 0 auto;
}

.hw-library-hero--photo .hw-library-hero__title {
    color: #fff;
    font-family: var(--hw-font-heading, 'Playfair Display', serif);
    font-style: italic;
    font-size: 2.25rem;
}

.hw-library-hero--photo .hw-library-hero__description {
    color: rgba(255, 255, 255, 0.9);
}

.hw-library-hero--photo .hw-library-hero__status {
    margin: 0.5rem 0 0;
}

.hw-library-hero--photo .hw-library-access-badge--granted {
    background: rgba(255, 255, 255, 0.15);
    color: #a8e6a0;
}

.hw-library-hero--photo .hw-library-hero__cta {
    border-top-color: rgba(255, 255, 255, 0.2);
}

.hw-library-hero--photo .hw-library-hero__cta p {
    color: rgba(255, 255, 255, 0.85);
}

.hw-library-hero--photo .hw-btn--primary {
    background: var(--hw-lib-white);
    color: var(--hw-lib-green);
    border-color: var(--hw-lib-white);
}

.hw-library-hero--photo .hw-btn--primary:hover {
    background: var(--hw-lib-green-light);
    border-color: var(--hw-lib-green-light);
}

.hw-library-hero__inner {
    max-width: 740px;
    margin: 0 auto;
}

.hw-library-hero__title {
    font-size: 2rem;
    color: var(--hw-lib-green);
    margin: 0 0 0.75rem;
}

.hw-library-hero__description {
    font-size: 1.05rem;
    color: var(--hw-lib-text);
    line-height: 1.6;
    margin: 0 0 1.25rem;
}

.hw-library-hero__cta {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(61, 107, 79, 0.2);
}

.hw-library-hero__cta p {
    font-size: 0.95rem;
    color: var(--hw-lib-text-light);
    margin: 0 0 0.75rem;
}

.hw-library-hero__status {
    margin: 0.5rem 0 0;
}

/* ── Access badges ────────────────────────────────────────── */
.hw-library-access-badge {
    display: inline-block;
    padding: 0.3em 0.8em;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}

.hw-library-access-badge--granted {
    background: var(--hw-lib-green-light);
    color: var(--hw-lib-green);
}

.hw-library-access-badge--locked {
    background: var(--hw-lib-gold-light);
    color: var(--hw-lib-gold);
}

/* ── Topic filter pills ───────────────────────────────────── */
.hw-library-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding: 0 1.5rem;
    margin-bottom: 2rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.hw-library-topics__label {
    font-weight: 600;
    color: var(--hw-lib-text);
    margin-right: 0.25rem;
}

.hw-library-topic-pill {
    display: inline-block;
    padding: 0.35em 0.9em;
    background: var(--hw-lib-white);
    border: 1px solid var(--hw-lib-border);
    border-radius: 20px;
    color: var(--hw-lib-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all var(--hw-lib-transition);
}

.hw-library-topic-pill:hover {
    background: var(--hw-lib-green-light);
    border-color: var(--hw-lib-green);
    color: var(--hw-lib-green);
}

.hw-library-topic-pill--active {
    background: var(--hw-lib-green);
    border-color: var(--hw-lib-green);
    color: var(--hw-lib-white);
}

.hw-library-topic-pill--active:hover {
    background: var(--hw-lib-green);
    color: var(--hw-lib-white);
}

.hw-library-topic-pill__count {
    opacity: 0.7;
    font-size: 0.8em;
    margin-left: 0.15em;
}

/* ── Catalog grid ─────────────────────────────────────────── */
.hw-library-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.75rem;
    padding: 0 1.5rem;
    max-width: 1200px;
    margin: 0 auto 2rem;
}

.hw-library-cols-2 .hw-library-grid {
    grid-template-columns: repeat(2, 1fr);
}

.hw-library-cols-4 .hw-library-grid {
    grid-template-columns: repeat(4, 1fr);
}

/* ── Text card ────────────────────────────────────────────── */
.hw-library-card {
    background: var(--hw-lib-white);
    border: 1px solid var(--hw-lib-border);
    border-radius: var(--hw-lib-radius);
    overflow: hidden;
    transition: box-shadow var(--hw-lib-transition), transform var(--hw-lib-transition);
}

.hw-library-card:hover {
    box-shadow: var(--hw-lib-shadow-hover);
    transform: translateY(-2px);
}

.hw-library-card__link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.hw-library-card__cover {
    position: relative;
    aspect-ratio: 3 / 4;
    background: var(--hw-lib-bg);
    overflow: hidden;
}

.hw-library-card__cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hw-library-card__cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #bbb;
}

.hw-library-card__cover-placeholder .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
}

.hw-library-card__lock {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(130, 98, 0, 0.9);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hw-library-card__lock svg {
    width: 14px;
    height: 14px;
}

.hw-library-card__body {
    padding: 1rem;
}

.hw-library-card__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--hw-lib-text);
    margin: 0 0 0.35rem;
    line-height: 1.3;
}

.hw-library-card__author {
    font-size: 0.875rem;
    color: var(--hw-lib-text-light);
    margin: 0 0 0.2rem;
}

.hw-library-card__year {
    font-size: 0.8rem;
    color: var(--hw-lib-text-light);
    margin: 0 0 0.5rem;
}

.hw-library-card__excerpt {
    font-size: 0.85rem;
    color: var(--hw-lib-text-light);
    line-height: 1.5;
    margin: 0 0 0.5rem;
}

.hw-library-card__topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.hw-library-card__topic-badge {
    display: inline-block;
    padding: 0.15em 0.5em;
    background: var(--hw-lib-green-light);
    color: var(--hw-lib-green);
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ── Single text page ─────────────────────────────────────── */
.hw-library-single {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.5rem;
}

.hw-library-breadcrumbs {
    font-size: 0.85rem;
    color: var(--hw-lib-text-light);
    margin-bottom: 1.5rem;
}

.hw-library-breadcrumbs a {
    color: var(--hw-lib-green);
    text-decoration: none;
}

.hw-library-breadcrumbs a:hover {
    text-decoration: underline;
}

.hw-library-breadcrumbs__sep {
    margin: 0 0.4em;
    color: #ccc;
}

.hw-library-single__header-inner {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.hw-library-single__cover {
    flex-shrink: 0;
    width: 200px;
}

.hw-library-single__cover-img {
    width: 100%;
    height: auto;
    border-radius: var(--hw-lib-radius);
    box-shadow: var(--hw-lib-shadow);
}

.hw-library-single__meta {
    flex: 1;
}

.hw-library-single__title {
    font-size: 1.75rem;
    color: var(--hw-lib-text);
    margin: 0 0 0.5rem;
    line-height: 1.25;
}

.hw-library-single__author {
    font-size: 1.05rem;
    color: var(--hw-lib-text-light);
    margin: 0 0 1rem;
    font-style: italic;
}

.hw-library-single__details {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.hw-library-detail {
    font-size: 0.9rem;
    color: var(--hw-lib-text);
}

.hw-library-detail strong {
    color: var(--hw-lib-text-light);
    font-weight: 500;
}

.hw-library-single__topics {
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.hw-library-single__topics strong {
    color: var(--hw-lib-text-light);
    font-weight: 500;
}

.hw-library-topic-link {
    color: var(--hw-lib-green);
    text-decoration: none;
}

.hw-library-topic-link:hover {
    text-decoration: underline;
}

.hw-library-single__access-notice {
    margin-top: 1rem;
}

/* ── Description ──────────────────────────────────────────── */
.hw-library-single__description {
    margin-bottom: 2rem;
    line-height: 1.7;
    color: var(--hw-lib-text);
}

.hw-library-single__excerpt {
    font-size: 1.05rem;
    font-style: italic;
    color: var(--hw-lib-text-light);
    margin-bottom: 1rem;
}

/* ── FlowPaper viewer container ───────────────────────────── */
.hw-flowpaper-container {
    background: #f5f5f5;
    border: 1px solid var(--hw-lib-border);
    border-radius: var(--hw-lib-radius);
    overflow: hidden;
    margin-bottom: 2rem;
}

.hw-flowpaper-frame {
    display: block;
    border: none;
}

.hw-library-single__viewer {
    margin-bottom: 2rem;
}

/* ── Notices ──────────────────────────────────────────────── */
.hw-library-notice {
    padding: 1rem 1.5rem;
    border-radius: var(--hw-lib-radius);
    margin-bottom: 1.5rem;
}

.hw-library-notice--info {
    background: var(--hw-lib-green-light);
    border: 1px solid rgba(61, 107, 79, 0.2);
    color: var(--hw-lib-green);
}

/* ── Gated / access-denied block ──────────────────────────── */
.hw-library-gated {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--hw-lib-bg);
    border: 2px dashed var(--hw-lib-border);
    border-radius: var(--hw-lib-radius);
    margin-bottom: 2rem;
}

.hw-library-gated__icon {
    color: var(--hw-lib-green);
    margin-bottom: 1rem;
}

.hw-library-gated__title {
    font-size: 1.4rem;
    color: var(--hw-lib-text);
    margin: 0 0 1rem;
}

.hw-library-gated__body {
    max-width: 600px;
    margin: 0 auto 1.5rem;
    text-align: left;
}

.hw-library-gated__body p {
    line-height: 1.65;
    color: var(--hw-lib-text);
    margin: 0 0 1rem;
}

.hw-library-gated__access-info {
    font-weight: 600;
    color: var(--hw-lib-green);
}

.hw-library-gated__tiers {
    list-style: none;
    padding: 0;
    margin: 0;
}

.hw-library-gated__tiers li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--hw-lib-border);
    font-size: 0.95rem;
    color: var(--hw-lib-text);
}

.hw-library-gated__tiers li:last-child {
    border-bottom: none;
}

.hw-library-gated__actions {
    margin-top: 1.5rem;
}

.hw-library-gated__login,
.hw-library-gated__logged-in {
    font-size: 0.9rem;
    color: var(--hw-lib-text-light);
    margin-top: 0.75rem;
}

.hw-library-gated__login a {
    color: var(--hw-lib-green);
    font-weight: 600;
}

/* ── Buttons (if not already global) ──────────────────────── */
.hw-btn {
    display: inline-block;
    padding: 0.6em 1.5em;
    border-radius: 5px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all var(--hw-lib-transition);
    cursor: pointer;
    border: 2px solid transparent;
}

.hw-btn--primary {
    background: var(--hw-lib-green);
    color: var(--hw-lib-white);
    border-color: var(--hw-lib-green);
}

.hw-btn--primary:hover {
    background: #2f5a3e;
    border-color: #2f5a3e;
    color: var(--hw-lib-white);
}

.hw-btn--outline {
    background: transparent;
    color: var(--hw-lib-green);
    border-color: var(--hw-lib-green);
}

.hw-btn--outline:hover {
    background: var(--hw-lib-green);
    color: var(--hw-lib-white);
}

.hw-btn--lg {
    padding: 0.75em 2em;
    font-size: 1.05rem;
}

/* ── Pagination ───────────────────────────────────────────── */
.hw-library-pagination {
    text-align: center;
    padding: 2rem 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.hw-library-pagination .page-numbers {
    display: inline-block;
    padding: 0.4em 0.8em;
    margin: 0 0.15em;
    border-radius: 4px;
    text-decoration: none;
    color: var(--hw-lib-text);
    border: 1px solid var(--hw-lib-border);
    transition: all var(--hw-lib-transition);
}

.hw-library-pagination .page-numbers:hover {
    background: var(--hw-lib-green-light);
    border-color: var(--hw-lib-green);
}

.hw-library-pagination .page-numbers.current {
    background: var(--hw-lib-green);
    color: var(--hw-lib-white);
    border-color: var(--hw-lib-green);
}

/* ── Back nav ─────────────────────────────────────────────── */
.hw-library-single__nav {
    padding-top: 1.5rem;
    border-top: 1px solid var(--hw-lib-border);
}

/* ── Empty state ──────────────────────────────────────────── */
.hw-library-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--hw-lib-text-light);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
    .hw-library-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hw-library-cols-4 .hw-library-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .hw-library-hero--photo {
        min-height: 220px;
        padding: 2rem 1rem;
    }

    .hw-library-hero--photo .hw-library-hero__title {
        font-size: 1.6rem;
    }
}

@media (max-width: 640px) {
    .hw-library-grid {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }

    .hw-library-cols-2 .hw-library-grid,
    .hw-library-cols-4 .hw-library-grid {
        grid-template-columns: 1fr;
    }

    .hw-library-hero {
        padding: 2rem 1rem;
    }

    .hw-library-hero__title {
        font-size: 1.6rem;
    }

    .hw-library-single__header-inner {
        flex-direction: column;
        gap: 1rem;
    }

    .hw-library-single__cover {
        width: 150px;
    }

    .hw-library-single__title {
        font-size: 1.4rem;
    }

    .hw-library-single__details {
        flex-direction: column;
        gap: 0.4rem;
    }

    .hw-library-gated {
        padding: 2rem 1rem;
    }

    .hw-flowpaper-container {
        height: 500px !important;
    }

    .hw-library-topics {
        padding: 0 1rem;
    }
}
