[hidden] {
  display: none !important;
}

/* Two heights for every control: main actions and inputs, and small ones. */
:root {
  --control: 2.75rem;
  --control-sm: 2.25rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

header,
main {
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand.small {
  font-size: 1.15rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

main {
  flex: 1;
}

.icon {
  width: 1em;
  height: 1em;
  flex: none;
}

.muted {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

input,
textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.6rem 0.8rem;
}

input {
  height: var(--control);
  padding-block: 0;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--accent);
  border-radius: 0.6rem;
  height: var(--control);
  padding: 0 1.1rem;
  background: var(--accent);
  color: var(--accent-ink);
  line-height: 1;
  white-space: nowrap;
}

.icon {
  display: block;
}

/* A square button holding only an icon, as tall as its row. */
button.icon-only {
  width: var(--control);
  padding: 0;
}

button.quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.75rem 0;
}

.actions .spacer {
  flex: 1;
}

/* The round "i" in the header that opens the about dialog. */
.info-button {
  flex: none;
  width: var(--control-sm);
  height: var(--control-sm);
  padding: 0;
  border: 1.5px solid var(--ink-muted);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
  font: italic 700 1.05rem/1 Georgia, serif;
}

/* Short points, each led by its key words, rather than a block of text. */
.points {
  display: grid;
  gap: 0.7rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.points li {
  padding-left: 0.8rem;
  border-left: 3px solid var(--line);
}

/* Start */

.hero {
  margin: 1.5rem 0 1rem;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 2.8rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.hero-bars {
  position: relative;
  display: grid;
  gap: 0.35rem;
  margin: 1.5rem 0;
}

.hero-bars::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -0.3rem;
  bottom: -0.3rem;
  border-left: 2px solid var(--ink-muted);
}

/* Each bar grows out of the zero line, to the right unless it is .left. Only
   the outer end is round, as in the results. */
.hero-bars span {
  height: 0.55rem;
  width: var(--size);
  margin-left: 50%;
  border-radius: 0 1rem 1rem 0;
  background: var(--demo);
  transform-origin: left;
  animation: grow 0.8s ease-out both;
}

.hero-bars span.left {
  margin-left: calc(50% - var(--size));
  border-radius: 1rem 0 0 1rem;
  transform-origin: right;
}

.hero-bars span:nth-child(2) { animation-delay: 0.05s; }
.hero-bars span:nth-child(3) { animation-delay: 0.1s; }
.hero-bars span:nth-child(4) { animation-delay: 0.15s; }
.hero-bars span:nth-child(5) { animation-delay: 0.2s; }
.hero-bars span:nth-child(6) { animation-delay: 0.25s; }
.hero-bars span:nth-child(7) { animation-delay: 0.3s; }

.demo-1 { --demo: var(--demo-teal); }
.demo-2 { --demo: var(--demo-coral); }
.demo-3 { --demo: var(--demo-violet); }
.demo-4 { --demo: var(--demo-olive); }
.demo-5 { --demo: var(--demo-sky); }
.demo-6 { --demo: var(--demo-rose); }
.demo-7 { --demo: var(--demo-slate); }

@keyframes grow {
  from {
    transform: scaleX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-bars span {
    animation: none;
  }
}

.lead {
  margin: 0 0 0.6rem;
  font-size: 1.15rem;
}

/* The way into the guided tour, quiet beneath the instruction. */
button.how-to {
  height: var(--control-sm);
  padding: 0 0.9rem;
  background: var(--card);
  font-size: 0.9rem;
}

button.how-to:hover {
  border-color: var(--accent);
}

/* The tour: the page dims around one lifted control, a bubble explains it. */
#tour {
  position: fixed;
  inset: 0;
  z-index: 10;
}

#tour-spot {
  position: fixed;
  border-radius: 0.8rem;
  box-shadow: 0 0 0 200vmax var(--backdrop);
  outline: 2px solid var(--accent);
  transition: top 0.25s, left 0.25s, width 0.25s, height 0.25s;
  pointer-events: none;
}

#tour-bubble {
  position: fixed;
  width: min(20rem, calc(100% - 1.5rem));
  padding: 1rem 1rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 8px 30px var(--shadow);
  transition: top 0.25s, left 0.25s;
}

#tour-text {
  margin: 0 1.8rem 0.8rem 0;
}

.tour-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tour-actions .spacer {
  flex: 1;
}

.tour-actions button {
  height: var(--control-sm);
  padding: 0 0.85rem;
  font-size: 0.9rem;
}

#tour-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  border: none;
}

@media (prefers-reduced-motion: reduce) {
  #tour-spot,
  #tour-bubble {
    transition: none;
  }
}

.topic {
  display: grid;
  gap: 0.5rem;
  margin: 0.75rem 0;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--card);
}

.topic input,
.topic textarea {
  background: var(--paper);
}

.topic-head {
  display: flex;
  gap: 0.5rem;
}

.topic-name {
  flex: 1;
  font-weight: 600;
}

/* Beside the title, away from where one reaches when done. */
.topic .suggest {
  flex: none;
}

