/* Layout for the pages that aren't case studies: home, work, about, perch, let's chat.
   Every text style comes from a .ds-* class in tokens.css and every space from the scale. */
#site-root button { font-family: var(--font-sans); } /* buttons don't inherit the page font */
.pg-sec { max-width: 1120px; margin: 0 auto; padding: var(--section-gap) var(--space-32) 0; }
.pg-col { max-width: 680px; }
:where(#site-root) :where(h1, h2, h3, h4, p, dl, dd, figure, blockquote) { margin: 0; }
:where(#site-root) :where(ul.pg-list) { list-style: none; margin: 0; padding: 0; }

/* buttons */
/* the contact form's submit: Let's chat's look at the main button's height, with the rolling label */
.chat-send { display: inline-flex; align-items: center; min-height: var(--space-48); padding: 0 var(--space-24); border: 0; border-radius: var(--radius-control); background: var(--page); box-shadow: inset 0 0 0 var(--stroke-button) var(--ink); color: var(--ink); font-weight: var(--weight-medium); cursor: pointer; }
.chat-send:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.pg-button { display: inline-flex; align-items: center; gap: var(--space-12); min-height: var(--space-48); padding: 0 var(--space-24); border-radius: var(--radius-control); background: var(--ink); color: var(--ink-inverse); font-family: var(--font-sans); font-size: var(--small-size); line-height: var(--small-line); font-weight: var(--weight-medium); transition: transform var(--duration-base) var(--ease); }
/* a secondary action: an underlined text link with its arrow, not a second button */
.pg-button-ghost { padding: 0; border: 0; background: none; color: var(--ink); }

/* home: hero */
.pg-hero-col { grid-column: 2; display: flex; flex-direction: column; align-items: center; }
.pg-hero-title { max-width: 620px; text-align: center; }
.pg-pet-hint { position: absolute; left: 0; right: 0; bottom: 76px; text-align: center; white-space: nowrap; font-family: var(--font-pixel); font-size: var(--pixel-size); line-height: var(--pixel-line); letter-spacing: 0.04em; color: var(--ink-secondary); pointer-events: none; transition: opacity var(--duration-slow) var(--ease); animation: ty-hint-in 660ms var(--ease) 940ms both; }

/* home and work: case study cards */
#work.pg-sec { padding-top: 0; }
/* the homepage heading: a full --section-gap below the plank, which ends 24px above this
   section (56px on phones, where the hero has more bottom padding) */
.pg-work-title { margin-top: calc(var(--section-gap) - var(--space-24)); }
@media (max-width: 640px) { .pg-work-title { margin-top: calc(var(--section-gap) - 56px); } }
.pg-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--cards-row-gap) var(--space-32); margin-top: var(--space-32); }
/* one link per card, named by its title. Text sits on the page; only the image has a shape. */
.pg-card { display: block; border-radius: var(--radius-card); color: var(--ink); }
.pg-card:focus-visible { outline: 2px solid var(--ink); outline-offset: var(--space-8); }
.pg-card-img { position: relative; border-radius: var(--radius-card); background: var(--raised); aspect-ratio: 16 / 10; overflow: hidden; }
.pg-card-img [data-slot] { height: 100%; aspect-ratio: auto; transition: transform var(--duration-zoom) var(--ease); }
/* the cards' entrance (js/card-enter.js): only that script sets data-enter, so cards show without it */
@media (prefers-reduced-motion: no-preference) {
  .pg-card-enter[data-enter="hidden"] { opacity: 0; transform: translate3d(0, var(--enter-shift), 0); transition: none; }
  .pg-card-enter[data-enter="in"] { transition: opacity var(--duration-enter) var(--ease-enter), transform var(--duration-enter) var(--ease-enter); }
}
/* a card's preview (js/card-preview.js, from data-video), over its thumbnail in the same frame, fading in once it's playing */
.pg-card-video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.pg-card-video { opacity: 0; transition: opacity var(--duration-preview) var(--ease-preview); pointer-events: none; }
.pg-card.is-previewing .pg-card-video { opacity: 1; }
.pg-card-meta { margin-top: var(--space-16); text-wrap: balance; }
.pg-card .ds-card-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; margin-top: var(--space-8); }
.pg-card-link { display: flex; align-items: center; gap: var(--space-8); width: fit-content; margin-top: var(--space-12); color: var(--ink); font-family: var(--font-sans); font-size: var(--small-size); line-height: var(--small-line); font-weight: var(--weight-medium); }
.pg-card-link-label { text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.pg-card:focus-visible .pg-card-img [data-slot] { transform: scale(1.02); }
.pg-card:focus-visible .pg-card-link { color: var(--theme-text); }
.pg-card:focus-visible .pg-card-link-label { text-decoration-thickness: 2px; }
.pg-card:focus-visible .link-arrow { transform: translate3d(2px, 0, 0); }
@media (hover: hover) {
  .pg-card:hover .pg-card-img [data-slot] { transform: scale(1.02); }
  .pg-card:hover .pg-card-link { color: var(--theme-text); }
  .pg-card:hover .pg-card-link-label { text-decoration-thickness: 2px; }
  .pg-card:hover .link-arrow { transform: translate3d(2px, 0, 0); }
}
/* the 48px link box centres its text, so the 40px is measured to the text */
#work > .pg-button { margin-top: calc(var(--cards-after) - (var(--space-48) - var(--small-line)) / 2); }

/* home: what I bring */
.pg-band { background: var(--sunken); margin-top: var(--section-gap); }
.pg-bring { padding-bottom: var(--section-gap); }
/* the tabs: plain labels, centred, under a plank drawn like the homepage ground. The cat
   loafs on the plank above the active label. On phones the row scrolls sideways inside
   the scroller (the cat scrolls with it, the plank spans the visible part), with a fade
   on the right while there's more. */
.pg-tabs-wrap { position: relative; }
.pg-tabs-scroll { overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; scrollbar-width: none; overscroll-behavior-x: contain; }
.pg-tabs-scroll::-webkit-scrollbar { display: none; }
.pg-tabs-track { position: relative; width: max-content; min-width: 100%; padding-top: var(--space-64); }
/* the plank: the row's width plus --space-12 each side (set in JS). The page colour behind
   the 40% canvas gives the same two wood tones as the homepage ground, on the band too. */
.pg-plank { position: absolute; left: 0; top: var(--space-64); display: block; }
.pg-plank canvas { display: block; image-rendering: pixelated; }
.pg-tabs { display: flex; justify-content: center; gap: var(--space-32); margin-top: var(--space-16); }
.pg-tab { display: inline-flex; align-items: center; min-height: var(--space-48); padding: 0; border: 0; background: none; font-family: var(--font-sans); font-size: var(--h4-size); line-height: var(--h4-line); font-weight: var(--weight-medium); color: var(--ink-secondary); white-space: nowrap; cursor: pointer; scroll-snap-align: start; transition: color var(--duration-quick) var(--ease); }
.pg-tab:hover, .pg-tab.is-on { color: var(--ink); }
.pg-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: var(--space-4); border-radius: var(--space-4); }
/* the active label's underline: the handwriting font's own underscore stroke, stretched to
   the label. It writes in left to right as a wipe (two opposite translates), so only
   transform moves. */
