/* REWExit PWA — looks and behaves like the original Android app. */

:root {
  --red: #cc0000;
  --red-dark: #a30000;
  --wheel-item-h: 52px;
  --appbar-h: 56px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--red);
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--red);
}

/* ---- Action bar ------------------------------------------------ */

.appbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  height: calc(var(--appbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  background: var(--red);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  z-index: 10;
}

.appbar__title {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  color: #fff;
}

/* ---- Stage ----------------------------------------------------- */

.stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
}

/* ---- Barcode --------------------------------------------------- */

.barcode-frame {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - 24px);
  max-width: 720px;
  margin: 16px auto 0;
  padding: 22px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

#barcode {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---- Controls (hidden until 3x double tap) --------------------- */

.controls {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.7s ease, visibility 0s linear 0.7s;
}

.controls.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.7s ease, visibility 0s;
}

.controls__label {
  font-size: 18px;
  color: #fff;
}

/* Wheel number picker (mimics Android NumberPicker) */

.wheel {
  position: relative;
  width: 132px;
  height: calc(var(--wheel-item-h) * 3);
  background: #fff;
  border-radius: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  scrollbar-width: none;
}

.wheel::-webkit-scrollbar {
  display: none;
}

.wheel:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.wheel__track {
  display: block;
}

.wheel__item,
.wheel__spacer {
  height: var(--wheel-item-h);
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: center;
}

.wheel__item {
  font-size: 28px;
  color: #9a9a9a;
  transition: color 0.15s ease, transform 0.15s ease;
}

.wheel__item.is-selected {
  color: #000;
  font-weight: 700;
  transform: scale(1.15);
}

/* Highlight band in the middle + fade at the edges */

.wheel::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: var(--wheel-item-h);
  transform: translateY(-50%);
  border-top: 2px solid var(--red);
  border-bottom: 2px solid var(--red);
  background: rgba(204, 0, 0, 0.05);
  pointer-events: none;
  z-index: 2;
}

.wheel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    #fff 0%,
    rgba(255, 255, 255, 0) 32%,
    rgba(255, 255, 255, 0) 68%,
    #fff 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* Refresh button */

.refresh {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #000;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.refresh svg {
  width: 42px;
  height: 42px;
}

.refresh:active {
  transform: scale(0.93);
  background: #f2f2f2;
}

.refresh:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

/* ---- Landscape / very short screens ---------------------------- */

@media (orientation: landscape) and (max-height: 520px) {
  .barcode-frame {
    margin-top: 8px;
    padding: 12px;
  }

  .controls {
    gap: 12px;
  }

  :root {
    --wheel-item-h: 40px;
  }

  .refresh {
    width: 64px;
    height: 64px;
  }

  .refresh svg {
    width: 32px;
    height: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .controls,
  .wheel__item,
  .refresh {
    transition: none;
  }
}
