/* Reset + base */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
  /* Kiosk/event context: prevent accidental text selection, callouts and
     double-tap zoom while someone is tapping quickly through the flow. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Inputs are the one place people DO need to select/copy text */
input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

h1, h2, h3, p, figure {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

input {
  font: inherit;
  color: inherit;
}

/* Visible only to assistive tech */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

button:focus:not(:focus-visible) {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* App shell: every screen is a full-height stage; the state machine toggles
   which one is visible. Kept as siblings (not removed from the DOM) so
   transitions can animate in/out. */
#app {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--color-bg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  /* #app's only in-flow-relevant children are position:absolute .screen
     elements, so as a flex item (see the >=640px body rule below) it has
     no intrinsic content to size itself from. Without an explicit width
     it collapses to 0 instead of filling max-width. */
  flex-shrink: 0;
}

/* On real desktop widths, frame the phone-shaped experience so it still
   reads as an intentional kiosk/phone product rather than a stretched page. */
@media (min-width: 640px) {
  body {
    background: var(--gray-900);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 0;
  }

  #app {
    min-height: min(860px, 100dvh);
    height: min(860px, 100dvh);
    border-radius: var(--radius-lg);
  }
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  z-index: 1;
  /* Inactive screens must clip their own content. Without this, a screen
     taller than the viewport (e.g. the result screen's full content)
     still contributes its full height to #app's scrollable area even
     while hidden, which lets #app itself pick up a stray scrollTop that
     then offsets every screen until something resets it. */
  overflow: hidden;
}

.screen.is-active {
  visibility: visible;
  pointer-events: auto;
  opacity: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  z-index: 2;
}

/* the incoming screen stacks above the outgoing one during the crossfade */
.screen.is-entering {
  z-index: 3;
}

@media (min-width: 640px) {
  .screen.is-active {
    border-radius: var(--radius-lg);
  }
}
