/* The password on the time ruler: a new password on a black page, measured in the time a computer would need to
   guess it. Thin lines, the password drawn as a row of bars, and one amber that means strong enough. */
:root {
  --page: #000000;          /* the page */
  --ink: #f1efe9;           /* the words and the bars of the password */
  --muted: #85837d;         /* the smaller words and the ruler at rest */
  --dim: #34332f;           /* the edge of the field and the small ticks */
  --box: #0d0d0c;           /* the inside of the field */
  --accent: #ffa733;        /* strong enough: the ruler up to the needle, and the needle */
  --make: #f1efe9;          /* the button */
  --make-ink: #000000;      /* the button's words */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Hubot Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 40px 16px;
}

.pw {
  position: relative;
  width: min(460px, 100%);
  margin: 0;
}

.pw__title {
  margin: 0;
  font-size: 22px;
  font-weight: 640;
  font-stretch: 100%;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.pw__for {
  margin: 5px 0 22px;
  font-size: 14px;
  font-weight: 430;
  line-height: 20px;
  color: var(--muted);
}

.pw__label {
  display: block;
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 560;
  font-stretch: 108%;
  line-height: 16px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- the field */
.pw__box {
  position: relative;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 6px 0 16px;
  border: 1px solid var(--dim);
  border-radius: 14px;
  background: var(--box);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pw.is-focus .pw__box {
  border-color: #77756f;
}

.pw.is-wrong .pw__box {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.pw__slot {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

/* the real field, its own letters transparent: the bars and letters over it are drawn cell by cell */
.pw__input {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: var(--accent);
  font: 400 17px/54px 'JetBrains Mono Variable', ui-monospace, monospace;
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}

.pw__input::selection {
  background: rgba(255, 167, 51, 0.3);
  color: transparent;
}

.pw__cells {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  pointer-events: none;
}

/* a cell: a bar while the password is hidden, the letter itself when it is shown */
.cell {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
}

.cell__bar {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 18px;
  margin: -9px 0 0 -1px;
  border-radius: 1px;
  background: var(--ink);
  transform-origin: 50% 100%;
}

.cell__ch {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  font: 400 17px/54px 'JetBrains Mono Variable', ui-monospace, monospace;
  text-align: center;
  color: var(--ink);
  opacity: 0;
  white-space: pre;
}

.pw__caret {
  position: absolute;
  left: 0;
  top: 17px;
  width: 1.5px;
  height: 21px;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
}

.pw__caret.is-on {
  animation: blink 1.06s steps(1) infinite;
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }

  50.01%,
  100% {
    opacity: 0;
  }
}

/* Show and Hide: a word that widens, never an underline */
.pw__show {
  flex: none;
  height: 42px;
  margin: 0;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: 600 14px/1 'Hubot Sans Variable', system-ui, sans-serif;
  font-stretch: 100%;
  cursor: pointer;
  transition: font-stretch 0.5s cubic-bezier(0.3, 1.7, 0.45, 1), background-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .pw__show:hover {
    font-stretch: 122%;
    background: #1b1b19;
  }
}

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

/* the brackets under the weak parts */
.pw__marks-clip {
  overflow: hidden;
}

.pw__marks {
  position: relative;
  height: 26px;
  margin: 0 6px 0 17px;
}

.mark {
  position: absolute;
  top: 3px;
  height: 7px;
  border: 1px solid var(--muted);
  border-top: 0;
  transform-origin: 50% 0;
}

.mark span {
  position: absolute;
  left: 50%;
  top: 7px;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 560;
  font-stretch: 112%;
  line-height: 14px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the ruler */
.ruler {
  position: relative;
  height: 84px;
  margin-top: 4px;
}

.ruler__tag {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 15px;
  font-weight: 620;
  font-stretch: 100%;
  line-height: 20px;
  color: var(--muted);
  white-space: nowrap;
  transform: translateX(-50%);
  will-change: transform;
}

.ruler.is-strong .ruler__tag {
  color: var(--accent);
}

.ruler__svg {
  position: absolute;
  left: 0;
  top: 22px;
  width: 100%;
  height: 40px;
  overflow: visible;
}

.ruler__ticks {
  fill: none;
  stroke: var(--dim);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.ruler__base {
  fill: none;
  stroke: var(--dim);
  stroke-width: 1;
}

.ruler__fill {
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
}

.ruler.is-strong .ruler__fill {
  stroke: var(--accent);
}

.ruler__goal {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 2 2;
}

.ruler__needle {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.ruler.is-strong .ruler__needle {
  stroke: var(--accent);
}

.ruler__units {
  position: absolute;
  left: 0;
  right: 0;
  top: 66px;
  height: 16px;
}

.ruler__units span {
  position: absolute;
  top: 0;
  font-size: 11px;
  font-weight: 520;
  font-stretch: 110%;
  line-height: 16px;
  color: var(--muted);
  white-space: nowrap;
  transform: translateX(-50%);
}

.ruler__units span.is-goal {
  color: var(--accent);
}

/* ---------------------------------------------------------------- the line under the ruler, and the button */
.pw__status {
  position: relative;
  min-height: 40px;
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 430;
  line-height: 20px;
  color: var(--muted);
}

.status__line {
  display: block;
}

.status__line.is-going {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  pointer-events: none;
}

.status__line b {
  font-weight: 640;
  color: var(--ink);
}

.status__line.is-wrong {
  color: var(--ink);
}

.status__line.is-strong b {
  color: var(--accent);
}

.status__btn {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 640;
  font-stretch: 100%;
  cursor: pointer;
  transition: font-stretch 0.5s cubic-bezier(0.3, 1.7, 0.45, 1), color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .status__btn:hover {
    font-stretch: 120%;
    color: var(--accent);
  }
}

.status__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.make {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 52px;
  margin: 14px 0 0;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--make-ink);
  font: 620 16px/1 'Hubot Sans Variable', system-ui, sans-serif;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.make__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--make);
  transition: inset 0.6s cubic-bezier(0.3, 1.7, 0.45, 1), transform 0.16s ease-out, background-color 0.3s ease;
}

.pw.is-strong-now .make__bg {
  background: var(--accent);
}

.make__label {
  display: block;
  font-stretch: 100%;
  white-space: nowrap;
  transition: font-stretch 0.6s cubic-bezier(0.3, 1.7, 0.45, 1);
}

@media (hover: hover) and (pointer: fine) {
  .make:not([aria-disabled='true']):hover .make__bg {
    inset: -2px -4px;
  }

  .make:not([aria-disabled='true']):hover .make__label {
    font-stretch: 116%;
  }
}

.make:not([aria-disabled='true']):active .make__bg,
.make.is-pressed .make__bg {
  transform: scale(0.97);
}

.make[aria-disabled='true'] {
  cursor: default;
}

.make:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* for screen readers only */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 440px) {
  .ruler__units span.is-minor {
    display: none;
  }
}
