/*
 * Signed-in portal pages: page heads, cards, tables, tabs and the printable
 * QR card. The sidebar and phone menu are in shell.css. Loaded after
 * portal.css, whose tokens it uses.
 */

.app .display {
  margin: 0;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.page-head .hint {
  margin-top: var(--space-2);
}

/* Facts under a page title, each with its icon. */
.meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  margin: var(--space-3) 0 0;
  padding: 0;
  color: var(--ink-mid);
  font-size: var(--text-sm);
  line-height: var(--leading-small);
  list-style: none;
}

.meta-list li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.meta-list .icon {
  width: 16px;
  height: 16px;
  color: var(--ink-dim);
}

.page-head-badges {
  display: flex;
  gap: var(--space-2);
}

.back {
  display: inline-block;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
}

.back::before {
  content: "\2190\00a0" / "";
}

.section {
  margin-top: var(--space-6);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 36px;
  margin-bottom: var(--space-3);
}

.section-head h2 {
  margin: 0;
}

.section-head a:not(.button) {
  font-size: var(--text-sm);
}

.banner {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--cream-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  line-height: var(--leading-small);
}

.banner-warning {
  background: var(--warning-tint);
}

.flash-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.flash {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--sage-tint);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  line-height: var(--leading-small);
}

.flash-error {
  background: var(--error-tint);
  color: var(--error-ink);
}

/* Cards, numbers, lists and tables. */

.totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin: 0 0 var(--space-4);
}

.totals .card {
  padding: var(--space-5);
}

.totals dt,
.facts dt {
  color: var(--ink-mid);
  font-size: var(--text-sm);
  line-height: var(--leading-small);
}

/* Figures are set in the display serif, with lining numerals so they read as
   data. Notes beside them stay in the sans. */
.totals dd {
  margin: var(--space-2) 0 0;
  font-family: var(--font-display);
  font-size: var(--text-figure);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
  font-variant-numeric: lining-nums tabular-nums;
}

.totals dd .of,
.totals dd .muted {
  font-family: var(--font-body);
  letter-spacing: 0;
}

.totals dd .muted {
  font-size: var(--text-sm);
  font-weight: 500;
}

.of {
  color: var(--ink-mid);
  font-size: var(--text-sm);
  font-weight: 500;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

/* A group on Home: name and privacy, where it is in its dates, two figures
   and a meter for how many sharing members practiced this week. */
.group-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 120ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.group-card:hover {
  border-color: var(--sage);
  box-shadow: 0 10px 28px rgba(44, 44, 42, 0.08);
  color: var(--ink);
  text-decoration: none;
  transform: translateY(-1px);
}

.group-card h3 {
  margin: 0;
  font-size: var(--text-md);
}

.group-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.group-privacy {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--space-1);
  margin-top: 3px;
  color: var(--ink-mid);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: var(--leading-small);
}

.group-privacy .icon {
  width: 14px;
  height: 14px;
}

.group-card-when {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: calc(-1 * var(--space-2)) 0 0;
  color: var(--ink-mid);
  font-size: var(--text-sm);
  line-height: var(--leading-small);
}

.group-card-when .icon {
  width: 15px;
  height: 15px;
  color: var(--ink-dim);
}

.group-card .hint {
  margin: 0;
}

.group-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6);
  margin: var(--space-2) 0 0;
}

.group-card-stats dt {
  color: var(--ink-mid);
  font-size: var(--text-sm);
  line-height: var(--leading-small);
}

.group-card-stats dd {
  margin: var(--space-1) 0 0;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
}

/* Notes beside a figure stay in the sans; "Not shared" is a note, not a figure. */
.group-card-stats dd .of,
.group-card-stats dd .muted {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
}

.meter {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--sage-tint);
}

.meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--sage);
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin: 0;
}

.facts dd {
  margin: var(--space-1) 0 0;
  text-wrap: pretty;
}

.card.list,
.table-card {
  padding: 0;
  overflow: hidden;
}

/* Positioned so hidden labels inside scroll with the table instead of
   widening the page. */
.table-card {
  position: relative;
  overflow-x: auto;
}

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

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
}

/* An alert: an icon for its type, what happened, and what can be done. Types
   that ask for an action take the warm tint. */
.alert-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
}

.alert-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sage-tint);
  color: var(--sage-ink);
}

.alert-icon .icon {
  width: 18px;
  height: 18px;
}

.alert-row.needs-action .alert-icon {
  background: var(--warning-tint);
  color: var(--warning-ink);
}

.alert-row.is-resolved .alert-icon {
  background: var(--cream-2);
  color: var(--ink-dim);
}

.list-row + .list-row,
.alert-row + .alert-row {
  border-top: 1px solid var(--line);
}

.alert-text {
  margin: 0 0 var(--space-1);
}

.alert-row.is-resolved .alert-text {
  color: var(--ink-mid);
}

