/* ==========================================================================
   Redesign layer: index pages (Stories gallery, Posts list). Loads after r-base.css.
   Reusable blocks:  .ix-head (page head)  ·  .gal / .gal-tile (image-led gallery)  ·  .plist / .plist-row (post list)
   ========================================================================== */

/* --------------------------------------------------------------------------
   .ix-head: page head, on the left (only the home hero is centred)
   -------------------------------------------------------------------------- */
.ix-page { padding-top: var(--s-9); }
.ix-head { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: var(--gap-head); text-align: left; max-width: 720px; }
.ix-head .lead { max-width: 600px; }
/* head with a drawing on the right (Stories: the bubbles draw and erase) */
.ix-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-8); }
.ix-top__art { flex: none; width: clamp(260px, 26vw, 400px); height: auto; margin-right: 4%; }
.ix-body { margin-top: var(--s-9); }
@media (max-width: 760px) {
  .ix-page { padding-top: var(--s-7); }
  .ix-head { align-items: flex-start; text-align: left; }
  .ix-top { position: relative; }
  .ix-top__art { position: absolute; right: 0; top: -14px; width: 130px; margin: 0; }   /* small, beside the title */
  .ix-body { margin-top: var(--s-7); }
}

/* --------------------------------------------------------------------------
   .gal: story cards as a mixed mosaic. Every tile has its own shape; words are the guest's name and the title, two lines at most.
   Start column: style="--at: N" (optional; auto-placement otherwise). Shapes (each sets span, image proportion, and where the words sit):
     --land 3:2, words under · --port 3:4, words beside · --sq 1:1, words under · --tall 4:5, words under · --wide 16:10, words beside
   State: .gal-tile--soon (not live yet: "Coming soon" tag, rendered as a <div>, not a link)
   -------------------------------------------------------------------------- */
.gal { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--s-6); row-gap: var(--s-8); align-items: start; }
.gal-tile { grid-column: var(--at, auto) / span 4; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-4); color: inherit; }
.gal-tile__img { position: relative; display: block; flex: none; width: 100%; overflow: hidden; aspect-ratio: 1 / 1; background: var(--sheet); border: 1px solid var(--rule); }
.gal-tile__text { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); min-width: 0; }
.gal-tile__label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; color: var(--ink-2); }
.gal-tile__label:has(.voice) > .label { display: none; } /* name only; the story number, date and dek stay in the markup */
.gal-tile__label .voice { font-size: 16px; color: var(--ink-2); }
.gal-tile__t { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-family: var(--display); font-weight: 500; font-size: 20px; line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; text-decoration: underline; text-decoration-color: transparent; text-decoration-thickness: 2px; text-underline-offset: 0.14em; transition: text-decoration-color var(--t-fast) var(--ease-out); }
.gal-tile__dek { font-size: 15px; line-height: 1.45; color: var(--ink-2); text-wrap: pretty; }   /* one-line summary under the title */
@media (hover: hover) and (pointer: fine) {
  a.gal-tile:hover .gal-tile__t { text-decoration-color: currentColor; }
}
a.gal-tile:focus-visible { outline: none; }
a.gal-tile:focus-visible .gal-tile__img { outline: 2px solid var(--ink); outline-offset: 4px; }
a.gal-tile:focus-visible .gal-tile__t { text-decoration-color: currentColor; }

/* outlined cutout of the guest: full body, straight on the page, no frame */   /* as wide as the title, so the figure centres over the words */
/* pen box around the cutout: same marker line as the rings and underlines, with a break in the bottom edge */   /* the box spans the title's width */
.gal-tile__box { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; }
.gal-tile__box path { vector-effect: non-scaling-stroke; }

/* guest card: outlined cutout standing on a greyed pattern (assets/story-bg) */
.sbg-tile { width: 70%; }
.sbg-tile .gal-tile__text { align-self: stretch; }   /* text spans the image width */
@media (max-width: 760px) { .gal-tile.sbg-tile { flex-direction: column; width: 100%; } .gal-tile .gal-tile__img.sbg { width: 70%; } }
.gal-tile__img.sbg { aspect-ratio: 3 / 4; background: var(--paper, #F4F1EA); border: 0; }
/* the pink pattern recolored to the accent blue (its light and dark kept, the hue taken from --accent), multiplied onto the paper at 30% */
.sbg::before { content: ""; position: absolute; inset: 0; background: var(--bg) center / cover, var(--accent); background-blend-mode: luminosity; filter: brightness(1.5); mix-blend-mode: multiply; opacity: .3; }
:root[data-theme="dark"] .sbg::before { mix-blend-mode: screen; filter: none; opacity: .2; }   /* dark: multiply would only blacken the tile */
.sbg img { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); height: 90%; width: auto; max-width: none; }

/* not live yet */

/* tablet: two columns, shapes kept; the wide one takes the full row */
@media (max-width: 1439px) {
  .gal { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--s-7); }
  .gal-tile { grid-column: span 1; }
}
/* phone: one column, every tile a row (image left, words right). Same image width for all, so the words line up; the shape shows in the height. */
@media (max-width: 760px) {
  .gal { grid-template-columns: minmax(0, 1fr); row-gap: var(--s-6); }
  .gal-tile { flex-direction: row; gap: var(--s-4); }
  .gal-tile .gal-tile__img { width: 34%; }
  .gal-tile__t { font-size: 18px; }
  .gal-tile__label .voice { font-size: 15px; }
  }

