/* RepMaxLab shared stylesheet. Plain CSS, no build step, no web fonts. */

:root {
  --ink: #15171a;
  --paper: #ffffff;
  --chalk: #f3f4f0;
  --rule: #d7d9d2;
  --muted: #555b64;
  --control: #6f757e;
  --accent: #ffc61a;
  --accent-dark: #eeb300;
  --accent-soft: #fff1bd;
  --error: #b3261e;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Avenir Next Condensed", Bahnschrift, "Roboto Condensed", sans-serif-condensed, "Arial Narrow", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --measure: 41rem;
}

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

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}

[hidden] { display: none !important; }

.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;
  left: 0.5rem;
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 0.9rem;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
}
.skip-link:focus { top: 0.5rem; }

.wrap {
  width: 100%;
  max-width: calc(var(--measure) + 2rem);
  margin: 0 auto;
  padding: 0 1rem;
}
.wrap-wide { max-width: 64rem; }

/* ---------- Type ---------- */

h1, h2, h3,
.logo, .btn, .result-number, caption, .more-list a, .big-link {
  font-family: var(--font-display);
  font-stretch: condensed;
}

h1, h2, h3 { line-height: 1.1; margin: 0; font-weight: 700; }
h1 { font-size: clamp(2.2rem, 8vw, 3.25rem); font-weight: 800; }
h2 { font-size: clamp(1.65rem, 5.5vw, 2.1rem); margin-top: 2.6rem; margin-bottom: 0.7rem; }
h3 { font-size: 1.35rem; margin-top: 1.8rem; margin-bottom: 0.4rem; }

p, ul, ol { margin: 0 0 1rem; }
ul, ol { padding-left: 1.3rem; }
li { margin-bottom: 0.4rem; }

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.16em;
}
a:hover { background: var(--accent-soft); }

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

code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; background: var(--chalk); padding: 0.1em 0.3em; border-radius: 3px; }

.lede { font-size: 1.15rem; margin: 0.6rem 0 0; }
.updated { color: var(--muted); font-size: 0.95rem; }

/* ---------- Header ---------- */

.site-header { border-bottom: 2px solid var(--ink); background: var(--paper); }
.header-row { display: flex; flex-direction: column; padding-top: 0.7rem; }

.logo {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.5rem;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  padding: 0.2rem 0;
}
.logo:hover { background: none; }
.logo svg { display: block; flex: none; }

.site-nav ul {
  display: flex;
  gap: 1.35rem;
  list-style: none;
  margin: 0 -1rem 0 0;
  padding: 0 2.5rem 0 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
}
.site-nav ul::-webkit-scrollbar { display: none; }
.site-nav li { margin: 0; flex: none; }
.site-nav a {
  display: block;
  padding: 0.75rem 0 0.6rem;
  font-size: 0.98rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 4px solid transparent;
}
.site-nav a:hover { background: none; border-bottom-color: var(--rule); }
.site-nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.site-nav a:focus-visible { outline-offset: -3px; }

@media (min-width: 56rem) {
  .header-row { flex-direction: row; align-items: center; justify-content: space-between; padding-top: 0; }
  .site-nav ul { margin: 0; padding: 0; overflow: visible; -webkit-mask-image: none; mask-image: none; }
  .site-nav a { padding: 1.15rem 0 0.95rem; }
}

/* ---------- Page ---------- */

main { display: block; padding-top: 1.4rem; }
main:focus { outline: none; }
h1 + .prose { margin-top: 0.75rem; }
.lede + .prose { margin-top: 1.1rem; }

.breadcrumbs { font-size: 0.92rem; color: var(--muted); margin-bottom: 0.7rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; margin: 0; padding: 0; }
.breadcrumbs li { margin: 0; }
.breadcrumbs li + li::before { content: "/"; margin: 0 0.45rem; color: var(--control); }
.breadcrumbs a { color: var(--muted); text-decoration-thickness: 1px; }

/* ---------- Calculator ---------- */

.calc {
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  margin: 1.2rem 0 2rem;
}
.calc-form { padding: 1rem; }

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.field { min-width: 0; }
.field label, .unit-toggle legend {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.3rem;
  padding: 0;
}
.optional { font-weight: 400; color: var(--muted); }

.field input[type="text"], .field select {
  display: block;
  width: 100%;
  min-height: 3.1rem;
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1.2;
  color: var(--ink);
  background-color: #fff;
  border: 2px solid var(--control);
  border-radius: 4px;
}
.field select {
  -webkit-appearance: none;
  appearance: none;
  padding-left: 0.6rem;
  padding-right: 1.85rem;
  font-size: 1rem;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2315171a' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 0.75rem;
}
.field input::placeholder { color: var(--control); opacity: 1; }
.field input[type="text"]:focus-visible, .field select:focus-visible {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--accent);
}
.field input[aria-invalid="true"], .field select[aria-invalid="true"] { border-color: var(--error); }

