:root {
  --paper: #f5efe3;
  --paper-deep: #ebe2d0;
  --card: #fbf8f1;
  --ink: #22332b;
  --pine: #2f4a3c;
  --pine-soft: #dfe6dc;
  --berry: #8a2d3a;
  --berry-soft: #f0dcd9;
  --gold: #a8854f;
  --muted: #777262;
  --line: rgba(34, 51, 43, 0.16);
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: "Jost", "Avenir Next", "Helvetica Neue", sans-serif;
  --script: "Pinyon Script", "Snell Roundhand", cursive;
  --ar: 0.714; /* card width / height, replaced once the photos load */
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(120% 70% at 50% 0%, #fbf7ee 0%, transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* soft paper grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .4 0 0 0 0 .3 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

#snow { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

.page {
  position: relative;
  z-index: 2;
  width: min(100%, 44rem);
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) 1.25rem 3rem;
  text-align: center;
}

/* ---------- type ---------- */

.eyebrow {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--pine);
}
.eyebrow .dot { color: var(--gold); margin: 0 0.35em; }

.script {
  margin: 0.25rem 0 0;
  font-family: var(--script);
  font-size: clamp(2rem, 7vw, 2.75rem);
  line-height: 1.2;
  color: var(--berry);
}
.script.small { font-size: 1.75rem; }

h1 {
  margin: 0.1em 0 0;
  font-weight: 400;
  font-size: clamp(2.75rem, 11vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
h1 em { font-style: italic; font-weight: 400; color: var(--pine); }

h2 {
  margin: 0.4rem 0 0;
  font-weight: 400;
  font-size: clamp(1.625rem, 5.5vw, 2.125rem);
  line-height: 1.12;
  text-wrap: balance;
}

.lede {
  max-width: 31rem;
  margin: 1.1rem auto 0;
  color: #4a5249;
  text-wrap: pretty;
}

.sprig { display: block; width: 7.5rem; height: 1.5rem; margin: 0.9rem auto 0.5rem; }
.sprig path { fill: none; stroke: var(--gold); stroke-width: 0.75; stroke-linecap: round; }
.sprig .star { fill: var(--gold); stroke: none; }

/* ---------- card ---------- */

.stage { margin-top: clamp(1.75rem, 5vw, 2.75rem); }

.card-wrap {
  position: relative;
  /* fits portrait and landscape cards: limited by column width and by screen height */
  width: min(100%, calc(66vh * var(--ar)));
  min-width: min(100%, 15rem);
  margin: 0 auto;
  perspective: 1600px;
}

.card {
  position: relative;
  aspect-ratio: var(--ar);
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.2, 0.75, 0.2, 1);
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  border-radius: 6px;
  outline: none;
}
.card.dragging { cursor: grabbing; transition: none; }
.card:focus-visible { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--pine); }
.card.nudge { animation: nudge 1.6s 0.7s cubic-bezier(0.3, 0.7, 0.3, 1) 1; }
@keyframes nudge { 0%, 100% { transform: rotateY(0); } 35% { transform: rotateY(-22deg); } 70% { transform: rotateY(9deg); } }

.face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 6px;
  background: var(--card);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 0 0 1px rgba(34, 51, 43, 0.08);
}
.face-b { transform: rotateY(180deg); }
.face img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
/* a whisper of sheen so it reads as printed card stock */
.face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.22) 0%, transparent 32%, transparent 70%, rgba(0, 0, 0, 0.06) 100%);
}

