/* =============================================
   Writing Showcase Modern — Frontend Styles
   ============================================= */

.lwp-wsm {
    --wsm-gap: 28px;
    --wsm-card-radius: var(--lwp-radius-md, 12px);
    --wsm-transition: var(--lwp-transition, all 0.4s cubic-bezier(0.4, 0, 0.2, 1));
    position: relative;
    padding: 80px 24px;
    background: var(--lwp-bg-primary, #0a0e17);
}

/* ===== Section Header ===== */
.lwp-wsm-header {
    text-align: center;
    margin-bottom: 48px;
}

.lwp-wsm-tag {
    display: inline-block;
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--lwp-accent-light, var(--lwp-accent, #7c5cbf));
    margin: 0 0 12px;
    opacity: 0.9;
}

.lwp-wsm-title {
    font-family: var(--lwp-font-serif, 'Cormorant Garamond', Georgia, serif);
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 400;
    line-height: 1.2;
    color: var(--lwp-text-primary, #e8eaf0);
    margin: 0 0 20px;
}

.lwp-wsm-divider {
    width: 60px;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--lwp-accent, #7c5cbf), transparent);
    margin: 0 auto;
    opacity: 0.6;
}

/* ===== Filter Bar (genre + writing type) ===== */
.lwp-wsm-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 28px;
    justify-content: center;
    align-items: flex-start;
    margin-bottom: 44px;
}

/* One group per taxonomy. The label sits above its pills so a two-group bar
   reads as "Genre / Writing type" rather than one meaningless pill soup. */
.lwp-wsm-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    /* The count line is a flex item with order: 1; groups must sort ahead of
       it so it never lands between two groups. */
    order: 0;
}

.lwp-wsm-filter-group-label {
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--lwp-text-muted, #6b7a94);
    margin: 0 4px 0 0;
}

/* A dropdown bar keeps its selects on one line rather than stacking. */
.lwp-wsm-filter--dropdown .lwp-wsm-filter-group {
    flex-wrap: nowrap;
}

.lwp-wsm-filter-btn {
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: var(--lwp-text-secondary, #9aa5b8);
    background: transparent;
    border: 1px solid var(--lwp-border, rgba(124, 92, 191, 0.2));
    border-radius: 100px;
    padding: 8px 18px;
    cursor: pointer;
    transition: var(--wsm-transition);
}

.lwp-wsm-filter-btn:hover {
    color: var(--lwp-text-primary, #e8eaf0);
    border-color: var(--lwp-accent-light, #a382de);
}

.lwp-wsm-filter-btn.active {
    color: #fff;
    background: var(--lwp-accent, #7c5cbf);
    border-color: var(--lwp-accent, #7c5cbf);
    box-shadow: 0 4px 16px var(--lwp-accent-glow, rgba(124, 92, 191, 0.3));
}

.lwp-wsm-filter-select {
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--lwp-text-primary, #e8eaf0);
    background: var(--lwp-surface, rgba(20, 30, 50, 0.6));
    border: 1px solid var(--lwp-border, rgba(124, 92, 191, 0.2));
    border-radius: 100px;
    padding: 9px 40px 9px 20px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a382de' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    transition: var(--wsm-transition);
}

.lwp-wsm-filter-select:hover {
    border-color: var(--lwp-accent-light, #a382de);
}

.lwp-wsm-filter-select:focus {
    outline: none;
    border-color: var(--lwp-accent-light, #a382de);
}

/* Result count — visually quiet, announced politely by filter.js. Sits on its
   own line below every group (flex-basis: 100% + order so it never lands
   between two groups). */
.lwp-wsm-filter-count {
    flex-basis: 100%;
    order: 1;
    margin: 4px 0 0;
    text-align: center;
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: var(--lwp-text-muted, #6b7a94);
    min-height: 1em;
}

/* No-results state — lives inside the filter bar (not the grid) so it stays
   visible when every card is hidden. flex-basis: 100% puts it on its own line
   below the groups, and order keeps it clear of the count line. */
.lwp-wsm-filter-empty {
    flex-basis: 100%;
    order: 2;
    margin: 0;
    padding: 12px 0 0;
    text-align: center;
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    color: var(--lwp-text-muted, #6b7a94);
}

.lwp-wsm-filter-empty[hidden] {
    display: none;
}

/* ===== Card Grid (layouts) ===== */
.lwp-wsm-grid {
    display: grid;
    gap: var(--wsm-gap);
    max-width: 1200px;
    margin: 0 auto;
}

.lwp-wsm--grid .lwp-wsm-grid {
    grid-template-columns: repeat(3, 1fr);
}

.lwp-wsm--double .lwp-wsm-grid {
    grid-template-columns: repeat(2, 1fr);
    max-width: 900px;
}

.lwp-wsm--single .lwp-wsm-grid {
    grid-template-columns: 1fr;
    max-width: 900px;
}

/* Single column reads as a row, not a tall stack: copy + buttons on the left,
   cover on the right. The DOM puts the media first, so order puts the text
   first visually. No display:flex here — the base .lwp-wsm-card rule already
   sets it, and repeating it would fight the !important display:none that
   filter.js puts on filtered-out cards. */
.lwp-wsm--single .lwp-wsm-card {
    flex-direction: row;
    align-items: stretch;
}

.lwp-wsm--single .lwp-wsm-card-body {
    order: 1;
    flex: 1 1 auto;
    justify-content: center;
    padding: 32px 36px;
}

/* The cover owns the whole right-hand side: flush to the card's edge, no
   inner padding, so the image fills the column instead of floating in the
   middle of it. The base .lwp-wsm-card-media paints --lwp-bg-tertiary, which
   is what made the cover look like a small object hovering in a tall empty
   box rather than the card's own right panel. */
.lwp-wsm--single .lwp-wsm-card-media {
    order: 2;
    flex: 0 0 340px;
    padding: 0;
    background: transparent;
}

.lwp-wsm--single .lwp-wsm-card-media img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: cover;
    object-position: center;
    border-radius: 0;
    box-shadow: none;
    transform: none;
}

.lwp-wsm-empty {
    text-align: center;
    color: var(--lwp-text-muted, #6b7a94);
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    padding: 40px 0;
}

/* ===== Card ===== */
.lwp-wsm-card {
    display: flex;
    flex-direction: column;
    background: var(--lwp-surface, rgba(20, 30, 50, 0.6));
    border: 1px solid var(--lwp-border, rgba(124, 92, 191, 0.2));
    border-radius: var(--wsm-card-radius);
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: var(--wsm-transition);
}

.lwp-wsm-card:hover {
    transform: translateY(-4px);
    border-color: var(--lwp-accent-light, #a382de);
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.lwp-wsm-card.lwp-wsm-hidden {
    display: none !important;
}

/* Cover */
.lwp-wsm-card-media {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 24px;
    background: var(--lwp-bg-tertiary, #151b2d);
}

.lwp-wsm-card-media img {
    max-height: 340px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    transition: var(--wsm-transition);
}

.lwp-wsm-card:hover .lwp-wsm-card-media img {
    transform: translateY(-4px) scale(1.02);
}

/* Body */
.lwp-wsm-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 24px;
}

.lwp-wsm-card-kicker {
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--lwp-accent-light, var(--lwp-accent, #7c5cbf));
    margin: 0 0 10px;
}

.lwp-wsm-card-title {
    font-family: var(--lwp-font-serif, 'Cormorant Garamond', Georgia, serif);
    font-size: clamp(1.4rem, 2.4vw, 1.8rem);
    font-weight: 500;
    line-height: 1.2;
    margin: 0 0 12px;
    /* Base color so unlinked titles (editor preview renders a bare h3) don't fall back to browser-black. The linked frontend variant is colored by the .lwp-wsm-card-title a rule below. */
    color: var(--lwp-text-primary, #e8eaf0);
}

.lwp-wsm-card-title a {
    color: var(--lwp-text-primary, #e8eaf0);
    text-decoration: none;
    transition: var(--wsm-transition);
}

.lwp-wsm-card-title a:hover {
    color: var(--lwp-accent-light, #a382de);
}

.lwp-wsm-card-pub {
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.82rem;
    color: var(--lwp-text-muted, #6b7a94);
    margin: 0 0 12px;
    letter-spacing: 0.02em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.lwp-wsm-card-desc {
    color: var(--lwp-text-secondary, #9aa5b8);
    line-height: 1.7;
    font-size: 0.92rem;
    margin: 0 0 20px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Actions */
.lwp-wsm-card-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 6px;
}

/* Card action buttons use the shared .lwp-btn system (css/lwp-modern-buttons.css) —
   rendered as lwp-btn lwp-btn--primary lwp-btn--md / --ghost. */

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .lwp-wsm--grid .lwp-wsm-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .lwp-wsm {
        padding: 60px 16px;
    }

    .lwp-wsm--grid .lwp-wsm-grid,
    .lwp-wsm--double .lwp-wsm-grid {
        grid-template-columns: 1fr;
    }

    .lwp-wsm-header {
        margin-bottom: 32px;
    }

    .lwp-wsm-card-media img {
        max-height: 300px;
    }

    /* The row layout needs real width for both halves — below this the cover
       squeezes the copy into a column. Stack it back to media-on-top. */
    .lwp-wsm--single .lwp-wsm-card {
        flex-direction: column;
    }

    .lwp-wsm--single .lwp-wsm-card-body {
        order: 2;
        padding: 24px;
    }

    /* Media-first DOM order is what the stacked layout wants, and the stacked
       layout wants the base media treatment back — the flush-fill rules above
       are for the row layout only. */
    .lwp-wsm--single .lwp-wsm-card-media {
        order: 0;
        flex: 0 0 auto;
        padding: 28px 24px;
        background: var(--lwp-bg-tertiary, #151b2d);
    }

    .lwp-wsm--single .lwp-wsm-card-media img {
        width: auto;
        height: auto;
        max-height: 300px;
        object-fit: contain;
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    }

    /* Two pill groups are wide — stack them (label leading each row) before
       the grid itself collapses. */
    .lwp-wsm-filter {
        gap: 16px 24px;
    }

    .lwp-wsm-filter-group {
        flex-basis: 100%;
        justify-content: center;
    }

    .lwp-wsm-filter-group-label {
        flex-basis: 100%;
        text-align: center;
        margin: 0;
    }
}

@media (max-width: 480px) {
    .lwp-wsm {
        padding: 48px 12px;
    }

    .lwp-wsm-card-body {
        padding: 20px;
    }

    .lwp-wsm-card-media {
        padding: 22px 18px;
    }

    .lwp-wsm-card-media img {
        max-height: 260px;
    }

    .lwp-wsm--single .lwp-wsm-card-media {
        padding: 22px 18px;
    }

    .lwp-wsm--single .lwp-wsm-card-media img {
        max-height: 260px;
    }
}

