/* Stories page: cover art fills each card, with the card's copy on a
   nearly transparent panel. Loaded only by page-stories.hbs, after
   library-palette.css, so the shelves elsewhere keep their current layout. */
/* The full-bleed hero band is 100vw wide, which includes the scrollbar and
   made the page scroll sideways. Clip at the viewport (sticky header unaffected). */
html:has(.all-stories-hero) { overflow-x: hidden; }

body.house-brand.page-template :is(.all-stories-discovery .discovery-result, .all-stories-library .collection-card) {
    --backdrop-panel: rgba(5, 17, 32, .38);
    --backdrop-scrim: linear-gradient(180deg, rgba(5, 17, 32, .08) 0%, rgba(5, 17, 32, .14) 40%, rgba(5, 17, 32, .30) 100%);
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: stretch;
    min-width: 0;
    min-height: 0;
    /* Same shape as the title cards (4:3). overflow: clip lets a card grow
       taller rather than cut off its copy on narrow screens. */
    aspect-ratio: 4 / 3;
    padding: 0;
    overflow: hidden;
    overflow: clip;
    border: 1px solid #517b9e;
    border-radius: 6px;
    background: #0b223a;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
}
/* The artwork layer covers the whole card. */
body.house-brand.page-template :is(.all-stories-discovery .discovery-result-image, .all-stories-library .collection-card-art) {
    position: absolute;
    inset: 0;
    z-index: -2;
    align-self: stretch;
    justify-self: stretch;
    width: 100%;
    height: 100%;
    margin: 0;
    grid-area: auto;
}
body.house-brand.page-template :is(.all-stories-discovery .discovery-result-image, .all-stories-library .collection-card-art) img {
    display: block;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    object-fit: cover;
    object-position: center center;
    border-radius: 0;
    background: #0b223a;
    transition: transform .5s ease;
}
/* Keep the title card's lettering in frame on tall cards. */
body.house-brand.page-template :is(.discovery-result-image, .collection-card-art) img.is-title-card { object-position: left center; }
body.house-brand.page-template :is(.all-stories-discovery .discovery-result, .all-stories-library .collection-card)::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--backdrop-scrim);
    pointer-events: none;
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    body.house-brand.page-template :is(.all-stories-discovery .discovery-result, .all-stories-library .collection-card):hover img { transform: scale(1.03); }
}

/* Copy panel. */
body.house-brand.page-template .all-stories-library .collection-card-link {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    flex: 1;
    gap: 0;
    padding: 0;
    color: inherit;
    text-decoration: none;
}
body.house-brand.page-template :is(.all-stories-discovery .discovery-result-copy, .all-stories-library .collection-card-copy) {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0 12px 12px;
    padding: 12px 16px 10px;
    min-width: 0;
    border: 1px solid rgba(244, 232, 206, .16);
    border-radius: 4px;
    background: var(--backdrop-panel);
    -webkit-backdrop-filter: blur(6px) saturate(1.1);
    backdrop-filter: blur(6px) saturate(1.1);
    text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
}
body.house-brand.page-template :is(.all-stories-discovery .discovery-result-copy, .all-stories-library .collection-card-copy) > * { grid-column: auto; grid-area: auto; }
body.house-brand.page-template :is(.all-stories-discovery .discovery-result, .all-stories-library .collection-card) h3 {
    order: -2;
    margin: 0 0 6px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--library-ivory);
    font-size: clamp(21px, 2vw, 26px);
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -.02em;
    overflow-wrap: anywhere;
}
body.house-brand.page-template .all-stories-discovery .discovery-result h3 a { display: inline; padding: 0; color: inherit; }
body.house-brand.page-template :is(.all-stories-discovery .discovery-result h3 a, .all-stories-library .collection-card-link):is(:hover, :focus-visible) h3,
body.house-brand.page-template .all-stories-discovery .discovery-result h3 a:is(:hover, :focus-visible) { color: var(--library-gold); text-decoration: none; }
body.house-brand.page-template :is(.all-stories-discovery .discovery-result small, .all-stories-library .collection-card-meta) { order: -1; margin: 0 0 8px; color: var(--library-gold); font-size: 12px; letter-spacing: .04em; }
body.house-brand.page-template :is(.all-stories-discovery .discovery-result, .all-stories-library .collection-card) p:not(.story-tropes) {
    margin: 0 0 10px;
    color: #eef3f8;
    font-size: 13.5px;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
body.house-brand.page-template .all-stories-library .collection-card-action { margin-top: 4px; min-height: 36px; color: var(--library-gold); }
body.house-brand.page-template .all-stories-discovery .discovery-chapters { position: relative; z-index: 1; margin-top: 4px; }
body.house-brand.page-template .all-stories-discovery .discovery-chapters summary { color: var(--library-gold); }
body.house-brand.page-template .all-stories-discovery .discovery-chapters ol { max-height: 220px; overflow: auto; }
body.house-brand.page-template .all-stories-discovery :is(.discovery-match-context, .discovery-chapters, .discovery-result-copy small) { position: relative; z-index: 1; }

/* Tropes: one row, same place and style on every card. */
body.house-brand.page-template .story-tropes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 10px;
    padding: 0;
    list-style: none;
}
body.house-brand.page-template .story-tropes li {
    padding: 3px 9px;
    border: 1px solid rgba(240, 199, 125, .55);
    border-radius: 999px;
    background: rgba(5, 17, 32, .35);
    color: var(--library-ivory);
    font-size: 11.5px;
    line-height: 1.4;
    letter-spacing: .02em;
    white-space: nowrap;
}

/* Grids: two columns on wide screens, one on phones. */
body.house-brand.page-template :is(.all-stories-discovery .reader-discovery-results, .all-stories-library .collection-grid) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr));
    gap: 22px;
}
@media (max-width: 480px) {
    body.house-brand.page-template :is(.all-stories-discovery .discovery-result-copy, .all-stories-library .collection-card-copy) { margin: 0 8px 8px; padding: 12px 12px 10px; }
    body.house-brand.page-template :is(.all-stories-discovery .discovery-result, .all-stories-library .collection-card) h3 { font-size: 21px; }
}
@media (forced-colors: active) {
    body.house-brand.page-template :is(.all-stories-discovery .discovery-result-copy, .all-stories-library .collection-card-copy) { background: Canvas; backdrop-filter: none; }
    body.house-brand.page-template .story-tropes li { border-color: CanvasText; background: Canvas; color: CanvasText; }
}

/* A story whose cover is missing or fails to load shows the title card. */
body.house-brand.page-template :is(.all-stories-discovery .discovery-result, .all-stories-library .collection-card).has-unavailable-art :is(.discovery-result-image, .collection-card-art) {
    background: #0b223a url("../images/bonus-stories-card.webp") center / cover no-repeat;
}
body.house-brand.page-template :is(.all-stories-discovery .discovery-result, .all-stories-library .collection-card).has-unavailable-art img { visibility: hidden; }
