/* The signature pad: a sheet of paper on a black page, blue-black ink and a red stamp. */
:root {
  --page: #000000;          /* the page */
  --paper: #f6f2e9;         /* the sheet */
  --paper-edge: #e4ddcd;
  --ink: #1b2560;           /* dry ink */
  --wet: #2f4de0;           /* wet ink */
  --text: #24211c;
  --muted: #8a8478;
  --stamp: #c63a2b;
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--text);
  font-family: 'Literata Variable', Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

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

.sign {
  width: min(480px, 100%);
  padding: 26px 24px 24px;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 30px 60px -30px rgba(255, 255, 255, 0.08);
}

.sign__title {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.sign__note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14.5px;
  font-style: italic;
}

/* ---------------------------------------------------------------- the tabs */
.sign__tabs {
  position: relative;
  display: inline-flex;
  gap: 4px;
  margin-top: 18px;
  padding: 4px;
  border-radius: 12px;
  background: #ebe5d7;
}

.tab {
  position: relative;
  z-index: 1;
  padding: 7px 16px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #6f685b;
  font: 600 14px 'Literata Variable', Georgia, serif;
  cursor: pointer;
  transition: color 0.25s;
  -webkit-tap-highlight-color: transparent;
}

.tab[aria-selected='true'] {
  color: var(--text);
}

/* the white mark under the tab chosen, moved by the script */
.tab__mark {
  position: absolute;
  top: 4px;
  left: 0;
  height: calc(100% - 8px);
  border-radius: 9px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(40, 32, 18, 0.15);
}

/* ---------------------------------------------------------------- the pad */
.pad {
  position: relative;
  height: 200px;
  margin-top: 12px;
  border: 1px solid var(--paper-edge);
  border-radius: 16px;
  background: #fffdf8;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

@media (hover: hover) and (pointer: fine) {
  .pad.is-drawing {
    cursor: none;
  }
}

.pad__ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pad__line {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 48px;
  border-top: 1.5px dashed #d8cfbb;
  pointer-events: none;
}

.pad__cross {
  position: absolute;
  left: 22px;
  bottom: 56px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: #b9ae97;
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.pad__hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  color: #a79c86;
  font-size: 14px;
  font-style: italic;
  text-align: center;
  pointer-events: none;
}

/* the name typed, written by hand */
.pad__typed {
  position: absolute;
  left: 46px;
  right: 22px;
  bottom: 44px;
  margin: 0;
  color: var(--ink);
  font: 600 50px/1 'Caveat Variable', cursive;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
}

.pad__typed span {
  display: inline-block;
  white-space: pre;
}

.pad__stamp {
  position: absolute;
  right: 26px;
  top: 22px;
  display: grid;
  justify-items: center;
  padding: 6px 14px 7px;
  border: 3px solid var(--stamp);
  border-radius: 10px;
  color: var(--stamp);
  font: 800 22px/1 'Literata Variable', Georgia, serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
}

.pad__stamp small {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
}

/* the nib that follows the mouse over the pad */
.pad__nib {
  position: absolute;
  top: 0;
  left: 0;
  width: 34px;
  height: 34px;
  margin: -34px 0 0 -17px;
  fill: #2a2a2e;
  stroke: #fffdf8;
  stroke-width: 1.4;
  stroke-linejoin: round;
  opacity: 0;
  pointer-events: none;
  transform-origin: 50% 100%;
}

.pad__nib path + path {
  fill: none;
}

/* ---------------------------------------------------------------- typing, and the buttons */
.sign__type {
  display: block;
  margin-top: 12px;
}

.sign__type[hidden] {
  display: none;
}

.sign__input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--paper-edge);
  border-radius: 12px;
  background: #fffdf8;
  color: var(--text);
  font: 16px 'Literata Variable', Georgia, serif;
  outline: none;
  transition: border-color 0.2s;
}

.sign__input:focus {
  border-color: var(--wet);
}

.sign__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.btn {
  padding: 10px 16px;
  border: 0;
  border-radius: 11px;
  background: #ebe5d7;
  color: var(--text);
  font: 600 14.5px 'Literata Variable', Georgia, serif;
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
  -webkit-tap-highlight-color: transparent;
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

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

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

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

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