/* shared/discover/rails.css: the home rails (Today's book, ranked rows, the path, tile rails, prize chips), canonical for
   stoareads.com and the app. Reads only the --dh-* tokens; edit it here, scripts/shared.mjs splices it into each host.
   Every rule is scoped under :where(.dh-rails), so a host's own .card, .chips or .rank outside it is never touched, and
   the scope adds no specificity, so each host's own overrides win as before. stoareads.com puts the class on <body>
   (its book rows and tiles use these rules on every page); the app puts it on its home's container.
   The actions inside a row (parts.acts, parts.buy) are each host's own markup, so their styles stay with the host. */

:where(.dh-rails) .tr{display:flex;gap:8px;align-items:baseline;font-size:15px;color:var(--dh-ink);margin:0}
/* A lead fitLeads hides (said already along the row) goes, dot and all; the proof slot keeps its row (Vera B on #647). */
:where(.dh-rails) .tr[hidden]{display:none}
:where(.dh-rails) .tr::before{content:"";flex:none;width:7px;height:7px;border-radius:50%;background:var(--dh-ev);transform:translateY(-1px)}
:where(.dh-rails) .tr.n{color:var(--dh-mut)}
:where(.dh-rails) .tr.n::before{background:none;border:1.5px solid var(--dh-mut);width:7px;height:7px}
:where(.dh-rails) .t-a{text-decoration:none}
@media (hover:hover){:where(.dh-rails) .t-a:hover{text-decoration:underline;text-underline-offset:3px}}

/* Today's book, compact (SPEC-PRE-SPRINT A): one book row, cover 72×108, title up to 3 lines, Buy as a text link. */
/* Today's book spans the column, so its rule and actions end at the column's right edge with every other block (Nt2-1). */
:where(.dh-rails) .rank.one{grid-template-columns:1fr}
/* UX-08 (Juno): Want to read and I've read it on one line under the text, 12 px below it, with Buy on Amazon beside
   them on the same line. The text spans the pair's and Buy's columns and the rest, so it never sizes them. */
:where(.dh-rails) .rank.one li{grid-template-columns:72px max-content max-content minmax(0,1fr)}
:where(.dh-rails) .rank.one .cv-a{grid-row:1/3}
:where(.dh-rails) .rank.one .rt{grid-column:2/-1}
:where(.dh-rails) .rank.one .sv-ri{grid-column:2;flex-direction:row;flex-wrap:nowrap;gap:0 16px;margin-top:12px}
:where(.dh-rails) .rank.one h3{-webkit-line-clamp:3;font-size:18px;line-height:24px}
:where(.dh-rails) .rank.one .buy-l{grid-column:3;margin:12px 0 0}
:where(.dh-rails) .rank.one .buy{display:inline-flex;align-items:center;height:44px;padding:0;border:0;border-radius:0;font-weight:600;font-size:15px;text-decoration:underline;text-underline-offset:3px}
:where(.dh-rails) .rank.one .buy-n{grid-column:1/-1;margin:4px 0 0}:where(.dh-rails) .rank.one .buy-note{display:block;font-size:13px;line-height:18px;color:var(--dh-mut)}

/* Highly ranked */
:where(.dh-rails) .rank{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:1fr 1fr;column-gap:56px}
:where(.dh-rails) .rank li{display:grid;grid-template-columns:32px 80px minmax(0,1fr) 168px;gap:0 16px;padding:16px 0;border-top:1px solid var(--dh-rule);align-items:start}
:where(.dh-rails) .rank .n{font:500 20px/24px var(--dh-display);color:var(--dh-mut);font-variant-numeric:lining-nums tabular-nums}
/* One book row (SPEC-SHELL §7.3): every line clamped, so rows side by side keep their actions level with the title. */
:where(.dh-rails) .rank .rt{min-width:0}
:where(.dh-rails) .rank h3{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;margin:0;font:600 17px/24px var(--dh-sans)}
:where(.dh-rails) .rank .by{margin:4px 0 0;overflow-wrap:break-word;color:var(--dh-mut);font-size:15px;line-height:20px}
:where(.dh-rails) .rank .why{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;margin:8px 0 0;font:400 16px/24px var(--dh-display)}
:where(.dh-rails) .rank .tr{margin:8px 0 0;font-size:14px;line-height:20px}:where(.dh-rails) .rank .tr span{min-width:0;text-wrap:pretty}
:where(.dh-rails) .rank .sv-ri{flex-direction:column;align-items:flex-start;gap:0;margin-top:-10px}