.pg-tab-mark { position: absolute; left: 0; top: 0; height: var(--space-12); overflow: hidden; pointer-events: none; color: var(--accent); transform: translate3d(var(--mark-x, 0), var(--mark-y, 0), 0); }
.pg-tab-mark-in { display: block; width: 100%; height: 100%; }
.pg-tab-mark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.pg-tab-mark.is-writing { animation: pg-wipe-out 300ms var(--ease) both; }
.pg-tab-mark.is-writing .pg-tab-mark-in { animation: pg-wipe-in 300ms var(--ease) both; }
@keyframes pg-wipe-out { from { transform: translate3d(var(--mark-x), var(--mark-y), 0) translate3d(-100%, 0, 0); } to { transform: translate3d(var(--mark-x), var(--mark-y), 0); } }
@keyframes pg-wipe-in { from { transform: translate3d(100%, 0, 0); } to { transform: none; } }
.pg-tabs-wrap::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: var(--space-48); background: linear-gradient(to right, transparent, var(--sunken)); pointer-events: none; opacity: 0; transition: opacity var(--duration-quick) var(--ease); }
.pg-tabs-wrap.is-more::after { opacity: 1; }
.pg-pillcat { position: absolute; inset: 0; pointer-events: none; }
.pg-pillcat-host { position: absolute; left: 0; top: var(--space-64); width: 100%; height: 0; }
.pg-pillcat .tc-cat { pointer-events: none; }
.pg-pillcat-hit { position: absolute; left: 20%; right: 20%; top: 45%; bottom: 0; pointer-events: auto; }
/* the cat's pet line sits in the room above the plank, outside the scroller so it isn't clipped */
.pg-tabs-wrap > .pg-tabs-msg { top: 0; bottom: auto !important; }
.pg-bring-body { max-width: 760px; margin: var(--space-32) auto 0; }
/* handwritten words: Vara draws them as SVG strokes in the accent. JS places them on a
   diagonal around the centred statement (placeHands): the top word starts a little left of
   the first line, the closing word ends a little right of the last, both inside the column. */
.pg-hand { color: var(--accent); height: calc(var(--hand-size) * 2); }
.pg-hand svg { overflow: visible; }
.pg-hand-top { --hand-size: var(--hand-top); transform: translate3d(var(--hand-shift, 0px), 0, 0) rotate(-6deg); transform-origin: left center; }
.pg-hand-bottom { --hand-size: var(--hand-bottom); max-width: 100%; transform: translate3d(var(--hand-shift, 0px), 0, 0) rotate(-4deg); transform-origin: right center; }
.pg-hand.is-plain { font-family: Caveat, cursive; font-weight: var(--weight-semibold); font-size: var(--hand-size); line-height: 1.1; }
.pg-hand-bottom.is-plain { text-align: right; }
.pg-bring-line { margin: var(--space-8) 0; min-height: calc(var(--title-line) * 2); text-align: center; opacity: 0; transform: translate3d(0, 12px, 0); transition: opacity var(--duration-slow) var(--ease), transform var(--duration-slow) var(--ease); }
.pg-bring-line.is-shown { opacity: 1; transform: none; }

/* home: the hero's flowers (js/flowers.js). 70% of their column, on its inner side, as buttons;
   each turns on the foot of its stem. */
