/* Site additions: only what bundle.css doesn't cover. Every value comes from tokens.css. */

/* ---------- Subgrid: blocks inside a section keep the 12 columns ---------- */
.sg { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; row-gap: var(--space-l); align-items: start; }
.sg.is-decisions { row-gap: var(--space-xl); }
/* a sub-heading sits close to its own content (m); the parts under it stay apart (l) */
.sg.yt-sub { row-gap: var(--space-m); }
.sg.yt-sub > .h3 + * ~ * { margin-top: calc(var(--space-l) - var(--space-m)); }

/* ---------- Text inside blocks ---------- */
.yt-two-text > * + * { margin-top: var(--space-s); }
.yt-two-text > h3 + *, .yt-two-text > h4 + * { margin-top: var(--space-xs); }
/* Key decisions: the right column keeps the text measure */
.yt-two-side { max-width: var(--measure); }
.yt-steps p + p { margin-top: var(--space-s); }
.yt-list { padding-left: 1.2em; }
.yt-list li + li { margin-top: var(--space-xs); }
.yt-list.lead li + li { margin-top: var(--space-s); }
/* a list in running text: an intro line ending in ":" holds its list close;
   sentence-long items and the paragraph after the list get paragraph spacing */
p + .yt-list { margin-top: var(--space-xs); }
p + .yt-list li + li, .yt-two-text .yt-list li + li { margin-top: var(--space-s); }
.yt-list + p { margin-top: var(--space-s); }
/* linked items: the links' touch padding already makes the gap */
.yt-list > li + li:has(> .yt-link) { margin-top: 0; }
/* a group title holds its list (Bookshelf) */
.h3 + .yt-list { margin-top: var(--space-s); }
.yt-side-stack > * + * { margin-top: var(--space-l); }
.yt-note { margin-top: var(--space-m); }

/* ---------- Case summary with 4 items ----------
   Desktop only: on the 4-column phone grid, 1 / 7 would add two empty columns and pull the whole summary 24px short of the margin. */
@media (min-width: 768px) { .yt-summary.is-4 > :nth-child(5) { grid-column: 1 / 7; } }
/* Layout B (900px and up): the summary starts at column 4, so the 4th item goes under the first one (Role) */
@media (min-width: 900px) { .yt-summary.is-4 > :nth-child(5) { grid-column: 4 / 8; } }

/* ---------- Results: one row per measure (case pages) ---------- */
.yt-results-lede { margin-top: var(--space-l); }   /* h2 → content */
.yt-results-note { margin-top: var(--space-m); }   /* belongs to the rows above */
.yt-result-rows { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; }
.yt-result-row { row-gap: var(--space-s); padding-block: var(--space-l); border-top: var(--line) solid var(--rule); }
.yt-result-rows > .yt-result-row:last-child { border-bottom: var(--line) solid var(--rule); }
.yt-result-rows + .yt-sub { margin-top: var(--space-l); }   /* same gap below the line as each result row has */
.yt-result-row .h4 { margin-top: var(--space-xs); max-width: 24ch; }
.yt-result-row .small { margin-top: var(--space-xs); max-width: 40ch; }
/* phones: stats and result rows stacked in one field (grid-fields.js step 0); items one baseline line apart,
   with the result rows' dividing lines in the middle of that line. The space left in the field's last row stays at the end. */
html.grid-fields main .f-stack.f-stack, html.grid-fields main .f-stack.f-stack > .sg { row-gap: var(--p-unit, 24px) !important; align-content: start; }
html.grid-fields main .f-stack > .yt-result-row + .yt-result-row::before,
html.grid-fields main .f-stack > .yt-result-row:last-child::after { --f-gap: var(--p-unit, 24px); }
.yt-before, .yt-to { color: var(--muted); }
.yt-to { margin-inline: .15em; }

/* ---------- Learnings: two paragraphs side by side, 6 columns each ---------- */
.yt-learnings { row-gap: var(--space-s); }
.yt-learnings p + p { margin-top: 0; }
/* a learning about the portfolio itself, set apart from the case learnings by a line */
.yt-learnings-aside { border-top: var(--line) solid var(--rule); padding-top: var(--space-m); }

/* ---------- Audience blocks (AI workflow results): space only, no frames ---------- */
.yt-trio { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-l) var(--gut); }
.yt-trio > div > * + * { margin-top: var(--space-xs); }
.yt-trio > div > p + p { margin-top: var(--space-s); }

