/* Name swipe with partner match, /puppy-names#swipe. Loaded on that page only.
 * Tokens come from styles.css, so light and dark both follow. */

.sw { display: none; }
.js .sw {
  display: grid; grid-template-columns: minmax(0, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 0.9rem 0.9rem 1rem; margin: 0 0 2rem;
  scroll-margin-top: 76px;
}
.sw-ic { width: 18px; height: 18px; flex: none; }
.sw-ic-lg { width: 26px; height: 26px; }

.sw-head h2 { margin: 0; font-size: 1.25rem; }
.sw-head h2:focus { outline: none; }
.sw-sub { margin: 0.2rem 0 0.75rem; color: var(--ink-soft); font-size: 0.9rem; line-height: 1.45; }

/* Partner banner */
.sw-partner {
  background: var(--brand-soft); border: 1px solid var(--brand-line); border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem; margin: 0 0 0.8rem; font-size: 0.93rem;
}
.sw-partner-msg { margin: 0 0 0.55rem; }
.sw-partner-mode { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* Deck summary and filters */
.sw-deck { margin: 0 0 0.9rem; }
.sw-deck > summary {
  display: flex; align-items: center; gap: 0.65rem; list-style: none; cursor: pointer;
  background: var(--surface-alt); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem; min-height: 48px; color: var(--ink);
}
.sw-deck > summary::-webkit-details-marker { display: none; }
.sw-deck > summary:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.sw-deck > summary .sw-ic { color: var(--brand-ink); }
.sw-deck-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.3; }
.sw-deck-label { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-deck-left { font-size: 0.82rem; color: var(--ink-soft); }
.sw-deck-change { font-size: 0.86rem; font-weight: 650; color: var(--brand-ink); text-decoration: underline; text-underline-offset: 2px; }
.sw-deck[open] .sw-deck-change { visibility: hidden; }
.sw-filters { padding: 0.4rem 0.1rem 0; }
.sw-group { border: 0; padding: 0; margin: 0.7rem 0 0; min-width: 0; }
.sw-group[hidden] { display: none; }
.sw-group legend { font-size: 0.8rem; font-weight: 650; color: var(--ink-soft); padding: 0; margin-bottom: 0.35rem; }
.sw-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.sw-chip { position: relative; display: inline-flex; }
.sw-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.sw-chip span {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0.3rem 0.75rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface);
  color: var(--ink-soft); font-size: 0.86rem; font-weight: 600; cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.sw-chip span:hover { border-color: var(--brand); color: var(--brand-ink); }
.sw-chip input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.sw-chip input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }
.sw-chip-letter span { min-width: 36px; justify-content: center; padding: 0.3rem 0.4rem; }
.sw-list-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.sw-list-row[hidden] { display: none; }
.sw-filter-foot { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.9rem 0 0.2rem; }

/* The card stack */
.sw-play { min-width: 0; }
.sw-stage { position: relative; height: 250px; margin: 0 auto; max-width: 26rem; }
@media (min-height: 760px) and (min-width: 380px) { .sw-stage { height: 262px; } }
.sw-card {
  position: absolute; inset: 0; margin: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 2.4rem 1.2rem 1.4rem;
  background: var(--surface);
  background-image: radial-gradient(120% 70% at 50% 120%, var(--brand-soft) 0%, transparent 70%);
  border: 1px solid var(--line-strong); border-radius: 22px; box-shadow: var(--shadow);
  touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: grab;
  transition: transform var(--dur-2) cubic-bezier(0.2, 0.7, 0.2, 1);
  will-change: transform;
  --keep: 0; --pass: 0;
}
.sw-card[hidden] { display: none; }
.sw-card:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
.sw-card.sw-dragging { transition: none; cursor: grabbing; }
.sw-card.sw-fling { transition: transform 260ms cubic-bezier(0.4, 0, 0.6, 1); }
.sw-card-back {
  transform: translateY(12px) scale(0.94); opacity: 0.75; box-shadow: var(--shadow-sm);
  pointer-events: none; cursor: default;
}
.sw-card-back .sw-name { opacity: 0.35; transition: opacity 200ms; }
.sw-card-back.is-next .sw-name { opacity: 1; }
.sw-name {
  font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em;
  font-size: clamp(2.3rem, 10.5vw, 3.3rem); line-height: 1.05; margin: 0; color: var(--ink);
  overflow-wrap: anywhere;
}
.sw-meaning { margin: 0.65rem 0 0; color: var(--ink-soft); font-size: 1rem; max-width: 30ch; line-height: 1.4; }
.sw-meaning:empty { display: none; }
.sw-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3rem; margin: 0.9rem 0 0; }
.sw-tags span {
  font-size: 0.78rem; font-weight: 600; color: var(--ink-soft);
  background: var(--surface-alt); border: 1px solid var(--line); border-radius: var(--radius-pill);
  padding: 0.12rem 0.55rem;
}
.sw-count { position: absolute; top: 0.85rem; left: 0; right: 0; margin: 0; font-size: 0.8rem; color: var(--ink-soft); }
.sw-count[hidden] { display: none; }
/* Why a card was suggested, where the count sits on other cards. */
.sw-why {
  position: absolute; top: 0.7rem; left: 50%; transform: translateX(-50%); margin: 0;
  max-width: calc(100% - 1.6rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 0.14rem 0.65rem; border-radius: var(--radius-pill);
  background: var(--brand-soft); border: 1px solid var(--brand-line); color: var(--brand-ink);
  font-size: 0.78rem; font-weight: 650;
}
.sw-why[hidden] { display: none; }
.sw-why.sw-why-explore { background: var(--surface-alt); border-color: var(--line); color: var(--ink-soft); }
/* The first visit hint above the card. */
.sw-hint {
  display: flex; align-items: center; gap: 0.6rem;
  max-width: 26rem; margin: 0 auto 0.7rem; padding: 0.45rem 0.5rem 0.45rem 0.75rem;
  background: var(--brand-soft); border: 1px solid var(--brand-line); border-radius: var(--radius-sm);
  color: var(--ink); font-size: 0.84rem; line-height: 1.4;
}
.sw-hint[hidden] { display: none; }
.sw-hint-text { margin: 0; flex: 1 1 auto; min-width: 0; }
.sw-hint .btn { flex: none; }
.sw-stamp { z-index: 1; }
.sw-stamp {
  position: absolute; top: 1.4rem; padding: 0.15rem 0.6rem; border: 3px solid; border-radius: 9px;
  font-weight: 800; font-size: 1.15rem; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--surface); pointer-events: none;
}
.sw-stamp-keep { left: 1rem; color: var(--brand-ink); border-color: var(--brand); transform: rotate(-12deg); opacity: var(--keep); }
.sw-stamp-pass { right: 1rem; color: var(--danger); border-color: var(--danger); transform: rotate(12deg); opacity: var(--pass); }

