/* The drafted share dialog: a graphite Share button on a white page, and the share dialog of an architecture
   studio's project drawn on white paper: graphite ink, blue construction lines, and a material hatch for every
   collaborator. The lines, the outline and the paper are moved by script.js. */
:root {
  --page: #ffffff;          /* the page */
  --paper: #ffffff;         /* the dialog's paper */
  --ink: #1d2126;           /* graphite: words, the inked outline, the Share and Invite buttons */
  --ink-hover: #353b43;     /* those buttons under the pointer */
  --muted: #59616b;         /* second lines and notes */
  --rule: #4b9cd6;          /* the blue construction lines, as a non-photo blue pencil */
  --field: #ccd2d8;         /* the edge of a field */
  --field-hover: #96a0aa;   /* a field under the pointer */
  --wash: #f2f4f6;          /* a quiet button or a row under the pointer */
  --wash-strong: #e6e9ed;   /* Invite while there is nothing to send */
  --error: #b23f2b;         /* an address that is not right */
  --veil: #161b21;          /* the colour the page darkens to behind the dialog */
  --brick: #d0915f;         /* the hatches of the collaborators' squares: masonry */
  --brick-bg: #fcf4ec;
  --steel: #7aa5c8;         /* steel */
  --steel-bg: #f0f5fa;
  --timber: #8bb184;        /* timber */
  --timber-bg: #f1f7ef;
  --glass: #a988bd;         /* glass */
  --glass-bg: #f8f2fb;
}

* {
  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: 'Jost Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

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

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- the Share button */
.slot {
  position: relative;
  display: inline-grid;
  isolation: isolate;
}

.opener {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 26px 0 22px;
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: #ffffff;
  font: 500 17px/1 'Jost Variable', system-ui, sans-serif;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
  -webkit-tap-highlight-color: transparent;
}

.opener__icon {
  width: 22px;
  height: 22px;
  stroke-width: 1.7;
}

.opener:active {
  transform: scale(0.97);
  transition-duration: 0.08s;
}

/* under the pointer the corners grow their construction lines, as the dialog will */
.slot__ticks {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  pointer-events: none;
  background:
    linear-gradient(var(--rule), var(--rule)) 0 12px / 12px 1px,
    linear-gradient(var(--rule), var(--rule)) 100% 12px / 12px 1px,
    linear-gradient(var(--rule), var(--rule)) 0 calc(100% - 12px) / 12px 1px,
    linear-gradient(var(--rule), var(--rule)) 100% calc(100% - 12px) / 12px 1px,
    linear-gradient(var(--rule), var(--rule)) 12px 0 / 1px 12px,
    linear-gradient(var(--rule), var(--rule)) calc(100% - 12px) 0 / 1px 12px,
    linear-gradient(var(--rule), var(--rule)) 12px 100% / 1px 12px,
    linear-gradient(var(--rule), var(--rule)) calc(100% - 12px) 100% / 1px 12px;
  background-repeat: no-repeat;
  transition: inset 0.4s cubic-bezier(0.3, 1.5, 0.5, 1), opacity 0.2s ease;
}

@media (hover: hover) {
  .opener:hover {
    background: var(--ink-hover);
  }

  .opener:hover + .slot__ticks {
    inset: -12px;
    opacity: 1;
  }
}

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

/* the focus goes back to Share by script after a click too: its ring shows only to who uses the keys */
html[data-using='pointer'] .opener:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- the dialog: the whole screen, see-through */
.share {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: clip;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.share[open] {
  display: grid;
  align-items: start;
  justify-items: center;
}

.share::backdrop {
  background: transparent;
}

.share:focus {
  outline: none;
}

.share__veil {
  position: absolute;
  inset: 0;
  background: transparent;
}

/* the sheet: its top is set by the script when it opens, so it grows downwards when someone is added */
.frame {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(440px, calc(100% - 32px));
  margin-top: 16px;
}

.frame__shade {
  position: absolute;
  inset: 0;
  box-shadow: 0 34px 64px -34px rgba(16, 22, 30, 0.5), 0 4px 16px -8px rgba(16, 22, 30, 0.14);
}

/* the paper fills in as a hatch whose lines thicken until they meet (--fill, from 0 to 1, moved by the script) */
.frame__paper {
  --fill: 1;
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, var(--paper) 0 calc(var(--fill) * 10px), transparent 0 10px);
}

.frame__paper.is-solid {
  background: var(--paper);
}

.frame__body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 24px;
  overflow: hidden auto;
  overscroll-behavior: contain;
  outline: none;
}

