/* =====================================================================
   Dealer Scratch Card Scheme
   Visual language: a steel mill dispatch slip. Hairline rules, mono for
   anything a machine reads (codes, quantities), brass reserved for prizes.
   ===================================================================== */

:root {
  --ink:    #0E1F2E;
  --slate:  #57697C;
  --paper:  #EDF1F4;
  --card:   #FFFFFF;
  --line:   #D2DAE2;
  --brass:  #B8860F;
  --win:    #12735A;
  --alert:  #A62A21;

  --sans:  "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --disp:  "Archivo", var(--sans);
  --mono:  "IBM Plex Mono", ui-monospace, "Courier New", monospace;

  --r: 3px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--ink); text-underline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---- Type ---------------------------------------------------------- */

h1, h2, h3 {
  font-family: var(--disp);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 .5rem;
  line-height: 1.15;
}

h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

.eyebrow {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--slate);
  margin: 0 0 .35rem;
}

.muted { color: var(--slate); }
.small { font-size: .82rem; }
.mono  { font-family: var(--mono); }
.right { text-align: right; }
.center{ text-align: center; }

/* ---- Shell --------------------------------------------------------- */

.topbar {
  background: var(--ink);
  color: #fff;
  border-bottom: 3px solid var(--brass);
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: .7rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.1rem;
  align-items: baseline;
}

.brand {
  font-family: var(--disp);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #fff;
  text-decoration: none;
  margin-right: auto;
}

.brand span { color: var(--brass); }

.topbar a.navlink {
  color: #C3CEDA;
  text-decoration: none;
  font-size: .88rem;
}

.topbar a.navlink:hover,
.topbar a.navlink.is-active { color: #fff; text-decoration: underline; }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.4rem 1rem 4rem;
}

.wrap-narrow { max-width: 480px; }

.pagehead {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

/* ---- Panels -------------------------------------------------------- */

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

.panel > :last-child { margin-bottom: 0; }

.panel-title {
  font-family: var(--disp);
  font-weight: 700;
  font-size: .95rem;
  padding-bottom: .55rem;
  margin-bottom: .9rem;
  border-bottom: 1px solid var(--line);
}

.grid {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* ---- Stat tiles ---------------------------------------------------- */

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink);
  border-radius: var(--r);
  padding: .8rem 1rem;
}

.stat-value {
  font-family: var(--disp);
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.02em;
}

.stat-label {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--slate);
  margin-top: .3rem;
}

.stat.is-brass { border-left-color: var(--brass); }
.stat.is-win   { border-left-color: var(--win); }

/* ---- Forms --------------------------------------------------------- */

.field { margin-bottom: .9rem; }

.field label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--slate);
  margin-bottom: .3rem;
}

.input,
select.input,
textarea.input {
  width: 100%;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: .6rem .7rem;
}

.input:focus {
  border-color: var(--ink);
  outline: none;
  box-shadow: 0 0 0 3px rgba(14, 31, 46, .12);
}

.input[readonly] { background: #F5F7F9; color: var(--slate); }

textarea.input { min-height: 78px; resize: vertical; }

.input-mono {
  font-family: var(--mono);
  letter-spacing: .3em;
  text-align: center;
  font-size: 1.35rem;
}

.hint { font-size: .78rem; color: var(--slate); margin-top: .3rem; }

/* ---- Buttons ------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  font-family: var(--sans);
  font-size: .92rem;
  font-weight: 600;
  padding: .62rem 1.1rem;
  border: 1px solid var(--ink);
  border-radius: var(--r);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s ease;
}

.btn:hover { opacity: .88; }

.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-block { width: 100%; }

.btn-ghost { background: transparent; color: var(--ink); }

.btn-small { font-size: .8rem; padding: .38rem .7rem; }

.btn-danger { background: var(--alert); border-color: var(--alert); }

/* ---- Messages ------------------------------------------------------ */

.msg {
  border: 1px solid var(--line);
  border-left: 3px solid var(--slate);
  border-radius: var(--r);
  background: #fff;
  padding: .7rem .85rem;
  font-size: .9rem;
  margin-bottom: 1rem;
}

.msg-error { border-left-color: var(--alert); color: var(--alert); }
.msg-ok    { border-left-color: var(--win);   color: var(--win); }
.msg[hidden] { display: none; }

/* ---- Tables -------------------------------------------------------- */

.table-scroll { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

table.data th {
  font-family: var(--mono);
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--slate);
  text-align: left;
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--ink);
  white-space: nowrap;
}

