/*
 * Meldingen of the account (docs/planning/16-admin-design.md C5, templates/account/_notification_switches.html.twig): the two switches in the card of a
 * list, each a row of at least 72px with its title, the line under it and the switch at the end (51 x 31, as the switch of the points), and the line
 * under the card that says that messages are on for this phone.
 *
 * A row is one button (role="switch"): the whole row is the target and answers the finger, the focus ring is drawn inside it (the list clips its corners).
 */

@layer components {
  .switch-row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    width: 100%;
    min-height: 72px;
    margin: 0;
    padding: var(--s-2) var(--s-4);
    border: 0;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: start;
  }

  /* The line under a row is part of the row, as with the rows of the account (72px with its line). */
  .list > li:not(:last-child) > .switch-row {
    min-height: 71px;
  }

  .switch-row:focus-visible {
    outline-offset: -3px;
  }

  .switch-row:active {
    background: var(--surface-2);
  }

  .list > li:first-child > .switch-row {
    border-top-left-radius: var(--r-lg);
    border-top-right-radius: var(--r-lg);
  }

  .list > li:last-child > .switch-row {
    border-bottom-left-radius: var(--r-lg);
    border-bottom-right-radius: var(--r-lg);
  }

  .switch-row__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  /* A title that wraps keeps its lines together, as C5 draws "Aanbiedingen en nieuwe gerechten". */
  .switch-row__title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
  }

  .switch-row__sub {
    color: var(--muted);
    font-size: 0.875rem;
    line-height: 1.4;
  }

  .switch-row__switch {
    position: relative;
    flex: none;
    width: 51px;
    height: 31px;
    border-radius: var(--r-pill);
    background: var(--border-strong);
  }

  .switch-row__switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 25%, transparent);
  }

  .switch-row[aria-checked='true'] .switch-row__switch {
    background: var(--primary);
  }

  .switch-row[aria-checked='true'] .switch-row__switch::after {
    left: 23px;
    background: var(--on-primary);
  }

  @media (prefers-reduced-motion: no-preference) {
    .switch-row__switch,
    .switch-row__switch::after {
      transition:
        background-color 0.15s ease,
        left 0.15s ease;
    }
  }

  @media (hover: hover) and (pointer: fine) {
    .switch-row:hover {
      background: var(--surface-2);
      cursor: pointer;
    }
  }

  /* "Meldingen staan aan op deze telefoon. …": small and muted under the card, in its margins. */
  .notifications-note {
    margin: var(--s-3) var(--s-5) 0;
    color: var(--muted);
    font-size: 0.875rem;
    line-height: 1.45;
  }
}
