/* The theme pages (/themes and /themes/<id>, src/views/pages/site/ThemesPage.tsx): a grid of theme tiles, a theme's own page
   and the closing band. They wear the content pages' header and links (site.css .site-doc__*, .site-more); everything here
   paints with the semantic tokens (--bg-deep --text --text-2 --text-3 --line --focus), so the pages follow the light or dark
   scheme. The sample cards are themed objects (card.css, themes.css, genres.css): only their wrappers are styled here.
   A tile holds two links, never nested: the whole tile (card, name, mood) is the primary one, and "Watch demo" under it the second.
   The most watched themes (round 9, shared/demo-views.ts popularThemes) are named here in solid gold (--candle, the fill of the site's
   other gold chips and buttons) under night ink, which reads in both schemes: the showcase at the top of the index (site-tpop), a
   ranked tile's badge and a ranked theme's badge under its breadcrumbs. One hue, no gradient; nothing is drawn over a card's art.
   Prefix: site-t (site-tg the index, site-ttile a tile, site-tpop the popular showcase, site-tpage a theme's page, site-tband the band).
   Motion: transform only; reduced motion and Calm mode at the end. */

/* ── The families (round 13): anchor chips, then a section each. A 44 px target. ─────────────────────────────────────────────────────── */
/* The anchor chips stay on screen under the header while the page scrolls (V2): the catalogue is long, and a visitor 60 tiles down should reach another
   family without scrolling back. Always ONE line of fixed height, so its room is a number the page can reserve: a bar that wraps would cover two, three or
   four chips' rows at 100 themes and its height would change with the width. The line scrolls sideways when the chips do not fit (a phone, a long list); the bar,
   never the page. Opaque, so a tile passing under it is not seen through it. It sits below the header (z) and above the tiles, and `scroll-padding-top`
   (here, and the header's own in base.css) leaves the header, this bar and 12 px free above whatever a link or the keyboard scrolls to, so no anchor's
   heading, tile or focus ring ends up under either. */
:root { --tfams-h: 60px; }
:root:has(> body > .site-header):has(.site-tfams) { scroll-padding-top: calc(var(--header-h) + var(--tfams-h) + 12px); }   /* (as specific as base.css's rule for the header alone, plus the bar's :has, so it wins whatever the order) */
.site-tfams {
  position: sticky;
  top: var(--header-h);
  z-index: calc(var(--z-sheet) - 2);
  box-sizing: border-box;
  height: var(--tfams-h);
  margin: 0 calc(-1 * var(--gutter)) var(--space-6);
  padding: 8px var(--gutter);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.site-tfams::-webkit-scrollbar { display: none; }
.site-tfams ul { display: flex; flex-wrap: nowrap; gap: var(--space-2); width: max-content; margin: 0; padding: 0; list-style: none; }
.site-tfams__link {
  display: inline-flex;
  flex: none;
  white-space: nowrap;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font: 600 .9375rem/1.2 var(--font-ui);
  text-decoration: none;
}
.site-tfams__link:hover { border-color: color-mix(in srgb, var(--text) 30%, transparent); color: var(--text); }
.site-tfams__link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.site-tfams__n, .site-tfam__n { color: var(--text-3, var(--text-2)); font-weight: 500; font-variant-numeric: tabular-nums; }
.site-tfam + .site-tfam { margin-top: clamp(40px, 5vw, 64px); }
.site-tfam__title {
  margin: 0 0 var(--space-5);
  font-size: clamp(1.25rem, 1.05rem + 1vw, 1.75rem);
  font-stretch: 75%;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ── The grid of tiles (the index, and "More themes like this") ──────────────────────────────────────────────── */
.site-tg__body { padding-block: clamp(28px, 3.6vw, 48px) var(--space-8); }
.site-tgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 196px), 1fr));
  gap: clamp(24px, 2.6vw, 36px) clamp(12px, 2vw, 24px);
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (max-width: 559px) { .site-tgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* a tile off screen skips its layout, its theme's art and its name face until it comes near (auto keeps the measured size);
   the link takes the tile's height, so the "Watch demo" links of a row share a line. content-visibility paints a tile no further
   than its own box, so the tile carries 6 px of room all round for its links' focus rings and the card's lift (the margin gives
   the room back: the grid is as it was; the gap, 12 px at the least, keeps one tile's room off the next tile's links) */
.site-ttile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: -6px;
  padding: 6px;
  content-visibility: auto;
  contain-intrinsic-size: auto 372px;
  container-type: inline-size;
}
.site-ttile__link {
  display: grid;
  flex: 1 1 auto;
  align-content: start;
  gap: 4px;
  color: var(--text);
  text-decoration: none;
  border-radius: 14px;
}
.site-ttile__link:hover { text-decoration: none; }
.site-ttile__link:focus-visible { outline: 2px solid var(--focus, var(--candle)); outline-offset: 4px; }
.site-ttile__card {
  position: relative;
  margin-bottom: 10px;
  container-type: inline-size;
  transition: transform var(--dur-2) var(--ease-out);
}
.site-ttile__link:hover .site-ttile__card { transform: translateY(-4px); }
/* the baked picture of the card (scripts/bake-cards.mjs): the live thumb's corners, ring and shadow (card.css .gcard--thumb) back on a square picture. Its size comes
   from the 4:5 ratio before the file arrives, and the theme's own colour (inline) shows until it does. */
