/* Am I in the 1%? — a plate in the manner of the Statistical Atlas of the United States. */

@font-face {
  font-family: "League Gothic";
  src: url("../fonts/league-gothic-normal-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("../fonts/public-sans-normal-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Public Sans";
  src: url("../fonts/public-sans-italic-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-style: italic;
  font-display: swap;
}

@property --col { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --row { syntax: "<number>"; inherits: true; initial-value: 0; }

:root {
  color-scheme: light;

  /* plate stock and ink */
  --paper: #ffffff;
  --ink: #14171c;
  --ink-2: #4a5160;
  --hairline: #d3d9e3;

  /* Old Glory Blue and Red (US Department of State), with a blue ramp for the 99% */
  --blue-1: #9ab2d8;
  --blue-2: #5a7db8;
  --blue-3: #0a3161;
  --red: #b31942;
  --red-press: #8e1235;

  --display: "League Gothic", "Arial Narrow", sans-serif;
  --text: "Public Sans", system-ui, sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --rule-gap: 7px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--blue-3) var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--text);
  caret-color: var(--red);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--red); color: var(--paper); }

a {
  color: var(--blue-3);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { color: var(--red); }

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

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.defs { position: absolute; }
.red { color: var(--red); }
.fig { color: var(--red); margin-right: 0.15em; }

/* ---------- the plate: thick-thin double rule ---------- */

.plate {
  position: relative;
  max-width: 1200px;
  margin: clamp(10px, 2.5vw, 32px) auto;
  margin-inline: clamp(10px, 2.5vw, 32px);
  margin-bottom: 0;
  border: 3px solid var(--ink);
  padding: clamp(24px, 4vw, 52px);
}
@media (min-width: 1264px) {
  .plate { margin-inline: auto; }
}
.plate::before {
  content: "";
  position: absolute;
  inset: var(--rule-gap);
  border: 1px solid var(--ink);
  pointer-events: none;
}

.plate-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
}
@media (min-width: 960px) {
  .plate-body {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
    gap: clamp(3rem, 6vw, 5.5rem);
    align-items: start;
  }
}

/* ---------- the question ---------- */

h1 {
  margin: 0 0 clamp(1.75rem, 3.5vw, 2.5rem);
  font: 400 clamp(3.9rem, 13vw, 6rem)/0.86 var(--display);
  letter-spacing: 0.005em;
  text-transform: uppercase;
  color: var(--blue-3);
  text-wrap: balance;
}

.field-label {
  display: block;
  font-weight: 650;
  font-size: 0.98rem;
  margin-bottom: 0.2rem;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.4rem;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.field-row:focus-within {
  border-bottom-color: var(--blue-3);
  box-shadow: 0 2px 0 0 var(--blue-3);
}
.field-row.is-invalid { border-bottom-color: var(--red); box-shadow: 0 2px 0 0 var(--red); }

.field-dollar,
.field-input {
  font: 400 clamp(2.9rem, 9vw, 3.6rem)/1 var(--display);
  color: var(--blue-3);
}
.field-dollar { padding-top: 0.08em; }
.field-input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0.12em 0 0;
  background: transparent;
  letter-spacing: 0.02em;
  outline: none;
}
.field-input::placeholder { color: var(--blue-2); opacity: 1; }

.field-go {
  flex: none;
  font: 400 1.4rem/1 var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--red);
  border: 0;
  padding: 0.75rem 1.15rem 0.7rem;
  cursor: pointer;
  transition: background-color 140ms ease, transform 140ms var(--ease-out);
}
.field-go:hover { background: var(--red-press); }
.field-go:active { transform: translateY(1px); }

.field-help {
  margin: 0.7rem 0 0;
  max-width: 48ch;
  font-size: 0.9rem;
  color: var(--ink-2);
}
.field-error {
  margin: 0.5rem 0 0;
  font-weight: 650;
  font-size: 0.95rem;
  color: var(--red);
}
.field-error:empty { display: none; }

/* ---------- the answer ---------- */

.answer { margin-top: clamp(2.25rem, 5vw, 3.25rem); }

.verdict {
  margin: 0 0 0.9rem;
  font: 400 clamp(4.6rem, 22vw, 6rem)/0.84 var(--display);
  text-transform: uppercase;
  color: var(--red);
  letter-spacing: 0.01em;
}
.verdict .letter { display: inline-block; }
.verdict.is-setting .letter {
  animation: set-type 520ms var(--ease-out) both;
  animation-delay: calc(var(--i) * 55ms);
}
@keyframes set-type {
  from { transform: translateY(-0.55em); opacity: 0; filter: blur(3px); }
  to { transform: none; opacity: 1; filter: none; }
}

