/* The Room stats screen (docs/design/room-stats.md), on top of `activity.css`
 * and `projects.css`.
 *
 * It takes the board's place the way Settings does, so it reuses the strip,
 * the heading and the notices, and adds the period buttons, a column per room
 * and the pairs table. The rooms stand side by side when the panel is wide
 * enough (`.settings-head` widens the panel at 46rem) and stack otherwise.
 *
 * The charts carry one colour: the accent for the length bars, and the
 * accent mixed into the empty cell's surface for the grid, more sprints more
 * accent. Words on and around them stay in the text colours. */

.rs-screen {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

/* A new period keeps the old figures on screen, faded, until the new ones
 * arrive: no blank screen and no jump. */
.rs-screen.htmx-request > :not(.rs-loading) {
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.rs-loading {
  margin: 0;
  padding: 2rem 0;
  color: var(--muted);
  text-align: center;
}

/* --- The period buttons and what they measure ----------------------------- */

.rs-periods {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

button.rs-period {
  min-height: 2rem;
  padding: 0.2rem 0.8rem;
  font-size: 0.85rem;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
}

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

.rs-range {
  margin: 0;
  font-weight: 500;
}

.rs-rules,
.rs-capped,
.rs-no-access-line,
.rs-tz {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

/* A room the reader can't open, in italics as Discord writes one. */
.rs-no-access {
  font-style: italic;
  font-weight: inherit;
}

.rs-rules p {
  margin: 0;
}

/* --- One column per room -------------------------------------------------- */

.rs-rooms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 0.75rem;
  min-width: 0;
}

.rs-room {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(0.8rem, 3vw, 1.1rem);
}

.rs-room-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.rs-figs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.rs-fig {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.rs-fig-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.rs-fig-value {
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.15;
}

/* The one figure that is a total for the period, not a rate: its own line,
 * under a rule, in the body's size. */
.rs-apart {
  margin: 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.rs-apart strong {
  color: var(--ink);
  font-weight: 600;
}

.rs-lengths,
.rs-heat {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.rs-chart-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Tall enough for the bars and both axis titles, so the canvas never scrolls
 * inside its own box. */
.rs-chart {
  position: relative;
  height: 11rem;
  min-width: 0;
}

.rs-say {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* --- The busiest-times grid ---------------------------------------------- */

.rs-grid {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  /* The surface between cells separates them: no borders drawn on the data. */
  border-spacing: 2px;
  font-size: 0.66rem;
  color: var(--muted);
}

.rs-grid th {
  font-weight: 400;
  white-space: nowrap;
}

.rs-grid thead th {
  text-align: left;
  padding: 0 0 0.1rem;
}

.rs-grid thead td:first-child,
.rs-grid tbody th {
  width: 2rem;
  text-align: left;
  padding-right: 0.2rem;
}

.rs-cell {
  height: 0.95rem;
  padding: 0;
  border-radius: 2px;
  background: color-mix(in oklab, var(--accent) calc(var(--v, 0) * 100%), var(--surface-2));
  cursor: default;
}

.rs-cell:hover,
.rs-cell.is-tipped {
  outline: 1px solid var(--ink);
  outline-offset: -1px;
}

.rs-legend {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.rs-legend-caption {
  margin-right: 0.3rem;
}

.rs-ramp {
  flex: 0 1 7rem;
  height: 0.55rem;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--surface-2),
    color-mix(in oklab, var(--accent) 18%, var(--surface-2)),
    var(--accent)
  );
}

/* The one tooltip, beside whichever cell is under the pointer. */
.rs-tip {
  position: fixed;
  z-index: 50;
  max-width: 16rem;
  padding: 0.4rem 0.55rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  pointer-events: none;
}

.rs-tip[hidden] {
  display: none;
}

/* --- The pairs table ------------------------------------------------------ */

.rs-pairs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.rs-pairs h2 {
  margin: 0;
  font-size: 1.05rem;
}

.rs-pairs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.rs-pairs-table th,
.rs-pairs-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.6rem 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.rs-pairs-table thead th {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.rs-pairs-table tbody th {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.rs-pairs-table td p {
  margin: 0;
}

.rs-pairs-table td p + p {
  margin-top: 0.3rem;
}

/* A phone's width: each pair as a block, its three parts one under another. */
@container panel (max-width: 30rem) {
  .rs-pairs-table thead {
    display: none;
  }

  .rs-pairs-table,
  .rs-pairs-table tbody,
  .rs-pairs-table tr,
  .rs-pairs-table th,
  .rs-pairs-table td {
    display: block;
  }

  .rs-pairs-table tr {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
  }

  .rs-pairs-table th,
  .rs-pairs-table td {
    border-bottom: 0;
    padding: 0.2rem 0;
  }
}

/* --- Nothing to show, and failures ---------------------------------------- */

.rs-empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(0.8rem, 3vw, 1.1rem);
}

.rs-empty h2 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}

.rs-empty p {
  margin: 0;
  color: var(--muted);
}

.rs-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

button.rs-retry {
  min-height: 2rem;
  padding: 0.2rem 0.8rem;
}
