/*! © 2015–2026 YourWeb (yourweb.se). All rights reserved. Proprietary – see LICENSE.md */
/* Styles only this tool uses (tool 05, /verktyg/losenordskoll/), prefix .pw-. Linked after /verktyg/verktyg.css.

   Contents
   01 Panel and the two parts   04 Generator options (choices, toggles, range)
   02 The generated secret       05 Strength check (field, verdict, notes)
   03 Meter                      06 Breach check                                   */

/* ───────────────────────── 01 Panel and the two parts ───────────────────────── */

/* A little tighter than the default panel so that the secret and its buttons stay above the fold on phones. */
.pw-panel {
  gap: 0.75rem;
  margin-top: 0.1rem;
}

.pw-app,
.pw-pane,
.pw-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  min-width: 0;
}

.pw-app > *,
.pw-pane > *,
.pw-options > * {
  min-width: 0;
}

.pw-panel > [data-pw-feedback]:empty {
  display: none;
}

.pw-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.25rem;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
}

.pw-mode {
  justify-content: center;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.3rem 0.3rem;
  border-color: transparent;
  font-size: 0.86rem;
  line-height: 1.15;
  text-align: center;
}

.pw-mode[aria-selected="true"],
.pw-mode[aria-selected="true"]:hover {
  border-color: var(--paper-100);
  background: var(--paper-100);
  color: var(--ink-900);
}

.pw-note {
  margin: 0;
  color: var(--warn);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
}

/* ───────────────────────── 02 The generated secret ───────────────────────── */

.pw-secret {
  display: flex;
  align-items: center;
  min-height: calc(2.8em + 1.3rem + 3px); /* two lines of text, the padding and the border */
  margin: 0;
  padding: 0.65rem 0.95rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 0.95rem;
  background: var(--surface-sunken);
  color: var(--text);
  font-family: var(--mono);
  font-size: clamp(1.05rem, 4.7vw, 1.45rem);
  font-weight: 600;
  line-height: 1.4;
  font-variant-ligatures: none;
}

.pw-secret [data-pw-secret] {
  display: block;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  -webkit-user-select: all;
  user-select: all;
}

/* Random characters have no word boundaries: fill each line instead of breaking early after a symbol. */
.pw-secret .is-chars {
  word-break: break-all;
}

.pw-digit {
  color: var(--accent);
}

.pw-symbol {
  color: var(--yellow-500);
}

.pw-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.pw-act {
  min-height: 2.9rem;
  padding: 0.4rem 0.6rem;
}

.pw-read {
  display: grid;
  gap: 0.6rem;
}

/* Room for four lines of explanation, so that the options below do not jump when the text gets shorter. */
@media (max-width: 33.99rem) {
  .pw-read .field__hint {
    min-height: 5.8em;
  }
}

/* The shared "copied" state is green text, which cannot be read on the yellow button. */
.pw-act.copy-btn[data-copied="true"],
.pw-act.copy-btn[data-copied="true"]:hover {
  border-color: var(--ok);
  background: var(--ok);
  color: var(--ink-950);
}

/* ───────────────────────── 03 Meter ───────────────────────── */

/* Four segments, an icon, a word and the bits: the level never depends on colour alone. */
.pw-meter {
  display: grid;
  gap: 0.5rem;
}

.pw-meter__bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.3rem;
}

.pw-meter__bar span {
  height: 0.45rem;
  border-radius: var(--radius-pill);
  background: var(--line-strong);
}

.pw-meter__bar span.is-on {
  background: var(--st, var(--text-dim));
}

.pw-meter__text {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.6rem;
  margin: 0;
}

.pw-meter__badge {
  display: inline-flex;
}

.pw-meter__badge .st-icon {
  width: 1.55rem;
  height: 1.55rem;
}

.pw-meter__name {
  color: var(--st, var(--text));
  font-size: 1.08rem;
  letter-spacing: -0.02em;
}

.pw-meter__bits {
  color: var(--text-soft);
  font-size: 0.92rem;
  font-weight: 700;
}

/* ───────────────────────── 04 Generator options ───────────────────────── */

.pw-set {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.pw-set > legend {
  margin: 0 0 0.5rem;
  padding: 0;
}

.pw-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.pw-choice {
  position: relative;
  display: block;
  min-width: 0;
}

/* The real radio button covers its pill: it stays focusable and tappable, but invisible. */
.pw-radio,
.pw-check {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 1rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.pw-choice .chip {
  width: 100%;
  justify-content: center;
  padding-inline: 0.5rem;
  text-align: center;
}

.pw-radio:checked + .chip,
.pw-radio:checked + .chip:hover {
  border-color: var(--paper-100);
  background: var(--paper-100);
  color: var(--ink-900);
}

.pw-radio:focus-visible + .chip {
  outline: 3px solid var(--yellow-500);
  outline-offset: 3px;
}

.pw-toggles {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
}

.pw-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  min-height: 2.9rem;
  padding: 0.4rem 0.85rem 0.4rem 0.75rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 160ms ease, background 160ms ease;
}

@media (hover: hover) {
  .pw-toggle:hover {
    border-color: rgba(255, 255, 255, 0.4);
  }

  .pw-choice:hover .pw-radio:not(:checked) + .chip {
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
  }
}

.pw-toggle:has(.pw-check:checked) {
  border-color: rgb(var(--accent-rgb) / 0.55);
  background: rgb(var(--accent-rgb) / 0.07);
}

.pw-toggle__box {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border: 1.5px solid var(--text-dim);
  border-radius: 0.4rem;
  transition: background 160ms ease, border-color 160ms ease;
}

.pw-toggle__box .icon {
  width: 1rem;
  height: 1rem;
  opacity: 0;
  stroke-width: 3;
}

.pw-check:checked + .pw-toggle__box .icon {
  opacity: 1;
}

.pw-check:checked + .pw-toggle__box {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--ink-900);
}