/* ---------- Responsive ---------- */
@media (max-width: 899px) {
  .yt-trio { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .sg > * { grid-column: 1 / -1; }
  /* bundle.css spans summary cells with :nth-child, which outranks .g > * on mobile */
  .yt-summary > :nth-child(n) { grid-column: 1 / -1; }
}

/* ---------- Process stepper: 6 steps in one row, vertical on phone ---------- */
.yt-stepper { --dot: 11px; list-style: none; padding: 0; margin: 0; position: relative;
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); column-gap: var(--gut); }
.yt-stepper::before { content: ""; position: absolute; left: 0; right: 0; top: calc(var(--dot) / 2); border-top: var(--line) solid var(--rule); }
.yt-step { position: relative; min-width: 0; }
.yt-step-mark { display: block; width: var(--dot); height: var(--dot); background: var(--ink); }
.yt-step-num { display: block; margin-top: var(--space-s); font-size: var(--fs-label); line-height: 1; letter-spacing: .06em; color: var(--muted); font-variant-numeric: tabular-nums; }
/* min-height: one tag tall, so steps without a tag keep their text on the same line as the others */
.yt-step-who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: calc(var(--fs-label) + 12px); margin-top: var(--space-s); }
.yt-step-tool { display: inline-flex; align-items: center; padding: 5px 8px; font-size: var(--fs-label); line-height: 1; letter-spacing: .04em; text-transform: uppercase; font-weight: 500; color: var(--ink); border: var(--line) solid var(--ink); white-space: nowrap; }
.yt-step.is-claude .yt-step-tool { background: var(--ink); color: var(--bg); }
.yt-step-text { margin-top: var(--space-s); font-size: clamp(15px, 1.25vw, 18px); line-height: 1.35; text-wrap: pretty; }

@media (max-width: 767px) {
  .yt-stepper { grid-template-columns: 1fr; row-gap: 0; }
  .yt-stepper::before { display: none; }
  .yt-step { padding-left: calc(var(--dot) + var(--space-s)); padding-bottom: var(--space-m); }
  .yt-step::before { content: ""; position: absolute; left: calc(var(--dot) / 2 - 0.5px); top: 0; bottom: 0; border-left: var(--line) solid var(--rule); }
  .yt-step:last-child::before { bottom: auto; height: var(--dot); }
  .yt-step-mark { position: absolute; left: 0; top: 2px; }
  .yt-step-num { margin-top: 0; }
  /* rows only line up across columns; stacked, an empty tag row is just a gap */
  .yt-step-who:empty { display: none; }
}

/* ---------- A section that follows the hero directly (Bookshelf) ---------- */
.yt-flush { padding-top: 0; }


/* ---------- Buttons: prototype links on the case pages ---------- */
.yt-btn { display: inline-flex; align-items: center; gap: var(--arrow-gap); min-height: 48px; padding: 0 24px;
  font-family: var(--font-sans); font-size: var(--fs-nav); line-height: 1; font-weight: 400; text-decoration: none;
  background: var(--ink); color: var(--bg); border: var(--line) solid var(--ink); border-radius: var(--radius-none);
  transition: gap var(--dur-feedback) var(--ease-settle), background var(--dur-feedback) var(--ease-settle), color var(--dur-feedback) var(--ease-settle); }
.yt-btn:hover { gap: var(--arrow-gap-hover); }
.yt-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.yt-btn.is-ghost { background: transparent; color: var(--ink); }
.yt-btn.is-ghost:hover { background: var(--ink); color: var(--bg); }
.yt-proto-top { margin-top: var(--space-s); }
.yt-proto { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-s) var(--space-m); margin-top: var(--space-m); }
.yt-proto p { margin: 0; max-width: 40ch; }
@media (max-width: 767px) { .yt-proto .yt-btn { width: 100%; box-sizing: border-box; justify-content: center; } }
/* the button hugs its label (Layout B turns .yt-proto into a grid, which would stretch it); phones keep it full width */
.yt-proto > .yt-btn { justify-self: start; }
@media (prefers-reduced-motion: reduce) { .yt-btn { transition-property: background, color; } }   /* the fill still changes; the gap doesn't move */

