/* enumerator.click — one page, one key. Tokens and values from _meta/design/README.md. */

/* IBM Plex Mono, self-hosted (IBM Plex release @ibm/plex-mono@2.5.0, OFL; see fonts/OFL.txt). */
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/IBMPlexMono-Regular.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/IBMPlexMono-Medium.woff2") format("woff2");
}

:root {
  --paper: #f5f2ec;
  --face: #fbfaf7;
  --face-hover: #ffffff;
  --ink: #1a1916;
  --ink-deep: #0b0a08;
  --secondary: #4f4d47;
  --faint: #6f6e69;
  --on-ink-secondary: #b8b3a8;
  --underline: #b9b4aa;
  --accent: #3f6699;
  --plate-1: #1a1916;
  --plate-2: rgba(26, 25, 22, 0.34);
  --plate-3: rgba(26, 25, 22, 0.13);
  --plate-ink-2: rgba(11, 10, 8, 0.34);
  --plate-ink-3: rgba(11, 10, 8, 0.13);

  --font: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: ui-sans-serif, system-ui, sans-serif;
  --column: 620px;
  --transition: 90ms linear;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  -webkit-text-size-adjust: 100%;
}

body { margin: 0; }

[hidden] { display: none !important; }

p { margin: 0; }

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

sup {
  font-family: var(--sans);
  font-size: 0.7em;
  line-height: 0;
  vertical-align: super;
}

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

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

/* Page: a single fluid column sized by container width, so 1cqw is 1% of the page. */
.page {
  container-type: inline-size;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: clamp(22px, 5.6cqw, 40px) clamp(22px, 5.6cqw, 40px) clamp(20px, 4.6cqw, 34px);
  overflow-x: hidden;

  --step: clamp(8px, 2.2cqw, 14px);
  --step-2: calc(var(--step) * 2);
  --step-3: calc(var(--step) * 3);
  --plates: 3; /* plates behind the key: three before the click, two after */
  --body: clamp(13px, 3.4cqw, 15px);
  --faint-size: clamp(11.5px, 2.9cqw, 13px);
}

.row {
  display: flex;
  justify-content: center;
}

.row > * {
  width: 100%;
  max-width: var(--column);
}

.tagline {
  font-size: var(--faint-size);
  line-height: 1.5;
  color: var(--faint);
  letter-spacing: 0.01em;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(18px, 4.4cqw, 30px);
  padding: clamp(24px, 5cqw, 40px) 0;
}

.main > * {
  width: 100%;
  max-width: var(--column);
}

.line {
  font-size: var(--body);
  line-height: 1.6;
}

.line--secondary { color: var(--secondary); }
.line--faint { color: var(--faint); }

/* Yesterday's result */
.yesterday {
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1cqw, 6px);
  font-size: var(--body);
  line-height: 1.62;
  color: var(--secondary);
  text-wrap: pretty;
}

.yesterday__lines { display: contents; }
.yesterday .tone-ink { color: var(--ink); }
.yesterday .tone-secondary { color: var(--secondary); }
.yesterday .tone-faint { color: var(--faint); }

.yesterday__share { margin-top: clamp(3px, 0.8cqw, 5px); }
.yesterday__share a { color: var(--secondary); }
.yesterday__share a:hover { color: var(--ink); }

/* The key: a paper plate over three receding ink plates. The wrapper reserves
   room for the extrusion so the plates never clip. */
.key-slot {
  display: grid;
  padding: 0 var(--step-3) var(--step-3) 0;
}

.key-slot > .key { grid-area: 1 / 1; }

/* The ink card waits beneath the paper one until the click reveals it. */
.key-slot:not(.is-counted) .key--counted { visibility: hidden; }

.key {
  appearance: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(6px, 1.6cqw, 12px);
  width: 100%;
  min-height: clamp(118px, 30cqw, 196px);
  margin: 0;
  padding: clamp(22px, 5.6cqw, 40px) clamp(22px, 5.4cqw, 38px);
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--face);
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: pointer;
  box-shadow:
    var(--step) var(--step) 0 0 var(--plate-1),
    var(--step-2) var(--step-2) 0 0 var(--plate-2),
    var(--step-3) var(--step-3) 0 0 var(--plate-3);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

button.key:hover:not(:disabled) { background: var(--face-hover); }

button.key:active:not(:disabled) {
  transform: translate(var(--step), var(--step));
  box-shadow:
    0 0 0 0 var(--plate-1),
    var(--step) var(--step) 0 0 var(--plate-2),
    var(--step-2) var(--step-2) 0 0 var(--plate-3);
}

button.key:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

/* Pending: the paper card is picked up a little and held until the server
   answers. No spinner, no colour change. */
.key:disabled {
  cursor: default;
}

.key-slot.is-pending .key:not(.key--counted) {
  transform: translate(-3px, -3px);
  box-shadow:
    calc(var(--step) + 3px) calc(var(--step) + 3px) 0 0 var(--plate-1),
    calc(var(--step-2) + 3px) calc(var(--step-2) + 3px) 0 0 var(--plate-2),
    calc(var(--step-3) + 3px) calc(var(--step-3) + 3px) 0 0 var(--plate-3);
}

/* Counted: the paper card is dismissed off the top of the stack, taking its
   plates with it; the ink card it covered is the record. */
@keyframes dismiss {
  from { transform: translate(-3px, -3px); opacity: 1; }
  60% { transform: translate(-3%, -75%) rotate(-1deg); opacity: 1; }
  to { transform: translate(-4%, -120%) rotate(-1.5deg); opacity: 0; }
}

