/* lowk.link — public ballot.
   Tokens and layout translated from lowk.link.dc.html. Mobile-first, but the
   design's "open on your phone" desktop dead end is deliberately not carried
   over: a link pasted into a group chat gets opened on laptops constantly, and
   turning those people away loses the vote for no benefit. */

:root {
  --bg-top: #f4f2fb;
  --bg-bottom: #eae6f6;
  --ink: #2b1f3d;
  --ink-soft: #6e6484;
  --ink-muted: #9a93ae;
  --brand: #7c5ce0;
  --brand-alt: #8fa4ea;
  --chip: #e6e2f8;
  --sheet: #fbfafe;
  --display: "Baloo 2", Nunito, -apple-system, "Segoe UI", sans-serif;
  --body: Nunito, -apple-system, "Segoe UI", sans-serif;
  --voice: "EB Garamond", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-top);
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  min-height: 100dvh;
  overflow-x: hidden;
  background: linear-gradient(175deg, var(--bg-top), var(--bg-bottom));
  font-family: var(--body);
  color: var(--ink);
  display: flex;
  justify-content: center;
}

a { color: var(--ink-soft); text-decoration: none; }
a:hover { color: var(--brand); }
button { font: inherit; border: 0; background: none; cursor: pointer; color: inherit; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Ambient blur orbs. Purely decorative, so they never take pointer events. */
.orb {
  position: absolute;
  width: 180px; height: 180px;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.45;
  pointer-events: none;
}
.orb-a { top: -40px; left: -60px; background: var(--brand); }
.orb-b { top: 300px; right: -70px; background: var(--brand-alt); }

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 430px;
  padding: 26px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------- animations ---------- */

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.78; }
  50% { transform: scale(1.045); opacity: 1; }
}
@keyframes land {
  0% { transform: scale(0.86); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes sheet-up {
  from { transform: translateY(101%); }
  to { transform: translateY(0); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer {
  0% { opacity: 0.5; }
  50% { opacity: 0.9; }
  100% { opacity: 0.5; }
}
@keyframes lock {
  from { transform: scaleX(0.9); opacity: 0; }
  to { transform: scaleX(1); opacity: 1; }
}

/* Someone who asked for less motion still needs the pulse that says "tap
   here", so keep opacity and drop movement rather than removing the cue. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

.person {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 104px; height: 104px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--chip) center / cover no-repeat;
  box-shadow: 0 12px 32px rgba(124, 92, 224, 0.26);
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 40px;
  color: var(--brand);
}
.avatar.has-image { color: transparent; }

.person-name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 38px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-align: center;
  overflow-wrap: anywhere;
}

.person-subtitle {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-muted);
}

/* ---------- the ask ---------- */

.ask {
  font-family: var(--voice);
  font-style: italic;
  font-size: 20px;
  line-height: 1.35;
  color: var(--ink-soft);
  text-align: center;
  text-wrap: pretty;
}
.ask em { font-style: inherit; color: var(--brand); }

/* ---------- sentence builder ---------- */

.builder {
  position: relative;
  padding: 22px 16px 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: 0 8px 30px rgba(43, 31, 61, 0.07);
}

.sentence-wrap { position: relative; }

.sentence-lock {
  position: absolute;
  inset: -10px -8px;
  border-radius: 26px;
  background: var(--chip);
  animation: lock 260ms cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.sentence {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sentence-fixed {
  font-family: var(--voice);
  font-style: italic;
  font-size: 21px;
  line-height: 1.2;
  color: var(--ink);
  text-align: center;
  text-wrap: pretty;
}

.slots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 0;
}

.slot {
  position: relative;
  margin: 0 3px;
  padding: 10px 15px;
  border-radius: 20px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 16px;
  line-height: 1.15;
  min-height: 44px;
}

.slot-empty {
  border: 1.5px dashed rgba(124, 92, 224, 0.28);
  background: transparent;
  color: rgba(124, 92, 224, 0.55);
}

.slot-pulse {
  border: 1.5px dashed rgba(124, 92, 224, 0.4);
  background: transparent;
  color: rgba(124, 92, 224, 0.85);
  animation: breathe 2.5s ease-in-out infinite;
}

.slot-filled {
  padding: 10px 14px;
  background: var(--chip);
  color: var(--brand);
  animation: land 180ms cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}
.slot-filled .caret { font-size: 12px; opacity: 0.5; }

.shuffle-row { display: flex; justify-content: center; margin-top: 20px; }

.shuffle {
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(124, 92, 224, 0.08);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 13px;
  min-height: 40px;
}

/* ---------- send ---------- */

.send-block {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.primary {
  width: 100%;
  padding: 18px;
  border-radius: 999px;
  background: linear-gradient(102deg, var(--brand), var(--brand-alt));
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
  font-size: 20px;
  text-align: center;
  box-shadow: 0 12px 28px rgba(124, 92, 224, 0.38);
}
.primary:active { transform: scale(0.985); }
.primary:disabled { opacity: 0.4; box-shadow: none; cursor: default; transform: none; }

.anon-pill {
  padding: 8px 15px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.proof { font-size: 12px; font-weight: 600; color: var(--ink-muted); text-align: center; }
.free-line { font-size: 12px; font-weight: 700; color: var(--ink-muted); }

/* Turnstile renders in interaction-only mode, so this collapses to nothing
   for the visitors who never get challenged. */
#turnstile-slot:not(:empty) { margin-top: 2px; }

/* ---------- what is lowk ---------- */

.what { border-top: 1px solid rgba(110, 100, 132, 0.14); padding-top: 16px; }

.what-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  font-family: var(--voice);
  font-style: italic;
  font-size: 17px;
  color: var(--ink-soft);
}
.what-chevron { font-family: var(--body); font-size: 13px; color: var(--ink-muted); }

.steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
  animation: fade 200ms ease both;
}

.step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
}
.step-emoji { font-size: 24px; }
.step-text { font-weight: 700; font-size: 14.5px; color: var(--ink); }

/* ---------- centered result states ---------- */

.centered {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  text-align: center;
}
.centered.pad { padding-top: 40px; }

.result-card {
  width: 100%;
  padding: 24px 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 8px 30px rgba(43, 31, 61, 0.07);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.result-emoji { font-size: 40px; }
.result-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  line-height: 1.2;
  text-wrap: pretty;
}
.result-note { font-family: var(--voice); font-style: italic; font-size: 18px; color: var(--ink-soft); }
.countdown {
  font-family: var(--display);
  font-weight: 800;
  font-size: 30px;
  color: var(--brand);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.big-emoji { font-size: 54px; }
.headline {
  font-family: var(--display);
  font-weight: 800;
  font-size: 26px;
  line-height: 1.15;
  text-wrap: pretty;
}

/* ---------- own link ---------- */

.link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 6px 22px rgba(43, 31, 61, 0.06);
}
.link-text {
  flex: 1;
  text-align: left;
  font-family: var(--display);
  font-weight: 800;
  font-size: 17px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy-button {
  padding: 9px 15px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--brand);
  font-family: var(--display);
  font-weight: 800;
  font-size: 14px;
  min-height: 40px;
}

/* ---------- loading skeleton ---------- */

.skeleton-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 18px;
}
.skeleton { background: var(--chip); animation: shimmer 1.4s ease-in-out infinite; }
.skeleton-avatar { width: 104px; height: 104px; border-radius: 50%; }
.skeleton-name { width: 190px; height: 34px; border-radius: 10px; }
.skeleton-sub { width: 150px; height: 13px; border-radius: 999px; }
.skeleton-card { width: 100%; height: 118px; border-radius: 22px; opacity: 0.7; margin-top: 16px; }
.skeleton-cta { width: 100%; height: 56px; border-radius: 999px; opacity: 0.55; }

/* ---------- desktop ---------- */

.desktop-card {
  padding: 18px 20px;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 12px 34px rgba(43, 31, 61, 0.1);
  font-family: var(--display);
  font-weight: 800;
  font-size: 18px;
  overflow-wrap: anywhere;
}
.desktop-hint { font-family: var(--display); font-weight: 800; font-size: 15px; color: var(--brand); }

/* ---------- footer ---------- */

.footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: auto;
  padding-top: 26px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-muted);
}

/* ---------- option sheet ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.scrim {
  position: absolute;
  inset: 0;
  background: rgba(43, 31, 61, 0.42);
  animation: fade 180ms ease both;
}
.sheet {
  position: relative;
  width: 100%;
  max-width: 430px;
  max-height: 70dvh;
  display: flex;
  flex-direction: column;
  background: var(--sheet);
  border-radius: 26px 26px 0 0;
  padding: 10px 0 max(18px, env(safe-area-inset-bottom));
  animation: sheet-up 240ms cubic-bezier(0.2, 0.9, 0.3, 1.05) both;
  box-shadow: 0 -14px 40px rgba(43, 31, 61, 0.2);
}
.grabber {
  width: 42px; height: 4px;
  border-radius: 999px;
  background: rgba(110, 100, 132, 0.22);
  margin: 4px auto 10px;
}
.sheet-title {
  padding: 0 20px 10px;
  font-family: var(--voice);
  font-style: italic;
  font-size: 17px;
  color: var(--ink-muted);
}
.sheet-rows {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sheet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: 16px;
  color: var(--ink);
  min-height: 48px;
}
.sheet-row:active { background: #efecf9; }
.sheet-row[aria-checked="true"] { background: var(--brand); color: #fff; }
.row-emoji { width: 24px; font-size: 19px; text-align: center; }
.row-label { flex: 1; font-family: var(--voice); font-style: italic; font-size: 19px; }

/* ---------- sent sheet ---------- */

.sent-overlay { z-index: 30; }
.sent-scrim { background: rgba(43, 31, 61, 0.5); animation: fade 200ms ease both; }
.sent-sheet {
  position: relative;
  width: 100%;
  max-width: 430px;
  background: var(--sheet);
  border-radius: 28px 28px 0 0;
  padding: 30px 22px max(26px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  animation: sheet-up 280ms cubic-bezier(0.2, 0.9, 0.3, 1.05) both;
  box-shadow: 0 -14px 44px rgba(43, 31, 61, 0.24);
}
.sent-emoji { font-size: 46px; }
.sent-line {
  font-family: var(--display);
  font-weight: 800;
  font-size: 23px;
  line-height: 1.25;
  text-wrap: pretty;
}
.sent-anon { font-family: var(--voice); font-style: italic; font-size: 18px; color: var(--ink-soft); }
.cluster-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.cluster { display: flex; }
.cluster span {
  width: 34px; height: 34px;
  margin-left: -9px;
  border-radius: 50%;
  background: #c9c0ee;
  filter: blur(3px);
  border: 2px solid var(--sheet);
}
.cluster-label { font-size: 12.5px; font-weight: 700; color: var(--ink-muted); text-align: left; }
.not-now { font-size: 12.5px; font-weight: 700; color: var(--ink-muted); padding: 8px; min-height: 40px; }

/* ---------- errors ---------- */

.error {
  width: 100%;
  padding: 13px 16px;
  border-radius: 16px;
  background: rgba(214, 64, 92, 0.1);
  color: #a8324c;
  font-weight: 700;
  font-size: 13.5px;
  text-align: center;
}

/* ---------- safety ---------- */

.safety {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink-muted);
  text-align: center;
  padding: 0 4px;
}

/* ---------- owner preview ---------- */

/* The owner opening their own link gets the real ballot, not a mock-up of it —
   with sending disabled, because a self-vote would inflate the very counts the
   app shows them. */
.preview-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 16px;
  border-radius: 16px;
  background: rgba(124, 92, 224, 0.1);
  color: var(--brand);
  font-weight: 800;
  font-size: 13px;
  text-align: center;
}
.preview-sub { font-weight: 700; font-size: 11.5px; color: var(--ink-muted); }

