/* shared/discover/home.css: the cover-led home and Discover (SPEC-HOME, Juno), canonical for stoareads.com and the
   app; home.mjs draws the markup. Colours and fonts are --dh-* tokens each site sets (on .com: reading-room.css :root).
   The cover box itself is cover-box.css's; these rules only size and place it. No ellipsis and no clamp anywhere:
   titles wrap, and a byline steps down its ladder (fit.js). */

/* ---- §2 hero ---- */
.dh-hero { padding-block: 24px 12px; }
.dh-hero h1 { margin: 0; max-width: none; font: 500 32px / 35px var(--dh-display); letter-spacing: -0.02em; color: var(--dh-ink); text-wrap: balance; }
.dh-hero .big-q { max-width: none; margin-top: 16px; }
/* Home v2 (HOME-DISCOVER-V2 §v2.2): one plain line under Seph's tagline (stoareads.com only; the app passes none). */
.dh-hero .dh-lede { margin: 8px 0 0; font: 400 17px / 24px var(--dh-sans); color: var(--dh-mut); }
.dh-try { position: relative; display: flex; align-items: baseline; gap: 16px; margin-top: -4px; font: 400 15px / 20px var(--dh-sans); overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.dh-try::-webkit-scrollbar { display: none; }
.dh-try p { flex: none; scroll-snap-align: start; margin: 0; padding: 12px 0; color: var(--dh-mut); }
.dh-try ul { flex: none; display: flex; gap: 24px; margin: 0; padding: 0 56px 0 0; list-style: none; white-space: nowrap; }
.dh-try li { flex: none; scroll-snap-align: start; }
.dh-try a { display: inline-block; padding: 12px 0; color: var(--dh-ink); text-decoration: none; }
.dh-try a:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
@media (hover: hover) { .dh-try a:hover { text-decoration: underline; text-underline-offset: 3px; } }
/* "Try" scrolls with the suggestions, so nothing sits cut against it (Juno on website PR 384). The fades show only while
   there's more to see that way (fit.js sets data-more and data-back on the line): 56 px at the right, and the list ends
   56 px past its last link, so the cut reads as "scroll for more" and the last suggestion scrolls fully clear (Juno on app
   PR 266); 24 px at the left once scrolled. A mask, not a painted gradient, so the fade is the page itself in both modes
   and never reads as a box. */
.dh-try { --dh-fl: 0px; --dh-fr: 0px; -webkit-mask-image: linear-gradient(to right, transparent, black var(--dh-fl), black calc(100% - var(--dh-fr)), transparent); mask-image: linear-gradient(to right, transparent, black var(--dh-fl), black calc(100% - var(--dh-fr)), transparent); }
.dh-try[data-back] { --dh-fl: 24px; }
.dh-try[data-more] { --dh-fr: 56px; }
.dh-hfan { display: none; }

/* ---- §3 Stoa's best rail ---- */
.sec.dh-best { padding-block: 8px 0; border-top: 0; }
.dh-best .sec-h, .dh-sec .sec-h { margin-bottom: 4px; }
/* The featured Best of (Seph 23:02Z Nov 23, Juno): one line under its heading on what the list is. */
.dh-feat .dh-dek { margin: -4px 0 12px; font: 400 15px / 20px var(--dh-sans); color: var(--dh-mut); }
.dh-best h2.sh, .dh-sec h2.sh { font: 500 var(--dh-h-section, 20px) / 1.15 var(--dh-display); } /* a site that sets --dh-h-section ranks Home's rows with its other sections (PL1) */
.dh-best .sec-h a, .dh-sec .sec-h a { padding: 11px 0; margin-block: -1px; } /* a 44 px target (audit P1 #7); the margin keeps the row its old height */
.dh-rail { display: flex; gap: 16px; margin: 0 -20px 0 0; padding: 0 20px 4px 0; overflow-x: auto; list-style: none; scroll-snap-type: x proximity; scrollbar-width: none; }
.dh-rail::-webkit-scrollbar { display: none; }
.dh-rail li { flex: none; width: 140px; scroll-snap-align: start; }
.dh-bk { display: block; color: var(--dh-ink); text-decoration: none; }
.dh-bc { display: block; }
.dh-bk:focus-visible .dh-bt { text-decoration: underline; text-underline-offset: 3px; }
@media (hover: hover) { .dh-bk:hover .dh-bt { text-decoration: underline; text-underline-offset: 3px; } }
.dh-bt { display: block; margin-top: 8px; font: 600 14px / 18px var(--dh-sans); overflow-wrap: break-word; }
.dh-ba { display: block; overflow: hidden; margin-top: 2px; font: 400 13px / 16px var(--dh-sans); color: var(--dh-mut); white-space: nowrap; }

/* ---- §4 Ways in: cover cards ---- */
.sec.dh-sec { padding-block: 12px 0; border-top: 0; }
.dh-ways { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
/* Cards in a row share its height, the fan at the top and the label at the bottom, so labels share a baseline. */
.dh-ways li { display: flex; }
/* Home's one row (UX-06): below 1024 a sideways rail, the edge of the next card a hint; the six fit one row above. */
/* Home's sideways rows of tiles, Ways in, Genres and By prize alike (Juno, polish PL14 and PL10): bleed to the right
   edge, snap, 2.3 tiles to a phone screen so a cut tile says there's more, and never narrower than 120 px, so a
   one-word label ("Productivity") fits whole. */
ul.dh-wrow { display: flex; gap: 12px; margin: 0 -20px 0 0; padding: 0 20px 0 0; list-style: none; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
.dh-wrow::-webkit-scrollbar { display: none; }
.dh-wrow li { display: flex; flex: none; width: max(120px, calc((100% - 32px) / 2.3)); scroll-snap-align: start; }
/* A genre or prize tile in a row stands like a Ways in card: its cover (or nothing) at the top, the label at the foot. */
.dh-wrow :is(.dh-sj, .dh-pz) { display: grid; grid-template-rows: 72px auto; align-items: start; gap: 0; flex: 1; height: auto; min-height: 120px; padding: 12px; border-radius: var(--r-card,12px); background: var(--dh-sunk); color: var(--dh-ink); text-decoration: none; }
.dh-wrow .dh-sc { width: 48px; }
/* A prize tile is a small plaque (R3-81, SPEC-BY-PRIZE): a 24x2 rule at the top (no laurel, Juno 18:23), the name 12px under it in the
   display face, balanced, whole words, at most 3 lines, and the count pinned to the foot so counts line up. */
.dh-wrow .dh-pz { grid-template-rows: auto auto 1fr; min-height: 136px; padding: 16px; }
.dh-pm { display: block; grid-row: 1; width: 24px; height: 2px; background: var(--dh-mut); }
.dh-pn { grid-row: 2; margin-top: 12px; font: 500 18px / 22px var(--dh-display); color: var(--dh-ink); text-wrap: balance; overflow-wrap: normal; hyphens: none; }
.dh-pc { grid-row: 3; align-self: end; margin-top: 8px; font: 400 13px / 18px var(--dh-sans); color: var(--dh-mut); font-variant-numeric: tabular-nums; }
.dh-pz:focus-visible .dh-pn { text-decoration: underline; text-underline-offset: 3px; }
.dh-pz:focus-visible .dh-pm { background: var(--dh-ink); }
@media (hover: hover) { .dh-pz:hover .dh-pn { text-decoration: underline; text-underline-offset: 3px; } .dh-pz:hover .dh-pm { background: var(--dh-ink); } }
@media (max-width: 599.98px) { .dh-wrow .dh-pz { padding: 14px; } .dh-pn { font-size: 17px; line-height: 21px; } }
/* Six prizes or fewer fill the column from 1024px, where Ways in does too: no short row and no peek (at 900 a sixth of the
   column breaks "Royal Society Science Book Prize" onto four lines, so 900 to 1023 keeps the row). Seven or more scroll. */
@media (min-width: 1024px) { ul.dh-wrow.dh-pzg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); margin-right: 0; padding-right: 0; overflow: visible; } ul.dh-wrow.dh-pzg li { width: auto; } }
.dh-pzl { margin: 24px 0 8px; font: 600 14px / 20px var(--dh-sans); color: var(--dh-mut); }
.dh-wrow .dh-sl { align-self: end; }
/* Narrower than any phone we gate on (Vera B's 260 rig): a two-column card is narrower than its fan, so the cards
   stack one to a row rather than run past the edge (Juno, Nov 14). */
@media (max-width: 299.98px) { .dh-ways:not(.dh-wrow) { grid-template-columns: minmax(0, 1fr); } }
.dh-way { display: grid; grid-template-rows: 72px auto; min-height: 120px; flex: 1; padding: 12px; border-radius: var(--r-card,12px); background: var(--dh-sunk); color: var(--dh-ink); text-decoration: none; }
.dh-fan { display: flex; height: 72px; }
.dh-fc { flex: none; width: 48px; transform-origin: 50% 100%; transform: rotate(calc((var(--i) - 1) * 4deg)); }
.dh-fc + .dh-fc { margin-left: -18px; }
/* Each cover's place in its fan, set here and not inline: the CSP has no 'unsafe-inline' for styles (Vera, live audit). */
.dh-fc, .dh-hc { --i: 0; }
:is(.dh-fc, .dh-hc):nth-child(2) { --i: 1; }
:is(.dh-fc, .dh-hc):nth-child(3) { --i: 2; }
:is(.dh-fc, .dh-hc):nth-child(4) { --i: 3; }
:is(.dh-fc, .dh-hc):nth-child(5) { --i: 4; }
.dh-wl { align-self: end; font: 600 15px / 20px var(--dh-sans); overflow-wrap: break-word; }
/* A fan's covers overlap, so a typeset cover shows its tone without its title (no word cut mid-way)... */
:is(.dh-fc, .dh-hc) .cv-none :is(b, i, .cv-ini) { visibility: hidden; }
/* ...and draws the title-block mark instead (cover-box.css, "Home's fans"). */
.dh-way:focus-visible .dh-wl { text-decoration: underline; text-underline-offset: 3px; }
@media (hover: hover) { .dh-way:hover .dh-wl { text-decoration: underline; text-underline-offset: 3px; } }
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .dh-fc { transition: transform 150ms ease; }
  .dh-way:hover .dh-fc { transform: translateX(calc((var(--i) - 1) * 6px)) rotate(calc((var(--i) - 1) * 4deg)); }
}
@media (prefers-reduced-motion: reduce) { .dh-fc { transform: none; } }

