/* Layout: one reading column (~44rem) inside a 66rem frame; examples and the
   Slop-o-meter break out to two columns on wide screens. Proofreader's red pen
   on cool paper: slop gets struck through, the clean version stays in ink. */
:root {
  --paper: #f2f3f0;
  --surface: #ffffff;
  --ink: #15181e;
  --muted: #5a606b;
  --rule: #d6d9d3;
  --pen: #c42a1f;
  --pen-soft: #f7dfdb;
  --warn: #9a6200;
  --warn-soft: #f5e8cc;
  --ok: #1d7448;
  --ok-soft: #dbeee2;
  --focus: #2b56d1;

  --mono: ui-monospace, "JetBrains Mono", "SF Mono", "Cascadia Code", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: clamp(1.75rem, 4vw, 2.25rem);
  --step-4: clamp(2.75rem, 9vw, 5.75rem);

  --frame: 66rem;
  --read: 44rem;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111317;
    --surface: #181b21;
    --ink: #e8eaee;
    --muted: #9ba1ad;
    --rule: #2a2e37;
    --pen: #ff6b5d;
    --pen-soft: #3a1e1b;
    --warn: #e7b14a;
    --warn-soft: #362a13;
    --ok: #5ccb92;
    --ok-soft: #15301f;
    --focus: #8aa8ff;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #111317;
  --surface: #181b21;
  --ink: #e8eaee;
  --muted: #9ba1ad;
  --rule: #2a2e37;
  --pen: #ff6b5d;
  --pen-soft: #3a1e1b;
  --warn: #e7b14a;
  --warn-soft: #362a13;
  --ok: #5ccb92;
  --ok-soft: #15301f;
  --focus: #8aa8ff;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.55;
}

a { color: inherit; text-underline-offset: 0.18em; }
a:hover { color: var(--pen); }

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

[hidden] { display: none !important; }

code {
  font-family: var(--mono);
  font-size: 0.9em;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
}
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 0.5rem 0.75rem; z-index: 5; }

.frame {
  max-width: var(--frame);
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-block: 1.25rem;
  font-family: var(--mono);
  font-size: var(--step--1);
}

.topbar__brand {
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.topbar__tools { display: flex; gap: 0.5rem; align-items: center; }

.chip-btn {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.2;
}
.chip-btn:hover { border-color: var(--ink); color: var(--ink); }

/* ---------- hero ---------- */

.hero {
  padding-block: clamp(2.5rem, 8vw, 6rem) clamp(2.5rem, 6vw, 4.5rem);
  border-bottom: 1px solid var(--rule);
}

.hero__title {
  font-family: var(--mono);
  font-size: var(--step-4);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.045em;
  margin: 0;
  text-wrap: balance;
}

.strike {
  position: relative;
  display: inline-block;
  text-decoration: none;
}
.strike::after {
  content: "";
  position: absolute;
  left: -0.04em;
  right: -0.04em;
  top: 52%;
  height: 0.09em;
  background: var(--pen);
  border-radius: 0.05em;
  transform: rotate(-2.5deg);
}

.hero__tagline {
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 1.75rem 0 0;
  max-width: var(--read);
  text-wrap: balance;
}

.hero__lead {
  font-size: var(--step-1);
  color: var(--muted);
  margin: 1rem 0 0;
  max-width: 38rem;
}

.hero__cta {
  display: inline-block;
  margin-top: 2rem;
  font-family: var(--mono);
  font-weight: 700;
  font-size: var(--step-0);
  background: var(--ink);
  color: var(--paper);
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius);
  text-decoration: none;
}
.hero__cta:hover { background: var(--pen); color: #fff; }

/* ---------- sections ---------- */

.section {
  padding-block: clamp(3rem, 7vw, 5rem);
  border-bottom: 1px solid var(--rule);
}

.section__title {
  font-family: var(--mono);
  font-size: var(--step-3);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}

.section__intro {
  color: var(--muted);
  margin: 0.75rem 0 0;
  max-width: var(--read);
}

/* ---------- examples ---------- */

.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 1.75rem;
  padding: 0.25rem;
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
}

.tab {
  font: inherit;
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--paper); }

.tab__count {
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  opacity: 0.7;
}

.examples__nojs-title {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--step-1);
  font-weight: 800;
}
.has-tabs .examples__nojs-title { display: none; }

.examples {
  display: grid;
  gap: 2.5rem;
  margin-top: 2.5rem;
}

.example__context {
  font-family: var(--mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.example__pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
}

@media (min-width: 760px) {
  .example__pair {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    align-items: start;
  }
}

.msg {
  min-width: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0.9rem 1rem 1rem;
}

.msg__label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 0.6rem;
}
.msg--dont .msg__label { color: var(--pen); }
.msg--do .msg__label { color: var(--ok); }

.msg__body {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
  font-size: 0.9375rem;
  line-height: 1.55;
}

.msg--dont .msg__body { color: var(--muted); }
.msg--dont .msg__body strong { color: var(--ink); }

.msg--dont del {
  text-decoration: line-through;
  text-decoration-color: var(--pen);
  text-decoration-thickness: 2px;
  color: var(--muted);
}