.pw-check:focus-visible + .pw-toggle__box {
  outline: 3px solid var(--yellow-500);
  outline-offset: 3px;
}

.pw-toggle__text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.pw-toggle__text small {
  margin-left: 0.35rem;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.pw-range-field {
  display: grid;
  gap: 0.1rem;
}

.pw-range-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.pw-range-value {
  color: var(--accent);
  font-size: 1.02rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.pw-range {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
}

.pw-step {
  width: 2.75rem;
  min-width: 2.75rem;
  height: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border-radius: 50%;
}

.pw-slider {
  --pw-fill: 50%;
  width: 100%;
  min-width: 0;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}

.pw-slider:focus-visible {
  outline: none;
}

.pw-slider::-webkit-slider-runnable-track {
  height: 0.5rem;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent) var(--pw-fill), rgba(255, 255, 255, 0.34) var(--pw-fill));
}

/* The thumb is 44 px wide so that it is easy to grab; the transparent border leaves a 28 px circle to look at. */
.pw-slider::-webkit-slider-thumb {
  width: 2.75rem;
  height: 2.75rem;
  margin-top: -1.125rem;
  border: 0.5rem solid transparent;
  border-radius: 50%;
  background: var(--paper-100);
  background-clip: padding-box;
  box-shadow: inset 0 0 0 1.5px var(--accent), inset 0 0 0 4.5px var(--ink-900);
  -webkit-appearance: none;
  appearance: none;
}

.pw-slider:focus-visible::-webkit-slider-thumb {
  outline: 3px solid var(--yellow-500);
  outline-offset: 3px;
}

.pw-slider::-moz-range-track {
  height: 0.5rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.34);
}

.pw-slider::-moz-range-progress {
  height: 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
}

.pw-slider::-moz-range-thumb {
  width: 2.75rem;
  height: 2.75rem;
  border: 0.5rem solid transparent;
  border-radius: 50%;
  background: var(--paper-100);
  background-clip: padding-box;
  box-shadow: inset 0 0 0 1.5px var(--accent), inset 0 0 0 4.5px var(--ink-900);
}

.pw-slider:focus-visible::-moz-range-thumb {
  outline: 3px solid var(--yellow-500);
  outline-offset: 3px;
}

/* ───────────────────────── 05 Strength check ───────────────────────── */

.pw-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: start;
}

.pw-input {
  letter-spacing: 0.03em;
}

.pw-eye {
  width: 3.25rem;
  min-width: 3.25rem;
  padding: 0;
}

.pw-eye[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.pw-verdict {
  display: grid;
  gap: 0.7rem;
  min-width: 0;
}

.pw-empty {
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text-soft);
  font-size: 0.92rem;
}

.pw-notes {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pw-notes li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.6rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.pw-notes .st-icon {
  width: 1.55rem;
  height: 1.55rem;
}

.pw-notes .st-icon .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.pw-advice {
  display: grid;
  gap: 0.65rem;
  justify-items: start;
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 0.6rem 0.6rem 0;
  background: rgb(var(--accent-rgb) / 0.08);
  font-size: 0.93rem;
  line-height: 1.5;
}

.pw-advice p {
  margin: 0;
}

.pw-token {
  padding: 0.05em 0.35em;
  border-radius: 0.35em;
  background: rgb(var(--st-rgb, 255 255 255) / 0.14);
  font-family: var(--mono);
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

/* ───────────────────────── 06 Breach check ───────────────────────── */

.pw-breach {
  display: grid;
  gap: 0.65rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.pw-breach__btn {
  width: 100%;
}

.pw-breach [data-pw-breach-out]:empty {
  display: none;
}

.pw-sent {
  color: var(--text-dim);
  font-size: 0.86rem;
}

@media (min-width: 34rem) {
  .pw-mode {
    font-size: 0.95rem;
  }

  .pw-choices--four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .pw-toggles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pw-toggles > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .pw-breach__btn {
    width: auto;
    justify-self: start;
  }
}

@media (min-width: 40rem) {
  .pw-panel,
  .pw-app,
  .pw-pane,
  .pw-options {
    gap: 1rem;
  }

  .pw-secret {
    min-height: 4.6rem;
    padding-inline: 1.15rem;
  }

  .pw-act {
    min-height: 3.25rem;
  }
}

/* On a very narrow or zoomed screen the long headline word may break rather than overflow. */
.tool--t5 .tool-hero h1 {
  overflow-wrap: anywhere;
}

/* Forced colours (Windows high contrast) drop backgrounds: selected states need the system colours. */
@media (forced-colors: active) {
  .pw-radio:checked + .chip,
  .pw-mode[aria-selected="true"] {
    forced-color-adjust: none;
    border-color: Highlight;
    background: Highlight;
    color: HighlightText;
  }

  .pw-check:checked + .pw-toggle__box {
    forced-color-adjust: none;
    border-color: Highlight;
    background: Highlight;
    color: HighlightText;
  }
}