/* Case screenshots */
.yt-shot { display: block; width: 100%; height: auto; border: var(--line) solid var(--box); box-sizing: border-box; }
.yt-card-media .yt-shot { aspect-ratio: 4 / 3; object-fit: cover; object-position: center top; transition: transform var(--dur-feedback) var(--ease-settle); }
.yt-card:hover .yt-card-media .yt-shot { transform: scale(0.975); }
@media (prefers-reduced-motion: reduce) { .yt-card-media .yt-shot { transition: none; } }

/* Card 3: /skills command menu. Sized with container units so it scales with the card.
   Padding is in % (of the card width): cqi on the container itself would resolve against the viewport. */
.sk { position: relative; aspect-ratio: 4 / 3; max-width: 100%; overflow: hidden; container-type: inline-size; box-sizing: border-box; color: var(--ink); transition: transform var(--dur-feedback) var(--ease-settle); }
.yt-card:hover .sk { transform: scale(0.975); }
.sk-d { background: var(--white); border: var(--line) solid var(--box); padding: 6% 7%; display: flex; flex-direction: column; justify-content: center; }
.sk-word { font-family: var(--font-sans); font-weight: 400; letter-spacing: -0.045em; line-height: 0.9; white-space: nowrap; }
.sk-d .sk-word { font-size: 13cqi; padding-bottom: 3.5cqi; border-bottom: var(--line) solid var(--ink); display: inline-flex; align-items: baseline; }
.sk-caret { display: inline-block; width: 0.06em; height: 0.82em; margin-left: 0.06em; background: var(--ink); transform: translateY(0.08em); animation: sk-blink 1.1s steps(1) calc(var(--d, 0ms) + var(--dur-enter)) 3; }
@keyframes sk-blink { 50% { opacity: 0; } }
/* three blinks (3.3s, under WCAG 2.2.2's 5s), then a solid caret; they start once the card has revealed and settled, so none are spent off-screen */
.yt-motion .yt-reveal:not(.is-in) .sk-caret { animation: none; }
.sk-menu { list-style: none; padding: 0; margin: 3.5cqi 0 0; display: grid; gap: 1.2cqi; font-size: 4.6cqi; line-height: 1.3; color: var(--muted); }
.sk-menu li { display: flex; justify-content: space-between; gap: 2cqi; }
.sk-menu li:first-child span:first-child { color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .sk { transition: none; } .sk-caret { animation: none; } }

/* ---------- Before/after frame: case hero, all 12 columns (before-after.js) ----------
   Before sits underneath. After sits on top and is clipped from the left edge to --pos. */
/* margin-top is left to the hero, which spaces its children with space-l */
.ba-fig { grid-column: 1 / -1; margin-inline: 0; margin-bottom: 0; container-type: inline-size;
  /* the frame is never taller than the screen: screen height minus the header and a gap above and below */
  --ba-max-h: calc(100vh - var(--bar-gap) - var(--header-height) - 2 * var(--space-m)); }
@supports (height: 100svh) { .ba-fig { --ba-max-h: calc(100svh - var(--bar-gap) - var(--header-height) - 2 * var(--space-m)); } }
/* full width; height follows the screenshot ratio up to the screen-height cap
   (aspect-ratio + max-height would shrink the width instead, so the height is computed from the figure's width) */
.ba { --pos: 50%; position: relative; width: 100%; height: min(calc(100cqw / (var(--ba-ratio, 16 / 9))), var(--ba-max-h)); box-sizing: border-box; overflow: hidden;
  border: var(--line) solid var(--box); background: var(--box); cursor: ew-resize;
  user-select: none; -webkit-user-select: none; touch-action: pan-y; }
/* the divider holds focus (role="slider"); the ring goes round the whole frame */
.ba:has(.ba-bar:focus-visible) { outline: 2px solid var(--ink); outline-offset: 4px; }
.ba-bar:focus-visible { outline: none; }
@supports not selector(:has(*)) { .ba-bar:focus-visible .ba-grip { outline: 2px solid var(--ink); outline-offset: 2px; } }
/* stage: the screenshot at its own ratio, centered; on a short screen the frame's grey fill shows on the sides.
   Layers, notes and the divider all measure against the stage, so they stay on the screenshot. */