table.data td {
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.data tr:last-child td { border-bottom: none; }

table.data td.num { font-family: var(--mono); text-align: right; }

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .15rem .4rem;
  border-radius: 2px;
  border: 1px solid var(--line);
  color: var(--slate);
}

.tag-win  { color: var(--win);   border-color: var(--win); }
.tag-miss { color: var(--slate); }
.tag-out  { color: var(--alert); border-color: var(--alert); }

.empty {
  padding: 1.8rem 1rem;
  text-align: center;
  color: var(--slate);
  font-size: .9rem;
}

/* ---- Dealer QR ----------------------------------------------------- */

.qr-block { text-align: center; }

.qr-frame {
  display: inline-block;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.qr-frame canvas, .qr-frame img { display: block; }

.qr-code-text {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: .18em;
  margin-top: .7rem;
}

.qr-url {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--slate);
  word-break: break-all;
  margin-top: .3rem;
}

/* =====================================================================
   Customer journey
   ===================================================================== */

.customer-page {
  background: var(--ink);
  min-height: 100vh;
}

.customer-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 1.6rem 1rem 3rem;
}

.shop-head {
  color: #fff;
  text-align: center;
  margin-bottom: 1.2rem;
}

.shop-head .eyebrow { color: var(--brass); }

.shop-head h1 { color: #fff; font-size: 1.4rem; }

.shop-head p { color: #A9B8C7; font-size: .85rem; margin: .2rem 0 0; }

.sheet {
  background: var(--card);
  border-radius: 6px;
  padding: 1.2rem;
}

/* Step rail - numbered because this really is a fixed sequence */
.steps {
  display: flex;
  gap: .4rem;
  margin-bottom: 1.1rem;
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.steps li {
  flex: 1;
  list-style: none;
  color: #6C7F92;
  border-top: 2px solid #33475A;
  padding-top: .35rem;
}

.steps li.is-done,
.steps li.is-current { color: var(--brass); border-top-color: var(--brass); }

/* ---- The coupon (signature element) -------------------------------- */

.coupon {
  position: relative;
  background: var(--card);
  border-radius: 6px;
  overflow: hidden;
  /* punched ticket edge */
  -webkit-mask-image:
    radial-gradient(circle 9px at 0 50%, transparent 98%, #000 100%),
    radial-gradient(circle 9px at 100% 50%, transparent 98%, #000 100%);
  -webkit-mask-composite: source-in;
          mask-image:
    radial-gradient(circle 9px at 0 50%, transparent 98%, #000 100%),
    radial-gradient(circle 9px at 100% 50%, transparent 98%, #000 100%);
          mask-composite: intersect;
}

.coupon-head {
  padding: .9rem 1.1rem .7rem;
  border-bottom: 1px dashed var(--line);
}

.coupon-code {
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .16em;
  color: var(--slate);
}

.scratch-area {
  position: relative;
  height: 210px;
  display: grid;
  place-items: center;
  background: #fff;
}

.prize {
  padding: 0 1.2rem;
  text-align: center;
}

.prize-label {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--slate);
}

.prize-name {
  font-family: var(--disp);
  font-weight: 800;
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: -.02em;
  color: var(--brass);
  margin: .3rem 0;
}

.prize-name.is-miss { color: var(--slate); font-size: 1.5rem; }

.prize-note { font-size: .85rem; color: var(--slate); }

#scratchCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  transition: opacity .45s ease;
}

#scratchCanvas.is-cleared { opacity: 0; pointer-events: none; }

.coupon-foot {
  padding: .75rem 1.1rem;
  border-top: 1px dashed var(--line);
  font-size: .78rem;
  color: var(--slate);
  display: flex;
  justify-content: space-between;
  gap: .5rem;
}

.reveal-in {
  animation: reveal-in .5s cubic-bezier(.2, .7, .3, 1) both;
}

@keyframes reveal-in {
  from { transform: scale(.94); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal-in { animation: none; }
  #scratchCanvas { transition: none; }
}

/* ---- Responsive ---------------------------------------------------- */

@media (max-width: 640px) {
  .pagehead { align-items: flex-start; }
  h1 { font-size: 1.3rem; }
  .stat-value { font-size: 1.6rem; }
  .topbar-inner { gap: .4rem .8rem; }
}

@media print {
  .topbar, .btn, .no-print { display: none !important; }
  body { background: #fff; }
  .panel { border: none; }
}
