:root {
  --paper: #efe4ce;
  --paper-deep: #e4d4b6;
  --sidebar: #e9d9ba;
  --ink: #241c14;
  --ink-soft: #5e5348;
  --rule: #cbb89a;
  --card: #fff8ec;
  --card-edge: #d7c4a4;
  --stamp: #8f2a1c;
  --stamp-dark: #6e1d14;
  --focus: #8f2a1c;
  --count: #2f5348;
  --shadow: 0 18px 40px -24px rgba(36, 28, 20, 0.45);
}

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

html {
  color: var(--ink);
  background: var(--paper);
  font-family: Figtree, "Segoe UI", sans-serif;
  line-height: 1.45;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  background:
    radial-gradient(1200px 500px at 10% -10%, #f7ecd6 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #e6d3b0 0%, transparent 50%),
    var(--paper);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  opacity: 0.14;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.masthead {
  max-width: 88rem;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.kicker {
  margin: 0 0 0.55rem;
  color: var(--stamp);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.masthead h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-optical-sizing: auto;
  font-size: clamp(2.4rem, 5vw, 4.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 0.92;
}

.lede {
  max-width: 38rem;
  margin: 0.9rem 0 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
  overflow-wrap: break-word;
}

.sources {
  max-width: 44rem;
  margin: 0.85rem 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  overflow-wrap: break-word;
}

.sources a {
  color: var(--stamp-dark);
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: minmax(18rem, 22rem) 1fr;
  gap: 0;
  max-width: 88rem;
  margin: 0 auto;
  min-height: calc(100vh - 10rem);
}

.ballot {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow: auto;
  padding: 1.4rem 1.35rem 2.5rem;
  background: linear-gradient(180deg, var(--sidebar) 0%, #e2d0af 100%);
  border-right: 1px solid var(--rule);
  box-shadow: inset -12px 0 24px -24px rgba(36, 28, 20, 0.35);
}

.policy input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.ballot-title {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.35rem;
}

.ballot-hint {
  margin: 0.25rem 0 1rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.policies {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.policy {
  display: grid;
  grid-template-columns: 1.15rem minmax(0, 1fr);
  gap: 0.7rem;
  padding: 0.7rem 0.2rem;
  border-top: 1px solid rgba(36, 28, 20, 0.08);
  cursor: pointer;
}

.policy:hover .policy-name {
  color: var(--stamp-dark);
}

.box {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.12rem;
  border: 2px solid var(--ink);
  background: var(--card);
}

.policy:has(input:checked) .box {
  background: var(--stamp);
  box-shadow: inset 0 0 0 2px var(--card);
}

.policy-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.policy-name {
  font-weight: 700;
  font-size: 0.98rem;
}

.policy-desc {
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.stage {
  padding: 1.4rem 1.5rem 3rem;
}

.stage-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.1rem;
}

.count {
  margin: 0;
  color: var(--count);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: 1.1rem;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--card-edge);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}

.tile:hover,
.tile:focus-visible {
  z-index: 2;
  border-color: var(--stamp);
}

.tile:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.tile-popup {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.9rem;
  overflow: auto;
  background: var(--card);
  color: var(--ink);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.tile:hover .tile-popup,
.tile:focus-visible .tile-popup {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.tile-popup-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile-popup-list li {
  padding: 0.28rem 0;
  border-top: 1px solid rgba(36, 28, 20, 0.08);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
}

.tile-popup-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.tile-popup-empty {
  margin: auto 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.tile > h2,
.tile > p {
  pointer-events: none;
}

.tile > h2 {
  margin: 0.85rem 0.9rem 0.15rem;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.55rem;
  line-height: 1;
}

.tile > p {
  margin: 0 0.9rem 1rem;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.poster {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 9.5rem;
  padding: 1.1rem 0.9rem;
  background: #f4efe4;
}

.poster .mark {
  position: absolute;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: transparent;
  
  
}

.poster img {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 100%;
  max-height: 7.2rem;
  object-fit: contain;
}

.poster-anc,
.poster-eff,
.poster-mk {
  background: #111;
}

.poster-anc .mark,
.poster-eff .mark,
.poster-mk .mark,
.poster-da .mark {
  color: #fff8ec;
}

.poster-ffplus,
.poster-acdp {
  background: #fff;
}

.poster-da {
  background: linear-gradient(160deg, #005baa 0%, #063a6b 100%);
}

.tile[hidden],
.empty[hidden] {
  display: none;
}

.empty {
  max-width: 36rem;
  margin: 2.5rem auto 0;
  padding: 1.8rem 1.6rem 2rem;
  background: var(--card);
  border: 2px solid var(--stamp);
  box-shadow: var(--shadow);
  text-align: left;
}

.empty-kicker {
  margin: 0 0 0.4rem;
  color: var(--stamp);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.empty-title {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.05;
}

.empty-body {
  margin: 0.8rem 0 0;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

.policy:has(input:focus-visible) .box {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .ballot {
    position: relative;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .masthead,
  .stage {
    padding-left: 1.15rem;
    padding-right: 1.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
