/* thescottrocca.com articles: the index page.
   Built by Bright Presence Digital, https://brightpresencedigital.com

   The idea is a core sample. The newest writing is at the surface and the older writing is
   deeper, one continuous list, and the thin line down its left edge is the core itself: each
   article is one band of it, in the colour of its topic. Colours and type come from tokens.css.

   Two layouts. Narrow screens get one column. From 1100px the heading and the topic filter sit
   in a left column that stays put while the list scrolls past, so a very wide window is used
   rather than left empty. The list is a size container, so its rows respond to the room the
   list actually has and not to the window. */

body{font-family:var(--ui);font-size:1rem;line-height:1.5;min-height:100vh;min-height:100svh;
  display:flex;flex-direction:column}
h1,h2,p,ol{margin:0}
ol{padding:0;list-style:none}
[hidden]{display:none !important}

.skip{position:absolute;left:1rem;top:-4rem;z-index:10;padding:.7rem 1rem;background:var(--ink);
  color:var(--bg);font-weight:600;text-decoration:none}
.skip:focus{top:1rem}

.index{flex:1 0 auto;width:100%;max-width:124rem;margin:0 auto;
  padding:clamp(1.75rem,5vw,4.5rem) clamp(1.5rem,4vw,4.5rem) 0}

/* ── The heading column ─────────────────────────────────────────────────────────────────────── */
.side{container-type:inline-size;padding-bottom:clamp(2rem,5vw,3rem)}
.masthead-home{display:inline-block;padding:.45rem 0;font-size:1.0625rem;font-weight:600;
  color:var(--ink-soft);text-decoration:none;border-bottom:1px solid var(--rule-strong);
  transition:color .2s,border-color .2s}
.masthead-home:hover{color:var(--ink);border-bottom-color:var(--accent-ink)}
.side-title{margin-top:clamp(1.25rem,3vw,2rem);font-family:var(--display);font-weight:400;
  font-size:clamp(3.5rem,21cqi,7rem);line-height:.95;letter-spacing:-.01em;color:var(--ink)}
.side-lede{margin-top:clamp(1rem,2.2vw,1.5rem);max-width:36ch;font-family:var(--text);
  font-size:clamp(1.125rem,1rem + .35vw,1.3125rem);line-height:1.6;color:var(--ink-soft);
  text-wrap:pretty}

/* The filter. Every topic is on show at once and the set wraps into rows; it never scrolls
   sideways. A button is a mark in the topic's colour, its name, and how many articles it holds.
   Chosen is shown three ways so it does not lean on colour alone: the mark fills, the name
   brightens and gains weight, and the line under it takes the topic colour. */
.filter{margin-top:clamp(1.75rem,4vw,2.5rem);display:grid;
  grid-template-columns:repeat(auto-fill,minmax(9.75rem,1fr));column-gap:1.25rem}
.pick{display:flex;align-items:center;gap:.6rem;min-height:2.75rem;padding:.35rem 0;margin:0;
  background:none;border:0;border-bottom:1px solid var(--rule);border-radius:0;
  font:inherit;font-size:.9375rem;color:var(--ink-soft);text-align:left;cursor:pointer;
  -webkit-tap-highlight-color:transparent;transition:color .2s,border-color .3s}
.pick-mark{flex:none;width:.5625rem;height:.5625rem;border:1.5px solid var(--accent);
  transition:background-color .2s}
.pick-name{flex:1 1 auto;white-space:nowrap}
.pick-count{flex:none;color:var(--ink-quiet);font-variant-numeric:tabular-nums}
.pick:hover{color:var(--ink)}
.pick[aria-pressed="true"]{color:var(--ink);font-weight:600;border-bottom-color:var(--accent)}
.pick[aria-pressed="true"] .pick-mark{background:var(--accent)}
.pick[aria-pressed="true"] .pick-count{color:var(--ink-soft)}
.status{min-height:1.5rem;margin-top:1rem;font-size:.9375rem;color:var(--ink-quiet)}

/* ── The list ───────────────────────────────────────────────────────────────────────────────── */
.main{container-type:inline-size;min-width:0;padding-bottom:clamp(3rem,7vw,6rem)}
.core>li+li>.row{border-top:1px solid var(--rule)}

