/* ==========================================================================
   BeautifyText.com — main stylesheet
   --------------------------------------------------------------------------
   Plain CSS3, no preprocessor and no framework. Organised as:
     1. Tokens            6. Tool UI
     2. Reset & base      7. Results & feedback
     3. Layout            8. Content pages
     4. Header & nav      9. Related tools
     5. Footer           10. Responsive
   ========================================================================== */

/* 1. Tokens ================================================================ */

:root {
  --blue-50:  #eff4ff;
  --blue-100: #dbe4ff;
  --blue-200: #bfd0fe;
  --blue-500: #3b6fe0;
  --blue-600: #1a56db;
  --blue-700: #1741a6;
  --blue-900: #10275f;

  --ink:      #141a26;
  --ink-soft: #3d4655;
  --ink-mute: #5c6675;
  --line:     #e2e6ee;
  --line-strong: #cfd5e0;
  --surface:  #ffffff;
  --surface-2:#f7f9fc;
  --surface-3:#eef2f8;

  --danger:   #b3261e;
  --danger-bg:#fdf0ef;
  --ok:       #0f5132;
  --ok-bg:    #eaf6ef;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", "Courier New", monospace;

  --text-xs:   0.8125rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.0625rem;
  --text-xl:   1.3125rem;
  --text-2xl:  1.625rem;
  --text-3xl:  2.125rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.75rem;
  --space-8: 3.5rem;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(16, 39, 95, 0.06);
  --shadow:    0 2px 8px rgba(16, 39, 95, 0.08);

  --wrap: 68rem;
  --wrap-narrow: 46rem;

  --focus-ring: 0 0 0 3px rgba(26, 86, 219, 0.35);
}

/* 2. Reset & base ========================================================== */

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

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

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0 0 var(--space-3);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.011em;
  text-wrap: balance;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); margin-top: var(--space-7); }
h3 { font-size: var(--text-xl); margin-top: var(--space-6); }
h4 { font-size: var(--text-lg); margin-top: var(--space-5); }

p { margin: 0 0 var(--space-4); }

a {
  color: var(--blue-700);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover { color: var(--blue-900); }

ul, ol { margin: 0 0 var(--space-4); padding-left: 1.4em; }
li { margin-bottom: var(--space-2); }
li:last-child { margin-bottom: 0; }

img, svg { max-width: 100%; height: auto; }

code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.9em; }

code {
  padding: 0.12em 0.36em;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--blue-900);
}

:focus-visible {
  outline: 2px solid var(--blue-600);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

hr {
  height: 1px;
  margin: var(--space-6) 0;
  border: 0;
  background: var(--line);
}

/* Visible only to screen readers, until focused. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--blue-600);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus { top: 0; color: #fff; }

/* 3. Layout ================================================================ */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.layout { padding-bottom: var(--space-6); }

main { display: block; }

.page-intro {
  max-width: var(--wrap-narrow);
  padding: var(--space-6) 0 var(--space-5);
}

.page-intro h1 { margin-bottom: var(--space-3); }

.lede {
  margin: 0;
  color: var(--ink-mute);
  font-size: var(--text-lg);
  line-height: 1.6;
}

/*
 * Breadcrumb trail. Sits between the header and the page intro, so the intro
 * loses its generous top padding when a trail is present — otherwise the two
 * stack into an awkward gap.
 */
.breadcrumbs {
  padding-top: var(--space-4);
  font-size: var(--text-sm);
}

.breadcrumbs__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--ink-mute);
}

.breadcrumbs__item { margin: 0; }

/* Separator drawn in CSS so it is never read out by a screen reader. */
.breadcrumbs__item + .breadcrumbs__item::before {
  content: "/";
  margin-right: var(--space-2);
  color: var(--border);
}

.breadcrumbs__item a { text-decoration: underline; text-underline-offset: 2px; }

/*
 * The trail sits inside the same .wrap as the intro that follows it, so the
 * intro drops its own top padding and the trail supplies the gap instead.
 */
.breadcrumbs + .page-intro { padding-top: 0; }

.page-content {
  max-width: var(--wrap-narrow);
  margin-top: var(--space-7);
}

.page-content h2 { margin-top: var(--space-7); }
.page-content h2:first-child { margin-top: 0; }

.prose-note {
  margin: var(--space-5) 0;
  padding: var(--space-4) var(--space-5);
  border-left: 3px solid var(--blue-200);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-2);
  color: var(--ink-soft);
}

.prose-note p:last-child { margin-bottom: 0; }

