/*
 * The club's universal check-in code: the public scan page, and the admin screen that
 * holds the code up. Built on the design tokens in static/styles.css.
 *
 * Deliberately its own file rather than an inline <style> block, which is what
 * member/check_ins/show.html.erb does and is not a pattern worth spreading.
 */

.qr-page {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--spacing-sm);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: var(--spacing-sm);
}

.qr-club {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin: 0;
}

.qr-run-title {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin: 0;
  text-wrap: balance;
}

.qr-run-meta {
  font-size: 16px;
  line-height: 1.45;
  color: var(--color-text-secondary);
  margin: 0;
}

/* The one bold thing on the page. Everything else stays quiet. */
.qr-primary-btn {
  display: block;
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 18px 24px;
  font-family: var(--font-stack);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--color-black);
  color: var(--color-white);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-speed) ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.qr-primary-btn:hover { background: #333; }
.qr-primary-btn:active { transform: scale(0.985); }
.qr-primary-btn[disabled] { background: var(--color-border); color: var(--color-text-secondary); cursor: not-allowed; }

.qr-secondary-btn {
  display: block;
  width: 100%;
  min-height: 56px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px 24px;
  font-family: var(--font-stack);
  font-size: 16px;
  font-weight: 600;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  text-decoration: none;
  transition: border-color var(--transition-speed) ease;
}

.qr-secondary-btn:hover { border-color: var(--color-text); }

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

.qr-check-in-form { display: flex; flex-direction: column; gap: var(--spacing-sm); }

/* Body text colour, not the site-wide secondary grey for p: this is the question on the screen. */
.qr-pace-prompt {
  font-size: 16px;
  line-height: 1.45;
  color: var(--color-text);
  margin: 0 0 12px;
  text-wrap: balance;
}

.qr-hint {
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text-secondary);
  margin: 0;
}

/* Success carries the tick AND the words -- never colour alone. */
.qr-success {
  background: var(--color-success);
  color: var(--color-white);
  border-radius: var(--radius-md);
  padding: 36px 24px;
}

.qr-success-mark { font-size: 46px; line-height: 1; margin-bottom: 10px; }
.qr-success-text { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }

/* The pace group check-in recorded, and the way to change it. This card is the surface,
   so the shared partial's own panel drops its frame rather than nesting a box in a box. */
.qr-pace {
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  text-align: left;
}

.qr-pace .run-pace-panel {
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
}

.qr-panel {
  background: var(--color-bg-alt);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 28px 22px;
  text-align: left;
}

.qr-panel-mark { font-size: 32px; line-height: 1; margin-bottom: 12px; }
.qr-panel-title { font-size: 17px; font-weight: 700; color: var(--color-text); margin: 0 0 8px; }
.qr-panel-text { font-size: 14px; line-height: 1.55; color: var(--color-text-secondary); margin: 0; }

.qr-next-up {
  border-top: 1px solid var(--color-border);
  margin-top: var(--spacing-sm);
  padding-top: var(--spacing-sm);
  text-align: left;
}

.qr-next-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin: 0 0 6px;
}

.qr-next-run { font-size: 16px; font-weight: 600; color: var(--color-text); margin: 0; }
.qr-next-meta { font-size: 13px; color: var(--color-text-secondary); margin: 4px 0 0; }

.qr-flash {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}

.qr-flash--notice { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.qr-flash--alert { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ---- the code itself ---- */

/*
 * Black on white, hard-coded. A QR code has to be dark-on-light to scan, and the auth
 * layout's ground is off-white (#faf9f7), which is not good enough behind it.
 */
.qr-code-panel {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  line-height: 0;
}

.qr-code-panel svg { display: block; width: 100%; height: auto; }

.qr-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--color-text-secondary);
  word-break: break-all;
  margin: 0;
}

/* ---- present mode: one code, held up, nothing else ---- */

.qr-present {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: var(--spacing-sm);
  background: #ffffff;
  text-align: center;
  overflow: hidden;
}

/*
 * As large as will fit, not as large as the viewport. The run name sits above it and
 * the link and brightness hint below, so sizing purely off vh pushed those off-screen
 * -- which on a held-up phone is exactly the information someone needs when the camera
 * will not focus. The subtraction reserves that space.
 */
.qr-present .qr-code-panel {
  width: min(88vw, calc(100dvh - 210px));
  flex: 0 1 auto;
  min-height: 0;
  border: 0;
  padding: 0;
}

