/* Stand Picker (.co.uk) — front-end styles.
   UI chrome themes to the visitor's palette via CSS custom properties:
   --spk-accent, --spk-accent-2, --spk-accent-3 (set by JS from the extracted palette). */

.spk-app {
  --spk-accent: #2d6cdf;
  --spk-accent-2: #5b8def;
  --spk-accent-3: #1b3a6b;
  --spk-ink: #1d1d1f;
  --spk-muted: #6b6b70;
  --spk-line: rgba(0,0,0,.12);
  --spk-card-radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--spk-ink);
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  overflow-x: hidden; /* never let the picker create horizontal page scroll */
}
/* Padding/borders must count inside the width, or width:100% + padding overflows
   the screen on mobile (pushed the phone + title off to the right). */
.spk-app, .spk-app * { box-sizing: border-box; }
/* Make the HTML hidden attribute reliable even on flex elements (fixes the
   hero bleeding behind the deck — was overridden by display:flex). */
.spk-app [hidden] { display: none !important; }
/* The lightbox is portalled to <body> (out of .spk-app) so it can sit above the
   site header — re-assert hidden handling for it and its children there. */
.spk-lightbox[hidden], .spk-lightbox [hidden] { display: none !important; }

.spk-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* ---------- Phone (single, centred) ---------- */
.spk-phone {
  width: 100%;
  max-width: 620px;
  background: #111319;
  border-radius: 30px;
  padding: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
/* Drawer below the image (inside the phone): form, then loved tray */
.spk-drawer { margin-top: 12px; background: #fff; border-radius: 16px; padding: 12px; }

/* Mobile: let the picker be fully fluid so it fits the screen cleanly with no
   clipping or sideways scroll (the 620px cap only applies on wider screens). */
@media (max-width: 640px) {
  .spk-app { max-width: 100%; }
  .spk-phone { width: 100%; max-width: 100%; padding: 10px; border-radius: 22px; }
  .spk-drawer { padding: 10px; }
  /* Keep the overlaid controls and hint clear of the rounded edges on narrow screens. */
  .spk-deck-controls { padding: 0 14px; }
  .spk-deck-hint { left: 10px; right: 10px; bottom: 70px; font-size: 11px; }
}
/* Landscape phones are short (height < ~520px) but WIDE (so the ≤640 rule above
   doesn't apply). Keep the picker compact here too, or its elements balloon to the
   620px cap and the bigger backing stores crash iOS. */
@media (max-height: 520px) {
  .spk-phone { max-width: 480px; padding: 8px; }
  .spk-phone-screen { min-height: 160px; }
  .spk-brandbar { padding: 6px 10px; }
  .spk-brandbar-logo { width: 24px; height: 24px; }
  .spk-brand-logo img { max-height: 40px; max-width: 160px; }
  .spk-lb-img { height: 60vh; }
}

/* Title overlay on the first image */
.spk-title-overlay {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3; pointer-events: none;
  padding: 9px 12px 16px; text-align: center; color: #fff;
  background: linear-gradient(to bottom, rgba(0,0,0,.62), rgba(0,0,0,0));
}
.spk-title-overlay strong { display: block; font-size: 15px; font-weight: 800; letter-spacing: .3px; }
.spk-title-overlay strong span { font-weight: 500; opacity: .92; }
.spk-title-overlay small { display: block; margin-top: 1px; font-size: 10.5px; opacity: .92; }
.spk-phone-screen {
  position: relative;
  background: #f4f4f6;
  border-radius: 20px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  min-height: 240px;
  /* Critical on narrow phones: min-height + aspect-ratio would otherwise drive
     the WIDTH up (240 × 16/10 = 384px) and overflow the screen. Cap it. */
  max-width: 100%;
}

/* Brand bar */
.spk-brandbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,.96);
  /* No backdrop-filter: blur — it forces a full-width offscreen GPU buffer that
     is created the instant the brand bar appears (on URL entry) and crashed iOS
     in landscape. The near-opaque background reads the same. */
  border-bottom: 1px solid var(--spk-line);
}
.spk-brandbar-logo { width: 30px; height: 30px; object-fit: contain; border-radius: 5px; background:#fff; }
.spk-brandbar-text { display: flex; flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 5px; line-height: 1.15; }
.spk-brandbar-label { font-size: 10px; color: var(--spk-muted); }
.spk-brandbar-text strong { font-size: 13px; }
.spk-swatches { display: flex; gap: 5px; margin-left: auto; }
.spk-swatches span { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.1); }

