/* components — the shared primitives from ui.js and the blocks in
   public/js/components/. See public/css/app.css for the tokens.

   Tokens only; every rule works in both themes. Motion is transform/opacity
   only, and the app-wide reduce-motion switch in app.css (the media query and
   :root[data-reduce-motion]) stops all of it. Targets are 44px, primary
   actions 48px; nothing is set under 11px and no sentence under 13px. */

/* ------------------------------------------------------------ screen head */
/* A real <h1>, one sentence on what the screen is for, and a door to its
   help sheet. The purpose line steps aside after the first few visits. */
.screen-head { margin: var(--sp-1) 2px var(--sp-4); }
.screen-head-row { display: flex; align-items: center; gap: var(--sp-2); min-height: var(--tap-min); }
.screen-head h1 {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--font-display); font-size: var(--fs-h1); font-weight: 700;
  letter-spacing: -.01em; line-height: 1.15; color: var(--ink);
}
/* Focus lands here after every navigation, for a screen reader. It is not a
   control, so it does not draw a ring. */
.screen-head h1:focus { outline: none; }
.screen-head-action { flex: none; display: flex; align-items: center; gap: var(--sp-2); }
.purpose {
  margin-top: var(--sp-1); max-width: 36em;
  font-size: var(--fs-body); line-height: 1.5; color: var(--ink-2);
}
.help-btn {
  flex: none; color: var(--ink-3);
  border-color: var(--line-soft); background: var(--surface);
}
.help-btn:hover { color: var(--accent-text); }

/* ---------------------------------------------------------- help + terms */
.help-purpose { font-size: var(--fs-md); line-height: 1.55; color: var(--ink); margin-bottom: var(--sp-1); }
.help-can {
  margin: 0 0 var(--sp-1); padding-left: 20px;
  font-size: var(--fs-body); line-height: 1.55; color: var(--ink-2);
}
.help-can li + li { margin-top: 6px; }
.help-can li::marker { color: var(--ink-3); }
.help-guide { margin-top: var(--sp-4); }

/* A glossary word the person can tap. The padding and the equal negative
   margin cancel out in the line, but give the finger a 44px-tall target. */
