/*
  Quiz - one stylesheet, phone portrait first. Every page fills exactly the viewport
  (100dvh) and never scrolls as a whole: a question takes the height that is left, and whatever
  can grow (the answer and its background, the categories, a list) scrolls inside its own box.
*/

:root {
  --bg: #12131c;
  --panel: #1c1e2b;
  --panel-2: #272a3b;
  --line: #363a52;
  --text: #f1f2f8;
  --muted: #a3a8c0;
  --ink: #14151d;
  --accent: #ffd166;
  --danger: #ff8f8f;
  --well: #191b27;
  /* The colours of the categories, and green and red for right and wrong. */
  --cyan: #5fd4e8;
  --yellow: #ffd166;
  --violet: #b79cff;
  --green: #7bd88f;
  --red: #ff7a85;
  --blue: #6ea8ff;
  --orange: #ffa25e;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
p,
dl,
dd,
ol {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: -0.3px;
}

h1:focus,
.page:focus {
  outline: none;
}

a {
  color: var(--accent);
}

/* ---------- Boot screen (index.html, before .NET has started) ---------- */

.boot {
  height: 100dvh;
  display: grid;
  place-content: center;
  gap: 18px;
  justify-items: center;
}

.boot__brand,
.brand {
  font-weight: 900;
  letter-spacing: 4px;
  font-size: 26px;
}

.boot__brand span,
.brand span {
  color: var(--accent);
}

.boot__bar {
  width: 140px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.boot__bar i {
  display: block;
  height: 100%;
  width: var(--blazor-load-percentage, 8%);
  background: var(--accent);
  transition: width 0.2s;
}

#blazor-error-ui {
  display: none;
  position: fixed;
  inset: auto 0 0 0;
  z-index: 50;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: #3a1f24;
  color: var(--text);
  font-size: 14px;
}

#blazor-error-ui .reload {
  margin-left: 8px;
}

#blazor-error-ui .dismiss {
  float: right;
  border: 0;
  background: none;
}

/* ---------- Shell ---------- */

.app {
  position: relative;
  display: flex;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

@media (min-width: 640px) {
  /* A phone app on a big screen: keep it phone-shaped. */
  .app {
    max-width: 520px;
    margin-inline: auto;
    border-inline: 1px solid var(--line);
  }
}

.stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 12px;
}

.bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.bar__back {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
}

.bar__back svg,
.icon-button svg {
  width: 22px;
  height: 22px;
}

