/*
 * POINTPAL guest app.
 *
 * One stylesheet, no framework, no build step — this deploys by copying files to a
 * Windows box, and introducing Node tooling for a stylesheet would be a bad trade.
 *
 * Design direction: the app is used standing at a counter with a cashier waiting. The
 * visual anchor is the scan ticket — a paper-receipt form with a perforated edge and a
 * hard black rule — and everything else stays quiet so it never competes with the thing
 * the guest actually opened the app to show. Merchant brand colour is injected per card
 * as --brand, so the app chrome is deliberately neutral: it has to sit next to fifty
 * different restaurant palettes without clashing with any of them.
 *
 * Typography is the system stack. That is a real decision, not a default: a web font is
 * a blocking download on a bad connection in a basement restaurant, and the one screen
 * that must never wait is the one with the barcode on it.
 */

:root {
  --ink:        #12161C;
  --ink-soft:   #2A303A;
  --paper:      #F4F5F2;
  --card:       #FFFFFF;
  --line:       #DEE1DA;
  --muted:      #5F6670;
  --accent:     #0E5B4A;
  --accent-dk:  #0A4034;
  --accent-tint:#E3EFE9;
  --gold:       #8A6A00;
  --gold-tint:  #FBF3D9;
  --danger:     #8C2F1E;
  --danger-tint:#F8E9E5;

  --brand: var(--accent);

  --radius:     14px;
  --radius-sm:  9px;
  --tap:        44px;

  --shadow-sm: 0 1px 2px rgba(18, 22, 28, .06);
  --shadow-md: 0 2px 10px rgba(18, 22, 28, .08);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  /* 16px minimum on body and every input: below that, iOS Safari zooms on focus. */
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; letter-spacing: -.02em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem;    font-weight: 650; }
p  { margin: 0 0 1rem; }

a { color: var(--accent-dk); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem 6rem;
}
.wrap--narrow { max-width: 460px; }

/* ------------------------------------------------------------------ header */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1rem;
  background: var(--ink);
  color: #fff;
}
.topbar__brand {
  font-weight: 800;
  letter-spacing: .16em;
  font-size: .82rem;
  text-transform: uppercase;
  color: #fff;
  text-decoration: none;
}
.topbar__brand span { color: #93C4B4; }

.langswitch { display: flex; gap: .25rem; }
.langswitch button {
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  padding: .3rem .55rem;
  background: transparent;
  color: rgba(255,255,255,.62);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  min-height: 32px;
}
.langswitch button[aria-current="true"] {
  color: #fff;
  border-color: rgba(255,255,255,.4);
}

/* ------------------------------------------------------------------ the ticket
 *
 * The signature element. A perforated top edge and a heavy rule under the code make it
 * read as something to be handed over, not as another card in a feed.
 */

.ticket {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.25rem 1rem 1rem;
  margin: 0 0 1.5rem;
  text-align: center;
  overflow: hidden;
}
.ticket::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 8px;
  background:
    radial-gradient(circle at 6px -2px, transparent 6px, var(--card) 6.5px) 0 0 / 12px 8px repeat-x;
  background-color: var(--paper);
}
.ticket__label {
  margin: .35rem 0 .9rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.ticket__qr {
  width: min(62vw, 240px);
  margin: 0 auto;
  color: var(--ink);
}
.ticket__qr svg { display: block; width: 100%; height: auto; }

.ticket__rule {
  height: 2px;
  background: var(--ink);
  margin: 1.1rem 0 .9rem;
  opacity: .12;
}
.ticket__barcode { color: var(--ink); }
.ticket__barcode svg { display: block; width: 100%; height: 64px; }

.ticket__code {
  margin: .55rem 0 0;
  font-family: var(--mono);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: .16em;
  font-variant-numeric: tabular-nums;
}
.ticket__hint {
  margin: .7rem 0 0;
  font-size: .78rem;
  color: var(--muted);
}

/* ------------------------------------------------------------------ cards */

.section-title {
  margin: 1.75rem 0 .7rem;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
}

.cards { display: grid; gap: .75rem; grid-template-columns: 1fr; }

.card {
  display: block;
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .95rem 1rem .95rem 1.35rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  min-height: var(--tap);
}
a.card:hover { border-color: var(--brand); }
.card::before {
  content: "";
  position: absolute;
  left: 0; top: .8rem; bottom: .8rem;
  width: 4px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}
.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
}
.card__name { font-weight: 650; font-size: 1.02rem; }
.card__balance {
  font-size: 1.45rem;
  font-weight: 750;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.card__balance small { font-size: .68rem; font-weight: 600; color: var(--muted); margin-left: .18rem; }
.card__value { font-size: .84rem; color: var(--muted); }

.progress {
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin: .65rem 0 .35rem;
}
.progress__bar { height: 100%; background: var(--brand); border-radius: 999px; }

.card__note { font-size: .78rem; color: var(--muted); }
.card__note--ready { color: var(--gold); font-weight: 600; }

/* ------------------------------------------------------------------ activity */

.activity { list-style: none; margin: 0; padding: 0; }
.activity li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  padding: .7rem 0;
  border-bottom: 1px solid var(--line);
}
.activity li:last-child { border-bottom: 0; }
.activity__main { min-width: 0; }
.activity__title { font-size: .93rem; font-weight: 550; }
.activity__meta { font-size: .78rem; color: var(--muted); }
.activity__delta {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
  font-size: .95rem;
}
.activity__delta--pos { color: var(--accent); }
.activity__delta--neg { color: var(--ink-soft); }

