/* forms.css — owner track: C6. The special forms' own controls, starting with PAIRS (task C6.2): Polite against
   Showtime, tugging one cloth across the tray. It loads after ui.css, which still holds the Phase B stub's PAIRS rules,
   and overrides them here. It needs nothing from ui.css (C4's), only app.css's palette, so the tug looks the same
   whatever ui.css keeps. Cut paper, as ui.css has it: card stock with a hard offset shadow, hand-cut corners, ink
   lettering, key badges on the corners and a squish when pressed. Under html.reduced-motion nothing yanks, springs or
   squishes; under .e2e (app.css) nothing animates at all. */

/* — PAIRS: the beat's line over the tug, two halves with one cloth across them and its knot on the seam — */

/* --knot-w: the knot's width, which its track keeps clear of the tug's ends; --tug-h: a half's height. The gold and the
   pressed shadow are ui.css's own values, held here so that PAIRS reads none of ui.css's variables. */
.pairs {
  --knot-w: 28px;
  --tug-h: 108px;
  --pairs-gold-hi: #FFD866;
  --pairs-gold-lo: #C99A12;
  --pairs-press: 1px 1px 0 rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 9px;
  width: 100%;
  max-width: 440px;
}

.pairs-line {
  margin: 0;
  padding: 0 4px;
  color: var(--window-warm);
  font-size: 0.9375rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
}

.pairs-tug {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  container-type: inline-size;
}

/* A half: card stock with none of a button's own look, the word at the top, the cloth across it below that, and the
   rest a place for a thumb. Two thumbs hammer the two halves at once, which is just how a pinch starts, so a half is a
   hold origin under the gesture rule (touch-action: none, a ruling of the Phase C fix wave): manipulation, which every
   other element keeps (app.css), lets a slight spread zoom the page mid-finale and cancel the taps. */
.pairs-side {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  display: flex;
  justify-content: center;
  min-height: var(--tug-h);
  margin: 0;
  padding: 13px 8px 0;
  border: 0;
  font: inherit;
  cursor: pointer;
  box-shadow: var(--paper-shadow);
  touch-action: none;
  transition: transform 60ms ease-out, box-shadow 90ms ease-out;
}

/* Pressed, a half squishes down into its shadow. */
.pairs-side:active {
  transform: translate(2px, 2px) scale(0.97);
  box-shadow: var(--pairs-press);
}