.standing {
  margin: 0 0 0.55rem;
  font-size: clamp(1.3rem, 3.6vw, 1.55rem);
  line-height: 1.28;
  font-weight: 600;
  text-wrap: balance;
}
.standing strong { color: var(--blue-3); font-weight: 800; }

.sass {
  margin: 0 0 1.4rem;
  font-size: 1.12rem;
  font-style: italic;
  color: var(--ink-2);
  max-width: 44ch;
}

.gap {
  margin: 0;
  padding-top: 1.1rem;
  border-top: 1px solid var(--ink);
  font-size: 1.08rem;
  max-width: 46ch;
}
.gap strong { color: var(--red); font-weight: 750; }

/* ---------- Fig. 1: the road to the 1% ---------- */

.route { margin: clamp(2.25rem, 5vw, 3rem) 0 0; }

.route figcaption,
.diagram h2,
.notes h2,
.legend th,
.corner,
.route-label {
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.route figcaption { font-size: 1.05rem; line-height: 1.2; }

.route-track {
  --line: 52px;
  position: relative;
  height: 112px;
  margin: 0.6rem 0.1rem 0;
}
.route-track.is-bare { height: calc(var(--line) + 14px); }
.route-line {
  position: absolute;
  left: 0; right: 0;
  top: var(--line);
  height: 2px;
  background: var(--ink);
}
.route-run {
  position: absolute;
  top: calc(var(--line) - 2px);
  height: 6px;
  background: var(--red);
  transform-origin: left center;
}
.route-run.is-over { background: var(--blue-3); }
.route-tick {
  position: absolute;
  top: calc(var(--line) - 10px);
  width: 1px;
  height: 10px;
  background: var(--ink);
}
.route-tick.is-end {
  width: 6px;
  height: 18px;
  top: calc(var(--line) - 8px);
  margin-left: -3px;
  background: var(--red);
}
.route-label {
  position: absolute;
  bottom: calc(100% - var(--line) + 14px);
  font-size: 0.95rem;
  line-height: 1.05;
  white-space: nowrap;
  transform: translateX(-50%);
  text-align: center;
}
.route-label b {
  display: block;
  font-family: var(--text);
  font-weight: 650;
  font-size: 0.82rem;
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.route-label.is-end { color: var(--red); }
.route-label[data-align="start"] { transform: translateX(-2px); text-align: left; }
.route-label[data-align="end"] { transform: translateX(calc(-100% + 2px)); text-align: right; }
.route-label.is-below { bottom: auto; top: calc(var(--line) + 18px); }
.route-label.is-gap { color: var(--ink); }
.route-label.is-gap b { color: var(--ink); }

.route-you {
  position: absolute;
  top: calc(var(--line) - 12px);
  width: 26px;
  height: 26px;
  margin-left: -13px;
}

/* the star that means "you" */
.star-mark {
  display: block;
  width: 100%;
  height: 100%;
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 1.6px;
  stroke-linejoin: round;
  paint-order: stroke;
  overflow: visible;
}

/* ---------- Fig. 2: the proportion square ---------- */

.diagram-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--ink);
}
.diagram h2 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.1;
}

