/* Palette and typography follow genbit's scaffold theme. */
:root {
  --text: #222;
  --bg: #faf9f6;
  --muted: #666;
  --link: #1557b0;
  --on-link: #fff;
  --border: #d8d6d0;
  --code-bg: #f3f4f6;
  --code-label-bg: #e7e9ed;
  --error: #b3261e;
  --mono: ui-monospace, monospace;
  font-family: system-ui, sans-serif;
  color-scheme: light;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #d9dce1;
    --bg: #1b1e23;
    --muted: #a8afb9;
    --link: #9cc4ff;
    --on-link: #1b1e23;
    --border: #3b414b;
    --code-bg: #292e36;
    --code-label-bg: #39404a;
    --error: #ffb4ab;
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

header {
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0;
  font-size: 1.75rem;
}

/* The favicon beside the title, as in bitfeed. */
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
}

p {
  margin: 0;
}

code {
  font-family: var(--mono);
}

/* Controls */

button,
input {
  font: inherit;
  color: inherit;
}

button {
  min-width: 44px;
  min-height: 44px;
  padding: 0.25rem 0.875rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  cursor: pointer;
}

button:hover {
  background: var(--code-label-bg);
}

button:disabled {
  color: var(--muted);
  background: var(--code-bg);
  cursor: not-allowed;
}

button.primary {
  width: 100%;
  color: var(--on-link);
  background: var(--link);
  border-color: var(--link);
  font-weight: 700;
}

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* Layout: one column on narrow screens (settings, generate, results). */

.layout {
  display: grid;
  gap: 2.5rem;
}

@media (min-width: 56rem) {
  .layout {
    grid-template-columns: 26rem minmax(0, 1fr);
    align-items: start;
  }
}

/* Keep the generate button in reach next to a long result list, but only
   when the settings fit in the viewport; otherwise the button would be cut off. */
@media (min-width: 56rem) and (min-height: 40rem) {
  .settings {
    position: sticky;
    top: 1rem;
  }
}

.results-head {
  margin-bottom: 0.75rem;
}

/* Label and controls share a row when there is room, and wrap otherwise. */
.field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
}

.field > label {
  min-width: 6.5em;
}

.field + .field {
  margin-top: 0.75rem;
}

.field > label,
legend {
  font-weight: 700;
}

legend {
  margin-bottom: 0.25rem;
}

.controls {
  display: flex;
  gap: 0.75rem;
}

.presets,
.stepper {
  display: flex;
}

/* Adjacent buttons share borders, like a segmented control. */
.presets button + button {
  margin-left: -1px;
}

.presets button {
  padding-inline: 0.5rem;
  font-variant-numeric: tabular-nums;
}

/* The selected preset is shown by inverted colors and bold text, not by hue alone. */
.presets button[aria-pressed="true"] {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
  font-weight: 700;
}

.stepper input {
  width: 3.5rem;
  min-height: 44px;
  margin: 0 -1px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0;
}

.stepper button {
  font-size: 1.25rem;
  line-height: 1;
}

fieldset {
  margin: 1rem 0 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  cursor: pointer;
}

.check input {
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: var(--link);
}

/* Character classes in a 2x2 grid; the symbol list gets its own line below. */
.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

#symbol-list code {
  overflow-wrap: anywhere;
}

.check code {
  color: var(--muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.errors {
  margin: 1rem 0 0;
  padding: 0 0 0 1rem;
  color: var(--error);
  border-inline-start: 4px solid var(--error);
}

.errors:empty {
  display: none;
}

.strength {
  margin-top: 1rem;
}

.settings .primary {
  margin-top: 1rem;
}

/* Results */

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.results-head h2 {
  margin: 0;
}

.copy-fallback-text {
  display: block;
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-family: var(--mono);
  color: inherit;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  resize: vertical;
}

.stale {
  margin-bottom: 1rem;
  padding-left: 0.75rem;
  border-inline-start: 4px solid var(--border);
  font-size: 0.875rem;
}

.placeholder {
  padding: 0.75rem;
  color: var(--muted);
  background: var(--code-bg);
}

/* Both labels share one grid cell, so swapping them never changes the width. */
.copy {
  display: inline-grid;
  place-items: center;
}

.copy > span {
  grid-area: 1 / 1;
}

.copy > span + span,
.copy.copied > span:first-child {
  visibility: hidden;
}

.copy.copied > span + span {
  visibility: visible;
}

.badge {
  margin-left: 0.25em;
  padding: 0.125rem 0.375rem;
  color: var(--muted);
  background: var(--code-label-bg);
  font-size: 0.75rem;
  white-space: nowrap;
}

.badge:empty {
  display: none;
}

.note {
  color: var(--muted);
  font-size: 0.875rem;
}

details.note summary {
  width: fit-content;
  cursor: pointer;
}

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

.results li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.375rem 0.375rem 0.375rem 0.75rem;
  background: var(--code-bg);
}

.results li + li {
  margin-top: 0.5rem;
}

.password {
  flex: 1;
  min-width: 0;
  /* Break between any two characters so symbols do not create ragged lines. */
  word-break: break-all;
  user-select: all;
}

.results .copy {
  flex-shrink: 0;
  background: var(--bg);
}

footer {
  margin-top: 3rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

footer p + p {
  margin-top: 0.5em;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
