/*
 * Coupon wheel widget page (/w/{id}), framed by merchant websites (docs/WIDGET.md). Standalone stylesheet:
 * nothing from app.css. Theme: html[data-theme=light|dark|auto] + the merchant's accent (--lw-accent, inline).
 * Logical properties only (RTL from dir="rtl"); animations collapse in reduced motion.
 */
:root {
  color-scheme: light;
  --lw-bg: #FFFFFF; --lw-surface: #F5F5FA; --lw-text: #14151A; --lw-muted: #5B6070; --lw-border: #D9DAE3;
  --lw-field: #FFFFFF; --lw-danger: #C62828; --lw-ok: #12805C; --lw-ok-soft: #E6F4EE; --lw-sep: #FFFFFF;
  --lw-font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Arabic", Tahoma, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --lw-bg: #15161D; --lw-surface: #1F2230; --lw-text: #ECEDF2; --lw-muted: #A3A8B8; --lw-border: #3A3E50;
  --lw-field: #0E0F13; --lw-danger: #FF6B6B; --lw-ok: #3DD68C; --lw-ok-soft: #0F2A1F; --lw-sep: #15161D;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    color-scheme: dark;
    --lw-bg: #15161D; --lw-surface: #1F2230; --lw-text: #ECEDF2; --lw-muted: #A3A8B8; --lw-border: #3A3E50;
    --lw-field: #0E0F13; --lw-danger: #FF6B6B; --lw-ok: #3DD68C; --lw-ok-soft: #0F2A1F; --lw-sep: #15161D;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--lw-bg); color: var(--lw-text);
  font: 400 15px/1.5 var(--lw-font); -webkit-font-smoothing: antialiased;
}
[lang="ar"] body { font-size: 16px; line-height: 1.65; }
[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: .2em; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--lw-accent); outline-offset: 2px; }

.lw-card { position: relative; max-width: 440px; margin: 0 auto; padding: 20px 20px 14px; text-align: center; }
.lw--popup .lw-card { padding-top: 22px; }
.lw-close {
  position: absolute; inset-block-start: 8px; inset-inline-end: 8px; z-index: 2;
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--lw-muted); cursor: pointer;
}
.lw-close:hover { background: var(--lw-surface); color: var(--lw-text); }
.lw-close svg { width: 22px; height: 22px; }

.lw-head { padding-inline: 28px; }
.lw--popup .lw-head { padding-inline: 44px; }
.lw-logo { display: block; max-width: 160px; max-height: 48px; margin: 0 auto 8px; object-fit: contain; }
.lw-title { margin: 0; font-size: 1.375rem; line-height: 1.25; font-weight: 800; text-wrap: balance; }
.lw-sub { margin: 6px 0 0; color: var(--lw-muted); text-wrap: pretty; }

/* Wheel: same geometry as the site wheel (svg_wheel.php / renderer.js), pointer at the top */
.lw-stage {
  position: relative; width: min(100%, 300px, 44vh); aspect-ratio: 1; margin: 14px auto 6px;
  min-width: 180px;
}
.lw-disc { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 6px var(--lw-surface), 0 8px 24px rgba(20, 21, 26, .16); }
.lw-disc > svg, .lw-disc > .lh-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.lh-canvas { transform-origin: 50% 50%; will-change: transform; }
.lh-svg { overflow: visible; }
.lh-svg .lh-sl path, .lh-svg .lh-sl circle { stroke: var(--lw-sep); stroke-width: 2px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.lh-svg .lh-sl circle:only-child { stroke: none; }
.lh-svg .lh-wl { font-family: var(--lw-font); }
.lw-pointer {
  position: absolute; inset-block-start: -20px; left: 50%; width: 30px; height: 34px; margin-left: -15px; z-index: 1;
  transform-origin: 50% 30%; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25));
}
.lw-pointer path { fill: var(--lw-accent); stroke: var(--lw-bg); stroke-width: 3; stroke-linejoin: round; }
.lw-pointer circle { fill: var(--lw-bg); }
.lw-hub {
  position: absolute; top: 50%; left: 50%; width: 15%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  background: var(--lw-accent); box-shadow: 0 0 0 4px var(--lw-bg), 0 2px 6px rgba(0, 0, 0, .25);
}
.lw-stage.is-empty .lw-pointer, .lw-stage.is-empty .lw-hub { display: none; }
.lw-stage.is-empty .lw-disc { box-shadow: none; background: var(--lw-surface); }

