/* The account pages (/account): forms and cards on the site's tokens
 * (style.css, loaded first). */

/* `hidden` always hides: the script shows and hides steps, the busy box
 * and fields with it, and a rule that sets `display` would otherwise win
 * over the browser's own [hidden] { display: none }. */
[hidden] {
  display: none !important;
}

.account-main {
  padding: 2.5rem 0 3rem;
}

#account {
  max-width: 40rem;
}

#account h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.2;
  margin: 0 0 0.75rem;
}

#account h2 {
  font-size: 1.15rem;
  margin: 0 0 0.5rem;
}

#account p {
  color: var(--muted);
}

.step {
  margin-bottom: 2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.25rem 1rem;
  margin: 0 0 1.25rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  margin: 0 0 1rem;
}

.field > span {
  font-weight: 600;
  font-size: 0.95rem;
}

.field input,
.field select {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}

.field input:focus-visible,
.field select:focus-visible,
#account button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field input.code {
  font-family: var(--font-mono);
  letter-spacing: 0.2em;
  max-width: 12rem;
}

.password {
  display: flex;
  gap: 0.5rem;
}

.password input {
  flex: 1;
  min-width: 0;
}

#account button {
  font: inherit;
  font-weight: 600;
  color: var(--fg);
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  cursor: pointer;
}

#account button:hover:not(:disabled) {
  border-color: var(--accent);
}

#account button:disabled {
  opacity: 0.55;
  cursor: default;
}

#account button.primary {
  background: var(--grad);
  color: var(--accent-fg);
  border-color: transparent;
}

#account button.danger {
  color: #fff;
  background: var(--del);
  border-color: transparent;
}

#account button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 0.5rem 0 0.75rem;
}

.check {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin: 0.75rem 0;
}

.hint,
#account .small {
  font-size: 0.9rem;
  font-family: inherit;
}

.strength[data-level="weak"] {
  color: var(--del);
}

.strength[data-level="ok"] {
  color: var(--accent-2);
}

.strength[data-level="strong"] {
  color: var(--add);
}

#account .error {
  color: var(--del);
  font-weight: 600;
}

.status {
  border: 1px solid var(--line);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  color: var(--fg);
}

.recovery-key,
#backup-list {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  background: var(--code-bg);
  color: var(--fg);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: all;
}

.busy {
  position: sticky;
  top: calc(var(--header-h) + 0.5rem);
  z-index: 5;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
}

.spinner {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    rotate: 360deg;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

.manage-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.muted {
  color: var(--muted);
}

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

.list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 0.75rem 0;
}

.list li .what {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.list li .what span {
  color: var(--muted);
  font-size: 0.9rem;
}

.list li .actions-inline {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.list li input {
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg);
}

.table-wrap {
  overflow-x: auto;
}

#activity {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

#activity th,
#activity td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.qr svg {
  width: 13rem;
  height: 13rem;
  background: #fff;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
}

#totp-secret {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.account-foot {
  border-top: 1px solid var(--line);
  padding: 1.5rem 16px;
  text-align: center;
  font-size: 0.9rem;
}

/* The manage page: a menu of sections beside the one open. */

#account[data-page="manage"] {
  max-width: 64rem;
}

/* The cards of each step and section count from 01. */
.step,
.manage-section {
  counter-reset: card;
}

/* A card holds a form: it stays put under the pointer. */
#account .card:hover {
  translate: none;
  box-shadow: var(--shadow);
}

#account h3 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

.manage-head {
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.75rem;
}

.manage-head h1 {
  margin-bottom: 0.25rem;
}

.manage-head p {
  margin: 0;
  overflow-wrap: anywhere;
}

.manage-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

.manage-nav {
  position: sticky;
  top: calc(var(--header-h) + 1rem);
  min-width: 0;
}

.manage-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.25rem;
}

.manage-nav a {
  display: grid;
  gap: 0.1rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--fg);
  text-decoration: none;
  min-width: 0;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.manage-nav a:hover {
  background: var(--bg-soft);
}

