/* PART-COVER-001..006: one fixed frame per kind, everywhere.
   /cover-frame prepares whole sharp artwork plus its edge/blur surround once.
   The source-image error fallback is contained, never stretched or cropped. */
[data-kind="ebook"], [data-kind="fanfiction"], .details.ebook, .details.fanfiction { --cover-ar: 2 / 3; }
[data-kind="audiobook"], [data-kind="music"], .details.audiobook, .details.music { --cover-ar: 1; }
[data-kind="magazine"], .details.magazine { --cover-ar: 3 / 4; }
.bk.bk-plate[data-kind].bk .c-cov:not(#_) { width:100%; height:auto; max-width:none; margin:0; aspect-ratio:var(--cover-ar, var(--ar, 2/3)); overflow:hidden; }
.bk.bk-plate[data-kind].bk .c-cov:not(#_) img { display:block; width:100%; height:100%; max-width:none; max-height:none; object-fit:contain; }
.bk.bk-plate[data-kind]:not([data-kind="ebook"]):not(#_) .bk-cover { height:auto; }
.bk.bk-plate[data-kind]:not([data-kind="ebook"]).bk:not(#_) { height:auto; grid-template-rows:auto auto; align-self:start; }
.nv-mount:not(#_), .dt-card.dv .mount:not(#_) { aspect-ratio:var(--cover-ar, 2/3); height:auto; }
.nv-mount:not(#_) > img, .dt-card.dv .mount:not(#_) > img { position:absolute; inset:0; display:block; width:100%; height:100%; max-width:none; max-height:none; object-fit:contain; }
/* Specific old mode sheets must never crop the foreground on smaller surfaces. */
img.cover-image { object-fit:contain !important; }
img.cover-image[hidden] { display:none !important; }
.mini-books .cover-image:not(#_), .dt-strip .cover-image:not(#_), .tr-row .cover-image:not(#_), .sh-pick .cover-image:not(#_), .fin-cover.cover-image:not(#_) { height:auto; aspect-ratio:var(--cover-ar, 2/3); }
/* Preserve the approved collage composition. Each cell receives a rendered
   whole cover at its kind ratio; only the prepared background can be cropped. */
.mu-collage:not(#_), .ff-collage:not(#_) { position:static; inset:auto; overflow:hidden; display:grid; gap:3px; width:100%; grid-template-columns:1fr 1fr; grid-template-rows:1fr 1fr; background:rgba(0,0,0,.28); }
.mu-collage:not(#_) { aspect-ratio:1; }
.ff-collage:not(#_) { aspect-ratio:2/3; }
.mu-collage[data-n="1"]:not(#_), .ff-collage[data-n="1"]:not(#_) { grid-template-columns:1fr; grid-template-rows:1fr; gap:0; }
.mu-collage[data-n="2"] > :nth-child(2):not(#_), .ff-collage[data-n="2"] > :nth-child(2):not(#_) { grid-column:2; grid-row:2; }
.mu-collage > img:not(#_), .ff-collage > img:not(#_) { display:block; width:100%; height:100%; min-height:0; object-fit:contain; }
.ff-letter:not(#_) { display:flex; align-items:center; justify-content:center; background:#2a1a2b; color:#e0aaff; font:800 48px Manrope,sans-serif; opacity:.5; }
.nv-mount > .cov-plate.text-thumb:not(#_), .dt-card.dv .mount > .cov-plate.text-thumb:not(#_) { width:100%; height:100%; aspect-ratio:var(--cover-ar,2/3); position:absolute; inset:0; }
.pub-grid > .pub-card:not(#_) { width:238px; flex:0 0 238px; }
.pub-card .c-cov:not(#_) { width:100%; height:auto; aspect-ratio:3/4; overflow:hidden; }
.pub-card .c-cov:not(#_) img { display:block; width:100%; height:100%; max-width:none; object-fit:contain; }
@media(max-width:600px) { .pub-grid > .pub-card:not(#_) { width:155px; flex:0 0 155px; } }

[data-cover-fallback-plate] { position:relative; width:100%; height:100%; min-height:0; aspect-ratio:var(--cover-ar,2/3); overflow:hidden; }

/* PART-COVER-007: Home slots are the same complete object, not just equal
   pictures. Group cards, work cards and empty actions share one footprint. */
.screen-in[data-kind] { --home-card-width:170px; --home-cover-factor:1.5; --home-meta-height:96px; --home-cover-height:calc((var(--home-card-width) - 20px) * var(--home-cover-factor) + 18px); --home-card-height:calc(var(--home-cover-height) + var(--home-meta-height) + 2px); }
.screen-in[data-kind="audiobook"], .screen-in[data-kind="music"] { --home-cover-factor:1; }
.screen-in[data-kind="magazine"] { --home-cover-factor:1.3333333333; }
.screen-in[data-kind]:not([data-kind="ebook"]).screen-in .grid > .card.bk.bk-plate[data-kind],
.screen-in[data-kind]:not([data-kind="ebook"]).screen-in .grid > .free.free-add {
  box-sizing:border-box; width:var(--home-card-width); min-width:var(--home-card-width); max-width:var(--home-card-width);
  height:var(--home-card-height); min-height:var(--home-card-height); max-height:var(--home-card-height);
  flex:0 0 var(--home-card-width); align-self:start; grid-template-rows:var(--home-cover-height) var(--home-meta-height); overflow:hidden;
}
.screen-in[data-kind]:not([data-kind="ebook"]).screen-in .grid > .card.bk.bk-plate[data-kind] > .bk-cover { box-sizing:border-box; height:var(--home-cover-height); min-height:0; overflow:hidden; }
.screen-in[data-kind]:not([data-kind="ebook"]).screen-in .grid > .card.bk.bk-plate[data-kind] > .bk-id {
  box-sizing:border-box; position:relative; height:var(--home-meta-height); min-height:var(--home-meta-height); max-height:var(--home-meta-height); padding:0; grid-template-rows:52px 44px; overflow:hidden;
}
.screen-in[data-kind]:not([data-kind="ebook"]).screen-in .grid > .card.bk.bk-plate[data-kind] .bk-id::after { top:58px; bottom:3px; }
.screen-in[data-kind]:not([data-kind="ebook"]).screen-in .grid > .card.bk.bk-plate[data-kind] .bk-id > h3.bk-title {
  display:-webkit-box !important; -webkit-box-orient:vertical !important; -webkit-line-clamp:2 !important; line-clamp:2 !important;
  position:absolute; top:8px; left:0; right:0; margin:0; height:36px !important; min-height:36px !important; max-height:36px !important; line-height:18px !important; overflow:hidden !important;
}
.screen-in[data-kind]:not([data-kind="ebook"]).screen-in .grid > .card.bk.bk-plate[data-kind] .bk-id > .bk-author {
  position:absolute !important; top:70px !important; left:8px; right:8px; margin:0 !important; transform:none !important; height:20px; min-height:20px; max-height:20px; line-height:20px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
@media(max-width:900px) { .screen-in[data-kind] { --home-card-width:156px; } }

/* Supplied Home Details artwork fits the existing button footprint. */
.screen-in .bk-home .bk-info { background:transparent !important; border-color:transparent !important; box-shadow:none !important; }
.screen-in .bk-home .bk-info > img.details-button-art { display:block; position:static; width:100%; height:100%; max-width:100%; max-height:100%; object-fit:contain; pointer-events:none; }
.screen-in[data-kind="ebook"] .details-button-art { filter:saturate(.65); }
.screen-in[data-kind="fanfiction"] .details-button-art { filter:hue-rotate(235deg) saturate(.8); }
.screen-in[data-kind="magazine"] .details-button-art { filter:hue-rotate(145deg) saturate(.65); }
.screen-in[data-kind="music"] .details-button-art { filter:hue-rotate(55deg) saturate(.8); }

/* Missing artwork reserves exactly the same image area as a real cover. */
.bk.bk-plate[data-kind].bk .c-cov:not(#_) > .cov-plate.text-thumb:not(#_) {
  position:absolute; inset:0; box-sizing:border-box; width:100%; height:100%; min-width:0; min-height:0; max-width:none; max-height:none; aspect-ratio:auto; overflow:hidden;
}

/* Keep Settings below the phone mode selector in every mode. */
@media (max-width:900px) { html[data-plate][data-shelf] .cog { top:calc(var(--HC, 64px) + 6px); width:36px; height:36px; } }

/* Keep actions near the available content when a description is absent. */
@media (min-width:901px) {
  html[data-plate][data-shelf] .details .dt-card.dv .detail-main:not(:has(.description)) .orn-divider { margin:24px 0 14px; }
}
/* An empty related shelf needs no large decorative banner. */
html[data-plate][data-shelf] .details .dt-card.dv .author-rail.rail-empty { min-height:0; padding:12px 24px !important; }
html[data-plate][data-shelf] .details .dt-card.dv .author-rail.rail-empty::before,
html[data-plate][data-shelf] .details .dt-card.dv .author-rail.rail-empty::after { display:none; }
html[data-plate][data-shelf] .details .dt-card.dv .rail-empty .author-copy strong { font-size:16px; }

/* A soft wash from the existing first cover fills unoccupied collage cells. */
.bk-cover:has(> .mu-collage), .bk-cover:has(> .ff-collage) { position:relative; overflow:hidden; }
.bk-cover > img.collage-bg.cover-image { position:absolute; inset:-12%; width:124%; height:124%; max-width:none; max-height:none; object-fit:cover !important; filter:blur(18px) brightness(.45); opacity:.8; }
.bk-cover > .mu-collage:not(#_), .bk-cover > .ff-collage:not(#_) { position:relative; z-index:1; background:transparent; }
.bk-cover > img.collage-bg + [data-cover-fallback-plate] { display:none; }

/* Size the fallback cover lettering to the small Now cover itself. */
.screen-in[data-kind] .nv-mount { container-type:inline-size; }
html[data-plate][data-shelf] .screen-in[data-kind] .nv-mount > .text-thumb { box-sizing:border-box; padding:10%; gap:4%; overflow:hidden; }
html[data-plate][data-shelf] .screen-in[data-kind] .nv-mount > .text-thumb b { display:block; width:100%; max-width:100%; padding:0; font-size:clamp(7px, 11cqw, 18px); line-height:1.12; overflow-wrap:anywhere; -webkit-line-clamp:unset; }
html[data-plate][data-shelf] .screen-in[data-kind] .nv-mount > .text-thumb span { display:block; width:100%; max-width:100%; padding:0; font-size:clamp(6px, 8cqw, 12px); line-height:1.12; overflow-wrap:anywhere; -webkit-line-clamp:unset; }