.msg--do {
  border-color: var(--ok);
  background: var(--ok-soft);
}
.msg--do .msg__body {
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
}

/* ---------- rules ---------- */

.rules {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 2.5rem;
}

@media (min-width: 760px) {
  .rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rule--lead { grid-column: 1 / -1; }
}

.rule {
  min-width: 0;
  border-top: 1px solid var(--rule);
  padding-block: 1.25rem 1.75rem;
  display: grid;
  gap: 0.4rem;
  align-content: start;
}

.rule__excuse {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--muted);
  quotes: "“" "”";
}
:lang(uk) .rule__excuse { quotes: "«" "»"; }
.rule__excuse::before { content: open-quote; }
.rule__excuse::after { content: close-quote; }
.rule__excuse del {
  text-decoration: line-through;
  text-decoration-color: var(--pen);
  text-decoration-thickness: 2px;
}

.rule__text {
  margin: 0;
  font-size: var(--step-2);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.rule__why {
  margin: 0;
  color: var(--muted);
  max-width: 34rem;
}

.rule--lead {
  border-top: 2px solid var(--ink);
  padding-block: 1.5rem 2.25rem;
}
.rule--lead .rule__excuse { font-size: var(--step-0); }
.rule--lead .rule__text {
  font-family: var(--mono);
  font-size: clamp(1.9rem, 5.5vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}
.rule--lead .rule__why { font-size: var(--step-1); }

/* ---------- Slop-o-meter ---------- */

.section__title--badged {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.badge-beta {
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  cursor: help;
  transform: translateY(0.1em);
}

.meter__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  margin-top: 2rem;
}

@media (min-width: 880px) {
  .meter__grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
  /* Results run longer than the input; keep the text in view while scrolling them. */
  .meter__input-wrap { position: sticky; top: calc(1rem + env(safe-area-inset-top, 0px)); }
}

.meter__input-wrap,
.meter__result-wrap { min-width: 0; display: grid; gap: 0.6rem; align-content: start; }

.meter__label {
  margin: 0;
  line-height: 1.55;
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.meter__input {
  width: 100%;
  min-height: 18rem;
  resize: vertical;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.meter__input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 2px var(--focus); }

.meter__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.meter__privacy {
  margin: 0;
  font-size: var(--step--1);
  color: var(--muted);
}

.meter__result {
  min-width: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
}

.score { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }

.score__num {
  font-family: var(--mono);
  font-size: clamp(3.5rem, 10vw, 5rem);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.score__max { font-family: var(--mono); color: var(--muted); font-weight: 600; }

[data-level="low"] .score__num { color: var(--ok); }
[data-level="mid"] .score__num { color: var(--warn); }
[data-level="high"] .score__num { color: var(--pen); }

.score__meta {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--muted);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.score__verdict {
  margin: 0;
  font-size: var(--step-2);
  font-weight: 700;
  line-height: 1.2;
}
.score__verdict:empty { display: none; }

.score__status { margin: 0; color: var(--muted); }
.score__status:empty { display: none; }

.bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(90deg, var(--ok-soft) 0 20%, var(--warn-soft) 20% 50%, var(--pen-soft) 50% 100%);
}
.bar__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--muted);
  border-radius: 999px;
  transition: width 240ms ease-out;
}
[data-level="low"] .bar__fill { background: var(--ok); }
[data-level="mid"] .bar__fill { background: var(--warn); }
[data-level="high"] .bar__fill { background: var(--pen); }

.bar-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.subhead {
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.hits { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }

.hit {
  border-top: 1px solid var(--rule);
  padding-top: 0.5rem;
}
.hit__head { display: flex; justify-content: space-between; gap: 0.75rem; align-items: baseline; }
.hit__name { font-weight: 700; }
.hit__pts {
  font-family: var(--mono);
  font-size: var(--step--1);
  color: var(--pen);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.hit__hint { margin: 0.15rem 0 0; font-size: 0.875rem; color: var(--muted); }
.hit--none { font-weight: 600; color: var(--ok); }

.annotated {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.875rem;
  line-height: 1.6;
  max-height: 22rem;
  overflow: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  background: var(--paper);
}
.annotated mark {
  background: var(--pen-soft);
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--pen);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.15em;
  border-radius: 2px;
  cursor: help;
}

.meter__share { display: grid; gap: 0.35rem; }
.meter__fine { margin: 0; font-size: var(--step--1); color: var(--muted); }

.btn {
  font: inherit;
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  justify-self: start;
}
.btn:hover:not(:disabled) { background: var(--ink); color: var(--paper); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--ghost { border-color: var(--rule); }
.btn.is-done { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }

/* Without JS the result panel has nothing to show. */
.meter:not(.is-live) .meter__result-wrap,
.meter:not(.is-live) .meter__actions { display: none; }

.noscript {
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--muted);
  margin: 1.5rem 0 0;
}

/* ---------- share ---------- */

.share-list {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  gap: 1rem;
  max-width: var(--read);
}

.share-item__label {
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.4rem;
}

.share-item__row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.share-item__text {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- footer ---------- */

.footer {
  padding-block: 2.5rem 3rem;
  font-size: var(--step--1);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
}
.footer p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .bar__fill { transition: none; }
}
