/* tools.css — the shared shell for the calculator pages under /calculators.
 *
 * Same design language as /support and /privacy (light-and-dark, system font,
 * the app's teal as the single accent) rather than the landing page's dark-only
 * hero treatment: these are pages people read and use, often in daylight, often
 * from a search result. Tokens mirror site/support/index.html — keep them in
 * step if the brand accent ever moves. */

:root {
  color-scheme: light dark;
  --accent: #0A8C82;        /* brand accent (fills) — app AccentColor */
  --accent-text: #0B847C;   /* AA accent text on background — app ReadoutText */
  --on-accent: #fff;
  --accent-soft: rgba(10, 140, 130, .07);
  --accent-edge: rgba(10, 140, 130, .22);
  --hairline: #e5e5e7;
  --muted: #86868b;
  --text: #1d1d1f;
  --bg: #fff;
  --surface: #fbfbfd;
  --field: #fff;
  --bar: rgba(255, 255, 255, .82);
  --radius: 14px;
  /* One height for every control on a field row, so a segmented control lines
     up with the inputs and selects beside it. The seg spends 6px of it on its
     own border + track padding. */
  --control-h: 50px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #2DD4C4;
    --accent-text: #2DD4C4;
    --on-accent: #000;
    --accent-soft: rgba(45, 212, 196, .10);
    --accent-edge: rgba(45, 212, 196, .30);
    --hairline: #2c2c2e;
    --text: #f5f5f7;
    --bg: #000;
    --surface: #1c1c1e;
    --field: #2c2c2e;
    --bar: rgba(0, 0, 0, .72);
  }
}

* { box-sizing: border-box; }
/* The UA's `[hidden] { display: none }` loses to any class selector that sets
   display — which .field and .answer both do. Without this the
   solved-for field stays on screen next to its own answer. */
[hidden] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}
/* Available to a screen reader, invisible on screen. Carries the spoken form
   of a readout whose visible text is punctuation a screen reader misreads. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Horizontal padding in px, not rem: at a 200% browser text size three nested
   rem paddings left the hero readout 133px to render 243px of digits. Vertical
   rhythm still scales with type, which is what you want. */
main { max-width: 780px; margin: 0 auto; padding: 2rem 20px 5rem; }

/* ── Top bar ───────────────────────────────────────────────────────────── */
/* The landing page's sticky bar, slimmed. The "Get the app" pill lives here so
   the app is discoverable at the moment a result appears — the .appcard at the
   foot of each page sits below the explainer, tables and FAQ, where someone who
   came from a search, solved their pace and left never scrolled. */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  /* Horizontal padding lines the bar up with the 780px content column. */
  padding: .45rem max(20px, calc((100% - 780px) / 2));
  background: var(--bar);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  backdrop-filter: saturate(1.4) blur(18px);
  border-bottom: 1px solid var(--hairline);
}
.bar .wordmark {
  display: inline-flex;
  align-items: center;
  min-height: 44px; /* touch target floor */
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--accent-text);
}
.bar .wordmark:hover { text-decoration: none; }
.bar .get {
  display: inline-flex;
  align-items: center;
  min-height: 44px; /* touch target floor */
  margin-left: auto;
  padding: .35rem 1rem;
  border-radius: 99px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: .9rem;
  transition: opacity .15s ease, transform .15s ease;
}
.bar .get:hover { text-decoration: none; opacity: .92; transform: translateY(-1px); }

/* ── Breadcrumb + headings ─────────────────────────────────────────────── */
.top { margin-bottom: 2rem; font-size: .95rem; color: var(--muted); }
.top a { color: var(--muted); }
.top a:hover { color: var(--accent-text); text-decoration: none; }
h1 { font-size: clamp(1.9rem, 5vw, 2.4rem); margin: 0 0 .4rem; letter-spacing: -0.02em; line-height: 1.15; }
.tagline { color: var(--muted); margin: 0 0 2rem; font-size: 1.08rem; }
h2 { font-size: 1.3rem; margin: 2.75rem 0 .75rem; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; margin: 1.75rem 0 .5rem; }

