/* ProfitSmarts. One stylesheet, nothing loaded from elsewhere.
   Two colours carry the idea: teal is what we acted on, amber hatch is what
   we held back. They mean that everywhere they appear. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f5;
  --fg: #15232b;
  --muted: #56646c;
  --rule: #d6ddda;
  --panel: #ebf0ee;
  --band: #0f2f38;
  --band-fg: #eef4f2;
  --treated: #0b6e69;
  --treated-strong: #08524e;
  --held: #b7791f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d171b;
    --fg: #e6ecea;
    --muted: #9fb0b6;
    --rule: #23343b;
    --panel: #132228;
    --band: #102a31;
    --band-fg: #eef4f2;
    --treated: #4cc3b8;
    --treated-strong: #7ad8cf;
    --held: #d9a441;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  overflow-wrap: break-word;
}

header, main, footer {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Display type: a local serif, so no request leaves the page. */
h1, h2, .figure, #start ol > li::before {
  font-family: "Iowan Old Style", Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
}

h1 {
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 1.25rem;
}

h2 {
  font-size: 1.55rem;
  line-height: 1.25;
  font-weight: 600;
  margin: 0 0 1rem;
}

p, ul, ol, dl { margin: 0 0 1rem; }
ul, ol { padding-left: 1.25rem; }
li { margin-bottom: 0.5rem; }

section {
  margin: 4rem auto;
  padding-top: 2.5rem;
  border-top: 1px solid var(--rule);
}

main > section:first-child {
  margin-top: 3rem;
  border-top: 0;
  padding-top: 0;
}

main > h1:first-child { margin-top: 3rem; }

a {
  color: var(--treated);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

a:hover { color: var(--treated-strong); }

a:focus-visible {
  outline: 3px solid var(--held);
  outline-offset: 3px;
  border-radius: 2px;
}

/* The band: header, and on the landing page the opening section, in full
   bleed. A border-image outset paints past both edges without 100vw, so the
   Windows scrollbar never causes a horizontal scroll, and in one paint, so
   no seam shows at fractional pixel edges. */

header, #what {
  --treated: #4cc3b8;
  --treated-strong: #7ad8cf;
  color: var(--band-fg);
  border-image: linear-gradient(var(--band), var(--band)) fill 0 / 0 / 0 100vmax;
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

header a,
header a:hover { color: var(--band-fg); }

header .wordmark {
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
}

/* The mark: two bars acted on, one held back. */
header .wordmark::before {
  content: "";
  display: inline-block;
  width: 1.05rem;
  height: 0.85rem;
  margin-right: 0.55rem;
  vertical-align: -0.05rem;
  background:
    linear-gradient(var(--treated), var(--treated)) 0 0 / 0.25rem 100% no-repeat,
    linear-gradient(var(--treated), var(--treated)) 0.4rem 0 / 0.25rem 100% no-repeat,
    repeating-linear-gradient(135deg, var(--held) 0 1.5px, transparent 1.5px 3.5px) 0.8rem 0 / 0.25rem 100% no-repeat;
}

header nav a { margin-left: 1.25rem; opacity: 0.85; }
header nav a:first-child { margin-left: 0; }
header nav a:hover { opacity: 1; }

main > section#what {
  margin: 0 auto;
  padding: 1.5rem 0 3.5rem;
}

#what p {
  max-width: 38rem;
  opacity: 0.85;
  margin-bottom: 0;
}

main > section#result {
  border-top: 0;
  padding-top: 0;
}

/* The number is the hero. */

.figure-line { margin: 0 0 1.25rem; }

.figure {
  font-size: clamp(3rem, 14vw, 5.5rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--treated);
  font-variant-numeric: lining-nums tabular-nums;
}

.figure-qualifier {
  font-size: 1.25rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Proof table. */

/* The proof and the control group may widen to 48rem. */
@media (min-width: 50rem) {
  #result, #control-group {
    max-width: 48rem;
    margin-left: -3rem;
    margin-right: -3rem;
  }
}

table.arms {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.25rem;
  font-variant-numeric: lining-nums tabular-nums;
}

table.arms caption {
  text-align: left;
  caption-side: top;
  color: var(--muted);
  font-size: 0.95rem;
  padding-bottom: 0.5rem;
}