.placeholder {
  position: absolute;
  inset: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--gold);
  outline: 1px solid rgba(168, 133, 79, 0.4);
  outline-offset: 4px;
  border-radius: 2px;
}
.face-a .placeholder { background: linear-gradient(160deg, #f4f1e6, #e3eadf); }
.face-b .placeholder { background: linear-gradient(160deg, #f8efe9, #f0dcd9); }
.ph-script { font-family: var(--script); font-size: clamp(2.25rem, 9vw, 3.25rem); line-height: 1.1; }
.face-a .ph-script { color: var(--pine); }
.face-b .ph-script { color: var(--berry); }
.ph-note { font-family: var(--sans); font-size: 0.625rem; letter-spacing: 0.28em; text-transform: uppercase; color: var(--muted); }

.card-shadow {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: -1.4rem;
  height: 2.2rem;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(60, 45, 20, 0.34), transparent);
  filter: blur(7px);
}

.controls { margin-top: 2.4rem; }

.side-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(251, 248, 241, 0.85);
}
.tab, .flip {
  min-height: 2.75rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.25s, color 0.25s;
}
.tab { padding: 0 1rem; }
.tab[aria-pressed="true"] { background: var(--pine); color: #fbf8f1; }
.tab[data-show="b"][aria-pressed="true"] { background: var(--berry); }
.flip { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0 0.9rem; color: var(--ink); }
.flip svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.6s cubic-bezier(0.2, 0.75, 0.2, 1); }
.flip:hover svg { transform: rotate(180deg); }
.flip:hover, .tab:not([aria-pressed="true"]):hover { background: var(--paper-deep); color: var(--ink); }
:is(.tab, .flip, .btn, input):focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }

.hint { margin: 0.8rem 0 0; font-style: italic; font-size: 1rem; color: var(--muted); }

/* ---------- panels ---------- */

.panel {
  margin-top: clamp(2.5rem, 7vw, 3.5rem);
  padding: clamp(1.5rem, 5vw, 2.5rem) clamp(1.1rem, 5vw, 2.5rem);
  background: rgba(251, 248, 241, 0.97);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 1px 0 #fff inset, 0 18px 40px -28px rgba(60, 45, 20, 0.45);
}
.panel[hidden] { display: none; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 1.5rem; }
.choice {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem 0.6rem 1rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.choice:hover { transform: translateY(-2px); }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice-a:has(input:checked) { border-color: var(--pine); background: var(--pine-soft); box-shadow: 0 0 0 1px var(--pine); }
.choice-b:has(input:checked) { border-color: var(--berry); background: var(--berry-soft); box-shadow: 0 0 0 1px var(--berry); }
.choice:has(input:focus-visible) { outline: 2px solid var(--pine); outline-offset: 2px; }
.thumb {
  width: min(100%, calc(5.5rem * max(1, var(--ar))));
  aspect-ratio: var(--ar);
  border-radius: 3px;
  background-size: cover;
  background-position: center;
  box-shadow: 0 6px 14px -8px rgba(60, 45, 20, 0.6), 0 0 0 1px rgba(34, 51, 43, 0.08);
}
.choice-a .thumb { background-color: #e3eadf; }
.choice-b .thumb { background-color: #f0dcd9; }
.choice-text { font-size: 1.375rem; line-height: 1.1; }
.choice-text small { display: block; margin-top: 0.3rem; font-family: var(--sans); font-size: 0.625rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }

.field { margin-top: 1.5rem; text-align: left; }
.field label { display: block; font-family: var(--sans); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; color: var(--pine); }
.optional { letter-spacing: 0.08em; color: var(--muted); text-transform: none; font-weight: 400; }
.field input {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem 0.1rem;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: none;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.5rem;
}
.field input::placeholder { color: #a9a393; font-style: italic; font-size: 1.1875rem; }
.field-note { margin: 0.5rem 0 0; font-size: 0.9375rem; font-style: italic; color: var(--muted); }

.form-error { margin: 1rem 0 0; color: var(--berry); font-style: italic; }

.btn {
  display: inline-block;
  width: 100%;
  min-height: 3.25rem;
  margin-top: 1.5rem;
  padding: 0 1.5rem;
  border: 1px solid var(--pine);
  border-radius: 999px;
  background: var(--pine);
  color: #fbf8f1;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.btn:hover { background: var(--ink); }
.btn:active { transform: scale(0.985); }
.btn[hidden] { display: none; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn-quiet { width: auto; max-width: 100%; padding: 0 1.25rem; letter-spacing: 0.18em; white-space: nowrap; background: none; color: var(--pine); }
.btn-quiet:hover { background: var(--pine-soft); }

/* ---------- results ---------- */

.results-sub { margin: 0.6rem 0 0; font-style: italic; color: #4a5249; }

.tally { margin-top: 1.5rem; }
.tally-bar { display: flex; gap: 3px; height: 0.5rem; }
.tally-bar span { display: block; min-width: 0.5rem; border-radius: 999px; transition: flex-grow 1.2s cubic-bezier(0.2, 0.75, 0.2, 1); flex: 1 1 0; }
.tally-a { background: var(--pine); }
.tally-b { background: var(--berry); }

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.1rem; }
.col-a { text-align: left; }
.col-b { text-align: right; }
.col-num { margin: 0; font-size: clamp(3rem, 13vw, 4.5rem); line-height: 1; font-variant-numeric: lining-nums; }
.col-a .col-num { color: var(--pine); }
.col-b .col-num { color: var(--berry); }
.col-label { margin: 0.2rem 0 0; font-family: var(--sans); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; }
.badge { display: inline-block; margin: 0.3rem 0 0; padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--gold); color: #fff; letter-spacing: 0.14em; }
.badge[hidden] { display: none; }

.names { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1rem 0 0; padding: 0; list-style: none; }
.col-b .names { justify-content: flex-end; }
.names li, .floater span {
  padding: 0.2rem 0.7rem 0.25rem;
  border-radius: 999px;
  font-size: 1.0625rem;
  font-style: italic;
  line-height: 1.3;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.names li { animation: pop 0.5s cubic-bezier(0.2, 1.3, 0.4, 1) backwards; }
.col-a .names li, .floater.a span { background: var(--pine-soft); color: var(--pine); }
.col-b .names li, .floater.b span { background: var(--berry-soft); color: var(--berry); }
.names li.me, .floater.me span { font-weight: 600; box-shadow: 0 0 0 1px currentColor; }
.names li.anon { opacity: 0.7; }
@keyframes pop { from { opacity: 0; transform: scale(0.6) translateY(8px); } }

/* ---------- votes drifting around the screen ---------- */

.floaters { position: fixed; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
.floater {
  position: absolute;
  top: 100%;
  animation: rise var(--dur, 18s) linear forwards;
  will-change: transform;
}
.floater span {
  display: block;
  max-width: 11rem;
  box-shadow: 0 6px 16px -10px rgba(60, 45, 20, 0.6);
  animation: sway var(--sway, 5s) ease-in-out infinite alternate, pop 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) backwards;
}
@keyframes rise {
  0% { transform: translateY(0); opacity: 0; }
  6% { opacity: var(--peak, 0.95); }
  85% { opacity: var(--peak, 0.95); }
  100% { transform: translateY(-118vh); opacity: 0; }
}
@keyframes sway { from { translate: -14px 0; rotate: -4deg; } to { translate: 14px 0; rotate: 4deg; } }
@media (max-width: 60rem) { .floater { --peak: 0.55; } }

/* ---------- countdown ---------- */

.countdown { margin-top: clamp(2.5rem, 7vw, 3.5rem); }
.clock { display: flex; justify-content: center; gap: clamp(0.75rem, 5vw, 2.25rem); margin-top: 1.1rem; }
.clock[hidden] { display: none; }
.clock div { min-width: 3.4rem; }
.clock b { display: block; font-weight: 400; font-size: clamp(2.5rem, 11vw, 4rem); line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.clock span { display: block; margin-top: 0.45rem; font-family: var(--sans); font-size: 0.5625rem; letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted); }
.clock div + div { border-left: 1px solid var(--line); padding-left: clamp(0.75rem, 5vw, 2.25rem); }
.reveal { margin: 0.8rem auto 0; max-width: 26rem; font-size: clamp(1.625rem, 6vw, 2.25rem); line-height: 1.15; text-wrap: balance; }
.reveal em { color: var(--berry); }

.foot { margin-top: 3.5rem; }
.foot .eyebrow { margin-top: 0.2rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .floaters, #snow { display: none; }
}

@media (max-width: 26rem) {
  .tab { padding: 0 0.75rem; }
  .flip { padding: 0 0.5rem; }
  .tab, .flip { letter-spacing: 0.14em; }
  .btn-quiet { font-size: 0.6875rem; letter-spacing: 0.12em; }
}

/* larger small-print on tablets and desktops */
@media (min-width: 48rem) {
  body { font-size: 1.3125rem; }
  .lede { max-width: 35rem; }
  .eyebrow, .field label, .col-label, .tab, .flip { font-size: 0.8125rem; }
  .btn { font-size: 0.875rem; }
  .ph-note, .choice-text small { font-size: 0.75rem; }
  .clock span { font-size: 0.75rem; }
  .hint { font-size: 1.1875rem; }
  .field-note { font-size: 1.125rem; }
  .field input::placeholder { font-size: 1.3125rem; }
  .names li, .floater span { font-size: 1.1875rem; }
  .choice-text { font-size: 1.625rem; }
}
