/* Kept in the DOM at all times (rather than display:none) so both opening and closing can
   transition; visibility is delayed by the same duration so the closed dialog stops
   catching clicks only after the sheet has finished sliding back down. */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: oklch(0 0 0 / 0.45);
  font-family: 'Helvetica Neue', Arial, sans-serif;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

.dialog.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease, visibility 0s;
}

/* iOS-style sheet: stops just short of the top edge so the dimmed page stays visible
   behind it, and eases up from below the viewport on open. */
.dialog-sheet {
  box-sizing: border-box;
  width: 100%;
  height: calc(100% - clamp(24px, 6vh, 48px));
  display: flex;
  flex-direction: column;
  background: oklch(0.98 0.003 40);
  border-radius: 14px 14px 0 0;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Only above 768px is the viewport the centered column (see main.css); below it the sheet
   spans the whole screen, however wide the phone is. */
@media (min-width: 768px) {
  .dialog-sheet {
    max-width: var(--viewport-width);
    margin: 0 auto;
  }
}

.dialog.open .dialog-sheet {
  transform: translateY(0);
}

/* Never scrolls: it takes all the room left under the grip and never shrinks below what it
   holds, so the content is centred in that room whether a step is short or tall. The bottom
   padding mirrors the grip's height so the content ends up centred in the sheet as a whole
   rather than only in the space below the grip. */
.dialog-body {
  flex: 1 0 auto;
  width: 100%;
  box-sizing: border-box;
  padding: 0 clamp(24px, 7vw, 56px) clamp(72px, 12vh, 120px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

/* The drag-to-dismiss area. Deliberately larger than the handle bar itself so the grab
   target is comfortable, and it owns the gesture (touch-action: none). It is also the last
   slack in the sheet: content taller than the rest shrinks it rather than causing a scroll. */
.dialog-grip {
  flex: 0 1 clamp(72px, 12vh, 120px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 44px;
  padding-top: 10px;
  box-sizing: border-box;
  cursor: grab;
  touch-action: none;
}

.dialog-grip:active {
  cursor: grabbing;
}

.dialog-handle {
  width: 64px;
  height: 5px;
  border-radius: 3px;
  background: oklch(0.14 0.006 40 / 0.2);
}

/* Base building blocks for whatever a feature renders inside the sheet, so each scenario
   only has to supply its own text and buttons rather than its own styling. */
.dialog-title {
  color: oklch(0.14 0.006 40);
  font-size: clamp(24px, 6vh, 32px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  margin-bottom: clamp(10px, 2.4vh, 18px);
}

.dialog-text {
  margin: 0 0 10px;
  color: oklch(0.4 0.006 40);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.dialog-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: clamp(12px, 3vh, 20px);
}

.dialog-input {
  width: 100%;
  box-sizing: border-box;
  padding: clamp(12px, 3vh, 16px) 14px;
  border: none;
  border-bottom: 3px solid oklch(0.14 0.006 40 / 0.15);
  border-radius: 0;
  background: oklch(0.14 0.006 40 / 0.04);
  color: oklch(0.14 0.006 40);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  outline: none;
}

.dialog-input:focus {
  border-bottom-color: oklch(0.63 0.22 25);
}

.dialog-input::placeholder {
  color: oklch(0.55 0.006 40);
  font-weight: 600;
}

.dialog-input-code {
  text-align: center;
  letter-spacing: 0.4em;
  font-size: clamp(20px, 5vh, 26px);
  font-weight: 800;
}

/* Holds its height while hidden so showing a message doesn't shift the buttons below. */
.dialog-error {
  min-height: 16px;
  margin-top: 8px;
  color: oklch(0.63 0.22 25);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0;
}

.dialog-error.visible {
  opacity: 1;
}

/* The QR code is drawn at a fixed pixel size by the encoder, so it is scaled down here to
   whatever room the sheet has left rather than dictating the height of the step. */
.dialog-qr {
  align-self: center;
  width: clamp(104px, 22vh, 180px);
  margin-top: clamp(8px, 1.6vh, 12px);
  padding: 8px;
  background: oklch(1 0 0);
  line-height: 0;
}

.dialog-qr canvas,
.dialog-qr img {
  width: 100% !important;
  height: auto !important;
}

/* A value nobody should be retyping by hand: the whole row is the copy button, and it says
   so once it has been tapped. */
.dialog-copy {
  width: 100%;
  box-sizing: border-box;
  margin-top: clamp(8px, 1.6vh, 12px);
  padding: 10px 12px;
  border: none;
  border-bottom: 3px solid oklch(0.14 0.006 40 / 0.15);
  background: oklch(0.14 0.006 40 / 0.04);
  color: oklch(0.14 0.006 40);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.dialog-copy.copied {
  border-bottom-color: oklch(0.63 0.22 25);
}

.dialog-copy-amount {
  font-size: clamp(18px, 4.4vh, 24px);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.dialog-copy-address {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
  word-break: break-all;
}

.dialog-status {
  margin-top: clamp(8px, 1.6vh, 12px);
  color: oklch(0.4 0.006 40);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* The small print a step cannot do without: what goes wrong if the amount is off, and who to
   write to when it does. */
.dialog-note {
  margin: clamp(8px, 1.6vh, 12px) 0 0;
  color: oklch(0.5 0.006 40);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.dialog-note a {
  color: oklch(0.4 0.006 40);
  text-underline-offset: 2px;
}

.dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: clamp(16px, 4vh, 28px);
}

.dialog-btn {
  width: 100%;
  padding: clamp(12px, 3vh, 18px);
  border: none;
  font-family: inherit;
  font-size: clamp(15px, 3.6vh, 18px);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-sizing: border-box;
}

.dialog-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.dialog-btn-primary {
  background: oklch(0.63 0.22 25);
  color: oklch(0.98 0.003 40);
}

.dialog-btn-secondary {
  background: oklch(0.14 0.006 40 / 0.08);
  color: oklch(0.3 0.006 40);
}

.dialog-link {
  align-self: center;
  /* Mirrors the gap the buttons keep from the text above them: .dialog-text's bottom margin
     plus .dialog-actions' top margin. */
  margin-top: calc(10px + clamp(16px, 4vh, 28px));
  color: oklch(0.4 0.006 40);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  text-underline-offset: 3px;
}
