/* The share menu made of modules: a playlist's Share button whose panel comes out of it square by square, and whose
   squares turn into the QR code of the link. The script draws the squares in the canvas; the words sit above it. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #0e1d24;           /* the panel, the button and the dark squares of the QR code */
  --ink-lift: #18323c;      /* the button under the pointer, and open */
  --paper: #e9f0ec;         /* the highlight, the light squares of the QR code and the words on the panel */
  --muted: #86a1a7;         /* the second line, the hints */
  --icon: #a6bec2;          /* the icons on the panel */
  --accent: #ffd36e;        /* the reading head: the squares and letters being read */
  --land: #3f7280;          /* a square as it lands */
  --rule: rgba(233, 240, 236, 0.1);
  --rim: rgba(233, 240, 236, 0.08);   /* the hairline round the panel */
}

* {
  box-sizing: border-box;
}

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

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

/* in cima alla pagina: in fondo al body, col suo margine, la allungherebbe */
.sr {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

/* schermo basso: meno vuoto sopra e sotto, così pannello e pulsante si rimpiccioliscono meno per starci */
@media (max-height: 520px) {
  .stage {
    padding: 16px 16px 22px;
  }
}

/* ---------------------------------------------------------------- the frame: the panel's room and its button */
.share {
  position: relative;
  width: 344px;
  height: var(--frame, 448px);
  flex: none;
}

/* the squares fly through all of it, so the canvas is a little larger than the frame */
.share__canvas {
  position: absolute;
  top: -24px;
  left: -24px;
  z-index: 1;
  width: calc(100% + 48px);
  height: calc(100% + 48px);
  pointer-events: none;
}

.share__shade,
.sheet {
  position: absolute;
  left: 0;
  bottom: 72px;
  width: 344px;
  height: 320px;
}

.share__shade {
  z-index: 0;
  border-radius: 18px;
  box-shadow: 0 2px 4px rgba(14, 29, 36, 0.14), 0 26px 48px -18px rgba(14, 29, 36, 0.5);
  opacity: 0;
}

.sheet {
  z-index: 2;
  visibility: hidden;
  pointer-events: none;
  color: var(--paper);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.sheet.is-shown {
  visibility: visible;
}

.sheet.is-live {
  pointer-events: auto;
}

.sheet__page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 9px 8px;
}

.sheet__page[hidden] {
  display: none;
}

/* the QR page takes the focus after a pointer, so the keys still work there; it needs no ring */
.sheet__page:focus {
  outline: none;
}

/* ---------------------------------------------------------------- what is shared */
.sheet__head {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 10px;
}

.sheet__cover {
  width: 44px;
  height: 44px;
  flex: none;
  clip-path: inset(0 round 10px);
}

.sheet__what {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sheet__title {
  font-size: 15.5px;
  font-weight: 640;
  letter-spacing: -0.005em;
}

.sheet__meta {
  font-size: 13px;
  font-weight: 440;
  color: var(--muted);
}

.sheet__rule {
  height: 1px;
  margin: 4px 10px;
  background: var(--rule);
}

/* ---------------------------------------------------------------- the items */
.menu {
  outline: none;
}

.item {
  position: relative;
  display: block;
  height: 44px;            /* the panel is worked out in squares of 8: the items stay 44 */
  color: inherit;
  text-decoration: none;
  outline: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.item__face {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  height: 100%;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}

/* the dark copy of each item, shown only where the highlight is (the script moves its clip-path). The words of the
   face are the colour of the highlight, so under it they vanish and only the dark copy is seen */
.item__face--ink {
  position: absolute;
  inset: 0;
  color: var(--ink);
  clip-path: inset(0 0 100% 0);
}

.item__icon {
  width: 20px;
  height: 20px;
  overflow: visible;
  fill: none;
  stroke: var(--icon);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.item__face--ink .item__icon {
  stroke: currentColor;
}

.item__glyph {
  position: relative;
  width: 20px;
  height: 20px;
}

.item__glyph .item__icon {
  position: absolute;
  inset: 0;
}

/* the check that takes the icon's place once something is copied */
.item__done {
  stroke-width: 2.1;
}

.item__face .item__done {
  stroke: var(--paper);
}

.item__face--ink .item__done {
  stroke: currentColor;
}

.item__bits {
  fill: var(--icon);
  stroke: none;
}

.item__face--ink .item__bits {
  fill: currentColor;
}

.item__end {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 13px;
  font-weight: 460;
}

.item__face--ink .item__end {
  color: inherit;
}

.item__chev {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the link: each letter is a span, so the reading head can turn it into its monospaced self */
.item__url {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 460;
  letter-spacing: 0.005em;
}

.item--link .item__face {
  gap: 10px;
}

/* the link item looks like a field */
.item--link::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid var(--rule);
  border-radius: 12px;
  pointer-events: none;
}

.ch {
  font-variation-settings: 'MONO' 0;
}

/* Copy and Copied share one cell, so the item does not jump */
.act {
  display: inline-flex;
  align-items: center;
  color: var(--paper);
  font-size: 13.5px;
  font-weight: 560;
}

/* on Embed it is a hint, on the link it is the action */
.item:not(.item--link) .act {
  color: var(--muted);
  font-weight: 480;
}

.item__face--ink .act {
  color: inherit;
}

.act__words {
  display: grid;
  justify-items: end;
}

.act__word {
  grid-area: 1 / 1;
}

.act__word[data-word='done'] {
  opacity: 0;
}


/* ---------------------------------------------------------------- the QR page */
.sheet__page--qr {
  padding: 8px 8px 0;
}

.qr__bar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  height: 44px;
}

.qr__title {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
}

.qr__btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease, transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
}

.qr__btn:active {
  transform: scale(0.94);
}

@media (hover: hover) and (pointer: fine) {
  .qr__btn:hover {
    background: rgba(233, 240, 236, 0.09);
  }
}

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

.qr__btn svg {
  width: 20px;
  height: 20px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the code itself is drawn in the canvas: this only keeps its place (the script sets its size) */
.qr__code {
  width: var(--code, 280px);
  height: var(--code, 280px);
  margin: 4px auto 0;
}

.qr__link {
  margin: 9px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 460;
  letter-spacing: 0.01em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the button */
.trigger {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  width: max-content;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
}

.trigger:active {
  transform: scale(0.97);
}

.trigger:focus-visible {
  outline: none;
}

/* the pill is the child, so the script can move it while the button keeps its press */
.trigger__pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 60px;
  padding: 0 27px 0 23px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(14, 29, 36, 0.22), 0 12px 26px -14px rgba(14, 29, 36, 0.6);
  transition: background-color 0.25s ease;
}

@media (hover: hover) and (pointer: fine) {
  .trigger:hover .trigger__pill {
    background: var(--ink-lift);
  }
}

.trigger[aria-expanded='true'] .trigger__pill {
  background: var(--ink-lift);
}

.trigger:focus-visible .trigger__pill {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

.trigger__icon {
  width: 22px;
  height: 22px;
  flex: none;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trigger__label {
  display: inline-block;
}

@media (prefers-reduced-motion: reduce) {
  .trigger,
  .qr__btn {
    transition: none;
  }

  .trigger:active,
  .qr__btn:active {
    transform: none;
  }
}
