/* The Settings menu: one <details>, in application.html. On a narrow window
   it is a menu that opens above the page. On a wide one the page becomes two
   columns, and the menu is a sidebar: held open, with its summary hidden.
   TestBrowserSettingsMenuIsASidebarWideAndAMenuNarrow holds both. */
.settings-nav {
  margin: 1rem 1rem 0;

  summary {
    padding: 0.375rem 0.75rem;
    border: 0.0625rem solid var(--border-color);
    border-radius: var(--control-radius);
    font-weight: bold;
    cursor: pointer;
  }

  ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* Every entry is the same row, link or button. */
  :is(a, button) {
    display: block;
    box-sizing: border-box;
    width: 100%;
    padding: 0.375rem 0.75rem;
    border: none;
    border-radius: var(--control-radius);
    background: none;
    color: var(--fg-color);
    font: inherit;
    text-align: start;
    cursor: pointer;

    &:hover {
      background: var(--bg-highlight-color);
      text-decoration: none;
    }

    &:focus-visible {
      outline: 0.125rem solid var(--highlight-color);
    }
  }

  /* Where you are: the accent's tint and the weight. The text keeps the body
     colour, because the accent's ink only clears 4.5:1 on the plain page, and
     on its own tint every accent fell short of it in the light theme. */
  [aria-current="page"] {
    background: oklch(from var(--highlight-color) l c h / 0.1);
    font-weight: bold;
  }

  /* The way out of Settings, set apart from the pages in it. */
  .settings-nav-start {
    margin: 0.5rem 0;
    color: var(--mid-color);
  }

  form {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 0.0625rem solid var(--border-color);
  }
}

@media screen and (min-width: 48em) {
  body:has(> .settings-nav) {
    display: grid;
    grid-template-columns: 12rem minmax(0, 48rem);
    justify-content: center;
    align-items: start;
    column-gap: 3rem;
    padding: 1.5rem 1rem;

    & > article,
    & > article main {
      margin: 0;
    }

    & > article > .flash {
      margin: 0 0 1.5rem;
    }
  }

  .settings-nav {
    margin: 0;

    summary {
      display: none;
    }

    /* A closed <details> keeps its content out of the page. This lets it
       back in, so the sidebar needs no `open` and no script. */
    details::details-content {
      content-visibility: visible;
    }

    .settings-nav-start {
      margin-top: 0;
    }
  }
}