.ba-stage { position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); aspect-ratio: var(--ba-ratio, 16 / 9); max-width: 100%; background: var(--bg); }
.ba-layer { position: absolute; inset: 0; }
.ba-layer > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; object-fit: contain; }
/* the frame takes the After screenshot's shape; a Before of another shape sits whole inside it, on the frame grey */
.ba-before { background: var(--box); }
.ba-after { clip-path: inset(0 0 0 var(--pos)); }
/* is-easing: edge snap when the mouse leaves near a side, and release from a pin; is-stepping: one arrow-key step */
.ba.is-easing .ba-after { transition: clip-path var(--dur-enter) var(--ease-settle); }
.ba.is-easing .ba-bar { transition: left var(--dur-enter) var(--ease-settle); }
.ba.is-stepping .ba-after { transition: clip-path var(--dur-feedback) var(--ease-settle); }
.ba.is-stepping .ba-bar { transition: left var(--dur-feedback) var(--ease-settle); }

/* divider: a bar with a square grip in the page colour, so it shows on the light screenshots */
.ba-bar { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 3px; margin-left: -1.5px; background: var(--bg); pointer-events: none; }
.ba-grip { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1; letter-spacing: 2px;
  transition: background-color var(--dur-feedback) var(--ease-settle), color var(--dur-feedback) var(--ease-settle); }
/* pinned (a click): the grip turns cream, with a dark edge so it still shows on the light screenshots */
.ba.is-pinned .ba-grip { background: var(--ink); color: var(--bg); box-shadow: inset 0 0 0 var(--line) var(--bg); }
/* hover no longer moves a pinned divider, so the cursor stops being a resize arrow */
.ba.is-pinned { cursor: default; }

/* Before / After labels, bottom corners, inside their own layer so the wipe clips them */
.ba-corner { position: absolute; bottom: 14px; padding: 6px 10px; font-size: var(--fs-label); line-height: 1; letter-spacing: .04em; text-transform: uppercase; font-weight: 500; border: var(--line) solid var(--ink); }
.ba-before .ba-corner { left: 14px; background: var(--bg); color: var(--ink); }
.ba-after .ba-corner { right: 14px; background: var(--ink); color: var(--bg); }

/* below 1024px the screenshots' text is too small to read in the frame, so a button opens both in the image viewer (lightbox.js) */
.ba-open { display: none; margin-top: var(--space-s); padding: 0; font: inherit; font-size: var(--fs-nav); color: var(--ink); background: none; border: 0; cursor: pointer; }
.ba-open:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (max-width: 1023px) { .ba-open { display: inline-block; } }
@media (max-width: 699px) {
  /* 15px capitals would be wider than half a phone-width screenshot, so the wipe would cut "After · re-created" at rest */
  .ba-corner { bottom: 8px; padding: 5px 7px; text-transform: none; letter-spacing: 0; }
  .ba-before .ba-corner { left: 8px; }
  .ba-after .ba-corner { right: 8px; }
  .ba-grip { width: 28px; height: 28px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .ba:is(.is-easing, .is-stepping) :is(.ba-after, .ba-bar), .ba-grip { transition: none; }
}

/* ---------- Image viewer: case screenshots open full screen (lightbox.js) ---------- */
main img.yt-shot[role="button"] { cursor: zoom-in; }
main img.yt-shot[role="button"]:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
html.lb-open { overflow: hidden; }
/* always dark, so the light screenshots stand out; colors match the page tokens */
.lb { --lb-bg: var(--bg); --lb-ink: var(--ink); --lb-muted: var(--muted); --lb-line: color-mix(in srgb, var(--ink) 30%, transparent);
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  display: none; flex-direction: column; background: var(--lb-bg); color: var(--lb-ink); font-family: var(--font-sans); }
.lb[open] { display: flex; animation: lb-in var(--dur-feedback) var(--ease-settle); }
.lb::backdrop { background: transparent; }
@keyframes lb-in { from { opacity: 0; } }   /* a fade with no travel, so it stays under reduced motion */
.lb-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--space-s);
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); }
.lb-count { white-space: nowrap; font-size: var(--fs-label); line-height: 1; letter-spacing: .06em; color: var(--lb-muted); font-variant-numeric: tabular-nums; }
.lb-actions { display: flex; gap: 8px; }
.lb-btn { min-width: 44px; min-height: 44px; padding: 0 14px; white-space: nowrap; font: inherit; font-size: var(--fs-nav); line-height: 1;
  background: transparent; color: var(--lb-ink); border: var(--line) solid var(--lb-line); border-radius: var(--radius-none); cursor: pointer; }