.term {
  display: inline; appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; color: inherit; letter-spacing: inherit; text-align: inherit;
  padding: 12px 1px; margin: -12px -1px;
  text-decoration: underline dotted;
  text-decoration-color: color-mix(in srgb, var(--accent-text) 70%, transparent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  border-radius: var(--r-xs);
}
.term:hover { color: var(--accent-text); }
.term:focus-visible { outline: 2px solid var(--accent-text); outline-offset: -8px; }
.term-short { font-size: var(--fs-md); line-height: 1.55; color: var(--ink); }
.term-why { font-size: var(--fs-body); line-height: 1.6; color: var(--ink-2); }
.term-see { margin-top: var(--sp-1); }

/* ---------------------------------------------------------------- overline */
/* The uppercase label above groups and previews, with a hairline beside it —
   the same voice as .section-title, one step quieter. */
.overline {
  display: flex; align-items: center; gap: var(--sp-2);
  margin: var(--sp-5) 2px var(--sp-2);
  font-family: var(--font-display); font-size: var(--fs-overline); font-weight: 650;
  text-transform: uppercase; letter-spacing: .08em; line-height: 1.3; color: var(--ink-3);
}
.overline::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.card > .overline:first-child,
.sheet-body > .overline:first-child { margin-top: 0; }

/* sectionTitle() is an <h2> now. It keeps the overline look it always had. */
.section-title > h2 {
  margin: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
}

/* ---------------------------------------------------------------- items */
/* The one row shape. A real <button> whenever it goes somewhere, with a
   chevron, so no row has to be guessed at. */
.item {
  position: relative;
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; min-height: 56px; padding: 10px 12px;
  border: 0; border-radius: var(--r); background: transparent;
  color: var(--ink); font: inherit; text-align: left;
}
button.item {
  appearance: none; cursor: pointer;
  transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
button.item:active { background: var(--surface-2); }
button.item:focus-visible { outline: 2px solid var(--accent-text); outline-offset: -2px; border-radius: var(--r); }
button.item:disabled { opacity: .5; cursor: not-allowed; }

.item-lead {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.2rem; line-height: 1;
  background: color-mix(in srgb, var(--seaglass) 14%, var(--surface));
  color: var(--accent-text);
}
.item-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-title { display: block; font-size: var(--fs-md); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.item-sub { display: block; font-size: var(--fs-note); line-height: 1.45; color: var(--ink-3); }
.item-meta {
  flex: none; font-size: var(--fs-note); color: var(--ink-3);
  font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap;
}
.item-chev { flex: none; display: grid; place-items: center; color: var(--ink-3); margin-right: -4px; }
.item > .tag { flex: none; }

.item.tone-ok .item-lead { background: color-mix(in srgb, var(--ok) 15%, var(--surface)); color: var(--ok-text); }
.item.tone-warn .item-lead { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); color: var(--warn-text); }
.item.tone-plum .item-lead { background: color-mix(in srgb, var(--plum) 16%, var(--surface)); color: var(--plum-text); }

/* Rows stacked inside a card: flush to the card's edges, separated by a
   hairline that starts under the text rather than under the icon. */
.card.item-group { padding: var(--sp-1) 0; }
.item-group > .item { border-radius: 0; padding: 10px var(--pad); }
.item-group > .item:first-child { border-top-left-radius: var(--r-lg); border-top-right-radius: var(--r-lg); }
.item-group > .item:last-child { border-bottom-left-radius: var(--r-lg); border-bottom-right-radius: var(--r-lg); }
.item-group > .item + .item::before,
.item-group > .switch-row + .switch-row::before {
  content: ''; position: absolute; top: 0; right: 0; left: var(--pad);
  height: 1px; background: var(--line-soft); pointer-events: none;
}
.item-group > .item.has-lead + .item.has-lead::before { left: calc(var(--pad) + 40px + var(--sp-3)); }

/* ---------------------------------------------------------------- switch */
/* A real checkbox with role=switch under the styling. The whole row is its
   label, so the target is the row (52px), not the 51 × 31 track. */
.switch-row {
  position: relative;
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px var(--sp-3);
  min-height: 52px; padding: var(--sp-2) 0; margin: 0;
  cursor: pointer;
}
.item-group > .switch-row { padding: 10px var(--pad); }
.switch-text { flex: 1 1 0; min-width: 0; }
.switch-text .lbl { display: inline; font-size: var(--fs-md); font-weight: 600; line-height: 1.35; color: var(--ink); }
.switch-text .hint { display: block; margin-top: 2px; font-size: var(--fs-note); line-height: 1.45; color: var(--ink-3); }
.switch-text .field-saved { margin-left: var(--sp-2); }
.switch-row .field-error { flex-basis: 100%; margin: 0; }

.switch { position: relative; flex: none; width: 51px; height: 31px; }
.switch .switch-input {
  position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: pointer;
}
/* app.css dims anything aria-busy; the real input must stay invisible. */
.switch .switch-input[aria-busy="true"] { opacity: 0; }
.switch-track {
  position: absolute; inset: 0; border-radius: var(--r-pill);
  background: var(--line-soft);
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  transition: background var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: var(--ink-inv);
  box-shadow: 0 1px 3px rgba(6, 37, 52, .28), 0 0 0 .5px rgba(6, 37, 52, .12);
  transition: transform var(--dur-2) var(--ease);
}
.switch-input:checked + .switch-track { background: var(--grad-accent); box-shadow: none; }
.switch-input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch-input:focus-visible + .switch-track { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.switch-input:disabled { cursor: not-allowed; }
.switch-input:disabled + .switch-track { opacity: .45; }
.switch-row.is-disabled { cursor: not-allowed; }
.switch-row.is-disabled .lbl { color: var(--ink-3); }
/* Saving: a small ring turns inside the thumb until the server answers. */
.switch-input[aria-busy="true"] + .switch-track .switch-thumb::after {
  content: ''; position: absolute; inset: 6px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-right-color: transparent;
  animation: ss-spin .8s linear infinite;
}

/* ---------------------------------------------------------- busy buttons */
/* action() marks a running button aria-busy; say so with more than a fade. */
.btn[aria-busy="true"]::after {
  content: ''; flex: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: ss-spin .8s linear infinite;
}
@keyframes ss-spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------------------- disclose */
.disclosure > summary {
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: var(--tap-min); cursor: pointer; list-style: none;
  font-size: var(--fs-body); font-weight: 600; color: var(--accent-text);
  border-radius: var(--r-xs);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.disclosure-chev { flex: none; display: grid; place-items: center; transition: transform var(--dur-2) var(--ease); }
.disclosure[open] > summary .disclosure-chev { transform: rotate(180deg); }
.disclosure-body { padding-top: var(--sp-2); }
.disclosure[open] > .disclosure-body { animation: ss-reveal var(--dur-2) var(--ease); }
@keyframes ss-reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- empty v2 */
/* What this is → what it will look like → one action. */
.empty { text-align: center; padding: var(--sp-6) var(--sp-3); color: var(--ink-2); }
.empty .glyph {
  width: 56px; height: 56px; margin: 0 auto var(--sp-3);
  display: grid; place-items: center; border-radius: 50%;
  font-size: 1.6rem; line-height: 1; opacity: 1;
  background: color-mix(in srgb, var(--seaglass) 14%, var(--surface));
}
.empty h3 { font-size: var(--fs-h3); font-weight: 650; color: var(--ink); line-height: 1.3; }
.empty p {
  max-width: 30em; margin: 6px auto 0;
  font-size: var(--fs-body); line-height: 1.5; color: var(--ink-2);
}
.empty-actions {
  display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-2);
  max-width: 320px; margin: var(--sp-4) auto 0;
}
.empty-actions .btn.primary { min-height: var(--tap); }
.empty-preview { margin-top: var(--sp-5); text-align: left; }
.empty-preview .overline { margin: 0 0 var(--sp-2); }
/* A picture of what will appear, not content: faded, untouchable, and fading
   out toward the bottom so it never reads as the real thing.
   Scoped to the preview wrapper on purpose. `ghost` is also the name of a
   button style (.btn.ghost), and a bare .ghost rule made every one of the
   seventy-odd ghost buttons in the app half-transparent and untappable —
   sheet Cancel buttons included. */
.empty-preview > .ghost {
  opacity: .5; pointer-events: none; user-select: none; -webkit-user-select: none;
  filter: saturate(.7);
  -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
}
.empty-preview > .ghost .card { box-shadow: none; }

/* ---------------------------------------------------------------- hints */
/* A first-use callout. Calm: the accent wash, never a warning colour, and
   it sits in the flow, so it cannot cover a primary action. */
.hint-callout {
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-1) var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
  border-radius: var(--r); background: var(--seaglass-wash);
  border: 1px solid color-mix(in srgb, var(--seaglass) 30%, transparent);
  color: var(--ink);
  animation: ss-hint-in var(--dur-3) var(--ease);
}
.hint-callout-icon { flex: none; padding-top: 10px; color: var(--accent-text); }
.hint-callout p { padding-top: 10px; font-size: var(--fs-note); line-height: 1.5; }
.hint-callout .hint-callout-action { margin: 2px 0 -4px -10px; color: var(--accent-text); }
.hint-callout .hint-close { flex: none; color: var(--ink-3); }
@keyframes ss-hint-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- shared tag */
/* "Changes it for both of you" — information, not a warning. */
.tag.shared-tag { background: var(--seaglass-wash); color: var(--accent-text); }
.tag.shared-tag svg.icon { margin-left: -1px; }

/* ------------------------------------------------------------- step dots */
.step-dots { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 12px; }
.step-dots i {
  display: block; width: 8px; height: 8px; border-radius: var(--r-pill);
  background: var(--line-strong); opacity: .45;
}
.step-dots i.done { background: var(--seaglass); opacity: .55; }
.step-dots i.on { width: 22px; background: var(--seaglass); opacity: 1; }

/* A tag that is also a button (Trends' provenance tags, say) keeps the tag's
   small look but gets a 44px hit area: a fixed box centred on it, whatever
   height the tag renders at. */
button.tag {
  position: relative; appearance: none; border: 0; cursor: pointer;
  font-family: inherit; line-height: inherit;
}
button.tag::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: max(calc(100% + 6px), 44px); height: max(100%, 44px);
  transform: translate(-50%, -50%);
}
button.tag:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* ui.js confirmSheet() and other one-message sheets */
.sheet-msg { margin-bottom: var(--sp-4); font-size: var(--fs-body); line-height: 1.55; color: var(--ink-2); }
/* Consequence copy is easier to read in paragraphs than as one block; the
   wrapper keeps the single-sentence case byte-for-byte what it was. */
.sheet-msg-group p + p { margin-top: var(--sp-2); }

/* ================================================= shared component blocks */

/* challenge.js — the rest of the card and the compact row live in crew.css */
.challenge-mini .bar { width: 100%; }

/* log.js */
.log-list { margin-bottom: 0; }

/* privacy.js — .privacy-intro and .privacy-preview-text are declared in
   settings.css, which loads after this file and owns the privacy block's type.
   Two copies of one rule drift apart, so only that one is kept. */
.card.privacy-preview {
  background: var(--seaglass-wash);
  border-color: color-mix(in srgb, var(--seaglass) 30%, transparent);
  box-shadow: none;
}
.privacy-preview .overline::after { background: color-mix(in srgb, var(--seaglass) 30%, transparent); }

/* datasource.js */
.datasource-intro { margin-bottom: var(--sp-3); line-height: 1.5; }
.datasource-block.is-onboarding .datasource-actions { gap: var(--sp-2); }
.datasource-block.is-onboarding .btn.primary { min-height: var(--tap); }
.datasource-note { margin-top: var(--sp-4); line-height: 1.6; }

/* invite.js */
.invite-lead { margin-bottom: var(--sp-3); line-height: 1.5; }
.invite-note { margin-top: var(--sp-3); line-height: 1.5; }
.invite-done { margin-top: var(--sp-3); }
.invite-block .btn.primary { min-height: var(--tap); }

/* phone.js */
.phone-status { display: flex; align-items: flex-start; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.phone-status-icon {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--seaglass) 14%, var(--surface));
  color: var(--accent-text);
}
.phone-status b { display: block; font-size: var(--fs-md); line-height: 1.35; margin-bottom: 2px; }
.phone-steps {
  margin: 0 0 var(--sp-3); padding-left: 22px;
  font-size: var(--fs-body); line-height: 1.6; color: var(--ink-2);
}
.phone-steps li + li { margin-top: var(--sp-1); }
.phone-inline-icon { display: inline-flex; vertical-align: -3px; color: var(--accent-text); }
.phone-block .btn.primary { min-height: var(--tap); }