/* How much a topic counts: the card takes on more accent the more it counts. */
.topic[data-weight="2"] {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 5%, var(--card));
}

.topic[data-weight="4"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--card));
}

.topic[data-weight="2"] .weight {
  border-color: var(--accent);
  color: var(--accent);
}

.topic[data-weight="4"] .weight {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.topic .remove {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
  color: var(--danger);
}

.topic .remove:hover {
  border-color: var(--danger);
}

.topic .actions {
  margin: 0;
}

.topic .actions button,
#toggle-weights {
  height: var(--control-sm);
  padding: 0 0.85rem;
  font-size: 0.9rem;
}

.topic .actions .icon-only {
  width: var(--control-sm);
  padding: 0;
}

#key input {
  flex: 1;
  min-width: 12rem;
}

#key p {
  flex-basis: 100%;
  margin: 0;
}

#status:empty {
  display: none;
}

/* Results */

#results {
  margin-top: 1.5rem;
}

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}




#weights {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--card);
}

.weight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.95rem;
}

/* Three equal segments, as tall as a small button. */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.2rem;
  width: min(15rem, 62%);
  height: var(--control-sm);
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
}

.segmented button {
  height: 100%;
  padding: 0;
  border: none;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--ink);
  font-size: 0.85rem;
}

.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

.party {
  border-top: 1px solid var(--line);
}

.party summary {
  display: grid;
  grid-template-columns: 5.5rem 1fr 3.8rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.8rem 0;
  cursor: pointer;
  list-style: none;
}

.party summary::-webkit-details-marker {
  display: none;
}

.party .name {
  font-weight: 700;
}

.party .score {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* The score column carries a chevron, so rows read as something to open. */
.party .score::after {
  content: "›";
  display: inline-block;
  width: 0.8rem;
  margin-left: 0.3rem;
  text-align: center;
  color: var(--ink-muted);
  transition: transform 0.15s;
}

.party details[open] .score::after {
  transform: rotate(90deg);
}

/* Scores run from -10 on the left to +10 on the right; the line marks 0. */
.bar {
  position: relative;
  height: 0.7rem;
  border-radius: 1rem;
  background: var(--line);
}

.bar::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -0.2rem;
  bottom: -0.2rem;
  border-left: 2px solid var(--ink-muted);
}

/* Only the outer end is round; the end at the zero line is straight. */
.bar span {
  position: absolute;
  height: 100%;
  border-radius: 0 1rem 1rem 0;
  background: var(--party);
}

.bar span.against {
  border-radius: 1rem 0 0 1rem;
}

/* Parties with nothing on the person's topics come last, greyed, with a
   hatched bar where the score would be. */
.party.silent .row {
  display: grid;
  grid-template-columns: 5.5rem 1fr 3.8rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.8rem 0;
  color: var(--ink-muted);
}

.bar.empty {
  height: 1.3rem;
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(135deg, var(--line) 0 3px, transparent 3px 8px);
  font-size: 0.75rem;
}

.bar.empty::after {
  content: none;
}

.party.silent .score {
  padding-right: 1.1rem;
}

.party.silent .score::after {
  content: none;
}

/* Below the ranking, the way into how it came about. */
a.how {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--control);
  margin-top: 1.25rem;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: var(--card);
  color: var(--ink);
  font-size: 0.95rem;
  text-decoration: none;
}

a.how:hover {
  border-color: var(--accent);
}

/* A party's topics by source. */
.topics {
  width: 100%;
  /* Equal columns for the three sources, whatever their headings say. */
  table-layout: fixed;
  border-collapse: collapse;
  margin: 0 0 1rem;
  font-size: 0.9rem;
}

.topics thead th {
  /* Over the middle of the cells beneath, not left where the row's text starts. */
  text-align: center;
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--ink-muted);
  padding: 0 0.1rem 0.3rem;
}

.topics tbody th {
  /* Room for two lines on every row, so rows keep one height whatever the title. */
  height: 3.3rem;
  text-align: left;
  font-weight: 600;
  padding: 0.25rem 0.5rem 0.25rem 0;
  border-top: 1px solid var(--line);
}

.topics tbody th span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.topics td {
  width: 22%;
  text-align: center;
  padding: 0.25rem 0.1rem;
  border-top: 1px solid var(--line);
}

.topics thead td {
  width: 34%;
  text-align: left;
  padding-bottom: 0.3rem;
  border-top: none;
}

.topics .off {
  opacity: 0.35;
}

.cell {
  width: 100%;
  height: var(--control-sm);
  padding: 0;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--neutral);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cell[aria-expanded="true"] {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
}

.topics .evidence td {
  width: auto;
  text-align: left;
  border-top: none;
  padding: 0 0 0.75rem;
}

.evidence-card {
  padding: 0.8rem 0.9rem;
  border-radius: 0.8rem;
  background: var(--card);
  font-size: 0.95rem;
}

.evidence-card > p {
  margin: 0 0 0.5rem;
}

.evidence-card > p:last-child {
  margin: 0;
}