.pg-flower { display: block; width: 70%; padding: 0; border: 0; border-radius: var(--radius-control); background: none; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.pg-flower:focus-visible { outline: 2px solid var(--ink); outline-offset: var(--space-4); }
@media (max-width: 767px) { .pg-flower { width: 100%; } }
.pg-flower svg { display: block; transform-origin: 48% 94.5%; }
.pg-petal { position: absolute; left: 0; top: 0; z-index: 3; width: 19px; height: 44px; pointer-events: none; transition: opacity var(--duration-base) var(--ease); }
.pg-petal.is-gone { opacity: 0; }

/* home: the runner in What's next (js/cat-game.js, DESIGN_SYSTEM.md, Pixel page theme). The tab
   content fades out and the game sits over the section; --s is its pixel, set in device pixels. */
.pg-game-hint { position: absolute; bottom: var(--space-12); display: inline-flex; align-items: center; gap: var(--space-4); color: var(--accent-text); font-family: Caveat, cursive; font-size: var(--h3-size); line-height: 1; white-space: nowrap; opacity: 0; pointer-events: none; }
.pg-game-hint.is-on { opacity: 1; transition: opacity var(--duration-note) var(--ease); }
.pg-game-hint.is-left { flex-direction: row-reverse; }
.pg-game-hint.is-left svg { transform: scaleX(-1); }
.pg-bring { position: relative; }
.pg-tabs-scroll, .pg-bring-body { transition: opacity var(--duration-base) var(--ease); }
.pg-plank { transform-origin: 0 0; transition: transform var(--duration-slow) var(--ease); }
.is-gaming .pg-tabs-scroll, .is-gaming .pg-bring-body, .is-asking .pg-bring-body { opacity: 0; }
.is-gaming .pg-tabs-msg, .is-gaming .pg-tabs-wrap::after { opacity: 0 !important; }
.pg-bring { transition: height var(--duration-slow) var(--ease); }
.pg-bring.is-gaming { box-sizing: border-box; overflow: hidden; }
.pg-game { position: absolute; top: var(--space-48); left: 0; right: 0; width: min(var(--game-w), calc(100% - var(--space-32))); height: var(--game-h); margin: 0 auto; z-index: 2; opacity: 0; outline: none; touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: opacity var(--duration-base) var(--ease); }
.pg-game.is-on { opacity: 1; }
.pg-game-canvas { position: absolute; left: 0; bottom: 0; display: block; opacity: 0; pointer-events: none; image-rendering: pixelated; }
.pg-game.is-live .pg-game-canvas { opacity: 1; }
.pg-game-hud { position: absolute; top: var(--space-8); right: 0; display: flex; gap: 3ch; font-family: var(--font-pixel); font-size: var(--game-size); line-height: var(--game-line); color: var(--ink); pointer-events: none; }
.pg-game-best { color: var(--ink-secondary); }
/* with the visitor's own cat: its name and the score, small, over the best score */
.pg-game-hud.is-named { flex-direction: column; align-items: flex-end; gap: 0; font-size: var(--game-small); }
.pg-game-hud.is-named .pg-game-score { order: -1; white-space: nowrap; }
.pg-game .px-frame { --s: var(--game-s, 2px); }
/* 40px to look at, outside the play area's corner; its ::after keeps the tap area at 44px */
.pg-game .pg-game-close { position: absolute; bottom: calc(100% + var(--space-4)); right: 0; width: var(--game-close); height: var(--game-close); padding: 0; }
.pg-game .pg-game-close::before { inset: 0; }
.pg-game .pg-game-close::after { inset: -2px; }
.pg-game-close .px-frame-fill { flex: 1; padding: 0; margin: var(--game-s, 2px); }
.pg-game-big { position: absolute; left: 0; right: 0; top: var(--space-48); font-family: var(--font-pixel); font-size: var(--game-big); line-height: var(--game-big); color: var(--ink); text-align: center; pointer-events: none; }
.pg-game .pg-game-again { position: absolute; left: 50%; top: var(--space-48); min-height: var(--tap-min); font-family: var(--font-pixel) !important; font-size: var(--game-small); line-height: var(--game-line); font-weight: var(--weight-regular); transform: translate3d(-50%, 0, 0); }
.pg-game .pg-game-again:active { transform: translate3d(-50%, 1px, 0); }
.pg-game-again .px-frame-fill { padding: 0 var(--space-12); }
/* under the button, shrinking until the game goes back to the tab (IDLE_EXIT in cat-game.js) */
.pg-game-bar { position: absolute; left: 0; right: 0; top: calc(100% + var(--space-4)); height: 2px; background: var(--accent); transform-origin: 0 50%; }
.is-still, .is-still * { transition: none !important; }
.pg-game .pg-game-paused { position: absolute; left: 50%; top: var(--space-32); cursor: pointer; font-family: var(--font-pixel); font-size: var(--game-small); line-height: var(--game-line); white-space: nowrap; text-align: center; color: var(--ink); transform: translate3d(-50%, 0, 0); }
.pg-game-paused .px-frame-fill { padding: var(--space-8) var(--space-16); }
.pg-game-help { position: absolute; left: 0; right: 0; top: calc(100% + var(--space-16)); text-align: center; transition: opacity var(--duration-base) var(--ease); }
.pg-game-help.is-gone { opacity: 0; }
.pg-game-ask { position: absolute; left: 0; right: 0; top: calc(var(--space-96) * 2); display: flex; flex-direction: column; align-items: center; gap: var(--space-16); }
.pg-game-ask .ds-small { color: var(--ink); }
.pg-game-ask-row { display: flex; gap: var(--space-12); }
.pg-game-ask .px-frame { min-height: var(--tap-min); }
.pg-game-ask .px-frame-fill { padding: 0 var(--space-16); }
.pg-game [hidden] { display: none; }
@media (max-width: 639px) { .pg-game .pg-game-again { top: var(--space-32); } .pg-game .pg-game-paused { top: var(--space-24); } }
@media (prefers-reduced-motion: reduce) {
  .pg-game-hint, .pg-game-hint.is-on, .pg-plank, .pg-bring, .pg-game-help { transition: none; }
}

/* let's chat: the note beside the button */
.chat-note[data-failed] { color: var(--accent-text); }
/* the cat that turns up when a message is sent: a 32px frame at 2x, sitting on the row's baseline */
.chat-cat { position: relative; flex: none; width: calc(32px * 2); height: calc(32px * 2); margin: calc(var(--space-16) * -1) 0 calc(var(--space-8) * -1); }
.chat-cat[hidden] { display: none; }

/* home: craft strip */
.pg-craft-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-16) var(--space-48); }
.pg-craft-head .ds-h2 { max-width: 440px; }

