/* Reusable pieces: buttons, panels, fields, chips, progress, chamber,
   member rows, dialog, toast. Screens compose these. */

/* Buttons */
.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .7em;
  min-height: 46px;
  padding: 13px 20px;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: transparent;
  color: var(--fg);
  font: 500 .74rem/1 var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 160ms, border-color 160ms, color 160ms, transform 160ms var(--ease), box-shadow 160ms;
  -webkit-tap-highlight-color: transparent;
}
.btn .icon { width: 1.25em; height: 1.25em; flex: none; }
.btn--primary { background: var(--butter); border-color: var(--butter); color: var(--bg); }
.btn--primary:hover { background: var(--butter-hover); transform: translateY(-1px); box-shadow: 0 8px 24px var(--butter-ring); }
.btn--primary:active { transform: scale(.97); box-shadow: none; }
.btn--outline:active, .btn--ghost:active { transform: scale(.97); }
.btn--primary[disabled] { opacity: .35; cursor: not-allowed; transform: none; box-shadow: none; }
.btn--outline { border-color: var(--border-strong); }
.btn--outline:hover { border-color: var(--butter); color: var(--butter); }
.btn--ghost { color: var(--muted); padding-inline: 12px; }
.btn--ghost:hover { color: var(--fg); }
.btn--sm { min-height: 36px; padding: 10px 13px; font-size: .64rem; }
.btn--lg { min-height: 52px; padding: 17px 26px; font-size: .78rem; }
.btn--block { width: 100%; }
.btn.nudge { animation: nudge 700ms var(--ease) 2; }
@keyframes nudge { 50% { box-shadow: 0 0 0 6px rgba(243, 224, 160, .25); } }

.link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0;
  border: 0;
  background: none;
  font: 400 .66rem var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 4px;
  white-space: nowrap;
  cursor: pointer;
}
.link:hover { color: var(--butter); text-decoration-color: var(--butter); }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg); }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin: 0; padding: 0 0 12px; border-bottom: 1px solid var(--border); font: 400 .68rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--fg-2); }
.panel-head .muted { color: var(--muted); text-align: right; }

/* Fields */
.input, textarea {
  display: block;
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  background: rgba(15, 52, 62, .85);
  color: var(--fg);
  font: 400 1.05rem var(--serif);
  transition: border-color 160ms, box-shadow 160ms;
}
.input { min-height: 50px; padding: 12px 14px; }
.input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
.input:focus, textarea:focus { outline: none; border-color: var(--butter); box-shadow: 0 0 0 4px rgba(243, 224, 160, .12); }
.input[aria-invalid='true'] { border-color: var(--rep); }

/* Choice chips (radio inputs styled as pills) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; }
.chips legend { padding: 0; margin-bottom: 10px; }
.chips label { position: relative; cursor: pointer; }
.chips input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.chips span { display: inline-flex; align-items: center; min-height: 34px; padding: 6px 13px; border: 1px solid var(--border-strong); border-radius: 999px; font: 400 .62rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); transition: border-color 160ms, color 160ms, background 160ms; }
.chips label:hover span { border-color: var(--muted); color: var(--fg-2); }
.chips input:checked + span { border-color: var(--butter); color: var(--butter); background: var(--butter-soft); }
.chips input:focus-visible + span { outline: 2px solid var(--butter); outline-offset: 2px; }
@media (pointer: coarse) { .chips span { min-height: 40px; } }

/* Progress: one segment per question */
.progress { display: flex; gap: 6px; margin: 16px 0 30px; padding: 0; list-style: none; }
.progress li { position: relative; flex: 1; height: 3px; border-radius: 3px; background: var(--border-strong); transition: background 300ms; }
.progress li::after { content: ''; position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: var(--butter); transition: width 500ms var(--ease); }
.progress li.done::after { width: 100%; }
.progress li.current::after { width: 45%; }
.progress li.skipped { background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 8px); opacity: .6; }
.progress button { position: absolute; inset: -14px 0; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; }

/* Chamber */
.hemi { display: block; width: 100%; height: auto; overflow: visible; }
.hemi .seat { transition: r 400ms var(--ease), fill 400ms, opacity 400ms; }
.hemi .seat.twin-seat.ping { animation: ping-twin 1600ms ease-out; }
@keyframes ping-twin { 0% { stroke: var(--butter); stroke-width: 0; } 40% { stroke: rgba(243, 224, 160, .6); stroke-width: .05; } 100% { stroke: rgba(243, 224, 160, 0); stroke-width: .09; } }
.hemi .seat.D { fill: var(--dem); }
.hemi .seat.R { fill: var(--rep); }
.hemi .seat.off { fill: var(--seat-off); }
.hemi .seat.twin-seat { fill: var(--butter); stroke: var(--bg); stroke-width: .012; }
.hemi .seat.picked { stroke: var(--fg); stroke-width: .016; }
.hemi .seat.ping { animation: ping 1400ms ease-out; }
@keyframes ping { 25% { fill: var(--butter); } }
.hemi .you-line { stroke: var(--butter); stroke-width: .006; stroke-dasharray: .02 .016; opacity: .8; }
.hemi .you-tag rect { fill: var(--butter); }
.hemi .you-tag text { font: 500 .062px var(--mono); letter-spacing: .012px; fill: var(--bg); }
.chamber-panel { padding: 18px 18px 16px; }
.chamber-panel .hemi { margin-top: 16px; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 14px 0 0; font: 400 .66rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; vertical-align: 1px; }
.dot--D { background: var(--dem); }
.dot--R { background: var(--rep); }

