/* mbnt password generator — same "keycap" theme as send.mbnt.se:
   square edges, brand cyan #27add4 from the logo, static grid background. */

/* Archivo for the interface; JetBrains Mono for the password.
   Both self-hosted (CSP is default-src 'self'), SIL OFL — see /fonts/*-OFL.txt */
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("/fonts/archivo-latin-wdth-normal.woff2") format("woff2-variations");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2-variations");
}

:root {
  --brand: #27add4;
  --brand-bright: #5bc7e8;
  --brand-deep: #13708c;
  --navy: #061c28;
  --abyss: #010b11;
  --panel: #0a2837;
  --paper: #eaf6fb;
  --text: var(--paper);
  --muted: #9cc4d6;
  --faint: #5b7f8f;
  --line: rgba(91, 199, 232, 0.2);
  --input-bg: #04141c;
  --input-border: rgba(91, 199, 232, 0.3);
  --alt-face: #103a4e;
  --alt-face-hover: #16475e;
  --alt-edge: #051620;
  --font-ui: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --wide: 112%;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--navy);
}

/* Background: static two-scale grid (24px fine, 120px major), fading out
   toward the edges. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(91, 199, 232, 0.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91, 199, 232, 0.075) 1px, transparent 1px),
    linear-gradient(rgba(91, 199, 232, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91, 199, 232, 0.14) 1px, transparent 1px);
  background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px;
  -webkit-mask-image: radial-gradient(90% 70% at 50% 35%, #000 30%, transparent 100%);
  mask-image: radial-gradient(90% 70% at 50% 35%, #000 30%, transparent 100%);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 59px;
  padding: 0 22px;
}

.logo { align-self: stretch; }

.logo img {
  display: block;
  height: 100%;
  width: auto;
}

main { max-width: 640px; margin: 44px auto; padding: 0 20px; }

section {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 24px;
  box-shadow: 0 1px 0 rgba(91, 199, 232, 0.08), 0 14px 0 -8px rgba(1, 11, 17, 0.55);
  animation: wipe 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes wipe {
  from { clip-path: inset(0 0 100% 0); }
  to   { clip-path: inset(-24px -24px -24px -24px); }
}

h1 { margin: 0 0 18px; font-size: 1.35rem; font-weight: 700; font-stretch: var(--wide); letter-spacing: -0.01em; }

.note { color: var(--muted); font-size: 0.9rem; }
a { color: var(--brand-bright); }
.footnote { margin: 22px 0 0; text-align: center; font-size: 0.75rem; line-height: 1.6; color: var(--faint); }
.footnote a { color: inherit; }

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

.offscreen { position: fixed; top: 0; left: -9999px; opacity: 0; }

/* ---------- password output ---------- */

.output-box { position: relative; }

#password {
  display: flex;
  align-items: center;
  min-height: 76px;
  padding: 16px 18px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1.35;
  word-break: break-all;
  /* No ligatures: "//", "->" etc. must show exactly the characters generated. */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  user-select: all;
  transition: border-color 0.12s ease;
}

#password.long { font-size: 1rem; }

/* Copied: a light sweep across the box and a "Copied" tag. */
.copy-sweep {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.copy-sweep::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 45%;
  background: linear-gradient(90deg, transparent, rgba(91, 199, 232, 0.38), transparent);
  transform: translateX(-110%);
}

.copied .copy-sweep::before { animation: sweep 0.55s cubic-bezier(0.3, 0.7, 0.3, 1); }
.copied #password { border-color: var(--brand); }

@keyframes sweep {
  from { transform: translateX(-110%); }
  to   { transform: translateX(260%); }
}

.copy-tag {
  position: absolute;
  right: 0;
  bottom: calc(100% + 7px);
  padding: 4px 7px;
  background: var(--brand);
  color: var(--navy);
  font: 700 10px/1 var(--font-ui);
  font-stretch: var(--wide);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.4);
  pointer-events: none;
}

.copy-tag::after {
  content: "";
  position: absolute;
  right: 11px;
  top: 100%;
  border: 5px solid transparent;
  border-top-color: var(--brand);
  border-bottom: 0;
}

.copied .copy-tag { opacity: 1; transform: none; }

/* ---------- strength meter: four square blocks ---------- */

.meter {
  --meter: #ff8a8a;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.meter[data-level="1"] { --meter: #ffd992; }
.meter[data-level="2"] { --meter: #7fe0a8; }
.meter[data-level="3"] { --meter: #7fe0a8; }

.meter-bars { display: grid; grid-template-columns: repeat(4, 28px); gap: 4px; }

.meter-bars i {
  display: block;
  height: 8px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.meter[data-level="0"] .meter-bars i:nth-child(-n + 1),
.meter[data-level="1"] .meter-bars i:nth-child(-n + 2),
.meter[data-level="2"] .meter-bars i:nth-child(-n + 3),
.meter[data-level="3"] .meter-bars i:nth-child(-n + 4) {
  background: var(--meter);
  border-color: var(--meter);
}

.meter-text { margin: 0; font-size: 0.88rem; color: var(--muted); }
.meter-text strong { color: var(--meter); font-weight: 700; }

.settings-note { margin: -4px 0 0; font-size: 0.82rem; }

/* ---------- buttons: keycaps ---------- */

.row { display: flex; align-items: center; gap: 12px; margin: 16px 0 0; }
.action-row { justify-content: space-between; }

button {
  display: inline-block;
  background: var(--brand);
  color: #04202c;
  border: none;
  border-radius: 0;
  padding: 11px 18px;
  margin-bottom: 4px;
  font-size: 0.95rem;
  font-weight: 650;
  font-stretch: var(--wide);
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--brand-deep), 0 4px 0 1px rgba(1, 11, 17, 0.5);
  transition: background-color 0.12s ease, transform 0.07s ease-out, box-shadow 0.07s ease-out;
}

button:hover { background: var(--brand-bright); }

button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--brand-deep), 0 1px 0 1px rgba(1, 11, 17, 0.5);
}

button:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }

button.secondary {
  background: var(--alt-face);
  color: var(--text);
  box-shadow: 0 4px 0 var(--alt-edge), inset 0 0 0 1px var(--input-border);
}

button.secondary:hover { background: var(--alt-face-hover); }

button.secondary:active {
  box-shadow: 0 1px 0 var(--alt-edge), inset 0 0 0 1px var(--input-border);
}

/* ---------- mode switch: two keycaps, the chosen one stays pressed ---------- */

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 26px 0 0;
  padding: 0;
  border: 0;
}

.modes input { position: absolute; opacity: 0; pointer-events: none; }

.modes label {
  display: block;
  padding: 11px 12px;
  text-align: center;
  font-weight: 650;
  font-stretch: var(--wide);
  font-size: 0.95rem;
  cursor: pointer;
  background: var(--alt-face);
  color: var(--muted);
  box-shadow: 0 4px 0 var(--alt-edge), inset 0 0 0 1px var(--input-border);
  margin-bottom: 4px;
  transition: background-color 0.12s ease, transform 0.07s ease-out, box-shadow 0.07s ease-out;
}

.modes label:hover { background: var(--alt-face-hover); color: var(--text); }

.modes input:checked + label {
  background: var(--brand);
  color: #04202c;
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--brand-deep), 0 1px 0 1px rgba(1, 11, 17, 0.5);
}

.modes input:focus-visible + label { outline: 2px solid var(--paper); outline-offset: 3px; position: relative; }

/* ---------- settings ---------- */

.settings {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(4, 20, 28, 0.45);
}

.setting {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px 12px;
}

.setting > label { color: var(--muted); font-size: 0.95rem; }

.setting > output {
  min-width: 3ch;
  padding: 2px 8px;
  background: var(--brand);
  color: #04202c;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.setting input[type="range"] { grid-column: 1 / -1; }

.setting-inline { display: flex; align-items: center; gap: 14px; }

input[type="text"] {
  width: 8ch;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: 0;
  padding: 7px 10px;
  font: 500 1rem var(--font-mono);
  text-align: center;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

/* Range: a flat track filled up to the thumb, and a small keycap as thumb. */
input[type="range"] {
  --pct: 0%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

/* no-repeat + padding-box: otherwise the fill's first pixels repeat into the
   right border as a thin cyan line. */
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  background: linear-gradient(90deg, var(--brand) var(--pct), var(--input-bg) var(--pct)) padding-box no-repeat;
  border: 1px solid var(--input-border);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  background: linear-gradient(90deg, var(--brand) var(--pct), var(--input-bg) var(--pct)) padding-box no-repeat;
  border: 1px solid var(--input-border);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 24px;
  margin-top: -9px;
  background: var(--paper);
  border: 0;
  border-radius: 0;
  box-shadow: 0 3px 0 var(--muted), 0 3px 0 1px rgba(1, 11, 17, 0.5);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 24px;
  background: var(--paper);
  border: 0;
  border-radius: 0;
  box-shadow: 0 3px 0 var(--muted), 0 3px 0 1px rgba(1, 11, 17, 0.5);
}

input[type="range"]:active::-webkit-slider-thumb { background: var(--brand-bright); }
input[type="range"]:active::-moz-range-thumb { background: var(--brand-bright); }
input[type="range"]:focus { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--brand); outline-offset: 2px; }
input[type="range"]:focus-visible::-moz-range-thumb { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Checkboxes: square; checked shows a filled cyan square inside. */
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  cursor: pointer;
}

.check .hint { color: var(--muted); font-size: 0.85rem; }

.check-row { display: flex; flex-wrap: wrap; gap: 14px 28px; }

input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 0;
  cursor: pointer;
  transition: background-color 0.1s ease, box-shadow 0.1s ease;
}

input[type="checkbox"]:checked {
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: inset 0 0 0 4px var(--input-bg);
}

input[type="checkbox"]:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  max-width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  color: var(--navy);
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 0 var(--brand-deep);
  transform: translate(-50%, calc(100% + 40px));
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  pointer-events: none;
}

.toast::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--brand-deep);
}

.toast.show { transform: translate(-50%, 0); }

@media (max-width: 480px) {
  main { margin-top: 28px; padding: 0 16px; }
  section { padding: 18px; }
  #password { font-size: 1.2rem; }
  .action-row { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  section,
  .copied .copy-sweep::before { animation: none; }
  .toast { transition: none; }
}