@media (max-width: 1023px) {
  .pg-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .pg-sec { padding-left: var(--space-16); padding-right: var(--space-16); }
}
@media (prefers-reduced-motion: reduce) {
  .pg-button, .pg-tab, .pg-tabs-wrap::after { transition: none; }
  .pg-card .pg-card-img [data-slot], .pg-card .link-arrow { transform: none !important; transition: none; }
  .pg-card-video { display: none; }
  .pg-tab-mark.is-writing, .pg-tab-mark.is-writing .pg-tab-mark-in { animation: none; }
  .pg-pet-hint { animation: none; }
  .pg-bring-line { transition: none; }
}

/* work: page heading above the cards */
.pg-head { padding-top: var(--space-96); }
#work.pg-work { padding-top: var(--space-48); }
.pg-work .pg-cards { margin-top: 0; }

/* perch: the make-a-cat dialog */
.pg-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.pg-veil { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: var(--space-24); background: rgba(18, 18, 18, 0.34); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
/* three bands: the head and the button stay put, and only the form between them scrolls. The
   dialog itself never does, so its corners stay round. */
.pg-dialog { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 720px; max-height: 88vh; max-height: 88dvh; overflow: hidden; border-radius: var(--space-24); background: var(--page); box-shadow: 0 30px 80px rgba(18, 18, 18, 0.28); }
.pg-dialog-head { position: relative; flex: none; display: flex; align-items: center; gap: var(--space-24); padding: var(--space-16) var(--space-64) 0 var(--space-32); background: var(--sunken); border-bottom: 1px solid var(--rule); }
.pg-dialog-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--space-24) var(--space-32); scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
.pg-dialog-scroll::-webkit-scrollbar { width: 6px; }
.pg-dialog-scroll::-webkit-scrollbar-track { background: transparent; }
.pg-dialog-scroll::-webkit-scrollbar-thumb { border-radius: var(--radius-round); background: var(--rule); }
.pg-dialog-scroll::-webkit-scrollbar-button { display: none; }
.pg-dialog-foot { position: relative; flex: none; padding: var(--space-16) var(--space-32) var(--space-24); background: var(--page); border-top: 1px solid var(--rule); }
/* the fade over the form's last 24px, while there's more below */
.pg-dialog-foot::before { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: var(--space-24); background: linear-gradient(to bottom, transparent, var(--page)); opacity: 0; pointer-events: none; transition: opacity var(--duration-quick) var(--ease); }
.pg-dialog-foot.is-more::before { opacity: 1; }
.pg-close { position: absolute; top: var(--space-16); right: var(--space-16); z-index: 1; display: flex; align-items: center; justify-content: center; width: var(--space-32); height: var(--space-32); padding: 0; border: 1px solid var(--rule); border-radius: var(--radius-round); background: var(--page); color: var(--ink); cursor: pointer; }
/* the live preview: a 64 x 52 sprite-pixel canvas, one pixel unit to a pixel, standing on the ledge */
.pg-preview { flex: none; }
.pg-preview canvas { display: block; width: calc(64 * var(--u)); height: calc(52 * var(--u)); image-rendering: pixelated; }
.pg-dialog-titles { min-width: 0; }
.pg-dialog-sub { margin-top: var(--space-8); }
/* two columns from 768px, so the whole form fits a screen 800px tall */
.pg-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "name fur" "look fur" "look more" "mood perch"; grid-template-rows: auto auto 1fr auto; gap: var(--space-24) var(--space-32); align-items: start; }
.pg-fields > .pg-field:nth-child(1) { grid-area: name; }
.pg-fields > .pg-field:nth-child(2) { grid-area: look; }
.pg-fields > .pg-field:nth-child(3) { grid-area: fur; }
.pg-fields > .pg-field:nth-child(4) { grid-area: more; }
.pg-fields > .pg-field:nth-child(5) { grid-area: mood; }
.pg-fields > .pg-field:nth-child(6) { grid-area: perch; }
.pg-field { display: flex; flex-direction: column; gap: var(--space-8); }
.pg-field > .ds-label { color: var(--ink); }
.pg-name { display: flex; gap: var(--space-8); }
.pg-input { flex: 1 1 auto; min-width: 0; height: var(--space-48); padding: 0 var(--space-16); border: 1px solid var(--rule); border-radius: var(--space-12); background: var(--raised); font-family: var(--font-sans); font-size: var(--body-size); line-height: var(--body-line); color: var(--ink); }
.pg-input::placeholder { color: var(--ink-secondary); }
.pg-input:focus-visible, .pg-dice:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.pg-dice { flex: none; display: flex; align-items: center; justify-content: center; width: var(--space-48); height: var(--space-48); padding: 0; border: 1px solid var(--rule); border-radius: var(--space-12); background: var(--raised); color: var(--ink); cursor: pointer; transition: transform var(--duration-quick) var(--ease); }
.pg-dice:active { transform: rotate(-20deg) scale(0.94); }
.pg-looks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-8); }
.pg-look-img { display: block; width: 64px; height: 64px; image-rendering: pixelated; }
/* one-of-many choices (mood, perch): a segmented control, one connected row with shared
   borders; the chosen segment is filled (the buttons' own styles come from cat-tree.js) */