.bar h1 {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar__stats {
  display: flex;
  gap: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat small,
.label,
.eyebrow {
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.eyebrow {
  color: var(--accent);
}

/* ---------- Controls ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
}

.button:disabled {
  opacity: 0.4;
}

.button--danger {
  border-color: rgb(255 143 143 / 0.45);
  color: var(--danger);
}

.icon-button {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
}

.icon-button:disabled {
  opacity: 0.35;
}

.segmented {
  flex: none;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}

.segmented button {
  min-width: 0;
  height: 38px;
  padding: 0 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

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

.banner {
  flex: none;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgb(255 143 143 / 0.14);
  color: var(--danger);
  font-size: 12.5px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.card h2 {
  font-size: 15px;
}

.card p {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--muted);
}

.card p strong {
  color: var(--text);
}

/* ---------- Toast ---------- */

.toast-host {
  position: absolute;
  inset: auto 12px calc(16px + env(safe-area-inset-bottom)) 12px;
  z-index: 40;
  display: grid;
  justify-items: center;
  pointer-events: none;
}

.toast {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13.5px;
  font-weight: 650;
  animation: toast-in 0.18s ease-out;
}

.toast--refusal {
  border-color: rgb(255 143 143 / 0.5);
  color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}


/* ---------- Lists (statistics, the review at the end of a round) ---------- */

.list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 4px;
}

.row {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.row__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
}

.row__text strong {
  font-size: 15px;
  color: var(--text);
}

.row__percent {
  flex: none;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.meter {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--panel-2);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--tone, var(--accent));
}

/* ---------- Start page ---------- */

.home__top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.home__links {
  display: flex;
  gap: 8px;
}

.home__label {
  flex: none;
  margin: 2px 4px -2px;
}

.tally {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tally div {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.tally dt {
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.tally dd {
  font-size: 19px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.hero {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--ink);
  text-decoration: none;
}

.hero__icon {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgb(20 21 29 / 0.14);
}

.hero__icon svg {
  width: 26px;
  height: 26px;
}

.hero__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
  font-weight: 600;
}

.hero__text strong {
  font-size: 18px;
  font-weight: 850;
  letter-spacing: -0.2px;
}

/* A category's colour: one of the tokens, never a hex here. */
.tile--cyan { --tone: var(--cyan); }
.tile--yellow { --tone: var(--yellow); }
.tile--violet { --tone: var(--violet); }
.tile--green { --tone: var(--green); }
.tile--red { --tone: var(--red); }
.tile--blue { --tone: var(--blue); }
.tile--orange { --tone: var(--orange); }

.tiles {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: min-content;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 4px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.tile strong {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile__icon {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--tone) 16%, transparent);
  color: var(--tone);
}

.tile__icon svg {
  width: 21px;
  height: 21px;
}

.tile__note {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- A round ---------- */

.round__wait {
  margin: auto;
  color: var(--muted);
}

.progress {
  flex: none;
  height: 4px;
  border-radius: 2px;
  background: var(--panel-2);
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.25s;
}

/* The question, its answers and what is revealed scroll together inside this box. */
.question {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.question__meta {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.chip {
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 750;
  white-space: nowrap;
}

.chip--quiet {
  background: var(--panel-2);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.dots {
  margin-left: auto;
  display: flex;
  gap: 3px;
}

.dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
}

.dots i.on {
  background: var(--accent);
}

.question__text {
  flex: none;
  margin: 2px 0;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -0.2px;
}

.answers {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.answer {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  text-align: left;
}

.answer__letter {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 800;
}

.answer:disabled {
  cursor: default;
}

.answer--right {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 16%, var(--panel));
}

.answer--right .answer__letter {
  background: var(--green);
  color: var(--ink);
}

.answer--wrong {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 16%, var(--panel));
}

.answer--wrong .answer__letter {
  background: var(--red);
  color: var(--ink);
}

.answer--other {
  opacity: 0.45;
}

.reveal {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  font-size: 14px;
  line-height: 1.5;
  animation: reveal 0.22s ease-out;
  /* Brought into view after an answer - with the answers above it still in sight. */
  scroll-margin-top: 124px;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.reveal__verdict {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 17px;
  font-weight: 850;
}

.reveal__verdict small {
  font-size: 12px;
  font-weight: 750;
  color: var(--muted);
}

.reveal--right .reveal__verdict {
  color: var(--green);
}

.reveal--wrong .reveal__verdict {
  color: var(--red);
}

.reveal__background,
.review__background {
  color: var(--muted);
}

.reveal__known {
  font-size: 12px;
  color: var(--muted);
}

.round__next {
  flex: none;
  min-height: 50px;
  font-size: 16px;
}

.round__actions {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
}

.round__actions .button {
  min-height: 50px;
}

/* ---------- The end of a round ---------- */

.summary {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  text-align: center;
}

.summary__score {
  font-size: 40px;
  font-weight: 900;
  line-height: 1.1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.summary__score small {
  font-size: 14px;
  font-weight: 750;
  color: var(--muted);
}

.summary__line {
  font-size: 14px;
  font-weight: 700;
}

.summary__verdict {
  font-size: 13px;
  color: var(--muted);
}

.review {
  flex: none;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  font-size: 13.5px;
  line-height: 1.5;
}

.review summary {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

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

.review p {
  margin-top: 8px;
}

.review__mark {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--ink);
}

.review__mark svg {
  width: 15px;
  height: 15px;
}

.review--right .review__mark {
  background: var(--green);
}

.review--wrong .review__mark {
  background: var(--red);
}

/* ---------- Optionen ---------- */

.settings {
  gap: 12px;
  overflow-y: auto;
}

.settings .card {
  flex: none;
}

.settings__footer {
  padding: 4px;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
}