/* ---------- pointer devices ---------- */

/* Everything below applies only where there's a mouse. Touch targets, sheet
   physics, and safe-area padding stay exactly as they are on phones. */
@media (hover: hover) and (pointer: fine) {
  .shell { padding-top: 40px; padding-bottom: 56px; }

  .slot,
  .shuffle,
  .what-toggle,
  .copy-button { transition: background 120ms ease, color 120ms ease, transform 120ms ease; }

  .slot-empty:hover,
  .slot-pulse:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: rgba(124, 92, 224, 0.06);
  }
  .slot-filled:hover { background: #dcd5f5; }
  .shuffle:hover { background: rgba(124, 92, 224, 0.16); color: var(--brand); }
  .primary:not(:disabled):hover { transform: translateY(-1px); }
  .sheet-row:hover { background: #efecf9; }
  .sheet-row[aria-checked="true"]:hover { background: var(--brand); }

  /* A sheet slid up from the bottom of a 1440px window reads as a mistake.
     Centre it and let it grow from the middle instead. */
  .overlay { align-items: center; }
  .sheet,
  .sent-sheet {
    border-radius: 26px;
    animation-name: dialog-in;
    max-height: 78dvh;
  }
  .sheet { padding-bottom: 18px; }
  .sent-sheet { padding-bottom: 26px; }
  .grabber { display: none; }
}

@keyframes dialog-in {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Keyboard users need to see where they are; the design never specified this
   because a touch prototype has no focus. */
:focus-visible {
  outline: 2.5px solid var(--brand);
  outline-offset: 2px;
  border-radius: 12px;
}