.sw-pop {
  position: absolute; z-index: 2; left: 50%; bottom: 0.9rem; transform: translateX(-50%);
  margin: 0; padding: 0.35rem 0.85rem; border-radius: var(--radius-pill);
  background: var(--brand); color: var(--on-brand); font-weight: 750; font-size: 0.9rem; white-space: nowrap;
  box-shadow: var(--shadow); pointer-events: none;
}
.sw-pop[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .sw-pop.is-on { animation: sw-pop 2.6s var(--ease) both; }
}
@keyframes sw-pop {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.92); }
  10%, 80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -4px); }
}
.sw-drawer-status {
  margin: 0 0 0.6rem; padding: 0.55rem 0.75rem; border-radius: var(--radius-xs);
  background: var(--brand-soft); border: 1px solid var(--brand-line); color: var(--ink); font-size: 0.9rem;
}
.sw-drawer-status[hidden] { display: none; }
.sw-done {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 1.2rem; border: 1px dashed var(--line-strong); border-radius: 22px; background: var(--surface-alt);
}
.sw-done[hidden] { display: none; }
.sw-done-title { font-family: var(--font-display); font-weight: 750; font-size: 1.25rem; margin: 0 0 0.35rem; }
.sw-done-btns { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-top: 0.8rem; }

/* Pass, undo, keep */
.sw-actions { display: flex; justify-content: center; align-items: flex-end; gap: 1.6rem; margin: 1.1rem 0 0.2rem; }
.sw-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  background: none; border: 0; padding: 0; cursor: pointer;
  font-size: 0.82rem; font-weight: 650; color: var(--ink-soft);
}
.sw-btn svg {
  box-sizing: content-box; width: 26px; height: 26px; padding: 18px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line-strong); box-shadow: var(--shadow-sm);
  transition: transform var(--dur-1) var(--ease), background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.sw-btn-pass svg { color: var(--danger); border-color: var(--danger); }
