/* An e-ink page: warm paper (Flexoki), gray ink, a book serif, high contrast. */
:root {
  --paper: #fffcf0;
  --screen: #fffcf0;
  --ink: #100f0f;
  --ink-soft: #403e3c;
  --muted: #6f6e69;
  --line: #dad8ce;
  --bezel: #1c1b1a;
  --danger: #af3029;
  --serif: Literata, Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --page: min(100% - 2rem, 72rem);
  color-scheme: light;
}

/* Literata was made for reading books on screens; its optical size axis
   tightens headings and opens up small text. Public Sans for the controls.
   Both are self-hosted (latin subset, OFL, see fonts/LICENSE-*.txt): the page
   makes no third-party requests. */
@font-face {
  font-family: Literata;
  src: url("fonts/literata.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Public Sans";
  src: url("fonts/public-sans.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.6 var(--serif);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p,
ul,
ol,
figure,
pre {
  margin: 0;
}

h1,
h2,
h3 {
  line-height: 1.15;
  text-wrap: balance;
}

a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
}

:is(a, button, input, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: .5rem .75rem;
  background: var(--ink);
  color: var(--screen);
  font-family: var(--sans);
  z-index: 1;
}

.skip-link:focus {
  top: 1rem;
}

/* Header */

.site-header,
main,
.site-footer {
  width: var(--page);
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  text-decoration: none;
}

.wordmark {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.site-header nav {
  display: flex;
  gap: 1.25rem;
  font: 500 .9rem/1 var(--sans);
}

.site-header nav a {
  color: var(--ink-soft);
  text-decoration: none;
}

.site-header nav a:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* Hero: the tool comes first */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 4.5rem);
  padding: clamp(2rem, 5vw, 3.5rem) 0;
}

.hero-copy {
  padding-top: 1.5rem;
}

.eyebrow {
  margin-bottom: .9rem;
  color: var(--muted);
  font: 600 .8rem/1.3 var(--sans);
  letter-spacing: .1em;
  text-transform: uppercase;
}

h1 {
  max-width: 14ch;
  font-size: clamp(2.4rem, 5.2vw, 4rem);
  font-weight: 700;
  letter-spacing: -.025em;
}

.lede {
  max-width: 32rem;
  margin-top: 1.5rem;
  color: var(--ink-soft);
  font-size: 1.2rem;
  line-height: 1.5;
}

.facts {
  display: grid;
  gap: .45rem;
  margin-top: 1.75rem;
  padding: 0;
  list-style: none;
  font: .95rem/1.4 var(--sans);
  color: var(--ink-soft);
}

.facts li {
  display: flex;
  gap: .6rem;
}

.facts li::before {
  content: "✓";
  font-weight: 700;
  color: var(--ink);
}

/* The tool, drawn as an e-reader: dark bezel, paper screen */

.reader {
  /* An X4 is about 3:5, like its 480×800 screen: the screen below gets a
     minimum height from the reader's width. The content can still make it
     taller (the result). */
  --bezel-x: .85rem;
  --bezel-bottom: 2.25rem;
  display: flex;
  container-type: inline-size;
  width: min(100%, 23rem);
  justify-self: center;
  padding: var(--bezel-x) var(--bezel-x) var(--bezel-bottom);
  border-radius: 1.4rem;
  background: var(--bezel);
  box-shadow: 0 1px 0 #444 inset, 0 18px 40px -18px rgba(0, 0, 0, .45);
}

.reader:focus {
  outline: none;
}

.screen {
  flex: 1;
  min-height: calc((100cqw + 2 * var(--bezel-x)) * 5 / 3 - var(--bezel-x) - var(--bezel-bottom));
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.35rem;
  border-radius: .5rem;
  background: var(--screen);
}

#options {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* The drop zone takes the screen's spare height. */
#options > .step:first-child {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#options > .step:first-child .drop {
  flex: 1;
}

/* Like CrossPoint's status bar at the bottom of the page. */
.status-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-top: auto;
  padding-top: .6rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 500 .72rem/1 var(--sans);
  font-variant-numeric: tabular-nums;
}

.status-bar span:last-child {
  text-align: right;
}

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

