/* Snug: how lists of posts are laid out (the home page, tags, days, the archive's lists). The layout puts one class
   on <body>, from Settings → Appearance → Lists of posts (or from the Snug theme in use): layout-cards, -columns,
   -masonry, -carousel, -pages, -magazine, -index, -spine. Without a class the list is the timeline it always was.
   Only what is inside .h-feed changes: a post's own page is never touched, the markup and its microformats stay as
   they are, and the order on screen follows the order in the page. On phones every layout is one column. */

/* wide layouts: the list may be wider than a column of text */
:is(.layout-columns,.layout-masonry,.layout-magazine,.layout-spine,.layout-carousel) .main:has(> .h-feed){max-width:calc(var(--list-w,66rem) + 2*var(--gut))}
:is(.layout-columns,.layout-masonry,.layout-magazine,.layout-spine,.layout-carousel) :is(.site-head .head-row,.site-foot .foot-row){max-width:calc(var(--list-w,66rem) + 2*var(--gut))}
.layout-spine{--list-w:58rem}
.layout-carousel{--list-w:52rem}
.h-feed > .pagination{clear:both}

/* a post as a card: shared by several layouts */
:is(.layout-cards,.layout-masonry,.layout-carousel) .h-feed .status,
:is(.layout-cards,.layout-masonry) .h-feed .article-card{padding:clamp(14px,2.4vw,20px) clamp(16px,2.6vw,22px);border:0;border-radius:var(--radius);background:var(--surface);box-shadow:0 0 0 1px var(--rail,var(--rule)),0 10px 24px -20px rgba(0,0,0,.35)}
:is(.layout-cards,.layout-masonry,.layout-carousel) .h-feed .status::before{content:none}

/* ---------- cards: each post a card, the day a label above them ---------- */
.layout-cards .h-feed .day + .day{border-top:0;padding-top:0}
.layout-cards .h-feed .day > .entry + .entry{border-top:0}
.layout-cards .h-feed .day > .entry + .status-day{padding-top:0}
.layout-cards .h-feed .day{margin-bottom:clamp(22px,4vw,34px)}
.layout-cards .h-feed .entry{margin-bottom:14px}
.layout-cards .h-feed .status + .status{margin-top:14px}
.layout-cards .h-feed .day-title{margin-bottom:.7em}

/* ---------- columns: a blogroll in two columns, read across ---------- */
@media (min-width:760px){
  .layout-columns .h-feed{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:clamp(28px,4vw,44px) clamp(32px,5vw,64px);align-items:start}
  .layout-columns .h-feed > :not(.day){grid-column:1/-1}
  .layout-columns .h-feed > .pinned{grid-column:1/-1}
  .layout-columns .h-feed .day,.layout-columns .h-feed .day + .day{margin:0;padding-top:clamp(18px,2.6vw,26px);border-top:1px solid var(--rail,var(--rule))}
  .layout-columns .h-feed > .page-title{margin-bottom:0}
  .layout-columns .h-feed .article-title{flex-basis:100%}
}

/* ---------- masonry: a waterfall of cards, pictures large ---------- */
.layout-masonry .h-feed .day,.layout-masonry .h-feed .day + .day{margin:0;padding:0;border:0}
.layout-masonry .h-feed .day > .entry + .entry{border-top:0}
.layout-masonry .h-feed .day > .entry + .status-day{padding-top:0}
.layout-masonry .h-feed .entry{margin:0 0 16px;break-inside:avoid}
.layout-masonry .h-feed .status-day{display:grid;gap:10px}
.layout-masonry .h-feed .status + .status{margin-top:0}
.layout-masonry .h-feed .day-title{margin:6px 0 0;font-size:.82rem;letter-spacing:.02em;color:var(--ink-2)}
.layout-masonry .h-feed .media.compact{--cap:none}
.layout-masonry .h-feed .media.compact .gallery-1 .gallery-item{max-width:none}
.layout-masonry .h-feed .article-card .article-cover{float:none;width:auto;margin:0 0 .8em}
.layout-masonry .h-feed .article-title{flex-basis:100%;font-size:clamp(1.2rem,1.6vw,1.45rem)}
@media (min-width:640px){
  .layout-masonry .h-feed{columns:3 17rem;column-gap:16px}
  .layout-masonry .h-feed > :not(.day),.layout-masonry .h-feed > .pinned{column-span:all}
}