/* A modern Stoic path */
:where(.dh-rails) .path{--dh-rail-n:4;display:grid;grid-auto-flow:column;grid-auto-columns:calc((100% - var(--dh-rail-n) * 24px) / (var(--dh-rail-n) + 0.4));gap:24px;list-style:none;margin:0;padding:0;counter-reset:s;overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:none}
:where(.dh-rails) .path::-webkit-scrollbar{display:none}
:where(.dh-rails) .path li{scroll-snap-align:start}
:where(.dh-rails) .path li{counter-increment:s}
:where(.dh-rails) .path .st{font:600 15px var(--dh-sans);color:var(--dh-mut);margin:14px 0 2px}
:where(.dh-rails) .path .st::before{content:counter(s) ". "}
/* The shared card's title under the stage line (Nt5-J2, one card component). */
:where(.dh-rails) .path h3{font:600 16px/22px var(--dh-sans);color:var(--dh-ink);margin:0;overflow-wrap:break-word}

/* Rails */
/* One tile size per width on every rail, the Stoic path and Stoa's best included (Nt3-J1, one card component): a
   rail with few tiles keeps the same tile width and leaves the rest of the column empty rather than stretching. */
:where(.dh-rails) .rail{--dh-rail-n:4;display:grid;grid-auto-flow:column;grid-auto-columns:calc((100% - var(--dh-rail-n) * 24px) / (var(--dh-rail-n) + 0.4));grid-template-rows:repeat(4,auto);gap:0 24px;list-style:none;margin:0;padding:0;overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:none}
:where(.dh-rails) .rail::-webkit-scrollbar{display:none}
/* A rail that scrolls shows n tiles and 0.4 of the next, so it reads as more to the right (Juno, PR 396): 4 from 900,
   5 from 1100, 6 from 1240, about 160 to 210 px a tile. */
@media (min-width:1100px){:where(.dh-rails) :is(.rail,.path){--dh-rail-n:5}}
@media (min-width:1240px){:where(.dh-rails) :is(.rail,.path){--dh-rail-n:6}}
/* One book tile (SPEC-SHELL §7, WS-54): four slots on a subgrid (cover, title with author, proof, actions), so covers,
   proofs and actions line up across a row whatever wraps; the proof slot is as tall as the row's tallest proof, and
   nothing when no tile has one. The author sits right under its own title, so a one-line title leaves no gap (PL9). */
:where(.dh-rails) .card{display:grid;grid-template-rows:subgrid;grid-row:span 4;grid-template-columns:minmax(0,1fr);row-gap:0;min-width:0;scroll-snap-align:start}
/* UX-19: the whole tile is the title's link, so a short title ("Huna", 40×19) is never a small target. The title link's
   box covers the tile; Want to read and I've read it sit above it and keep their own targets. */
:where(.dh-rails) :is(.card,.path li,.rank li){position:relative}
:where(.dh-rails) :is(.card,.path li,.rank li) .t-a::after{content:"";position:absolute;inset:0}
:where(.dh-rails) :is(.card,.path li,.rank li) .sv-ri{position:relative;z-index:1}
:where(.dh-rails) .card .cv-a{display:block}
:where(.dh-rails) .card h3{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;margin:12px 0 0;font:600 16px/22px var(--dh-sans);color:var(--dh-ink)}
:where(.dh-rails) .card h3.t4{-webkit-line-clamp:4}:where(.dh-rails) .card h3.t5{-webkit-line-clamp:5}
:where(.dh-rails) .card .by{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;margin:4px 0 0;color:var(--dh-mut);font-size:15px;line-height:20px}
:where(.dh-rails) .card .pf{min-width:0}
:where(.dh-rails) .card .pf .tr{margin:8px 0 0;font-size:14px;line-height:20px}:where(.dh-rails) .card .pf .tr span{text-wrap:pretty;min-width:0}
/* R3-78 (Seph 16:00 Nov 15, SPEC-CARD-ACTIONS): a tile's two actions say what they do. Icon and words, stacked, each as
   wide as the tile and left-aligned with its title: 32 px drawn, a 44 px target from a vertical ::after across the 12 px
   gap. The pair keeps its two rows (76 px) when Read replaces them, so nothing moves. */