.pg-chips { display: flex; border: 1px solid var(--rule); border-radius: var(--radius-control); overflow: hidden; }
.pg-chips > button + button { border-left: 1px solid var(--rule) !important; }
.pg-chips > button:focus-visible { outline: 2px solid var(--ink); outline-offset: -4px; }
.pg-custom { display: flex; flex-direction: column; gap: var(--space-8); padding: var(--space-12); border: 1px solid var(--rule); border-radius: var(--space-12); background: var(--sunken); }
.pg-ramp { display: grid; border-radius: var(--space-8); overflow: hidden; }
.pg-ramp-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.pg-ramp-9 { grid-template-columns: repeat(9, minmax(0, 1fr)); }
.pg-submit { width: 100%; min-height: var(--space-48); }
.pg-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.pg-submit:disabled:hover .px-frame-fill { background: var(--page); color: var(--ink); }
.pg-submit:disabled:active { transform: none; }
.pg-name-msg { color: var(--accent-text); }
.pg-save-msg { margin-bottom: var(--space-12); text-align: center; }
.pg-name-msg:empty, .pg-perch-note:empty { display: none; }
.pg-dice[data-offer] { border-color: var(--ink); background: var(--ink); color: var(--ink-inverse); }
/* phones: a bottom sheet, one column, with the same three bands */
@media (max-width: 767px) {
  .pg-veil { padding: 0; align-items: flex-end; }
  .pg-dialog { max-width: none; max-height: calc(100vh - var(--space-24)); max-height: calc(100dvh - var(--space-24)); border-radius: var(--space-24) var(--space-24) 0 0; }
  .pg-dialog-head { gap: var(--space-16); padding: var(--space-12) var(--space-64) 0 var(--space-16); }
  .pg-close { top: var(--space-12); right: var(--space-12); width: var(--space-48); height: var(--space-48); }
  .pg-dialog-titles .ds-h2 { margin: 0; }
  .pg-dialog-scroll { padding: var(--space-16); }
  .pg-fields { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "look" "fur" "more" "mood" "perch"; grid-template-rows: none; gap: var(--space-16); }
  .pg-looks button { padding: var(--space-4) 0 !important; }
  .pg-dialog-foot { padding: var(--space-12) var(--space-16) calc(var(--space-12) + env(safe-area-inset-bottom)); }
}

/* perch: the pixel name tag. --s is the page's pixel unit. The outline is the sprites' own outline colour; the corners
   and the notch are stepped pixels, with no blur anywhere. */
.pg-tag { --s: var(--u); --line: rgb(10, 10, 14); position: fixed; left: 0; top: 0; z-index: 40; display: none; pointer-events: none; }
.pg-tag.is-on { display: block; }
.pg-tag-box, .pg-tag-fill {
  clip-path: polygon(var(--s) 0, calc(100% - var(--s)) 0, calc(100% - var(--s)) var(--s), 100% var(--s), 100% calc(100% - var(--s)), calc(100% - var(--s)) calc(100% - var(--s)), calc(100% - var(--s)) 100%, var(--s) 100%, var(--s) calc(100% - var(--s)), 0 calc(100% - var(--s)), 0 var(--s), var(--s) var(--s));
}
.pg-tag-box { padding: var(--s); background: var(--line); }
.pg-tag-fill { display: flex; flex-direction: column; gap: var(--s); padding: calc(var(--s) * 3) calc(var(--s) * 5) calc(var(--s) * 4); background: var(--page); white-space: nowrap; }
.pg-tag-name { display: flex; align-items: center; gap: calc(var(--s) * 3); font-family: var(--font-tag); font-size: 16px; line-height: 16px; color: var(--ink); }
.pg-tag-line { color: var(--ink); }
.pg-tag-you { padding: var(--s) calc(var(--s) * 2); background: var(--accent-text); color: var(--ink-inverse); font-family: var(--font-pixel); font-size: var(--pixel-size); line-height: var(--pixel-line); }
.pg-tag-you[hidden] { display: none; }
/* notch: a two-pixel point under the box. Row 0 is the box's bottom outline, opened in cream;
   rows 1 and 2 step in to the tip. The element is one cream pixel; the shadows are the rest. */
