/*
  styles.css
  The look of the page: one column, plenty of space, one accent colour
  (a deep teal), and a light and a dark version that follow the reader's
  device. Only fonts already on the reader's device are used, so the page
  loads nothing from anywhere.

  The colours are the lines at the top. Change one there and it changes
  everywhere.
*/

/* ---------------------------------------------------------------- colours */

:root {
  color-scheme: light dark;

  --paper: #fdfdfc;
  --panel: #f4f4f2;
  --ink: #261c2c;          /* deep aubergine, for text and buttons */
  --ink-soft: #554a5a;
  --rule: #e3e0dc;
  --field-border: #857b8a;
  --accent: #1b6568;       /* the one accent colour: deep teal */
  --accent-wash: #e6f7f9;  /* the same teal, very pale */
  --card-edge: #261c2c;
  --button: #261c2c;
  --button-ink: #ffffff;
  --problem-wash: #fbeee6;
  --problem-edge: #a5492a;
  --shadow: rgba(38, 28, 44, 0.16);

  --serif: "Source Serif 4", "Source Serif Pro", ui-serif, "Iowan Old Style",
    "Sitka Heading", "Sitka Text", Charter, Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;

  --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #19121b;
    --panel: #211825;
    --ink: #f4f4f2;
    --ink-soft: #b9b0bd;
    --rule: #3a2c43;
    --field-border: #8a7d91;
    --accent: #7dd2d9;
    --accent-wash: #173238;
    --card-edge: #3f7880;
    --button: #f4f4f2;
    --button-ink: #19121b;
    --problem-wash: #34211a;
    --problem-edge: #f0a47f;
    --shadow: rgba(0, 0, 0, 0.5);
  }
}

/* -------------------------------------------------------------- the basics */

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  /* Keeps a focused box clear of the result floating at the bottom. */
  scroll-padding-bottom: calc(var(--result-height, 0px) + 1.5rem);
}

body {
  margin: 0;
  padding: 3.5rem 1.5rem 5rem;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

#page {
  max-width: var(--measure);
  margin: 0 auto;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 400;
  color: var(--ink);
  text-wrap: balance;
}

h1 {
  font-size: 2.5rem;
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 1.5rem;
}

h2 {
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 1rem;
}

h3 {
  font-size: 1.375rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 0.375rem;
}

p {
  margin: 0 0 1rem;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  overflow-wrap: anywhere;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

section {
  margin: 4rem 0 0;
}

.intro {
  font-size: 1.1875rem;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 38em;
}

.notice {
  font-size: 0.9375rem;
  line-height: 1.55;
  background: var(--accent-wash);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin: 1.5rem 0 0;
}

.notice-problem {
  background: var(--problem-wash);
  border-left-color: var(--problem-edge);
  margin: 0 0 1rem;
}

/* --------------------------------------------------------- the seven views */

.view {
  padding: 2rem 0;
  border-top: 1px solid var(--rule);
}

.view:first-child {
  border-top: 0;
  padding-top: 0.5rem;
}

.view-explanation {
  color: var(--ink-soft);
  margin: 0 0 1.25rem;
}

.field {
  margin: 0 0 1.125rem;
}

.field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 0.375rem;
}

.field-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.slider {
  flex: 1 1 auto;
  min-width: 0;
  height: 1.75rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.number-wrap {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.number {
  width: 4.75rem;
  padding: 0.35rem 0.45rem;
  font: inherit;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--field-border);
  border-radius: 3px;
}

.unit {
  color: var(--ink-soft);
}

.fixed-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.375rem 1rem;
  margin: 0;
}

