/*
 * 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-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; }

.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); }
}

/*
 * Print: just the code and the link. Everything that is screen furniture goes, and the
 * code scales up to fill the page so it still scans from across a table.
 */
@media print {
  .admin-sidebar,
  .admin-banner,
  .admin-flash,
  .admin-qr-actions,
  .admin-qr-danger,
  .admin-qr-header p,
  .qr-present-exit,
  .qr-present-tip { display: none !important; }

  .admin-layout, .admin-content { display: block !important; margin: 0 !important; padding: 0 !important; }
  .admin-qr-page { max-width: none; }
  .admin-qr-grid { display: block; }
  .admin-qr-code { width: 100%; }
  .qr-code-panel { border: 0; padding: 0; width: 15cm; max-width: 100%; margin: 0 auto; }
  .admin-qr-header h1 { text-align: center; font-size: 22pt; }
  .qr-url, .admin-qr-side .qr-next-label { text-align: center; }
  .admin-qr-side { align-items: center; }
}
