/* The filling honeycomb: a piece of wax comb alone on a black page; under it one line of words with the percentage
   and the pill. The comb, the honey and the caps are painted by script.js with these colours. */
:root {
  --page: #000000;          /* the page */
  --ink: #f6efe2;           /* the words */
  --muted: #9a8f7c;         /* the quiet words */
  --error: #ff8466;         /* what went wrong */
  --ok: #ffc94d;            /* import complete */
  --wax: #d9a441;           /* the wax of the walls */
  --wax-light: #f8dc93;     /* the lit crest of the walls */
  --wax-dark: #7a4f14;      /* the wax in shade */
  --well: #1c1107;          /* the bottom of an empty cell */
  --honey-light: #ffd977;   /* honey where it is thin, near the surface */
  --honey: #f0a31a;         /* honey */
  --honey-deep: #8f3f05;    /* honey where it is thick */
  --cap: #f1c96e;           /* the wax cap of a full cell */
  --cap-light: #fff0c4;     /* the light on the cap's dome */
  --crack: #ff5a3c;         /* the cell that could not be read */
  --glint: #fff1c4;         /* the warm light that crosses the comb at the end */
  --button: #f6efe2;        /* the pill */
  --button-ink: #140d05;    /* its words */
  --line: #4a3f30;          /* the ring round the quiet pill */
  --focus: #ffc94d;         /* the keyboard's focus ring */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap, no zoom */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 40px 16px;
}

/* ---------------------------------------------------------------- the comb */
.favo {
  display: grid;
  width: min(380px, 100%);
}

/* the drawing is 380 by 232 units and scales with the width */
.favo__comb {
  position: relative;
  width: 100%;
  aspect-ratio: 380 / 232;
}

.favo__paint {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------------------------------------------------------------- the words */
.favo__info {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 16px;
  align-items: end;
  margin: 12px 22px 0;
}

.favo__title,
.favo__meta,
.favo__pct {
  margin: 0;
}

.favo__title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 22px;
  font-size: 16px;
  font-weight: 640;
  font-stretch: 94%;
  line-height: 22px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.favo__meta {
  grid-column: 1;
  min-width: 0;
  height: 19px;
  font-size: 13.5px;
  font-weight: 460;
  line-height: 19px;
  color: var(--muted);
  white-space: nowrap;
}

.favo__swap {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

/* the percentage keeps its width while the figures change, and narrows on the width axis */
.favo__pct {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  min-width: 2.7em;
  font-size: 34px;
  font-weight: 600;
  font-stretch: 78%;
  line-height: 1;
  letter-spacing: -0.03em;
  text-align: right;
  opacity: 0;
}

.favo[data-mode='error'] .favo__title {
  color: var(--error);
}

.favo[data-mode='error'] .favo__pct {
  color: var(--muted);
}

.favo[data-mode='done'] .favo__title {
  color: var(--ok);
}

/* the tick of Import complete, drawn in by script.js */
.favo__tick {
  display: none;
  flex: none;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: var(--ok);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

.favo[data-mode='done'] .favo__tick {
  display: block;
}

/* ---------------------------------------------------------------- the pill */
.favo__buttons {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

/* the fill is a layer of its own that swells past the edge with a bounce, and the words widen on the width axis of
   the font; pressed, the pill squashes a little */
.pill {
  position: relative;
  display: inline-grid;
  place-items: center;
  height: 44px;
  min-width: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--button-ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 640;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.25s ease;
}

.pill::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--button);
  transition: inset 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.25s ease, box-shadow 0.25s ease;
}

.pill__label {
  display: inline-block;
  font-stretch: 88%;
  transition: font-stretch 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* while the import runs the pill steps back: transparent with a ring, and it cancels */
.pill.is-quiet {
  color: var(--ink);
}

.pill.is-quiet::before {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--line);
}

@media (hover: hover) and (pointer: fine) {
  .pill:hover::before {
    inset: -2px -5px;
  }

  .pill:hover .pill__label {
    font-stretch: 104%;
  }

  .pill.is-quiet:hover::before {
    background: color-mix(in srgb, var(--line) 45%, transparent);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .pill::before,
  .pill__label {
    transition: none;
  }
}
