/* Mobile first, and the same card as Days Since. The two amounts are the
   largest things on the page: this is used standing at a till, one-handed. */

:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #16181d;
  --ink-soft: #5c6270;
  --line: #e2e5ea;
  --accent: #1f6feb;
  --on-accent: #ffffff;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1c1f25;
    --ink: #e8eaee;
    --ink-soft: #9aa1ae;
    --line: #2b2f37;
    --accent: #4a9eff;
    --on-accent: #0b1220;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 1rem;
  background: var(--bg);
  color: var(--ink);
  /* Helvetica first, and never Arial; see days-since/assets/style.css. */
  font: 16px/1.45 "Helvetica Neue", Helvetica, "Nimbus Sans", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.card {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.1rem 1.1rem 1.4rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.page-head h1 { margin: 0; font-size: 1.35rem; letter-spacing: -0.01em; }

h2 {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.prompt { margin: 0; color: var(--ink-soft); }

/* --- The converter -------------------------------------------------------- */

.convert { margin: 1.1rem 0 0; }

.side { margin: 0; padding: 0; border: 0; min-width: 0; }

.amount {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0.45rem 0.65rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  /* Equal-width digits, so the answer does not jitter as the question is typed. */
  font-variant-numeric: tabular-nums;
}

.amount:focus-visible,
.swap:focus-visible,
.ranges button:focus-visible,
.chip input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* The radios are real, for the keyboard and for screen readers; what is seen
   and pressed is the label around each one.

   The border belongs to the label, which is the thing that takes the press,
   so the box drawn is the box that works. The labels sit on a grid of equal
   columns: each one is as wide as its share of the row rather than as wide
   as three letters, and a second row lines up under the first. */
.chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.9rem, 1fr));
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.chip {
  position: relative;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.chip input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip span {
  display: block;
  /* 44px tall with the line height: a comfortable thumb target. */
  padding: 0.75rem 0.4rem;
  /* One less than the label's, to sit inside its border. */
  border-radius: 7px;
  font-size: 0.9rem;
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-align: center;
}

@media (hover: hover) {
  .chip:hover { border-color: var(--ink-soft); }
}

/* The fill is the span's, and its shadow paints over the label's border, so
   the chosen one is a solid block without asking the label to know what its
   input holds. */
.chip input:checked + span {
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  font-weight: 700;
}

.swap {
  display: block;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0.5rem auto;
  padding: 0;
  color: var(--ink);
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.rate-line {
  margin: 0.9rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  white-space: pre-wrap;
}

/* --- Sections under the converter ----------------------------------------- */

.block {
  margin-top: 1.2rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

/* --- Cheat sheet ---------------------------------------------------------- */

/* Both directions side by side, even on a phone: the point of the sheet is to
   find a price in either column without scrolling. */
.sheet {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.sheet-table th,
.sheet-table td {
  padding: 0.3rem 0;
  text-align: right;
  border-bottom: 1px solid var(--line);
}

.sheet-table th {
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.sheet-table td:first-child { color: var(--ink-soft); }
.sheet-table td:last-child { font-weight: 700; }
.sheet-table tr:last-child td { border-bottom: 0; }

/* --- History -------------------------------------------------------------- */

.ranges { display: flex; gap: 0.25rem; }

.ranges button {
  min-width: 2.75rem;
  padding: 0.45rem 0.5rem;
  color: var(--ink-soft);
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.ranges button[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--line);
  background: var(--bg);
  font-weight: 700;
}

.readout {
  margin: 0.5rem 0 0.3rem;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  white-space: pre-wrap;
}

.chart { min-height: 190px; }

.chart svg {
  display: block;
  /* Up-and-down still scrolls the page; side-to-side scrubs the line. */
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--ink-soft); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .cross { stroke: var(--ink-soft); stroke-width: 1; visibility: hidden; }
/* Ringed in the card colour so the dot reads as sitting on the line. */
.chart .dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }

.facts {
  margin: 0.7rem 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 0.9rem;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.facts dt {
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 0.1rem;
}

.facts dd { margin: 0; }

/* --- Picker and footer ---------------------------------------------------- */

.picker summary {
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.picker .prompt { margin-top: 0.6rem; font-size: 0.9rem; }

.picker-find {
  width: 100%;
  margin: 0.6rem 0 0;
  padding: 0.55rem 0.65rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  /* 16px keeps iOS from zooming the page when the field is tapped. */
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}

.picker-find:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* display: flex on a row would otherwise outrank the hidden attribute. */
.pick[hidden] { display: none; }

#picker-none { margin-top: 0.6rem; font-size: 0.9rem; }

.picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.4rem;
  margin-top: 0.6rem;
}

/* Boxed like the toggles above, and for the same reason: the whole row takes
   the press, so the whole row is drawn. */
.pick {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  /* 44px tall with the line height. */
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.3;
  cursor: pointer;
}

.pick input {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--accent);
}

.pick strong { letter-spacing: 0.02em; }

/* A long name is cut short rather than wrapped, so every row is one height. */
.pick span {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (hover: hover) {
  .pick:hover { border-color: var(--ink-soft); }
}

/* The tick already says which are chosen; where the browser can tell the row
   what its box holds, the border says it too. */
.pick:has(input:checked) { border-color: var(--accent); }

.pick:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.source {
  margin: 1.2rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.source a { color: inherit; }