.qr-present-run { font-size: 22px; font-weight: 700; color: #111111; margin: 0; letter-spacing: -0.015em; }
.qr-present-sub { font-size: 15px; color: #555555; margin: 0; }
.qr-present-cta { font-size: 13px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: #111111; margin: 0; }
.qr-present-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #666666; margin: 0; word-break: break-all; }
.qr-present-tip { font-size: 12px; color: #888888; margin: 0; }

.qr-present-exit {
  position: fixed;
  top: 12px;
  right: 12px;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.06);
  color: #111111;
  font-size: 20px;
  text-decoration: none;
}

.qr-present-exit:hover { background: rgba(0, 0, 0, 0.12); }

@media (min-width: 480px) {
  .qr-page { padding: var(--spacing-md); gap: var(--spacing-md); }
  .qr-run-title { font-size: 36px; }
  .qr-run-meta { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .qr-primary-btn, .qr-secondary-btn { transition: none; }
  .qr-primary-btn:active { transform: none; }
}

/* ---- admin: the management page ---- */

.admin-qr-page { max-width: 880px; }
.admin-qr-header h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 8px; color: var(--color-text); }
.admin-qr-header p { font-size: 16px; line-height: 1.55; color: var(--color-text-secondary); margin: 0; max-width: 56ch; }

.admin-qr-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: var(--spacing-md);
  align-items: start;
  margin-top: var(--spacing-md);
}

.admin-qr-side { display: flex; flex-direction: column; gap: var(--spacing-xs); }
.admin-qr-actions { display: flex; flex-wrap: wrap; gap: var(--spacing-xs); align-items: center; margin-top: var(--spacing-xs); }

.admin-qr-btn {
  min-height: 44px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-text);
  background: var(--color-text);
  color: var(--color-white);
  font-family: var(--font-stack);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: opacity var(--transition-speed) ease;
}

.admin-qr-btn:hover { opacity: 0.85; }
.admin-qr-btn--secondary { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.admin-qr-btn--secondary:hover { border-color: var(--color-text); opacity: 1; }
.admin-qr-btn--danger { background: transparent; color: var(--color-danger); border-color: var(--color-danger); }

.admin-qr-copied { font-size: 13px; font-weight: 600; color: var(--color-success); }

.admin-qr-danger {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-sm);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.admin-qr-danger .qr-panel-text { max-width: 56ch; }

@media (max-width: 720px) {
  .admin-qr-grid { grid-template-columns: minmax(0, 1fr); }
}

/*
 * The printed flyer shares this page so there is one QR and one token rather than
 * a second view that could drift from it. Flyer-only elements stay out of the
 * management screen until the sheet is printed.
 */
.qr-flyer-mark,
.qr-flyer-headline,
.qr-flyer-sub,
.qr-flyer-foot,
.qr-flyer-type-label,
.qr-flyer-note { display: none; }

/*
 * Print: one sheet to leave on a table. Wordmark, headline, code, then the URL as
 * a fallback for a camera that won't focus. Sizes are in cm so the sheet comes out
 * the same on A4 and Letter, and the stack measures 900px against a 950px Letter
 * content box -- lengthening the headline or the note will push it to a second page.
 *
 * This stylesheet is also loaded by the public check-in pages, so anything not
 * scoped to .admin-qr-* applies when a runner prints one of those too.
 *
 * Colours are hard-coded rather than themed, for the same reason QrCodeSvg
 * hard-codes black: ink on paper has no theme to inherit from.
 */
@media print {
  @page { margin: 1.4cm; }

  .admin-sidebar,
  .admin-banner,
  .admin-flash,
  .admin-qr-actions,
  .admin-qr-danger,
  .admin-qr-header h1,
  .admin-qr-intro,
  .admin-qr-side .qr-next-label,
  .qr-present-exit,
  .qr-present-tip { display: none !important; }

  .qr-flyer-mark,
  .qr-flyer-headline,
  .qr-flyer-sub,
  .qr-flyer-foot,
  .qr-flyer-type-label,
  .qr-flyer-note { display: block; }

  .admin-layout, .admin-content { display: block !important; margin: 0 !important; padding: 0 !important; }
  .admin-qr-page { max-width: none; }
  .admin-qr-grid { display: block; margin: 0; }
  .admin-qr-code { width: 100%; }

  .admin-qr-header { text-align: center; }
  .qr-flyer-mark { width: 9cm; max-width: 100%; height: auto; margin: 0 auto 0.8cm; }
  /* Both of these are <p> inside .admin-qr-header, which carries its own
     screen type rule. Qualify them or the flyer headline prints at body size. */
  .admin-qr-header .qr-flyer-headline {
    font-size: 34pt;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin: 0;
    max-width: none;
    color: #111;
  }
  .admin-qr-header .qr-flyer-sub {
    font-size: 15pt;
    line-height: 1.35;
    margin: 0.3cm auto 0.7cm;
    max-width: none;
    color: #111;
  }

  .qr-code-panel { border: 0; padding: 0; width: 10.5cm; max-width: 100%; margin: 0 auto; }

  /* The side column stays a flex column in print, so its gap would stack on top of
     these margins. Zero it and let the margins alone set the rhythm. */
  .admin-qr-side { align-items: center; text-align: center; gap: 0; }
  .qr-flyer-foot { font-size: 15pt; font-weight: 600; margin: 0.7cm 0 0; color: #111; }
  .qr-flyer-type-label { font-size: 9.5pt; margin: 0.7cm 0 0.1cm; color: #111; }
  .qr-url { text-align: center; font-size: 11pt; margin: 0; color: #111; }
  .qr-flyer-note { font-size: 9pt; line-height: 1.4; margin: 0.5cm 0 0; color: #111; }
}
