/* layouts/settings. Wide, the sections sit in a sidebar. On a phone the hub
   (/settings) lists them as rows, and every other page swaps them for a link
   back up — so a page with .settings-back is never the hub. */
.settings {
  display: grid;
  gap: 1.5em 3em;
  align-items: start;

  h1 {
    font-size: 1.75em;
    text-align: left;
    margin: 0 0 0.75em;
  }

  h1 + * {
    margin-top: 0;
  }

  /* The listings centre their pager; here everything hangs off the left. */
  .pagination {
    align-items: flex-start;
  }

  /* Direct children only, so a form's error summary keeps its own h2. */
  .user-section > h2,
  .form-group > legend {
    font-size: 1.25em;
    font-weight: 900;
    color: var(--fg-color);
    margin: 0 0 0.75em;
    border-bottom: 0.0625rem solid var(--border-color);
  }
}

/* One row style at every width; a phone only makes the rows taller and adds a
   chevron. The list hangs into the gutter by its own padding, so the labels
   line up with the title above and the page's edge. */
.settings-nav {
  ul {
    list-style: none;
    margin: 0 -0.75em;
    padding: 0;
  }

  a {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0 0.75em;
    border-radius: 0.5em;
    color: var(--fg-color);
    font-weight: 600;

    /* A faint tint of the text colour rather than --bg-highlight-color: on
       dark that grey is brighter than the wash, and a hovered row would
       outshine the current one. */
    &:hover {
      color: var(--fg-color);
      text-decoration: none;
      background: color-mix(in oklab, var(--fg-color) 10%, transparent);
    }

    /* A bar as well as the wash, so the current section isn't told apart by
       colour alone. */
    &[aria-current] {
      background: var(--accent-wash-color);
      box-shadow: inset 0.1875rem 0 0 var(--link-color);
      border-radius: 0 0.5em 0.5em 0;
    }
  }
}

.settings-nav-title {
  margin: 0 0 0.5em;
  font-weight: 900;
}

.settings-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  min-height: 2.75rem;
  font-weight: bold;

  &::before {
    content: "";
    width: 0.5em;
    height: 0.5em;
    border: solid currentColor;
    border-width: 0 0 0.125em 0.125em;
    transform: rotate(45deg);
  }
}

@media screen and (width < 36em) {
  .settings:has(.settings-back) .settings-nav {
    display: none;
  }

  .settings-nav {
    /* The hub is the Account page, already showing below the list. */
    li:has(> a[aria-current]) {
      display: none;
    }

    a {
      justify-content: space-between;
      min-height: 3em;

      &::after {
        content: "";
        width: 0.5em;
        height: 0.5em;
        border: solid var(--mid-color);
        border-width: 0.125em 0.125em 0 0;
        transform: rotate(45deg);
      }
    }
  }

  .settings-nav-title {
    font-size: 1.75em;
  }
}

@media screen and (min-width: 36em) {
  .settings {
    max-width: 54em;
    grid-template-columns: 11em minmax(0, 1fr);
  }

  .settings-back {
    display: none;
  }

  .settings-nav-title {
    color: var(--mid-color);
  }
}

/* --link-color, not the raw accent: orange and teal fall to about 2:1
   as text on the light page. */
#user-sessions .item[aria-current] h3 {
  color: var(--link-color);
}
#user-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 1em;
  margin: 2em 0;

  .stat {
    padding: 0.75em 1em;
    border: 0.0625rem solid var(--border-color);
    border-radius: 0.5em;
  }

  a.stat {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: 0.2s ease all;

    /* The menu's hover. The number steps to the link hover colour as any
       link does, which also keeps the lighter accents legible on the grey. */
    &:hover {
      color: inherit;
      text-decoration: none;
      background: color-mix(in oklab, var(--fg-color) 10%, transparent);

      .stat-value {
        color: var(--link-hover-color);
      }
    }
  }

  .stat-value {
    display: block;
    font-size: 2em;
    font-weight: 900;
    line-height: 1.2;
    color: var(--link-color);
  }

  .stat-label {
    display: block;
    font-size: 0.875em;
    color: var(--mid-color);
  }
}

#user-details ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5em;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
}

.import-form {
  display: flex;
  align-items: center;
  gap: 0.5em;

  input[type="file"] {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    min-height: 2.75rem;
    /* WebKit ignores flex on a file input, so the picker is centred by
       symmetric padding instead — which lands the row at 44px on its own. */
    padding: 0.4em 0.5em;

    font-size: 0.875em;
    color: var(--mid-color);
    background: var(--bg-color);
    border: 0.0625rem solid var(--border-color);
    border-radius: 0.5em;

    &::file-selector-button {
      font: inherit;
      font-weight: bold;
      color: var(--fg-color);
      background: var(--bg-highlight-color);
      padding: 0.5em 1em;
      margin-right: 0.75em;
      border: none;
      border-radius: 0.375em;
      cursor: pointer;
      transition: 0.2s ease all;
    }

    /* The text stays put and the tile deepens: accent text on this grey
       drops below 2:1 under the lighter accents. */
    &::file-selector-button:hover {
      background: color-mix(in oklab, var(--fg-color) 18%, var(--bg-color));
    }
  }
}

@media screen and (max-width: 32em) {
  .import-form {
    flex-direction: column;
    align-items: stretch;

    /* Sized to its label, like the export button above it. */
    .button {
      align-self: flex-start;
    }
  }
}

.user-section {
  margin: 2em 0;
  ul {
    margin: 0;
  }
  code {
    font-family: ui-monospace;
    overflow-wrap: anywhere;
  }
  .token-copy {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5em 1em;

    code {
      display: inline-flex;
      align-items: center;
      box-sizing: border-box;
      min-height: 2.75rem;
      padding: 0 1em;
      background: var(--bg-highlight-color);
      border-radius: 0.5em;
    }
  }
}
#device-authorize {
  text-align: center;
  max-width: 24em;
  margin: 0 auto;
  form {
    margin: 0 auto;
  }
  /* The section is centred; the list of grants reads better left aligned. */
  .requested-scopes {
    display: inline-block;
    text-align: left;
    margin: 0.5em auto 1.5em;
  }
  .full-access-warning {
    color: var(--danger-color);
  }
  .deny-link {
    display: inline-block;
    font-weight: bold;
    color: var(--mid-color);
    &:hover {
      color: var(--danger-color);
    }
  }
}
#device-success {
  text-align: center;
}