.verdict {
  font-weight: 700;
}

.divergence {
  font-size: 0.85rem;
  color: var(--warning);
}

.quote {
  margin: 0;
}

.quote blockquote {
  margin: 0;
  font-style: italic;
}

.quote blockquote.clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
}

.quote mark {
  background: var(--highlight);
  color: var(--ink);
}

.quote figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin-top: 0.5rem;
}

/* The whole passage first, the source at the end of the line. */
.quote figcaption .text-button {
  order: -1;
}

.quote figcaption a.source {
  margin-left: auto;
}

/* Until the key sentences arrive: lines in place of the quote, so it does not jump. */
.quote blockquote.loading {
  display: grid;
  gap: 0.5rem;
  padding: 0.3rem 0;
}

.quote blockquote.loading span {
  height: 0.8rem;
  border-radius: 0.4rem;
  background: var(--line);
  animation: pulse 1.2s ease-in-out infinite alternate;
}

.quote blockquote.loading span:last-child {
  width: 60%;
}

@keyframes pulse {
  to {
    opacity: 0.4;
  }
}

/* Sources read as citations, not as calls to action. */
a.source {
  color: var(--ink-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

a.source:hover {
  color: var(--ink);
  text-decoration: underline;
}

.text-button {
  height: auto;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink);
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.vote-list {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.vote {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
}

.vote .badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  margin-top: 0.1rem;
  border-radius: 50%;
  font-weight: 700;
  color: var(--paper);
  background: var(--neutral);
}

.vote.agree .badge {
  background: var(--agree-strong);
}

.vote.disagree .badge {
  background: var(--disagree-strong);
}

.vote a.source {
  color: var(--ink);
  font-size: 0.95rem;
}

.vote-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* About */

dialog {
  width: min(40rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: var(--paper);
  color: var(--ink);
}

dialog::backdrop {
  background: var(--backdrop);
}

.dialog-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

#close-sources {
  width: var(--control-sm);
  height: var(--control-sm);
  padding: 0;
}

.disclosure {
  margin: 1rem 0;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.disclosure summary {
  cursor: pointer;
  font-weight: 600;
}

dialog a {
  font-size: 0.9rem;
  color: var(--accent);
}

#program-list {
  list-style: none;
  padding: 0;
}

#program-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0 0.5rem 0.8rem;
  border-left: 3px solid var(--party);
  margin: 0.6rem 0;
}

a.pdf {
  flex: none;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  color: var(--ink);
  font-size: 0.85rem;
  text-decoration: none;
}

#program-list p {
  margin: 0;
}

.program-title {
  font-weight: 600;
}

#website-list {
  font-size: 0.85rem;
  padding-left: 0;
  list-style: none;
}

#website-list li {
  padding-left: 0.6rem;
  border-left: 3px solid var(--party);
  margin: 0.25rem 0;
}

@media (max-width: 34rem) {
  body {
    font-size: 16px;
  }

  header,
  main {
    padding: 0.75rem 1rem;
  }

  .party summary,
  .party.silent .row {
    grid-template-columns: 4.8rem 1fr 3rem;
    gap: 0.6rem;
  }

  .topics {
    font-size: 0.85rem;
  }

  .topics thead td {
    width: 28%;
  }

  .topics thead th {
    font-size: 0.68rem;
  }

  /* A sheet from the bottom, as phones show dialogs. */
  dialog {
    width: 100%;
    max-width: none;
    max-height: 100%;
    margin: auto 0 0;
    border-radius: 0.8rem 0.8rem 0 0;
  }
}

/* LEVELS in js/analysis.js, from Klarer Widerspruch (0) to Klare Übereinstimmung (4). */
.level-0 { color: var(--disagree-strong); }
.level-1 { color: var(--disagree); }
.level-2 { color: var(--neutral); }
.level-3 { color: var(--agree); }
.level-4 { color: var(--agree-strong); }

/* Party colors */
.party-afd { --party: var(--afd-blue); }
.party-bsw { --party: var(--bsw-orange); }
.party-fdp { --party: var(--fdp-yellow); }
.party-gruene { --party: var(--gruene-green); }
.party-linke { --party: var(--linke-magenta); }
.party-spd { --party: var(--spd-red); }
.party-union { --party: var(--union-black); }

/* While Jev works: the start page's bars, growing and shrinking as if the ranking were taking shape. */
#thinking {
  margin: 1.5rem 0;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--card);
  text-align: center;
}

#thinking p {
  margin: 0.25rem 0 0;
}

#thinking-count {
  font-weight: 600;
}

.hero-bars.thinking {
  margin: 0.5rem 0 1.25rem;
}

.hero-bars.thinking span {
  animation: think 1.6s ease-in-out infinite alternate;
}

.hero-bars.thinking span:nth-child(2n) { animation-duration: 1.2s; }
.hero-bars.thinking span:nth-child(3n) { animation-duration: 2s; }

@keyframes think {
  from {
    transform: scaleX(0.25);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-bars.thinking span,
  .quote blockquote.loading span {
    animation: none;
  }
}