.site-ttile__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  border-radius: clamp(10px, 7cqi, 22px);
  box-shadow: 0 1px 2px rgb(0 0 0 / .2), 0 14px 30px -14px rgb(0 0 0 / .6);
}
/* a rotated card (sketchbook) is baked upright; the picture turns like the live thumb did (card.css .gcard--thumb) */
.site-ttile__img[style*="--card-rotate"] { rotate: var(--card-rotate); scale: .985; }
/* "Sample" is a small chip on its own line above the theme's name, in the caption: nothing sits on the card's art, where a corner is
   always some theme's eyebrow, and the name never wraps to make room for it. The words are --text-2 (AA on the page in both schemes)
   in a hairline box; it is hidden from assistive tech (the card it labels is) and sits outside the heading, so the heading is the
   theme's name alone. */
.site-ttile__sample {
  padding: 2px 6px 1px;
  border: 1px solid color-mix(in srgb, var(--text-2) 40%, transparent);
  border-radius: 4px;
  color: var(--text-2);
  font: 650 .625rem/1.2 var(--font-ui);
  letter-spacing: .14em;
  text-transform: uppercase;
}
.site-ttile__name {
  margin: 0;
  color: var(--text);
  font: 700 1.0625rem/1.2 var(--font-ui);
  letter-spacing: 0;
}
.site-ttile__link:hover .site-ttile__name { text-decoration: underline; text-underline-offset: .18em; }
.site-ttile__mood { margin: 0; color: var(--text-2); font-size: .875rem; line-height: 1.4; }
/* the caption's chip row: "Sample" and, for a popular theme, its badge beside it on the same line, so a ranked tile is no taller than
   its neighbours (the longest badge, "#2 most popular", and the chip are about 189 px: a tile of 13 rem (208 px) or more has the room
   with 19 px to spare; the narrower tiles stack them, see the container rules after the foot's) */
.site-ttile__tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0 0 5px; }
.site-ttile__rank {
  padding: 3px 6px 2px;
  border-radius: 4px;
  background: var(--candle);
  color: var(--night-900);
  font: 700 .625rem/1.2 var(--font-ui);
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}
/* the second link: quiet, a play mark in the accent and the words in --text-2 (both AA on the page), a 32 px target;
   the words line up with the tile's name (the 2 px of padding is the box's, for its ring) */