.sw-btn-keep svg { color: var(--on-brand); background: var(--brand); border-color: var(--brand); fill: currentColor; }
.sw-btn-undo svg { width: 18px; height: 18px; padding: 12px; color: var(--ink-soft); }
.sw-btn:hover:not(:disabled) svg { transform: translateY(-2px); }
.sw-btn-pass:hover:not(:disabled) svg { background: var(--danger-soft); }
.sw-btn-keep:hover:not(:disabled) svg { background: var(--brand-strong); border-color: var(--brand-strong); }
.sw-btn:focus-visible { outline: none; }
.sw-btn:focus-visible svg { outline: 3px solid var(--brand); outline-offset: 3px; }
.sw-btn:disabled { cursor: default; opacity: 0.45; }
.sw-help { text-align: center; font-size: 0.82rem; color: var(--ink-soft); margin: 0.5rem auto 0.9rem; max-width: 26rem; }
@media (hover: none) { .sw-help-keys { display: none; } }

.sw-bar { display: flex; gap: 0.6rem; max-width: 26rem; margin: 0 auto; }
.sw-bar .btn { flex: 1 1 0; padding-left: 0.6rem; padding-right: 0.6rem; gap: 0.4rem; white-space: nowrap; }
.sw-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.5rem; height: 1.5rem;
  padding: 0 0.4rem; border-radius: var(--radius-pill); background: var(--brand-soft); color: var(--brand-ink);
  font-size: 0.8rem; font-weight: 750;
}

/* Names you both liked */
.sw-matches {
  margin: 1.1rem 0 0; padding: 0.9rem 1rem; border: 1px solid var(--brand-line); border-radius: var(--radius-sm);
  background: var(--surface);
}
.sw-matches[hidden] { display: none; }
.sw-matches-h { margin: 0; font-size: 1.1rem; }
.sw-matches-h + p { margin: 0.25rem 0 0.6rem; }
.sw-match-list { list-style: none; padding: 0; margin: 0 0 0.8rem; display: grid; gap: 0.35rem; }
.sw-match-list li { padding: 0.45rem 0.65rem; background: var(--brand-soft); border-radius: var(--radius-xs); }
.sw-match-list li span { display: block; color: var(--ink-soft); font-size: 0.88rem; line-height: 1.35; }
.sw-matches-foot { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }

/* Share card preview, the same words the share kit draws on the image */
/* The same frame PuplrShare.card() draws: a white sticker panel with a navy
 * outline on a biscuit ground. Fixed light colours in dark mode too, because
 * the image it previews is always light. */
.sw-share-card {
  background: #ffffff; color: var(--navy); border: 2.5px solid var(--navy); border-radius: 16px; padding: 1.1rem 1.15rem 0.9rem;
  max-width: 22rem; box-shadow: 0 0 0 10px var(--biscuit); margin: 10px;
}
.sw-share-card[hidden] { display: none; }
.scp-brand { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 0.9rem; letter-spacing: 0.02em; }
.scp-title { margin: 0.35rem 0 0.6rem; font-family: var(--font-display); font-weight: 800; font-size: 1.45rem; line-height: 1.15; }
.scp-lines { list-style: none; margin: 0 0 0.7rem; padding: 0; display: grid; gap: 0.3rem; font-size: 0.92rem; }
.scp-lines span { font-weight: 400; }
.scp-foot { margin: 0; font-size: 0.8rem; font-weight: 600; border-top: 1px solid currentColor; padding-top: 0.5rem; }
.sw-share-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.7rem 0 0; }
.sw-share-row:empty { display: none; }

