/*
 * Client Photo Galleries - client-facing styles.
 *
 * Scoped under .cpg so it cannot leak into the surrounding Breakdance page,
 * and built on its own custom properties so a theme's cascade cannot quietly
 * restyle a buy button. Inherits the page font deliberately: the gallery should
 * look like part of the site, not like a plugin bolted onto it.
 */

/* Every token defers to the site's own design system (--awp-*) and falls back
   to that system's current value. Two different jobs in one declaration:

   On a gallery page the Breakdance stylesheets are loaded, so the plugin
   inherits the site and keeps inheriting it when Alex retunes the brand - the
   accent moves here the moment it moves there, with nothing to sync.

   On the order page there is no Breakdance at all. maybe_render_order() emits
   a standalone document linking only this stylesheet, so --awp-* resolves to
   nothing and the fallbacks are what actually paint. That is why they are the
   real values rather than approximations: the page a client reaches from their
   download email has to look like the site it came from, unaided.

   There is deliberately no prefers-color-scheme block. This stylesheet used to
   carry one, and it was the only one on the page that did - the theme is
   unconditionally dark (#121212), so the light branch rendered #1d1d1f text
   onto a near-black page at 1.05:1 for every visitor whose phone was not in
   dark mode, which is most of them. Dark is not a theme here, it is the brand. */
