/* Settings v0.2 (increment SET, owner item 11): the six groups and their jump
 * list, Categories and Paid-from sources (money-cards.js), Days until due,
 * Evening nudge and Day start (day-cards.js); in step 2, the Devices card's sync
 * lines and revoke question, and This device: Photos on mobile data, Reset this
 * device and About.
 *
 * Built in the wireframe's card language (docs/ui/MOCKUP.html) on views.css's
 * `.card` — colour from tokens.css only, light and dark; every control 44 px
 * (--touch); a visible focus ring on every one; nothing wider than a 360 px
 * phone. Green is structure (the group headings, a chosen chip), as tokens.css
 * says. */

/* ------------------------------------------------------ the jump list */

.set-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
}

.set-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: var(--text-md);
  font-weight: 600;
  text-decoration: none;
}

.set-nav__link:hover {
  border-color: var(--accent);
}

.set-nav__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* -------------------------------------------------------- the six groups */

/* S: a jump lands the label a small step under the screen's top edge, not
 * flush against it. With the phone's 15 px label the page's heights are no
 * longer whole pixels, and a flush landing left the label a fifth of a pixel
 * ABOVE the edge on a 3x screen (test_settings_v2.py holds it at 0 to 16). */
.set-group__title {
  scroll-margin-top: var(--space-1);
  margin: var(--space-8) 0 calc(-1 * var(--space-2));
  padding-top: var(--space-2);
  color: var(--accent);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.set-group__title:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* --------------------------------------------- Categories, Paid-from sources */

.set-row {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.set-row:last-child {
  border-bottom: 0;
}

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

.set-row__main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  overflow-wrap: anywhere;
}

.set-row__name {
  font-weight: 600;
}

.set-row__edit {
  flex: none;
}

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

.set-editor {
  margin: var(--space-2) 0 var(--space-1);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}

.set-editor .field {
  margin-bottom: var(--space-3);
}

.set-editor .card__detail {
  margin: var(--space-2) 0 0;
}

/* The editor's own Save, green as every Save is (.btn--primary), but the
 * width of its words: Turn off and Cancel sit beside it on a 360 phone. */
.set-editor__save {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.set-editor__save:hover:not(:disabled) {
  border-color: var(--ps-green-deep);
}

/* What a write just did, under the row it changed. */
.set-row__said {
  margin: var(--space-1) 0 0;
}

.set-add {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.set-add .field {
  margin-bottom: var(--space-3);
}

/* One question's answers: its words in front, then the chips (the keypad's
 * `How it was paid:` row, keypad.js). */
.set-choices {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
}

.set-choices__label {
  flex: 0 0 100%;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

/* 12 px a side, so a source's four answers sit on one line of a 390 phone. */
.chip.set-choice {
  min-height: var(--touch);
  padding: 0 var(--space-3);
  font-size: var(--text-base);
}

.chip.set-choice[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.chip.set-choice:disabled {
  opacity: 0.6;
}

/* -------------------------------------------------------- Days until due */

.set-days__row {
  display: grid;
  grid-template-areas:
    "label box"
    "unit box";
  grid-template-columns: minmax(0, 1fr) 5rem;
  align-items: center;
  column-gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.set-days__row:last-child {
  border-bottom: 0;
}

.set-days__label {
  grid-area: label;
  font-weight: 600;
}

.set-days__input {
  grid-area: box;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.set-days__input[aria-invalid="true"],
.set-time__input[aria-invalid="true"] {
  border-color: var(--danger);
}

.set-days__unit {
  grid-area: unit;
  color: var(--ink-muted);
  font-size: var(--text-md);
}

.set-card__actions {
  margin-top: var(--space-4);
}

/* ------------------------------------------------- Evening nudge, Day start */

.set-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--touch);
  margin: 0 0 var(--space-3);
  cursor: pointer;
  font-weight: 600;
}

.set-toggle__box {
  flex: none;
  width: 1.375rem;
  height: 1.375rem;
  margin: 0;
  accent-color: var(--accent);
}

.set-toggle__box:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.set-time {
  max-width: 11rem;
}

/* The hour, as the time chips write a time (capture.css .chip--time). */
.set-value {
  margin: 0 0 var(--space-2);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.1;
}

/* ---------------------------------------- Settings → Devices (SET step 2) */

/* Under a device, what the Sync audit says of it: when it last sent and received. */
.devices__sync {
  margin: var(--space-1) 0 0;
}

/* The revoked devices, under their own small heading after the ones in use:
 * history, quieter, with nothing to press. */
.devices__gone {
  margin-top: var(--space-6);
}

.devices__gone:empty {
  display: none;
}

.devices__item--revoked .card__name {
  color: var(--ink-muted);
}

.devices__revoked-at {
  color: var(--danger);
  font-weight: 600;
}

/* The question a revoke asks, in the device's own row, edged in the danger
 * colour as the destructive step it is. Its confirm is a danger-outlined
 * button: the first tap only opens the question, the second acts. */
.devices__revoke,
.devices__name,
.set-reset__ask {
  margin: var(--space-3) 0 var(--space-1);
  padding: var(--space-3);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}

.devices__revoke-title,
.set-reset__question {
  margin: 0 0 var(--space-2);
  color: var(--ink);
  font-weight: 700;
}

/* Naming a device (review round 1): the same box, not a warning — green, not red. */
.devices__name {
  border-left-color: var(--accent);
}

.devices__name .field {
  margin: 0 0 var(--space-1);
}

.devices__name .card__detail,
.devices__revoke .card__detail {
  margin: 0 0 var(--space-2);
}

.devices__revoke-warn,
.set-reset__warn {
  color: var(--warn-ink);
  font-weight: 600;
}

.devices__revoke-go,
.set-reset__go {
  border-color: var(--danger);
  color: var(--danger);
}

.devices__revoke-go:hover:not(:disabled),
.set-reset__go:hover:not(:disabled),
.devices__revoke-open[aria-expanded="true"] {
  border-color: var(--danger);
}

/* What takes the focus without being a control — a question's first line, the
 * card's words after a revoke — shows where it is. */
.devices__revoke-title:focus-visible,
.set-reset__question:focus-visible,
.devices .card__status:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------- This device (SET step 2) */

/* Photos on mobile data: what the link is now, under the switch's words. */
.set-wifi__now {
  margin: var(--space-2) 0 0;
  color: var(--ink);
  font-size: var(--text-base);
  font-weight: 600;
}

/* About: a term and its value per row, the term a narrow column. */
.set-about {
  margin: 0;
}

.set-about__row {
  display: grid;
  grid-template-columns: minmax(6.5rem, 34%) minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.set-about__row:last-child {
  border-bottom: 0;
}

.set-about__term {
  color: var(--ink-muted);
  font-size: var(--text-md);
  font-weight: 600;
}

.set-about__value {
  margin: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.set-about__detail {
  display: block;
  margin-top: var(--space-1);
  color: var(--ink-faint);
  font-size: var(--text-sm);
}

/* A device's lines sit close under its name, as one entry: V3T's were spaced
 * as separate paragraphs, and with the sync line a row grew tall. */
.devices__item > .card__name,
.devices__item > .card__detail {
  margin: var(--space-1) 0 0;
}

.devices__item > .card__name {
  margin-top: 0;
}

.devices__item > .devices__token-state {
  margin-bottom: var(--space-2);
}

.devices__gone-title {
  margin: 0;
}
