:root {
  --kraft: #CBAE87;
  --kraft-deep: #B8976C;
  --slip: #FFFFFF;
  --ink: #000000;
  --envelope: #8DB8E0;
  --envelope-deep: #6F9FCB;
  --flash: #E3001B;
  --night: #0F1B3D;
  --display: "Karantina", "Arial Narrow", sans-serif;
  --body: "Rubik", "Arial", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--kraft);
  /* Faint cardboard fibre, the material of every Israeli voting booth. */
  background-image:
    repeating-linear-gradient(97deg, rgba(0,0,0,.025) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(3deg, rgba(255,255,255,.05) 0 1px, transparent 1px 11px);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.6;
  transition: background-color .9s ease, color .9s ease;
}
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

/* Breaking-news bar */
.flash {
  display: flex; align-items: stretch;
  background: var(--flash); color: #fff;
  font-family: var(--display); font-size: 28px; line-height: 1;
  overflow: hidden; position: relative;
}
.flash-label {
  flex: none; background: #fff; color: var(--flash);
  padding: 10px 18px 8px; font-weight: 700; z-index: 1;
}
.flash-track { flex: 1; overflow: hidden; display: flex; align-items: center; }
.flash-lines {
  display: flex; gap: 56px; white-space: nowrap; padding-inline-start: 24px;
  animation: crawl 60s linear infinite;
}
.flash-lines span { padding-top: 2px; }
@keyframes crawl { from { transform: translateX(0); } to { transform: translateX(50%); } }
.flash-mute {
  flex: none; border: 0; background: rgba(0,0,0,.18); color: #fff; cursor: pointer;
  font-family: var(--body); font-size: 14px; padding: 8px 16px; z-index: 1;
}
.flash-mute:hover { background: rgba(0,0,0,.3); }
.flash.is-muted .flash-lines { animation-play-state: paused; }

main { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* Hero */
.hero { padding: 72px 0 40px; }
.hero h1 {
  font-family: var(--display); font-weight: 700; margin: 0;
  font-size: clamp(76px, 15vw, 190px); line-height: .82; letter-spacing: -.01em;
}
.hero .also {
  font-family: var(--display); font-weight: 400; margin: 10px 0 0;
  font-size: clamp(40px, 7vw, 84px); line-height: .9;
}
.hero p { max-width: 36ch; margin: 26px 0 0; font-size: 20px; }

/* Booth */
.booth { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 40px; padding: 30px 0 70px; align-items: start; }
.booth h2 { font-family: var(--display); font-size: 54px; line-height: .9; margin: 0 0 6px; }
.booth .hint { margin: 0 0 22px; }

.tray {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  background: var(--kraft-deep); padding: 14px; border-radius: 4px;
  box-shadow: inset 0 2px 0 rgba(0,0,0,.15), inset 0 -2px 0 rgba(255,255,255,.2);
}
.slip {
  appearance: none; border: 1px solid rgba(0,0,0,.25); background: var(--slip); color: var(--ink);
  aspect-ratio: 3 / 4; cursor: pointer; padding: 12px 12px 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 1px 0 rgba(0,0,0,.2);
  transition: transform .15s ease;
}
.slip:hover, .slip:focus-visible { transform: translateY(-5px); }
.slip .code { font-family: var(--display); font-weight: 700; font-size: clamp(46px, 6.5vw, 76px); line-height: .8; }
.slip .name { font-size: 13px; line-height: 1.3; text-align: center; }
.slip.is-cast { visibility: hidden; }

.envelope-col { position: sticky; top: 24px; }
.envelope {
  background: var(--envelope); border-radius: 6px; position: relative;
  aspect-ratio: 4 / 3; overflow: hidden;
  box-shadow: 0 2px 0 var(--envelope-deep);
}
.envelope::before {
  /* the flap */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 52%;
  background: var(--envelope-deep);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  opacity: .55;
}
.envelope .stamp {
  position: absolute; bottom: 16px; inset-inline-start: 18px;
  font-family: var(--display); font-size: 26px; line-height: 1; opacity: .7;
}
.result { margin-top: 18px; min-height: 9em; }
.result h3 { font-family: var(--display); font-size: 40px; line-height: .95; margin: 0 0 8px; }
.result p { margin: 0 0 10px; }
.result .verdict { font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn {
  appearance: none; border: 2px solid var(--ink); background: transparent; color: var(--ink);
  font-family: var(--body); font-size: 16px; font-weight: 500; padding: 9px 18px; cursor: pointer;
}
.btn.solid { background: var(--ink); color: #fff; }
/* WhatsApp's own dark teal: recognizable, and white on it passes contrast. */
.btn.share { background: #075E54; border-color: #075E54; color: #fff; }
.btn.share:hover { background: #054740; border-color: #054740; color: #fff; }
.btn:hover { background: var(--ink); color: #fff; }
.flyer { position: fixed; z-index: 50; pointer-events: none; margin: 0; }

.coffee { border-top: 2px solid var(--ink); padding: 28px 0 34px; }
.coffee h2 { font-family: var(--display); font-size: 48px; line-height: .9; margin: 0 0 8px; }
.coffee p { margin: 0 0 16px; max-width: 46ch; }
a.btn { display: inline-block; text-decoration: none; }
body.night .coffee { border-color: #E7ECF7; }
footer { border-top: 2px solid var(--ink); padding: 20px 0 40px; font-size: 15px; }
footer p { max-width: 70ch; margin: 0; }

/* Lights out */
body.night { background-color: var(--night); background-image: none; color: #E7ECF7; }
body.night .flash { filter: grayscale(1) brightness(.5); }
body.night .tray, body.night .envelope-col, body.night .hero p, body.night .hint { opacity: .25; transition: opacity .9s ease; }
body.night .btn { border-color: #E7ECF7; color: #E7ECF7; }
body.night .btn:hover { background: #E7ECF7; color: var(--night); }
body.night footer { border-color: #E7ECF7; }
.goodnight { display: none; }
body.night .goodnight { display: block; }
.goodnight {
  position: fixed; inset: auto 0 0 0; padding: 28px 24px 34px; background: var(--night);
  border-top: 1px solid rgba(231,236,247,.25); text-align: center; z-index: 40;
}
.goodnight strong { display: block; font-family: var(--display); font-size: 58px; line-height: .9; font-weight: 400; }
.goodnight p { margin: 8px auto 14px; max-width: 46ch; }

@media (max-width: 820px) {
  .booth { grid-template-columns: 1fr; }
  .envelope-col { position: static; }
  .hero { padding-top: 44px; }
  .flash { font-size: 22px; }
}
@media (max-width: 420px) {
  .tray { gap: 8px; padding: 10px; }
  .slip .name { font-size: 11.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .flash-lines { animation: none; }
  .slip { transition: none; }
  body { transition: none; }
}

/* Language switch: a plain link, top of the hero, on the reading end. */
.lang-switch { display: flex; justify-content: flex-end; padding-top: 18px; }
.lang-switch a { font-size: 15px; font-weight: 500; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.lang-switch a:hover { text-decoration-thickness: 2px; }
.hero { padding-top: 40px; }

/* English reads left to right, so its crawl moves the other way. */
[dir="ltr"] .flash-lines { animation-name: crawl-ltr; }
@keyframes crawl-ltr { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* Arriving from a friend's share link. */
.friend {
  margin: 28px 0 0; padding: 12px 16px; max-width: 46ch;
  background: var(--slip); border: 2px solid var(--ink); font-weight: 500;
}
.slip.is-friend { outline: 3px dashed var(--ink); outline-offset: 3px; }

/* Live results */
.results { border-top: 2px solid var(--ink); padding: 28px 0 34px; }
.results h2 { font-family: var(--display); font-size: 48px; line-height: .9; margin: 0 0 8px; }
.results .lead { margin: 0 0 18px; font-weight: 500; }
.results ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-width: 720px; }
.results li { display: grid; grid-template-columns: 3.2em minmax(0, 13em) minmax(0, 1fr) 3.4em; align-items: center; gap: 12px; }
.results .r-code { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1; }
.results .r-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .r-bar { height: 14px; background: var(--kraft-deep); display: block; }
.results .r-bar i { display: block; height: 100%; background: var(--ink); transition: width .6s ease; }
.results .r-pct { font-size: 15px; font-variant-numeric: tabular-nums; text-align: end; }
.results .total, .results .note { margin: 14px 0 0; font-size: 14px; }
body.night .results { border-color: #E7ECF7; opacity: .25; }
body.night .results .r-bar i { background: #E7ECF7; }
@media (max-width: 560px) {
  .results li { grid-template-columns: 2.6em minmax(0, 1fr) 3.2em; }
  .results .r-bar { grid-column: 1 / -1; order: 4; }
  .results ol { gap: 16px; }
  .results li { row-gap: 5px; }
}
@media (prefers-reduced-motion: reduce) { .results .r-bar i { transition: none; } }
