/* Colours, shapes and sizes follow trainlocal.app. The typefaces do not: its
   two are licensed and cannot go in a public repository, so this page uses the
   one the visitor's device already has. */
:root {
  color-scheme: light dark;

  /* The same colours trainlocal.app uses. */
  --paper: #f5f7f8;
  --surface: #ffffff;
  --ink: #121823;
  --soft: #5a6577;
  --line: rgb(18 24 35 / 0.14);
  --brand: #1e47d8;
  --button: #0f1622;
  --on-button: #ffffff;
  /* One colour per tray. They carry meaning, so they are used nowhere else. */
  --complaint: #c93a2b;
  --praise: #0b6b3a;
  --question: #7a2fb8;
  --none: #5a6577;

  @media (prefers-color-scheme: dark) {
    --paper: #0b111a;
    --surface: #0f1622;
    --ink: #eef2f5;
    --soft: #93a0b4;
    --line: rgb(255 255 255 / 0.12);
    --brand: #7c93ff;
    --button: #f5f7f8;
    --on-button: #0b111a;
    --complaint: #f0705e;
    --praise: #7fd9a0;
    --question: #c4a1ff;
    --none: #93a0b4;
  }

  accent-color: var(--brand);
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 106.25%;
  line-height: 1.65;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

main,
footer,
.masthead {
  max-width: 68rem;
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2.5rem);
}

main > * + * {
  margin-block-start: clamp(2.5rem, 6vw, 4rem);
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.3rem, 7vw, 4.2rem);
  font-weight: 600;
  letter-spacing: -0.03em;
}

h2 {
  font-size: clamp(1.625rem, 1.3rem + 1.2vw, 2.25rem);
}

h3 {
  font-size: 1.1875rem;
  line-height: 1.3;
}

b,
strong,
dt {
  font-weight: 500;
}

p {
  margin: 0;
  max-width: 62ch;
}

a {
  color: inherit;
  text-decoration-color: var(--brand);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
  transition: color 150ms ease;
}

a:hover {
  color: var(--brand);
}

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

.quiet {
  color: var(--soft);
  font-size: 0.92rem;
}

.problem {
  color: var(--complaint);
}

/* ---- Top of the page */

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 4.75rem;
  border-block-end: 1px solid var(--line);
}

.masthead a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  text-decoration: none;
}

.wordmark {
  gap: 0.6rem;
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.masthead a:not(.wordmark) {
  color: var(--soft);
  font-size: 0.94rem;
}

.masthead a:not(.wordmark):hover {
  color: var(--ink);
}

.intro {
  padding-block-start: clamp(2.5rem, 9vw, 6rem);
}

.intro p {
  margin-block-start: 1.1rem;
  font-size: 1.15rem;
  color: var(--soft);
}

/* ---- The form */

.desk {
  display: grid;
  gap: 0.7rem;
  max-width: 46rem;
}

.desk label {
  font-weight: 500;
}

textarea {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--surface);
  color: inherit;
  font: inherit;
  resize: vertical;
}

textarea::placeholder {
  color: var(--soft);
  opacity: 0.75;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.1rem;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button[type='submit'] {
  min-height: 2.9rem;
  padding: 0.6rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--button);
  color: var(--on-button);
  font-weight: 500;
}

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

#status {
  flex: 1 1 16rem;
  font-size: 0.92rem;
  color: var(--soft);
}

#status.problem {
  color: var(--complaint);
}

progress {
  width: 100%;
  height: 0.5rem;
}

.tryouts {
  margin-block-start: 0.6rem;
  font-size: 0.92rem;
  color: var(--soft);
}

.tryouts ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.tryouts button {
  min-height: 2.75rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding-inline: 1.1rem;
  background: var(--surface);
  text-align: start;
}

.tryouts button:hover {
  border-color: var(--brand);
}

/* ---- The answer */

[data-tray='Complaint'] {
  --tray: var(--complaint);
}

[data-tray='Praise'] {
  --tray: var(--praise);
}

[data-tray='Question'] {
  --tray: var(--question);
}

[data-tray='none'] {
  --tray: var(--none);
}

.answer {
  max-width: 46rem;
}

#answer {
  margin-block-start: 0.9rem;
  min-height: 11rem;
}

#answer > * + * {
  margin-block-start: 0.8rem;
}

blockquote {
  margin: 0;
  padding-inline-start: 0.9rem;
  border-inline-start: 3px solid var(--line);
  color: var(--soft);
}

.verdict strong {
  display: block;
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--tray);
}

.bars {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.bars > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 1rem;
}

.bars dt {
  font-weight: 500;
}

.bars dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.bar {
  grid-column: 1 / -1;
  height: 0.5rem;
  border-radius: 999px;
  background: linear-gradient(var(--tray) 0 0) no-repeat var(--line);
  background-size: calc(var(--share) * 100%) 100%;
  transition: background-size 0.35s ease-out;
}

/* ---- The trays */

.trays {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr));
  gap: 0.9rem;
  margin-block-start: 1rem;
}

.tray {
  min-height: 8.5rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--line);
  border-block-start: 3px solid var(--tray);
  border-radius: 0.625rem;
  background: var(--surface);
}

.tray h3 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--tray);
}

.count {
  font-variant-numeric: tabular-nums;
  color: var(--soft);
  font-weight: 500;
}

.tray ul {
  display: grid;
  gap: 0.45rem;
  margin: 0.7rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.92rem;
}

.tray li {
  padding-block-end: 0.45rem;
  border-block-end: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.tray li:first-child {
  animation: land 0.3s ease-out;
}

@keyframes land {
  from {
    opacity: 0;
    translate: 0 -0.5rem;
  }
}

/* ---- How it was made */

.how ol {
  display: grid;
  gap: 1.6rem;
  margin: 1.2rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.how li {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  column-gap: 0.9rem;
  counter-increment: step;
}

.how li::before {
  content: counter(step);
  grid-row: span 3;
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.how li > * {
  grid-column: 2;
}

.how h3 {
  padding-block-start: 0.45rem;
}

.how p {
  margin-block-start: 0.35rem;
  color: var(--soft);
}

pre {
  margin: 0.7rem 0 0;
  padding: 1rem 1.1rem;
  border-radius: 0.625rem;
  background: var(--surface);
  border: 1px solid var(--line);
  overflow-x: auto;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  tab-size: 2;
}

/* ---- Good to know */

.facts dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1.3rem 2.2rem;
  margin: 1.1rem 0 0;
}

.facts dt {
  color: var(--ink);
}

.facts dd {
  margin: 0.2rem 0 0;
  color: var(--soft);
}

footer {
  margin-block: clamp(3rem, 8vw, 5rem) 2rem;
  padding-block-start: 1.2rem;
  border-block-start: 1px solid var(--line);
  color: var(--soft);
  font-size: 0.92rem;
}

@media (prefers-reduced-motion: reduce) {
  .bar,
  .tray li:first-child {
    transition: none;
    animation: none;
  }
}