.fixed-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.field-note {
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

.both {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.375rem 0 0;
  padding-top: 0.875rem;
  border-top: 1px dotted var(--field-border);
}

.both-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.both-value {
  font-size: 1.125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.reset-row {
  margin: 1.75rem 0 0;
}

/* --------------------------------------------------------------- buttons */

.button {
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--button-ink);
  background: var(--button);
  border: 1px solid var(--button);
  border-radius: 3px;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
}

.button:hover {
  opacity: 0.86;
}

.button-quiet {
  color: var(--ink);
  background: transparent;
  border-color: var(--field-border);
}

.button-quiet:hover {
  opacity: 1;
  border-color: var(--ink);
}

/* ------------------------------------------------------------- the result */

/*
  The result stays at the bottom of the screen while the reader works through
  the views, then settles in its place below them.
*/
.result {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 2.5rem 0 0;
  padding: 1rem 1.375rem 1.125rem;
  background: var(--accent-wash);
  border: 1px solid var(--card-edge);
}

.result.is-floating {
  box-shadow: 0 -0.5rem 1.75rem var(--shadow);
}

.result-line {
  font-family: var(--serif);
  font-size: 1.75rem;
  text-wrap: balance;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 0.375rem;
}

.result-comparison {
  font-size: 1.0625rem;
  margin: 0;
}

/* --------------------------------------------------- the comparison list */

.list-intro {
  color: var(--ink-soft);
}

.comparison-list {
  list-style: none;
  margin: 1.75rem 0;
  padding: 0;
}

.comparison-item {
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}

.comparison-item:last-child {
  border-bottom: 1px solid var(--rule);
}

.comparison-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.25rem;
  margin: 0;
}

.comparison-what {
  flex: 1 1 16rem;
}

.comparison-chance {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.comparison-period,
.comparison-precaution {
  font-size: 0.9375rem;
  color: var(--ink-soft);
  margin: 0.25rem 0 0;
}

.comparison-precaution-label {
  font-weight: 600;
}

.comparison-source {
  white-space: nowrap;
}

.comparison-mine {
  background: var(--accent-wash);
  border: 1px solid var(--card-edge);
  padding: 0.875rem 1.125rem;
}

.comparison-mine + .comparison-item {
  border-top: 0;
}

.comparison-mine-text {
  font-family: var(--serif);
  font-size: 1.3125rem;
  line-height: 1.3;
  margin: 0;
}

.list-count {
  font-weight: 500;
}

/* ------------------------------------------- how sure you would have to be */

.needed-line {
  text-wrap: pretty;
  font-family: var(--serif);
  font-size: 1.4375rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
  padding-left: 1.25rem;
  border-left: 3px solid var(--accent);
}

/* -------------------------------------------------------- the link button */

.copy-status {
  font-size: 0.9375rem;
  color: var(--ink-soft);
  min-height: 1.5em;
  margin: 0.75rem 0 0;
}

.copy-fallback {
  display: block;
  width: 100%;
  margin-top: 0.375rem;
  padding: 0.5rem 0.6rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--field-border);
  border-radius: 3px;
}

/* ------------------------------------------------------------- the bottom */

.page-footer {
  margin-top: 5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

.sources-heading {
  font-size: 1.25rem;
  margin-top: 2.25rem;
}

.sources {
  margin: 0;
  padding-left: 1.5rem;
  font-size: 0.875rem;
  line-height: 1.6;
}

.sources li {
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}

/* ------------------------------------------------- a phone, 360 pixels wide */

@media (max-width: 30rem) {
  body {
    padding: 2rem 1rem 3.5rem;
    font-size: 1rem;
  }

  h1 {
    font-size: 1.875rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }

  .intro {
    font-size: 1.0625rem;
  }

  section {
    margin-top: 3rem;
  }

  .view {
    padding: 1.625rem 0;
  }

  .field-controls {
    gap: 0.75rem;
  }

  .number {
    width: 4.25rem;
  }

  .result {
    padding: 0.75rem 0.875rem 0.8125rem;
    margin-left: -0.25rem;
    margin-right: -0.25rem;
  }

  .result-line {
    font-size: 1.3125rem;
    margin-bottom: 0.25rem;
  }

  .result-comparison {
    font-size: 0.875rem;
    line-height: 1.45;
  }

  .needed-line {
    font-size: 1.1875rem;
    padding-left: 1rem;
  }

  .comparison-mine {
    padding: 0.75rem 0.875rem;
  }
}

/* On a short screen, the result does not float: it would hide too much. */
@media (max-height: 34rem) {
  .result {
    position: static;
  }

  html {
    scroll-padding-bottom: 0;
  }
}

/* ------------------------------------------------------------- printing */

@media print {
  body {
    padding: 0;
  }

  .result {
    position: static;
    box-shadow: none;
  }

  .reset-row,
  .share-section {
    display: none;
  }
}
