/* ScentSync, rabattspelet "Skrapa fram din doftrabatt" (templates/butik/_spel.html, spel.js).
   En skraplott formad som en parfymetikett: svart etikett med tunn guldram, guldfolie i en kartusch,
   varm grå yta under. Bygger på tokens i butik.css (--guld, --yta, --rubrikfont, --brodfont, --ease-ut). */

html.spel-las, html.spel-las body { overflow: hidden; }

/* ---------- Dialogen ---------- */
.spel {
  --spel-guld: var(--guld, #d3c092);
  --spel-guld-mork: #9c7f45;
  padding: 0; border: 0; background: transparent; color: var(--text, #262626);
  width: min(440px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px);
  overflow: visible; font-family: var(--brodfont); letter-spacing: .02em;
}
.spel::backdrop { background: rgba(12, 10, 8, .62); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.spel[open] { animation: spel-in .5s var(--ease-ut, cubic-bezier(.16, 1, .3, 1)) both; }
.spel[open]::backdrop { animation: spel-tona-in .45s ease both; }
.spel.stanger { animation: spel-ut .22s ease-in both; }
.spel.stanger::backdrop { animation: spel-tona-ut .22s ease-in both; }
@keyframes spel-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes spel-ut { to { opacity: 0; transform: scale(.97); } }
@keyframes spel-tona-in { from { opacity: 0; } }
@keyframes spel-tona-ut { to { opacity: 0; } }

.spel__panel {
  position: relative; background: var(--yta, #f4f2ef); border-radius: 22px; padding: 12px;
  max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .12);
}
.spel :focus-visible { outline: 2px solid #000; outline-offset: 3px; }

.spel__stang {
  position: absolute; top: 29px; right: 29px; z-index: 5; width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
  border: 1px solid rgba(211, 192, 146, .35); background: rgba(0, 0, 0, .55); color: #fff;
  transition: background-color .2s, border-color .2s, transform .3s var(--ease-ut);
}
.spel__stang .ikon { width: 18px; height: 18px; }
.spel__stang:hover { background: #000; border-color: var(--spel-guld); transform: rotate(90deg); }
.spel__stang:focus-visible { outline-color: var(--spel-guld); }

/* ---------- Etiketten ---------- */
.spel__etikett {
  background: radial-gradient(120% 90% at 50% 0%, #1d1915 0%, #000 62%);
  border-radius: 16px; padding: 9px; color: #fff; text-align: center;
}
.spel__ram {
  position: relative; border: 1px solid rgba(211, 192, 146, .6); border-radius: 10px; padding: 22px 22px 14px;
}
.spel__ram::before {             /* dubbel guldlinje, som på en parfymetikett */
  content: ""; position: absolute; inset: 4px; border: 1px solid rgba(211, 192, 146, .22); border-radius: 7px; pointer-events: none;
}
.spel__logga { width: 58px; height: auto; margin: 0 auto 8px; display: block; }
.spel__overrad { margin: 0; font-size: 11px; line-height: 1.4; letter-spacing: .24em; text-transform: uppercase; color: var(--spel-guld); }
.spel__rubrik { margin: 6px 0 16px; font-family: var(--rubrikfont); font-weight: 600; font-size: 25px; line-height: 1.15; letter-spacing: .005em; color: #fff; }

/* Kartuschen med guldfolien */
.spel__lott {
  position: relative; height: 128px; border-radius: 12px; overflow: hidden; isolation: isolate;
  background: radial-gradient(80% 120% at 50% 50%, #2b2318 0%, #0e0c0a 72%);
  box-shadow: inset 0 0 0 1px rgba(211, 192, 146, .45);
  transition: box-shadow .9s var(--ease-ut);
}
.spel__vinst { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px 16px; }
.spel__vinst-stor {
  font-family: var(--rubrikfont); font-weight: 700; font-size: 44px; line-height: 1.05; letter-spacing: .01em;
  background: linear-gradient(180deg, #f7ecd0 0%, #d3c092 55%, #a98b51 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.spel__vinst-under { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: rgba(255, 255, 255, .78); }
.spel__folie {
  position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; display: block;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  cursor: crosshair; transition: opacity .8s var(--ease-ut);
}
.spel__lott::after {             /* guldskimret som sveper över vinsten */
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: linear-gradient(105deg, transparent 32%, rgba(255, 236, 190, .32) 50%, transparent 68%);
  transform: translateX(-130%);
}
.spel__lott.klar { box-shadow: inset 0 0 0 1px rgba(211, 192, 146, .85), 0 0 34px rgba(211, 192, 146, .28); }
.spel__lott.klar .spel__folie { opacity: 0; pointer-events: none; }
.spel__lott.klar::after { animation: spel-svep 1.5s .35s ease-out both; }
.spel__lott.klar .spel__vinst-stor { animation: spel-sken 1.6s var(--ease-ut) both; }
.spel__lott.klar .spel__vinst-under { animation: spel-tona-in 1s .3s ease both; }
@keyframes spel-svep { to { transform: translateX(130%); } }
@keyframes spel-sken {
  0% { opacity: .2; transform: scale(.94); filter: drop-shadow(0 0 0 rgba(211, 192, 146, 0)); }
  45% { opacity: 1; transform: scale(1.04); filter: drop-shadow(0 0 16px rgba(211, 192, 146, .7)); }
  100% { opacity: 1; transform: none; filter: drop-shadow(0 0 6px rgba(211, 192, 146, .3)); }
}
.spel__laddar { display: inline-flex; gap: 6px; }
.spel__laddar i { width: 7px; height: 7px; border-radius: 50%; background: var(--spel-guld); opacity: .35; animation: spel-prick 1.2s infinite ease-in-out; }
.spel__laddar i:nth-child(2) { animation-delay: .15s; } .spel__laddar i:nth-child(3) { animation-delay: .3s; }
@keyframes spel-prick { 40% { opacity: 1; transform: translateY(-3px); } }
.spel__etikett-fot { margin: 12px 0 0; font-size: 10px; letter-spacing: .3em; text-transform: uppercase; color: rgba(211, 192, 146, .72); }
.spel__etikett-fot span { margin: 0 .3em; }

/* ---------- Stegen under etiketten ---------- */
.spel__steg { padding: 18px 10px 6px; text-align: center; }
.spel__steg.in { animation: spel-steg .55s var(--ease-ut) both; }
@keyframes spel-steg { from { opacity: 0; transform: translateY(10px); } }
.spel__text { margin: 0 0 14px; font-size: 14px; line-height: 1.55; color: #4a4540; }
.spel__vinster-rubrik { margin: 0 0 8px; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--dampad, #5f5b57); }
.spel__vinster { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.spel__vinster li { padding: 5px 12px; border-radius: 8px; background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); font-family: var(--rubrikfont); font-weight: 500; font-size: 13px; line-height: 1.5; }
.spel__visa {
  display: inline-flex; align-items: center; justify-content: center; margin: 16px auto 0; min-height: 46px; padding: 0 26px;
  border-radius: var(--radie-knapp, 10px); border: 1px solid #000; background: transparent; color: #000; cursor: pointer;
  font-family: var(--rubrikfont); font-weight: 500; font-size: 14px; letter-spacing: .04em;
  transition: background-color .25s var(--ease-ut), color .25s;
}
.spel__visa:hover { background: #000; color: #fff; }
.spel__visa:disabled { opacity: .5; cursor: default; }
.spel__finstilt { margin: 12px 0 2px; font-size: 12px; line-height: 1.5; color: var(--dampad, #5f5b57); }

.spel__grattis { margin: 0 0 12px; font-family: var(--rubrikfont); font-size: 18px; line-height: 1.35; font-weight: 500; outline: none; }
.spel__grattis strong { font-weight: 700; }
.spel__kodruta {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; text-align: left;
  background: #fff; border-radius: 14px; padding: 12px 10px 12px 18px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.spel__kod-etikett { grid-column: 1; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--dampad, #5f5b57); }
.spel__kod { grid-column: 1; grid-row: 2; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 600; font-size: 23px; letter-spacing: .08em; color: #000; overflow-wrap: anywhere; }
.spel__kopiera {
  grid-column: 2; grid-row: 1 / span 2; display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 16px;
  border: 0; border-radius: var(--radie-knapp, 10px); background: #000; color: #fff; cursor: pointer; font-family: var(--rubrikfont); font-weight: 500; font-size: 13px;
  transition: background-color .2s;
}
.spel__kopiera:hover { background: #2a2622; }
.spel__kopiera.kopierad { background: var(--ok, #137333); }
.spel__villkor { margin: 10px 0 -6px; font-size: 13.5px; line-height: 1.5; font-weight: 600; color: var(--text, #262626); }
.spel__mejl-info { margin: 0 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--dampad, #5f5b57); }
.spel__giltig { margin: 10px 0 14px; font-size: 13px; line-height: 1.5; color: var(--dampad, #5f5b57); }
.spel__nedrakning [data-spel-nedrakning] { color: #000; font-weight: 500; font-variant-numeric: tabular-nums; }
.spel__anvand { width: 100%; min-height: 50px; font-size: 15px; }
.spel__anvand.klar { --kb: var(--ok, #137333); background: var(--ok, #137333); border-color: var(--ok, #137333); color: #fff; cursor: default; transform: none; box-shadow: none; }
.spel__svar { margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: var(--ok, #137333); }
.spel__svar:empty { display: none; }
.spel__svar.fel { color: var(--fel, #b3261e); }

.spel__mejl { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid rgba(38, 38, 38, .12); text-align: left; }
.spel__mejl summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  font-family: var(--rubrikfont); font-weight: 500; font-size: 14px; text-decoration: underline; text-underline-offset: .25em;
}
.spel__mejl summary::-webkit-details-marker { display: none; }
.spel__mejl summary::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .25s; }
.spel__mejl[open] summary::after { transform: translateY(1px) rotate(-135deg); }
.spel__mejlform { padding: 8px 0 2px; }
.spel__etikett-text { display: block; font-size: 13px; margin: 0 0 4px; color: var(--dampad, #5f5b57); }
.spel__mejlrad { display: flex; gap: 8px; }
.spel__mejlrad .falt { flex: 1; min-width: 0; min-height: 44px; border-radius: var(--radie-knapp, 10px); padding: 8px 16px; }
.spel__mejlrad .knapp { flex: none; min-height: 44px; }
.spel__kryss { margin-top: 8px; font-size: 13px; }
.spel__kryss input { accent-color: #000; }
.spel__fortsatt {
  display: block; margin: 10px auto 2px; padding: 10px 14px; border: 0; background: none; cursor: pointer; color: #000;
  font-family: var(--rubrikfont); font-weight: 500; font-size: 14px; text-decoration: underline; text-underline-offset: .25em;
}

/* ---------- Mobil: bottenark ---------- */
@media (max-width: 749px) {
  .spel { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 94dvh; }
  .spel[open] { animation: spel-upp .5s var(--ease-ut, cubic-bezier(.16, 1, .3, 1)) both; }
  .spel.stanger { animation: spel-ned .25s ease-in both; }
  .spel__panel { border-radius: 22px 22px 0 0; padding: 18px 10px calc(8px + env(safe-area-inset-bottom)); max-height: 94dvh; }
  .spel__panel::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: rgba(0, 0, 0, .18); }
  .spel__stang { top: 34px; right: 26px; }
  .spel__panel { transition: transform .25s var(--ease-ut); }
  .spel__ram { padding: 16px 14px 12px; }
  .spel__logga { width: 44px; margin-bottom: 6px; }
  .spel__rubrik { font-size: 21px; margin-bottom: 12px; padding: 0 40px; }
  .spel__lott { height: 112px; }
  .spel__vinst-stor { font-size: 40px; }
  .spel__steg { padding: 14px 6px 4px; }
  .spel__kod { font-size: 20px; }
}
@keyframes spel-upp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes spel-ned { to { transform: translateY(100%); } }

/* ---------- Fliken "Skrapa & vinn" (med eget kryss för att dölja den för gott) ---------- */
.spel-flik {
  position: fixed; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 95;
  display: inline-flex; align-items: stretch; border-radius: var(--radie-knapp, 10px);
  border: 1px solid rgba(211, 192, 146, .6); background: #000; color: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .22); animation: spel-flik-in .6s var(--ease-ut, ease) both;
  transition: bottom .28s;
}
.spel-flik[hidden] { display: none; }
.spel-flik button { border: 0; background: none; color: inherit; cursor: pointer; font-family: var(--rubrikfont); }
.spel-flik__oppna {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px 0 14px;
  font-weight: 500; font-size: 13px; letter-spacing: .04em; border-radius: var(--radie-knapp, 10px) 0 0 var(--radie-knapp, 10px);
}
.spel-flik__dolj {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; min-height: 44px;
  border-left: 1px solid rgba(211, 192, 146, .3) !important; border-radius: 0 var(--radie-knapp, 10px) var(--radie-knapp, 10px) 0;
  color: rgba(255, 255, 255, .7) !important;
}
.spel-flik__dolj .ikon { width: 16px; height: 16px; }
.spel-flik__oppna:hover, .spel-flik__dolj:hover { background: #1b1814; color: #fff !important; }
.spel-flik button:focus-visible { outline: 2px solid var(--guld, #d3c092); outline-offset: -3px; }
.spel-flik__ikon { width: 18px; height: 18px; color: var(--guld, #d3c092); flex: none; }
@keyframes spel-flik-in { from { opacity: 0; transform: translateX(-24px); } }
body:has(.kopbar.synlig) .spel-flik { bottom: calc(84px + env(safe-area-inset-bottom)); }
body:has([data-samtycke]:not([hidden])) .spel-flik { display: none; }

/* ---------- Minskad rörelse ---------- */
@media (prefers-reduced-motion: reduce) {
  .spel[open], .spel.stanger, .spel[open]::backdrop, .spel.stanger::backdrop, .spel-flik, .spel__steg.in,
  .spel__lott.klar .spel__vinst-stor, .spel__lott.klar .spel__vinst-under, .spel__laddar i { animation: none !important; }
  .spel__lott.klar::after { display: none; }
  .spel__folie, .spel__lott, .spel__stang, .spel-flik { transition: none !important; }
}