/* 4. Header & nav ========================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(8px);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  min-height: 4rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-right: auto;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover { color: var(--ink); }
.brand__mark { display: block; width: 34px; height: 34px; }

.brand__name {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand__name-accent { color: var(--blue-600); }

.nav-toggle {
  display: none;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}

.nav-toggle__bars,
.nav-toggle__bars::before,
.nav-toggle__bars::after {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.nav-toggle__bars { position: relative; }
.nav-toggle__bars::before,
.nav-toggle__bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle__bars::before { top: -5px; }
.nav-toggle__bars::after { top: 5px; }

.site-nav__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav__item { margin: 0; }

.site-nav__link {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}

.site-nav__link:hover { background: var(--surface-3); color: var(--blue-900); }

.site-nav__link.is-current {
  background: var(--blue-50);
  color: var(--blue-700);
}

/* 5. Footer ================================================================ */

.site-footer {
  margin-top: var(--space-8);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.site-footer__inner {
  display: grid;
  gap: var(--space-5);
  padding-block: var(--space-6);
}

.site-footer__name {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--ink);
}

.site-footer__note {
  margin: 0;
  max-width: 34ch;
  color: var(--ink-mute);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.site-footer__heading {
  margin: 0 0 var(--space-3);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}

.site-footer__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer__list li { margin-bottom: var(--space-2); }

.site-footer__list a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: var(--text-sm);
}

.site-footer__list a:hover { color: var(--blue-700); text-decoration: underline; }

.site-footer__legal {
  margin: 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
  color: var(--ink-mute);
  font-size: var(--text-sm);
}

/* 6. Tool UI =============================================================== */

.tool {
  margin-top: var(--space-5);
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.tool__field { margin-bottom: var(--space-5); }

.tool__label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
}

.tool__hint {
  display: block;
  margin-top: var(--space-1);
  color: var(--ink-mute);
  font-size: var(--text-xs);
  font-weight: 400;
}

.tool__textarea {
  display: block;
  width: 100%;
  min-height: 13.5rem;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  resize: vertical;
  tab-size: 4;
}

.tool__textarea--out {
  background: var(--surface-2);
}

.tool__textarea::placeholder { color: #99a1ae; }

.tool__textarea:focus {
  border-color: var(--blue-500);
  outline: none;
  box-shadow: var(--focus-ring);
}

.tool__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}

.tool__row--split { align-items: stretch; }
.tool__row > .tool__field { flex: 1 1 14rem; margin-bottom: 0; }

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.field__label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--ink-soft);
}

select,
input[type="text"],
input[type="search"] {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
}

select:focus,
input[type="text"]:focus {
  border-color: var(--blue-500);
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Checkboxes laid out as a wrapping grid of equal-height cells. */
.options {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  font-size: var(--text-sm);
}

.option:hover { border-color: var(--blue-200); background: var(--blue-50); }

.option input {
  flex: 0 0 auto;
  width: 1.0625rem;
  height: 1.0625rem;
  margin: 0.2rem 0 0;
  accent-color: var(--blue-600);
  cursor: pointer;
}

.option__text { display: block; min-width: 0; }

.option__title { display: block; font-weight: 600; color: var(--ink); }

.option__desc {
  display: block;
  margin-top: 0.1rem;
  color: var(--ink-mute);
  font-size: var(--text-xs);
  line-height: 1.45;
}

/*
 * Emphasise checked options. The checkbox is the only state-bearing element in
 * the control, so the not-yet-universally-supported :has() selector is a pure
 * enhancement: it tints the whole tile. Everything remains usable without it,
 * and it is wrapped so an unsupported selector cannot drop the rule block.
 */
@supports selector(:has(*)) {
  .option:has(input:checked) {
    border-color: var(--blue-500);
    background: var(--blue-50);
  }
}

.option:focus-within {
  border-color: var(--blue-500);
}

/* Single-column variant, for option sets with long explanatory text. */
.options--single { grid-template-columns: 1fr; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.5rem;
  padding: var(--space-2) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--blue-600);
  color: #fff;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.btn:hover { background: var(--blue-700); color: #fff; }
.btn:active { transform: translateY(1px); }

.btn--secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.btn--secondary:hover {
  border-color: var(--blue-200);
  background: var(--blue-50);
  color: var(--blue-900);
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--blue-700);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.btn--ghost:hover { background: var(--blue-50); color: var(--blue-900); }

.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn[disabled]:active { transform: none; }

.shortcut-hint {
  margin: calc(var(--space-4) * -1) 0 var(--space-5);
  color: var(--ink-mute);
  font-size: var(--text-xs);
}

/* 7. Results & feedback ==================================================== */

.status {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  min-height: 1.5rem;
  margin: var(--space-4) 0 0;
  color: var(--ink-soft);
  font-size: var(--text-sm);
}

.status:empty { display: none; }

.status__badge {
  flex: 0 0 auto;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok);
  font-size: var(--text-xs);
  font-weight: 700;
}