.lb-btn:hover { border-color: var(--lb-ink); }
/* the smallest phones: tighter buttons keep the bar on one line */
@media (max-width: 374px) { .lb-bar { gap: 8px; } .lb-actions { gap: 6px; } .lb-btn { padding: 0 10px; } }
.lb-btn:focus-visible { outline: 2px solid var(--lb-ink); outline-offset: 2px; }
/* the image sits centered with auto margins, which drop to 0 once it is bigger than the stage, so every edge stays reachable */
.lb-stage { flex: 1; min-height: 0; display: flex; position: relative; overflow: auto; overscroll-behavior: contain;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.lb-img { flex: none; display: block; margin: auto; max-width: none; height: auto; cursor: zoom-in; user-select: none; -webkit-user-select: none; }
.lb.is-zoomed .lb-img { cursor: zoom-out; }
.lb.is-dragging .lb-img { cursor: grabbing; }

/* ---------- Page loader: every portfolio page open (loader.js; the classes come from loader-init.js in each page's head) ---------- */
/* plain cover until the loader's canvas is up; it never depends on loader.js to go away (the head failsafe drops the class) */
html.is-loading body::after { content: ""; position: fixed; inset: 0; z-index: 99; background: var(--bg); }
/* the hero title and header rule wait for the loader instead of playing behind it */
html:is(.is-loading, .is-loader-exit) .yt-load-rise,
html:is(.is-loading, .is-loader-exit) .yt-header-in::after { animation-play-state: paused; }
.yt-loader { position: fixed; inset: 0; z-index: 100; background: var(--bg); color: var(--ink); transition: opacity 400ms var(--ease); }
.yt-loader.is-out { opacity: 0; }
.yt-loader canvas { display: block; width: 100%; height: 100%; }
/* centered counter; loader.js leaves the grid empty around it, so it needs no background patch */
.yt-loader-count { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-family: var(--font-sans); font-size: var(--fs-h4); font-weight: 400; letter-spacing: -0.03em; line-height: 1; font-feature-settings: "tnum"; }
/* reduced motion: no loader, the page fades in */
html.is-fade-in body { animation: yt-page-in 200ms var(--ease) both; }
@keyframes yt-page-in { from { opacity: 0; } }

/* ---------- Header on narrow phones ----------
   Below 460px the name and the three links can't share a row at the 16px link floor (373px + margins + the bar's 24px insets), so the header takes two rows (90px).
   Pinned, that would hold over a tenth of the screen, so here it scrolls away with the page. */
@media (max-width: 459px) { .yt-header { position: relative; } }
/* header and footer: their fill runs across the 12 columns only, the same edges as their lines (--bg from tokens.css) */
.yt-header-in, .yt-footer-in { --bar-m: var(--m); padding-inline: calc(var(--bar-m) + var(--bar-pad)); background: linear-gradient(var(--bg), var(--bg)) center / calc(100% - 2 * var(--bar-m)) 100% no-repeat; }
@media (max-width: 767px) { .yt-header-in, .yt-footer-in { --bar-m: var(--m-mobile); } }
/* a strip of page colour above the header (it stays while the header is pinned) and below the footer */
.yt-header { padding-top: var(--bar-gap); }
.yt-footer { padding-bottom: var(--bar-gap); }
/* running text is one step softer than titles; links and bold words inside it stay full --ink */
.body:not(.muted), .lead:not(.muted), .yt-step-text { color: var(--ink-soft); }
:is(.body, .lead, .yt-step-text) :is(a, b, strong) { color: var(--ink); }
/* header and footer show their lines again */
.yt-header-in::after, .yt-footer-in::before { display: block; }
/* the header keeps a fill now that nothing runs behind it */
.yt-header { background: var(--bg); }

/* ---------- Buttons on the dark site: outlined in cream on the page colour (the focus ring stays) ---------- */
.yt-btn, .yt-btn.is-ghost { background: var(--bg); color: var(--ink); border: var(--line) solid var(--ink); }
.yt-btn:hover, .yt-btn.is-ghost:hover { background: var(--ink); color: var(--bg); }
.ba-open { background: var(--bg); border: var(--line) solid var(--ink); padding-inline: var(--space-s); }
/* a 44px touch target: the label centred by its line, the border inside the 44px */
.ba-open { box-sizing: border-box; min-height: 44px; line-height: calc(44px - 2 * var(--line)); }
.lb-btn, .lb-btn:hover { background: var(--lb-bg); border: var(--line) solid var(--lb-line, var(--ink)); }

/* tables and result rows: the softer line of "Products built on it", the same grey as the light site's dark section */
.yt-table, .yt-result-rows { --rule: var(--rule-soft); }