.pg-tag-notch { --p: var(--page); position: absolute; left: calc(50% - var(--s)); top: calc(100% - var(--s)); width: var(--s); height: var(--s); background: var(--p);
  box-shadow:
    calc(var(--s) * -1) 0 0 0 var(--p), var(--s) 0 0 0 var(--p), calc(var(--s) * 2) 0 0 0 var(--p),
    calc(var(--s) * -2) 0 0 0 var(--line), calc(var(--s) * 3) 0 0 0 var(--line),
    calc(var(--s) * -1) var(--s) 0 0 var(--line), 0 var(--s) 0 0 var(--p), var(--s) var(--s) 0 0 var(--p), calc(var(--s) * 2) var(--s) 0 0 var(--line),
    0 calc(var(--s) * 2) 0 0 var(--line), var(--s) calc(var(--s) * 2) 0 0 var(--line); }

/* perch: one button over each cat for keyboard users, invisible until focused */
.pg-cat-keys { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.pg-cat-key { position: absolute; left: 0; top: 0; width: 0; height: 0; padding: 0; border: 0; background: transparent; pointer-events: none; }
.pg-cat-key:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: var(--space-4); }
@media (prefers-reduced-motion: reduce) { .pg-dice, .pg-dialog-foot::before { transition: none; } }

/* home: the ground the cats stand on, their shadows, hearts, the peek and the toast */
.pg-ground { position: absolute; left: 0; top: 100%; display: block; image-rendering: pixelated; }
.pg-cat-shadow { position: absolute; left: 0; top: 100%; background-size: 100% 100%; image-rendering: pixelated; pointer-events: none; }
/* a pixel heart, 5 x 4 sprite pixels at 2x, drawn with box-shadow */
.pg-heart { position: absolute; bottom: 48px; width: 2px; height: 2px; color: #D9576B; pointer-events: none; opacity: 0;
  box-shadow: 2px 0 0 currentColor, 6px 0 0 currentColor, 0 2px 0 currentColor, 2px 2px 0 currentColor, 4px 2px 0 currentColor, 6px 2px 0 currentColor, 8px 2px 0 currentColor, 2px 4px 0 currentColor, 4px 4px 0 currentColor, 6px 4px 0 currentColor, 4px 6px 0 currentColor;
  animation: pg-heart 1100ms var(--ease) both; }
@keyframes pg-heart { 0% { opacity: 0; transform: translate3d(0, 0, 0) scale(0.6); } 15% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; transform: translate3d(var(--dx), var(--dy), 0) scale(1); } }
.pg-band { position: relative; }
/* the "!" a tap leaves in the air for the cats to chase; JS sets its size and sprite */
.pg-marker { position: absolute; z-index: 5; background-repeat: no-repeat; background-size: 100% 100%; image-rendering: pixelated; pointer-events: none; animation: pg-marker-in var(--duration-quick) var(--ease) both; transition: opacity var(--duration-base) var(--ease); }
.pg-marker.is-gone { opacity: 0; }
@keyframes pg-marker-in { from { opacity: 0; transform: translate3d(0, var(--space-4), 0); } to { opacity: 1; transform: none; } }
.pg-peek { position: absolute; bottom: 100%; overflow: hidden; pointer-events: none; }
.pg-peek-host { position: absolute; left: 0; bottom: 0; width: 100%; height: 64px; pointer-events: auto; }
.pg-toast { position: fixed; left: 50%; bottom: var(--space-24); z-index: 80; display: flex; align-items: center; gap: var(--space-12); max-width: calc(100vw - var(--space-32)); padding: var(--space-12) var(--space-12) var(--space-12) var(--space-16); border: 1px solid var(--rule); border-radius: var(--space-16); background: var(--raised); box-shadow: 0 12px 34px rgba(18, 18, 18, 0.14); opacity: 0; transform: translate3d(-50%, var(--space-16), 0); transition: opacity var(--duration-base) var(--ease), transform var(--duration-base) var(--ease); }
.pg-toast.is-on { opacity: 1; transform: translate3d(-50%, 0, 0); }
.pg-toast .ds-small { color: var(--ink); }
.pg-toast-close { flex: none; display: flex; align-items: center; justify-content: center; width: var(--space-32); height: var(--space-32); padding: 0; border: 0; border-radius: var(--radius-round); background: transparent; color: var(--ink); cursor: pointer; }
@media (prefers-reduced-motion: reduce) {
  .pg-heart, .pg-peek { display: none; }
  .pg-marker { animation: none; transition: none; }
  .pg-toast { transition: none; }
}

/* perch: Markings and eyes, a full-width disclosure under Fur colour */
.pg-more { display: flex; align-items: center; gap: var(--space-12); width: 100%; min-height: var(--space-48); padding: 0 var(--space-16); border: 1px solid var(--rule); border-radius: var(--space-12); background: var(--raised); color: var(--ink); text-align: left; cursor: pointer; }
.pg-more > span:first-child { flex: 1; }
.pg-more:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.pg-more svg { transition: transform var(--duration-quick) var(--ease); }
.pg-more[aria-expanded="true"] svg { transform: rotate(180deg); }
.pg-more-dots { display: flex; gap: var(--space-4); }
.pg-dot { width: var(--space-12); height: var(--space-12); border-radius: 50%; border: 1px solid var(--rule); }
.pg-more-body { display: flex; flex-direction: column; gap: var(--space-16); }
/* fur, markings and eyes: one grid of seven 40px dots, each in a 44px tap area. The grid reaches
   2px past the column each side, so the dots themselves line up with the labels and fields. */
