/* Storefront marketing add-ons: discount popup + age gate. Loaded on every
   themed AND default shop (see store/_extras.html) so it has to work with
   whatever the page's own CSS variables are — it never assumes store.css. A
   merchant's own colour pick (--sfx-bg/--sfx-text/--sfx-accent, set inline
   per popup) always wins over the theme's tokens, which win over the plain
   fallback at the end of each var() chain. Everything here is sfx- prefixed
   and does nothing at all until a [data-sfx-popup] / [data-sfx-age] loses its
   `hidden` attribute — zero layout impact when an add-on is off. */

[data-sfx-root] { all: initial; }

.sfx-popup, .sfx-age {
  font-family: var(--body, system-ui, sans-serif);
  color: var(--sfx-text, var(--ink, #221410));
}

.sfx-popup *, .sfx-age * { box-sizing: border-box; }

/* ── popup ─────────────────────────────────────────────────────────────── */

.sfx-popup { position: fixed; inset: 0; z-index: 2147483000; }
.sfx-popup[hidden] { display: none; }

.sfx-popup__backdrop {
  position: absolute; inset: 0; background: rgba(20, 18, 14, .5);
}

.sfx-popup__panel {
  position: relative; z-index: 1; margin: auto; max-width: 420px;
  max-height: calc(100vh - 32px); overflow: auto;
  background: var(--sfx-bg, var(--paper, #fff));
  border-radius: 14px;
  box-shadow: 0 8px 16px rgba(0,0,0,.12), 0 24px 48px rgba(0,0,0,.18);
  padding: 28px 24px 24px;
}
.sfx-corners-square .sfx-popup__panel { border-radius: 2px; }

/* Layout: centre (default), corner (bottom-right card), bottom bar (full-width strip) */
.sfx-layout-centre .sfx-popup__panel {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: calc(100% - 32px);
}
.sfx-layout-corner .sfx-popup__panel {
  position: fixed; right: 16px; bottom: 16px; left: auto; top: auto;
  width: min(360px, calc(100% - 32px)); margin: 0;
}
.sfx-layout-corner .sfx-popup__backdrop { background: transparent; pointer-events: none; }
.sfx-layout-bottom-bar .sfx-popup__panel {
  position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-width: none;
  width: 100%; border-radius: 14px 14px 0 0; margin: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
}
.sfx-layout-bottom-bar.sfx-corners-square .sfx-popup__panel { border-radius: 0; }
.sfx-layout-bottom-bar .sfx-popup__backdrop { background: transparent; pointer-events: none; }
.sfx-layout-bottom-bar .sfx-popup__img { display: none; }

.sfx-popup__x {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 999px; cursor: pointer;
  color: var(--sfx-text, var(--ink, #221410)); opacity: .6;
}
.sfx-popup__x:hover { opacity: 1; background: rgba(0,0,0,.06); }
.sfx-popup__x svg { width: 16px; height: 16px; }

.sfx-popup__img {
  display: block; width: 100%; max-height: 160px; object-fit: cover;
  border-radius: 10px; margin-bottom: 16px;
}
.sfx-corners-square .sfx-popup__img { border-radius: 2px; }

.sfx-popup__h {
  font-family: var(--display, inherit); font-size: 22px; font-weight: 700;
  line-height: 1.2; margin: 0 0 8px;
}
.sfx-popup__p { margin: 0 0 16px; font-size: 14.5px; line-height: 1.5; opacity: .85; }

.sfx-popup__form { display: flex; flex-direction: column; gap: 10px; }
.sfx-popup__label { font-size: 13px; font-weight: 600; }
.sfx-popup__input {
  width: 100%; padding: 11px 12px; font-size: 15px; font-family: inherit;
  border: 1.5px solid var(--line, #ddd); border-radius: 8px;
  background: #fff; color: #17171a;
}
.sfx-corners-square .sfx-popup__input,
.sfx-corners-square .sfx-popup__btn { border-radius: 2px; }
.sfx-popup__input:focus-visible { outline: 2px solid var(--sfx-accent, var(--accent, #0B6B43)); outline-offset: 1px; }

.sfx-popup__consent { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.4; }
.sfx-popup__consent input { margin-top: 3px; width: 16px; height: 16px; flex: none; }

.sfx-popup__err { color: #9B2C12; font-size: 13px; margin: 0; }
.sfx-popup__err[hidden] { display: none; }

.sfx-popup__btn {
  appearance: none; border: 0; cursor: pointer; padding: 12px 20px;
  font-size: 15px; font-weight: 600; font-family: inherit; border-radius: 999px;
  background: var(--sfx-accent, var(--accent, #0B6B43)); color: #fff;
  min-height: 44px;
}
.sfx-popup__btn:hover { filter: brightness(0.92); }
.sfx-popup__btn:focus-visible { outline: 2px solid var(--sfx-accent, var(--accent, #0B6B43)); outline-offset: 2px; }

.sfx-popup__coderow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sfx-popup__code {
  font-family: var(--mono, ui-monospace, monospace); font-size: 18px; font-weight: 700;
  letter-spacing: .04em; padding: 8px 14px; border: 1.5px dashed var(--line, #ccc);
  border-radius: 8px; background: rgba(0,0,0,.03);
}
.sfx-corners-square .sfx-popup__code { border-radius: 2px; }
.sfx-popup__copy {
  appearance: none; cursor: pointer; padding: 8px 14px; font-size: 13.5px; font-weight: 600;
  border-radius: 999px; border: 1.5px solid var(--sfx-accent, var(--accent, #0B6B43));
  background: transparent; color: var(--sfx-accent, var(--accent, #0B6B43));
  min-height: 40px;
}
.sfx-corners-square .sfx-popup__copy { border-radius: 2px; }
.sfx-popup__copy[data-copied]::after { content: " \2713"; }

/* ── age gate ──────────────────────────────────────────────────────────── */

.sfx-age {
  position: fixed; inset: 0; z-index: 2147483001;
  background: rgba(15, 14, 12, .92);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.sfx-age[hidden] { display: none; }
.sfx-age__panel {
  max-width: 420px; width: 100%; background: var(--paper, #fff);
  color: var(--ink, #221410); border-radius: 14px; padding: 28px 24px;
  text-align: center;
}
.sfx-age__h { font-family: var(--display, inherit); font-size: 22px; margin: 0 0 10px; }
.sfx-age__p { font-size: 14.5px; line-height: 1.5; opacity: .85; margin: 0 0 20px; }
.sfx-age__actions { display: flex; flex-direction: column; gap: 10px; }
.sfx-age__yes, .sfx-age__no {
  appearance: none; border: 0; cursor: pointer; padding: 12px 20px; font-size: 15px;
  font-weight: 600; font-family: inherit; border-radius: 999px; min-height: 44px;
}
.sfx-age__yes { background: var(--accent, #0B6B43); color: #fff; }
.sfx-age__no { background: transparent; color: var(--ink, #221410); box-shadow: inset 0 0 0 1.5px var(--line, #ccc); }
.sfx-age__yes:focus-visible, .sfx-age__no:focus-visible { outline: 2px solid var(--accent, #0B6B43); outline-offset: 2px; }

/* ── shared ────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  .sfx-popup__panel, .sfx-age__panel { animation: sfx-in .18s ease; }
}
@keyframes sfx-in { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 480px) {
  .sfx-popup__panel { padding: 22px 18px 18px; }
  .sfx-layout-corner .sfx-popup__panel { right: 8px; left: 8px; bottom: 8px; width: auto; }
}

/* ── dashboard live preview ────────────────────────────────────────────────
   dash/popup.html and dash/age_check.html render the SAME markup inside a
   bounded box instead of a full-page overlay, always visible, updated by a
   small script as the merchant types (never the trigger timers, never the
   seen/claim network calls, never localStorage — a preview must not count as
   a real impression or quietly suppress the real popup for the merchant's
   own browser next time they visit their own shop). Only `position` changes
   here; every colour/layout/corner rule above still applies unmodified. */
.sfx-previewbox {
  position: relative; min-height: 340px; overflow: hidden; border-radius: 10px;
  background: repeating-linear-gradient(45deg, #eee, #eee 10px, #e4e4e4 10px, #e4e4e4 20px);
}
.sfx-previewbox .sfx-popup, .sfx-previewbox .sfx-age { position: absolute; }
.sfx-previewbox .sfx-popup__backdrop { position: absolute; }
.sfx-previewbox .sfx-layout-centre .sfx-popup__panel,
.sfx-previewbox .sfx-layout-corner .sfx-popup__panel,
.sfx-previewbox .sfx-layout-bottom-bar .sfx-popup__panel { position: absolute; }

/* ── Countdown deal bar (store/_extras.html, static/deal.js) ───────────────
   A dark strip at the very top of the page that works on any theme; a theme
   restyles it through the --sfx-deal-* tokens or its own .sfx-deal rules. */
.sfx-deal {
  --sfx-deal-bg: #15130f; --sfx-deal-fg: #fff; --sfx-deal-seg: rgba(255, 255, 255, .1);
  --sfx-deal-tag: var(--accent, #2d6a4f); --sfx-deal-tag-fg: #fff;
  position: relative; z-index: 60; background: var(--sfx-deal-bg); color: var(--sfx-deal-fg);
  font-family: var(--body, system-ui, sans-serif);
  animation: sfx-deal-in .35s cubic-bezier(.2, .8, .2, 1);
}
.sfx-deal[hidden] { display: none; }
@keyframes sfx-deal-in { from { opacity: 0; transform: translateY(-100%); } }
.sfx-deal__in {
  max-width: 1200px; margin: 0 auto; min-height: 48px; box-sizing: border-box;
  padding: 7px 52px 7px 16px; display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 6px 16px;
}
.sfx-deal__tag {
  background: var(--sfx-deal-tag); color: var(--sfx-deal-tag-fg); border-radius: 4px;
  font: 700 11px/1 var(--body, system-ui, sans-serif); letter-spacing: .08em;
  text-transform: uppercase; padding: 6px 8px; white-space: nowrap;
}
.sfx-deal__text { margin: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; font-size: 14px; line-height: 1.3; }
.sfx-deal__offer { font-weight: 700; }
.sfx-deal__sub { opacity: .78; font-size: 13px; }
.sfx-deal__clock { display: flex; align-items: center; gap: 5px; }
.sfx-deal__ends { font-size: 12px; opacity: .78; margin-right: 3px; white-space: nowrap; }
.sfx-deal__seg {
  display: inline-flex; align-items: baseline; gap: 3px; background: var(--sfx-deal-seg);
  border-radius: 6px; padding: 5px 7px;
}
.sfx-deal__seg[hidden] { display: none; }
.sfx-deal__seg b { font: 700 16px/1 var(--mono, ui-monospace, monospace); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: center; }
.sfx-deal__seg i { font-style: normal; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; opacity: .72; }
.sfx-deal__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sfx-deal__x {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  background: none; border: 0; border-radius: 50%; color: inherit; opacity: .72; cursor: pointer;
}
.sfx-deal__x:hover { opacity: 1; background: rgba(255, 255, 255, .08); }
.sfx-deal__x:focus-visible { outline: 2px solid var(--sfx-deal-tag); outline-offset: 2px; opacity: 1; }
.sfx-deal__x svg { width: 16px; height: 16px; fill: none; }
.sfx-deal.is-ended .sfx-deal__clock, .sfx-deal.is-ended .sfx-deal__tag { display: none; }
@media (max-width: 599px) {
  .sfx-deal__in { padding: 8px 44px 8px 12px; gap: 6px 10px; }
  .sfx-deal__text { font-size: 13px; justify-content: center; text-align: center; }
  .sfx-deal__sub { font-size: 12px; }
  .sfx-deal__tag { display: none; }
  .sfx-deal__ends { display: none; }
  .sfx-deal__seg { padding: 4px 6px; }
  .sfx-deal__seg b { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { .sfx-deal { animation: none; } }
