/* ==========================================================================
   LWP Extras — modern mode
   Sections on work (.lwp-mw-*) and series (.lwp-ms-*) pages, the card grid
   (.lwp-ex-*), and the single/archive extras pages. Palette variables use
   the shared --lwp-* system with hardcoded fallbacks; every selector is
   scoped to the lwp-ex/lwp-mw-extras/lwp-ms-extras prefixes.
   ========================================================================== */

/* ===== CARD (shared by work/series sections + archive) ===== */

.lwp-ex-card {
    /* Anchor for the stretched title link (see .lwp-ex-card-title a::after). */
    position: relative;
    background: var(--lwp-surface, rgba(20, 30, 50, 0.6));
    border: 1px solid var(--lwp-border, rgba(124, 92, 191, 0.2));
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: var(--lwp-transition, all 0.4s cubic-bezier(0.4, 0, 0.2, 1));
}

.lwp-ex-card:hover {
    background: var(--lwp-surface-hover, rgba(30, 45, 70, 0.8));
    transform: translateY(-2px);
}

.lwp-ex-card-media {
    line-height: 0;
}

.lwp-ex-card-media img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.lwp-ex-card-body {
    padding: 24px 24px 28px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.lwp-ex-badge {
    display: inline-block;
    align-self: flex-start;
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--lwp-accent-light, #a382de);
    background: var(--lwp-accent-glow, rgba(124, 92, 191, 0.12));
    border: 1px solid var(--lwp-border, rgba(124, 92, 191, 0.2));
    border-radius: 999px;
    padding: 4px 12px;
    margin-bottom: 14px;
}

.lwp-ex-card-title {
    font-family: var(--lwp-font-serif, 'Cormorant Garamond', Georgia, serif);
    font-size: 1.45rem;
    font-weight: 500;
    line-height: 1.3;
    margin: 0 0 10px;
}

.lwp-ex-card-title a {
    color: var(--lwp-text-primary, #e8eaf0);
    text-decoration: none;
    transition: var(--lwp-transition, all 0.4s cubic-bezier(0.4, 0, 0.2, 1));
}

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

/*
 * Whole-card link: the title anchor's ::after is stretched over the entire
 * card, so clicking anywhere (media, badge, padding, blank space) opens the
 * extra. The card keeps overflow:hidden, so the hit-area respects the rounded
 * corners. Download/Visit buttons stack above it and keep their own targets.
 */
.lwp-ex-card-title a::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Move the keyboard ring from the title text onto the whole card. */
.lwp-ex-card-title a:focus-visible {
    outline: none;
}

.lwp-ex-card-title a:focus-visible::after {
    outline: 2px solid var(--lwp-accent-light, #a382de);
    outline-offset: -3px;
}

.lwp-ex-card-desc {
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--lwp-text-muted, #6b7a94);
    margin: 0 0 18px;
    flex: 1;
}

.lwp-ex-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/*
 * Buttons sit above the stretched link so Download/Visit keep their own
 * targets. Lifted per-button rather than on the row, otherwise the row's
 * empty strip beside the buttons would swallow card clicks.
 */
.lwp-ex-card-actions a {
    position: relative;
    z-index: 2;
}

/* ===== GRID ===== */

.lwp-ex-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

/* ===== WORK PAGE SECTION ===== */

.lwp-mw-extras {
    background: var(--lwp-bg-secondary, #0f1420);
    padding: 80px 24px;
}

.lwp-mw-extras-inner {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== SERIES PAGE SECTION ===== */

.lwp-ms-extras {
    background: var(--lwp-bg-primary, #0a0e17);
    padding: 80px 24px;
}

.lwp-ms-extras-inner {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== SINGLE EXTRA PAGE ===== */

.lwp-ex-single {
    background: var(--lwp-bg-primary, #0a0e17);
}

.lwp-ex-single-hero {
    padding: 72px 24px 48px;
    text-align: center;
}

.lwp-ex-single-hero-inner {
    max-width: 720px;
    margin: 0 auto;
}

.lwp-ex-single-hero img {
    max-width: 100%;
    max-height: 340px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
    margin-bottom: 28px;
}

.lwp-ex-single-hero .lwp-ex-badge {
    align-self: auto;
    display: inline-block;
    margin-bottom: 16px;
}

.lwp-ex-single-title {
    font-family: var(--lwp-font-serif, 'Cormorant Garamond', Georgia, serif);
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    font-weight: 400;
    line-height: 1.15;
    color: var(--lwp-text-primary, #e8eaf0);
    margin: 0 0 24px;
}

.lwp-ex-single-content {
    background: var(--lwp-bg-secondary, #0f1420);
    padding: 64px 24px;
}

.lwp-ex-single-content-inner {
    max-width: 720px;
    margin: 0 auto;
}

.lwp-ex-single-body {
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 1.05rem;
    line-height: 1.9;
    color: var(--lwp-text-secondary, #9aa5b8);
}

.lwp-ex-single-body p {
    margin-bottom: 1.5em;
}

.lwp-ex-single-body p:last-child {
    margin-bottom: 0;
}

/* Single image (content type: image) */
.lwp-ex-single-figure {
    margin: 0 0 24px;
}

.lwp-ex-single-figure img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
}

/* Gallery (content type: gallery) — three layouts */
.lwp-ex-gallery {
    margin-bottom: 24px;
}

/* Carousel: large stage + thumbnail strip */
.lwp-ex-gallery-stage {
    margin: 0 0 16px;
    height: 460px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--lwp-surface, #14161c);
    border-radius: 12px;
    overflow: hidden;
}

.lwp-ex-gallery-main {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.lwp-ex-gallery-caption {
    margin-top: 10px;
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--lwp-text-muted, #7c8698);
    text-align: center;
    /* Reserve ~4 lines so swapping images doesn't reflow the stage. */
    min-height: calc(4 * 1.5em);
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.lwp-ex-gallery-caption:empty {
    min-height: 0;
    margin-top: 0;
}

.lwp-ex-gallery-thumbs-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lwp-ex-gallery-thumbs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding: 4px 2px;
    flex: 1;
    scrollbar-width: thin;
}

.lwp-ex-gallery-thumb {
    flex: 0 0 auto;
    width: 84px;
    height: 64px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    background: none;
    cursor: pointer;
    scroll-snap-align: start;
    overflow: hidden;
}

.lwp-ex-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lwp-ex-gallery-thumb.is-active {
    border-color: var(--lwp-accent, #c9a227);
}

.lwp-ex-gallery-thumb:focus-visible {
    outline: 2px solid var(--lwp-accent, #c9a227);
    outline-offset: 2px;
}

.lwp-ex-gallery-arrow {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--lwp-surface, #14161c);
    color: var(--lwp-text-primary, #f5f7fa);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lwp-ex-gallery-arrow:hover {
    background: var(--lwp-accent, #c9a227);
    color: #14161c;
}

/* Grid: all images, click to zoom */
.lwp-ex-gallery--grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.lwp-ex-gallery-grid-item {
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 12px;
    background: none;
    cursor: zoom-in;
    overflow: hidden;
    aspect-ratio: 4 / 3;
}

.lwp-ex-gallery-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.lwp-ex-gallery-grid-item:hover img {
    transform: scale(1.04);
}

.lwp-ex-gallery-grid-item:focus-visible {
    outline: 2px solid var(--lwp-accent, #c9a227);
    outline-offset: 2px;
}

/* Stacked: full-width images with captions */
.lwp-ex-gallery-stack {
    margin: 0 0 24px;
}

.lwp-ex-gallery-stack img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
}

.lwp-ex-gallery-stack figcaption {
    margin-top: 8px;
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--lwp-text-muted, #7c8698);
    text-align: center;
    /* Reserve ~4 lines so captions of varying length don't reflow. */
    min-height: calc(4 * 1.5em);
}

/* Lightbox (grid only) */
.lwp-ex-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.lwp-ex-lightbox[hidden] {
    display: none;
}

.lwp-ex-lightbox-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90vw;
    max-height: 90vh;
}

.lwp-ex-lightbox-figure {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lwp-ex-lightbox-img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
}

.lwp-ex-lightbox-caption {
    margin-top: 12px;
    color: #f5f7fa;
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.95rem;
    text-align: center;
}

.lwp-ex-lightbox-counter {
    margin-top: 6px;
    color: #9aa5b8;
    font-size: 0.85rem;
}

.lwp-ex-lightbox-close,
.lwp-ex-lightbox-prev,
.lwp-ex-lightbox-next {
    position: absolute;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lwp-ex-lightbox-close:hover,
.lwp-ex-lightbox-prev:hover,
.lwp-ex-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.28);
}

.lwp-ex-lightbox-close {
    top: 20px;
    right: 20px;
}

.lwp-ex-lightbox-prev {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.lwp-ex-lightbox-next {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

@media (max-width: 600px) {
    .lwp-ex-gallery-stage {
        height: 300px;
    }

    .lwp-ex-gallery-thumb {
        width: 64px;
        height: 50px;
    }
}

.lwp-ex-single-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 32px;
}

/* Related books / series chips */

.lwp-ex-related {
    padding: 40px 24px 72px;
}

.lwp-ex-related-inner {
    max-width: 720px;
    margin: 0 auto;
}

.lwp-ex-related-label {
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--lwp-accent-light, #a382de);
    margin: 0 0 14px;
}

.lwp-ex-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.lwp-ex-chip {
    display: inline-block;
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 0.85rem;
    color: var(--lwp-text-secondary, #9aa5b8);
    background: var(--lwp-surface, rgba(20, 30, 50, 0.6));
    border: 1px solid var(--lwp-border, rgba(124, 92, 191, 0.2));
    border-radius: 999px;
    padding: 8px 16px;
    text-decoration: none;
    transition: var(--lwp-transition, all 0.4s cubic-bezier(0.4, 0, 0.2, 1));
}

.lwp-ex-chip:hover {
    color: var(--lwp-text-primary, #e8eaf0);
    border-color: var(--lwp-accent, #7c5cbf);
}

/* ===== ARCHIVE PAGE ===== */

.lwp-ex-archive {
    background: var(--lwp-bg-primary, #0a0e17);
    min-height: 60vh;
}

.lwp-ex-archive-hero {
    padding: 72px 24px 48px;
    text-align: center;
}

.lwp-ex-archive-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

.lwp-ex-archive-empty {
    font-family: var(--lwp-font-sans, 'Inter', -apple-system, sans-serif);
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--lwp-text-muted, #6b7a94);
    text-align: center;
    padding: 48px 24px;
}
