/* CardColl
 *
 * A dark interface, because the thing it exists to do is show a barcode in a
 * shop queue and a dark shell makes the white code panel the brightest thing
 * on the screen -- which is exactly what a scanner wants.
 *
 * No framework. The old build pulled Tailwind from a CDN at runtime, which
 * meant a third party learned every visit and the app could not work offline.
 */

/* ----------------------------------------------------------------- tokens */
:root {
  --bg: #0b1220;
  --surface: #131c2b;
  --surface-2: #1b2637;
  --surface-3: #22304400;
  --border: #26344a;
  --border-soft: #1e2a3c;

  --text: #e7eef8;
  --muted: #8ba0bb;
  --faint: #5b6d86;

  --teal: #0fb6a4;
  --teal-bright: #2ad4c0;
  --teal-dim: #0a7d72;
  --coral: #ff7a59;
  --danger: #f2555a;

  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 10px 30px rgb(0 0 0 / 45%);
  --shadow-soft: 0 2px 8px rgb(0 0 0 / 25%);

  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* A wallet is a thing you tap, not a thing you select. Text inside the code
   panel stays selectable, because copying the number by hand is sometimes the
   only thing that works at a broken till. */
body {
  -webkit-user-select: none;
  user-select: none;
}

.code-number,
input,
textarea {
  -webkit-user-select: text;
  user-select: text;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: var(--teal-bright);
}

:focus-visible {
  outline: 2px solid var(--teal-bright);
  outline-offset: 2px;
  border-radius: 6px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.centre {
  text-align: center;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ views */
.view-centre {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------------------------------------------------------- sign-in */
.login {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-mark {
  width: 132px;
  height: 132px;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgb(15 182 164 / 22%));
}

.login-title {
  margin: 12px 0 4px;
  font-size: 34px;
  letter-spacing: -0.02em;
}

.login-tagline {
  margin: 0 0 28px;
  color: var(--muted);
}

.login-note {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--faint);
}

.login-points {
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
  font-size: 14px;
  color: var(--muted);
}

.login-points li {
  position: relative;
  padding: 6px 0 6px 24px;
}

.login-points li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 14px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
}

/* The Vrse button is specified by Vrse and copied verbatim: one wording, one
   look, whichever site you are on. Only the width is ours. */
.vrse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: 10px;
  border: 1px solid #1d2b3b;
  background: linear-gradient(160deg, #0d151f 0%, #121c28 100%);
  color: #c2d6ea;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
}

.vrse-btn:hover {
  border-color: #2b3f56;
  color: #dcecfa;
}

.vrse-btn:focus-visible {
  outline: 2px solid #3ee6c4;
  outline-offset: 2px;
}

.vrse-btn svg {
  flex: none;
}

.lang-select {
  margin-top: 26px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
}

/* ----------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgb(11 18 32 / 88%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.wordmark img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  color: var(--muted);
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.search-row {
  position: relative;
  max-width: 1100px;
  margin: 10px auto 0;
}

.search-row-inset {
  margin-top: 0;
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  fill: var(--faint);
  pointer-events: none;
}

.search-row input {
  width: 100%;
  height: 46px;
  padding: 0 14px 0 42px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
}

.search-row input::placeholder {
  color: var(--faint);
}

.search-row input:focus {
  border-color: var(--teal-dim);
  outline: none;
}

/* ------------------------------------------------------------------- grid */
.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 120px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

@media (max-width: 420px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

.divider {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 2px;
  color: var(--faint);
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

/* A card is the brand's own colour, dimmed hard so a wall of them is calm and
   the logo still reads. Full-strength brand colours side by side are a riot. */
.card {
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--brand, #374151);
  opacity: 0.16;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--border);
}

.card:active {
  transform: scale(0.98);
}

.card img {
  position: relative;
  width: 74%;
  height: 62%;
  object-fit: contain;
}

/* Around half the brand marks are black wordmarks -- every Inditex label,
   Sephora, Matas, Reserved, Empik. On a near-black card those are invisible,
   so tools/normalise_logos.py measures each logo's ink and flags the dark
   ones, and they get a light plate to sit on. Same reason a real loyalty card
   prints a black logo on white plastic rather than on the dark background. */
.card img.on-plate,
.tile img.on-plate {
  background: #f4f7fa;
  border-radius: 8px;
  padding: 6%;
}

.card img.on-plate {
  width: 70%;
  height: 58%;
  padding: 3%;
}

.card-letters {
  position: relative;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 1px 6px rgb(0 0 0 / 45%);
}

.card-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 8px 6px;
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
  color: #dbe6f4;
  background: linear-gradient(to top, rgb(11 18 32 / 92%), transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card.pinned {
  border-color: var(--coral);
}

.badge {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgb(11 18 32 / 78%);
  color: var(--muted);
}

.badge-pin {
  color: var(--coral);
}

.badge-shared {
  color: #7fb2ff;
}

.empty {
  text-align: center;
  padding: 60px 20px;
}

.empty img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  opacity: 0.85;
}

.empty p {
  margin: 6px 0;
  font-size: 17px;
  font-weight: 600;
}

.empty .muted {
  font-size: 14px;
  font-weight: 400;
}

/* -------------------------------------------------------------------- fab */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + var(--safe-b));
  z-index: 30;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--teal-bright), var(--teal-dim));
  color: #04231f;
  box-shadow: 0 8px 24px rgb(15 182 164 / 35%);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease;
}