.row{position:relative;display:grid;grid-template-columns:minmax(0,1fr);row-gap:.5rem;
  padding:clamp(1.4rem,3.4cqi,2.25rem) clamp(.75rem,2cqi,1.5rem) clamp(1.5rem,3.6cqi,2.4rem)
          clamp(1.25rem,3.4cqi,2.5rem);
  color:inherit;text-decoration:none;transition:background-color .25s}
/* The band of the core that belongs to this article. */
.row::before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--accent);
  transform-origin:left center;transition:transform .3s var(--ease)}
.row:hover,.row:focus-visible{background:color-mix(in srgb,var(--accent) 9%,transparent)}
.row:hover::before,.row:focus-visible::before{transform:scaleX(2.6)}

.row-when{font-size:.9375rem;color:var(--ink-quiet);font-variant-numeric:tabular-nums}
.row-title{font-family:var(--text);font-weight:500;line-height:1.2;color:var(--ink);
  font-size:clamp(1.5rem,1.05rem + 1.9cqi,2.375rem);text-wrap:balance}
.row-dek{max-width:60ch;font-family:var(--text);line-height:1.6;color:var(--ink-soft);
  font-size:clamp(1.0625rem,.98rem + .42cqi,1.25rem);text-wrap:pretty}
.row-meta{display:flex;flex-wrap:wrap;column-gap:1.1rem;margin-top:.25rem;font-size:.9375rem;
  color:var(--ink-quiet)}
.row-topic{color:var(--accent-ink);font-weight:600}
.row-pic{display:none}

/* Every other row: its picture as a small thumbnail at the right, beside the words, cropped to one
   shape so the column lines up down the page. A row without a picture simply has no column. */
.core>li:not(:first-child)>.row:has(.row-pic){grid-template-columns:minmax(0,1fr) clamp(5rem,22cqi,8rem);
  column-gap:clamp(1rem,3cqi,1.75rem)}
.core>li:not(:first-child)>.row:has(.row-pic)>*{grid-column:1}
.core>li:not(:first-child)>.row:has(.row-pic)>.row-title{text-wrap:pretty}
/* On a narrow screen the picture sits beside the date and title only; the sentence and the topics
   run the full width under both, so the words never get squeezed into a sliver. */
.core>li:not(:first-child)>.row:has(.row-pic)>.row-dek,
.core>li:not(:first-child)>.row:has(.row-pic)>.row-meta{grid-column:1 / 3}
.core>li:not(:first-child)>.row>.row-pic{display:block;grid-column:2;grid-row:1 / 3;align-self:start;
  width:100%;height:auto;aspect-ratio:4/3;object-fit:cover;margin-top:.3rem;
  border:1px solid var(--rule-strong)}

/* The lead: whichever article is first in the list. Same parts as any row, set larger, and the
   only place on the page a picture may appear. It is built to stand with or without one. */
.core>li:first-child>.row{row-gap:.75rem;padding-top:clamp(1.25rem,3cqi,2rem);
  padding-bottom:clamp(2rem,4.5cqi,3.25rem)}
.core>li:first-child .row-title{font-family:var(--display);font-weight:400;line-height:1.06;
  font-size:clamp(2.125rem,1rem + 5.1cqi,5.25rem);letter-spacing:-.005em}
.core>li:first-child .row-dek{font-size:clamp(1.1875rem,1.02rem + .8cqi,1.5rem);line-height:1.55;
  max-width:52ch}
.core>li:first-child .row-pic{display:block;width:100%;max-width:42rem;height:auto;
  margin-top:.9rem;border:1px solid var(--rule-strong)}

/* With room, the date moves out into its own column so every title starts on one line down the
   page, and the lead's picture sits beside its sentence instead of under it. */
