/* Cada case cabe num ecrã: história à esquerda, números e gráfico à direita. */
.case__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 0 clamp(1.5rem, 3vw, 3rem);
}

.case__story {
  display: flex;
  flex-direction: column;
}

.case__step {
  padding: 0.85rem 0;
  border-bottom: 1px dotted currentColor;
}

.case__step:last-child {
  border-bottom: 0;
}

.case__label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: var(--step--1);
  opacity: 0.75;
}

.case__step p {
  max-width: 52ch;
  font-size: 0.875rem;
  line-height: 1.55;
}

.case__check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
  padding: 0.1rem 0.6rem 0.1rem 0.45rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: var(--step--1);
  font-weight: 700;
}

.case__check svg {
  width: 0.85rem;
  height: 0.85rem;
}

.case__figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  border-bottom: 1px dotted currentColor;
}

.case__figure {
  padding: 0.85rem 1rem 0.85rem 0;
}

.case__figure:nth-child(-n + 2) {
  border-bottom: 1px dotted currentColor;
}

.case__figure dt {
  font-size: var(--step--1);
  opacity: 0.75;
}

.case__figure dd {
  margin: 0.15rem 0 0;
  font-size: clamp(1.35rem, 2.1vw, 1.85rem);
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.case__figure small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  line-height: 1.4;
  opacity: 0.75;
}

.case__evolution {
  padding-top: 0.85rem;
}

.case__evolution-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  margin-bottom: 0.4rem;
  font-size: var(--step--1);
}

.case__chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.case__chart text {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: currentColor;
}

.case__bar {
  cursor: default;
  outline: none;
}

.case__bar:focus-visible path {
  stroke: currentColor;
  stroke-width: 2;
  stroke-opacity: 0.5;
}

.case__bar:hover path {
  opacity: 0.8;
}

.case__tooltip {
  position: absolute;
  transform: translate(-50%, -100%);
  max-width: 18rem;
  padding: 0.45rem 0.65rem;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.75rem;
  line-height: 1.4;
  border-radius: 4px;
  pointer-events: none;
  z-index: 2;
}

.case__table {
  margin-top: 0.35rem;
  font-size: 0.75rem;
}

.case__table summary {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.case__table table {
  width: 100%;
  margin-top: 0.5rem;
  border-collapse: collapse;
}

.case__table th,
.case__table td {
  padding: 0.3rem 0.75rem 0.3rem 0;
  text-align: left;
  border-bottom: 1px dotted currentColor;
  font-variant-numeric: tabular-nums;
}

.case__table th {
  font-weight: 700;
}

.case__note {
  margin-top: 0.35rem;
  font-size: 0.7rem;
  line-height: 1.45;
  opacity: 0.75;
  max-width: 70ch;
}

.case__note--in-table,
.case__switch {
  display: none;
}

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

/* Telemóvel: a história e os números ficam em dois painéis lado a lado. A pasta fica
   com a altura do painel mais alto e cabe num ecrã, mesmo com as barras do browser. */
@media (max-width: 760px) {
  .case__switch {
    display: flex;
    gap: 0.4rem;
    padding: 0.6rem 0 0.15rem;
  }

  .case__switch button {
    padding: 0.3rem 0.7rem;
    border: 1px solid currentColor;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.72rem;
    cursor: pointer;
  }

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

  .case__body {
    display: flex;
    align-items: flex-start;
    gap: var(--gutter);
    margin: 0 calc(-1 * var(--gutter));
    padding: 0 var(--gutter);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .case__body::-webkit-scrollbar {
    display: none;
  }

  .case__story,
  .case__data {
    flex: 0 0 100%;
    scroll-snap-align: start;
  }

  .case__step {
    padding: 0.55rem 0;
  }

  .case__step p {
    font-size: 0.78rem;
    line-height: 1.45;
  }

  .case__label {
    margin-bottom: 0.2rem;
    font-size: 0.72rem;
  }

  .case__check {
    margin-bottom: 0.3rem;
    font-size: 0.72rem;
  }

  .case__figure {
    padding: 0.5rem 0.75rem 0.5rem 0;
  }

  .case__figure dt {
    font-size: 0.7rem;
  }

  .case__figure dd {
    font-size: 1.15rem;
  }

  .case__figure small {
    margin-top: 0.15rem;
    font-size: 0.65rem;
    line-height: 1.35;
  }

  .case__evolution {
    padding-top: 0.55rem;
  }

  .case__evolution-head {
    font-size: 0.72rem;
    margin-bottom: 0.2rem;
  }

  .case__note {
    display: none;
  }

  .case__note--in-table {
    display: block;
  }
}