.step-title {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .7rem;
  padding: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.step-number {
  display: grid;
  width: 1.6rem;
  height: 1.6rem;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  font: 700 .8rem/1 var(--sans);
}

/* Drop zone */

.drop {
  position: relative;
  display: grid;
  gap: .35rem;
  place-items: center;
  min-height: 8.5rem;
  padding: 1.25rem;
  text-align: center;
  border: 1.5px dashed #b7b5ac;
  border-radius: .6rem;
  transition: background-color .15s, border-color .15s;
}

.drop:hover,
.drop.over {
  border-color: var(--ink);
  background: #f2f0e5;
}

.drop.over {
  border-style: solid;
}

.drop.has-file {
  border-style: solid;
  border-color: var(--ink);
}

.drop:focus-within {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.drop input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop input:disabled {
  cursor: not-allowed;
}

.drop label {
  display: grid;
  gap: .2rem;
  pointer-events: none;
}

.drop-title {
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
}

.drop-hint {
  color: var(--muted);
  font: .9rem/1.3 var(--sans);
}

.file-name {
  max-width: 100%;
  font: 600 .9rem/1.35 var(--sans);
  overflow-wrap: anywhere;
}

/* Device cards */

.devices {
  display: grid;
  grid-template-columns: 1fr;
  gap: .6rem;
}

.device {
  position: relative;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem .8rem;
  border: 1.5px solid var(--line);
  border-radius: .6rem;
  cursor: pointer;
  transition: border-color .15s;
}

.device:hover {
  border-color: #b7b5ac;
}

.device:has(input:checked) {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.device:has(input:focus-visible) {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.device input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* A small reader, in the device's proportions */
.device-art {
  flex: none;
  width: 1.55rem;
  height: 2.45rem;
  border: 3px solid var(--bezel);
  border-bottom-width: 6px;
  border-radius: .3rem;
  background: var(--screen);
}

.device-art--x3 {
  width: 1.65rem;
  height: 2.35rem;
}

.device-text {
  display: grid;
  gap: .1rem;
}

.device-name {
  font-weight: 700;
  line-height: 1.2;
}

.device-note {
  color: var(--muted);
  font: .78rem/1.3 var(--sans);
}

/* Advanced options */

details > summary {
  width: fit-content;
  color: var(--ink-soft);
  font: 500 .9rem/1.4 var(--sans);
  cursor: pointer;
}

details > summary:hover {
  color: var(--ink);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem;
  padding-top: .85rem;
}

.field {
  display: grid;
  gap: .3rem;
}

.field label {
  font: 600 .8rem/1.3 var(--sans);
}

input[type="number"],
select {
  width: 100%;
  min-height: 2.6rem;
  padding: .5rem .65rem;
  border: 1.5px solid var(--line);
  border-radius: .45rem;
  background: var(--screen);
  color: var(--ink);
  font: 1rem/1.2 var(--sans);
}

input[type="number"]:focus,
select:focus {
  border-color: var(--ink);
}

input::placeholder {
  color: #878580;
}

/* Buttons */

.button {
  display: flex;
  width: 100%;
  min-height: 3.2rem;
  align-items: center;
  justify-content: center;
  padding: .75rem 1rem;
  border: 2px solid var(--ink);
  border-radius: .6rem;
  background: var(--ink);
  color: var(--screen);
  font: 700 1.05rem/1 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}

.button:hover:not(:disabled) {
  background: #282726;
}

.button--secondary {
  background: transparent;
  color: var(--ink);
}

.button--secondary:hover:not(:disabled) {
  background: #f2f0e5;
}

.result > .button--secondary {
  margin-top: .5rem;
}

.button:disabled {
  border-color: var(--line);
  background: transparent;
  color: #878580;
  cursor: not-allowed;
}

/* Progress, error */

.progress-label {
  font-size: 1.15rem;
  font-weight: 700;
}

.progress .meter {
  margin-top: .6rem;
}

.meter {
  display: flex;
  align-items: center;
  gap: .75rem;
}

progress {
  flex: 1;
  height: .8rem;
  appearance: none;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--screen);
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: var(--screen);
}

progress::-webkit-progress-value {
  background: var(--ink);
}

progress::-moz-progress-bar {
  background: var(--ink);
}

#percent {
  min-width: 3.5ch;
  font: 700 .9rem/1 var(--sans);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.error {
  padding: .75rem .9rem;
  border: 1.5px solid var(--danger);
  border-radius: .5rem;
  color: var(--danger);
  font: 600 .9rem/1.45 var(--sans);
}

/* Result */

/* One screen at a time, like turning a page: the form, then the progress,
   then the result. */
.progress {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .35rem;
}

.result {
  display: grid;
  align-content: start;
  gap: .75rem;
}

.result:focus {
  outline: none;
}

.result-title {
  font-size: 1.15rem;
}

.result-sizes {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .2rem .6rem;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.result-sizes #size-before {
  color: var(--muted);
  font-weight: 400;
}

.result-sizes .arrow {
  color: var(--muted);
  font-weight: 400;
}

.result-summary {
  font: 600 1rem/1.4 var(--sans);
}

.hint {
  color: var(--muted);
  font: .85rem/1.45 var(--sans);
}

.result-details[open] > summary {
  margin-bottom: .5rem;
}

dl {
  display: grid;
  grid-template-columns: 1fr auto;
  margin: 0 0 .5rem;
  font: .9rem/1.4 var(--sans);
}

dt,
dd {
  padding: .4rem 0;
  border-top: 1px solid var(--line);
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.warnings h3 {
  margin-bottom: .3rem;
  font-size: 1rem;
}

.warnings ul {
  padding-left: 1.2rem;
  font: .85rem/1.45 var(--sans);
}

/* Bands below the tool */

.band {
  padding: clamp(2.5rem, 6vw, 4rem) 0;
  border-top: 1px solid var(--line);
}

.band h2 {
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  letter-spacing: -.015em;
}

.band-lede {
  max-width: 40rem;
  margin-top: .6rem;
  color: var(--ink-soft);
  font-size: 1.1rem;
}

.cases {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.5rem, 4vw, 3rem);
  margin-top: 2rem;
}

.case {
  display: grid;
  align-content: start;
  gap: .7rem;
}

.case h3 {
  font-size: 1.3rem;
}

.case > p {
  color: var(--ink-soft);
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
  margin-top: .3rem;
}

.pair img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: .45rem;
  filter: grayscale(.35);
}

.pair figcaption {
  margin-top: .4rem;
  font: 600 .85rem/1.3 var(--sans);
  text-align: center;
}

.case > .source {
  color: var(--muted);
  font: .82rem/1.45 var(--sans);
}

.sizes {
  margin-top: 2.25rem;
  font-size: 1.1rem;
}

.how {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1.25rem, 3vw, 2.5rem);
  margin-top: 2rem;
  padding: 0;
  list-style: none;
  counter-reset: how;
}

.how li {
  counter-increment: how;
}

.how li::before {
  content: counter(how);
  display: block;
  margin-bottom: .6rem;
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
}

.how h3 {
  margin-bottom: .45rem;
  font-size: 1.2rem;
}

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

.more {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.5rem, 4vw, 3rem);
}