.pairs-word {
  font: 800 min(1.375rem, 26px, 7cqi)/1 "Baloo 2", system-ui, sans-serif;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* POLITE: plain cream card stock, dotted like a good tablecloth, the word in plum. */
.pairs-side[data-side="POLITE"] {
  --yank: -1;
  border-radius: 16px 11px 15px 12px;
  background:
    radial-gradient(circle, rgba(91, 42, 94, 0.13) 0 1.6px, transparent 2.2px) 0 0 / 13px 13px,
    var(--cards);
  color: var(--plum);
}

/* SHOWTIME: her own accent, lit from below its word, with a ring of marquee bulbs inside its edge. The light centre
   sits under the half's foot, so the cream word stands on the accent itself (about 3:1, large and bold, with its ink
   shadow); behind the word it read at about 2.3:1. */
.pairs-side[data-side="SHOWTIME"] {
  --yank: 1;
  border-radius: 11px 16px 12px 15px;
  background: radial-gradient(ellipse 90% 70% at 50% 125%, #1BB8AE, var(--accent-star) 70%);
  color: var(--cards);
}

.pairs-side[data-side="SHOWTIME"]::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 3px dotted var(--window-warm);
  border-radius: 8px 12px 9px 11px;
  pointer-events: none;
}

.pairs-side[data-side="SHOWTIME"] .pairs-word {
  text-shadow: 2px 2px 0 rgba(43, 27, 47, 0.45);
}

/* The side ahead stands lit, and still squishes when pressed. */
.pairs[data-lead="POLITE"] .pairs-side[data-side="POLITE"],
.pairs[data-lead="SHOWTIME"] .pairs-side[data-side="SHOWTIME"] {
  box-shadow: var(--paper-shadow), 0 0 0 3px var(--window-warm);
}

.pairs[data-lead="POLITE"] .pairs-side[data-side="POLITE"]:active,
.pairs[data-lead="SHOWTIME"] .pairs-side[data-side="SHOWTIME"]:active {
  box-shadow: var(--pairs-press), 0 0 0 3px var(--window-warm);
}

/* Each tap yanks its half towards its own side; the attribute's new value restarts the yank. */
.pairs-side[data-yank="a"] {
  animation: pairs-yank-a 170ms ease-out;
}

.pairs-side[data-yank="b"] {
  animation: pairs-yank-b 170ms ease-out;
}

@keyframes pairs-yank-a {
  35% { transform: translateX(calc(var(--yank) * 5px)) rotate(calc(var(--yank) * -1.6deg)) scale(0.97); }
}

@keyframes pairs-yank-b {
  35% { transform: translateX(calc(var(--yank) * 5px)) rotate(calc(var(--yank) * -1.6deg)) scale(0.97); }
}

/* The key badges: Left on POLITE's outer corner, Right on SHOWTIME's, as the cloths and cards wear theirs. */
.pairs-key {
  position: absolute;
  top: -7px;
  z-index: 1;
  width: 24px;
  height: 24px;
  border: 2px solid var(--cards);
  border-radius: 50%;
  background: var(--ink);
}

.pairs-side[data-side="POLITE"] .pairs-key {
  left: -6px;
}

.pairs-side[data-side="SHOWTIME"] .pairs-key {
  right: -6px;
}

.pairs-key::before {
  content: "";
  position: absolute;
  inset: 5px 5px 5px 6px;
  background: var(--cards);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.pairs-side[data-side="POLITE"] .pairs-key::before {
  inset: 5px 6px 5px 5px;
  clip-path: polygon(100% 0, 0 50%, 100% 100%);
}

/* The cloth: a twisted plum cloth across both halves and on past their ends, drawn in a lane over the tug that takes no
   taps. Its knot travels a track that keeps it whole inside the tug; --pull (ui/pairs.js) puts the knot that many % of
   the track from its centre, and the cloth goes with it. */
.pairs-lane {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

/* The chalk line down the seam: the centre the knot must pass. */
.pairs-lane::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 50%;
  border-left: 2px dashed rgba(255, 246, 229, 0.5);
  transform: translateX(-1px);
}

.pairs-track {
  position: absolute;
  top: 61%;
  right: calc(var(--knot-w) / 2 + 8px);
  left: calc(var(--knot-w) / 2 + 8px);
  height: 0;
}

.pairs-cloth {
  position: absolute;
  inset: 0;
  transform: translateX(calc(var(--pull, 0) * 1%));
  transition: transform 150ms cubic-bezier(0.3, 1.6, 0.5, 1);
}

.pairs-cloth::before {
  content: "";
  position: absolute;
  top: -9px;
  right: -100%;
  left: -100%;
  height: 18px;
  border-top: 2px solid rgba(255, 246, 229, 0.28);
  background: repeating-linear-gradient(118deg, var(--plum) 0 9px, #73387A 9px 14px, var(--plum) 14px 16px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}

/* The knot: a gold ribbon tied round the cloth, its tails hanging below it as a pennant. */
.pairs-knot {
  position: absolute;
  top: -12px;
  left: calc(50% - var(--knot-w) / 2);
  width: var(--knot-w);
  height: 42px;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.35));
}

.pairs-knot::before {
  content: "";
  position: absolute;
  inset: 8px 2px 0;
  background: linear-gradient(var(--pairs-gold-hi), var(--tone-fabulous) 55%, var(--pairs-gold-lo));
  clip-path: polygon(10% 0, 90% 0, 90% 58%, 100% 100%, 50% 78%, 0 100%, 10% 58%);
}

.pairs-knot::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 50%;
  width: 22px;
  height: 20px;
  margin-left: -11px;
  border-radius: 48% 52% 50% 50%;
  background: radial-gradient(circle at 38% 32%, #FFE9A8, var(--tone-fabulous) 48%, var(--pairs-gold-lo));
  box-shadow: inset 0 -2px 0 rgba(43, 27, 47, 0.22);
}

/* A phone lying down keeps the tug lower, as app.css packs the rest of the column. */
@media (orientation: landscape) and (max-height: 500px) {
  .pairs {
    --tug-h: 80px;
    gap: 6px;
  }

  .pairs-side {
    padding-top: 9px;
  }

  .pairs-track {
    top: 56%;
  }

  .pairs-line {
    font-size: 0.875rem;
  }
}

html.reduced-motion .pairs-side[data-yank] {
  animation: none;
}

html.reduced-motion .pairs-side:active {
  transform: none;
}

html.reduced-motion .pairs-cloth {
  transition: none;
}
