/* 05 Use cases: eight questions, seven of them a real A/B pair the visitor can vote on.
 * Each pair is one print (cream paper, deep ink, thin lines; art in assets/pairs/, made by _build/pairs/make_pairs.py)
 * and only the judged quality changes between A and B, so the better side is clear in a second.
 * At rest the check sits on the side most people pick. A tap or click moves it to the visitor's pick, a "+1 vote"
 * chip rises, and the call above asks that card's question. Square corners throughout: 2 px at most, round only for
 * the check disc. Loaded after site.css; the behaviour is in pairs.js. */

.pcs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-sm); }

.pc { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto 1fr; padding: 14px 14px var(--space-lg); border-radius: 2px; background: var(--color-card); color: var(--color-ink); box-shadow: 0 22px 40px -28px oklch(8% 0.08 268 / 0.95); transition: box-shadow var(--dur-short) var(--ease-out); }
.pc.is-asked { box-shadow: 0 0 0 2px var(--ink-lilac-hex), 0 22px 40px -28px oklch(8% 0.08 268 / 0.95); }

/* The pair: two buttons side by side. The check disc and the "+1 vote" chip are one element each per pair; they move. */
.pc__pair { --gap: 8px; position: relative; grid-row: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); }
.pc__opt { position: relative; display: block; width: 100%; min-width: 44px; min-height: 44px; margin: 0; padding: 0; aspect-ratio: 4 / 3; border: 0; border-radius: 0; background: var(--ink-sheet); color: inherit; cursor: default; -webkit-tap-highlight-color: transparent; }
.js .pc__opt { cursor: pointer; }
.pc__opt img, .pc__opt .tone { position: absolute; inset: 0; width: 100%; height: 100%; }
.pc__opt img { display: block; object-fit: cover; }
/* the frame of each print sits over the art: a hairline at rest, the brand blue when it is the pick */
.pc__opt::before { content: ""; position: absolute; inset: 0; z-index: 1; box-shadow: inset 0 0 0 1px var(--color-rule-strong); pointer-events: none; transition: box-shadow var(--dur-short) var(--ease-out); }
.pc__opt.is-on::before { box-shadow: inset 0 0 0 2.5px var(--ink-blue); }
.pc__opt:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; }
@media (hover: hover) {
  .js .pc__opt:hover::before { box-shadow: inset 0 0 0 1.5px var(--ink-blue); }
  .js .pc__opt.is-on:hover::before { box-shadow: inset 0 0 0 2.5px var(--ink-blue); }
}
.js .pc__opt:active { transform: scale(0.97); }
/* after a pick of the weaker side, the side most people pick is shown, quietly: a dashed frame */
.pc__opt.is-hint::before { box-shadow: none; outline: 1.5px dashed var(--ink-blue); outline-offset: -1.5px; }