.pg-swatches-7 { display: grid; grid-template-columns: repeat(7, minmax(0, var(--swatch-tap))); justify-content: space-between; margin: 0 calc((var(--swatch-size) - var(--swatch-tap)) / 2); }
.pg-swatch { display: flex; align-items: center; justify-content: center; aspect-ratio: 1 / 1; padding: 0; border: 0; background: none; cursor: pointer; }
.pg-swatch:focus-visible { outline: 2px solid var(--ink); outline-offset: -1px; border-radius: var(--radius-round); }
@media (prefers-reduced-motion: reduce) { .pg-more svg { transition: none; } }

/* the pixel details on /cat-tree (DESIGN_SYSTEM.md, Pixel page theme). Art is drawn on a grid at
   whole-number scales: SVG paths with crisp edges, or sprites with image-rendering: pixelated. */
/* the stage: rows of pixel units, the tree and cats on two canvases that clip at the page edge */
.px-stage { position: relative; width: 100%; height: calc(224 * var(--u)); margin-top: var(--space-24); overflow: hidden; }
.px-stage:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.px-stage-canvas { position: absolute; inset: 0; transition: transform var(--duration-quick) var(--ease), opacity var(--duration-quick) var(--ease); }
.px-stage-canvas.is-still { transition: none; }
.px-stage-canvas.is-left { opacity: 0; transform: translate3d(-100%, 0, 0); }
.px-stage-canvas.is-right { opacity: 0; transform: translate3d(100%, 0, 0); }
.px-stage-canvas.is-fade { opacity: 0; }
.px-tree-nav { position: absolute; top: 50%; z-index: 2; min-width: var(--tap-min); min-height: var(--tap-min); transform: translate3d(0, -50%, 0); }
.px-tree-nav .px-frame-fill { padding: 0; }
.px-tree-nav svg { width: calc(7 * var(--u)); height: calc(7 * var(--u)); }
.px-tree-nav:disabled { opacity: 0.3; cursor: default; }
.px-tree-prev { left: var(--space-8); }
.px-tree-next { right: var(--space-8); }
.px-tree-label { font-family: var(--font-tag); font-size: 16px; line-height: 16px; color: var(--ink); }
.px-layer { position: absolute; left: 0; top: 0; display: block; image-rendering: pixelated; }
.px-layer + .px-layer { pointer-events: none; }
.px-sprig { display: block; width: calc(19 * var(--u)); height: calc(20 * var(--u)); margin: 0 auto var(--space-16); }
.px-under { display: flex; flex-direction: column; align-items: center; gap: var(--space-12); padding: var(--space-16) var(--space-24) var(--space-48); }
.px-hint { display: inline-flex; align-items: center; gap: var(--space-8); margin-bottom: var(--space-16); white-space: nowrap; }
.px-hint svg { width: calc(13 * var(--u)); height: calc(5 * var(--u)); }
.px-cta { min-height: var(--space-48); cursor: pointer; }
.px-cta .px-frame-fill { padding: 0 var(--space-24); }
.px-cta svg { width: calc(7 * var(--u)); height: calc(7 * var(--u)); }
/* each head is a 14 × 13 image cut from the cat's sitting frame (cat-tree.js), one unit to a pixel */
.px-tally { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--head-gap); min-height: var(--tap-min); padding: 0 var(--space-8); border: 0; background: none; color: inherit; cursor: pointer; }
.px-tally:hover .ds-small, .px-tally:focus-visible .ds-small { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.px-tally .ds-small { margin-left: var(--space-4); }
.px-head { flex: none; width: calc(14 * var(--u)); height: calc(13 * var(--u)); background-size: 100% 100%; background-repeat: no-repeat; image-rendering: pixelated; }
.px-more { font-family: var(--font-tag); font-size: 16px; line-height: 16px; color: var(--ink); }
/* a small name tag: the Perch tag's box, laid out in a row */
.px-mine-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--space-8); min-width: 0; max-width: min(100%, 560px); }
.px-mine { --s: var(--u); --line: rgb(10, 10, 14); }
.px-mine .pg-tag-fill { flex-direction: row; align-items: center; gap: var(--space-8); padding: 0 0 0 var(--space-8); }
.px-mine-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-tag); font-size: 16px; line-height: 16px; color: var(--ink); }
.px-mine { min-width: 0; max-width: 100%; }
.px-mine-go { display: flex; align-items: center; gap: var(--space-8); min-width: 0; min-height: var(--tap-min); padding: 0; border: 0; background: none; cursor: pointer; }
.px-mine-edit { flex: none; display: flex; align-items: center; justify-content: center; width: var(--tap-min); height: var(--tap-min); padding: 0; border: 0; background: none; color: var(--ink); cursor: pointer; }
.px-mine-edit svg { width: calc(9 * var(--u)); height: calc(9 * var(--u)); }
.px-mine-edit:hover { background: var(--ink); color: var(--ink-inverse); }
.px-mine-edit:focus-visible { outline: 2px solid var(--ink); outline-offset: -4px; }
/* the pixel toast: "Name joined the tree", in the name tag's box */
.px-toast { --s: var(--u); --line: rgb(10, 10, 14); position: fixed; left: 50%; bottom: var(--space-24); z-index: 80; width: max-content; max-width: calc(100vw - var(--space-32)); pointer-events: none; opacity: 0; transform: translate3d(-50%, var(--space-16), 0); transition: opacity var(--duration-base) var(--ease), transform var(--duration-base) var(--ease); }
.px-toast.is-on { opacity: 1; transform: translate3d(-50%, 0, 0); }
.px-toast .pg-tag-fill { white-space: normal; }
.px-toast .ds-small { color: var(--ink); }
/* the share card, in the name tag's box, as a native dialog */
.px-card:focus { outline: none; }
.px-card { --s: var(--u); --line: rgb(10, 10, 14); padding: 0; border: 0; background: none; max-width: calc(100vw - var(--space-32)); max-height: calc(100dvh - var(--space-32)); }
.px-card::backdrop { background: rgba(18, 18, 18, 0.34); }
.px-card .pg-tag-fill { align-items: center; gap: var(--space-12); padding: var(--space-12); white-space: normal; }
.px-card-image { display: block; width: auto; height: auto; max-width: 100%; max-height: calc(100dvh - 148px); }
.px-card-row { display: flex; flex-wrap: wrap; gap: var(--space-8); }
.px-card .px-frame { min-height: var(--tap-min); text-decoration: none; color: var(--ink); }
.px-card .px-frame-fill { padding: 0 var(--space-16); }
/* the gallery: every cat as a head and name, in the name tag's box, as a native dialog */
.px-gallery { --s: var(--u); --line: rgb(10, 10, 14); width: min(100vw - var(--space-32), 560px); max-width: none; height: min(100dvh - var(--space-32), 640px); max-height: none; padding: 0; border: 0; background: none; }
.px-gallery:focus { outline: none; }
.px-gallery::backdrop { background: rgba(18, 18, 18, 0.34); }
.px-gallery .pg-tag-box { height: 100%; box-sizing: border-box; }
.px-gallery .pg-tag-fill { height: 100%; box-sizing: border-box; gap: var(--space-12); padding: var(--space-16); white-space: normal; }
.px-gallery .pg-input { flex: none; box-sizing: border-box; width: 100%; }
.px-gallery-top { display: flex; align-items: center; justify-content: space-between; }
.px-gallery-close { width: var(--tap-min); height: var(--tap-min); margin: calc(var(--space-8) * -1); }
.px-gallery-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); grid-auto-rows: max-content; gap: var(--space-4); }
.px-gallery-cat { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); min-width: 0; padding: var(--space-8) var(--space-4); border: 0; background: none; cursor: pointer; }
.px-gallery-cat:hover, .px-gallery-cat:focus-visible { background: var(--sunken); }
.px-gallery-name { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; color: var(--ink); }
/* saving a cat's link: one quiet line and a small text button, after placing, in in-app browsers and in the edit dialog */
.px-save { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--space-8); color: var(--ink-secondary); pointer-events: auto; }
.px-save-iab { justify-content: center; max-width: 420px; text-align: center; }
.px-text-btn { display: inline-flex; align-items: center; min-height: var(--tap-min); padding: 0; border: 0; background: none; color: var(--ink); cursor: pointer; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.px-text-btn:hover, .px-text-btn:focus-visible { color: var(--accent-text); text-decoration-thickness: 2px; }
.px-dialog-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 var(--space-24); margin-top: var(--space-4); }
@media (prefers-reduced-motion: reduce) { .px-toast { transition: none; } .px-stage-canvas { transition: opacity var(--duration-quick) linear; } }