/* ── The calculator ────────────────────────────────────────────────────── */
.calc {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  padding: 1.25rem 16px 1.4rem;
  margin: 0 0 1.5rem;
}
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem 1rem; }
/* Every control in a row lines up even when one label wraps to two lines (the
   pace calculator's "Custom distance (km)"): each field is a subgrid of the
   three shared rows — label, control, hint — so the row's tallest label sizes
   the band and the inputs still start together. */
.field { display: grid; grid-template-rows: subgrid; grid-row: span 3; row-gap: .3rem; min-width: 0; }
/* `.field-label` labels a group of radios, where a single `for=` can't. It was
   a <fieldset>/<legend>, but a rendered legend is not a grid item, so the
   subgrid above never reached it and the seg sat off the row; role=radiogroup
   + aria-labelledby groups them without the legend's layout rules. */
.field > label,
.field > .field-label {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0;
}
input[type="text"], input[type="number"], select {
  font: inherit;
  min-height: var(--control-h);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: .55rem .7rem;
  width: 100%;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}
select {
  /* Restore an affordance the appearance reset removes, without an image file. */
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 2px), calc(100% - 13px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.1rem;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--muted); opacity: .7; }
.hint { font-size: .8rem; color: var(--muted); }

/* A segmented control, the way the apps present a two- or three-way choice. */
.seg { display: flex; background: var(--field); border: 1px solid var(--hairline); border-radius: 10px; padding: 2px; }
/* Flex, not block: the visually hidden radio is out of flow but a block label
   still opens a line box for it, which made the seg ~10px taller than the
   inputs beside it. */
.seg label { flex: 1; display: flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--control-h) - 6px); /* Apple's 44pt floor on the row you actually tap */
  flex: 1;
  text-align: center;
  padding: .38rem .3rem;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.seg input:checked + span { background: var(--accent); color: var(--on-accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* A range input, in the brand accent and at a thumb size you can actually hit.
   Chrome/Safari and Firefox need separate pseudo-elements; the rules can't be
   combined into one selector list (an unknown pseudo drops the whole rule). */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 44px;
  background: transparent;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: var(--hairline);
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--hairline);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -10px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}

