/* Reach's price calculator (reach.html #calc, reach-calc.js): four cards, one per channel, each a
   big count to type and a slider; beside them the month, its total first. Only tokens; the yellow
   is the sliders' fill, as Dawn's one accent. */

.calc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-areas:
    "head head"
    "grid sum"
    "notes notes";
  gap: var(--space-8) var(--space-6);
  margin-top: var(--space-16);
  padding: var(--space-8);
}
.calc-head {
  grid-area: head;
  max-width: 640px;
}
.calc-head h3 {
  font-size: var(--size-h3);
}
.calc-head p {
  margin-top: var(--space-2);
  color: var(--text-muted);
}

/* One card per channel, each in its own named place, so nothing a browser extension slips in
   between them can push one along */
.calc-grid {
  grid-area: grid;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-areas:
    "out in"
    "text minute";
  align-content: start;
  gap: var(--space-4);
}
.ch-out {
  grid-area: out;
}
.ch-in {
  grid-area: in;
}
.ch-text {
  grid-area: text;
}
.ch-minute {
  grid-area: minute;
}
.calc-ch {
  display: grid;
  gap: var(--space-2);
  align-content: start;
  padding: var(--space-5);
  border-radius: var(--radius-card);
  border: var(--border) solid var(--line);
  background: var(--bg-raised);
}
.calc-top {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
}
.calc-top .chip {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-control);
  border: var(--border) solid var(--line);
  background: var(--surface);
  color: var(--text-strong);
}
.calc-top .icon {
  width: 18px;
  height: 18px;
}
.calc-top label {
  font-size: 15px;
  font-weight: var(--weight-medium);
  color: var(--text);
}
.calc-top output {
  font-size: 15px;
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--text-strong);
}

/* The count: a big number to type over */
.calc .count {
  width: 100%;
  min-height: var(--target);
  margin-top: var(--space-2);
  padding: 0;
  border: 0;
  border-bottom: var(--border) solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text-strong);
  font: inherit;
  font-size: var(--size-h3);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-heading);
  font-variant-numeric: tabular-nums;
  transition: border-color var(--duration-fast) var(--ease-out);
}
.calc .count:hover {
  border-bottom-color: var(--line-strong);
}
.calc .count:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

/* The slider: a thin track, filled yellow up to the thumb */
.calc input[type="range"] {
  --fill: 0%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: var(--target);
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.calc input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background:
    linear-gradient(var(--accent), var(--accent)) 0 / var(--fill) 100% no-repeat,
    var(--surface-3);
}
.calc input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
}
.calc input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--accent);
}
.calc input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: var(--text-strong);
}
.calc input[type="range"]::-moz-range-thumb {
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: var(--text-strong);
}
.calc input[type="range"]:focus {
  outline: none;
}
.calc input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px var(--accent-line);
}
.calc input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px var(--accent-line);
}
.calc-ch small {
  font-size: 13px;
  line-height: var(--leading-ui);
  color: var(--text-muted);
}

/* The month: the total first, then what makes it; as tall as its words, never stretched */
.calc-sum {
  grid-area: sum;
  align-self: start;
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
  border-radius: var(--radius-card);
  border: var(--border) solid var(--line-strong);
  background: var(--surface-2);
}
/* The total shrinks with its box, so the largest month ($19,012.37) still fits beside or above
   "a month" */
.calc-total {
  container-type: inline-size;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-2);
  margin-top: var(--space-3);
}
.calc-total b {
  font-size: min(56px, 18cqi);
  line-height: 1;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-display);
  font-variant-numeric: tabular-nums;
  color: var(--text-strong);
}
.calc-total span {
  font-size: var(--size-small);
  color: var(--text-muted);
}
.calc-sum dl {
  display: grid;
  margin: var(--space-6) 0 0;
  padding-top: var(--space-4);
  border-top: var(--border) solid var(--line);
}
.calc-sum dl div {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  font-size: 15px;
}
.calc-sum dt {
  color: var(--text-muted);
}
.calc-sum dd {
  margin: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text-strong);
}
.calc-sum .sub {
  margin-top: var(--space-2);
  padding-top: var(--space-4);
  border-top: var(--border) solid var(--line);
}
.calc-sum .sub dt {
  color: var(--text-strong);
}
.calc-notes {
  grid-area: notes;
  display: grid;
  gap: var(--space-2);
}
.calc-notes a {
  color: inherit;
}

@media (max-width: 1080px) {
  .calc {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "grid"
      "sum"
      "notes";
  }
}

/* Under the cards and full width: the total on the left, what makes it on the right */
@media (min-width: 721px) and (max-width: 1080px) {
  .calc-sum {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "label lines"
      "total lines";
    column-gap: var(--space-10);
  }
  .calc-sum .eyebrow {
    grid-area: label;
  }
  .calc-total {
    grid-area: total;
    align-self: start;
  }
  .calc-sum dl {
    grid-area: lines;
    margin: 0;
    padding: 0 0 0 var(--space-10);
    border-top: 0;
    border-left: var(--border) solid var(--line);
  }
}

@media (max-width: 720px) {
  .calc {
    margin-top: var(--space-12);
    padding: var(--space-5);
    gap: var(--space-6);
  }
  .calc-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "out"
      "in"
      "text"
      "minute";
  }
  .calc-ch {
    padding: var(--space-4);
  }
  .calc-sum {
    padding: var(--space-5);
  }
  .calc-total b {
    font-size: min(48px, 18cqi);
  }
}