.fab:hover {
  transform: scale(1.06);
}

.fab:active {
  transform: scale(0.95);
}

.fab svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

/* ----------------------------------------------------------------- footer */
.footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--faint);
}

.footer .dot {
  margin: 0 6px;
}

/* ---------------------------------------------------------------- dialogs */
.sheet {
  width: min(560px, 100vw);
  max-height: 92dvh;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sheet-small {
  width: min(400px, 100vw);
}

.sheet::backdrop {
  background: rgb(4 8 15 / 72%);
  backdrop-filter: blur(3px);
}

.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: rise 0.18s ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@media (max-width: 560px) {
  .sheet,
  .sheet-small {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    border: 0;
    margin: 0;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}

.sheet-head h2 {
  font-size: 18px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.sheet-foot {
  padding: 12px 18px calc(12px + var(--safe-b));
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex: none;
}

.sheet-foot-split {
  justify-content: space-between;
}

/* --------------------------------------------------------------- controls */
.btn {
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  transition: filter 0.15s ease;
}

.btn:hover {
  filter: brightness(1.15);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-primary {
  background: linear-gradient(150deg, var(--teal-bright), var(--teal-dim));
  color: #04231f;
}

.btn-quiet {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  border-color: rgb(242 85 90 / 45%);
  color: var(--danger);
}

.btn-danger-quiet {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--teal-bright);
  cursor: pointer;
  font-size: 14px;
  text-decoration: underline;
}

.field {
  display: block;
  margin: 0 0 16px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select,
#home-country,
.share-add input {
  width: 100%;
  height: var(--tap);
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
}

.field input:focus,
.field select:focus {
  border-color: var(--teal-dim);
  outline: none;
}

#card-number {
  font-size: 18px;
  letter-spacing: 0.08em;
}

.notice {
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
}

.notice-error {
  border-color: rgb(242 85 90 / 40%);
  background: rgb(242 85 90 / 10%);
  color: #ffc9cb;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}

.chip[aria-pressed="true"] {
  border-color: var(--teal-dim);
  background: rgb(15 182 164 / 14%);
  color: var(--teal-bright);
}

.chip-x {
  background: none;
  border: 0;
  color: var(--danger);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 0 0 2px;
}

/* ------------------------------------------------------------ brand picker */
.brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.brand-opt {
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 6px 8px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease;
}

.brand-opt:hover {
  border-color: var(--teal-dim);
}

.tile {
  width: 46px;
  height: 46px;
  margin: 0 auto 6px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--surface-3);
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile-letters {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
}

.tile-lg {
  width: 62px;
  height: 62px;
  border-radius: 14px;
}

.tile-lg .tile-letters {
  font-size: 24px;
}

.brand-opt span {
  display: block;
  font-size: 11px;
  line-height: 1.25;
  color: var(--muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.chosen {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.chosen h3 {
  font-size: 17px;
}

/* ------------------------------------------------------------------- tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 12px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
}

#reader {
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  min-height: 220px;
}

#reader video {
  width: 100% !important;
  display: block;
}

/* -------------------------------------------------------- the code itself */
/* White, always. A scanner needs contrast and a dark barcode does not scan. */
.code-stage {
  background: #fff;
  padding: 22px 18px 16px;
  text-align: center;
  flex: none;
}

.code-area {
  min-height: 150px;
  display: grid;
  place-items: center;
}

.code-area svg,
.code-area canvas,
.code-area img {
  max-width: 100%;
  height: auto;
}

.code-number {
  margin: 10px 0 0;
  color: #111;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.1em;
  word-break: break-all;
}

.code-big {
  color: #0b1220;
  font-size: clamp(28px, 9vw, 44px);
  font-weight: 700;
  letter-spacing: 0.06em;
  word-break: break-all;
  padding: 10px;
}

.bright-btn {
  margin-top: 12px;
  background: none;
  border: 1px solid #d5dbe4;
  color: #55606f;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}

/* Full-screen code: the queue-jumping mode. Everything else gets out of the
   way and the panel goes as bright and as large as the screen allows. */
.code-stage:fullscreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
}

.code-stage:fullscreen .code-area svg,
.code-stage:fullscreen .code-area canvas {
  transform: scale(1.35);
}

.seg {
  display: flex;
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}

.seg-btn {
  flex: 1;
  height: 48px;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.seg-btn[aria-pressed="true"] {
  color: var(--teal-bright);
  border-bottom-color: var(--teal);
}

.account-email {
  margin: 0 0 18px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 12px;
  font-size: 14px;
  color: var(--muted);
  word-break: break-all;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.sheet-actions .btn {
  width: 100%;
}

.share-add {
  display: flex;
  gap: 8px;
}

.share-add input {
  flex: 1;
}

#share-block h4 {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 2px;
}

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 60;
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  font-size: 14px;
  animation: rise 0.18s ease-out;
  max-width: calc(100vw - 32px);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