/* the drafting: the construction lines and the inked outline, over everything, never in the way */
.draft {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.draft .b,
.avatar__draft .b {
  stroke: var(--rule);
  stroke-width: 1;
  stroke-linecap: butt;
}

.draft .i {
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: butt;
}

.avatar__draft .i {
  stroke: var(--ink);
  stroke-width: 1;
  stroke-linecap: butt;
}

/* ---------------------------------------------------------------- the head */
.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.head__text {
  min-width: 0;
}

.head__title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 26px;
  letter-spacing: -0.005em;
}

.head__sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.close {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  margin: -8px -8px 0 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1);
  -webkit-tap-highlight-color: transparent;
}

.close svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.8;
}

.close:active {
  transform: scale(0.92);
}

/* ---------------------------------------------------------------- fields and buttons */
.label {
  display: block;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  letter-spacing: 0.01em;
}

.field {
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--field);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font: 400 15px/1.2 'Jost Variable', system-ui, sans-serif;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field::placeholder {
  color: #69717b;
  opacity: 1;
}

.field:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.field[aria-invalid='true'] {
  border-color: var(--error);
}

.field[aria-invalid='true']:focus {
  box-shadow: 0 0 0 1px var(--error);
}

.select {
  position: relative;
  display: block;
}

.select select {
  padding-right: 34px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.select svg {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  stroke-width: 1.8;
  pointer-events: none;
}

/* the permission of someone already in: plain words until the pointer or the focus comes */
.select--quiet select {
  height: 40px;
  padding: 0 30px 0 10px;
  border-color: transparent;
  background: transparent;
  font-size: 14px;
}

.select--quiet svg {
  right: 8px;
  width: 16px;
  height: 16px;
  margin-top: -8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 6px;
  font: 500 15px/1 'Jost Variable', system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1);
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: scale(0.96);
}

.btn--ink {
  background: var(--ink);
  color: #ffffff;
}

.btn--ink:disabled {
  background: var(--wash-strong);
  color: #7f8892;
  cursor: not-allowed;
}

.btn--line {
  background: #ffffff;
  box-shadow: inset 0 0 0 1px var(--field);
  color: var(--ink);
}

.btn--line.is-copied {
  box-shadow: inset 0 0 0 1px var(--ink);
}

@media (hover: hover) {
  .field:hover:not(:focus) {
    border-color: var(--field-hover);
  }

  .field[aria-invalid='true']:hover:not(:focus) {
    border-color: var(--error);
  }

  .select--quiet select:hover:not(:focus) {
    border-color: var(--field);
    background: #ffffff;
  }

  .btn--ink:hover:not(:disabled) {
    background: var(--ink-hover);
  }

  .btn--line:hover,
  .close:hover {
    background: var(--wash);
  }
}

.btn:focus-visible,
.close:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

html[data-using='pointer'] .btn:focus-visible,
html[data-using='pointer'] .close:focus-visible {
  outline: none;
}

.note {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}

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

/* ---------------------------------------------------------------- inviting */
.invite {
  margin: 20px 0 0;
}

.invite__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px auto;
  gap: 8px;
}

/* ---------------------------------------------------------------- the people */
.people {
  margin-top: 18px;
}

.people__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.person {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 120px;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 0;
  isolation: isolate;
}

/* behind the row: lights up when someone already in is invited again (--glow, moved by the script) */
.person::before {
  content: '';
  position: absolute;
  inset: 2px -8px;
  z-index: -1;
  border-radius: 6px;
  background: #e8f1f9;
  opacity: var(--glow, 0);
}