.site-ttile__demo {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  margin: 0 0 0 -2px;
  padding: 0 2px;
  border-radius: 8px;
  color: var(--text-2);
  font: 600 .875rem/1.2 var(--font-ui);
  text-decoration: none;
}
.site-ttile__demo svg { flex: none; color: var(--accent-ink); }
.site-ttile__demo:hover { color: var(--text); text-decoration: underline; text-underline-offset: .18em; }
.site-ttile__demo:focus-visible { outline: 2px solid var(--focus, var(--candle)); outline-offset: 2px; }
/* the foot: "Watch demo" and, beside it, the demo's views (--text-2, AA on the page in both schemes; nothing on the card's art). When
   the tile's room is under 13 rem (two-column phones; the link, a gap and the longest label, "999.9K views", are about 12.8 rem) the
   views stack under the link, and the decision is the TILE's width, so every tile of a row stacks together: the grid's tiles are all
   one width. The foot is then as tall in every tile of a grid that shows any
   views, so the "Watch demo" links of a row still share a line (a tile with no views keeps the room; a grid with none needs none). */
.site-ttile__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 10px;
  margin-top: 4px;
}
.site-ttile__views {
  color: var(--text-2);
  font: 500 .8125rem/1.2 var(--font-ui);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
@container (max-width: 13rem) {
  .site-ttile__foot { flex-direction: column; align-items: flex-start; row-gap: 0; }
  .site-tgrid:has(.site-ttile__views) .site-ttile__foot { min-height: calc(32px + 1.2 * .8125rem); }
}
/* A tile of 13 rem or less (the foot's breakpoint: two-column phones, and a 3 to 5 column grid just past a new column) stacks the chip
   and the badge, two chip lines (17 + 4 + 17 px), so a badge never wraps alone. The tiles of a row hold the same two lines, so the
   names of a row stay on one line: on a phone (two columns) the tile beside a ranked one (the other of its row: the odd one before
   it, the even one after it), and only the rows with a badge pay for it; from 560 px a row's tiles are not known to the selectors,
   so the grid that shows any badge holds them in every tile (its narrow band is a few dozen px of a viewport's width). */
@container (max-width: 13rem) {
  .site-ttile__tags { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 559px) {
  @container (max-width: 13rem) {
    .site-ttile:nth-child(odd):has(+ .site-ttile .site-ttile__rank) .site-ttile__tags,
    .site-ttile:has(.site-ttile__rank) + .site-ttile:nth-child(even) .site-ttile__tags { min-height: 38px; }
  }
}
@media (min-width: 560px) {
  @container (max-width: 13rem) {
    .site-tgrid:has(.site-ttile__rank) .site-ttile__tags { min-height: 38px; }
  }
}

/* ── The popular showcase (the index, only when some theme is popular) ──────────────────────────────────────────── */
/* the most watched theme large, in a panel with a gold edge and a warm glow in the corner it grows from; the next ones in a list
   beside it (stacked under it below 1024 px). The big card is sized by its wrapper like a theme page's: the wrapper is the container
   the card scales to, and the card keeps its 4:5 box, never cropped. */
.site-tpop { display: grid; gap: clamp(16px, 2vw, 24px); margin-bottom: clamp(36px, 5vw, 60px); }
@media (min-width: 1024px) {
  .site-tpop { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .site-tpop:not(:has(.site-tpop__also)) { grid-template-columns: minmax(0, 1fr); }
}
.site-tpop__feature {
  position: relative;
  isolation: isolate;
  overflow: clip;
  display: grid;
  align-items: center;
  gap: var(--space-5) clamp(24px, 3.4vw, 44px);
  padding: clamp(20px, 3vw, 36px);
  border: 1px solid color-mix(in srgb, var(--accent-ink) 38%, var(--line));
  border-radius: 22px;
  background:
    radial-gradient(90% 110% at 0 0, color-mix(in srgb, var(--candle) 17%, transparent), transparent 62%),
    var(--surface);
  box-shadow: var(--shadow-1), 0 0 0 1px color-mix(in srgb, var(--candle) 10%, transparent);
}
@media (min-width: 720px) { .site-tpop__feature { grid-template-columns: clamp(220px, 34%, 300px) minmax(0, 1fr); } }
.site-tpop__card { width: min(100%, 250px); margin-inline: auto; container-type: inline-size; }
@media (min-width: 720px) { .site-tpop__card { width: 100%; margin-inline: 0; } }
.site-tpop__copy { min-width: 0; }
/* the eyebrow is the h2's first child (the heading reads "Most popular: {name}" through its hidden twin): a block of its own, and its gap to the name is its margin */
.site-tpop__eyebrow { display: flex; align-items: center; gap: 7px; margin: 0 0 var(--space-2); }
.site-star { flex: none; }
.site-tpop__name {
  margin: 0;
  font-size: clamp(2rem, 1.3rem + 2.6vw, 3.25rem);
  font-weight: 800;
  font-stretch: 75%;
  line-height: .96;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.site-tpop__name a { color: var(--text); text-decoration: none; }
.site-tpop__name a:hover { text-decoration: underline; text-decoration-thickness: .06em; text-underline-offset: .12em; }
.site-tpop__name a:focus-visible { outline: 2px solid var(--focus, var(--candle)); outline-offset: 4px; border-radius: 6px; }
.site-tpop__mood { margin: var(--space-3) 0 0; color: var(--text-2); font-size: 1.0625rem; line-height: 1.45; text-wrap: pretty; }
.site-tpop__views { margin: var(--space-3) 0 0; color: var(--text); font: 650 .9375rem/1.4 var(--font-ui); font-variant-numeric: tabular-nums; }
.site-tpop__ctas { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-5); }

.site-tpop__also {
  min-width: 0;
  padding: clamp(18px, 2.4vw, 26px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
}
.site-tpop__also-title { margin: 0; color: var(--text-2); font: 700 .8125rem/1.2 var(--font-ui); letter-spacing: .16em; text-transform: uppercase; }
.site-tpop__list { display: grid; gap: var(--space-4); margin: var(--space-4) 0 0; padding: 0; list-style: none; }
.site-tpop__row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 16px; align-items: start; min-width: 0; }
.site-tpop__row + .site-tpop__row { padding-top: var(--space-4); border-top: 1px solid var(--line); }
.site-tpop__thumb { width: 72px; container-type: inline-size; }
.site-tpop__info { display: grid; justify-items: start; min-width: 0; }
.site-tpop__info > p { margin: 0; }
.site-tpop__rank { color: var(--accent-ink); font: 700 .75rem/1.3 var(--font-ui); letter-spacing: .12em; }
.site-tpop__rowname { font: 700 1.125rem/1.2 var(--font-ui); letter-spacing: 0; overflow-wrap: anywhere; }
.site-tpop__rowname a { color: var(--text); text-decoration: none; }
.site-tpop__rowname a:hover { text-decoration: underline; text-underline-offset: .18em; }
.site-tpop__rowname a:focus-visible, .site-tpop__rowdemo:focus-visible { outline: 2px solid var(--focus, var(--candle)); outline-offset: 2px; border-radius: 6px; }
.site-tpop__rowviews { margin-top: 2px; color: var(--text-2); font-size: .875rem; font-variant-numeric: tabular-nums; }
.site-tpop__rowdemo {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  color: var(--text-2);
  font: 600 .875rem/1.2 var(--font-ui);
  text-decoration: none;
}
.site-tpop__rowdemo svg { flex: none; color: var(--accent-ink); }
.site-tpop__rowdemo:hover { color: var(--text); text-decoration: underline; text-underline-offset: .18em; }

/* the grid's own heading, when the showcase sits above it */
.site-tg__all {
  margin: 0 0 var(--space-5);
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.25rem);
  font-stretch: 75%;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.site-tg__how { margin-top: clamp(56px, 7vw, 96px); }
.site-tg__how h2 { margin-top: 0; font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.25rem); font-stretch: 75%; font-weight: 800; letter-spacing: -0.02em; }

/* ── A theme's page ──────────────────────────────────────────────────────────────────────────────────────────── */
.site-crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
  color: var(--text-3);
  font-size: .875rem;
}
.site-crumbs li + li::before { content: "/"; margin-right: 8px; color: var(--text-3); }
.site-crumbs a { color: var(--text-2); text-decoration: none; }
.site-crumbs a:hover { color: var(--text); text-decoration: underline; }
.site-crumbs [aria-current] { color: var(--text); }

/* a popular theme's badge, between the breadcrumbs and the title: a gold pill with a star (decorative), like a tile's badge */
.site-tpage__rank {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 var(--space-3);
  padding: 5px 12px 5px 9px;
  border-radius: 999px;
  background: var(--candle);
  color: var(--night-900);
  font: 700 .75rem/1.2 var(--font-ui);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.site-tpage__title { max-width: 18ch; margin-top: 0; }
.site-tpage__name { display: block; }
.site-tpage__kind {
  display: block;
  margin-top: .45em;
  color: var(--text-2);
  font: 600 clamp(1.125rem, .95rem + .8vw, 1.5rem)/1.25 var(--font-ui);
  letter-spacing: 0;
}
.site-tpage__ctas { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-5); }
/* the demo's views, a muted line under the call-to-action row */
.site-tpage__views { margin: var(--space-3) 0 0; color: var(--text-2); font-size: .875rem; font-variant-numeric: tabular-nums; }

.site-tpage__figure { width: min(100%, 340px); margin: 0; }
.site-tpage__card { position: relative; container-type: inline-size; }
.site-tpage__caption { margin-top: var(--space-3); color: var(--text-3); font-size: .8125rem; line-height: 1.4; }
@media (min-width: 900px) {
  .site-tpage__head-inner { align-items: center; }
  .site-tpage__figure { width: clamp(280px, 25vw, 340px); justify-self: end; }
  .site-tpage__caption { text-align: center; }
}

.site-tpage__body { display: grid; gap: clamp(56px, 7vw, 96px); padding-block: clamp(32px, 4vw, 56px) var(--space-8); }
.site-tpage__prose > section + section { margin-top: 2.5rem; }
.site-tpage__prose > section > * + * { margin-top: .85em; }
.site-tpage__prose h2 { margin-top: 0; font-size: clamp(1.25rem, 1.1rem + .5vw, 1.5rem); }
.site-tpage__facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 12px 28px;
  padding-block: 16px;
  border-block: 1px solid var(--line);
}
.site-tpage__facts > div { display: contents; }
.site-tpage__facts dt { padding-top: .2em; color: var(--text-3); font: 650 .75rem/1.4 var(--font-ui); letter-spacing: .12em; text-transform: uppercase; }
.site-tpage__facts dd { margin: 0; color: var(--text); }
@media (max-width: 559px) {
  .site-tpage__facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .site-tpage__facts dd + dt { margin-top: 10px; }
}