table.arms th,
table.arms td {
  padding: 0.7rem 0.5rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

table.arms th:first-child,
table.arms td:first-child { padding-left: 0; }

table.arms thead th {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

table.arms .num {
  text-align: right;
  white-space: nowrap;
}

table.arms th.num:last-child,
table.arms td.num:last-child { padding-right: 0; }

table.arms tbody th { font-weight: 500; }

/* Each rate drawn on the same track. Widths are the rates themselves;
   tests/test_site.py holds them to `stats`. */
.rate-bar {
  display: block;
  width: 6rem;
  height: 0.5rem;
  margin: 0.35rem 0 0 auto;
  background: var(--rule);
  border-radius: 4px;
  overflow: hidden;
}

.rate-bar::before {
  content: "";
  display: block;
  height: 100%;
  border-radius: 4px;
  transform-origin: left center;
}

.rate-bar-treated::before {
  width: 39.4%;
  background: var(--treated);
}

.rate-bar-held::before {
  width: 16.4%;
  background: repeating-linear-gradient(135deg, var(--held) 0 2px, transparent 2px 6px);
  box-shadow: inset 0 0 0 1px var(--held);
}

/* Below 30rem the row labels wrap; the figures never split. */
@media (max-width: 30rem) {
  table.arms th, table.arms td { padding-left: 0.35rem; padding-right: 0.35rem; }
  .rate-bar { width: 4.5rem; }
}

/* The listings we leave alone. */

main > section#control-group {
  background: var(--panel);
  border: 0;
  border-radius: 4px;
  padding: 1.5rem;
}

@media (min-width: 48rem) {
  main > section#control-group { padding: 2rem; }
}

#control-group > :last-child { margin-bottom: 0; }

.shelf {
  display: flex;
  height: 2.5rem;
  gap: 3px;
}

.shelf-treated {
  flex: 85;
  background: var(--treated);
  border-radius: 4px 0 0 4px;
}

.shelf-held {
  flex: 15;
  background: repeating-linear-gradient(135deg, var(--held) 0 2px, transparent 2px 7px);
  border: 1px solid var(--held);
  border-radius: 0 4px 4px 0;
}

.shelf-labels {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.6rem 0 1.75rem;
  font-size: 0.95rem;
  line-height: 1.4;
}

.shelf-label { color: var(--muted); }
.shelf-label strong { color: var(--fg); font-variant-numeric: lining-nums tabular-nums; }
.shelf-labels .shelf-label:last-child { text-align: right; }

@media (max-width: 30rem) {
  .shelf-labels { flex-direction: column; gap: 0.35rem; }
  .shelf-labels .shelf-label:last-child { text-align: left; }
}

dl.control-terms {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin: 0 0 1.75rem;
}

@media (min-width: 48rem) {
  dl.control-terms {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }
}

dl.control-terms dt {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

dl.control-terms dd { margin: 0; }

/* What it will not do: each line gets a stop mark. */

#refusals ul {
  list-style: none;
  padding-left: 0;
}

#refusals li {
  position: relative;
  padding-left: 2rem;
  margin-bottom: 0.75rem;
}

#refusals li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.3em;
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--muted);
  border-radius: 50%;
  background: linear-gradient(45deg, transparent calc(50% - 1px), var(--muted) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px));
}

/* How it starts: the content is a sequence, so the numbers are shown. */

#start ol {
  list-style: none;
  counter-reset: step;
  padding-left: 0;
}

#start ol > li {
  counter-increment: step;
  position: relative;
  min-height: 2rem;
  padding-left: 3rem;
  margin-bottom: 1rem;
}

#start ol > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -0.05rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--treated);
  border-radius: 50%;
  color: var(--treated);
  font-size: 1.05rem;
  line-height: 1;
  font-variant-numeric: lining-nums;
}

/* One call to action, and the only filled element on the page. */

a.cta {
  display: inline-block;
  background: var(--treated);
  color: var(--bg);
  padding: 0.8rem 1.4rem;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
}

a.cta:hover {
  background: var(--treated-strong);
  color: var(--bg);
}

/* Small print. The qualifiers under the proof are set off as asides. */

.notes {
  font-size: 0.95rem;
  color: var(--muted);
}

div.notes {
  border-left: 3px solid var(--rule);
  padding-left: 1rem;
}

.notes strong { color: var(--fg); }

footer {
  margin-top: 5rem;
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.95rem;
}

/* The one motion: the bars fill in once, on load. */

@media (prefers-reduced-motion: no-preference) {
  .shelf-treated { animation: fill-shelf 900ms cubic-bezier(0.22, 1, 0.36, 1) both; }
  .shelf-held { animation: fill-shelf 900ms cubic-bezier(0.22, 1, 0.36, 1) 150ms both; }
  .rate-bar-treated::before { animation: fill-rate 900ms cubic-bezier(0.22, 1, 0.36, 1) both; }
  .rate-bar-held::before { animation: fill-rate 900ms cubic-bezier(0.22, 1, 0.36, 1) 150ms both; }

  @keyframes fill-shelf { from { flex-grow: 0; } }
  @keyframes fill-rate { from { transform: scaleX(0); } }
}
