/* assets/widget.css — the public entry flows (spin-to-win and receipt upload).
   Kept separate from admin.css: this is the partner's branding, not ours.
   Promotion.themeConfig (primary colour, secondary colour, corner radius —
   deliberately just three tokens) overrides --brand/--brand-deep/--radius
   via an inline <style> block the widget prints per request.

   This is the one page a promotion's actual customers see, usually on a
   phone with one hand, so tap targets, focus rings and readable contrast
   matter more here than anywhere in the admin. */

:root {
  --ground:   #f2f4f9;
  --paper:    #ffffff;
  --ink:      #1b2a4a;
  --ink-soft: #5a6784;
  --line:     #dce1ec;
  --field:    #f7f8fc;
  --brand:      #4f46e5;
  --brand-deep: #3730a3;
  --danger:      #b42318;
  --danger-bg:   #fef3f2;
  --danger-line: #fecdca;
  --ok:        #067647;
  --ok-bg:     #ecfdf3;
  --ok-line:   #abefc6;
  --radius:    14px;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

.widget-wrap {
  display: flex;
  justify-content: center;
  padding: 6vh 16px 40px;
}

.widget-card {
  width: 100%;
  max-width: 420px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-top: 5px solid var(--brand);
  padding: 30px 26px 28px;
  box-shadow: 0 1px 3px rgba(27, 42, 74, .08);
}

.widget-logo { display: block; max-height: 48px; max-width: 100%; margin: 0 auto 18px; }

/* ---- layoutType variants: hero / badge / text ----
   Only .widget-logo and .widget-intro change size/order inside .widget-card.
   Every layout renders the same name + description + logo — presentation only. */

.layout-hero .widget-logo {
  width: calc(100% + 52px);
  max-width: none;
  height: auto;
  max-height: 160px;
  object-fit: cover;
  border-radius: var(--radius);
  margin: -30px -26px 18px;
}

.layout-badge .widget-logo {
  width: 64px;
  height: 64px;
  max-height: 64px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--line);
}

.layout-text.widget-card { position: relative; }
.layout-text .widget-logo {
  position: absolute;
  top: 26px;
  right: 22px;
  width: 32px;
  height: 32px;
  max-height: 32px;
  object-fit: cover;
  border-radius: 6px;
  margin: 0;
}
.layout-text .widget-intro { padding-right: 40px; }

.widget-logo[src=""] { display: none; }

.lang-switch { display: flex; justify-content: center; gap: 10px; margin-bottom: 14px; }
.lang-switch a {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .03em;
  color: var(--ink-soft, #6b7280);
  text-decoration: none;
  padding: 2px 6px;
  border-radius: 4px;
}
.lang-switch a.on { color: var(--brand); background: rgba(0,0,0,.04); }

h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0 0 6px;
}

.lede {
  color: var(--ink-soft);
  font-size: 15px;
  text-align: center;
  margin: 0 0 22px;
}

/* ---------------------------------------------------------------- fields */

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: 16px; /* 16px keeps iOS Safari from zooming in on focus */
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}

.field textarea { min-height: 88px; resize: vertical; line-height: 1.5; }

.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%235a6784' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  background: var(--paper);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .16);
}

.field input::placeholder, .field textarea::placeholder { color: #9aa3b8; }

.field .hint { display: block; font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; }

/* File input: a tappable drop zone rather than a bare browser control. */
.field input[type="file"] {
  padding: 14px 12px;
  border-style: dashed;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
}
.field input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

/* "Scan my PIN" trigger under the pin-code field. Full-width and dashed
   like the file-drop zones elsewhere in the widget, so it reads as an
   obviously tappable alternative to typing rather than a stray label. */
.scan-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  padding: 11px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand);
  background: var(--field);
  border: 1.5px dashed var(--brand);
  border-radius: 9px;
  cursor: pointer;
  transition: background .12s ease, border-style .12s ease;
}
.scan-btn:hover { background: rgba(79, 70, 229, .08); }
.scan-btn:active { border-style: solid; }
.scan-btn:disabled { opacity: .6; cursor: default; }
.scan-btn-badge {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, .18);
  color: var(--brand);
}
.scan-btn-icon { width: 17px; height: 17px; }

/* Thumbnail of the photo just chosen, so it's obvious it took. */
.file-preview {
  display: none;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}