:where(.dh-rails) .card .sv-ri{align-self:end;flex-direction:column;flex-wrap:nowrap;align-items:stretch;gap:0;min-height:44px;margin:8px 0 0}
:where(.dh-rails) .card :is(.sv-s,.ri){position:relative;justify-content:flex-start;gap:8px;width:100%;height:44px;min-height:44px;padding:0;margin:0;font:600 14px/20px var(--dh-sans);white-space:nowrap}
:where(.dh-rails) .card :is(.sv-s,.ri)::after{content:"";position:absolute;inset:0}/* S2: the buttons are 44 px themselves */
:where(.dh-rails) .card :is(.sv-s,.ri) svg{flex:none;width:18px;height:18px}
:where(.dh-rails) .card .ri-wrap{flex-direction:column;flex-wrap:nowrap;align-items:stretch;gap:0}
:where(.dh-rails) .card .ri-wrap > :is(.ri-done,.ri-rate){min-height:44px;padding:0;margin:0;font-size:14px}
/* A rated card (Seph 23:13Z Nov 23): one line on the first action row, the check and "Loved it" in the card's ink, never wrapping. */
.card .ri-wrap > button.ri-card{color:var(--dh-ink);white-space:nowrap}
:where(.dh-rails) .card .sv-ri > :is(.ri-rate,.ri-stars){display:flex;align-items:center;min-height:44px;padding:0;margin:0;font-size:14px}/* the app's Read + Rate slot */
@supports not (grid-template-rows:subgrid){:where(.dh-rails) .card{display:flex;flex-direction:column}:where(.dh-rails) .card .sv-ri{margin-top:auto;padding-top:8px}}
/* VB-58 (Vera B on #653): the laurel prompt stays inside a 140 px Home card (one minmax(0,1fr) column, no wrap), and its
   first laurel lines up with the text. */
:where(.dh-rails) .card .ri-wrap .ri-stars{margin-left:-3px;max-width:calc(100% + 3px)}
:where(.dh-rails) .chips{display:flex;flex-wrap:wrap;gap:0 22px;margin:28px 0 0;padding:0;list-style:none;font-size:15px}
:where(.dh-rails) .chips li:first-child{color:var(--dh-mut);padding:10px 0}
:where(.dh-rails) .chips a{display:inline-block;padding:11px 0;line-height:22px;color:var(--dh-link);font-weight:600;text-underline-offset:3px}

/* "I've read it" (WS-36): next to Save in rows, stacked in rails, its own line under the lead's Save and Buy. */
:where(.dh-rails) .sv-ri{display:flex;flex-wrap:wrap;align-items:center;gap:0 16px}
/* VB-54: read-it.js puts an empty .ri-wrap after each I've read it link for a signed-in member; empty, it takes no room
   and no gap, so rows and tiles don't grow 12 px after first paint (CLS). It fills only when the book is read. */
.sv-ri > .ri-wrap:empty{display:none}

@media (max-width:899px){
  :where(.dh-rails) .path::-webkit-scrollbar,:where(.dh-rails) .rail::-webkit-scrollbar{display:none}
  :where(.dh-rails) .rank{grid-template-columns:1fr}
  :where(.dh-rails) .rank li{grid-template-columns:32px 64px minmax(0,1fr);gap:0 16px;padding:16px 0}
  :where(.dh-rails) .rank li:nth-child(n+7){display:none}
  /* UX-08 (Juno): under 900 px every row's Want to read and I've read it sit on one line under the row, across its
     full width from the numeral or cover, 12 px below it; a text column alone is too narrow for the pair at 320. */
  :where(.dh-rails) .rank .sv-ri{grid-column:1/-1;flex-direction:row;gap:0 16px;margin-top:12px}
  :where(.dh-rails) .rank.one li{grid-template-columns:72px minmax(0,1fr)}
  :where(.dh-rails) .rank.one .sv-ri,:where(.dh-rails) .rank.one .buy-l{grid-column:1/-1}
  :where(.dh-rails) .rank.one .buy-l{margin:0}
  :where(.dh-rails) .rank.one .cv-a{grid-row:auto}
  :where(.dh-rails) .rank.one .buy-n{grid-column:1/-1}
  :where(.dh-rails) .path{grid-template-columns:none;grid-auto-flow:column;grid-auto-columns:140px;overflow-x:auto;margin:0 -20px;padding:0 20px;gap:16px;scrollbar-width:none;scroll-padding:0 20px}
  :where(.dh-rails) .rail{grid-auto-columns:140px;margin:0 -20px;padding:0 20px;gap:0 16px;scroll-padding:0 20px}
}
/* Highly ranked between 900 and 1199: two columns leave the text 59 px beside a 168 px actions column, so the
   actions sit under the text, as on a phone (N3-4 measurement). */
@media (min-width:900px) and (max-width:1199px){
  :where(.dh-rails) .rank:not(.soc-list):not(.one) li{grid-template-columns:32px 80px minmax(0,1fr)}
  :where(.dh-rails) .rank:not(.soc-list):not(.one) .sv-ri{grid-column:3;flex-direction:row;gap:0 16px;margin-top:4px}
}