/* The picture box shared by the home sections and the lists: a photo fills it, an ink drawing sits whole inside it, a guest cutout stands in it */
.fp-img { position: relative; display: block; overflow: hidden; background: var(--sheet); border: 1px solid var(--rule); }
.fp-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fp-img--draw img { box-sizing: border-box; padding: 9% 8%; object-fit: contain; }
.fp-img--cut img { inset: auto auto 0 50%; height: 92%; width: auto; max-width: none; transform: translateX(-50%); }
:root[data-theme="dark"] .fp-img--draw img { filter: invert(1) hue-rotate(180deg) brightness(.92); }   /* ink drawings, same flip as .doodle-img */

/* --------------------------------------------------------------------------
   .plist: compact post list. Row = number · title + dek · topic · date · arrow.
   Hover / keyboard focus: the active row stays full strength, the others dim; arrow slides in, title nudges.
   Transforms and opacity only, so nothing shifts.
   -------------------------------------------------------------------------- */
.plist { list-style: none; border-top: 1px solid var(--ink); }
.plist > li { border-bottom: 1px solid var(--rule); }
.plist-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 156px 128px 20px; column-gap: var(--s-5); align-items: center; padding: 11px 0 12px; color: inherit; transition: opacity var(--t-fast) var(--ease-out); }
.plist-row__n { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.plist-row__main { display: flex; flex-direction: column; gap: 1px; transition: transform var(--t-fast) var(--ease-out); }
.plist-row__t { font-family: var(--display); font-weight: 500; font-size: 24px; line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance; }
.plist-row__dek { font-size: 17px; line-height: 1.42; color: var(--ink-2); }
.plist-row__topic { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }   /* column fits "Agent infrastructure"; widen it for a longer topic */
.plist-row__meta { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.plist-row__go { justify-self: end; font-size: 18px; line-height: 1; opacity: 0; transform: translateX(-8px); transition: opacity var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out); }

@media (hover: hover) and (pointer: fine) {
  .plist:hover .plist-row:not(:hover) { opacity: 0.35; }
  .plist-row:hover .plist-row__main { transform: translateX(6px); }
  .plist-row:hover .plist-row__go { opacity: 1; transform: none; }
}
.plist:has(.plist-row:focus-visible) .plist-row:not(:focus-visible) { opacity: 0.35; }
.plist-row:focus-visible { outline: 2px solid var(--ink); outline-offset: 6px; }
.plist-row:focus-visible .plist-row__main { transform: translateX(6px); }
.plist-row:focus-visible .plist-row__go { opacity: 1; transform: none; }

/* wide screens: one line per post: number, title, description, topic, date. Anything too long ends in "…" rather than wrapping. */
@media (min-width: 1440px) {
  .plist-row { grid-template-columns: 32px minmax(0, 1fr) 156px 140px 16px; column-gap: 20px; align-items: center; padding: 16px 0 17px; }
  .plist-row__main { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(0, 1fr); column-gap: 24px; align-items: center; }
  .plist-row__t, .plist-row__dek { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .plist-row__t { font-size: 20px; }
  .plist-row__dek { font-size: 14.5px; }
}

/* narrower: topic + date stack into one meta column; title and dek still one line each */
@media (max-width: 1439px) {
  .plist-row { grid-template-columns: 40px minmax(0, 1fr) 156px 20px; grid-template-rows: auto auto; row-gap: 4px; padding: 20px 0 22px; }
  .plist-row__main { gap: 6px; }
  .plist-row__t, .plist-row__dek { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .plist-row__n { grid-row: 1 / 3; }
  .plist-row__main { grid-row: 1 / 3; }
  .plist-row__topic { grid-column: 3; grid-row: 1; }
  .plist-row__meta { grid-column: 3; grid-row: 2; }
  .plist-row__go { grid-column: 4; grid-row: 1 / 3; align-self: center; }
}
/* phones: like a news list. The title, then a small date · topic line; number, dek, reading time and arrow stay in the markup */
@media (max-width: 760px) {
  .plist-row { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: none; column-gap: var(--s-5); row-gap: 10px; padding: 24px 0 26px; align-items: baseline; }
  .plist-row__n, .plist-row__dek, .plist-row__len, .plist-row__go { display: none; }
  .plist-row__meta { grid-column: 1; grid-row: 2; }
  .plist-row__topic { grid-column: 2; grid-row: 2; color: var(--ink-2); }
  .plist-row__main { grid-column: 1 / -1; grid-row: 1; }   /* title first, date and topic under it */
  .plist-row__t { font-size: 21px; white-space: normal; }
}

/* Posts page: head on the left, the network drawing (draws and erases) on the right, then the list. Under 1100px the drawing sits small beside the title. */
.ix-page--posts { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "list"; }
.ix-page--posts > .ix-head { grid-area: head; }
.ix-page--posts > .plist { grid-area: list; width: 100%; }
.ix-page__art { grid-area: art; display: none; width: 100%; max-width: 340px; height: auto; }
@media (max-width: 1099px) {   /* small, up beside the title */
  .ix-page--posts { position: relative; }
  .ix-page__art { display: block; position: absolute; right: var(--margin); top: calc(var(--s-9) - 8px); width: clamp(130px, 30vw, 240px); }
}
@media (min-width: 761px) and (max-width: 1099px) { .ix-page--posts .ix-head .lead { max-width: min(600px, calc(100% - clamp(130px, 30vw, 240px) - var(--s-6))); } }
@media (max-width: 760px) { .ix-page__art { top: calc(var(--s-7) - 20px); width: 130px; } }   /* phones: one fixed size beside the title, like the Stories bubbles */
@media (max-width: 360px) { .ix-top__art, .ix-page__art { width: 108px; } }   /* narrowest phones: smaller, so it clears the title */
@media (min-width: 1440px) {
  .ix-page--posts { grid-template-columns: minmax(0, 720px) minmax(0, 1fr); grid-template-areas: "head art" "list list"; column-gap: var(--s-7); align-items: center; }
  .ix-page__art { display: block; justify-self: center; }
}

@media (prefers-reduced-motion: reduce) {
  .plist-row, .plist-row__main, .plist-row__go, .gal-tile__t { transition: none; }
  .plist-row:hover .plist-row__main, .plist-row:focus-visible .plist-row__main { transform: none; }
  .plist-row__go { transform: none; }
}

/* How it works: the same head as Stories, with the two café tables drawing themselves on the right */
.guest-steps .ix-top__art--tables { width: clamp(300px, 30vw, 440px); }
@media (max-width: 760px) {
  .guest-steps .ix-top { flex-direction: column; align-items: flex-start; gap: var(--s-6); }
  .guest-steps .ix-top__art--tables { position: static; width: min(100%, 320px); align-self: center; }
}

/* .plist--img (Posts and Stories pages): the same list with a small picture after the number, and slightly smaller titles. Phones: picture on the left. */
.plist--img .plist-row__img { width: 88px; aspect-ratio: 8 / 5; }
.plist--img .plist-row__t { font-size: 20px; }
@media (min-width: 1440px) { .plist--img .plist-row__t { font-size: 18px; } }
.plist--img .plist-row { grid-template-columns: 48px 88px minmax(0, 1fr) 156px 128px 20px; }
@media (min-width: 1440px) { .plist--img .plist-row { grid-template-columns: 32px 88px minmax(0, 1fr) 156px 140px 16px; } }
@media (max-width: 1439px) {
  .plist--img .plist-row { grid-template-columns: 40px 88px minmax(0, 1fr) 156px 20px; }
  .plist--img .plist-row__img { grid-row: 1 / 3; }
  .plist--img .plist-row__topic { grid-column: 4; }
  .plist--img .plist-row__meta { grid-column: 4; }
  .plist--img .plist-row__go { grid-column: 5; }
}
@media (max-width: 760px) {
  /* Phones: the picture sits left, the title and its date and topic beside it, like the home rows (Vojta, 14 Nov: lists must show images) */
  .plist--img .plist-row { grid-template-columns: 96px auto minmax(0, 1fr); align-items: start; row-gap: 8px; }
  .plist--img .plist-row__img { display: block; width: 96px; grid-column: 1; grid-row: 1 / 3; }
  .plist--img .plist-row__main { grid-column: 2 / -1; grid-row: 1; }
  .plist--img .plist-row__meta { grid-column: 2; grid-row: 2; }
  .plist--img .plist-row__topic { grid-column: 3; grid-row: 2; }
  .plist--img .plist-row__t { font-size: 19px; }
}

/* List and home rows: no text runs past two lines; the rest ends in "…" (Vojta, 14 Nov). Rows that are one line by design keep their nowrap. :where() keeps it weaker than the rules that hide a dek on phones. */
:where(.plist-row__t, .plist-row__dek, .px-row__t, .px-row__dek) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
