/* The offline notes notice with the changes that fly into the cloud: a dark pill over a small white note, alone on
   white. The pill hangs from the top of its slot and comes down when the network drops; the marks that fly from the
   note to the counter and from the counter into the cloud live in one overlay (.flight) over everything. */
:root {
  --page: #ffffff;          /* the page */
  --pill: #141417;          /* the body of the pill */
  --pill-top: #222227;      /* the light top of the pill */
  --pill-ink: #f4f4f6;      /* the words on the pill */
  --pill-muted: #9a9aa4;    /* the small words on the pill */
  --off: #8d8d96;           /* the cloud while offline */
  --accent: #3f7cff;        /* the cloud back online, the marks going up, the check */
  --note: #ffffff;          /* the note */
  --note-edge: #e9e9ee;     /* the edge of the note */
  --ink: #1b1b1f;           /* the words of the note */
  --muted: #8f8f99;         /* the small words of the note */
}

* {
  box-sizing: border-box;
}

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;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
}

.deck {
  width: min(92vw, 360px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2.6vh, 18px);
}

/* the slot the pill hangs in: it keeps its height when the pill is away, so the note never jumps */
.slot {
  width: 100%;
  height: clamp(56px, 15vh, 64px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  height: clamp(54px, 14.5vh, 62px);
  max-width: 100%;
  padding: 0 9px 0 10px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--pill-top), var(--pill) 62%);
  color: var(--pill-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 1px 2px rgba(10, 10, 20, 0.18),
    0 8px 18px -6px rgba(10, 10, 20, 0.28),
    0 22px 40px -18px rgba(10, 10, 30, 0.35);
  visibility: hidden;
  -webkit-tap-highlight-color: transparent;
}

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

/* a soft band of light along the top edge of the pill */
.pill__sheen {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  overflow: hidden;
  background: radial-gradient(120% 70% at 30% -20%, rgba(255, 255, 255, 0.1), transparent 60%);
}

/* the light that crosses the pill when everything is synced */
.pill__sweep {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 28%;
  opacity: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 22%, transparent) 40%, rgba(255, 255, 255, 0.14) 50%, color-mix(in srgb, var(--accent) 22%, transparent) 60%, transparent);
}

.cloud {
  position: relative;
  flex: none;
  width: clamp(36px, 10vh, 42px);
  height: clamp(36px, 10vh, 42px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.cloud svg {
  width: 62%;
  height: 62%;
  overflow: visible;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cloud__shape {
  stroke: var(--off);
  stroke-width: 1.6;
}

/* the cut under the bar, in the colour of the pill, so the bar seems to pass through the cloud */
.cloud__cut line {
  stroke: #1b1b1f;
  stroke-width: 4.2;
}

.cloud__bar line {
  stroke: var(--pill-ink);
  stroke-width: 1.6;
}

.cloud__up,
.cloud__tick {
  stroke: var(--accent);
  stroke-width: 1.7;
  opacity: 0;
}

.pill__words {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-right: 2px;
}

.pill__title,
.pill__sub {
  position: relative;
  display: block;
  overflow: hidden;
  white-space: nowrap;
}

.pill__title {
  font-size: clamp(13px, 3.8vh, 14.5px);
  line-height: 1.25;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  letter-spacing: 0.005em;
}

.pill__sub {
  font-size: clamp(11px, 3.2vh, 12.5px);
  line-height: 1.3;
  color: var(--pill-muted);
  font-variation-settings: 'wdth' 98;
}

.pill__title > span,
.pill__sub > span,
.badge__num > span {
  display: block;
}

/* the counter of the changes waiting: its width goes to zero when everything is up */
.badge {
  flex: none;
  overflow: hidden;
}

.badge__in {
  display: flex;
  align-items: baseline;
  gap: 5px;
  height: clamp(34px, 9.5vh, 40px);
  padding: 0 12px;
  margin-left: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  align-items: center;
}

.badge__num {
  position: relative;
  overflow: hidden;
  min-width: 0.62em;
  font-size: 15px;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  text-align: center;
}

.badge__label {
  font-size: 11.5px;
  color: var(--pill-muted);
}

/* the note being written: the thing the changes come from */
.note {
  position: relative;
  width: 100%;
  padding: clamp(12px, 3.6vh, 18px) clamp(14px, 4.6vw, 20px) clamp(10px, 3vh, 14px);
  border-radius: 18px;
  background: var(--note);
  box-shadow:
    inset 0 0 0 1px var(--note-edge),
    0 1px 2px rgba(20, 20, 40, 0.04),
    0 14px 30px -18px rgba(20, 20, 40, 0.18);
}

.note__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.note__name {
  font-size: clamp(14px, 4vh, 16px);
  font-weight: 640;
  font-variation-settings: 'wdth' 104;
  letter-spacing: -0.005em;
}

.note__when {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.note__body {
  margin: clamp(6px, 2vh, 10px) 0 0;
  min-height: calc(3 * 1.5em);
  font-size: clamp(12.5px, 3.6vh, 14px);
  line-height: 1.5;
  color: #3a3a42;
}

.note__caret {
  display: inline-block;
  width: 1.5px;
  height: 1.1em;
  margin-left: 1px;
  vertical-align: -0.18em;
  border-radius: 1px;
  background: var(--accent);
  animation: blink 1.05s steps(1) infinite;
}

.typing .note__caret {
  animation: none;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.note__rule {
  display: block;
  height: 1px;
  margin: clamp(8px, 2.4vh, 12px) 0 clamp(7px, 2vh, 10px);
  background: var(--note-edge);
}

.note__foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

/* the marks that fly: little strokes, like lines of a page */
.flight {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.mark {
  position: absolute;
  left: 0;
  top: 0;
  width: 9px;
  height: 3px;
  margin: -1.5px 0 0 -4.5px;
  border-radius: 2px;
  background: var(--ink);
}

.mark--up {
  background: var(--accent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent);
}

@media (hover: hover) {
  .pill {
    transition: box-shadow 0.3s ease;
  }

  .pill:hover {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.14),
      inset 0 0 0 1px rgba(255, 255, 255, 0.1),
      0 1px 2px rgba(10, 10, 20, 0.18),
      0 10px 22px -6px rgba(10, 10, 20, 0.32),
      0 26px 46px -18px rgba(10, 10, 30, 0.4);
  }
}

/* on a narrow screen the counter keeps only its number, so the words of the pill are never cut */
@media (max-width: 400px) {
  .pill {
    gap: 9px;
  }

  .badge__label {
    display: none;
  }

  .badge__in {
    padding: 0 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .note__caret {
    animation: none;
  }
}