.toggle {
  display: inline-flex;
  border: 1.5px solid var(--ink);
}
.toggle-btn {
  font: 400 1.05rem/1 var(--display);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  padding: 0.62rem 1.05rem 0.55rem;
  min-height: 40px;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.toggle-btn + .toggle-btn { border-left: 1.5px solid var(--ink); }
.toggle-btn:hover { background: #eef2f8; }
.toggle-btn[aria-pressed="true"] { background: var(--blue-3); color: var(--paper); }
.toggle-btn:focus-visible { outline-offset: 2px; position: relative; z-index: 1; }

.square-wrap {
  position: relative;
  margin: 1.1rem 0 0.9rem;
  padding-right: 3.6rem;
  max-width: 34rem;
}
.corner {
  display: block;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--ink-2);
}
.corner--top { text-align: right; margin-bottom: 0.45rem; }
.corner--bottom { margin-top: 0.45rem; }

.square {
  position: relative;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  aspect-ratio: 1;
}
.cell {
  background: var(--c, var(--hairline));
  transition: background-color 280ms ease;
  transition-delay: var(--d, 0ms);
}
.cell[data-group="bottom50"] { --c: var(--blue-1); }
.cell[data-group="middle40"] { --c: var(--blue-2); }
.cell[data-group="next9"] { --c: var(--blue-3); }
.cell[data-group="top1"] { --c: var(--red); }

.you-star {
  position: absolute;
  left: 0;
  top: 0;
  width: calc((100% - 18px) / 10);
  aspect-ratio: 1;
  transform: translate(calc(var(--col) * (100% + 2px)), calc((9 - var(--row)) * (100% + 2px)));
  transition: --col 760ms var(--ease-out), --row 760ms var(--ease-out);
  pointer-events: none;
}
.you-star .star-mark {
  position: absolute;
  inset: 14%;
  width: 72%;
  height: 72%;
}
.you-star::after {
  /* a short leader in the margin points at the star's row; it never crosses the cells */
  content: "";
  position: absolute;
  left: calc(100% + (9 - var(--col)) * (100% + 2px) + 3px);
  top: 50%;
  height: 1px;
  width: 9px;
  background: var(--ink);
}
.you-tag {
  position: absolute;
  top: 50%;
  left: calc(100% + (9 - var(--col)) * (100% + 2px) + 14px);
  transform: translateY(-50%);
  font: 400 1.05rem/1 var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tip {
  position: absolute;
  z-index: 2;
  max-width: 15rem;
  padding: 0.5rem 0.65rem;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.84rem;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(10, 20, 40, 0.18);
}
.tip strong { display: block; margin-bottom: 0.15rem; font-size: 0.98rem; font-variant-numeric: tabular-nums; }
.tip em { display: block; margin-top: 0.35rem; font-style: normal; font-weight: 650; }

.caption {
  margin: 0 0 1.5rem;
  max-width: 48ch;
  font-size: 0.98rem;
  min-height: 4.6em;
}

.legend {
  width: 100%;
  max-width: 34rem;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.legend th {
  text-align: left;
  font-size: 0.92rem;
  padding: 0 0 0.45rem;
  border-bottom: 1px solid var(--ink);
}
.legend td {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
.legend .num {
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding-left: 0.9rem;
}
.legend .swatch {
  position: relative;
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  margin-right: 0.55rem;
  vertical-align: -0.08rem;
  background: var(--c);
}
.legend tr.is-mine .swatch {
  width: 1.1rem;
  height: 1.1rem;
  margin-left: -0.125rem;
  margin-right: 0.43rem;
  vertical-align: -0.2rem;
}
.legend .swatch .star-mark {
  position: absolute;
  inset: 12%;
  width: 76%;
  height: 76%;
}
.legend td:first-child { white-space: nowrap; }
.legend tr.is-mine td { font-weight: 750; }
.legend .brief { display: none; }
@media (max-width: 480px) {
  .legend .full { display: none; }
  .legend .brief { display: inline; }
  .legend { font-size: 0.86rem; }
  .legend .num { padding-left: 0.5rem; }
  .legend .swatch { margin-right: 0.45rem; }
}

/* ---------- notes ---------- */

.notes {
  margin-top: clamp(2.5rem, 6vw, 4rem);
  padding-top: 1rem;
  border-top: 1px solid var(--ink);
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink-2);
}
.notes h2 { margin: 0 0 0.6rem; font-size: 1.05rem; color: var(--ink); }
.notes ol { margin: 0; padding-left: 1.15rem; }
.notes li { margin-bottom: 0.45rem; break-inside: avoid; }
.notes strong { color: var(--ink); font-weight: 650; }
@media (min-width: 860px) {
  .notes ol { columns: 2; column-gap: 3rem; }
}

/* ---------- a text plate (privacy policy) ---------- */

.doc > * { max-width: 40rem; }
.doc-back {
  display: inline-block;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
  font: 400 1.05rem/1 var(--display);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--blue-3);
  border-bottom: 1px solid var(--blue-3);
  padding-bottom: 0.2rem;
}
.doc-back:hover { color: var(--red); border-bottom-color: var(--red); }
.doc h1 { margin-bottom: 0.6rem; }
.doc-date {
  margin: 0 0 1.75rem;
  font-size: 0.9rem;
  color: var(--ink-2);
}
.doc-lede {
  margin: 0 0 1.25rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--ink);
  font-size: clamp(1.3rem, 3.6vw, 1.55rem);
  line-height: 1.32;
  font-weight: 600;
  text-wrap: pretty;
}
.doc h2 {
  margin: 2rem 0 0.4rem;
  font: 400 1.3rem/1.1 var(--display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.doc p { margin-top: 0; text-wrap: pretty; }
.imprint a[aria-current="page"] { color: var(--ink-2); text-decoration: none; }

/* ---------- imprint, under the plate ---------- */

.imprint {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 2rem;
  max-width: 1200px;
  margin: 0.85rem clamp(10px, 2.5vw, 32px) clamp(16px, 3vw, 32px);
  padding: 0 0.2rem;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--ink-2);
}
.imprint p { margin: 0; }
.imprint-sep { margin: 0 0.35em; }
@media (min-width: 1264px) {
  .imprint { margin-inline: auto; }
}

.noscript {
  max-width: 40rem;
  margin: 1rem auto;
  padding: 0 1rem;
  font-weight: 650;
  color: var(--red);
}

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