/* RP Portfolio — theme layer, loaded after tokens.css and system.css (design system 1794158049-2d7d).
   1. WordPress glue: maps block markup onto the system's classes. No new visual rules.
   2. Staged shared corrections: tested on staging, not yet in the design system. Each is listed in the design-system
      change register (tools/ds-register.md) and is removed here once the system adopts it and system.css is
      re-copied. */

/* ===================================================================== 1. WordPress glue */
/* Core's flow layout adds nothing (blockGap is 0); post content sits directly in main. */
.wp-block-post-content > .pf-section:first-child { padding-top: var(--pf-space-moderate); }
.wp-block-post-content > .pf-section:last-child { padding-bottom: var(--pf-space-group); }
/* On a case study, More work follows post content: the content's last section keeps no end padding and More work
   sits the system's section distance below it, as if both were sections of main. */
.wp-block-post-content:has(+ .pf-section) > .pf-section:last-child { padding-bottom: 0; }
.wp-block-post-content:has(> .pf-section) + .pf-section { margin-top: var(--pf-space-major); }

/* The project cards are core groups in the editor; the published page replaces each with one link (inc/project-cards.php). */
.editor-styles-wrapper .pf-card > .wp-block-image { margin: 0; }
.editor-styles-wrapper .pf-card > .wp-block-image img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.editor-styles-wrapper .pf-card > .pf-card-title a { color: inherit; text-decoration: none; }
.editor-styles-wrapper .pf-card > .pf-card-kind { text-align: left; }

/* ===================================================================== 2. Staged shared corrections */

/* R1 — ProjectIndex and More work: column thresholds in rem (32.5rem, 56.25rem), so enlarged text gets fewer,
   wider columns. Identical to the system's 520px and 900px at the default text size. The unconditional rules
   cancel the system's px queries; the rem queries then apply. */
.pf-index { grid-template-columns: minmax(0, 1fr); }
@container pf-section (min-width: 32.5rem) { .pf-index { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container pf-section (min-width: 56.25rem) { .pf-index { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pf-index--row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pf-index--row > :nth-child(3) { display: none; }
@container pf-section (min-width: 56.25rem) {
	.pf-index--row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.pf-index--row > :nth-child(3) { display: flex; }
}
/* R3 — More work keeps two cards side by side on every phone at the default text size (a 320px screen leaves a
   17.5rem frame); only when enlarged text makes the frame narrower than that do the two cards stack. */
@container pf-section (width < 17.5rem) { .pf-index--row { grid-template-columns: minmax(0, 1fr); } }

/* R2 — ProjectCard caption: stacks only when the card is narrower than 16.25rem (the system's 260px at the
   default text size), so enlarged text stacks the caption instead of crowding it. */
.pf-card-caption { flex-direction: row; align-items: baseline; }
.pf-card-kind { text-align: right; }
@container pf-card (width < 16.25rem) {
	.pf-card-caption { flex-direction: column; align-items: flex-start; }
	.pf-card-kind { text-align: left; }
}

/* R6 — Frames size the same in every engine. Three WebKit (Safari) behaviours, found 15 Nov 2026 in Safari 26.6 and
   Playwright WebKit 18.2 and 27.2; Chrome and Firefox already behave as below, so nothing changes there:
   a. A frame placed directly in a grid track (pf-frame or pf-opener-frame as a grid item, with an aspect-ratio) shrinks
      to its content's width instead of filling its columns: Safari treats its default alignment as "start". Frames
      always fill their columns, so justify-self says so explicitly (30 Story Coffee's logo frame, Frame it's feature,
      Occamy's identity frames).
   b. A frame sized by aspect-ratio, placed in a shared (subgrid) row, contributes the wrong height to that row, so the
      row is too short and the caption under it detaches (Ahern's pairs, 30 Story Coffee's digital row). Its automatic
      minimum height is the trigger: overflow-hidden frames have none per spec, so min-height: 0 states that.
   c. The viewer link (and its image) inside a frame resolves height: 100% inconsistently against a frame sized by
      aspect-ratio, max-height or a stretched track, so images overflow or fall short of their frames. The link fills
      the frame by absolute positioning instead, which every engine resolves against the frame's own box. Frames always
      have a size of their own (columns and aspect-ratio, a height, or a stretched track); none takes it from its image. */
:is(.pf-frame, .pf-opener-frame) { justify-self: stretch; min-height: 0; }
:is(.pf-frame, .pf-opener-frame) > .pf-zoom { position: absolute; inset: 0; }
/* Viewer links on a padded ground (pf-media) stay in flow; they are the focus ring's positioning box (R4). */
.pf-media > .pf-zoom { position: relative; }

/* R4 — Focus on viewer links inside clipping frames (Figure, Gallery, Opener). The frame clips an outside outline, so
   the indicator is drawn inside the edge, above the image: 2px of ink at the edge, then 2px of the page colour.
   The two colours are 16:1 apart, so whatever the artwork under them, one of them is at least 3:1 against it
   (WCAG 1.4.11, 2.4.7; technique C40), and the pair is 4px thick. Approved as a shared accessibility correction
   (15 Nov 2026); replaces the single accent ring each case-study stylesheet carried. Unfocused frames are unchanged. */
:is(.pf-frame, .pf-media, .pf-opener-frame) .pf-zoom:focus-visible { outline-color: var(--pf-color-ink); outline-offset: calc(-1 * var(--pf-focus-width)); }
:is(.pf-frame, .pf-media, .pf-opener-frame) .pf-zoom:focus-visible::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; outline: var(--pf-focus-width) solid var(--pf-color-ink); outline-offset: calc(-1 * var(--pf-focus-width)); box-shadow: inset 0 0 0 calc(2 * var(--pf-focus-width)) var(--pf-color-page); }

/* R5 — Forced colours. Frame and swatch grounds are part of the artwork's presentation: without them, black marks
   and logos sit on a black canvas in dark themes and the colour roles lose their colours. They keep their own
   colours; text, borders, buttons and links around them follow the reader's theme as before. The header and footer
   mark is black line art on the page, so it is inverted when the theme's canvas is dark. */
@media (forced-colors: active) {
	.pf-frame, .pf-media, .pf-opener-frame, .pf-card-frame, .pf-swatch-chip { forced-color-adjust: none; }
	:is(.pf-frame, .pf-media, .pf-opener-frame) .pf-zoom:focus-visible, :is(.pf-frame, .pf-media, .pf-opener-frame) .pf-zoom:focus-visible::after { outline-color: Highlight; box-shadow: none; }
}
@media (forced-colors: active) and (prefers-color-scheme: dark) {
	.pf-logo { filter: invert(1); }
}