.manage-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.manage-nav a[aria-current="page"] {
  background: var(--accent-soft);
  border-color: var(--line);
  box-shadow: inset 3px 0 0 var(--accent);
}

.manage-nav .name {
  font-weight: 600;
}

.manage-nav .about {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.manage-sections {
  min-width: 0;
}

.manage-sections > .status {
  margin: 0 0 1rem;
}

.section-head {
  margin-bottom: 1rem;
}

#account .section-head h2 {
  font-size: 1.35rem;
  margin: 0 0 0.2rem;
}

.section-head h2:focus {
  outline: none;
}

.section-head p {
  margin: 0;
}

/* Forms read better narrower than the column. */
.manage-section .field,
.manage-section .check {
  max-width: 30rem;
}

.card.danger-zone {
  border-color: color-mix(in srgb, var(--del) 45%, var(--line));
}

.card.danger-zone h3 {
  color: var(--del);
}

/* Narrow screens: the menu becomes a row of tabs that scrolls sideways. */
@media (max-width: 52rem) {
  .manage-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .manage-nav {
    top: var(--header-h);
    z-index: 4;
    background: var(--bg);
    margin: 0 -16px;
    padding: 0.5rem 16px;
    border-bottom: 1px solid var(--line);
  }

  .manage-nav ul {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }

  .manage-nav ul::-webkit-scrollbar {
    display: none;
  }

  .manage-nav li {
    flex: none;
    scroll-snap-align: start;
  }

  .manage-nav a {
    white-space: nowrap;
    padding: 0.45rem 0.8rem;
  }

  .manage-nav a[aria-current="page"] {
    box-shadow: inset 0 -2px 0 var(--accent);
  }

  .manage-nav .about {
    display: none;
  }
}

@media (min-width: 40rem) and (max-width: 52rem) {
  .manage-nav {
    margin: 0 -24px;
    padding: 0.5rem 24px;
  }
}

/* Setting up an OAuth app on your own Forgejo server. */
ol.setup {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  color: var(--muted);
  display: grid;
  gap: 0.35rem;
}

ol.setup code {
  overflow-wrap: anywhere;
  color: var(--fg);
}

/* Adding a service: a tile per service, then how, as one switch. */

fieldset.providers,
fieldset.how {
  border: 0;
  padding: 0;
  margin: 0 0 1.1rem;
  min-width: 0;
}

fieldset.providers legend,
fieldset.how legend {
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0;
  margin-bottom: 0.5rem;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.6rem;
}

.provider {
  --brand: var(--fg);
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  padding: 0.85rem 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  min-width: 0;
  transition:
    border-color 0.15s,
    background 0.15s,
    box-shadow 0.15s,
    translate 0.15s;
}

.provider[data-kind="bitbucket"] {
  --brand: #2684ff;
}

.provider[data-kind="forgejo"] {
  --brand: #f97316;
}

.provider[data-kind="jira"] {
  --brand: #2684ff;
}

.provider[data-kind="slack"] {
  --brand: #e01e5a;
}

/* The radio itself stays for the keyboard and screen readers, unseen. */
.provider input,
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.provider-logo {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.7rem;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}

.provider-logo svg {
  width: 1.4rem;
  height: 1.4rem;
  fill: currentColor;
}

.provider-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider:hover {
  border-color: var(--line-strong);
  translate: 0 -1px;
}

.provider:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

.provider:has(input:focus-visible),
.segmented label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, auto);
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  max-width: 100%;
}

.segmented label {
  position: relative;
  text-align: center;
  padding: 0.45rem 0.9rem;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  min-width: 0;
}

.segmented label:hover {
  color: var(--fg);
}

.segmented label:has(input:checked) {
  background: var(--card);
  color: var(--fg);
  box-shadow: var(--shadow);
}

/* The list of sign-ins, then adding one. */
#services-open h3 {
  margin-top: 1.5rem;
}

/* Narrow: the switch's halves share the width. */
@media (max-width: 30rem) {
  .segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .segmented label {
    padding: 0.45rem 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .provider {
    transition: none;
  }

  .provider:hover {
    translate: none;
  }
}
