body:has(input[id="pretty"]:checked) .paragraph-pair p:nth-child(1) {
  text-wrap: pretty;
}
body:has(input[id="balance"]:checked) .paragraph-pair p:nth-child(1) {
  text-wrap: balance;
}
body:has(input[id="hyphens"]:checked) p {
  hyphens: auto;
}
body:has(input[id="justify"]:checked) p {
  text-align: justify;
}

/* --------------------------------------
   Reset    
-------------------------------------- */

* { box-sizing: border-box; }
:root { color-scheme: light dark; }
html { background: light-dark(white, black); }
body { margin: 0; }
.ar { direction: rtl;}
hr {
  border: none;
  border-top: 1px solid #ccc;
  margin: 3rem 33%;
}


/* --------------------------------------
   Overall layout & styling
-------------------------------------- */
article {
  grid-column: 2;
  margin-block: 4rem;
  margin-inline: 5ch;
}
section {
  position: relative;
}
p {
  font-size: 1.2rem;
  font-family: Georgia;
  color: light-dark(#444, white);
  line-height: 1.4;
  margin-block: 1lh;
}
a {
  color: light-dark(#444, white);
  text-decoration: none;
}


/* --------------------------------------
   Ghosts
-------------------------------------- */

body:has(input[id="ghosts"]:not(:checked)) .paragraph-pair p:nth-child(2) {
  display: none;
}
.paragraph-pair {
  position: relative;
}
.paragraph-pair p:nth-child(2) {
  position: absolute;
  z-index: -1;
  inset-block-start: 0;
  inset-inline-start: 0;
  margin: 0;
  color: light-dark(#9ff2f2, #0f6666);
}

/* --------------------------------------
   Guides
-------------------------------------- */
:root {
  --ideal-target-offset: 45px; 
  /*textWrapPrettyMaxStretch * textWrapPrettyStretchability*/
  --inner-limit-offset: 90px;
  /* textWrapPrettyMaxStretch * textWrapPrettyStretchability + textWrapPrettyMaxShrink * textWrapPrettyShrinkability*/
  --box-edge: light-dark(#eee, #333);
  --ideal-target: light-dark(#06b406, #00a700);
  --inner-limit: light-dark(magenta, #940094);
  --outer-limit: light-dark(red, #b60000);
}
.language-block {
  border: 1.5px solid transparent;
}
body:has(input[id="guides"]:checked) {
  .language-block {
    border-color: var(--box-edge);
    border-inline-end-color: var(--ideal-target);
  }
  &:has(input[id="pretty"]:checked) {
    .language-block {
      border-inline-end-color: var(--outer-limit);
    }
    .ideal-line, .new-limit-line {
      position: absolute;
      inset-block-start: 0;
      inset-block-end: 0;
      width: 1.5px;
    }
    .ideal-line {
      background-color: var(--ideal-target);
      inset-inline-end: var(--ideal-target-offset);
    }
    .new-limit-line {
      background-color: var(--inner-limit);
      inset-inline-end: var(--inner-limit-offset);
      width: 1.3px;
    }
  }
}


/* --------------------------------------
   Controls
-------------------------------------- */
nav {
  position: fixed;
  bottom: 0;
  left: 0;
  height: min-content;
  width: 100%;
  background: light-dark(rgba(249, 244, 244, 0.96), rgb(37, 66, 13, 0.95));
  box-shadow: 0 -1px 13px rgba(0, 0, 0, 0.2);
  padding: 1rem 1rem 0.5rem;
  z-index: 3;
  div {
    margin-block-end: 0.4rem;
  }
}
input {
  accent-color: light-dark(purple, yellow);
}
label, input {
  vertical-align: middle;
}
label {
  font-family: monospace;
  font-size: 1rem;
  padding-left: 0.33rem;
}
body:has(input[id="pretty"]:checked) .pretty label,
body:has(input[id="hyphens"]:checked) .hyphens label, 
body:has(input[id="justify"]:checked) .justify label, 
body:has(input[id="guides"]:checked) .guides label,
body:has(input[id="ghosts"]:checked) .ghosts label,
body:has(input[id="balance"]:checked) .balance label {
  color: light-dark(purple, yellow);  
}


/* --------------------------------------
   Error message for lack of support
-------------------------------------- */

.error-message { display: none; }
@supports not (text-wrap: pretty) {
  .error-message {
    color: white;
    padding: 2rem;
    margin-right: 3rem;
    background: darkred;
    display: block;
    text-align: center;
    font-size: 1.3rem;
    font-family: ui-system, sans-serif;
    a {
      color: #f1f170;
    }
    position: fixed;
    top: 50px;
    left: 290px;
  }
}