.lw-odds { margin: 4px auto 0; max-width: 320px; font-size: .875rem; text-align: start; }
.lw-odds summary { cursor: pointer; color: var(--lw-muted); text-align: center; padding: 6px; }
.lw-odds ul { margin: 4px 0 0; padding: 0; list-style: none; }
.lw-odds li { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--lw-border); }
.lw-odds li span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.lw-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }

.lw-form { margin-top: 12px; text-align: start; }
.lw-field label { display: block; margin-bottom: 4px; font-weight: 650; font-size: .9375rem; }
.lw-opt { color: var(--lw-muted); font-weight: 400; }
.lw-field input {
  display: block; width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--lw-border); border-radius: 10px;
  background: var(--lw-field);
}
.lw-field input:focus { outline: none; border-color: var(--lw-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lw-accent) 25%, transparent); }
.lw-field input[aria-invalid="true"] { border-color: var(--lw-danger); }
[dir="rtl"] .lw-field input { text-align: right; }
.lw-check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0 0; font-size: .8125rem; line-height: 1.45; color: var(--lw-muted); cursor: pointer; }
.lw-check input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--lw-accent); }
.lw-err { margin: 10px 0 0; color: var(--lw-danger); font-weight: 650; font-size: .875rem; }
.lw-spin {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 52px; margin-top: 14px; padding: 0 20px;
  border: 0; border-radius: 999px; background: var(--lw-accent); color: var(--lw-accent-ink);
  font-weight: 800; font-size: 1.0625rem; cursor: pointer; box-shadow: 0 2px 0 rgba(0, 0, 0, .18);
  transition: transform .12s, filter .2s;
}
.lw-spin:hover:not(:disabled) { filter: brightness(1.06); }
.lw-spin:active:not(:disabled) { transform: scale(.97); }
.lw-spin:disabled { cursor: default; opacity: .6; }
.lw-spin.is-busy { opacity: 1; }
.lw-legal { margin: 10px 0 0; color: var(--lw-muted); font-size: .75rem; text-align: center; }
.lw-legal a { margin-inline-start: 4px; white-space: nowrap; }
.lw-state { margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--lw-surface); color: var(--lw-text); font-weight: 600; }

.lw-result { margin-top: 12px; padding: 16px; border-radius: 16px; background: var(--lw-surface); outline: none; animation: lw-pop .32s cubic-bezier(.2, .8, .2, 1); }
.lw-result.is-win { background: var(--lw-ok-soft); box-shadow: inset 0 0 0 2px var(--lw-ok); }
@keyframes lw-pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.lw-res-title { margin: 0; font-size: 1.25rem; line-height: 1.3; }
.lw-res-prize { margin: 4px 0 0; font-weight: 700; font-size: 1.0625rem; overflow-wrap: anywhere; }
.lw-res-prize:empty, .lw-res-msg:empty { display: none; }
.lw-code { margin-top: 12px; text-align: start; }
.lw-code label { display: block; font-size: .8125rem; color: var(--lw-muted); margin-bottom: 4px; }
.lw-code__row { display: flex; gap: 8px; }
.lw-code__val {
  flex: 1; min-width: 0; min-height: 48px; padding: 8px 12px; border: 2px dashed var(--lw-ok); border-radius: 10px; background: var(--lw-field);
  font: 800 1.125rem/1.2 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .04em; text-align: center;
}
.lw-copy {
  flex: none; min-width: 92px; min-height: 48px; padding: 0 14px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--lw-accent); color: var(--lw-accent-ink); font-weight: 750;
}
.lw-res-msg { margin: 10px 0 0; color: var(--lw-muted); font-size: .9375rem; white-space: pre-line; }
.lw-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.lw-brand { margin: 14px 0 0; font-size: .75rem; color: var(--lw-muted); }
.lw-brand a { color: inherit; }
.lw--popup .lw-brand { margin-bottom: 4px; }

@media (max-height: 560px) { .lw-stage { width: min(100%, 220px, 40vh); } .lw-card { padding-top: 12px; } }
@media (prefers-reduced-motion: reduce) { .lw-result { animation: none; } .lw-spin { transition: none; } }