.cpg {
	--cpg-ink: var(--awp-ink, #f2f2f2);
	--cpg-ink-soft: var(--awp-ink-soft, #b5b5b5);
	--cpg-ink-faint: var(--awp-ink-faint, #8a8a8a);
	--cpg-line: var(--awp-line, #2e2e2e);
	--cpg-line-strong: var(--awp-line-strong, #666666);
	--cpg-bg: var(--awp-bg, #121212);
	--cpg-raise: var(--awp-bg-accent, #1a1a1a);
	--cpg-deep: var(--awp-bg-deep, #242424);

	/* Amber is the site's action colour, so it buys photos here. */
	--cpg-accent: var(--awp-accent, #e8a33d);
	--cpg-accent-hover: var(--awp-accent-hover, #f2b55c);
	--cpg-accent-ink: var(--awp-accent-ink, #121212);

	--cpg-good: var(--awp-success, #9fd8a3);
	--cpg-good-bg: #15271a;

	/* The brand's action colour and the obvious warning hue are the same amber,
	   so these two cannot both be solid fills or a closing-soon notice competes
	   with the buy button. Action stays a solid amber control; a warning is an
	   amber-tinted panel. Same family, different form, no ambiguity. */
	--cpg-warn: var(--awp-accent-hover, #f2b55c);
	--cpg-warn-bg: var(--awp-accent-quiet, #3a2c14);

	--cpg-bad: var(--awp-danger, #f2b8b5);
	--cpg-bad-bg: #2d1718;

	--cpg-focus: var(--awp-focus-width, 2px);
	--cpg-focus-offset: var(--awp-focus-offset, 3px);

	--cpg-radius: 10px;
	--cpg-gap: 18px;

	/* Both overlays have to clear the theme's sticky header, which Breakdance
	   publishes at z-index 900. At 200 and 100 they did not: the header painted
	   over the lightbox bar and the checkout box, and - the part that actually
	   broke things - its nav links stayed clickable through both scrims. Hit
	   testing at the header band with the lightbox open returned a Breakdance
	   nav link, not the overlay. A client one tap from buying could leave the
	   page by pressing what looked like empty black.

	   Named here rather than written at each rule so the relationship between
	   the three is visible in one place, and so a theme that raises its header
	   again is a one-line change. */
	--cpg-z-cart: 20;
	--cpg-z-lightbox: 940;
	--cpg-z-modal: 960;

	box-sizing: border-box;
	color: var(--cpg-ink);
	max-width: 1320px;
	margin-inline: auto;

	/* Surfaces the browser draws, not us. Focus rings, underline offset and
	   tabular numerals were already handled; these were still system
	   defaults - a white caret in the code box and a stock grey scrollbar
	   down an otherwise authored dark page. Inherited, so the lightbox and
	   the checkout get them without being named. */
	accent-color: var(--cpg-accent);
	scrollbar-color: var(--cpg-line-strong) transparent;
	scrollbar-width: thin;
}

.cpg *,
.cpg *::before,
.cpg *::after {
	box-sizing: border-box;
}

/* A selected sentence used to come back in the browser default blue, which
   is the one colour on the page that belongs to no design system. Amber at
   a third strength reads as a highlight on #121212 without turning the
   selected words into something that looks pressable. Solid value first for
   anything that cannot do color-mix. */
.cpg::selection,
.cpg ::selection {
	background: #5a4420;
	background: color-mix(in srgb, var(--cpg-accent) 32%, transparent);
	color: var(--cpg-ink);
	text-shadow: none;
}

.cpg input,
.cpg textarea {
	caret-color: var(--cpg-accent);
}

/* ---------------------------------------------------------------- the gate */

.cpg-gate {
	display: flex;
	justify-content: center;
	padding: 48px 20px;
}

/* The card holds two forms - the code, and the way back in for a client who
   has lost it - so the card cannot be the form. Nested forms are invalid and
   the second one would silently submit the first. */
.cpg-gate__card {
	width: 100%;
	max-width: 380px;
	background: var(--cpg-raise);
	border: 1px solid var(--cpg-line);
	border-radius: var(--cpg-radius);
	padding: 28px;
}

.cpg-gate__heading {
	margin: 0 0 6px;
	font-size: 1.45rem;
	line-height: 1.2;
}

.cpg-gate__intro {
	margin: 0 0 20px;
	color: var(--cpg-ink-soft);
	line-height: 1.5;
}

.cpg-gate__label,
.cpg-field__label {
	display: block;
	margin-bottom: 6px;
	font-size: 0.82rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--cpg-ink-soft);
}

/* "Your name" is the first field in the checkout and was unmarked, so a
   first-timer assumes it is required - and it never has been. Saying so is
   cheaper than a client typing a name he did not want to give. */
.cpg-field__opt {
	font-weight: 400;
	letter-spacing: 0;
	text-transform: none;
	color: var(--cpg-ink-faint);
}

.cpg-gate__input,
.cpg-field input {
	width: 100%;
	padding: 12px 14px;
	font-size: 1rem;
	font-family: inherit;
	color: var(--cpg-ink);
	background: var(--cpg-bg);
	border: 1px solid var(--cpg-line);
	border-radius: 8px;
}

.cpg-gate__input {
	font-size: 1.3rem;
	letter-spacing: 0.22em;
	text-align: center;
	text-transform: uppercase;
}

.cpg-gate__input:focus-visible,
.cpg-field input:focus-visible {
	outline: 2px solid var(--cpg-accent);
	outline-offset: 1px;
}

.cpg-gate__card .cpg-btn {
	width: 100%;
	margin-top: 16px;
}

.cpg-gate__help {
	margin: 14px 0 0;
	font-size: 0.82rem;
	color: var(--cpg-ink-soft);
	text-align: center;
}

.cpg-gate__legal {
	margin: 20px 0 0;
	font-size: 0.78rem;
	line-height: 1.5;
	color: var(--cpg-ink-faint);
	text-align: center;
}

.cpg-gate__legal a {
	color: var(--cpg-ink-soft);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.cpg-gate__legal a:hover {
	color: var(--cpg-ink);
}

/* Lost code. Folded away by default: it is the second thing anyone needs, and
   a gate that leads with "can't find it?" reads like it expects to fail. */
.cpg-gate__lost {
	margin-top: 22px;
	padding-top: 18px;
	border-top: 1px solid var(--cpg-line);
}

.cpg-gate__lostsummary {
	cursor: pointer;
	font-size: 0.9rem;
	color: var(--cpg-ink-soft);
	text-align: center;
	list-style: none;
}

.cpg-gate__lostsummary::-webkit-details-marker {
	display: none;
}

.cpg-gate__lostsummary::after {
	content: " \203A";
}

.cpg-gate__lost[open] .cpg-gate__lostsummary {
	margin-bottom: 16px;
	color: var(--cpg-ink);
}

.cpg-gate__lostsummary:focus-visible {
	outline: 2px solid var(--cpg-accent);
	outline-offset: 2px;
	border-radius: 4px;
}

.cpg-gate__lostnote {
	margin: 0 0 16px;
	font-size: 0.9rem;
	line-height: 1.5;
	color: var(--cpg-ink-soft);
}

/* An address is read, not recited: none of the code box's tracking, caps or
   centring belongs on it. */
.cpg-gate__input--email {
	font-size: 1rem;
	letter-spacing: normal;
	text-align: left;
	text-transform: none;
}

/* ---------------------------------------------------------------- buttons */

.cpg-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 12px 20px;
	font: inherit;
	font-weight: 600;
	line-height: 1;
	border-radius: 8px;
	border: 1px solid transparent;
	cursor: pointer;
	transition: background-color 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.cpg-btn--primary {
	background: var(--cpg-accent);
	color: var(--cpg-accent-ink);
}

/* The site's own hover amber, not opacity. Fading a solid control toward a
   near-black page dulls it and drops its contrast at the moment the pointer
   is on it; the brand already defines the brighter step to go to instead. */
.cpg-btn--primary:hover:not(:disabled) {
	background: var(--cpg-accent-hover);
}

.cpg-btn--ghost {
	background: transparent;
	color: var(--cpg-ink);
	border-color: var(--cpg-line);
}

.cpg-btn--ghost:hover {
	background: var(--cpg-raise);
}

.cpg-btn:disabled {
	opacity: 0.5;
	cursor: default;
}

.cpg-btn:focus-visible {
	outline: 2px solid var(--cpg-accent);
	outline-offset: 2px;
}

/* ---------------------------------------------------------------- notes */

.cpg-note {
	margin: 0 0 16px;
	padding: 11px 14px;
	border-radius: 8px;
	background: var(--cpg-raise);
	color: var(--cpg-ink-soft);
	font-size: 0.92rem;
	line-height: 1.45;
}

.cpg-note--good { background: var(--cpg-good-bg); color: var(--cpg-good); }
.cpg-note--warn { background: var(--cpg-warn-bg); color: var(--cpg-warn); }
.cpg-note--bad  { background: var(--cpg-bad-bg);  color: var(--cpg-bad); }

/* An offer. The server sends this tone for the next-bundle nudge and the
   deposit credit, and it had no rule at all - so "2 more photos makes it any
   6 for $60", which is the best sentence in the product, rendered in the same
   neutral grey as "The photos are not up yet."

   Not given a hue, deliberately. Green already means a gain the client has
   banked and amber already means the gallery is closing; a third tint would
   be a fourth meaning in a palette with three. It earns its weight from
   surface and ink instead - a bordered panel one step up from the page, in
   full-strength text rather than the soft grey - which reads as something
   being held out rather than something being reported. */
.cpg-note--info {
	background: var(--cpg-deep);
	border: 1px solid var(--cpg-line-strong);
	color: var(--cpg-ink);
}

/* ---------------------------------------------------------------- header */

.cpg-head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 20px;
	padding-bottom: 16px;
	border-bottom: 1px solid var(--cpg-line);
}

.cpg-head__title {
	margin: 0 0 4px;
	font-size: 1.5rem;
	line-height: 1.2;
}

.cpg-head__sub {
	margin: 0;
	color: var(--cpg-ink-soft);
}

.cpg-head__forget {
	font-size: 0.86rem;
	color: var(--cpg-ink-soft);
}

.cpg-toolbar {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 16px;
}

.cpg-toolbar .cpg-btn {
	padding: 8px 14px;
	font-size: 0.88rem;
}

/* Start again throws away a selection that may have taken five minutes to
   build, with no confirm and no undo. It used to be an identical ghost button
   8px from Select everything - the same size, the same weight, the same
   colour, one thumb-width away from the control it is the opposite of.

   Pushed to the far end of the bar and demoted to text. Same 44px of height
   so it is no harder to hit on purpose, just much harder to hit by accident,
   and no longer dressed as the useful one. */
.cpg-toolbar__clear {
	margin-left: auto;
	padding: 8px 4px;
	min-height: 44px;
	font: inherit;
	font-size: 0.88rem;
	color: var(--cpg-ink-faint);
	background: none;
	border: 0;
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-color: var(--cpg-line-strong);
	cursor: pointer;
	transition: color 120ms ease;
}

.cpg-toolbar__clear:hover {
	color: var(--cpg-ink);
	text-decoration-color: currentColor;
}

.cpg-toolbar__clear:focus-visible {
	outline: var(--cpg-focus) solid var(--cpg-accent);
	outline-offset: var(--cpg-focus-offset);
	border-radius: 4px;
}

/* ---------------------------------------------------------------- the grid */

/* Justified rows, the layout every proofing gallery uses.

   Each tile is given a width proportional to its own aspect ratio, which
   means every tile that lands on the same row ends up exactly the same
   height - width / ratio is constant across the row. Nothing is cropped,
   rows are flush, and crucially the photos read left to right in order.
   CSS columns packed just as tightly but ran 1,5,9,2,6,10 down each
   column, which is no use to somebody picking frames.

   --cpg-row is the height rows aim for; flex stretches each row from
   there to fill the width exactly. */
.cpg-grid {
	/* Proofs are exported at 600px on the long edge. Rows aim low enough
	   that enough frames fit per row for none of them to be stretched past
	   their natural size - an upscaled proof looks soft, and the photo is
	   the thing being sold. */
	--cpg-row: 240px;

	display: flex;
	flex-wrap: wrap;
	gap: var(--cpg-gap);
	margin: 0 0 24px;
	padding: 0;
	list-style: none;
}

.cpg-tile {
	/* --cpg-ar is written onto each tile by the renderer from the real
	   stored dimensions, so there is no layout shift while images load. */
	flex: var(--cpg-ar, 1.5) 1 calc(var(--cpg-ar, 1.5) * var(--cpg-row));
	margin: 0;
	min-width: 0;

	/* The orphan problem, solved by a ceiling instead of an absorber.

	   There used to be a .cpg-grid::after with flex-grow: 1000000 here, to
	   stop two leftover frames stretching across the whole page. It worked on
	   an orphan row and was wrong on a full one: the absorber cannot tell the
	   difference, so it ate the slack either way and a last row with exactly
	   as many frames as the rows above it rendered 360x241 under four rows of
	   531x355 - 32% smaller, reading as a mistake rather than as a decision.
	   Measured at both 1280 and 1440, which cap to the same 1080 container.

	   A max-width lets every row grow the way the others do and only catches
	   the genuinely short one. The ceiling has to sit above every stretch a
	   normal row can reach, and that bound is known rather than guessed: with
	   N frames on a row the slack can never exceed one more frame's width, so
	   the stretch tops out just under (N+1)/N. Two per row is the fewest that
	   ever happens above the phone breakpoint, which puts the worst normal
	   case a shade under 1.5x.

	   1.7 clears that with room, and is still low enough to do its job: a lone
	   landscape at the end of a gallery stops at 612px instead of spanning the
	   page, which is within a couple of percent of the 600px the proofs are
	   exported at - so it is not upscaled into softness either, which is what
	   section 8.25 is about. Below 720px this is overridden outright; the
	   phone abandons justified rows and has its own composition rule. */
	max-width: calc(var(--cpg-ar, 1.5) * var(--cpg-row) * 1.7);
}

.cpg-tile__frame {
	display: block;
	position: relative;
	width: 100%;
	padding: 0;
	background: var(--cpg-raise);
	border: 2px solid transparent;
	border-radius: var(--cpg-radius);
	overflow: hidden;
	cursor: pointer;
	transition: border-color 120ms ease;
}

span.cpg-tile__frame {
	cursor: default;
}

.cpg-tile__img {
	display: block;
	width: 100%;
	height: auto;
	/* No forced ratio and no crop. A client choosing which photo to buy
	   has to see the whole frame, and a session mixes portrait and
	   landscape - cropping both to one box would cut the sides off every
	   landscape shot. A slightly ragged bottom edge is the cheaper price. */
}

/* Unpicked, the control floats over a photograph it does not own, so it stays
   white on a scrim and borrows no brand colour. Picked, it fills with the
   accent and the mark flips to the accent's own ink - the stroke is drawn in
   currentColor precisely so that one `color` change carries it. A white tick
   on amber measures about 1.9:1, which would hide the mark at the one moment
   it is confirming a purchase. */
.cpg-tile__tick {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 24px;
	height: 24px;
	color: #fff;
	border: 2px solid currentColor;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.35);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.cpg-tile__tick::after {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 10px;
	height: 5px;
	border-left: 2.5px solid currentColor;
	border-bottom: 2.5px solid currentColor;
	transform: translateY(-1px) rotate(-45deg);
	opacity: 0;
	transition: opacity 100ms ease;
}

.cpg-tile.is-picked .cpg-tile__frame {
	border-color: var(--cpg-accent);
}

.cpg-tile__tick[aria-pressed="true"] {
	color: var(--cpg-accent-ink);
	background: var(--cpg-accent);
	border-color: var(--cpg-accent);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.cpg-tile__tick[aria-pressed="true"]::after {
	opacity: 1;
}

.cpg-tile__frame:focus-visible {
	outline: 2px solid var(--cpg-accent);
	outline-offset: 2px;
}

.cpg-tile__badge {
	position: absolute;
	bottom: 8px;
	left: 8px;
	padding: 3px 8px;
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: #fff;
	background: rgba(0, 0, 0, 0.6);
	border-radius: 4px;
}

/* ---------------------------------------------------------------- the cart */

.cpg-cart {
	position: sticky;
	bottom: 0;
	z-index: var(--cpg-z-cart);
	margin-top: 8px;
	padding: 12px 0 16px;
	background: linear-gradient(to top, var(--cpg-bg) 65%, transparent);
}

/* Waiting on a price. The total is an en dash and Checkout cannot be pressed,
   because it had nothing behind it and returned in silence - a primary button
   that does nothing is indistinguishable from a broken site. The whole bar
   dims very slightly rather than the button alone: the number is the thing
   that is provisional, and dimming only the control would have read as the
   control being broken rather than the figure being unsettled. */
.cpg-cart.is-pricing .cpg-cart__total {
	color: var(--cpg-ink-faint);
}

.cpg-cart .cpg-btn--primary[disabled] {
	opacity: 0.55;
	cursor: default;
}

.cpg-cart__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 14px;
	padding: 14px 18px;
	background: var(--cpg-raise);
	border: 1px solid var(--cpg-line);
	border-radius: var(--cpg-radius);
	/* A 9%-black shadow was invisible against a near-black page, so the cart
	   had nothing holding it off the photographs it floats over. On a dark
	   canvas depth comes from a deeper cast plus a faint top rim catching
	   light, not from a darker edge nobody can see. */
	box-shadow:
		0 -1px 0 rgba(255, 255, 255, 0.06) inset,
		0 8px 28px rgba(0, 0, 0, 0.55);
}

.cpg-cart__sum {
	flex: 0 0 auto;
}

.cpg-cart__count {
	margin: 0;
	font-size: 0.84rem;
	color: var(--cpg-ink-soft);
}

.cpg-cart__total {
	margin: 2px 0 0;
	font-size: 1.5rem;
	font-weight: 700;
	line-height: 1.1;
	/* Proportional digits made the total jog sideways between $45 and $90 as
	   photos went on and off, which reads as the number being unsure of
	   itself. This is the one figure on the page that has to look settled. */
	font-variant-numeric: tabular-nums;
	/* Holds the line while the en dash placeholder is in it, so the bar does
	   not change height on the way to a price. */
	min-height: 1.1em;
}

.cpg-cart__msgs {
	flex: 1 1 220px;
	min-width: 0;
}

.cpg-cart__msgs .cpg-note {
	margin: 0 0 6px;
	padding: 7px 11px;
	font-size: 0.86rem;
}

.cpg-cart__msgs .cpg-note:last-child {
	margin-bottom: 0;
}

.cpg-cart__inner .cpg-btn--primary {
	flex: 0 0 auto;
	margin-left: auto;
}

/* ---------------------------------------------------------------- checkout */

.cpg-modal {
	position: fixed;
	inset: 0;
	z-index: var(--cpg-z-modal);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	/* 55% black over a #121212 page barely dims it, so the gallery stayed
	   fully legible behind the checkout and the modal did not read as modal. */
	background: rgba(0, 0, 0, 0.78);
	overflow-y: auto;
}

.cpg-modal[hidden] {
	display: none;
}

/* The site's surfaces step #121212 -> #1a1a1a -> #242424. The gate card and
   the cart sit on the middle step; the checkout opens above the cart, so it
   takes the top one. Using the page colour here left the dialog the same
   value as what it was covering. */
.cpg-modal__box {
	width: 100%;
	max-width: 440px;
	max-height: 100%;
	overflow-y: auto;
	padding: 26px;
	background: var(--cpg-deep);
	border: 1px solid var(--cpg-line);
	border-radius: var(--cpg-radius);
}

.cpg-modal__title {
	margin: 0 0 16px;
	font-size: 1.3rem;
}

.cpg-modal__lines {
	margin-bottom: 20px;
	padding-bottom: 14px;
	border-bottom: 1px solid var(--cpg-line);
}

.cpg-line {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	padding: 5px 0;
	font-size: 0.94rem;
}

.cpg-line--total {
	margin-top: 8px;
	padding-top: 10px;
	border-top: 1px solid var(--cpg-line);
	font-size: 1.1rem;
	font-weight: 700;
}

.cpg-line--credit {
	color: var(--cpg-good);
}

.cpg-field {
	display: block;
	margin-bottom: 14px;
}

.cpg-modal__delivery {
	margin: 0 0 10px;
	font-size: 0.86rem;
	line-height: 1.5;
	color: var(--cpg-ink-soft);
}

.cpg-modal__policy {
	margin: 0 0 16px;
	font-size: 0.82rem;
}

.cpg-modal__policy a {
	color: var(--cpg-ink-soft);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.cpg-modal__policy a:hover {
	color: var(--cpg-ink);
}

.cpg-modal__legal {
	margin: 0 0 16px;
	font-size: 0.78rem;
	line-height: 1.5;
	color: var(--cpg-ink-faint);
}

.cpg-modal__legal a {
	color: var(--cpg-ink-soft);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.cpg-modal__legal a:hover {
	color: var(--cpg-ink);
}

.cpg-modal__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: space-between;
}

.cpg-modal__actions .cpg-btn {
	flex: 1 1 auto;
}

/* ---------------------------------------------------------------- order page */

/* A standalone document - no theme, no Breakdance, only this file. It is also
   the page a client opens from their email, often as the first thing they see
   after paying, so it carries the brand on its own. Dark to match the site
   they just came from, and one scheme only: a client who followed a link out
   of a near-black gallery into a white page would think something broke.

   The canvas is a step darker than the card so the card reads as lifted
   without needing a shadow to say so. */
body.cpg-orderpage {
	margin: 0;
	padding: 0;
	background: var(--awp-bg-darkest, #0d0d0d);
	color: var(--awp-ink, #f2f2f2);
	font-family: var(--awp-font, "InterVariable", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
	line-height: var(--awp-lh-body, 1.6);
}

/* The order page's links were browser-default blue on near-black - 1.92:1,
   and the only navigation on the most important page in the product. The
   download button and per-photo link classes were styled; a bare <a> was not. */
.cpg-order a {
	color: var(--cpg-accent);
	text-underline-offset: 0.18em;
	text-decoration-thickness: from-font;
}

.cpg-order a:hover {
	color: var(--cpg-accent-hover);
}

.cpg-order a:focus-visible {
	outline: var(--cpg-focus) solid var(--cpg-accent);
	outline-offset: var(--cpg-focus-offset);
	border-radius: 2px;
}

.cpg-order {
	max-width: 560px;
	margin: 10vh auto;
	padding: 36px;
	background: var(--cpg-bg);
	border: 1px solid var(--cpg-line);
	border-radius: var(--cpg-radius);
}

/* The wordmark. Matches the site header's own treatment - 600 weight, the
   brand's tight tracking, the heading ink - rather than inventing a second
   lockup for a page nobody will see side by side with the first.

   Deliberately quiet and deliberately above the heading: it is a signature on
   the delivery, not a banner. It is also not an eyebrow for the h1 - it is a
   link to the site, sitting in its own band with a rule under it, which is why
   it carries a border and its own spacing rather than hugging the title. */
.cpg-order__brand {
	display: block;
	margin: 0 0 24px;
	padding-bottom: 18px;
	border-bottom: 1px solid var(--cpg-line);
	font-size: 0.95rem;
	font-weight: 600;
	letter-spacing: var(--awp-track-tight, -0.02em);
	line-height: 1.2;
}

/* Beats `.cpg-order a`, which paints every link on this page amber. The
   wordmark is a name, not an action, and amber here would compete with the
   download button that the whole page exists to deliver - the same specificity
   trap as section 8.35, handled the same way: element plus class, never
   !important. */
.cpg-order a.cpg-order__brand {
	color: var(--cpg-ink);
	text-decoration: none;
}

.cpg-order a.cpg-order__brand:hover {
	color: var(--cpg-accent);
}

.cpg-order__title {
	margin: 0 0 14px;
	font-size: 1.6rem;
	line-height: 1.2;
}

.cpg-order__lead {
	margin: 0 0 14px;
	font-size: 1.15rem;
	font-weight: 600;
}

.cpg-order p {
	margin: 0 0 14px;
}

.cpg-order__ref {
	margin-top: 22px;
	padding-top: 16px;
	border-top: 1px solid var(--cpg-line);
	font-size: 0.86rem;
	color: var(--cpg-ink-soft);
}

.cpg-order__ref code {
	font-size: 0.92em;
}

.cpg-order__back {
	margin: 0;
	font-size: 0.9rem;
}

/* ---------------------------------------------------------------- small screens */

@media (max-width: 1040px) {
	.cpg-grid {
		--cpg-row: 200px;
	}
}

@media (max-width: 720px) {
	/* On a phone the justified rows are abandoned entirely: a landscape gets
	   a row to itself, portraits go two to a row, and the two never mix.
	   Mixing them is what left the uneven holes down the right-hand side.

	   Rows are not height-matched here, so --cpg-row does not apply. */
	.cpg-grid {
		--cpg-gap: 12px;

		align-items: flex-start;
	}

	/* One rule, and no holes.
	
	     a landscape   basis 100%              -> always alone, full width
	     a portrait    basis 50% minus gutter  -> two share a row
	
	   Nothing can join a landscape, because its basis already fills the
	   line. Three portraits cannot fit either - 150% of the width. The
	   portrait's flex-grow is what keeps the layout solid: an odd one left
	   over at the end of a run stretches to the full width instead of
	   sitting at half width beside an empty space. Mixed rows were what
	   produced the ragged holes before. */
	.cpg-tile--wide {
		flex: 0 0 100%;
		max-width: 100%;
	}

	.cpg-tile--tall {
		flex: 1 1 calc(50% - (var(--cpg-gap) / 2));
		max-width: 100%;
	}

}

@media (max-width: 560px) {
	.cpg-grid {
		--cpg-gap: 10px;
	}

	.cpg-cart__inner {
		padding: 12px 14px;
	}

	.cpg-cart__inner .cpg-btn--primary {
		flex: 1 1 100%;
		margin-left: 0;
	}

	/* The cart reached 239px of a 695px viewport - 34% of the screen, over the
	   photographs it exists to sell - and it changed height on every single
	   tap: 180px, then 239px, then 199px as messages came and went. A thumb
	   reaching for a tick near the bottom of the screen was aiming at a
	   moving target.

	   Two causes, both here. It stacked every message the server sent, and it
	   had no floor, so it shrank as well as grew. One message at a time on a
	   phone - they arrive in priority order, so the first is the one worth
	   saying - and a reserved line for it either way.

	   Everything suppressed here is still said in the checkout breakdown,
	   which is a screen with room for it rather than a bar over the work. */
	.cpg-cart__msgs {
		flex: 1 1 100%;
		order: 3;
		min-height: 2.4em;
	}

	.cpg-cart__msgs .cpg-note:nth-child(n + 2) {
		display: none;
	}

	.cpg-order {
		margin: 0;
		border: 0;
		border-radius: 0;
		min-height: 100vh;
		padding: 28px 22px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cpg * {
		transition: none !important;
	}
}

/* ---------------------------------------------------------------- lightbox */

/* The tick is a sibling of the frame rather than a child, because a button
   cannot be nested inside another button. The tile anchors it. */
.cpg-tile {
	position: relative;
}

.cpg-tile__tick {
	z-index: 2;
	width: 30px;
	height: 30px;
	padding: 0;
	font: inherit;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color 120ms ease, transform 120ms ease;
}

/* The circle stays 30px, because it floats over somebody's photograph and a
   44px disc in the corner of a 240px frame covers the subject. The pressable
   area is 44px, which is what WCAG 2.5.5 is actually about: an invisible
   square centred on the circle, drawn as a pseudo-element so it extends past
   the button's own box without pushing the layout around.

   It reaches out and up, into the corner, rather than in over the frame -
   so the extra target lands on the tile's own padding and the gutter, not on
   the part of the photo a client is trying to look at. */
.cpg-tile__tick::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 44px;
	height: 44px;
	transform: translate(-50%, -50%);
}

.cpg-tile__tick:hover {
	transform: scale(1.08);
}

/* Covered by the charge without having been picked. This happens on a
   complete-set promotion: the client picked nine, the set price was the
   cheaper answer, so the tenth is hers too. It used to show as nothing at
   all - the cart said "all 10 photos" over a grid with nine ticks, which
   asks her to trust a total over her own eyes at the moment she pays it.

   Drawn as a hollow amber ring rather than a filled one, because it is a
   different fact from "I chose this": the fill means she picked it, the ring
   means the price reached it. Both mean she is getting it. */
.cpg-tile.is-included .cpg-tile__tick[aria-pressed="false"] {
	color: var(--cpg-accent);
	background: rgba(0, 0, 0, 0.5);
	border-color: var(--cpg-accent);
}

.cpg-tile.is-included .cpg-tile__tick[aria-pressed="false"]::after {
	opacity: 0.55;
}

.cpg-tile.is-included .cpg-tile__frame {
	border-color: color-mix(in srgb, var(--cpg-accent) 45%, transparent);
}

.cpg-tile__tick:focus-visible {
	outline: 2px solid var(--cpg-accent);
	outline-offset: 2px;
}

.cpg-lightbox {
	position: fixed;
	inset: 0;
	z-index: var(--cpg-z-lightbox);
	display: grid;
	grid-template-columns: auto 1fr auto;
	grid-template-rows: auto 1fr auto;
	align-items: center;
	background: rgba(0, 0, 0, 0.94);
	overscroll-behavior: contain;
}

.cpg-lightbox[hidden] {
	display: none;
}

.cpg-lightbox__bar {
	grid-column: 1 / -1;
	grid-row: 1;
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px 16px;
	color: #fff;
}

.cpg-lightbox__meta {
	display: flex;
	align-items: baseline;
	gap: 14px;
	margin: 0;
	min-width: 0;
}

.cpg-lightbox__count {
	font-size: 0.9rem;
	opacity: 0.75;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* What she has chosen and what it comes to, inside the overlay that hides the
   cart. Carries the accent because it is the only running total visible from
   here and it is the answer to the question somebody pressing Choose is
   actually asking. Tabular, for the same reason the cart's total is. */
.cpg-lightbox__running {
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--cpg-accent);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.cpg-lightbox__running:empty {
	display: none;
}

.cpg-lightbox__pick {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 9px;
	min-width: 210px;
	padding: 13px 24px;
	font: inherit;
	font-weight: 600;
	font-size: 1rem;
	color: #fff;
	background: rgba(255, 255, 255, 0.14);
	border: 1px solid rgba(255, 255, 255, 0.3);
	border-radius: 999px;
	cursor: pointer;
	transition: background-color 120ms ease;
}

.cpg-lightbox__pick:hover {
	background: rgba(255, 255, 255, 0.24);
}

.cpg-lightbox__pick[aria-pressed="true"] {
	color: var(--cpg-accent-ink);
	background: var(--cpg-accent);
	border-color: var(--cpg-accent);
}

.cpg-lightbox__tick {
	position: relative;
	width: 19px;
	height: 19px;
	border: 2px solid currentColor;
	border-radius: 50%;
	flex: 0 0 auto;
}

.cpg-lightbox__tick::after {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 9px;
	height: 4px;
	border-left: 2.5px solid currentColor;
	border-bottom: 2.5px solid currentColor;
	transform: translateY(-1px) rotate(-45deg);
	opacity: 0;
	transition: opacity 100ms ease;
}

.cpg-lightbox__pick[aria-pressed="true"] .cpg-lightbox__tick::after {
	opacity: 1;
}

/* 44px square, where it was 34x32. It is the control a one-handed thumb
   reaching for Choose used to hit by mistake, so it is now both easier to
   press deliberately and - because Choose moved to the bottom band - no
   longer anywhere near it. */
.cpg-lightbox__close {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	margin-left: auto;
	width: 44px;
	height: 44px;
	padding: 0;
	font: inherit;
	font-size: 2rem;
	line-height: 1;
	color: #fff;
	background: none;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	opacity: 0.8;
}

.cpg-lightbox__close:hover {
	opacity: 1;
}

.cpg-lightbox__stage {
	grid-column: 2;
	grid-row: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	min-height: 0;
	padding: 0 8px;
	/* Horizontal gestures belong to the gallery, not the browser. */
	touch-action: pan-y pinch-zoom;
}

.cpg-lightbox__img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
	transition: opacity 140ms ease;
}

.cpg-lightbox.is-swapping .cpg-lightbox__img {
	opacity: 0.25;
}

.cpg-lightbox__nav {
	grid-row: 2;
	width: 56px;
	height: 56px;
	padding: 0 0 4px;
	font: inherit;
	font-size: 2.4rem;
	line-height: 1;
	color: #fff;
	background: rgba(255, 255, 255, 0.1);
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	transition: background-color 120ms ease, opacity 120ms ease;
}

.cpg-lightbox__nav:hover {
	background: rgba(255, 255, 255, 0.22);
}

.cpg-lightbox__nav:disabled {
	opacity: 0.25;
	cursor: default;
}

.cpg-lightbox__nav--prev {
	grid-column: 1;
	margin-left: 12px;
}

.cpg-lightbox__nav--next {
	grid-column: 3;
	margin-right: 12px;
}

.cpg-lightbox__nav:focus-visible,
.cpg-lightbox__close:focus-visible,
.cpg-lightbox__pick:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.cpg-lightbox__foot {
	grid-column: 1 / -1;
	grid-row: 3;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 12px 16px 16px;
}

.cpg-lightbox__hint {
	margin: 0;
	font-size: 0.78rem;
	text-align: center;
	color: rgba(255, 255, 255, 0.5);
}

/* On a touch screen the arrows are redundant and eat into the photo, and the
   choose button wants to be a thumb-sized target at the bottom of the screen
   rather than tucked into a corner. */
/* Phones keep all three columns, but only for the bottom row: the photo gets
   the full width above, and the arrows sit either side of Choose where a thumb
   already is. They used to be hidden here in favour of swiping, which works
   but is invisible - and the one thing a parent does over and over is step to
   the next frame and take it. Swipe still works. */
@media (max-width: 720px) {
	.cpg-lightbox__bar,
	.cpg-lightbox__stage {
		grid-column: 1 / -1;
	}

	.cpg-lightbox__stage {
		padding: 0 6px;
	}

	.cpg-lightbox__nav {
		grid-row: 3;
		align-self: center;
		width: 46px;
		height: 46px;
		font-size: 1.9rem;
	}

	.cpg-lightbox__nav--prev {
		margin-left: 6px;
	}

	.cpg-lightbox__nav--next {
		margin-right: 6px;
	}

	.cpg-lightbox__foot {
		grid-column: 2;
		padding: 12px 6px 16px;
	}

	.cpg-lightbox__pick {
		width: 100%;
		min-width: 0;
		padding: 14px 16px;
	}

	/* The most reachable 46px of a phone screen was spent telling a touch
	   user to press arrow keys, which are display:none at this width. Swiping
	   is discoverable by trying it, the arrows are right there either side of
	   Choose, and that band belongs to the button. */
	.cpg-lightbox__hint {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cpg-lightbox__img,
	.cpg-tile__tick {
		transition: none;
	}
}

/* ---------------------------------------------------------------- downloads
   The paid order page. Lives inside .cpg-order, so it inherits the card and
   both colour schemes from the tokens above. */

.cpg-dl__all {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	margin: 0 0 18px;
}

.cpg-dl__button {
	display: inline-block;
	padding: 12px 20px;
	border-radius: 8px;
	background: var(--cpg-accent);
	color: var(--cpg-accent-ink);
	font-weight: 600;
	text-decoration: none;
}

.cpg-dl__button:hover {
	background: var(--cpg-accent-hover);
	color: var(--cpg-accent-ink);
}

/* Both of these exist to beat `.cpg-order a`, which paints every link on the
   page amber. This button's background is already amber, so that rule won on
   specificity - 0,1,1 against 0,1,0 - and painted the label invisible: amber
   text on an amber fill, on the single control the whole page exists for. It
   rendered as a blank yellow square that still downloaded the zip when
   clicked.

   The hover state was accidentally correct, because .cpg-dl__button:hover
   matches the same 0,1,1 as .cpg-order a:hover and comes later in the file.
   That is exactly why the symptom was "no text until the pointer is on it",
   and it is why specificity, not colour, was the thing to look at.

   Matched on element plus class rather than with !important, so a later
   variant of this button can still override it. */
.cpg-order a.cpg-dl__button,
.cpg-order a.cpg-dl__button:hover {
	color: var(--cpg-accent-ink);
}

.cpg-dl__button:focus-visible,
.cpg-dl__link:focus-visible {
	outline: 2px solid var(--cpg-accent);
	outline-offset: 2px;
}

.cpg-dl__size {
	color: var(--cpg-ink-soft);
	font-size: 0.88rem;
	white-space: nowrap;
}

.cpg-order .cpg-dl__note {
	padding: 10px 12px;
	border-radius: 8px;
	background: var(--cpg-warn-bg);
	color: var(--cpg-warn);
	font-size: 0.92rem;
}

.cpg-dl__list {
	margin: 0 0 14px;
	padding: 0;
	list-style: none;
	border-top: 1px solid var(--cpg-line);
}

.cpg-dl__item {
	display: grid;
	grid-template-columns: 56px 1fr auto auto;
	grid-template-areas: "thumb name size link";
	align-items: center;
	gap: 12px;
	padding: 10px 0;
	border-bottom: 1px solid var(--cpg-line);
}

.cpg-dl__thumb {
	grid-area: thumb;
	width: 56px;
	height: 42px;
	object-fit: cover;
	border-radius: 4px;
	display: block;
}

.cpg-dl__name {
	grid-area: name;
	min-width: 0;
	overflow-wrap: anywhere;
	font-size: 0.94rem;
}

.cpg-dl__size {
	grid-area: size;
}

.cpg-dl__free {
	color: var(--cpg-good);
	font-style: normal;
	font-size: 0.82rem;
}

.cpg-dl__link {
	grid-area: link;
	color: var(--cpg-accent);
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
}

.cpg-dl__link:hover {
	text-decoration: underline;
}

/* Narrow screens: the file size drops under the name rather than squeezing
   the Download link off the edge. */
@media (max-width: 520px) {
	.cpg-dl__item {
		grid-template-columns: 56px 1fr auto;
		grid-template-areas:
			"thumb name link"
			"thumb size link";
		gap: 4px 12px;
	}
}