.status--error { color: var(--danger); }

.status--error .status__badge { background: var(--danger-bg); color: var(--danger); }

.stats {
  display: grid;
  gap: var(--space-3);
  margin: 0 0 var(--space-5);
  padding: 0;
  list-style: none;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
}

.stat {
  margin: 0;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.stat__value {
  display: block;
  font-size: var(--text-2xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  color: var(--blue-700);
}

.stat__label {
  display: block;
  margin-top: var(--space-1);
  color: var(--ink-mute);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat--wide { grid-column: span 2; }

.freq {
  margin: 0;
  padding: 0;
  list-style: none;
}

.freq__row {
  display: grid;
  grid-template-columns: minmax(6rem, 1fr) 3fr auto;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
}

.freq__word {
  overflow-wrap: anywhere;
  font-weight: 600;
  color: var(--ink-soft);
}

.freq__bar {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.freq__bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--blue-500);
}

.freq__count {
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute);
}

.tool__subheading {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
}

.empty-hint {
  margin: 0;
  padding: var(--space-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink-mute);
  font-size: var(--text-sm);
}

kbd {
  padding: 0.1em 0.4em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.85em;
}

/* 8. Content pages ========================================================= */

.card-grid {
  display: grid;
  gap: var(--space-4);
  margin: var(--space-5) 0;
  padding: 0;
  list-style: none;
  grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr));
}

.card {
  margin: 0;
  height: 100%;
}

.card__link {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  height: 100%;
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.card__link:hover {
  border-color: var(--blue-200);
  box-shadow: var(--shadow);
}

.card__title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--blue-700);
}

.card__text {
  margin: 0;
  color: var(--ink-mute);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.card__meta {
  margin-top: auto;
  padding-top: var(--space-3);
  color: var(--ink-mute);
  font-size: var(--text-xs);
  font-weight: 600;
}

.table-scroll { overflow-x: auto; margin: 0 0 var(--space-5); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

caption {
  margin-bottom: var(--space-2);
  color: var(--ink-mute);
  font-size: var(--text-sm);
  text-align: left;
}

th, td {
  padding: var(--space-3);
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th { background: var(--surface-2); font-weight: 700; }

tbody tr:nth-child(even) td { background: #fafbfd; }

dl.faq { margin: 0; }

dl.faq dt {
  margin-top: var(--space-5);
  font-weight: 700;
  color: var(--ink);
}

dl.faq dd { margin: var(--space-2) 0 0; color: var(--ink-soft); }

.contact-block {
  margin: var(--space-5) 0;
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.contact-block p:last-child { margin-bottom: 0; }

.contact-email {
  font-size: var(--text-xl);
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* 9. Related tools ========================================================= */

.related {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}

.related__heading {
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
}

.related__list {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}

.related__item { margin: 0; }

.related__link {
  display: block;
  height: 100%;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
}

.related__link:hover { border-color: var(--blue-200); background: var(--blue-50); }

.related__label {
  display: block;
  font-weight: 700;
  color: var(--blue-700);
  font-size: var(--text-sm);
}

.related__text {
  display: block;
  margin-top: var(--space-1);
  color: var(--ink-mute);
  font-size: var(--text-xs);
  line-height: 1.5;
}

/* 10. Responsive =========================================================== */

@media (max-width: 46rem) {
  :root {
    --text-3xl: 1.75rem;
    --text-2xl: 1.4375rem;
  }

  .nav-toggle { display: inline-flex; }

  .site-nav {
    flex-basis: 100%;
    display: none;
    padding-bottom: var(--space-3);
  }

  .site-nav.is-open { display: block; }

  .site-nav__list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    border-top: 1px solid var(--line);
  }

  .site-nav__link {
    padding: var(--space-3) var(--space-2);
    border-radius: 0;
    font-size: var(--text-base);
  }

  .tool { padding: var(--space-4); }

  .stat--wide { grid-column: span 1; }

  .freq__row { grid-template-columns: minmax(4.5rem, 1.2fr) 2fr auto; }
}

@media (min-width: 46.0625rem) {
  /* Progressive enhancement: a menu button is pointless without JS. */
  .nav-toggle { display: none !important; }

  .site-footer__inner {
    grid-template-columns: 2fr 1fr 1fr;
    align-items: start;
  }

  .site-footer__legal { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .site-header, .site-footer, .related, .actions, .nav-toggle { display: none !important; }

  .tool { border: 0; padding: 0; box-shadow: none; }

  body { font-size: 11pt; }
}
