/* Ticket check: single light theme, mobile-first. */

:root {
  --color-bg: #F3F4F6;
  --color-surface: #FFFFFF;
  --color-text: #111827;
  --color-text-muted: #4B5563;
  --color-border: #D1D5DB;
  --color-focus: #1D4ED8;

  --color-valid-bg: #0B5D1E;
  --color-valid-fg: #FFFFFF;
  --color-invalid-bg: #9B1C1C;
  --color-invalid-fg: #FFFFFF;
  --color-pending-bg: #FFD54A;
  --color-pending-fg: #000000;
  --color-neutral-bg: #374151;
  --color-neutral-fg: #FFFFFF;

  --color-primary-bg: #1F2937;
  --color-primary-fg: #FFFFFF;
  --color-progress: #4B5563;

  --radius: 12px;
  --gap: 16px;
  --max-width: 480px;
  --touch-min: 56px;
  --touch-small: 52px;
  --row-padding-y: 8px;
  --banner-padding-y: 16px;
  --banner-margin-y: 10px;                     /* extra space above/below the status banner */
  --logo-height: clamp(2.25rem, 1.8rem + 2vw, 2.75rem); /* 36-44px */

  --font-base: 1.125rem;                       /* 18px */
  --font-value: clamp(1.25rem, 1.1rem + 0.8vw, 1.375rem); /* 20-22px */
  --font-banner: 1.75rem;                      /* 28px */
  --font-button-small: 1rem;                   /* 16px */

  color-scheme: light;
}

/*
 * Fallback for browsers without svh support: compact layout for short
 * viewports, so that status, all fields and all buttons fit without
 * scrolling on 360x640 phones (visible height incl. browser bars ~520px).
 */
@media (max-height: 740px) {
  :root {
    --gap: 10px;
    --touch-min: 48px;
    --touch-small: 44px;
    --row-padding-y: 5px;
    --banner-padding-y: 10px;
    --banner-margin-y: 4px;
    --logo-height: 2rem;                       /* 32px */
    --font-base: 1rem;                         /* 16px */
    --font-value: 1.125rem;                    /* 18px */
    --font-banner: 1.375rem;                   /* 22px */
    --font-button-small: 0.9375rem;            /* 15px */
  }
}

/*
 * Continuous scaling with the small viewport height (svh = visible height with
 * browser UI shown). The page never scrolls, so browser bars stay visible and
 * the small viewport is the one actually seen.
 * Each token interpolates linearly from the compact value at 520px height to
 * the standard value at 800px height and is clamped outside that range:
 *   value(h) = v520 + (h - 520) * (v800 - v520) / 280
 * Overrides the step values above in browsers that support svh
 * (Chrome/Edge 108, Firefox 101, Safari 15.4).
 */
@supports (height: 1svh) {
  :root {
    --gap: clamp(10px, 2.143svh - 1.14px, 16px);
    --touch-min: clamp(48px, 2.857svh + 33.14px, 56px);
    --touch-small: clamp(44px, 2.857svh + 29.14px, 52px);
    --row-padding-y: clamp(5px, 1.071svh - 0.57px, 8px);
    --banner-padding-y: clamp(10px, 2.143svh - 1.14px, 16px);
    --banner-margin-y: clamp(4px, 2.143svh - 7.14px, 10px);
    --logo-height: clamp(2rem, 4.286svh + 9.71px, 2.75rem);           /* 32-44px */
    --font-base: clamp(1rem, 0.714svh + 12.29px, 1.125rem);          /* 16-18px */
    --font-value: clamp(1.125rem, 1.429svh + 10.57px, 1.375rem);     /* 18-22px */
    --font-banner: clamp(1.375rem, 2.143svh + 10.86px, 1.75rem);     /* 22-28px */
    --font-button-small: clamp(0.9375rem, 0.357svh + 13.14px, 1rem); /* 15-16px */
  }
}

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

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--font-base);
  line-height: 1.4;
}

[hidden] {
  display: none !important;
}

.app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--gap);
  padding-top: max(var(--gap), env(safe-area-inset-top));
  padding-bottom: max(var(--gap), env(safe-area-inset-bottom));
  min-height: 100vh;                           /* fallback without svh support */
  min-height: 100svh;
}

/* Header with brand logo */

.app-header {
  display: flex;
  align-items: center;
  margin-bottom: var(--gap);
}

.logo {
  display: block;
  width: auto;
  height: var(--logo-height);
  max-width: 100%;
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* Status banner */

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-block: var(--banner-margin-y);
  padding: var(--banner-padding-y) var(--gap);
  border-radius: var(--radius);
  font-size: var(--font-banner);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.banner-icon {
  flex: 0 0 auto;
  width: 1.3em;
  height: 1.3em;
}

.banner-valid { background: var(--color-valid-bg); color: var(--color-valid-fg); }
.banner-invalid { background: var(--color-invalid-bg); color: var(--color-invalid-fg); }
.banner-pending { background: var(--color-pending-bg); color: var(--color-pending-fg); }
.banner-neutral { background: var(--color-neutral-bg); color: var(--color-neutral-fg); }

/* Card details */

.details {
  margin: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.row {
  display: grid;
  grid-template-columns: minmax(7.5rem, 40%) 1fr;
  gap: 12px;
  align-items: baseline;
  padding: var(--row-padding-y) var(--gap);
}

.row + .row {
  border-top: 1px solid var(--color-border);
}

.row dt {
  color: var(--color-text-muted);
}

.row dd {
  margin: 0;
  font-size: var(--font-value);
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Buttons */

.actions {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* "Details" and "+30 Sec" side by side */
.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}

.btn-small {
  min-height: var(--touch-small);
  padding: 8px 12px;
  font-size: var(--font-button-small);
}

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

.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: var(--touch-min);
  padding: 12px var(--gap);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
}

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

.btn-primary {
  background: var(--color-primary-bg);
  color: var(--color-primary-fg);
  border: 2px solid var(--color-primary-bg);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 2px solid var(--color-text);
}

/* Progress bar behind the close button label; width set via transform from app.js. */
.btn-progress .progress {
  position: absolute;
  inset: 0;
  background: var(--color-progress);
  transform-origin: left center;
  transform: scaleX(1);
  pointer-events: none;
}

.btn-label,
.btn-remaining {
  position: relative;
}

.btn-remaining {
  font-variant-numeric: tabular-nums;
  min-width: 3.5ch;
  text-align: right;
}

/* Messages */

.title {
  margin: 0;
  font-size: var(--font-banner);
}

.message {
  margin: 0;
  font-size: var(--font-value);
}

.message-large {
  font-size: var(--font-banner);
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .btn-progress .progress {
    transition: none;
  }
}