/* The shortlist drawer: a bottom sheet on phones, a side panel on wide screens */
html.sw-locked { overflow: hidden; }
dialog.sw-drawer {
  position: fixed; inset: auto 0 0 0; margin: 0; padding: 0; border: 0;
  width: 100%; max-width: 100%; max-height: 88vh; max-height: 88dvh;
  background: var(--surface); color: var(--ink); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
}
dialog.sw-drawer::backdrop { background: rgba(29, 31, 75, 0.5); }
.sw-drawer-in { display: flex; flex-direction: column; max-height: inherit; }
.sw-drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.9rem 1rem 0.7rem; border-bottom: 1px solid var(--line);
}
.sw-drawer-head h2 { margin: 0; font-size: 1.2rem; }
.sw-close {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--ink-soft); border-radius: var(--radius-xs); cursor: pointer;
}
.sw-close:hover { background: var(--surface-alt); color: var(--ink); }
.sw-drawer-body { overflow-y: auto; padding: 0.8rem 1rem 1.4rem; overscroll-behavior: contain; }
.sw-drawer-body > p:first-child { margin-top: 0; }
.sw-empty { padding: 1rem; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--ink-soft); background: var(--surface-alt); }
.sw-empty[hidden] { display: none; }
.sw-empty::before {
  content: ""; display: block; width: 56px; height: 54px; margin: 0 auto 0.4rem;
  background: url("/art/pip-happy.svg") center / contain no-repeat;
}
.sw-list { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.4rem; }
.sw-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.2rem 0.6rem; align-items: center;
  padding: 0.55rem 0.6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.sw-item.is-chosen { border-color: var(--brand); background: var(--brand-soft); }
.sw-item-n {
  width: 1.7rem; height: 1.7rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-alt); color: var(--ink-soft); font-size: 0.8rem; font-weight: 700; align-self: start;
}
.sw-item-txt { min-width: 0; }
.sw-item-txt strong { font-size: 1.05rem; }
.sw-item-m { display: block; color: var(--ink-soft); font-size: 0.85rem; line-height: 1.35; }
.sw-chosen-tag {
  font-size: 0.72rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--on-brand); background: var(--brand); border-radius: var(--radius-pill); padding: 0.05rem 0.45rem; vertical-align: 2px;
}
.sw-item-btns { grid-column: 2; display: flex; gap: 0.3rem; flex-wrap: wrap; }
.sw-mini {
  min-width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: var(--radius-xs); cursor: pointer;
  font-size: 0.85rem; font-weight: 650;
}
.sw-mini svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sw-mini:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-ink); background: var(--brand-soft); }
.sw-mini:disabled { opacity: 0.4; cursor: default; }
.sw-mini-txt { padding: 0 0.75rem; }
.sw-mini[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.sw-mini[data-act="remove"] { margin-left: auto; }
.sw-drawer-sec { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.sw-drawer-sec[hidden] { display: none; }
.sw-drawer-sec h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.sw-drawer-sec .field { display: grid; gap: 0.3rem; margin: 0.7rem 0 0; }
.sw-drawer-sec .field label { font-weight: 650; font-size: 0.9rem; }
.sw-drawer-sec input[type="text"] { width: 100%; }
#sw-link { font-size: 0.85rem; color: var(--ink-soft); }

@media (prefers-reduced-motion: no-preference) {
  dialog.sw-drawer[open] { animation: sw-up var(--dur-2) var(--ease); }
}
@keyframes sw-up { from { transform: translateY(40px); } to { transform: none; } }
@keyframes sw-in { from { transform: translateX(40px); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .sw-card, .sw-card.sw-fling, .sw-btn svg, .sw-chip span { transition: none; }
}

/* Wide screens: the card on the left, the deck and matches beside it. */
@media (min-width: 900px) {
  .js .sw {
    grid-template-columns: minmax(0, 27rem) minmax(0, 1fr); column-gap: 2.2rem;
    grid-template-areas: "head head" "play partner" "play deck" "play matches" "play rest";
    grid-template-rows: auto auto auto auto 1fr;
    padding: 1.4rem 1.6rem 1.6rem;
  }
  .sw-head { grid-area: head; }
  .sw-partner { grid-area: partner; }
  .sw-deck { grid-area: deck; }
  .sw-play { grid-area: play; }
  .sw-matches { grid-area: matches; margin-top: 0; }
  .sw-stage { height: 320px; }
  dialog.sw-drawer {
    inset: 0 0 0 auto; width: 26rem; max-width: 100vw; height: 100vh; height: 100dvh; max-height: none;
    border-radius: 20px 0 0 20px;
  }
  .sw-drawer-in { height: 100%; }
}
@media (min-width: 900px) and (prefers-reduced-motion: no-preference) {
  dialog.sw-drawer[open] { animation: sw-in var(--dur-2) var(--ease); }
}

/* The share kit row inside the swipe panels. */
.sw-share-row .ps-mounted { margin: 0; }