/* Member rows (top five, full ranking, topics) */
.members { margin: 0; padding: 0 20px; list-style: none; counter-reset: r; }
.members > li { counter-increment: r; display: grid; align-items: center; gap: 12px; padding: 12px 0; }
.members > li + li { border-top: 1px solid var(--border); }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--raise); box-shadow: 0 0 0 1px var(--border-strong); }
.avatar--sm { width: 30px; height: 30px; }
.avatar--xs { width: 24px; height: 24px; }
.who { min-width: 0; font: 400 1.05rem/1.25 var(--serif); }
.who small { display: block; margin-top: 3px; font: 400 .62rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.pct { font: 400 1.2rem var(--serif); color: var(--butter); font-variant-numeric: tabular-nums; }
.party-chip { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--party); vertical-align: 1px; }

/* Dialog */
.dialog { width: min(480px, calc(100vw - 2 * var(--gutter))); padding: 30px 24px 24px; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--card); color: var(--fg); box-shadow: 0 40px 80px rgba(4, 22, 27, .6); }
.dialog::backdrop { background: rgba(6, 24, 29, .72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; top: 8px; right: 10px; }
.dialog-close button { padding: 6px 10px; border: 0; background: none; color: var(--muted); font-size: 1.7rem; line-height: 1; cursor: pointer; }
.dialog-close button:hover { color: var(--butter); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border: 1px solid var(--butter);
  border-radius: var(--r);
  background: var(--card);
  color: var(--fg);
  font: 400 .72rem/1.5 var(--mono);
  letter-spacing: .06em;
  box-shadow: 0 16px 40px rgba(4, 22, 27, .5);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 200ms, transform 200ms var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 960px) { .toast { bottom: calc(28px + env(safe-area-inset-bottom)); } }

/* Sticky bottom bar (phones) */
.bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(17, 58, 68, 0), var(--bg) 40%); animation: rise 400ms var(--ease) both; }
@media (min-width: 960px) { .bottombar { display: none !important; } }

/* Page hero: copy beside a visual on desktop */
.hero { padding-top: 44px; }
.hero-copy > .reveal:nth-child(2) { animation-delay: 80ms; }
.hero-copy > .reveal:nth-child(3) { animation-delay: 180ms; }
.hero-copy > .reveal:nth-child(n+4) { animation-delay: 260ms; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn { flex: 1 1 auto; }

/* Deck cards: butter numeral, rule, title, body */
.cards { display: grid; gap: 14px; margin: 8px 0 0; padding: 0; list-style: none; }
.card { padding: 22px 22px 24px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel); }
.card-n { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); font: 400 1.5rem/1 var(--display); color: var(--butter); }
.card-n small { font: 400 .62rem var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.card h3 { margin: 0 0 8px; font: 500 1.2rem/1.25 var(--serif); }
.card p { margin: 0; line-height: 1.55; color: var(--muted); }

/* Probability bar with a 0-50-100 scale */
.bar { height: 8px; overflow: hidden; border-radius: 8px; background: var(--bg-deep); box-shadow: inset 0 0 0 1px var(--border); }
.bar span { display: block; width: 0; height: 100%; border-radius: 8px; background: var(--butter); transition: width 1200ms var(--ease); }
.bar-scale { display: flex; justify-content: space-between; margin: 8px 0 0; font: 400 .6rem var(--mono); letter-spacing: .1em; color: var(--muted); }

@media (min-width: 640px) {
  .actions .btn { flex: 0 0 auto; }
  .cards { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 960px) {
  .hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 64px; align-items: center; min-height: min(660px, calc(100dvh - 110px)); padding-top: 24px; }
  .hero .headline { font-size: clamp(4.4rem, 6.6vw, 6rem); }
}

/* Loading: photos shimmer until they arrive, then fade in (fadeInImages in
   ui/dom.js); .skeleton lines stand in for text that's still loading. */
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes img-in { from { opacity: 0; filter: blur(6px); } }
.avatar, .portrait img, .friend img, .skeleton i, .card-frame {
  background: linear-gradient(100deg, var(--raise) 30%, #2b6874 50%, var(--raise) 70%) 0 0 / 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.avatar.is-loaded, .portrait img.is-loaded, .friend img.is-loaded { animation: img-in 450ms var(--ease) both; }
.skeleton { display: grid; gap: 9px; padding: 4px 0 2px; }
.skeleton i { display: block; height: 12px; border-radius: 6px; }
.skeleton i:nth-child(2) { width: 88%; }
.skeleton i:nth-child(3) { width: 56%; }