/* ---------- carousel: a day's statuses side by side, swiped or stepped through ---------- */
.layout-carousel .h-feed .status-day{position:relative;display:grid;grid-auto-flow:column;grid-auto-columns:min(86%,21rem);grid-template-rows:auto 1fr;gap:0 14px;overflow-x:auto;overscroll-behavior-x:contain;scroll-snap-type:x mandatory;scroll-padding-left:2px;scrollbar-width:thin;padding:2px 2px 14px;margin-left:-2px;margin-right:-2px}
.layout-carousel .h-feed .status-day:focus-visible{outline-offset:6px}
.layout-carousel .h-feed .day-title{grid-row:1;grid-column:1;position:sticky;left:2px;width:max-content;max-width:86vw}
.layout-carousel .h-feed .status{grid-row:2;margin:0;scroll-snap-align:start}
.layout-carousel .h-feed .status + .status{margin-top:0}
.layout-carousel .h-feed .status-day:has(.status:only-of-type){grid-auto-columns:minmax(0,100%)}
.lay-steps{display:flex;justify-content:flex-end;gap:8px;margin:0 0 14px}
.lay-steps[hidden]{display:none}
.lay-step{appearance:none;-webkit-appearance:none;display:grid;place-items:center;width:40px;height:40px;padding:0;border:1px solid var(--rule);border-radius:50%;background:var(--surface);color:var(--ink);font:inherit;cursor:pointer}
.lay-step:hover{border-color:var(--ink)}
.lay-step:disabled{opacity:.35;cursor:default}
.lay-step svg{display:block}

/* ---------- pages: a day to a screen, turned like pages ---------- */
@media (min-height:520px){
  html:has(body.layout-pages .h-feed){scroll-snap-type:y proximity;scroll-padding-top:72px}
  /* each day a sheet of paper, read from its top like a page, the next one under it */
  .layout-pages .h-feed .day,.layout-pages .h-feed .day + .day{display:flex;flex-direction:column;justify-content:flex-start;min-height:min(calc(100vh - 170px),760px);min-height:min(calc(100svh - 170px),760px);margin:0 0 clamp(20px,4vh,36px);padding:clamp(28px,5vh,52px) clamp(20px,4vw,48px);border:1px solid var(--rule);border-radius:calc(var(--radius,12px) * .5);background:var(--surface,var(--paper));box-shadow:0 1px 0 var(--rule),0 18px 40px -30px rgba(0,0,0,.45)}
  .layout-pages .h-feed .day{scroll-snap-align:start}
  .layout-pages .h-feed{padding-bottom:72px} /* room above the page buttons */
}
.lay-turn{position:fixed;z-index:24;left:50%;bottom:max(16px,calc(env(safe-area-inset-bottom,0px) + 10px));display:flex;align-items:center;gap:4px;padding:4px;border:1px solid var(--rule);border-radius:999px;background:color-mix(in srgb,var(--paper) 86%,transparent);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);transform:translateX(-50%);box-shadow:0 12px 28px -18px rgba(0,0,0,.5)}
.lay-turn .lay-step{border-color:transparent;background:transparent}
.lay-turn .lay-step:hover:not(:disabled){background:color-mix(in srgb,var(--ink) 8%,transparent)}
.lay-count{min-width:3.4em;color:var(--ink-2);font-size:.82rem;font-variant-numeric:tabular-nums;text-align:center}

/* ---------- magazine: the newest day leads, the rest in a grid under it ---------- */
@media (min-width:760px){
  .layout-magazine .h-feed{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:clamp(28px,4vw,48px) clamp(24px,3vw,40px);align-items:start}
  .layout-magazine .h-feed > :not(.day),.layout-magazine .h-feed > .pinned{grid-column:1/-1}
  .layout-magazine .h-feed .day,.layout-magazine .h-feed .day + .day{margin:0;padding-top:clamp(16px,2vw,22px);border-top:1px solid var(--ink)}
  .layout-magazine .h-feed > .day:not(.pinned):first-of-type,.layout-magazine .h-feed > .pinned + .day{grid-column:1/-1;padding-bottom:clamp(8px,2vw,20px)}
  .layout-magazine .h-feed > .day:not(.pinned):first-of-type .status .e-content{font-size:1.3em;line-height:1.45}
  .layout-magazine .h-feed > .day:not(.pinned):first-of-type .article-title{font-size:clamp(2.2rem,5vw,3.6rem);line-height:1.02}
  .layout-magazine .h-feed > .day:not(.pinned):first-of-type .p-summary{max-width:44rem;font-size:1.12em}
  .layout-magazine .h-feed > .day:not(.pinned):first-of-type .status-day{display:grid;grid-template-columns:repeat(auto-fit,minmax(16rem,1fr));gap:20px 36px}
  .layout-magazine .h-feed > .day:not(.pinned):first-of-type .status-day .day-title{grid-column:1/-1;margin-bottom:0}
  .layout-magazine .h-feed > .day:not(.pinned):first-of-type .status + .status{margin-top:0}
  .layout-magazine .h-feed .day ~ .day .article-title{flex-basis:100%;font-size:clamp(1.3rem,2vw,1.7rem)}
  .layout-magazine .h-feed .day ~ .day .article-card .article-cover{float:none;width:auto;margin:0 0 .8em}
}