.alert-actions {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Row controls match the small buttons beside them. */
.inline-form select {
  width: auto;
  height: 36px;
  min-height: 36px;
  padding: 0 34px 0 var(--space-3);
  background-position: right 12px center;
  font-size: var(--text-sm);
}

.row-between {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.row-between .hint {
  flex: 1 1 320px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  line-height: var(--leading-small);
}

.table th {
  min-width: 6.5rem;
  padding: var(--space-3);
  color: var(--ink-mid);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: left;
  text-wrap: balance;
  vertical-align: bottom;
}

.table th:first-child,
.table td:first-child {
  padding-left: var(--space-6);
}

.table th:last-child,
.table td:last-child {
  padding-right: var(--space-6);
}

.table td {
  padding: var(--space-3);
  border-top: 1px solid var(--line);
  vertical-align: middle;
  /* The card scrolls sideways on small screens instead of squeezing rows. */
  white-space: nowrap;
  transition: background-color 120ms ease;
}

.table tbody tr:hover td {
  background: rgba(237, 230, 214, 0.35);
}

/* Chip lists wrap inside their cell rather than stretching the table. */
.table td.chips {
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
  white-space: normal;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Text after a right-aligned number column starts clear of it. */
.table .num + :is(th, td):not(.num) {
  padding-left: var(--space-6);
}

.table .actions {
  text-align: right;
  white-space: nowrap;
}

.badge,
.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: var(--leading-small);
  white-space: nowrap;
}

.badge {
  background: var(--cream-2);
  color: var(--ink-mid);
}

.badge-active {
  background: var(--sage-tint);
  color: var(--sage-ink);
}

/* A live state carries a small dot. */
.badge-active::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 6px 1px 0;
  border-radius: 50%;
  background: currentColor;
  vertical-align: middle;
}

/* Ended is a plain state; the warm tint is kept for things that need a look. */
.badge-warning {
  background: var(--warning-tint);
  color: var(--ink);
}

.badge-archived {
  color: var(--ink-dim);
}

.badge-quiet {
  background: transparent;
  border: 1px solid var(--line);
}

.chip {
  margin: 0 4px 4px 0;
  background: var(--sage-tint);
  color: var(--sage-ink);
  font-weight: 500;
}

.chips {
  line-height: 1.9;
}

.person {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.person-large strong {
  display: block;
}

.display.person-large {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.person-large .avatar {
  width: 44px;
  height: 44px;
  font-size: var(--text-sm);
}

.avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--sage-light);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

.avatar-small {
  width: 30px;
  height: 30px;
}

/* Five earthy tints, picked from each person's name by the `tone` filter so a
   list of people isn't one block of sage. */
.avatar.tone-1 { background: #C4D4C6; color: #34463A; }
.avatar.tone-2 { background: #BCD8D5; color: #24524F; }
.avatar.tone-3 { background: #EBDCC0; color: #5E4A2A; }
.avatar.tone-4 { background: #E8CFC5; color: #6E4237; }
.avatar.tone-5 { background: #DCD8CE; color: #4A463E; }

.empty {
  padding: var(--space-7) var(--space-6);
  text-align: center;
}

/* A quiet icon above an empty state's title. */
.empty-mark {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: var(--space-4);
  border-radius: 50%;
  background: var(--sage-tint);
  color: var(--sage-ink);
}

.empty-mark .icon {
  width: 24px;
  height: 24px;
}

.empty p {
  max-width: 56ch;
  margin: 0 auto var(--space-4);
  color: var(--ink-mid);
}

.empty .button {
  margin-top: var(--space-2);
}

.empty-small {
  padding: var(--space-5);
}

.empty-small p {
  margin-bottom: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.tabs {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tabs a {
  padding: var(--space-3) var(--space-4);
  color: var(--ink-mid);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.tabs a:hover {
  color: var(--ink);
}

.tabs a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--sage-ink);
}

.tab-panel > .note,
.tab-panel > .hint {
  margin-bottom: var(--space-4);
}

/* The tab bar names the tab, so a tab opens with a one-line intro and, when
   it has one, its main action. */
.tab-panel > .tab-intro {
  max-width: 68ch;
  margin: 0 0 var(--space-5);
}

.tab-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.tab-head .hint {
  flex: 1 1 320px;
  max-width: 68ch;
}

.tab-panel > .hint:last-child {
  margin-top: var(--space-4);
}

.person-panel {
  margin-bottom: var(--space-6);
}

.person-panel .danger-zone {
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}

.handover {
  padding: var(--space-4);
  background: var(--cream);
  border-radius: var(--radius-sm);
}

/* Invite tab and the printable QR card. */

.invite-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: var(--space-4);
}

.invite-card .code {
  text-align: left;
  padding-left: 0;
}

.copy-field {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.copy-field .button {
  flex: none;
  white-space: nowrap;
}

.qr-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
}

.qr svg {
  display: block;
  width: 100%;
  height: auto;
}

.qr-card .qr {
  width: 100%;
  max-width: 200px;
}

.print-page {
  background: var(--card);
}

.print-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 480px;
  margin: var(--space-5) auto;
  padding: 0 var(--space-4);
}

.print-card {
  max-width: 480px;
  margin: 0 auto var(--space-7);
  padding: var(--space-7) var(--space-6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  text-align: center;
}

.print-org {
  color: var(--sage-ink);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: var(--text-sm);
}

.print-qr {
  width: 260px;
  margin: var(--space-5) auto;
}

.print-step {
  font-weight: 600;
}

.print-or,
.print-link {
  color: var(--ink-mid);
  font-size: var(--text-sm);
}

@media print {
  .print-toolbar {
    display: none;
  }

  .print-card {
    border: 0;
    margin-top: 0;
  }
}

@media (max-width: 900px) {
  .invite-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  /* The icon stays beside the alert; its actions sit under the text. */
  .alert-row {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: var(--space-3) var(--space-4);
  }

  .alert-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  .totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }

  /* An odd last figure takes the full row instead of sitting alone. */
  .totals > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .totals .card {
    padding: var(--space-4);
  }
}

@media (max-width: 480px) {
  .table th:first-child,
  .table td:first-child {
    padding-left: var(--space-5);
  }

  .table th:last-child,
  .table td:last-child {
    padding-right: var(--space-5);
  }

  .list-row,
  .alert-row {
    padding: var(--space-4) var(--space-5);
  }
}

/* A meter under a figure in a total card. */
.totals dd .meter {
  margin-top: var(--space-4);
}
