/* Fair Copy. Loaded after ../style.css and built on its tokens. Its controls (the language switch, buttons, and
   menus) are drawn like Fair Roll's in ../fair-roll/fair-roll.css: keep the two matching. Fair Copy's options sit
   in the toolbar beside Format rather than in ruled rows, because they shape what Format does. */

/* Light and dark values, as in style.css: light-dark() where the browser has it, the light values otherwise.
   The same values as Fair Roll's. */
:root {
  --well: #E1EAE5; --line: #707E77; --warn: #A14206;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@supports (color: light-dark(#000, #FFF)) {
  :root {
    /* Recessed ground for the text box */
    --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);
    /* Problems. Light: an orange, 6.1:1 on --bg. Dark: a rose, 8.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; }
.tool code { font-family: var(--mono); font-size: 0.9em; }

.copier { margin-top: 40px; display: flex; flex-direction: column; gap: 32px; }
/* Code needs more width than prose: on wide screens the tool grows past the reading column, centered on it,
   while the heading, intro, and explainer keep their measure. */
@media (min-width: 70rem) {
  .tool .copier { align-self: center; width: min(1032px, calc(100vw - 48px)); }
  .report-text, .report-more { max-width: 72ch; }
}
.copier p { margin: 0; max-width: none; }
.copier fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.copier [hidden] { display: none !important; }

/* The language switch. The radio covers its label, so the label is the hit area. */
.copier .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; }
/* Five languages fit on two rows of a phone with less padding. */
@media (max-width: 30rem) {
  .languages label { padding: 0 12px; }
}

/* The text box. Lines don't wrap, so the line and column of a problem match what you see, and the line numbers
   in the gutter beside it line up. The box draws the border; the gutter scrolls with the text area. */
.editor { display: flex; flex-direction: column; gap: 16px; }
.code-box {
  display: flex; align-items: stretch; overflow: hidden;
  border: 1.5px solid var(--line); border-radius: 16px; background: var(--well);
}
.code-box:has(.code:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
/* A file held over the box: the border takes the accent, as a hovered button does. */
.code-box.dropping { border-color: var(--accent); border-style: dashed; }
.gutter, .code { font-family: var(--mono); font-size: 0.9375rem; line-height: 1.6; }
/* The numbers are positioned, so a long text can't make the box taller: the gutter is as tall as the text area,
   and page.js moves the numbers as it scrolls and widens the gutter for longer numbers (--digits). */
.gutter {
  position: relative; flex: none; width: calc(max(2, var(--digits, 1)) * 1ch + 22px); overflow: hidden;
  border-right: 1px solid var(--rule); color: var(--muted);
  user-select: none; -webkit-user-select: none;
}
.gutter pre {
  position: absolute; top: 0; right: 10px; margin: 0; padding: 16px 0;
  font: inherit; text-align: right; font-variant-numeric: tabular-nums; will-change: transform;
}
.code {
  display: block; flex: 1 1 auto; min-width: 0; min-height: 20rem; margin: 0; padding: 16px 18px 16px 14px;
  border: 0; border-radius: 0; background: transparent; color: var(--fg); tab-size: 4;
  white-space: pre; overflow-wrap: normal; overflow: auto; resize: vertical; caret-color: var(--accent);
}
.code::placeholder { color: var(--muted); opacity: 1; }
.code:focus-visible { outline: none; }

/* The buttons, and the options that shape Format beside them. They wrap under the buttons on narrow screens. */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* The keyboard shortcut, and a note that a bookmark keeps the settings. The shortcut is for keyboards only. */
.hints { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 24px; margin-top: -4px; }
.hint { font-size: 0.9375rem; color: var(--muted); }
@media (hover: none) and (pointer: coarse), (max-width: 40rem) {
  #shortcut-hint { display: none; }
}

/* "This looks like JSON": a quiet row under the language switch. */
.suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: -16px !important; }
.suggest #suggest-text { font-weight: 600; }
.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:disabled { opacity: 1; border-color: var(--rule); color: var(--muted); cursor: not-allowed; }
.button:disabled:hover { border-color: var(--rule); color: var(--muted); }
.link {
  min-height: 44px; padding: 0 4px; 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); }
.button:focus-visible, .link:focus-visible, .problem:focus-visible, .select select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}

/* The report: what a check or format found. Problems are buttons that put the cursor where they are. */
.report { display: flex; flex-direction: column; gap: 12px; }
.tool .report-title { margin: 0; font-size: 1.375rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.report[data-state="ok"] .report-title { color: var(--accent); }
.report[data-state="problems"] .report-title, .report[data-state="stopped"] .report-title { color: var(--warn); }
.report[data-state="checked"] .report-title, .report[data-state="empty"] .report-title { color: var(--fg); }
.report[data-state="busy"] .report-title { color: var(--muted); }
.report-text, .report-more { font-size: 1rem; color: var(--muted); }
.problems { margin: 4px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.problem {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 16px; width: 100%; min-height: 44px;
  padding: 12px 0; border: 0; border-bottom: 1px solid var(--rule); background: none; color: var(--fg);
  font: inherit; font-size: 1rem; line-height: 1.45; text-align: left; cursor: pointer;
}
.problem .where { flex: none; min-width: 11.5em; font-weight: 700; color: var(--warn); font-variant-numeric: tabular-nums; }
.problem .what { flex: 1 1 18em; }
.problem:hover .what { color: var(--accent); }

/* Options: a label and a menu each, in a row */
.options fieldset { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.field { display: flex; align-items: center; gap: 10px; }
.field > label { font-size: 0.9375rem; font-weight: 600; color: var(--muted); }
.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);
}

.tool .explainer { margin-top: 56px; }
.tool .explainer h2:first-child { margin-top: 0; }

@media print {
  :root { --well: #FFFFFF; --line: #000000; --warn: #000000; }
  .languages, .toolbar, .gutter, .explainer { display: none !important; }
  .code-box { border: 0; background: none; }
  .code { min-height: 0; border: 0; padding: 0; resize: none; overflow: visible; white-space: pre-wrap; }
}
