/* PwHash – steel and brass: the result is shown as a cut key of character cells. */

:root {
  --ground: #e6e9ec;
  --surface: #f6f7f8;
  --ink: #1b2631;
  --muted: #566370;
  --line: #c3cad1;
  --brass: #8f6b1c;
  --brass-soft: #e9dcbc;
  --digit: #245b8a;
  --special: #8a3155;
  --warn: #8a4b00;
  --radius-field: 0.5rem;
  --radius-key: 0.9rem;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-key: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", "DejaVu Sans Mono", Menlo, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #12181e;
    --surface: #1b232b;
    --ink: #e4e9ee;
    --muted: #97a3ae;
    --line: #34404b;
    --brass: #d8b665;
    --brass-soft: #3a3322;
    --digit: #86b9e0;
    --special: #e493b4;
    --warn: #f0b35c;
  }
}

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 1rem/1.5 var(--font-ui);
  -webkit-text-size-adjust: 100%;
}

.page {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

h1 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.logo {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.7rem;
}

.lede {
  margin: 0.75rem 0 1.75rem;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Mode switch */
.mode {
  display: inline-flex;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.mode button {
  border: 0;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.mode button[aria-checked="true"] {
  background: var(--ink);
  color: var(--surface);
}

/* Fields */
.field {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.label-row label {
  margin-bottom: 0.35rem;
}

input {
  width: 100%;
  min-width: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
}

input:focus-visible,
button:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--brass);
  outline-offset: 2px;
}

.input-with-button {
  display: flex;
  gap: 0.5rem;
}

.note {
  margin: 0.35rem 0 0;
  min-height: 1.4em;
  color: var(--muted);
  font-size: 0.875rem;
}

.note strong {
  color: var(--ink);
  font-weight: 600;
}

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

.checksum output {
  margin-left: 0.3rem;
  padding: 0.1rem 0.45rem;
  border-radius: 0.3rem;
  background: var(--brass-soft);
  color: var(--ink);
  font-family: var(--font-key);
  font-weight: 700;
  letter-spacing: 0.12em;
}

button.ghost {
  flex: none;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.stepper {
  display: flex;
  gap: 0.5rem;
  max-width: 12rem;
}

.stepper input {
  text-align: center;
  -moz-appearance: textfield;
}

.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.stepper button {
  width: 2.75rem;
  font-size: 1.2rem;
  line-height: 1;
}

/* Result: the cut key */
.result {
  margin-top: 2rem;
}

.key {
  display: block;
  width: 100%;
  padding: 1rem 0.9rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius-key);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease;
}

.key:disabled {
  border-style: dashed;
  border-color: var(--line);
  cursor: default;
}

.cells {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.3rem;
  min-height: 2.4rem;
}

.cell {
  display: grid;
  place-items: center;
  height: 2.4rem;
  border-bottom: 3px solid var(--line);
  font-family: var(--font-key);
  font-size: clamp(1rem, 4.6vw, 1.35rem);
  font-variant-numeric: slashed-zero;
}

.cell.digit {
  color: var(--digit);
}

.cell.special {
  color: var(--special);
}

.cell.control {
  color: var(--warn);
}

.cell.blank {
  border-bottom-style: dashed;
}

.key.copied {
  border-color: var(--brass);
}

.key.copied .cell {
  border-bottom-color: var(--brass);
}

.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.6rem;
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.warning {
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.8rem;
  border-left: 3px solid var(--warn);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
}

/* Footer */
.footer {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

.footer p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--brass);
  text-underline-offset: 0.2em;
}

details {
  margin-top: 0.5rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
}

details p {
  color: var(--muted);
}

code {
  font-family: var(--font-key);
  font-size: 0.9em;
}

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

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