.site-tpage__more .site-head--row { align-items: flex-end; }
.site-tpage__more-title { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.25rem); font-stretch: 75%; font-weight: 800; letter-spacing: -0.02em; }
.site-tgrid--more { margin-top: var(--space-5); }
@media (min-width: 900px) { .site-tgrid--more { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ── The closing band ────────────────────────────────────────────────────────────────────────────────────────── */
.site-tband { border-top: 1px solid var(--line); background: var(--bg-deep, var(--night-950)); }
.site-tband__inner {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  max-width: var(--maxw);
  margin-inline: auto;
  padding: clamp(48px, 6vw, 80px) var(--gutter);
  text-align: center;
}
.site-tband__title { font-size: clamp(2rem, 1.3rem + 2.6vw, 3.25rem); font-stretch: 75%; font-weight: 800; line-height: .95; letter-spacing: -0.03em; }
.site-tband__text { max-width: 44ch; color: var(--text-2); }
.site-tband .site-cta { margin-top: var(--space-3); }

/* ── Reduced motion and Calm mode ────────────────────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .site-ttile__card { transition: none; }
  .site-ttile__link:hover .site-ttile__card { transform: none; }
}
:root[data-calm] .site-ttile__card { transition: none; }
:root[data-calm] .site-ttile__link:hover .site-ttile__card { transform: none; }