.key.is-dismissed {
  animation: dismiss 380ms cubic-bezier(0.4, 0, 0.7, 1) forwards;
  pointer-events: none;
}

.key__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.key__count {
  font-size: clamp(38px, 9.6cqw, 74px);
  line-height: 0.94;
  letter-spacing: -0.02em;
  font-weight: 500;
}

.key__marker {
  font-size: clamp(10px, 2.5cqw, 12px);
  line-height: 1.4;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  padding-bottom: clamp(4px, 1cqw, 8px);
}

.key__sub {
  font-size: clamp(13px, 3.3cqw, 16px);
  line-height: 1.4;
  color: var(--secondary);
}

/* After the click: the stack has stepped one layer closer and inverted. Not a
   button. It drops one step but keeps the column's left edge. */
.page.is-counted { --plates: 2; }

.key--counted {
  gap: clamp(8px, 1.8cqw, 14px);
  border-color: var(--ink-deep);
  background: var(--ink);
  color: var(--paper);
  cursor: default;
  transform: translate(0, var(--step));
  box-shadow:
    var(--step) var(--step) 0 0 var(--plate-ink-2),
    var(--step-2) var(--step-2) 0 0 var(--plate-ink-3);
}

.key--counted:focus,
.key--counted:focus-visible { outline: none; }

.key__ordinal {
  font-size: clamp(25px, 6.3cqw, 48px);
  line-height: 1.04;
  letter-spacing: -0.02em;
  font-weight: 500;
}

.key__marks {
  display: flex;
  align-items: flex-end;
  gap: clamp(6px, 1.4cqw, 10px);
  white-space: nowrap;
  padding-bottom: clamp(4px, 1cqw, 8px);
  color: var(--on-ink-secondary);
  font-size: clamp(10px, 2.5cqw, 12px);
  line-height: 1.4;
}

.key__share {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--on-ink-secondary);
  font: inherit;
  font-size: clamp(10px, 2.5cqw, 12px);
  line-height: 1.4;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  cursor: pointer;
}

.key__share:hover { color: var(--paper); }

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

.key--counted .key__sub {
  font-size: clamp(12.5px, 3.2cqw, 15px);
  color: var(--on-ink-secondary);
}

.line--error {
  margin-top: clamp(-14px, -3.4cqw, -8px);
}

/* The wall: a short faint ladder of records, newest first, starting on the
   deepest plate's left edge, each older record one plate-step further right,
   like the key's layers. */
.wall {
  font-size: var(--faint-size);
  line-height: 1.62;
  color: var(--faint);
  display: flex;
  flex-direction: column;
  min-height: 1.62em;
}

.wall__entry { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: calc(var(--step) * var(--plates)); }
.wall__entry:nth-child(2) { padding-left: calc(var(--step) * (var(--plates) + 1)); }
.wall__entry:nth-child(3) { padding-left: calc(var(--step) * (var(--plates) + 2)); }
.wall__entry:nth-child(4) { padding-left: calc(var(--step) * (var(--plates) + 3)); }
.wall__entry:nth-child(5) { padding-left: calc(var(--step) * (var(--plates) + 4)); }
.wall__entry:nth-child(n + 6) { padding-left: calc(var(--step) * (var(--plates) + 5)); }
.wall__own { color: var(--ink); }
.wall__you { color: var(--faint); }

/* Email field, opened from the footer */
.email {
  display: flex;
  flex-direction: column;
  gap: clamp(3px, 0.9cqw, 5px);
  margin: 0;
}

.email__actions {
  display: flex;
  align-items: flex-end;
  gap: clamp(8px, 2cqw, 12px);
  padding-bottom: 7px;
  font-size: var(--body);
  color: var(--faint);
}

.email__when {
  font-size: var(--faint-size);
  line-height: 1.5;
  color: var(--faint);
}

.email__row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: clamp(12px, 3cqw, 20px);
  margin-top: clamp(8px, 2cqw, 12px);
}

.email__input {
  appearance: none;
  width: clamp(180px, 46cqw, 260px);
  margin: 0;
  padding: 0 0 7px;
  border: 0;
  border-bottom: 1px solid var(--underline);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--body);
}

.email__input::placeholder { color: var(--faint); opacity: 1; }

.email__input:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.email__submit,
.email__close {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--body);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.email__submit:hover { color: #000; }

.email__close { color: var(--faint); }
.email__close:hover { color: var(--ink); }

/* Footer */
.foot {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 3.4cqw, 22px);
}

.foot__links,
.foot__post {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(8px, 2cqw, 12px);
  font-size: var(--faint-size);
  line-height: 1.5;
  color: var(--faint);
}

.foot__post {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2.4cqw, 16px);
}

.foot__offer { display: contents; }

.foot__link {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--faint);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.foot__link:hover { color: var(--ink); }

.footnote {
  display: flex;
  flex-direction: column;
  gap: clamp(9px, 2.2cqw, 13px);
  max-width: var(--column);
  font-size: clamp(12px, 3cqw, 14px);
  line-height: 1.66;
  color: var(--secondary);
  text-wrap: pretty;
}

.footnote__title { color: var(--ink); }
.footnote__tagline { color: var(--faint); }

.foot__last {
  font-size: clamp(11px, 2.7cqw, 12.5px);
  line-height: 1.5;
  color: var(--faint);
}

@media (prefers-reduced-motion: reduce) {
  .key { transition: none; }
  .key.is-dismissed { animation: none; visibility: hidden; }
}

/* Standalone pages (privacy, what just happened): the footnote typography in the main column. */
.main--notice { justify-content: flex-start; }
.notice { width: 100%; }