/* ------------------------------------------------------------------ stats */

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .6rem;
  margin: 1rem 0;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .7rem .8rem;
}
.stat__value {
  font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.stat__label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.balance-hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
}
.balance-hero__value {
  font-size: 2.5rem; font-weight: 780; letter-spacing: -.035em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.balance-hero__value small { font-size: .9rem; font-weight: 600; color: var(--muted); }
.balance-hero__sub { color: var(--muted); font-size: .92rem; margin-top: .3rem; }

/* ------------------------------------------------------------------ rewards */

.reward {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 0;
  border-bottom: 1px solid var(--line);
}
.reward:last-child { border-bottom: 0; }
.reward__name { font-weight: 600; }
.reward__desc { font-size: .8rem; color: var(--muted); }
.pill {
  font-size: .74rem;
  font-weight: 700;
  padding: .28rem .6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.pill--ready { background: var(--gold-tint); color: var(--gold); }
.pill--wait  { background: var(--paper); color: var(--muted); border: 1px solid var(--line); }

/* ------------------------------------------------------------------ forms */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
}

.field { margin-bottom: 1rem; }
.field > label {
  display: block;
  font-size: .82rem;
  font-weight: 650;
  margin-bottom: .3rem;
}
.input {
  width: 100%;
  min-height: var(--tap);
  padding: .6rem .75rem;
  font: inherit;
  font-size: 16px;              /* below 16px, iOS zooms the page on focus */
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
}
.input:focus { border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-tint); }

.input--code {
  font-family: var(--mono);
  font-size: 1.6rem;
  letter-spacing: .5em;
  text-align: center;
  padding-left: .5em;           /* letter-spacing adds a trailing gap; recentre */
  font-variant-numeric: tabular-nums;
}

.field__error { display: block; margin-top: .3rem; font-size: .8rem; color: var(--danger); }
.field__hint  { display: block; margin-top: .3rem; font-size: .78rem; color: var(--muted); }

.check {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  font-size: .88rem;
  line-height: 1.4;
}
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  width: 100%;
  min-height: var(--tap);
  padding: .7rem 1.1rem;
  font: inherit;
  font-weight: 650;
  color: #fff;
  background: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--accent-dk); border-color: var(--accent-dk); }
.btn--ghost { background: transparent; color: var(--accent-dk); }
.btn--ghost:hover { background: var(--accent-tint); }
.btn--quiet {
  background: transparent; color: var(--ink); border-color: var(--line);
}
.btn--quiet:hover { background: var(--paper); }
.btn--danger { background: var(--danger); border-color: var(--danger); }
.btn--auto { width: auto; }
.btn--sm { min-height: 36px; padding: .35rem .75rem; font-size: .84rem; }

.notice {
  padding: .75rem .9rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.notice--ok    { background: var(--accent-tint); color: var(--accent-dk); border-color: #C4DFD4; }
.notice--error { background: var(--danger-tint); color: var(--danger); border-color: #EBCFC8; }
.notice--warn  { background: var(--gold-tint);  color: var(--gold);  border-color: #EBDCA8; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.stack > * + * { margin-top: .75rem; }

.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

.linkrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--tap);
  padding: .7rem 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}
.linkrow:last-child { border-bottom: 0; }

.device {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--line);
}
.device:last-child { border-bottom: 0; }
.device__name { font-weight: 600; }
.device__meta { font-size: .78rem; color: var(--muted); word-break: break-word; }

.tokenbox {
  font-family: var(--mono);
  font-size: .78rem;
  word-break: break-all;
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: .7rem;
}

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: .5rem 0 .5rem 2.2rem;
  font-size: .93rem;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: .5rem;
  width: 1.6rem; height: 1.6rem;
  display: grid; place-items: center;
  background: var(--accent-tint);
  color: var(--accent-dk);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
}

/* ------------------------------------------------------------------ bottom nav */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  /* Without the safe-area inset the iPhone home indicator sits on top of the tabs. */
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 20;
}
.tabbar a {
  flex: 1;
  min-height: var(--tap);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
  padding: .45rem .25rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.tabbar a[aria-current="page"] { color: var(--accent-dk); }
.tabbar svg { width: 22px; height: 22px; }

/* ------------------------------------------------------------------ responsive */

@media (min-width: 480px) {
  .ticket__qr { width: 260px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 768px) {
  h1 { font-size: 1.9rem; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .wrap { padding-bottom: 2.5rem; }

  /* Above the fold on a phone means a fixed bottom bar; on a tablet it is clutter. */
  .tabbar {
    position: static;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
  }
  .tabbar a { flex: 0 0 auto; flex-direction: row; gap: .4rem; padding: .8rem 1rem; font-size: .88rem; }
}

@media (min-width: 1024px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  .layout-split {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.75rem;
    align-items: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media print {
  .tabbar, .topbar, .btn { display: none; }
}
