/* Shared controls for the Atomic Tools built from the same parts: the palette,
   the page frame, labels, buttons, segmented controls, sliders, notes and hints.

   A tool links this after atomic-shell.css and before its own <style>, so a
   rule in the page overrides the same selector here. Each page keeps its
   layout and whatever is its own. A control drawn the same way everywhere
   lives here once.

   Madlib Maker, Markdown ↔ Rich Text, Text Diff and Wordle Checker have their
   own styles and do not load this file. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ------------------------------------------------------------- palette
   A page adds its own tokens (a mark colour, a tint) in its own :root. */

:root {
  color-scheme: light;
  --paper: #f5f4ef;
  --surface: #fbfaf6;
  --ink: #111111;
  --ink-soft: #444444;
  --ink-muted: #66665f;
  --rule: #1a1a1a;
  --rule-soft: #d8d6cf;
  --focus: #2b5fff;
  --display: "GT America Expanded", -apple-system, BlinkMacSystemFont, sans-serif;
  --text: "GT America", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, "JetBrains Mono", monospace;
}

.dark {
  color-scheme: dark;
  --paper: #0e0e0d;
  --surface: #161614;
  --ink: #f3f1ea;
  --ink-soft: #cfccc4;
  --ink-muted: #a4a39d;
  --rule: #f3f1ea;
  --rule-soft: #2a2a28;
  --focus: #6f8dff;
}

/* ---------------------------------------------------------- page frame */

html, body { margin: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}

a { color: inherit; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

main {
  flex: 1;
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 48px 0 64px;
  display: flex; flex-direction: column; gap: 24px;
}

/* The one line under the top bar that says what the tool does. */
.page-sub { color: var(--ink-muted); font-size: 0.95rem; max-width: 56ch; }

.pane { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field { display: inline-flex; align-items: center; gap: 8px; }

/* -------------------------------------------------------------- labels */

.section-label {
  font-family: var(--text); font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-muted);
}
/* A count beside a label: "8 items", "174 words". */
.pane-count { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- buttons
   Buttons and segmented controls draw at 32px. A 6px overhang above and
   below makes each a 44px tap, and a 12px row gap keeps wrapped rows from
   overlapping. */

.text-btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--rule-soft); border-radius: 0; background: transparent;
  color: var(--ink-muted);
  font-family: var(--text); font-size: 0.7rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}
.text-btn svg { width: 12px; height: 12px; flex: none; }
.text-btn:disabled { opacity: 0.45; cursor: default; }

/* The one action that moves a screen forward: filled, like a pressed toggle. */
.text-btn.primary {
  padding: 6px 18px;
  border-color: var(--ink); background: var(--ink);
  color: var(--paper);
}

.segmented { display: inline-flex; border: 1px solid var(--rule-soft); }
.segmented button {
  position: relative;
  min-height: 32px;
  padding: 6px 12px;
  border: 0; background: transparent;
  color: var(--ink-muted);
  font-family: var(--text); font-size: 0.7rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--rule-soft); }
.segmented button::before,
.text-btn::before { content: ""; position: absolute; inset: -6px 0; }

.segmented button[aria-pressed="true"],
.text-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* Hover leaves a pressed or chosen control alone: it is filled with ink, and
   ink text on it would hide the label. The exclusions sit in :where() so the
   rules stay light enough for a page's own hover rule to override them. */
@media (hover: hover) and (pointer: fine) {
  .segmented button:where(:not([aria-pressed="true"])):hover { color: var(--ink); }
  .text-btn:where(:not(:disabled, [aria-disabled="true"], [aria-pressed="true"], [aria-checked="true"])):hover { color: var(--ink); border-color: var(--ink); }
  .text-btn.primary:where(:not(:disabled, [aria-disabled="true"])):hover { background: var(--ink-soft); border-color: var(--ink-soft); color: var(--paper); }
}

/* ------------------------------------------------------------- sliders
   Drawn like the page's rules: a 1px track and a square thumb. The box is
   32px tall (44px for touch), so the thumb is easy to catch. :where() keeps
   these at no specificity, so a page sets a width with any selector. */

:where(input[type="range"]) {
  appearance: none; -webkit-appearance: none;
  width: 132px; height: 32px;
  background: transparent;
  cursor: pointer;
}
:where(input[type="range"])::-webkit-slider-runnable-track { height: 1px; background: var(--rule); }
:where(input[type="range"])::-moz-range-track { height: 1px; background: var(--rule); }
:where(input[type="range"])::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 10px; height: 18px; margin-top: -9px;
  border: 0; border-radius: 0;
  background: var(--ink);
}
:where(input[type="range"])::-moz-range-thumb {
  width: 10px; height: 18px;
  border: 0; border-radius: 0;
  background: var(--ink);
}

@media (pointer: coarse) {
  :where(input[type="range"]) { height: 44px; }
  :where(input[type="range"])::-webkit-slider-thumb { width: 16px; height: 26px; margin-top: -13px; }
  :where(input[type="range"])::-moz-range-thumb { width: 16px; height: 26px; }
}

/* ------------------------------------------------------- fields, menus */

textarea::placeholder { color: var(--ink-muted); }
/* The chevron a .select-wrap draws over its native select. */
.select-wrap svg {
  position: absolute; right: 10px; top: 50%;
  width: 12px; height: 12px; margin-top: -6px;
  color: var(--ink-muted);
  pointer-events: none;
}

/* ------------------------------------------------------ notes and hints */

/* What shows where a result will be, before there is one. */
.placeholder {
  padding: 40px 20px;
  border: 1px dashed var(--rule-soft);
  color: var(--ink-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* Something the page did or could not do. */
.status-note {
  padding: 10px 14px;
  border: 1px solid var(--rule-soft);
  color: var(--ink-muted);
  font-size: 0.85rem;
}
/* Problems and warnings are not the empty state: the full-strength rule, ink
   text and a mark. */
.status-note.strong {
  display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px;
  border-color: var(--rule);
  color: var(--ink);
}
.status-note.strong svg { width: 16px; height: 16px; margin-top: 2px; }
/* A note whose cause can be taken back carries the button at its end, or
   under the text where there isn't room beside it. */
.status-note.has-action { grid-template-columns: 16px minmax(0, 1fr) auto; align-items: center; }
.status-note.has-action svg { align-self: start; }

.hint { color: var(--ink-muted); font-size: 0.85rem; line-height: 1.55; }

@media (max-width: 560px) {
  main { padding: 32px 0 48px; gap: 18px; }
  .status-note.has-action { grid-template-columns: 16px minmax(0, 1fr); }
  .status-note.has-action .text-btn { grid-column: 2; justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