/* the in-app browser notice, at the top of the Make your cat form */
.pg-iab { display: flex; align-items: flex-start; gap: var(--space-8); margin-bottom: var(--space-16); padding: var(--space-12); border: 1px solid var(--rule); border-radius: var(--radius-control); background: var(--sunken); }
.pg-iab .ds-small { flex: 1; color: var(--ink); }
.pg-iab .pg-toast-close { width: var(--tap-min); height: var(--tap-min); margin: calc(var(--space-8) * -1); }

/* back to top in the pixel frame: same 44px box, same place */
[data-theme="pixel"] [data-back-top] { padding: var(--s); border: 0 !important; border-radius: 0; background: none !important; -webkit-backdrop-filter: none; backdrop-filter: none; color: var(--ink) !important; }
[data-theme="pixel"] [data-back-top] .px-frame-fill { padding: 0; }
[data-theme="pixel"] [data-back-top] svg { width: calc(8 * var(--u)); height: calc(8 * var(--u)); }
[data-theme="pixel"] [data-back-top]:hover .px-frame-fill, [data-theme="pixel"] [data-back-top]:focus-visible .px-frame-fill { color: var(--ink-inverse); }
[data-theme="pixel"] [data-back-top][data-tone="dark"]::before { background: var(--page); }
/* the logo and text links keep their size; an invisible area brings the tap target to 44px */
[data-theme="pixel"] .nv-logo, [data-theme="pixel"] .nv-link, [data-theme="pixel"] footer#contact [data-ty-logo] { position: relative; }
[data-theme="pixel"] .nv-logo::after, [data-theme="pixel"] .nv-link::after, [data-theme="pixel"] footer#contact [data-ty-logo]::after { content: ''; position: absolute; left: 50%; top: 50%; width: max(100%, var(--tap-min)); height: max(100%, var(--tap-min)); transform: translate(-50%, -50%); }