/* ---- §5 Subjects: cover tiles ---- */
.dh-subj { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.dh-subj li:last-child:nth-child(odd) { grid-column: 1 / -1; }
.dh-sj { display: flex; align-items: center; gap: 10px; height: 72px; padding: 6px 10px 6px 6px; border-radius: var(--r-card,12px); background: var(--dh-sunk); color: var(--dh-ink); text-decoration: none; }
.dh-sc { flex: none; width: 40px; }
.dh-sl { font: 600 15px / 20px var(--dh-sans); overflow-wrap: break-word; }
.dh-sj:focus-visible .dh-sl { text-decoration: underline; text-underline-offset: 3px; }
@media (hover: hover) { .dh-sj:hover .dh-sl { text-decoration: underline; text-underline-offset: 3px; } }

/* Under 360 a tile is too narrow for a 13-letter label beside its cover: one column. */
@media (max-width: 359.98px) {
  .dh-subj { grid-template-columns: minmax(0, 1fr); }
  .dh-subj li:last-child:nth-child(odd) { grid-column: auto; }
}

/* Dark: the sunk cards get a hairline inside, so they hold their edge on the dark page. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.dh-way, .dh-sj, .dh-pz) { box-shadow: inset 0 0 0 1px var(--dh-rule); } }
:root[data-theme="dark"] :is(.dh-way, .dh-sj, .dh-pz) { box-shadow: inset 0 0 0 1px var(--dh-rule); }

/* ---- 640 to 1023 ---- */
@media (min-width: 640px) {
  .dh-ways, .dh-subj { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dh-wrow li { width: calc((100% - 56px) / 3.4); }
  .dh-subj li:last-child:nth-child(odd) { grid-column: auto; }
}

/* ---- §6 desktop, 1024 and up ---- */
@media (min-width: 1024px) {
  .dh-home .w { padding-inline: 32px; }
  .dh-hero { display: grid; grid-template-columns: 7fr 5fr; align-items: center; gap: 32px; max-height: 360px; padding-block: 40px 16px; }
  /* One section gap on desktop: 24 above each heading. */
  .sec.dh-sec { padding-top: 24px; }
  .dh-hero h1 { font-size: 48px; line-height: 52px; }
  .dh-hero .big-q { max-width: 560px; }
  /* Flush right (WS-54): the fan opens to the left, so the last cover stands upright on the column's right edge. */
  .dh-hfan { display: flex; justify-content: flex-end; padding-block: 8px; }
  .dh-hc { flex: none; width: 120px; transform-origin: 50% 100%; transform: rotate(calc((var(--i) - 4) * 3deg)); }
  .dh-hc + .dh-hc { margin-left: -48px; }
  .dh-rail { margin-right: 0; padding-right: 0; }
  /* The same tile as every other rail (Nt3-J1): n covers and 0.4 of the next, 4 to 1099, 5 to 1239, then 6. */
  .dh-rail { --dh-rail-n: 4; gap: 24px; }
  .dh-rail li { width: calc((100% - var(--dh-rail-n) * 24px) / (var(--dh-rail-n) + 0.4)); }
  .dh-best h2.sh, .dh-sec h2.sh { font-size: var(--dh-h-section, 24px); }
  .dh-ways { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .dh-ways.dh-wrow { display: grid; margin-right: 0; padding-right: 0; overflow: visible; }
  /* Genres and prizes keep scrolling: 6.4 tiles to the column, flush with it on the right (PL15 adds arrows). */
  ul.dh-wrow { margin-right: 0; padding-right: 0; }
  .dh-wrow:not(.dh-ways) li { width: calc((100% - 72px) / 6.4); }
  .dh-ways.dh-wrow li { width: auto; }
  .dh-way { min-height: 168px; grid-template-rows: 84px auto; }
  .dh-fan { height: 84px; }
  .dh-fc { width: 56px; }
  .dh-fc + .dh-fc { margin-left: -21px; }
  .dh-subj { grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); }
}
/* 1024 to 1199: a narrower column, so smaller covers keep the fan inside it. */
@media (min-width: 1100px) { .dh-rail { --dh-rail-n: 5; } }
@media (min-width: 1240px) { .dh-rail { --dh-rail-n: 6; } }
@media (min-width: 1024px) and (max-width: 1199.98px) {
  .dh-hc { width: 100px; }
  .dh-hc + .dh-hc { margin-left: -44px; }
}
@media (min-width: 1024px) and (prefers-reduced-motion: reduce) { .dh-hc { transform: none; } }
/* Phones: the Try suggestions wrap to a second line, so none runs off the right edge (audit B5; Juno, SPEC-SEARCH-BAR §11).
   Each suggestion still sits whole on its line. The row goes when the search panel's Try rows replace it (step 3).
   UX-16: "Try" and the suggestions wrap as one row of items, so a second line starts at the left edge, not indented
   under the first suggestion. The list itself draws no box (display: contents); gaps sit only between items on a line. */
/* Polish PL4 (Juno, on PR 569): below 900 "Try" and its suggestions are one 44 px line that scrolls sideways, bleeding to
   the screen edge as the rails do, so the hints never take a second row and Stoa's best stays up. */
@media (max-width: 899px) {
  .dh-try { margin-right: -20px; padding-right: 20px; }
}
/* While the search panel hangs under the home bar, the Try row behind it is not drawn, so nothing shows in the gap. */
html.ss-under-open .dh-try { visibility: hidden; }

/* Genres (SPEC-GENRES-SWITCH §2): the lead eight as tiles, two by four below 900 px and four by two from 900 up; then
   home's one row to all 19, or Discover's other eleven as text links, two columns at 375 and one wrapped line wide. */
.dh-subj.dh-gn { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dh-gn li:last-child:nth-child(odd) { grid-column: auto; }
@media (max-width: 359.98px) { .dh-subj.dh-gn { grid-template-columns: minmax(0, 1fr); } }
.dh-all { margin: 4px 0 0; }
.dh-all a { display: inline-flex; align-items: center; min-height: 44px; }
.dh-all a, .dh-mg a { color: var(--dh-ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.dh-mh { margin: 20px 0 8px; font: 600 15px / 20px var(--dh-sans); color: var(--dh-mut); }
.dh-mg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; margin: 0; padding: 0; list-style: none; }
.dh-mg li { display: flex; align-items: center; min-height: 44px; }
.dh-mg a { display: flex; align-items: center; min-height: 44px; min-width: 44px; } /* the whole 44 px row is the link (Vera, G3) */
@media (min-width: 900px) {
  .dh-subj.dh-gn { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dh-mg { display: flex; flex-wrap: wrap; gap: 0 24px; }
}
