/* Fair Roll. Loaded after ../style.css and built on its tokens. */

/* Light and dark values, as in style.css: light-dark() where the browser has it, the light values otherwise. */
:root {
  --well: #E1EAE5; --line: #707E77; --symbol: #5C46A7; --warn: #A14206;
  --digit: var(--accent); /* 5.0:1 on --well in light, 11.3:1 in dark */
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@supports (color: light-dark(#000, #FFF)) {
  :root {
    /* Recessed ground for the result and inputs */
    --well: light-dark(#E1EAE5, #091B15);
    /* Control borders: 4.1:1 on --bg, 3.5:1 on --well. Dark: 3.9:1, 4.3:1 */
    --line: light-dark(#707E77, #6F8178);
    /* A violet: blue would merge with the green digits for tritanopes. 5.9:1 on --well; dark 9.3:1 */
    --symbol: light-dark(#5C46A7, #BFB2F9);
    /* Light: an orange, 6.1:1 on --bg, 5.2:1 on --well. Dark: a rose, 8.1:1, 9.1:1, because a light orange beside
       the mint accent reads as one color for red-green color-blind visitors */
    --warn: light-dark(#A14206, #EEA3C9);
  }
}

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

.tool .intro { font-size: 1.25rem; color: var(--muted); }
.tool .notice { margin-top: 32px; }

.generator { margin-top: 40px; display: flex; flex-direction: column; gap: 32px; }
.generator[hidden] { display: none; }
.generator p { margin: 0; max-width: none; }
.generator fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.generator [hidden] { display: none !important; }

/* Two-way switches: the mode, and the symbol rule. The radio covers its label, so the label is the hit area. */
.generator .segmented {
  display: inline-flex; flex-wrap: wrap; align-self: flex-start; gap: 4px; padding: 4px;
  border: 1.5px solid var(--line); border-radius: 26px;
}
.segmented label {
  position: relative; display: flex; align-items: center; min-height: 44px; padding: 0 20px;
  border-radius: 22px; font-weight: 600; cursor: pointer;
}
.segmented input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segmented label:hover { color: var(--accent); }
.segmented label:has(input:checked) { background: var(--fg); color: var(--bg); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.segmented.small label { min-height: 40px; padding: 0 16px; font-size: 1rem; }

/* Result */
.result {
  display: flex; flex-direction: column; gap: 16px;
  padding: clamp(20px, 5vw, 32px); background: var(--well); border-radius: 16px;
}
.secret {
  min-height: 1.4em;
  font-family: var(--mono); font-size: clamp(1.375rem, 1.05rem + 1.6vw, 1.875rem); font-weight: 500; line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: anywhere;
  -webkit-user-select: all; user-select: all;
}
/* Random passwords have no words to keep whole, so fill each line evenly instead of breaking at hyphens. */
.secret.is-password { word-break: break-all; line-break: anywhere; }
.secret .digit { color: var(--digit); }
.secret .symbol { color: var(--symbol); }
.secret .space { box-shadow: inset 0 -2px 0 var(--rule); } /* makes each space visible and countable */
.summary { font-size: 1rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.summary strong { font-weight: 700; color: var(--fg); }
.summary [data-rating="strong"], .summary [data-rating="good"] { color: var(--accent); }
.summary [data-rating="weak"] { color: var(--warn); }
.error { color: var(--warn); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

.button {
  min-height: 44px; padding: 0 18px; border: 1.5px solid var(--fg); border-radius: 22px;
  background: transparent; color: var(--fg);
  font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer;
}
.button:hover { border-color: var(--accent); color: var(--accent); }
.button.primary { min-width: 6.5em; background: var(--accent); border-color: var(--accent); color: var(--bg); }
.button.primary:hover { background: var(--fg); border-color: var(--fg); }
.button:focus-visible, .link:focus-visible, .chip:focus-visible, .stepper button:focus-visible,
.select select:focus-visible, .symtext:focus-visible, .dice summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button:disabled:hover { border-color: var(--accent); color: var(--bg); background: var(--accent); }

/* Options: label-and-control rows ruled like the site's .rows */
.options { display: flex; flex-direction: column; gap: 40px; }
.options fieldset { display: flex; flex-direction: column; border-top: 1.5px solid var(--fg); }
.options legend {
  float: left; width: 100%; padding: 16px 0 4px;
  font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em;
}
.field {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 64px; padding: 8px 0; border-top: 1px solid var(--rule);
}
/* Hairlines go between rows only, so a group doesn't end in a line just above the next group's rule. */
.options legend + .field { border-top: 0; }
.field > label, .field > span:first-child { font-weight: 600; }
label.field { cursor: pointer; }
label.field:hover > span:first-child { color: var(--accent); }
.field .sample { margin-left: 6px; font-family: var(--mono); font-size: 0.9375rem; font-weight: 400; color: var(--muted); }
.field input[type="checkbox"] { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.field input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.field input[type="checkbox"]:disabled { cursor: not-allowed; }

.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 24px; }
.stepper button {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 22px; background: none; color: var(--fg); cursor: pointer;
}
.stepper button svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.stepper button:hover { color: var(--accent); }
.stepper button:focus-visible { outline-offset: -2px; }
.stepper input {
  width: 3.5ch; padding: 0; border: 0; background: none; color: var(--fg); text-align: center; caret-color: var(--accent);
  font: inherit; font-weight: 700; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
/* The ring goes round the whole stepper, so it doesn't crowd the number. */
.stepper input:focus-visible { outline: none; }
.stepper:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }

/* On narrow screens (or with large text) the dropdown moves under its label instead of running off the edge. */
.field:has(> .select) { flex-wrap: wrap; row-gap: 8px; }
.select { position: relative; display: inline-block; max-width: 100%; }
.select select {
  max-width: 100%; min-height: 44px; padding: 0 44px 0 18px; border: 1.5px solid var(--line); border-radius: 22px;
  background: var(--bg); color: var(--fg);
  font: inherit; font-size: 1rem; font-weight: 600; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.select::after {
  content: ""; position: absolute; top: 50%; right: 20px; width: 7px; height: 7px; pointer-events: none;
  border-right: 2px solid var(--fg); border-bottom: 2px solid var(--fg); transform: translateY(-70%) rotate(45deg);
}

.note { padding: 0 0 12px; font-size: 0.9375rem; color: var(--warn); }
.hint { font-size: 0.9375rem; color: var(--muted); }

/* Symbols */
.symbols { gap: 14px; }
.symbols .hint:first-of-type { margin-top: 4px; }
.symtext {
  width: 100%; min-height: 48px; padding: 0 16px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--well); color: var(--fg);
  font-family: var(--mono); font-size: 1.125rem; caret-color: var(--accent);
}
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.chip {
  min-width: 2.25em; min-height: 2.25em; padding: 0 8px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--well); color: var(--symbol);
  font-family: var(--mono); font-size: 1.125rem; cursor: pointer;
}
.chip:hover { border-color: var(--warn); color: var(--warn); text-decoration: line-through; }
.link {
  align-self: flex-start; min-height: 44px; padding: 0; border: 0; background: none; color: var(--fg);
  font: inherit; font-size: 0.9375rem; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 4px;
  cursor: pointer;
}
.link:hover { color: var(--accent); }

/* Strength: ruled and titled like the option groups above it */
.strength { border-top: 1.5px solid var(--fg); }
.tool .strength h2 { margin: 0; padding: 16px 0 4px; font-size: 1.25rem; letter-spacing: -0.01em; }
.tool .strength .rows { margin-top: 0; border-top: 0; }
.tool .explainer h2:first-child { margin-top: 0; }
/* Wide enough for "Strong protection", so all four values line up. */
.strength .row .label { min-width: 9.25em; }
.strength .value strong { font-weight: 700; }
.strength .value small { display: block; margin-top: 2px; font-size: 0.9375rem; color: var(--muted); }

/* Dice rolls */
/* Sits straight under the strength rows, as one more row. */
.dice { margin-top: -32px; border-bottom: 1px solid var(--rule); }
.dice summary {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 64px; font-weight: 700; cursor: pointer; list-style: none;
}
.dice summary::-webkit-details-marker { display: none; }
.dice summary:hover { color: var(--accent); }
/* A Show/Hide pill with a chevron, drawn like the Separator menu so it reads as a control. */
.dice .disclosure {
  display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 16px;
  border: 1.5px solid var(--line); border-radius: 20px;
  font-size: 0.9375rem; font-weight: 600; color: var(--fg);
}
.dice .disclosure::after {
  content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}
.dice[open] .disclosure::after { transform: translateY(2px) rotate(-135deg); }
.dice summary:hover .disclosure { border-color: var(--accent); color: var(--accent); }
.dice .when-open, .dice[open] .when-closed { display: none; }
.dice[open] .when-open { display: inline; }
.dice > p { margin-bottom: 16px; font-size: 1rem; color: var(--muted); }
.dice-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 24px;
  margin: 0 0 20px; padding: 0; list-style: none; font-family: var(--mono); font-size: 1.0625rem;
}
.dice-list .roll { margin-right: 12px; color: var(--muted); }

.tool .explainer { margin-top: 56px; }

@media print {
  :root { --well: #FFFFFF; --line: #000000; --digit: #000000; --symbol: #000000; --warn: #000000; }
  .modes, .actions, .options, .dice summary, .explainer { display: none !important; }
  .result { padding: 0; }
  .dice:not([open]) { display: none; }
}