/* The check: a disc on the top right corner of the chosen print. It slides across when the pick changes. */
.pc__check { position: absolute; z-index: 2; top: -9px; left: calc(50% - var(--gap) / 2 - 13px); width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--color-card); background: var(--ink-blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.2 8.4l2.4 2.4 5.2-5.4' fill='none' stroke='%23F2F2EE' stroke-width='2' stroke-linecap='square'/%3E%3C/svg%3E") center / 14px no-repeat; pointer-events: none; transition: left var(--dur-long) var(--ease-out); }
.pc__pair[data-pick="b"] .pc__check { left: calc(100% - 13px); }
.pc__check.is-pop { animation: pc-pop 420ms var(--ease-out); }
@keyframes pc-pop { 0% { transform: scale(1); } 35% { transform: scale(1.32) translateY(-3px); } 100% { transform: scale(1); } }

/* "+1 vote": a small square chip that rises from the pick and fades */
.pc__plus { position: absolute; z-index: 3; top: 38%; left: 25%; padding: 4px 7px 3px; border-radius: 2px; background: var(--ink-blue); color: var(--ink-paper); font: 500 0.75rem/1 var(--font-outlier); letter-spacing: 0.02em; white-space: nowrap; pointer-events: none; opacity: 0; transform: translate(-50%, 0); }
.pc__pair[data-pick="b"] .pc__plus { left: 75%; }
.pc__plus.is-go { animation: pc-rise 1100ms var(--ease-out) both; }
@keyframes pc-rise { 0% { opacity: 0; transform: translate(-50%, 8px); } 18% { opacity: 1; transform: translate(-50%, 0); } 70% { opacity: 1; transform: translate(-50%, -14px); } 100% { opacity: 0; transform: translate(-50%, -22px); } }

/* The line under the pair: empty at rest (it keeps the old space), it answers after a vote. */
/* Its height is kept at rest, so a vote never moves the cards (two lines where four narrow columns make it wrap). */
.band .pc__say { --say-lines: 1; grid-row: 2; display: flex; align-items: flex-start; gap: 7px; min-height: calc(var(--say-lines) * 1.3em); margin: 9px 0 8px; max-width: none; font: 500 0.75rem/1.3 var(--font-outlier); letter-spacing: 0.01em; color: var(--ink-blue); opacity: 0; transform: translateY(-3px); transition: opacity var(--dur-short) var(--ease-out), transform var(--dur-short) var(--ease-out); }
.pc.is-voted .pc__say { opacity: 1; transform: none; }
.band .pc.is-off .pc__say { color: var(--color-muted); }
.pc__say::before { content: ""; flex: none; width: 7px; height: 7px; margin-top: 0.3em; background: currentColor; }

.band .pc__k { grid-row: 3; margin: 0; max-width: none; font: 500 var(--text-label)/1.2 var(--font-outlier); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--color-muted); }
.band .pc__q { grid-row: 4; margin: 6px 0 0; font-family: var(--font-display); font-size: 1.5625rem; font-variation-settings: "opsz" 36; line-height: 1.14; letter-spacing: -0.01em; color: var(--color-ink); max-width: 15ch; }