/* Hero */
.spk-hero { position: absolute; inset: 0; display: flex; flex-direction: column; }
.spk-hero-img { flex: 1; background-size: cover; background-position: center; background-color:#e9e9ec; }
.spk-hero-hint {
  padding: 10px; text-align: center; font-size: 13px; color: var(--spk-muted);
  background: rgba(255,255,255,.9);
}

/* Deck */
.spk-deck { position: absolute; inset: 0; padding-top: 47px; }
.spk-cards { position: absolute; inset: 47px 14px 14px; }
.spk-card {
  position: absolute; inset: 0;
  border-radius: var(--spk-card-radius);
  overflow: hidden;
  background: #fff;
  background-size: cover; background-position: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.16);
  border: 1px solid var(--spk-line);
  touch-action: pan-y;
  cursor: grab;
}
.spk-card:active { cursor: grabbing; }
/* will-change only while actually dragging — applying it to every stacked card
   promotes dozens of GPU layers at once and crashes mobile browsers. */
.spk-card.spk-dragging { cursor: grabbing; will-change: transform; }
/* One-time nudge so the top card visibly invites a drag */
.spk-card.spk-nudge { animation: spk-nudge 1.5s ease 0.4s 2; }
@keyframes spk-nudge {
  0%, 100% { transform: translateX(0) rotate(0); }
  30% { transform: translateX(26px) rotate(4deg); }
  60% { transform: translateX(-20px) rotate(-3deg); }
}
.spk-card .spk-card-tint {
  position: absolute; inset: 0;
  /* Plain low-opacity wash instead of mix-blend-mode: blend modes force an
     offscreen compositing layer per card, which is expensive/crashy on mobile. */
  opacity: .12; pointer-events: none;
}
.spk-card .spk-card-badge {
  position: absolute; top: 10px; left: 10px;
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
  background: rgba(255,255,255,.85); color: var(--spk-accent-3);
  padding: 3px 8px; border-radius: 20px;
}
.spk-card.spk-gone-left  { transition: transform .3s ease, opacity .3s ease; transform: translateX(-140%) rotate(-14deg); opacity: 0; }
.spk-card.spk-gone-right { transition: transform .3s ease, opacity .3s ease; transform: translateX(140%) rotate(14deg); opacity: 0; }
.spk-stamp {
  position: absolute; top: 18px; font-size: 22px; font-weight: 800; letter-spacing: 1px;
  padding: 4px 12px; border: 3px solid; border-radius: 8px; opacity: 0; transition: opacity .1s;
  pointer-events: none;
}
.spk-stamp.spk-stamp-like { right: 16px; color: #16a34a; border-color: #16a34a; transform: rotate(12deg); }
.spk-stamp.spk-stamp-nope { left: 16px;  color: #dc2626; border-color: #dc2626; transform: rotate(-12deg); }

.spk-deck-empty {
  position: absolute; inset: 47px 14px 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; color: var(--spk-muted); font-size: 14px; padding: 0 16px;
}
.spk-empty-cta {
  border: none; cursor: pointer; padding: 13px 22px; border-radius: 12px;
  background: var(--spk-accent); color: #fff; font-size: 15px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.spk-empty-cta:hover { filter: brightness(1.06); }

/* Onboarding hint banner over the deck — tells users what to do */
.spk-deck-hint {
  position: absolute; bottom: 80px; left: 14px; right: 14px; z-index: 1100;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: rgba(17,19,25,.82); color: #fff;
  font-size: 12px; font-weight: 500; padding: 7px 10px; border-radius: 10px;
  pointer-events: none; transition: opacity .4s ease;
}
.spk-deck-hint.spk-hide { opacity: 0; }
.spk-deck-hint b { font-weight: 700; }

/* Swipe controls — overlaid on the image, inset clear of the rounded corners */
.spk-deck-controls {
  position: absolute; left: 0; right: 0; bottom: 16px; z-index: 1100;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 22px; pointer-events: none;
}
.spk-ctrl { display: flex; align-items: center; justify-content: center; pointer-events: auto; }
.spk-ctrl-label { display: none; } /* icons only when overlaid, to save room */
.spk-btn {
  width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; box-shadow: 0 4px 12px rgba(0,0,0,.18);
  background: #fff; transition: transform .12s ease;
}
.spk-btn:hover { transform: scale(1.06); }
.spk-btn:active { transform: scale(.92); }
.spk-nope { color: #dc2626; }
/* Love/heart button is always red so the white heart stays visible even when a
   brand's accent colour is white or very light. (Nav "Next" state overrides below.) */
.spk-like { color: #fff; background: #e11d48; }

/* Animated directional hints — bob the buttons until the user acts (super obvious) */
@keyframes spk-bob-l { 0%, 55%, 100% { transform: translateX(0); } 28% { transform: translateX(-7px) scale(1.05); } }
@keyframes spk-bob-r { 0%, 55%, 100% { transform: translateX(0); } 28% { transform: translateX(7px) scale(1.05); } }
.spk-deck-controls:not(.spk-acted) .spk-nope { animation: spk-bob-l 1.5s ease-in-out infinite; }
.spk-deck-controls:not(.spk-acted) .spk-like { animation: spk-bob-r 1.5s ease-in-out infinite; }

/* Browse (no details yet): neutral Next button + hide the love/skip stamps */
.spk-deck-controls.spk-nav .spk-like { background: #fff; color: var(--spk-ink); }
.spk-deck.spk-preview .spk-stamp { display: none; }

/* ---------- Love tray (in the light drawer) ---------- */
.spk-tray { margin-top: 12px; color: var(--spk-ink); border-top: 1px solid var(--spk-line); padding-top: 10px; }
.spk-tray-head { padding: 2px 4px 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.spk-tray-head #spk-tray-count { font-size: 12px; font-weight: 600; opacity: .9; }
.spk-tray-note { font-size: 11px; opacity: .72; text-align: right; }
.spk-tray-items {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; min-height: 8px;
}
.spk-love {
  position: relative; flex: 0 0 84px; height: 64px; border-radius: 10px; overflow: hidden;
  background: #2a2d36 center/cover; border: 1px solid rgba(255,255,255,.14);
  cursor: pointer;
}
.spk-love .spk-love-base, .spk-love .spk-love-branded {
  position: absolute; inset: 0; background-size: cover; background-position: center;
}
.spk-love .spk-love-branded { opacity: 0; transition: opacity .6s ease; }
.spk-love.spk-revealed .spk-love-branded { opacity: 1; }
.spk-love .spk-shimmer {
  position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%);
  background-size: 200% 100%; animation: spk-shim 1.1s linear infinite;
}
.spk-love.spk-revealed .spk-shimmer { display: none; }
@keyframes spk-shim { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.spk-tray-cta { display: flex; gap: 8px; margin-top: 6px; }
.spk-cta {
  flex: 1; border: none; cursor: pointer; padding: 10px; border-radius: 10px; font-weight: 600; font-size: 13px;
}
.spk-cta-book { background: var(--spk-accent); color: #fff; }
.spk-cta-tpl  { background: rgba(255,255,255,.16); color: #fff; }

/* ---------- Panel / form (now inside the phone drawer) ---------- */
.spk-panel { width: 100%; }
.spk-panel-toggle {
  flex: 0 0 auto; white-space: nowrap; border: 1px solid var(--spk-line); background: #fff; cursor: pointer;
  padding: 5px 10px; border-radius: 16px; font-size: 12px; font-weight: 600; color: var(--spk-ink);
}
.spk-panel-toggle:hover { background: #f4f4f6; }
/* Collapsed: hide the form so the loved tray takes the drawer; toggle stays as the expand button */
.spk-app.spk-collapsed .spk-panel-title,
.spk-app.spk-collapsed .spk-form,
.spk-app.spk-collapsed .spk-brand-logo { display: none; }
.spk-panel-title { font-size: 16px; margin: 0 0 12px; text-align: center; }
.spk-form { gap: 12px; }
.spk-form { display: flex; flex-direction: column; gap: 8px; }
.spk-field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--spk-muted); }
.spk-field input, .spk-field select {
  padding: 7px 9px; border: 1px solid var(--spk-line); border-radius: 8px; font-size: 13px; color: var(--spk-ink);
  background: #fff;
}
.spk-field input:focus, .spk-field select:focus { outline: 2px solid var(--spk-accent); border-color: transparent; }
.spk-row { display: flex; gap: 8px; flex-wrap: wrap; }
.spk-row .spk-field { flex: 1; min-width: 150px; }
.spk-submit {
  margin-top: 4px; padding: 13px; border: none; border-radius: 12px; cursor: pointer;
  background: var(--spk-accent); color: #fff; font-size: 16px; font-weight: 600;
  transition: filter .15s ease;
}
.spk-submit:hover { filter: brightness(1.05); }
.spk-submit:disabled { opacity: .6; cursor: default; }
.spk-status { font-size: 12px; min-height: 15px; margin: 2px 0 0; }
.spk-status.spk-err { color: #dc2626; }
.spk-status.spk-ok  { color: #16a34a; }
.spk-brand-logo { margin-top: 8px; }
/* Cap on BOTH axes (and an explicit pixel width, not 100%) so an SVG logo with no
   intrinsic raster size can't rasterise to a huge backing store — this was the
   landscape-on-URL-entry crash. */
.spk-brand-logo img { max-height: 56px; max-width: 200px; width: auto; height: auto; object-fit: contain; }
.spk-disclaimer { width: 100%; order: 5; font-size: 11px; color: var(--spk-muted); margin: 6px 0 0; }
.spk-tray-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.spk-tray-tip { margin: 0; font-size: 11px; opacity: .7; }

/* ---------- Lightbox ---------- */
.spk-lightbox { position: fixed; inset: 0; z-index: 99999; display: flex; align-items: center; justify-content: center; }
.spk-lb-backdrop { position: absolute; inset: 0; background: rgba(10,10,14,.82); }
.spk-lb-panel {
  position: relative; z-index: 1; width: min(1180px, 96vw); max-height: 96vh; overflow: auto;
  background: #15171d; color: #fff; border-radius: 16px; padding: 16px 16px 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.spk-lb-close {
  position: absolute; top: 10px; right: 12px; z-index: 3; width: 34px; height: 34px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.14); color: #fff; font-size: 15px; cursor: pointer;
}
.spk-lb-close:hover { background: rgba(255,255,255,.26); }
.spk-lb-stage { position: relative; display: flex; align-items: center; gap: 8px; }
.spk-lb-img { position: relative; flex: 1; aspect-ratio: 16 / 9; max-height: 74vh; background: #000; border-radius: 12px; }
/* Real <img> (not a background) so iOS handles zoom/decode efficiently and doesn't
   crash building a huge backing store for a full-screen element. */
.spk-lb-photo { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; object-fit: contain; border-radius: 12px; display: block; }
.spk-lb-cost {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 16px 16px 12px; text-align: center;
  background: linear-gradient(to top, rgba(0,0,0,.78), rgba(0,0,0,0));
  color: #fff; font-size: 17px; font-weight: 800; border-radius: 0 0 12px 12px; letter-spacing: .2px;
}
.spk-lb-cost small { display: block; margin-top: 2px; font-size: 11px; font-weight: 500; opacity: .85; letter-spacing: .3px; }
.spk-lb-cost .spk-lb-disc { display: block; margin-top: 3px; font-size: 9.5px; font-weight: 400; opacity: .7; letter-spacing: 0; }
/* Info overlay — a translucent card over the image (stand still partly visible) */
.spk-lb-info {
  position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center;
  padding: 16px; border-radius: 12px; background: rgba(8,10,16,.74);
}
.spk-lb-info-body {
  max-width: 560px; max-height: 100%; overflow: auto; color: #fff; font-size: 14px; line-height: 1.5;
  background: rgba(18,20,28,.82); border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: 18px 20px;
}
.spk-lb-info-body h4 { margin: 14px 0 6px; font-size: 15px; font-weight: 700; color: #c9ccd4; }
.spk-lb-info-body h4:first-child { margin-top: 0; }
.spk-lb-info-body ul { margin: 4px 0 10px; padding-left: 18px; }
.spk-lb-info-body li { margin: 3px 0; }
.spk-lb-info-body a { color: #fff; }
.spk-lb-info-close {
  position: absolute; top: 8px; right: 10px; z-index: 7; width: 32px; height: 32px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.18); color: #fff; font-size: 14px; cursor: pointer;
}
.spk-lb-info-close:hover { background: rgba(255,255,255,.3); }
.spk-lb-nav {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.16); color: #fff; font-size: 22px; line-height: 1;
}
.spk-lb-nav:hover { background: rgba(255,255,255,.3); }
.spk-lb-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 10px 2px 12px; font-size: 12px; opacity: .85; }
.spk-lb-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.spk-lb-act {
  flex: 1 1 0; min-width: 120px; text-align: center;
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: #fff;
  padding: 11px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; line-height: 1.2;
}
.spk-lb-act:hover { background: rgba(255,255,255,.16); }
.spk-lb-primary { background: var(--spk-accent); border-color: transparent; }
.spk-lb-danger { color: #ff8a8a; border-color: rgba(255,138,138,.4); background: transparent; }
.spk-lb-status { min-height: 16px; font-size: 12px; margin: 10px 2px 0; opacity: .9; }

@media (max-width: 620px) {
  /* Lightbox on mobile: give the image real height and stop the price overlay +
     button grid from swamping it. */
  .spk-lb-panel { padding: 12px 12px 14px; max-height: 94vh; }
  .spk-lb-img { aspect-ratio: auto; height: 48vh; min-height: 200px; }
  .spk-lb-cost { padding: 10px 12px 8px; font-size: 13px; }
  .spk-lb-cost small { font-size: 10px; margin-top: 1px; }
  .spk-lb-cost .spk-lb-disc { display: none; } /* drop the tiny print on mobile */
  .spk-lb-nav { width: 32px; height: 32px; font-size: 18px; }
  .spk-lb-meta { margin: 8px 2px 8px; }
  .spk-lb-actions { gap: 6px; }
  .spk-lb-act { flex: 1 1 calc(50% - 6px); min-width: 0; padding: 9px 6px; font-size: 12px; }
}
