/* ==========================================================================
   ShareFam — rhythm.css
   The "Today Together" surface: the total, the household clock line, the
   degraded banner and the five source cards.

   DEV_GUIDE constraints this file is written to, and how each is met:

   #1  ZERO px. Every length here is rem, %, ch or a viewport unit. A single
       px would pin a family's chosen text size and make the 360-pixel-wide
       layout (#5) unreadable for anybody who scales their browser up.
   #2  Light AND dark. The tokens come from `sharefam.css`; this file adds
       only what a rhythm card needs, and adds it for BOTH themes — via
       `prefers-color-scheme` and the `[data-theme]` attribute the theme
       controller stamps, so the toggle wins over the OS in both directions.
   #4  A long day scrolls INSIDE its card rather than pushing the page; the
       dialog height cap (85vh AND 85dvh) lives in `sharefam.css`.
   #5  Mobile-first from a 360-pixel-wide viewport: one column by default, a
       grid only once there is room.
   #6  Motion 150-300ms, and NONE for a reader who asked for none.

   THE TONE OF A CARD IS NEVER THE ONLY SIGNAL. A source ShareFam could not
   read shows an em dash instead of a number, the server's own sentence, and
   a written warning — the colour is the third signal, not the first. Colour
   alone is unreadable for the ~1 in 12 readers with a colour vision
   deficiency and invisible to a screen reader for everyone.
   ========================================================================== */

.sf-rhythm-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  padding: 1rem 1.125rem;
  border: 0.0625rem solid var(--sf-border, rgba(15, 23, 42, 0.12));
  border-radius: 0.75rem;
  background: var(--sf-surface, #ffffff);
}

.sf-rhythm-summary__total {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.sf-rhythm-summary__note,
.sf-rhythm-summary__zone-note {
  font-size: 0.875rem;
  opacity: 0.8;
  flex: 1 1 16rem;
}

.sf-rhythm-summary__zone {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   The degraded banner. Never shown when nothing is wrong — a banner that is
   always there is a banner nobody reads.
   -------------------------------------------------------------------------- */
.sf-rhythm-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.875rem 1.125rem;
  border: 0.0625rem solid var(--sf-warn-border, rgba(180, 83, 9, 0.4));
  border-radius: 0.75rem;
  background: var(--sf-warn-surface, rgba(253, 230, 138, 0.25));
}

/* --------------------------------------------------------------------------
   The cards
   -------------------------------------------------------------------------- */
.sf-rhythm-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 48rem) {
  .sf-rhythm-grid {
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  }
}

.sf-rhythm-card {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 1.125rem;
  border: 0.0625rem solid var(--sf-border, rgba(15, 23, 42, 0.12));
  border-left-width: 0.25rem;
  border-radius: 0.75rem;
  background: var(--sf-surface, #ffffff);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.sf-rhythm-card[data-sf-tone="ok"] {
  border-left-color: var(--sf-accent, #4f46e5);
}

.sf-rhythm-card[data-sf-tone="muted"] {
  border-left-color: var(--sf-border, rgba(15, 23, 42, 0.25));
  opacity: 0.85;
}

.sf-rhythm-card[data-sf-tone="warn"] {
  border-left-color: var(--sf-warn-border, #b45309);
}

.sf-rhythm-card__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sf-rhythm-card__title {
  font-size: 1rem;
  font-weight: 650;
  margin: 0;
  flex: 1 1 auto;
}

.sf-rhythm-card__count {
  font-size: 1.375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
  text-align: right;
}

.sf-rhythm-card__message {
  margin: 0;
  font-size: 0.875rem;
  opacity: 0.85;
}

.sf-rhythm-card__warn {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--sf-warn-text, #92400e);
}

.sf-rhythm-card__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  /* A very busy day scrolls inside the card rather than pushing the rest of
     the page off the screen. */
  max-height: 18rem;
  overflow-y: auto;
}

.sf-rhythm-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
  padding: 0.375rem 0;
  border-top: 0.0625rem solid var(--sf-border, rgba(15, 23, 42, 0.08));
  font-size: 0.9375rem;
}

.sf-rhythm-item__label {
  flex: 1 1 12ch;
  overflow-wrap: anywhere;
}

.sf-rhythm-item__detail {
  font-size: 0.8125rem;
  opacity: 0.75;
  white-space: nowrap;
}

.sf-rhythm-card__more {
  margin: 0;
  font-size: 0.8125rem;
  opacity: 0.75;
}

/* --------------------------------------------------------------------------
   The four states every ShareFam surface ships
   -------------------------------------------------------------------------- */
.sf-rhythm-state {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1.25rem;
  border: 0.0625rem dashed var(--sf-border, rgba(15, 23, 42, 0.2));
  border-radius: 0.75rem;
  font-size: 0.9375rem;
}

.sf-rhythm-state__icon {
  font-size: 1.25rem;
  opacity: 0.7;
}

.sf-rhythm-state--error {
  border-style: solid;
  border-color: var(--sf-danger-border, rgba(190, 18, 60, 0.4));
}

.sf-rhythm-state--offline {
  border-color: var(--sf-warn-border, rgba(180, 83, 9, 0.4));
}

/* --------------------------------------------------------------------------
   Dark, both ways round: the OS preference AND the explicit toggle.
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  .sf-rhythm-summary,
  .sf-rhythm-card {
    background: var(--sf-surface, #111827);
    border-color: var(--sf-border, rgba(148, 163, 184, 0.25));
  }

  .sf-rhythm-card__warn {
    color: var(--sf-warn-text, #fbbf24);
  }
}

[data-theme="dark"] .sf-rhythm-summary,
[data-theme="dark"] .sf-rhythm-card {
  background: var(--sf-surface, #111827);
  border-color: var(--sf-border, rgba(148, 163, 184, 0.25));
}

[data-theme="dark"] .sf-rhythm-card__warn {
  color: var(--sf-warn-text, #fbbf24);
}

[data-theme="light"] .sf-rhythm-summary,
[data-theme="light"] .sf-rhythm-card {
  background: var(--sf-surface, #ffffff);
  border-color: var(--sf-border, rgba(15, 23, 42, 0.12));
}

[data-theme="light"] .sf-rhythm-card__warn {
  color: var(--sf-warn-text, #92400e);
}

/* --------------------------------------------------------------------------
   #6 — none of it for somebody who asked for none.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .sf-rhythm-card {
    transition: none;
  }
}