.person__text {
  display: grid;
  min-width: 0;
}

.person__name,
.person__mail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person__name {
  font-size: 15px;
  font-weight: 500;
  line-height: 20px;
}

.person__mail {
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}

.person__owner {
  padding-left: 11px;
  color: var(--muted);
  font-size: 14px;
}

/* every collaborator is a square of drafting paper with a material hatched into it */
.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
}

.avatar__fill {
  position: absolute;
  inset: 0;
  clip-path: polygon(0% 0%, 200% 0%, 0% 200%);
}

.avatar__ini {
  position: relative;
  padding: 2px 3px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 600;
  line-height: 14px;
  letter-spacing: 0.04em;
}

.avatar__draft {
  position: absolute;
  top: -12px;
  left: -12px;
  width: 64px;
  height: 64px;
  overflow: visible;
  pointer-events: none;
}

.mat-brick .avatar__fill {
  background: repeating-linear-gradient(45deg, var(--brick) 0 1.2px, transparent 1.2px 6px), var(--brick-bg);
}

.mat-steel .avatar__fill {
  background:
    repeating-linear-gradient(45deg, var(--steel) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(-45deg, var(--steel) 0 1px, transparent 1px 7px),
    var(--steel-bg);
}

.mat-timber .avatar__fill {
  background: repeating-linear-gradient(0deg, var(--timber) 0 1px, transparent 1px 5px), var(--timber-bg);
}

.mat-glass .avatar__fill {
  background: repeating-linear-gradient(90deg, var(--glass) 0 1px, transparent 1px 4px, var(--glass) 4px 5px, transparent 5px 12px), var(--glass-bg);
}

/* ---------------------------------------------------------------- the link */
.link {
  margin-top: 16px;
}

.link__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.link__url {
  background: #f7f8f9;
  text-overflow: ellipsis;
}

.link__copy {
  min-width: 128px;
}

.link__icons {
  position: relative;
  width: 18px;
  height: 18px;
}

.link__icons svg {
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.link__tick {
  opacity: 0;
  stroke-width: 2.1;
}

.link__foot {
  position: relative;
  height: 26px;
}

/* the dimension line drawn under the link once it is copied */
.dim {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 26px;
  overflow: visible;
  pointer-events: none;
}

.dim line {
  stroke: var(--ink);
  stroke-width: 1;
  stroke-linecap: butt;
}

.dim .dim__tick {
  stroke-width: 1.6;
}

.dim text {
  fill: var(--ink);
  stroke: none;
  font: 500 12px 'Jost Variable', system-ui, sans-serif;
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- less movement */
@media (prefers-reduced-motion: reduce) {
  .slot__ticks {
    inset: -12px;
    transition: opacity 0.2s ease;
  }

  .opener:active,
  .btn:active:not(:disabled),
  .close:active {
    transform: none;
  }
}

/* ---------------------------------------------------------------- the phone */
@media (max-width: 480px) {
  .frame__body {
    padding: 20px;
  }

  .head__title {
    font-size: 19px;
  }

  .close {
    width: 44px;
    height: 44px;
    margin: -10px -10px 0 0;
  }

  /* the address on a line of its own, the permission and Invite under it */
  .invite__row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .invite__email {
    grid-column: 1 / -1;
  }

  .invite__send {
    min-width: 104px;
  }

  /* 16 pixels: Safari on iPhone does not zoom into a field it can read */
  .field,
  .select--quiet select {
    font-size: 16px;
  }

  .select--quiet select {
    height: 44px;
  }

  /* the names get the room: the permission column narrows */
  .person {
    grid-template-columns: 40px minmax(0, 1fr) 108px;
  }

  /* the whole link shows: Copy keeps only its icon, and its words for screen readers */
  .link__copy {
    width: 48px;
    min-width: 0;
    padding: 0;
  }

  .link__copy [data-copy-label] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* a finger: 16 pixels, so Safari on iPhone does not zoom into the field, phone held sideways too */
@media (pointer: coarse) {
  .field,
  .select--quiet select {
    font-size: 16px;
  }
}
