/*
 * Settings menu (settings-menu mission WP02; FR-001, FR-002, NFR-001, NFR-002,
 * contracts/settings-ui.md): the dialog of ui/settings-menu.js, the clear-data
 * confirmation (ui/clear-data-dialog.js) and the header's gear button
 * (app/shell.js). Tokens only (tokens.css); the dialog frame, buttons, inputs
 * and focus rings come from dialogs.css and base.css.
 *
 *   targets   every select, radio row, switch row and button is at least
 *             var(--touch-target) (44 px) tall; a radio or switch is a whole
 *             label row, so the text is part of the target
 *   width     the dialog is at most the viewport (dialogs.css); content never
 *             widens it (min-width: 0, wrapping text, selects shrink), so there
 *             is no sideways scroll at 360 px; long content scrolls inside
 *   colour    text uses --color-text / --color-text-muted (4.5:1 in both
 *             appearances); the danger button uses --color-danger, also 4.5:1
 */

/* ---------------------------------------------------------- gear button */

/* The name takes the free space, so the navigation and the gear sit at the
 * end, the gear last (also in a header without navigation). */
.site-header__home {
  margin-inline-end: auto;
}

.site-header__settings {
  flex: none;
  padding: var(--space-2);
}

.site-header__settings svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: currentColor;
}

/* On phones the navigation takes a row of its own: the gear stays on the
 * first row, beside the name, at the end. */
@media (max-width: 599.98px) {
  .site-header__settings {
    order: 1;
  }

  .site-header__nav {
    order: 2;
  }
}

/* ---------------------------------------------------------- the dialog */

.settings {
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.settings__body {
  gap: var(--space-4);
  min-width: 0;
}

.settings__body > * {
  min-width: 0;
}

.settings__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.settings__section {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-subtle);
}

.settings__heading {
  font-size: var(--text-section-title);
  line-height: var(--line-height-tight);
}

.settings__field {
  display: grid;
  gap: var(--space-1);
  justify-items: start;
  min-width: 0;
}

.settings__field > select {
  min-width: 10rem;
  max-width: 100%;
}

.settings__label {
  font-weight: var(--font-weight-semibold);
}

.settings .hint {
  color: var(--color-text-muted);
  font-size: var(--text-caption);
  overflow-wrap: anywhere;
}

.settings__total {
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.settings__note[hidden],
.settings__warning[hidden] {
  display: none;
}

.settings__status:empty,
.settings__announce:empty {
  display: none;
}

.settings__status,
.settings__announce {
  color: var(--color-text-muted);
  font-size: var(--text-caption);
}

.settings__warning {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-warning);
  border-left-width: 6px;
  border-radius: var(--radius-sm);
  background: var(--color-warning-surface);
  color: var(--color-text);
}

/* Radio groups: a fieldset with its legend, one row per choice. */
.settings__group {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.settings__group > legend {
  padding: 0;
  margin-bottom: var(--space-1);
}

.settings__radios {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-4);
}

.settings__radio,
.settings__switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch-target);
  cursor: pointer;
}

.settings__switch {
  font-weight: var(--font-weight-semibold);
}

.settings__radio input,
.settings__switch input {
  flex: none;
  min-height: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--color-accent);
  cursor: pointer;
}

/* ---------------------------------------------------------- clear-data popup */

/* Question, "Will be deleted" and "Will be kept" lists, then the buttons
 * (ui/clear-data-dialog.js). Text wraps, so the 360 px bottom sheet never
 * scrolls sideways; a long list scrolls inside the dialog. */
.settings-confirm {
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.settings-confirm .dialog__body {
  min-width: 0;
}

.settings-confirm .dialog__body > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.settings-confirm__heading {
  margin: var(--space-2) 0 0;
  font-size: var(--text-panel-title);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
}

.settings-confirm__list {
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding-inline-start: var(--space-5);
  color: var(--color-text);
}

.settings-confirm__list > li {
  line-height: var(--line-height);
}

/* ---------------------------------------------------------- danger action */

.button--danger {
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.button--danger:hover {
  background: var(--color-danger-surface);
  border-color: var(--color-danger);
}
