/* Public story shelves: paper, plum ink and a restrained book motif.
   Surface colors inherit appearance tokens so light/dark preferences remain intact. */
body:is(.discovery-page,.discovery-detail) {
  --shelf-line:color-mix(in srgb,var(--border) 70%,transparent);
  --shelf-matte:color-mix(in srgb,var(--site-tint) 64%,var(--site-page));
}
.discovery-page .container { max-width:1280px; padding:0 28px 72px; }
.discovery-page .hero { display:grid; grid-template-columns:minmax(0,1.5fr) minmax(280px,1fr); align-items:center; gap:28px; margin:0 0 32px; padding:36px 0 32px; border-color:var(--shelf-line); }
.hero-copy { min-width:0; }
.discovery-page .discovery-eyebrow { font-size:12px; letter-spacing:2px; margin-bottom:17px; }
.discovery-page .hero h1 { font-size:42px; line-height:1.5; letter-spacing:1px; font-weight:500; }
.discovery-page .hero h1 span { display:block; }
.hero-art { position:relative; width:320px; max-width:100%; height:240px; justify-self:center; isolation:isolate; }
.hero-orbit { position:absolute; inset:17px 0; border:1px solid var(--shelf-line); border-radius:50%; transform:rotate(-24deg); }
.hero-orbit::before { content:""; position:absolute; inset:20px -15px; border:1px dashed var(--shelf-line); border-radius:50%; }
.hero-book { position:absolute; width:134px; height:183px; border:1px solid var(--shelf-line); border-radius:3px 9px 9px 3px; }
.hero-book-back { top:25px; left:65px; transform:rotate(-16deg); background:var(--site-sage); box-shadow:6px 7px 0 color-mix(in srgb,var(--site-paper) 80%,var(--border)); }
.hero-book-front { top:28px; left:135px; transform:rotate(11deg); padding:17px 15px 14px 21px; background:var(--site-soft); color:var(--accent-dark); display:flex; flex-direction:column; box-shadow:8px 12px 24px #39273812; }
.hero-book-front::before { content:""; position:absolute; top:0; bottom:0; left:8px; border-left:1px solid color-mix(in srgb,var(--accent) 15%,transparent); }
.hero-book-front > span { font-size:8px; letter-spacing:2px; }
.hero-book-front b { font:500 15px/1.75 var(--font-story); margin-top:16px; }
.hero-book-front i { font-size:27px; font-style:normal; margin-top:9px; font-weight:400; }
.hero-book-front small { margin-top:auto; font-size:7px; letter-spacing:.5px; }
.hero-spark { position:absolute; top:8px; right:24px; font-size:32px; color:var(--accent); }
.discovery-page .plaza-layout { grid-template-columns:144px minmax(0,1fr); gap:30px; }
.discovery-page .category-sidebar { padding:9px 0; background:transparent; border:0; border-radius:0; backdrop-filter:none; }
.discovery-page .category-title { font-family:inherit; font-size:12px; color:var(--ink); margin:4px 12px 10px; }
.discovery-page .category-list { gap:5px; }
.discovery-page .category-list .chip { border:0; border-radius:8px; padding:10px 12px; font-size:12px; background:transparent; box-shadow:none; transform:none; }
html[data-appearance] .discovery-page .category-list .chip.active { color:var(--accent-dark); background:var(--site-soft); font-weight:600; }
.discovery-page .category-list .chip.active .tag-count { color:inherit; }
.discovery-page .tag-count { opacity:1; font-size:10px; }
.discovery-page .search-bar { gap:8px; margin-bottom:26px; }
.discovery-page .search-input { min-height:44px; border-color:var(--shelf-line); border-radius:10px; font-size:13px; padding-left:41px; box-shadow:none; }
html[data-appearance] .discovery-page .search-input { background:var(--site-paper); color:var(--site-ink); }
.discovery-page .search-wrap::before { content:""; width:12px; height:12px; border:1.5px solid var(--ink-light); border-radius:50%; left:17px; opacity:.7; }
.discovery-page .search-wrap::after { content:""; position:absolute; left:29px; top:calc(50% + 4px); width:5px; border-top:1.5px solid var(--ink-light); transform:rotate(45deg); opacity:.7; }
.discovery-page .search-btn { min-height:44px; padding:10px 23px; border-radius:10px; font-size:13px; box-shadow:none; }
.discovery-page .sort-bar { gap:14px; margin-bottom:18px; }
.shelf-heading { font-size:17px; font-weight:600; line-height:1.6; flex:1; }
.shelf-heading span { font-size:12px; font-weight:400; color:var(--ink-light); margin-left:14px; }
.sort-options { display:flex; gap:3px; padding:3px; background:var(--site-tint); border-radius:8px; }
.discovery-page .sort-btn { font-family:inherit; font-size:11px; padding:6px 12px; border-radius:6px; }
html[data-appearance] .discovery-page .sort-btn.active { background:var(--site-paper); color:var(--accent-dark); box-shadow:0 1px 3px #0000000a; }
.discovery-page #search-hint { flex-basis:100%; overflow-wrap:anywhere; }
.discovery-page .grid { gap:24px 20px; align-items:start; }
.discovery-page .story-card { min-width:0; border-color:var(--shelf-line); border-radius:13px; box-shadow:0 2px 6px #39273803; }
.discovery-page .story-card:hover { border-color:color-mix(in srgb,var(--accent) 45%,var(--border)); box-shadow:0 10px 24px #3927380d; }
/* Catalog frames are independent of the author's uploaded crop ratio. */
html[data-appearance] .discovery-page .story-card .cover { position:relative; flex:none; width:100%; min-height:0; box-sizing:border-box; aspect-ratio:3/4 !important; padding:0; background:var(--shelf-matte); border-radius:12px 12px 0 0; border-bottom:1px solid var(--shelf-line); display:flex; align-items:center; justify-content:center; }
.discovery-page .story-card .cover img { position:absolute; inset:0; display:block; width:100%; height:100%; object-fit:cover !important; object-position:center; border-radius:0; box-shadow:none; }
html[data-appearance] .discovery-page .cover-letter { width:100%; background:transparent; color:var(--accent-dark); }
.discovery-page .cover-letter b { font-size:30px; letter-spacing:5px; }
.discovery-page .cover-letter span { font-size:9px; letter-spacing:2px; }
.discovery-page .story-card-body { padding:16px; flex:none; }
.discovery-page .story-card .title { flex:none; font-family:inherit; font-size:16px; font-weight:600; line-height:1.6; height:3.2em; min-height:0; margin-bottom:8px; }
.discovery-page .story-card .desc { font-size:12px; line-height:1.9; height:3.8em; max-height:3.8em; -webkit-line-clamp:2; margin-bottom:10px; }
.discovery-page .story-card .tags { flex:none; flex-wrap:nowrap; align-items:center; height:24px; overflow:hidden; margin-bottom:10px; }
.discovery-page .story-card .tags .chip { flex-shrink:0; box-sizing:border-box; max-height:24px; line-height:1.6; border-radius:5px; padding:2px 6px; background:var(--site-tint); font-size:10px; }
.discovery-page .story-card .meta { flex:none; flex-wrap:nowrap; height:32px; margin-top:0; gap:10px; min-width:0; }
.discovery-page .story-card .meta > :first-child { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.discovery-page .card-author { display:inline-flex;align-items:center;gap:5px;min-width:0;max-width:100%;padding:0;border:0;border-radius:0;background:transparent;color:var(--site-muted);font-size:12px;font-weight:400;line-height:1.7;text-decoration:none; }
.discovery-page .card-author > span { min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration:underline;text-underline-offset:3px;text-decoration-color:color-mix(in srgb,var(--site-muted) 45%,transparent); }
.discovery-page .card-author .author-arrow { width:11px;height:11px;flex-shrink:0; }
.discovery-page .card-author:hover { color:var(--site-ink); }
.discovery-page .card-stats { display:flex;flex-wrap:nowrap;align-items:center;gap:5px 14px;border:0;border-top:1px solid var(--shelf-line);border-radius:0;background:transparent;padding:9px 0 0;margin-top:8px;color:var(--site-muted);font-size:12px;font-weight:400;line-height:1.7;font-variant-numeric:tabular-nums; }
.discovery-page .card-stats > span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.discovery-page .card-share { min-height:28px; }
.discovery-page .skel-card { height:450px; background:var(--site-tint); }
.discovery-page .infinite-scroll-status { color:var(--site-muted); }
.discovery-page .infinite-retry { color:var(--site-accent); }
.discovery-page .infinite-scroll-status[data-state="done"] { padding-top:8px; }
.discovery-detail .detail-wrap { margin-inline:auto; }
.discovery-detail .detail-hero { border-color:var(--shelf-line); box-shadow:0 5px 25px #39273804; }
@media(max-width:1000px) and (min-width:769px) {
  .discovery-page .hero { grid-template-columns:minmax(0,1fr) 260px; }
  .discovery-page .hero h1 { font-size:30px; }
  .hero-art { transform:scale(.85); }
  .shelf-heading span { display:none; }
}
@media(max-width:768px) {
  .discovery-page .container { padding:0 18px 56px; }
  .discovery-page .hero { display:block; padding:28px 0 24px; margin-bottom:18px; }
  .discovery-page .discovery-eyebrow { margin-bottom:12px; font-size:11px; }
  .discovery-page .hero h1 { font-size:29px; line-height:1.55; }
  .hero-art { display:none; }
  .discovery-page .plaza-layout { grid-template-columns:minmax(0,1fr); gap:8px; }
  .discovery-page .category-sidebar { min-width:0; padding:0; margin:0; overflow:visible; }
  .discovery-page .category-list { flex-flow:row nowrap; gap:6px; padding:2px 2px 9px; overflow-x:auto; overflow-y:hidden; overscroll-behavior-inline:contain; scroll-snap-type:x proximity; scrollbar-width:none; border-bottom:1px solid var(--shelf-line); }
  .discovery-page .category-list::-webkit-scrollbar { display:none; }
  .discovery-page .category-list .chip { flex:0 0 auto; scroll-snap-align:start; padding:8px 11px; background:var(--site-paper); border:1px solid var(--shelf-line); border-radius:7px; font-size:11px; white-space:nowrap; }
  .discovery-page .search-bar { margin-bottom:21px; }
  .discovery-page .search-input { font-size:12px; min-height:42px; }
  .discovery-page .search-btn { min-height:42px; padding:9px 16px; font-size:12px; }
  .shelf-heading { font-size:16px; }
  .shelf-heading span { display:none; }
  .discovery-page .sort-bar { margin-bottom:15px; }
  .discovery-page .grid { gap:16px 12px; }
  .discovery-page .story-card-body { padding:13px 11px 11px; }
  .discovery-page .story-card .title { font-size:14px; }
  .discovery-page .story-card .desc { font-size:12px; }
  .discovery-page .story-card .tags { gap:4px; margin-bottom:10px; }
  .discovery-page .story-card .tags .chip { font-size:9px; padding:2px 4px; }
  .discovery-page .story-card .meta { font-size:10px; gap:4px; }
  .discovery-page .card-author { gap:4px;font-size:11px; }
  .discovery-page .card-stats { gap:4px 10px;padding:8px 0 0;font-size:11px; }
  .discovery-page .cover-letter b { font-size:24px; letter-spacing:3px; }
  .discovery-page .cover-letter span { font-size:8px; letter-spacing:1px; }
}
@media(prefers-reduced-motion:reduce) { .discovery-page .story-card,.discovery-page .card-author { transition:none; } }

/* Keep API order visible from left to right, then top to bottom. */
@media(min-width:1101px) {
  .discovery-page .grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media(max-width:768px) {
  .discovery-page .grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .discovery-page .story-card-body { flex:none;width:100%;box-sizing:border-box;padding:8px 9px; }
  .discovery-page .story-card .title { height:auto; min-height:0; margin-bottom:4px; font-size:13px; line-height:1.45; display:block; overflow:visible; overflow-wrap:anywhere; }
  .discovery-page .story-card .desc { height:auto;max-height:none;min-height:0;margin-bottom:4px;font-size:11px;line-height:1.5;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;overflow:hidden; }
  .discovery-page .story-card .tags { height:22px; min-height:0; max-height:22px; margin-bottom:4px; flex-wrap:nowrap; align-items:center; overflow:hidden; }
  .discovery-page .story-card .tags .chip { font-size:9px;line-height:1.4;padding:1px 4px; }
  .discovery-page .story-card .meta { height:24px; min-height:24px; flex-wrap:nowrap; gap:4px; }
  .discovery-page .card-author,.discovery-page .card-share { min-height:24px; font-size:11px; }
  .discovery-page .story-card .card-stats { height:22px;min-height:22px;flex-wrap:nowrap;margin-top:4px;padding:4px 0 0;font-size:10px;gap:4px 8px; }
  .discovery-page .grid .skel-card { height:300px; padding:0; }
  html[data-appearance] body.discovery-page .story-card .cover { height:auto!important;max-height:none!important;aspect-ratio:auto!important;align-self:initial; }
  html[data-appearance] body.discovery-page .story-card .cover img { position:relative!important;inset:auto!important;width:100%!important;height:auto!important;max-height:320px;object-fit:contain!important; }
  .discovery-page .infinite-scroll-status { padding:18px 8px calc(24px + env(safe-area-inset-bottom)); }
}

/* Compact discovery controls and stable cover dimensions. */
.discovery-filter-summary { display:flex; flex-wrap:wrap; gap:4px 12px; align-items:center; margin:-4px 0 18px; color:var(--site-muted); font-size:12px; line-height:1.7; }
.discovery-filter-summary button { font:inherit; color:var(--site-muted); }
.discovery-result-count { margin-right:2px; }
.discovery-filter { border:0; border-bottom:1px solid var(--site-border); background:transparent; padding:4px 0; max-width:100%; overflow-wrap:anywhere; text-align:left; cursor:pointer; }
.discovery-filter span { margin-left:5px; }
.discovery-filter:hover,.discovery-filter-summary .clear-search:hover { color:var(--site-ink); }
.discovery-page #discovery-heading { scroll-margin-top:110px; }
.discovery-page .sort-options { flex-shrink:0; }
.discovery-page .search-wrap { min-width:0; }
.discovery-page .search-input { font-size:16px; box-sizing:border-box; }
.discovery-page .category-retry { color:var(--site-muted); font-size:12px; line-height:1.7; padding:8px 12px; }
.category-retry button { font:inherit; color:var(--site-accent); background:none; border:0; padding:4px 0; cursor:pointer; text-decoration:underline; }
.discovery-page .cover-loading::before { content:""; position:absolute; inset:0; background:linear-gradient(135deg,var(--site-tint),var(--site-paper)); }
.discovery-page .cover-loading img { opacity:0; }
.discovery-page .cover-letter { text-align:center; padding:16px; box-sizing:border-box; }
.discovery-page .cover-letter span { font-size:11px; letter-spacing:1px; }
.discovery-page .grid .skel-card { width:100%; height:auto; min-height:0; aspect-ratio:3/4; padding:0; box-sizing:border-box; }
.discovery-page :is(.search-btn,.sort-btn,.category-list .chip) { min-height:40px; }
.discovery-page :is(.search-input,.search-btn,.sort-btn,.category-list button,.discovery-filter-summary button):focus-visible { outline:2px solid var(--site-accent); outline-offset:3px; }
@media(max-width:768px) {
  .discovery-page .category-title { margin:0 0 8px; }
  .discovery-page .category-list { flex-direction:row; flex-wrap:nowrap; overflow-x:auto; overscroll-behavior-x:contain; max-width:100%; padding:4px 2px 10px; }
  .discovery-page .category-list .chip { flex-shrink:0; white-space:nowrap; min-height:42px; }
  .discovery-page .category-retry { flex-shrink:0; margin:0; padding:8px 2px; }
  .discovery-page .search-input { min-height:44px; }
  .discovery-page .search-btn { min-height:44px; }
  .discovery-filter-summary { margin-top:-2px; gap:2px 12px; }
  .discovery-filter-summary button { min-height:36px; }
  .discovery-page .story-card .meta { gap:4px 8px; }
  .discovery-page .card-author { min-height:32px; max-width:100%; }
  .discovery-page .card-share { min-height:32px; margin-left:auto; padding:4px 0; }
}
@media(prefers-reduced-motion:reduce) {
  .discovery-page .infinite-scroll-status[data-state="loading"]::before { animation:none; }
}
