/* Wave 8: the inbox, the conflict banner, presence and the offline line.

   Loads after hub.css and the earlier waves, so a rule at equal specificity
   here wins. Tokens come from hub.css :root and wave5-tokens.css. Nothing
   here moves on its own: the rows are a data-freq high surface, the banner
   fades in on one opacity transition and the chip ticks on the spring. */

/* ---- Inbox head and tabs ---------------------------------------------- */

.inbox-head {
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--s3) var(--s5);
}

.inbox-tabs .segment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* The unread count inside a segment: ink on the quiet segment, lime on the
   dark one, so it reads in both states. */
.inbox-tab-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  box-sizing: border-box;
  border-radius: var(--r-pill);
  background: var(--neutral-200);
  color: var(--ink);
  font-size: var(--fs-label);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.segment.is-active .inbox-tab-count,
.segments.has-indicator .segment.is-active .inbox-tab-count {
  background: var(--forest-700);
  color: var(--lime);
}

/* Without the segments controller the active segment paints itself. */
.inbox-tabs .segment.is-active {
  background: var(--ink);
  color: var(--lime);
}

/* ---- Rows ------------------------------------------------------------- */

/* The unread mark: a forest dot before the name and the name in the heavy
   weight. Read rows keep the dot's space so names stay aligned. */
.inbox-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: transparent;
  vertical-align: middle;
  transition: background var(--dur-fast) var(--ease-out);
}

.needs-row.is-unread .inbox-dot {
  background: var(--forest-500);
}

.needs-row.is-unread .needs-who {
  font-weight: 700;
}

.needs-row:not(.is-unread) .needs-what {
  color: var(--ink-soft);
}

/* Back from a snooze: the chip says so, in front of the sentence. */
.inbox-returned {
  margin-right: 6px;
  vertical-align: 1px;
}

/* The custom date inside the dots menu: a field and a quiet link on one
   line, never a second pill beside Done. */
.inbox-snooze-date {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
}

.inbox-snooze-date .input {
  flex: 1 1 auto;
  min-width: 0;
}

/* The Inbox link on the Today card: the count sits as a small chip. */
.today-inbox-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Ink on lime, like the nav badge, so the number reads as the same count. */
.inbox-link-chip {
  padding: 1px 7px;
  background: var(--ink);
  border-color: var(--ink);
  color: var(--lime);
}

/* ---- Conflict banner (04 R14) ----------------------------------------- */

/* Yellow because the save did not happen, not red because nothing is lost:
   her text is still in the fields under it. */
.conflict-banner {
  background: var(--warn-soft);
  border: 1px solid oklch(0.80 0.08 70);
  border-radius: var(--r-sm);
  padding: 12px 16px;
  color: var(--warn-ink);
  margin-bottom: var(--s4);
}

.conflict-banner strong {
  color: var(--warn-ink);
}

.conflict-banner p {
  margin: 0;
}

.conflict-diff {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  font-size: var(--fs-sm);
}

.conflict-diff li {
  display: grid;
  grid-template-columns: minmax(80px, 120px) 1fr 1fr;
  gap: 10px;
}

.conflict-diff li > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.conflict-diff .conflict-field {
  font-weight: 700;
}

.conflict-diff .conflict-theirs::before,
.conflict-diff .conflict-yours::before {
  display: block;
  font-size: var(--fs-label);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.conflict-diff .conflict-theirs::before { content: "Theirs"; }
.conflict-diff .conflict-yours::before { content: "Yours"; }

.conflict-actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 600px) {
  .conflict-diff li {
    grid-template-columns: 1fr;
    gap: 2px;
    padding-bottom: 6px;
    border-bottom: 1px solid oklch(0.88 0.04 70);
  }
}

/* ---- Presence ("Katie is editing") ----------------------------------- */

.presence-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  white-space: nowrap;
}

.presence-chip:empty {
  display: none;
}

.presence-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--forest-500);
  animation: presence-tick 2.4s var(--ease-spring) infinite;
}

@keyframes presence-tick {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(.7); opacity: .55; }
}

@media (prefers-reduced-motion: reduce) {
  .presence-chip::before {
    animation: none;
  }
}

/* Under the editor title: the subtitle and the chip on one line, the chip
   pushed to the right. */
.editor-sub-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  flex-wrap: wrap;
}

.editor-sub-row .editor-sub {
  margin: 0;
}

/* The chip on the library row sits after the title, before the meta. */
.script-row-main .presence-chip {
  margin-left: 8px;
}

/* ---- Offline line (04 R15) ------------------------------------------- */

/* One thin line, above everything, no layout shift: fixed to the top and
   the page keeps its own padding. On a phone it sits under the safe area. */
.offline-banner {
  position: fixed;
  top: var(--safe-t);
  left: 0;
  right: 0;
  z-index: calc(var(--z-nav) + 3);
  padding: 6px 16px;
  text-align: center;
  font-size: var(--fs-sm);
  font-weight: 600;
  background: var(--warn-soft);
  color: var(--warn-ink);
  border-bottom: 1px solid oklch(0.80 0.08 70);
  opacity: 1;
  transition: opacity var(--dur-base) var(--ease-out);
}

.offline-banner.is-back {
  background: var(--success-tint);
  color: var(--ok-ink);
  border-bottom-color: oklch(0.80 0.08 150);
}

.offline-banner[hidden] {
  display: none;
}
