/* The publishing origami: a warm pale panel on a white page, a sheet of two-tone origami paper, four phase bars and
   a pill. The paper is painted by script.js with these colours; the panel, the words and the bars are plain CSS. */
:root {
  --page: #ffffff;          /* the page */
  --panel: #f5f2ed;         /* the publish panel */
  --ink: #1d1a17;           /* the words */
  --muted: #7d756c;         /* the quieter words */
  --paper: #26388a;         /* the paper's side that lies up at the start, ink blue */
  --paper-back: #f2714b;    /* its other side, coral */
  --shadow: #5a2a17;        /* the paper's shadow on the panel */
  --guide: #3a332d;         /* the dashed fold lines, as in an origami diagram */
  --track: #e6e0d8;         /* the empty phase bars */
  --error: #c8341c;         /* what went wrong */
  --ok: #2f7a4f;            /* the tick when the article is live */
  --button: #1d1a17;        /* the button */
  --button-ink: #ffffff;    /* its words */
  --line: #d9d1c6;          /* the ring of the quiet button */
  --focus: #e8603b;         /* 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: 'Instrument 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: 32px 16px;
}

/* ---------------------------------------------------------------- the panel */
.pub {
  position: relative;
  width: min(380px, 100%);
  padding: 18px 20px 16px;
  border-radius: 24px;
  background: var(--panel);
  color: var(--ink);
}

.pub__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.pub__words {
  min-width: 0;
}

.pub__title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 620;
  font-stretch: 94%;
  line-height: 1.25;
  letter-spacing: -0.012em;
}

.pub__meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 450;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* the words that change slide by themselves */
.pub__swap {
  display: inline-block;
}

.pub__swap .is-error {
  color: var(--error);
}

.pub__swap b {
  color: var(--ink);
  font-weight: 600;
}

/* the figure on the right: the words count at rest, the percentage while publishing, Live at the end */
.pub__figure {
  position: relative;
  flex: none;
  min-width: 64px;
  height: 21px;
  margin: 0;
  font-size: 16.5px;
  font-weight: 620;
  line-height: 21px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.pub__pct {
  display: inline-block;
}

.pub__pct.is-quiet {
  color: var(--muted);
  font-weight: 480;
  font-size: 13px;
}

.pub__live {
  position: absolute;
  right: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--ok);
  white-space: nowrap;
  visibility: hidden;
}

.pub__tick {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* ---------------------------------------------------------------- the paper */
/* the canvas is wider than its place, so the bird's shadow and its wings in flight are never cut */
.pub__paper {
  position: relative;
  height: 196px;
  margin: 6px -20px 4px;
}

.pub__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the phases */
.pub__phases {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.pub__phase {
  min-width: 0;
}

.pub__name {
  display: block;
  margin-bottom: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 520;
  font-stretch: 92%;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: color 0.35s ease, font-stretch 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pub__phase.is-on .pub__name {
  color: var(--ink);
  font-weight: 620;
  font-stretch: 100%;
}

.pub__phase.is-done .pub__name {
  color: var(--ink);
}

.pub__phase.is-failed .pub__name {
  color: var(--error);
  font-weight: 620;
}

.pub__track {
  position: relative;
  display: block;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--track);
}

.pub__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--paper);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: background-color 0.3s ease;
}

.pub__phase.is-failed .pub__fill {
  background: var(--error);
}

/* ---------------------------------------------------------------- the site and the button */
.pub__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.pub__site {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 480;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pub__site .pub__swap {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

/* the pill: its words widen on the width axis under the pointer, its body swells with a bounce */
.pill {
  position: relative;
  z-index: 0;
  display: inline-grid;
  flex: none;
  place-items: center;
  height: 40px;
  min-width: 44px;
  padding: 0 19px;
  overflow: visible;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--button-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 620;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.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 paper folds the button only cancels: it steps back */
.pill.is-quiet {
  color: var(--ink);
}

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

/* Retry is in the paper's colour */
.pill.is-strong::before {
  background: var(--paper);
}

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

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

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

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

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