.with-unit { position: relative; }
.with-unit input[type="text"] { padding-right: 2.6rem; }
.unit-tag {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}

.unit-toggle { border: 0; margin: 0; padding: 0; }
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 3.1rem;
  border: 2px solid var(--control);
  border-radius: 4px;
  overflow: hidden;
}
.seg label { position: relative; display: block; margin: 0; cursor: pointer; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 1.1rem;
  font-weight: 700;
}
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent); }

.options { margin: 0 0 1rem; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.options summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 0;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.options summary::-webkit-details-marker { display: none; }
.options summary::after {
  content: "";
  flex: none;
  width: 0.6rem;
  height: 0.6rem;
  margin: 0 0.35rem 0.25rem 0;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(45deg);
}
.options[open] summary::after { transform: rotate(-135deg); margin-bottom: -0.2rem; }
.options .field-grid { margin-top: 0.2rem; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0.2rem 0 1rem;
  font-size: 0.98rem;
  line-height: 1.35;
  cursor: pointer;
}
.check input { flex: none; width: 1.35rem; height: 1.35rem; margin: 0; accent-color: var(--ink); }
[data-step-text] { white-space: nowrap; }

.hint { font-size: 0.92rem; color: var(--muted); margin: -0.3rem 0 0.9rem; }

.form-error { color: var(--error); font-weight: 600; margin: 0 0 0.9rem; }
.form-warning {
  border-left: 6px solid var(--ink);
  background: var(--chalk);
  padding: 0.7rem 0.9rem;
  margin: 0 1rem 1rem;
  font-size: 0.98rem;
  scroll-margin-top: 0.75rem;
}

.btn {
  display: block;
  width: 100%;
  min-height: 3.4rem;
  padding: 0.6rem 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translateY(1px); }

.btn-quiet {
  min-height: 2.9rem;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
}
.btn-quiet:hover { background: var(--accent-soft); }

/* ---------- Results ---------- */

.results { border-top: 2px solid var(--ink); padding: 1rem; }

.result-hero {
  background: var(--accent);
  border-radius: 4px;
  padding: 0.95rem 1rem 1rem;
  scroll-margin-top: 0.75rem;
}
.result-hero:focus { outline: none; }
.result-hero:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.result-label { font-weight: 600; margin: 0; }
.result-number {
  font-size: clamp(3.6rem, 19vw, 6rem);
  font-weight: 800;
  line-height: 0.95;
  margin: 0.15rem 0 0.35rem;
  font-variant-numeric: tabular-nums;
}
.result-number .unit { font-size: 0.42em; font-weight: 700; }
.result-meta { margin: 0; font-size: 0.98rem; line-height: 1.45; }

.results .table-wrap { margin-top: 1.5rem; }
.results .hint { margin: -0.6rem 0 0; }
.results .t-warmups .table-wrap { margin-bottom: 1.5rem; }

@media (min-width: 40rem) {
  .results { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 1.5rem; align-items: start; }
  .results > * { grid-column: 1 / -1; }
  .results > .t-formulas { grid-column: 1; grid-row: 2; }
  .results > .t-warmups { grid-column: 2; grid-row: 2; }
  .results > .t-percents { grid-row: 3; }
}

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.4rem; }
.copy-status { align-self: center; font-size: 0.95rem; font-weight: 600; margin: 0; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin: 1.1rem 0 1.5rem; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-size: 1.3rem; font-weight: 700; line-height: 1.15; padding: 0 0 0.45rem; }
th, td { padding: 0.55rem 0.6rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
thead th { font-size: 0.9rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--ink); vertical-align: bottom; }
tbody th { font-weight: 600; }
th.num, td.num { text-align: right; }
td.strong, tr.is-picked td, tr.is-picked th { font-weight: 700; }
tr.is-picked td, tr.is-picked th { background: var(--accent-soft); }
tr.total td, tr.total th { border-top: 2px solid var(--ink); font-weight: 700; }

td.pct, th.pct {
  width: 38%;
  font-weight: 600;
  background: linear-gradient(90deg, var(--accent-soft) calc(var(--p, 0) * 1%), transparent 0);
}