/* ---------- index: a contents page. Titles and dates in rows, statuses cut to two lines ---------- */
.layout-index .h-feed .day,.layout-index .h-feed .day + .day{margin:0;padding:0;border:0}
.layout-index .h-feed .day > .entry + .entry{border-top:0;padding-top:0}
.layout-index .h-feed .entry{margin:0;padding:.85em 0;border-bottom:1px solid var(--rule)}
.layout-index .h-feed .day > .entry + .entry{padding-top:.85em}
.layout-index .h-feed .article-head{margin:0;align-items:baseline}
.layout-index .h-feed .article-title{font-size:1.12rem;line-height:1.35;letter-spacing:0}
.layout-index .h-feed :is(.p-summary,.article-foot,.article-cover,.status-more,.media,.comment-link,.embed,.quote){display:none}
.layout-index .h-feed .status-day{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.5em 14px;align-items:baseline}
.layout-index .h-feed .day-title{grid-column:2;grid-row:1;margin:0;font-size:.86rem;font-weight:400;letter-spacing:0;white-space:nowrap}
.layout-index .h-feed .day-title a{color:var(--ink-2)}
.layout-index .h-feed .status{grid-column:1;display:flex;align-items:baseline;gap:12px;margin:0;padding:0;border:0}
.layout-index .h-feed .status + .status{margin-top:0}
.layout-index .h-feed .status::before{content:none}
.layout-index .h-feed .status .e-content{flex:1;min-width:0;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;overflow:hidden}
.layout-index .h-feed .status .e-content > p{display:inline;margin:0}
.layout-index .h-feed .status-meta{flex:none;order:-1;min-width:4.6em;margin:0;gap:0}
.layout-index .h-feed .status-meta .tag{display:none}
@media (max-width:560px){.layout-index .h-feed .status-day{grid-template-columns:minmax(0,1fr)}.layout-index .h-feed .day-title{grid-column:1}.layout-index .h-feed .article-date{flex-basis:100%}}

/* ---------- spine: the timeline down the middle, posts to either side in turn ---------- */
@media (min-width:860px){
  .layout-spine .h-feed .day-title{text-align:center}
  .layout-spine .h-feed .status-day{position:relative;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);column-gap:56px}
  .layout-spine .h-feed .status-day::before{content:"";position:absolute;left:50%;top:3.2em;bottom:0;width:2px;margin-left:-1px;background:var(--rail,var(--rule))}
  .layout-spine .h-feed .status-day .day-title{grid-column:1/-1}
  .layout-spine .h-feed .status{position:relative;margin:0 0 18px;padding:0;border:0}
  .layout-spine .h-feed .status + .status{margin-top:0}
  .layout-spine .h-feed .status:nth-of-type(odd){grid-column:1;text-align:right}
  .layout-spine .h-feed .status:nth-of-type(even){grid-column:2;margin-top:2.6em}
  .layout-spine .h-feed .status:nth-of-type(odd) .status-meta{justify-content:flex-end}
  .layout-spine .h-feed .status:nth-of-type(odd) .media.compact .gallery-1 .gallery-item{margin-left:auto}
  .layout-spine .h-feed .status::before{left:auto;right:-33px}
  .layout-spine .h-feed .status:nth-of-type(even)::before{left:-33px;right:auto}
  .layout-spine .h-feed .article-card{max-width:44rem;margin-left:auto;margin-right:auto}
  .layout-spine .h-feed > :not(.day){max-width:44rem;margin-left:auto;margin-right:auto}
}

@media (prefers-reduced-motion:reduce){
  html:has(body.layout-pages .h-feed){scroll-snap-type:none}
  .layout-carousel .h-feed .status-day{scroll-behavior:auto}
}