@container (min-width:54rem){
  .row{grid-template-columns:8.25rem minmax(0,1fr);column-gap:1.5rem}
  .row>*{grid-column:2}
  .row-when{grid-column:1;grid-row:1;padding-top:.7em}
  .row-when,.row-meta{font-size:1.0625rem}
  .core>li:first-child .row-when{padding-top:1.9cqi}
  .core>li:not(:first-child)>.row:has(.row-pic){grid-template-columns:8.25rem minmax(0,1fr) clamp(8rem,17cqi,12rem)}
  .core>li:not(:first-child)>.row:has(.row-pic)>*{grid-column:2}
  .core>li:not(:first-child)>.row:has(.row-pic)>.row-when{grid-column:1}
  .core>li:not(:first-child)>.row:has(.row-pic)>.row-dek,
  .core>li:not(:first-child)>.row:has(.row-pic)>.row-meta{grid-column:2}
  .core>li:not(:first-child)>.row>.row-pic{grid-column:3;grid-row:1 / 5}
}
@container (min-width:64rem){
  .core>li:first-child>.row:has(.row-pic){grid-template-columns:8.25rem minmax(0,1fr) minmax(0,38%);
    grid-template-rows:auto auto 1fr}
  .core>li:first-child>.row:has(.row-pic) .row-title{grid-column:2 / 4}
  .core>li:first-child>.row:has(.row-pic) .row-pic{grid-column:3;grid-row:2 / 4;margin-top:.5rem;
    align-self:start}
}

/* ── Footer ─────────────────────────────────────────────────────────────────────────────────── */
.site-foot{flex:none;width:100%;max-width:124rem;margin:0 auto;padding:0 clamp(1.5rem,4vw,4.5rem)}
.site-foot-line{display:flex;flex-wrap:wrap;justify-content:space-between;gap:.5rem 2rem;
  padding-top:1.5rem;border-top:1px solid var(--rule);font-size:.9375rem;color:var(--ink-quiet)}
.site-foot-links{display:flex;gap:1.5rem}
.site-foot-links a{color:var(--ink-soft);text-decoration:underline;text-decoration-color:var(--rule-strong);
  text-underline-offset:.25em;transition:color .2s,text-decoration-color .2s}
.site-foot-links a:hover{color:var(--ink);text-decoration-color:var(--accent-ink)}

/* Keyboard focus: one clear ring, the same everywhere on the page. */
.masthead-home:focus-visible,.pick:focus-visible,.site-foot a:focus-visible{
  outline:2px solid var(--accent-ink);outline-offset:4px}
.row:focus-visible{outline:2px solid var(--accent-ink);outline-offset:-2px}

/* ── Two zones ──────────────────────────────────────────────────────────────────────────────── */
@media (min-width:1100px){
  .index{display:grid;grid-template-columns:minmax(20rem,26%) minmax(0,1fr);
    column-gap:clamp(2.5rem,5vw,8rem);align-items:start}
  .side{position:sticky;top:0;padding-top:clamp(1.75rem,5vw,4.5rem);margin-top:calc(-1 * clamp(1.75rem,5vw,4.5rem));
    max-width:32rem}
  .filter{grid-template-columns:repeat(2,minmax(0,1fr));column-gap:1rem}
  .pick{gap:.5rem}
}
/* A tall, wide window has room for the topics as one plain column, like a contents list. */
@media (min-width:1500px) and (min-height:940px){
  .filter{grid-template-columns:minmax(0,1fr);max-width:22rem}
  .pick{font-size:1.0625rem;min-height:3rem}
  .status{font-size:1rem}
}
/* A short window cannot hold the heading column whole, so it scrolls away with the page rather
   than staying put with its lower half out of reach. */
@media (min-width:1100px) and (max-height:640px){
  .side{position:static}
}

/* ── Filtering, as movement ─────────────────────────────────────────────────────────────────── */
/* While the filter is changing the list, each row is its own moving piece so the survivors glide
   to their new places. Each title also carries a name of its own, used when travelling to its
   article; for the length of a filter change that name is set aside, because a title cannot be
   both a piece on its own and part of a moving row. */
html.is-filtering .row{view-transition-name:var(--vt,none)}
html.is-filtering .row-title{view-transition-name:none !important}
html.is-filtering .site-foot{view-transition-name:index-foot}
html.is-filtering::view-transition-group(*){animation-duration:.5s;animation-timing-function:cubic-bezier(.22,1,.36,1)}
html.is-filtering::view-transition-old(*),
html.is-filtering::view-transition-new(*){animation-duration:.3s}
html.is-filtering::view-transition-old(root),
html.is-filtering::view-transition-new(root){animation:none}