/* Writing tone: the two replies are real text in the page's own faces, in a square chat slip. */
.pc__opt .tone { display: flex; align-items: center; justify-content: center; padding: 7% 7% 12%; container-type: inline-size; background: var(--ink-sheet); text-align: left; }
.tone__slip { position: relative; display: block; margin: 0; width: 100%; padding: 6cqw 6.5cqw; border: 1px solid var(--ink-deep); background: #FFFCF5; color: var(--ink-deep); }
/* the slip's tail: a sharp V notch (a square turned 45 degrees; its top half covers the slip's own edge) */
.tone__slip::after { content: ""; position: absolute; left: 10cqw; bottom: calc(-3cqw - 0.5px); width: 6cqw; height: 6cqw; background: #FFFCF5; border-right: 1px solid var(--ink-deep); border-bottom: 1px solid var(--ink-deep); transform: rotate(45deg); }
.tone__slip--warm { font: 500 11.2cqw/1.16 var(--font-body); letter-spacing: -0.01em; }
.tone__slip--cold { font: 400 8.6cqw/1.28 var(--font-outlier); letter-spacing: 0.01em; text-transform: uppercase; }

/* The eighth card: the visitor's own question. */
.pc--yours { background: transparent; color: var(--ink-paper); box-shadow: inset 0 0 0 1px var(--color-rule-strong); }
.pc--yours:hover { box-shadow: inset 0 0 0 1px var(--ink-lilac-hex); }
.pc__yours { grid-row: 1; display: flex; align-items: center; justify-content: center; aspect-ratio: 8 / 3; border: 1px dashed var(--ink-lilac-hex); }
.pc__yours code { font-size: var(--text-md); color: var(--ink-paper); }
.pc__yours .pc__caret { display: inline-block; width: 2px; height: 1.1em; margin: 0 2px; vertical-align: -0.2em; background: var(--ink-lilac-hex); animation: caret 1.1s steps(1) infinite; }
.pc--yours .pc__gap { --say-lines: 1; grid-row: 2; height: calc(var(--say-lines) * 1.3 * 0.75rem + 17px); }
.uses .pc--yours .pc__k { color: var(--ink-mist); }
.uses .pc--yours .pc__q { color: var(--ink-lilac-hex); }
.pc__link { position: absolute; inset: 0; z-index: 2; }
.pc__link:focus-visible { outline: 2px solid var(--ink-lilac-hex); outline-offset: 3px; }

/* Four narrow columns: the prints get the room the padding gave up, and the answer may take two lines. */
@media (min-width: 52.01rem) and (max-width: 73.75rem) {
  .pc { padding: 10px 10px var(--space-md); }
  .pc__pair { --gap: 6px; }
  .band .pc__say, .pc--yours .pc__gap { --say-lines: 2; }
}
@media (max-width: 64rem) {
  .band .pc__q { font-size: 1.375rem; }
}
@media (max-width: 52rem) {
  .pcs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Phones: one row per question, as before, but the prints are big enough to see and to tap (88 x 66 each). The answer
 * line takes the kicker's place after a vote. */
@media (max-width: 40rem) {
  .pcs { grid-template-columns: minmax(0, 1fr); gap: 0; border-top: var(--rule-hair) solid oklch(40% 0.17 267); }
  /* the first text row keeps two lines for the answer, so a vote never moves the rows below */
  .pc { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: minmax(calc(2 * 1.25 * 0.6875rem), auto) auto; column-gap: 14px; row-gap: 2px; align-items: center; padding: 10px 0; border-radius: 0; background: transparent; color: var(--ink-paper); box-shadow: none; border-bottom: var(--rule-hair) solid oklch(40% 0.17 267); }
  .pc.is-asked { box-shadow: none; }
  .pc.is-asked .pc__q { color: var(--ink-lilac-hex); }
  .pc__pair { --gap: 6px; grid-row: 1 / span 2; grid-column: 1; grid-template-columns: 88px 88px; }
  .pc__opt::before { box-shadow: inset 0 0 0 1px oklch(70% 0.06 270); }
  .pc__opt.is-on::before { box-shadow: inset 0 0 0 2.5px var(--ink-lilac-hex); }
  .pc__opt.is-hint::before { outline-color: var(--ink-lilac-hex); }
  .pc__check { top: -7px; width: 22px; height: 22px; left: calc(50% - var(--gap) / 2 - 11px); border-color: var(--ink-deep); background-size: 12px; }
  .pc__pair[data-pick="b"] .pc__check { left: calc(100% - 11px); }
  .pc__plus { font-size: 0.6875rem; }
  .band .pc__k, .band .pc__say { grid-column: 2; grid-row: 1; align-self: end; margin: 0; }
  .band .pc__k { font-size: 0.6875rem; letter-spacing: 0.04em; color: var(--ink-mist); transition: opacity var(--dur-short) var(--ease-out); }
  .pc.is-voted .pc__k { opacity: 0; }
  .band .pc__say { min-height: 0; font-size: 0.6875rem; line-height: 1.25; color: var(--ink-lilac-hex); }
  .band .pc.is-off .pc__say { color: var(--ink-mist); }
  .pc__say::before { width: 6px; height: 6px; }
  .band .pc__q { grid-column: 2; grid-row: 2; align-self: start; margin: 0; max-width: none; font-size: 1rem; color: var(--ink-paper); }
  .pc--yours { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pc, .pc__opt::before, .pc__check, .pc__say, .pc__k { transition: none; }
  .js .pc__opt:active { transform: none; }
  .pc__check.is-pop, .pc__yours .pc__caret { animation: none; }
  /* the chip still says "+1 vote", it just holds still and fades */
  .pc__plus.is-go { animation: pc-blink 1400ms linear both; }
  @keyframes pc-blink { 0%, 80% { opacity: 1; transform: translate(-50%, -6px); } 100% { opacity: 0; transform: translate(-50%, -6px); } }
}