/* ── The answer ────────────────────────────────────────────────────────── */
.answer {
  display: block; /* <output> is inline by default; without this the card's
                     border and tint draw as fragments, not a box. */
  margin: 1.25rem 0 0;
  padding: 1rem 14px;
  border: 1px solid var(--accent-edge);
  background: var(--accent-soft);
  border-radius: var(--radius);
}
.answer .label {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .1rem;
}
/* The hero readout, as the app renders it: rounded, tabular, in the accent. */
.answer .big {
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: clamp(1.9rem, 8vw, 2.9rem);
  font-weight: 800;
  overflow-wrap: anywhere; /* a 200%-text hero must wrap, never spill its card */
  letter-spacing: -0.015em;
  line-height: 1.12;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.answer .big small { font-size: .42em; font-weight: 700; color: var(--muted); margin: 0 .18em 0 .15em; }
.answer .also { margin: .45rem 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.answer .also b { color: var(--text); font-weight: 600; }
.error { color: #c0392b; margin: 1rem 0 0; }
@media (prefers-color-scheme: dark) { .error { color: #ff8a80; } }

/* ── Tables: splits, equivalents, reference data ───────────────────────── */
.tablewrap { overflow-x: auto; margin: 1.25rem 0; -webkit-overflow-scrolling: touch; }
/* Focusable so a keyboard user can scroll it — a pointer-only scroll region is
   a WCAG 2.1.1 failure. The outline confirms where the focus went. */
.tablewrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: .95rem; }
/* Table captions live OUTSIDE the scroller (see the HTML): inside it they
   inherited the table's width, so on a phone the caption could only be read by
   scrolling the very table it described — and `display:block` on a <caption>
   breaks table layout rather than fixing it. The wrapper is labelled by this
   paragraph via aria-labelledby, so the table still has an accessible name. */
.tcaption {
  color: var(--muted);
  font-size: .88rem;
  margin: 1.25rem 0 -.75rem;
}
th, td { text-align: right; padding: .45rem .6rem; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
tbody tr:hover { background: var(--accent-soft); }
td.key { font-weight: 600; }

/* ── FAQ disclosures — same component as /support ──────────────────────── */
.qa { border: 1px solid var(--hairline); border-radius: 12px; margin: 0 0 .6rem; }
.qa[open] { border-color: var(--accent-edge); }
.qa summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1.1rem;
  font-weight: 600;
  border-radius: 12px;
}
.qa summary::-webkit-details-marker { display: none; }
.qa summary::after {
  content: "";
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--accent-text);
  border-bottom: 2px solid var(--accent-text);
  transform: rotate(45deg);
  transition: transform .2s ease;
  margin-top: -4px;
}
.qa[open] summary::after { transform: rotate(225deg); margin-top: 4px; }
.qa p, .qa ul { margin: 0 0 .9rem; padding-left: 1.1rem; padding-right: 1.1rem; }
.qa ul { padding-left: 2.3rem; }

/* An explainer that opens rather than a wall that must be scrolled past. Same
   component vocabulary as the FAQ disclosures above; the visible <summary> is
   the takeaway, so a skimmer gets the point without opening anything. */
details.more {
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  margin: 1.5rem 0;
  padding: 0;
}
details.more + details.more { margin-top: -1.5rem; border-top: 0; }
/* Block, not flex: the title and its lede are one sentence and must wrap as
   one. Under flex they became two columns on a phone. */
details.more > summary {
  cursor: pointer;
  list-style: none;
  display: block;
  position: relative;
  min-height: 44px;
  padding: .8rem 2rem .8rem 0;
  font-weight: 600;
  color: var(--text);
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 1.35rem;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--accent-text);
  border-bottom: 2px solid var(--accent-text);
  transform: rotate(45deg);
  transition: transform .2s ease;
}
details.more[open] > summary::after { transform: rotate(225deg) translate(-3px, -3px); }
details.more > summary .lede { font-weight: 400; color: var(--muted); }
/* The separator is presentation, not copy — so it lives here rather than as a
   dash typed into every summary. */
details.more > summary .lede::before { content: "· "; }
details.more > *:not(summary):last-child { margin-bottom: 1.1rem; }

/* ── The app card, and the other-calculators grid ──────────────────────── */
.appcard {
  border: 1px solid var(--accent-edge);
  background: var(--accent-soft);
  border-radius: 16px;
  padding: 1.15rem 1.35rem 1.25rem;
  margin: 2.5rem 0 0;
}
.appcard h2 { margin: 0 0 .35rem; font-size: 1.15rem; }
.appcard p { margin: 0 0 .9rem; color: var(--muted); }
.btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px; /* touch target floor */
  padding: .6rem 1.2rem;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  transition: transform .15s ease, opacity .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); opacity: .92; }
.btn.secondary { background: transparent; color: var(--accent-text); border: 1px solid var(--accent-edge); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; margin: 1.25rem 0; padding: 0; list-style: none; }
.grid a {
  display: block;
  height: 100%;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  color: inherit;
  transition: border-color .15s ease, transform .15s ease;
}
.grid a:hover { text-decoration: none; border-color: var(--accent-edge); transform: translateY(-2px); }
.grid b { display: block; color: var(--accent-text); margin-bottom: .1rem; }
.grid span { font-size: .9rem; color: var(--muted); }

.note { color: var(--muted); font-size: .92rem; }
.method { border-left: 3px solid var(--accent-edge); padding-left: 1rem; margin: 1.25rem 0; }
.method code, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
footer { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--hairline); color: var(--muted); font-size: .9rem; }
footer a { color: var(--muted); }

/* No JS: the calculator can't work, so say so instead of showing dead fields. */
.nojs { display: none; }
html:not(.js) .nojs { display: block; }
html:not(.js) .calc { display: none; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