.more h2 {
  font-size: 1.4rem;
}

.more p {
  margin-top: .6rem;
  color: var(--ink-soft);
}

pre {
  margin-top: 1rem;
  padding: .9rem 1rem;
  overflow-x: auto;
  border-radius: .5rem;
  background: var(--bezel);
  color: #e6e4d9;
  font: .88rem/1.6 var(--mono);
}

/* Footer */

.site-footer {
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: .85rem/1.5 var(--sans);
}

.site-footer strong {
  color: var(--ink);
  font-family: var(--serif);
}

/* Narrow screens: one column, tool right after the headline */

@media (max-width: 52rem) {
  .hero {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding-top: 1.5rem;
  }

  .hero-copy {
    padding-top: 0;
  }

  .facts {
    margin-top: 1rem;
  }

  .cases,
  .how,
  .more {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 34rem) {
  body {
    font-size: 1rem;
  }

  .site-header nav a:not(:last-child) {
    display: none;
  }

  h1 {
    font-size: 2.15rem;
  }

  .lede {
    margin-top: .8rem;
    font-size: 1.05rem;
  }

  .reader {
    --bezel-x: .5rem;
    --bezel-bottom: 1.5rem;
    border-radius: 1.1rem;
  }

  .screen {
    padding: 1rem;
  }

  .drop {
    min-height: 7rem;
  }

  .devices,
  .grid {
    grid-template-columns: 1fr;
  }
}