.grid-table { font-size: clamp(0.75rem, 3.3vw, 0.9rem); line-height: 1.3; }
.grid-table th, .grid-table td { padding: 0.45rem 0.14rem; text-align: right; }
.grid-table thead th { font-size: inherit; text-align: right; white-space: nowrap; }
.grid-table thead th[colspan] { text-align: center; border-bottom: 1px solid var(--rule); }
.grid-table thead th[rowspan], .grid-table tbody th {
  position: sticky;
  left: 0;
  padding-left: 0.3rem;
  padding-right: 0.35rem;
  text-align: left;
  background: var(--chalk);
  border-right: 2px solid var(--ink);
  white-space: nowrap;
}
.grid-table tbody tr:nth-child(5n) td, .grid-table tbody tr:nth-child(5n) th { border-bottom-color: var(--control); }
@media (min-width: 30rem) {
  .grid-table th, .grid-table td { padding: 0.45rem 0.5rem; }
  .grid-table thead th[rowspan], .grid-table tbody th { padding-left: 0.5rem; padding-right: 0.6rem; }
}

/* ---------- Article ---------- */

.prose { overflow-wrap: break-word; }
.prose a { overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }

.eq {
  background: var(--chalk);
  border-radius: 4px;
  padding: 0.55rem 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-x: auto;
  white-space: nowrap;
}

.note {
  border-left: 6px solid var(--accent);
  background: var(--chalk);
  padding: 0.8rem 1rem;
  margin: 1.3rem 0;
}
.note > :last-child { margin-bottom: 0; }

.sources { font-size: 0.93rem; color: var(--muted); }
.sources li { margin-bottom: 0.5rem; }

.calc-block { margin-top: 2.6rem; }
.calc-block h2 { margin-top: 0; }

.more { margin-top: 2.8rem; }
.more-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.more-list li { margin: 0; padding: 0.8rem 0; border-bottom: 1px solid var(--rule); }
.more-list a { font-size: 1.3rem; font-weight: 700; line-height: 1.15; }
.more-list span { display: block; color: var(--muted); font-size: 0.97rem; margin-top: 0.15rem; }

.big-link { font-size: 1.6rem; font-weight: 700; overflow-wrap: anywhere; }

.ad-slot { margin: 1.5rem 0; text-align: center; }
.ad-slot:empty { display: none; }

.pass { font-weight: 700; }
.fail { font-weight: 700; color: var(--error); }

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 3.2rem;
  padding: 1.8rem 0 2.4rem;
  background: var(--chalk);
  border-top: 2px solid var(--ink);
  font-size: 0.96rem;
}
.footer-cols { display: grid; gap: 1.4rem; margin-bottom: 1.4rem; }
@media (min-width: 40rem) { .footer-cols { grid-template-columns: 1fr 1fr; } }
.footer-title { font-weight: 700; margin: 0 0 0.4rem; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 0; }
.site-footer li a { display: inline-block; padding: 0.3rem 0; }
.fineprint { color: var(--muted); margin: 0 0 0.4rem; }

/* ---------- Print ---------- */

@media print {
  .site-header, .site-footer, .breadcrumbs, .ad-slot, .no-print, .skip-link { display: none !important; }
  body { font-size: 11pt; }
  main { padding-top: 0; }
  h1 { font-size: 22pt; }
  table { font-size: 10pt; line-height: 1.3; }
  a { text-decoration: none; }
  .calc { border: 0; margin: 0.5rem 0; }
  .results { border-top: 0; padding: 0; }
  .result-hero { background: none; border: 2px solid #000; }
  .result-hero { padding: 8pt 10pt; }
  .result-number { font-size: 34pt; }
  td.pct, th.pct, tr.is-picked td, tr.is-picked th { background: none; }
  .table-wrap { overflow: visible; }
  th, td { padding: 2.5pt 5pt; }
  .grid-table { font-size: 8.5pt; line-height: 1.25; }
  .grid-table th, .grid-table td { padding: 2pt 4pt; }
  .grid-table thead th[rowspan], .grid-table tbody th { position: static; background: none; }
  .results { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 18pt; align-items: start; }
  .results > * { grid-column: 1 / -1; }
  .results > .t-formulas { grid-column: 1; grid-row: 2; }
  .results > .t-warmups { grid-column: 2; grid-row: 2; }
  .results > .t-percents { grid-row: 3; }
  .results .table-wrap { margin-top: 12pt; margin-bottom: 0; }
  caption { font-size: 13pt; }

  /* "Print results" on a calculator: only the results. */
  .print-results .lede, .print-results .prose, .print-results .more, .print-results .calc-form,
  .print-results .form-warning, .print-results .calc-block > h2, .print-results .calc-block > p { display: none !important; }

  /* "Print the charts" on the chart page: only the charts, one per page. */
  .print-charts .lede, .print-charts .calc-block, .print-charts .more,
  .print-charts .prose > :not(.printable) { display: none !important; }
  .print-charts .printable + .printable,
  .print-charts .printable ~ .printable { break-before: page; page-break-before: always; }
  .print-charts .printable h2 { margin-top: 0; }
}