.file-preview.on { display: block; }
.file-preview img {
  display: block;
  width: 100%;
  max-height: 190px;
  object-fit: contain;
  border-radius: 6px;
}
.file-preview .file-name {
  display: block;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
  word-break: break-all;
}

/* Checkbox / radio with its label. Full ink colour: the consent line is the
   one the entrant is legally agreeing to, so it isn't small print. */
.checkline {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 12px;
  padding: 4px 0;
  cursor: pointer;
}
.checkline input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 1px 0 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.checkline a { color: var(--brand); }

/* 1-5 rating as tappable pills instead of pinhead radios. */
.rating { display: flex; gap: 8px; }
.rating label {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.rating label input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.rating label:hover { border-color: var(--brand); color: var(--ink); }
.rating label:focus-within { box-shadow: 0 0 0 3px rgba(79, 70, 229, .16); }
.rating label.picked {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

/* --------------------------------------------------------------- buttons */

button.primary {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 48px;
  padding: 13px 16px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s ease;
}
button.primary:hover  { background: var(--brand-deep); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled { opacity: .55; cursor: default; transform: none; }

/* Quiet text button — "start over", and anything that shouldn't compete
   with the main action. */
.linkish {
  display: inline-block;
  width: auto;
  margin: 0 0 14px;
  padding: 6px 0;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-soft);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}
.linkish:hover { color: var(--brand); }

/* Progress dots above "start over" — one per step that actually applies
   this run (survey/skill are conditional), so visitors can see how much
   of the flow is left. */
.widget-steps { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; }
.widget-steps .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-soft);
  opacity: .3;
}
.widget-steps .dot.done { background: var(--brand); opacity: .55; }
.widget-steps .dot.current { background: var(--brand); opacity: 1; width: 10px; height: 10px; }
.widget-steps-label { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-soft); }

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

/* --------------------------------------------------------------- notices */

.notice {
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 18px;
}
.notice.error { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.notice.ok    { background: var(--ok-bg);     border-color: var(--ok-line);     color: var(--ok); }

/* ------------------------------------------------------------------ spin */

.prize-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 10px;
  margin: 6px 0 24px;
}
.prize-card {
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 12px 6px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink-soft);
  background: var(--field);
  overflow-wrap: anywhere;
  transition: border-color .1s, background .1s, color .1s, transform .1s;
}
.prize-card img { width: 32px; height: 32px; object-fit: cover; border-radius: 6px; margin: 0 auto 6px; display: block; }
.prize-card.lit {
  border-color: var(--brand);
  background: var(--paper);
  color: var(--ink);
  transform: scale(1.04);
}
.prize-card.winner {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.win-banner {
  text-align: center;
  margin-bottom: 20px;
}
.win-banner .prize-name { font-size: 19px; font-weight: 700; margin: 10px 0 2px; }
.win-banner .prize-desc { font-size: 14px; color: var(--ink-soft); }

.success-icon { text-align: center; font-size: 40px; line-height: 1; margin-bottom: 6px; }

/* ------------------------------------------------------------- terms page */

.terms-wrap { max-width: 720px; margin: 0 auto; padding: 6vh 20px 60px; }
.terms-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-top: 5px solid var(--brand);
  padding: 34px 32px;
}
.terms-card h1 { font-size: 22px; margin: 0 0 4px; text-align: left; }
.terms-card h2 { font-size: 18px; margin: 26px 0 8px; }
.terms-card h3 { font-size: 16px; margin: 26px 0 8px; }
.terms-card p, .terms-card li { font-size: 14.5px; color: var(--ink-soft); line-height: 1.65; }
.terms-card ul, .terms-card ol { padding-left: 20px; }
.terms-card a { color: var(--brand); }
.terms-card table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 14px 0; }
.terms-card th, .terms-card td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }

@media print {
  body { background: #fff; }
  .terms-wrap { padding: 0; }
  .terms-card { border: 0; border-radius: 0; padding: 0; box-shadow: none; }
}

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

@media (max-width: 480px) {
  .widget-wrap { padding-top: 3vh; }
  .widget-card { padding: 24px 20px 22px; }
  .prize-row { grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); gap: 8px; }
  .terms-card { padding: 26px 20px; }
  .layout-hero .widget-logo { margin: -24px -20px 16px; width: calc(100% + 40px); max-height: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .prize-card.lit { transform: none; }
}
