/*
 * The product tour: the "See it working" section's animated overview.
 *
 * This replaces the theme kit's stock showreel. The page used to offer a play
 * button over a poster that opened a lightbox onto a video shot for a fitness
 * app -- a demo of a product that is not this one. Rather than ship a poster
 * with nothing behind it, the button now opens a tour built out of the real
 * application's own interface: the same sidebar, the same eight stat tiles in
 * the same order as Dashboard.vue, the same figures the demo store reports.
 *
 * Why markup and not a recording:
 *
 *   sharp     it is vector and text, so it is exact at any size and on any
 *             display, where a 1080p capture is soft the moment the frame is
 *             wider than 1080px
 *   small     a few KB against tens of MB, with no encode, no CDN and no
 *             third-party player loading a tracker onto the landing page
 *   true      it reads the product's actual labels and ordering, so it cannot
 *             drift away from the app the way a recording does the first time
 *             a screen is redesigned
 *   legible   captions are real text: selectable, translatable and indexed
 *
 * Everything is scoped to .bk-tour or .landing so none of it can reach the
 * application's own styling, and every size inside the stage is set in `em`
 * off a container-query root -- so the whole scene scales as one piece and the
 * layout is identical at 380px and at 1600px.
 *
 * Pairs with assets/js/tour.js, which drives the timeline.
 */

.landing {
  --tour-ink: #131a2f;
  --tour-body: #5a6480;
  --tour-faint: #8b95ad;
  --tour-line: #e7eaf3;
  --tour-wash: #f7f8fc;
  --tour-brand: #17255c;
  --tour-accent: #f28c38;
  --tour-violet: #6d28d9;
  --tour-blue: #1677ff;
  --tour-green: #16a34a;
  --tour-red: #e5484d;
  --tour-amber: #fa8c16;
}

/* ─── The trigger ───────────────────────────────────────────────────────
   The poster keeps its frame; the button sits over it. The whole figure is
   the hit area -- a 3.5rem circle is a small target on a phone, and there is
   nothing else on the poster to click. */

.landing .tour-trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  position: relative;
  border-radius: var(--bk-radius-lg, 22px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.landing .tour-trigger figure {
  margin: 0;
  overflow: hidden;
  border-radius: var(--bk-radius-lg, 22px);
}
.landing .tour-trigger img {
  display: block;
  width: 100%;
  transition: transform 620ms cubic-bezier(0.22, 1, 0.36, 1);
}
.landing .tour-trigger:hover img { transform: scale(1.022); }

/* A wash over the poster so white type and the button hold their contrast.
   Darker at the foot, where the caption sits. */
.landing .tour-trigger::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--bk-radius-lg, 22px);
  background: linear-gradient(180deg,
    rgba(19, 26, 47, 0.55) 0%,
    rgba(19, 26, 47, 0.42) 45%,
    rgba(19, 26, 47, 0.80) 100%);
  transition: opacity 320ms ease;
  pointer-events: none;
}
.landing .tour-trigger:hover::after { opacity: 0.82; }

.landing .tour-trigger-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  z-index: 2;
  pointer-events: none;
}

/* The button. Two rings pulse out of it on a long cycle -- enough to catch the
   eye once as the section scrolls in, not enough to nag. */
.landing .tour-play {
  position: relative;
  width: 5.25rem;
  height: 5.25rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--tour-brand);
  box-shadow: 0 18px 45px -14px rgba(19, 26, 47, 0.55);
  transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1), background 220ms ease, color 220ms ease;
}
.landing .tour-play svg {
  width: 1.6rem;
  height: 1.6rem;
  margin-left: 0.22rem;
  fill: currentColor;
}
.landing .tour-trigger:hover .tour-play {
  transform: scale(1.09);
  background: var(--tour-accent);
  color: #fff;
}
.landing .tour-trigger:focus-visible { outline: none; }
.landing .tour-trigger:focus-visible .tour-play {
  outline: 3px solid #fff;
  outline-offset: 5px;
}
.landing .tour-play::before,
.landing .tour-play::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  animation: tour-pulse 3.6s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}
.landing .tour-play::after { animation-delay: 1.8s; }

@keyframes tour-pulse {
  0%        { transform: scale(1);    opacity: 0.85; }
  55%, 100% { transform: scale(1.75); opacity: 0; }
}

.landing .tour-trigger-label {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 14px rgba(19, 26, 47, 0.5);
}
.landing .tour-trigger-meta {
  position: absolute;
  left: 1.75rem;
  bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.landing .tour-trigger-meta .dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--tour-accent);
}

@media (max-width: 575px) {
  .landing .tour-play { width: 4rem; height: 4rem; }
  .landing .tour-play svg { width: 1.2rem; height: 1.2rem; }
  .landing .tour-trigger-label { font-size: 0.9rem; }
  .landing .tour-trigger-meta { left: 1rem; bottom: 1rem; font-size: 0.72rem; }
}


/* ─── The lightbox ──────────────────────────────────────────────────────
   Its own dialog rather than the theme's GLightbox: the tour has to be told
   when it becomes visible so the timeline starts from the top and stops when
   the panel closes, and the bought plugin gives no hook for that. */

.bk-tour {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: clamp(0.75rem, 3vw, 2.5rem);
  background: rgba(11, 16, 32, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 280ms ease, visibility 280ms;
}
.bk-tour.is-open { opacity: 1; visibility: visible; }

.bk-tour-panel {
  width: min(1180px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: #0f1530;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 50px 120px -40px rgba(0, 0, 0, 0.85);
  transform: translateY(18px) scale(0.985);
  opacity: 0;
  transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1), opacity 320ms ease;

  /* The size container for the stage inside it. It has to live here and not on
     the stage itself: an element cannot query its own size, so a font-size in
     `cqi` set on the stage would look past it for an ancestor container, find
     none, and silently fall back to viewport units -- which drift away from the
     panel's width as soon as the two stop being proportional. The panel's width
     is explicit, so containing its inline axis costs nothing. */
  container-type: inline-size;
}
.bk-tour.is-open .bk-tour-panel { transform: none; opacity: 1; }

.bk-tour-close {
  position: absolute;
  top: clamp(0.5rem, 2vw, 1.4rem);
  right: clamp(0.5rem, 2vw, 1.4rem);
  width: 2.6rem;
  height: 2.6rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
  transition: background 180ms ease, transform 180ms ease;
}
.bk-tour-close:hover { background: rgba(255, 255, 255, 0.24); transform: rotate(90deg); }
.bk-tour-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ─── The stage ─────────────────────────────────────────────────────────
   A 16:9 box that is its own container-query root. Every length inside the
   mock application is set in `em` against the font-size below, so one line
   governs the scale of the entire scene and the layout never reflows -- it
   only shrinks. `cqi` is the real unit; the `vw` above it is the fallback for
   engines without container queries, where the panel is near enough full width
   for that to land in the right place. */

.bk-tour-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  background: var(--tour-wash, #f7f8fc);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 1.12vw;
}
@supports (font-size: 1cqi) {
  .bk-tour-stage { font-size: 1.30cqi; }
}

/* ─── Mock application chrome ───────────────────────────────────────────
   Constant across every chapter, so the tour reads as one session moving
   through one product rather than as five unrelated pictures. Only the active
   sidebar row and the panel on the right change. */

.tw-app {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 15.5em 1fr;
  background: #fff;
  color: var(--tour-ink);
}

.tw-side {
  border-right: 1px solid var(--tour-line);
  padding: 1.15em 0.85em;
  display: flex;
  flex-direction: column;
  gap: 0.9em;
  background: #fff;
}
.tw-brand { display: flex; align-items: center; gap: 0.6em; padding: 0 0.35em; }
.tw-brand-mark {
  width: 1.9em;
  height: 1.9em;
  border-radius: 0.55em;
  background: var(--tour-brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.95em;
  position: relative;
  flex: none;
}
.tw-brand-mark::after {
  content: '';
  position: absolute;
  top: 0.25em;
  right: 0.25em;
  width: 0.32em;
  height: 0.32em;
  border-radius: 50%;
  background: var(--tour-accent);
}
.tw-brand-name {
  font-weight: 700;
  font-size: 0.92em;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tw-search {
  display: flex;
  align-items: center;
  gap: 0.5em;
  border: 1px solid var(--tour-line);
  border-radius: 0.55em;
  padding: 0.5em 0.7em;
  color: var(--tour-faint);
  font-size: 0.82em;
}
.tw-nav { display: flex; flex-direction: column; gap: 0.12em; }
.tw-nav-item {
  display: flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.6em 0.75em;
  border-radius: 0.55em;
  font-size: 0.86em;
  font-weight: 500;
  color: var(--tour-body);
  position: relative;
  transition: background 260ms ease, color 260ms ease;
}
.tw-nav-item .ic {
  width: 1.05em;
  height: 1.05em;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
}
.tw-nav-item.is-on {
  background: #f3f0fe;
  color: var(--tour-violet);
  font-weight: 600;
}
.tw-nav-item.is-on .ic { opacity: 1; }

.tw-main { display: flex; flex-direction: column; min-width: 0; background: var(--tour-wash); }
.tw-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  padding: 0.85em 1.35em;
  border-bottom: 1px solid var(--tour-line);
  background: #fff;
}
.tw-greet { font-size: 1.05em; font-weight: 700; letter-spacing: -0.02em; }
.tw-sub { font-size: 0.76em; color: var(--tour-faint); margin-top: 0.15em; }
.tw-top-right { display: flex; align-items: center; gap: 0.6em; flex: none; }
.tw-chip {
  font-size: 0.74em;
  font-weight: 600;
  color: var(--tour-body);
  padding: 0.38em 0.75em;
  border-radius: 0.45em;
  transition: background 260ms ease, color 260ms ease;
}
.tw-chip.is-on { background: #f3f0fe; color: var(--tour-violet); }
.tw-avatar {
  width: 1.65em;
  height: 1.65em;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tour-violet), var(--tour-blue));
}
.tw-body { position: relative; flex: 1; min-height: 0; }


/* ─── Scenes ────────────────────────────────────────────────────────────
   One per chapter, stacked in the same box. Only the live one is painted;
   the rest are hidden from the accessibility tree too, so a screen reader
   is not read five overlapping screens at once. */

.tw-scene {
  position: absolute;
  inset: 0;
  padding: 1.1em 1.35em;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.6em);
  transition: opacity 380ms ease, transform 480ms cubic-bezier(0.22, 1, 0.36, 1), visibility 380ms;
  display: flex;
  flex-direction: column;
  gap: 0.85em;
  overflow: hidden;
}
.tw-scene.is-live { opacity: 1; visibility: visible; transform: none; }
.tw-scene { justify-content: center; }

/* The stagger primitive. Anything carrying `.r` starts low and faded and is
   lifted in when its scene goes live; `--d` is its delay in milliseconds, so
   a scene's choreography is written in the markup next to the thing it
   describes rather than as thirty numbered rules down here. */
.tw-scene .r { opacity: 0; }
.tw-scene.is-live .r {
  animation: tw-rise 560ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--d, 0) * 1ms);
}
@keyframes tw-rise {
  from { opacity: 0; transform: translateY(0.7em); }
  to   { opacity: 1; transform: none; }
}

/* Shared furniture */
.tw-card {
  background: #fff;
  border: 1px solid var(--tour-line);
  border-radius: 0.7em;
  padding: 0.85em 0.95em;
}
.tw-card-t {
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--tour-ink);
  margin-bottom: 0.7em;
}
.tw-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-size: 0.68em;
  font-weight: 700;
  padding: 0.25em 0.6em;
  border-radius: 1em;
  letter-spacing: 0.01em;
}
.tw-pill.ok  { background: rgba(22, 163, 74, 0.12);  color: var(--tour-green); }
.tw-pill.due { background: rgba(250, 140, 22, 0.14); color: #b45309; }
.tw-pill.low { background: rgba(229, 72, 77, 0.12);  color: var(--tour-red); }

/* ── Chapter 1: the dashboard ──
   The eight stat tiles, in the order Dashboard.vue builds them, with the
   demo store's own figures. The values are counted up by tour.js. */

.sc-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6em;
}
.kpi {
  background: #fff;
  border: 1px solid var(--tour-line);
  border-radius: 0.65em;
  padding: 0.7em 0.8em;
  display: flex;
  align-items: center;
  gap: 0.65em;
}
.kpi-ic {
  width: 1.9em;
  height: 1.9em;
  border-radius: 0.5em;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--tint, rgba(109, 40, 217, 0.12));
}
.kpi-ic svg { width: 0.95em; height: 0.95em; stroke: var(--tone, var(--tour-violet)); fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.kpi-l { font-size: 0.68em; color: var(--tour-faint); font-weight: 500; }
.kpi-v { font-size: 0.92em; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.sc-charts { display: grid; grid-template-columns: 1.85fr 1fr; gap: 0.6em; flex: 1; min-height: 0; }
.tw-plot { display: flex; align-items: flex-end; gap: 0.75em; height: 100%; padding-top: 0.3em; }
.tw-grp { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 0.26em; height: 100%; }
/* A baseline, so the bars stand on something rather than float. */
.tw-plot { border-bottom: 1px solid var(--tour-line); }
.tw-bar {
  width: 1.05em;
  border-radius: 0.18em 0.18em 0 0;
  height: 0;
  background: var(--tour-violet);
  transition: height 900ms cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: calc(var(--d, 0) * 1ms);
}
.tw-bar.b2 { background: #67d3f5; }
.tw-scene.is-live .tw-bar { height: var(--h); }

.tw-donut { display: grid; place-items: center; height: 100%; }
.tw-donut svg { width: 78%; max-height: 100%; transform: rotate(-90deg); }
.tw-donut circle { fill: none; stroke-width: 7; stroke-dasharray: var(--len) 999; stroke-dashoffset: var(--len); transition: stroke-dashoffset 1000ms cubic-bezier(0.22, 1, 0.36, 1); transition-delay: calc(var(--d, 0) * 1ms); }
.tw-scene.is-live .tw-donut circle { stroke-dashoffset: 0; }


/* ── Chapter 2: raising an invoice ── */
.sc-inv { display: grid; grid-template-columns: 1.9fr 1fr; gap: 0.6em; min-height: 0; }
.tw-tbl { width: 100%; border-collapse: collapse; font-size: 0.74em; }
.tw-tbl th {
  text-align: left;
  font-weight: 600;
  color: var(--tour-faint);
  font-size: 0.9em;
  padding: 0 0.5em 0.5em;
  border-bottom: 1px solid var(--tour-line);
}
.tw-tbl td { padding: 0.5em; border-bottom: 1px solid #f2f4fa; }
.tw-tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tw-tbl .nm { font-weight: 600; color: var(--tour-ink); }

.tw-sum { display: flex; justify-content: space-between; font-size: 0.76em; padding: 0.4em 0; }
.tw-sum.tot {
  border-top: 1px solid var(--tour-line);
  margin-top: 0.3em;
  padding-top: 0.6em;
  font-size: 0.95em;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.tw-sum span:first-child { color: var(--tour-faint); }
.tw-sum.tot span:first-child { color: var(--tour-ink); }

/* The stamp lands late and overshoots slightly, the way a rubber stamp does. */
.inv-stamp {
  align-self: center;
  margin-top: 0.9em;
  border: 0.18em solid var(--tour-green);
  color: var(--tour-green);
  border-radius: 0.4em;
  padding: 0.25em 0.85em;
  font-size: 0.95em;
  font-weight: 800;
  letter-spacing: 0.12em;
  opacity: 0;
}
.tw-scene.is-live .inv-stamp {
  animation: tw-stamp 620ms cubic-bezier(0.3, 1.4, 0.5, 1) both;
  animation-delay: calc(var(--d, 0) * 1ms);
}
@keyframes tw-stamp {
  0%   { opacity: 0; transform: scale(2.1) rotate(-24deg); }
  60%  { opacity: 1; transform: scale(0.93) rotate(-8deg); }
  100% { opacity: 1; transform: scale(1) rotate(-8deg); }
}

/* ── Chapter 3: stock ── */
.lvl {
  display: block;                 /* a <span> is inline, and height does not apply to one */
  height: 0.4em;
  border-radius: 1em;
  background: #eef1f8;
  overflow: hidden;
  margin-top: 0.35em;
}
.lvl i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--tone, var(--tour-green));
  transition: width 850ms cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: calc(var(--d, 0) * 1ms);
}
.tw-scene.is-live .lvl i { width: var(--w); }

/* ── Chapter 4: procurement ── */
.tw-steps { display: flex; align-items: flex-start; gap: 0; margin-top: 0.2em; }
.tw-step { flex: 1; text-align: center; position: relative; font-size: 0.72em; color: var(--tour-faint); }
.tw-step::before {
  content: '';
  position: absolute;
  top: 0.72em;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--tour-line);
}
.tw-step:first-child::before { display: none; }
.tw-step .dot {
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--tour-line);
  margin: 0 auto 0.45em;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
  transition: background 320ms ease, border-color 320ms ease, transform 320ms ease;
  transition-delay: calc(var(--d, 0) * 1ms);
}
.tw-step .dot svg { width: 0.8em; height: 0.8em; stroke: #fff; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity 260ms ease calc(var(--d, 0) * 1ms + 140ms); }
.tw-scene.is-live .tw-step.done .dot { background: var(--tour-green); border-color: var(--tour-green); }
.tw-scene.is-live .tw-step.done .dot svg { opacity: 1; }
.tw-scene.is-live .tw-step.done { color: var(--tour-ink); font-weight: 600; }

/* ── Chapter 5: the books ──
   The rule under the trial balance draws itself, then the totals agree. */
.tw-ledger { display: grid; grid-template-columns: 1fr auto auto; gap: 0.35em 1.1em; font-size: 0.74em; }
.tw-ledger .h { color: var(--tour-faint); font-weight: 600; font-size: 0.9em; }
.tw-ledger .num { text-align: right; font-variant-numeric: tabular-nums; }
.tw-ledger .tt { font-weight: 800; border-top: 1px solid var(--tour-line); padding-top: 0.4em; margin-top: 0.2em; }
.tw-balanced {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  margin-top: 0.7em;
  font-size: 0.74em;
  font-weight: 700;
  color: var(--tour-green);
  opacity: 0;
}
.tw-scene.is-live .tw-balanced {
  animation: tw-rise 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--d, 0) * 1ms);
}


/* ─── End card ──────────────────────────────────────────────────────────
   Shown after the last chapter, over the stage. A tour that simply stops is
   a dead end; this is the one place the tour asks for something. */
.tw-end {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9em;
  text-align: center;
  background: radial-gradient(120% 120% at 50% 0%, #24337a 0%, #0f1530 62%);
  color: #fff;
  opacity: 0;
  visibility: hidden;
  transition: opacity 460ms ease, visibility 460ms;
}
.tw-end.is-live { opacity: 1; visibility: visible; }
.tw-end h3 { color: #fff; font-size: 2.1em; font-weight: 800; letter-spacing: -0.03em; margin: 0; }
.tw-end p { color: rgba(255, 255, 255, 0.72); font-size: 0.92em; margin: 0; max-width: 26em; }
.tw-end-actions { display: flex; gap: 0.6em; margin-top: 0.4em; flex-wrap: wrap; justify-content: center; }
.tw-end-btn {
  font-size: 0.86em;
  font-weight: 700;
  padding: 0.7em 1.5em;
  border-radius: 0.55em;
  border: 0;
  cursor: pointer;
  background: var(--tour-accent);
  color: #fff;
  text-decoration: none;
  transition: transform 180ms ease, background 180ms ease;
}
.tw-end-btn:hover { transform: translateY(-2px); background: #dd7a26; color: #fff; }
.tw-end-btn.ghost { background: rgba(255, 255, 255, 0.12); }
.tw-end-btn.ghost:hover { background: rgba(255, 255, 255, 0.2); }

/* ─── Transport ─────────────────────────────────────────────────────────
   Progress, caption and controls, on the dark ground under the stage. The
   segments are the chapter list: each is a button, so the tour can be read
   out of order the way a reader who only cares about stock would want. */

.bk-tour-track { display: flex; gap: 0.25rem; padding: 0 1.1rem; background: #0f1530; }
.bk-tour-seg {
  flex: 1;
  height: 3px;
  border: 0;
  padding: 0;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
  overflow: hidden;
  position: relative;
}
.bk-tour-seg i {
  position: absolute;
  inset: 0;
  transform-origin: left;
  transform: scaleX(0);
  background: var(--tour-accent);
  border-radius: inherit;
}
.bk-tour-seg.done i { transform: scaleX(1); }
.bk-tour-seg.now i { animation: tw-fill linear forwards; animation-duration: var(--dur, 9s); }
.bk-tour.is-paused .bk-tour-seg.now i { animation-play-state: paused; }
@keyframes tw-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.bk-tour-seg:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.bk-tour-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.1rem 1rem;
  background: #0f1530;
  color: #fff;
}
.bk-tour-cap { flex: 1; min-width: 0; }
.bk-tour-kick {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tour-accent);
}
.bk-tour-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin-top: 0.1rem;
}
.bk-tour-note { font-size: 0.8rem; color: rgba(255, 255, 255, 0.6); margin-top: 0.1rem; }
.bk-tour-cap.swap { animation: tw-cap 420ms ease both; }
@keyframes tw-cap { from { opacity: 0; transform: translateY(0.4rem); } to { opacity: 1; transform: none; } }

.bk-tour-ctl { display: flex; align-items: center; gap: 0.35rem; flex: none; }
.bk-tour-btn {
  width: 2.2rem;
  height: 2.2rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 180ms ease;
}
.bk-tour-btn:hover { background: rgba(255, 255, 255, 0.22); }
.bk-tour-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.bk-tour-btn svg { width: 0.95rem; height: 0.95rem; fill: currentColor; }
.bk-tour-btn .ico-pause { display: none; }
.bk-tour:not(.is-paused) .bk-tour-btn .ico-pause { display: block; }
.bk-tour:not(.is-paused) .bk-tour-btn .ico-play { display: none; }

/* ─── Small screens ─────────────────────────────────────────────────────
   The sidebar is dead weight under about 700px, so it goes and the scenes get
   the room. The stage also stops being 16:9 here: a phone is portrait, and a
   16:9 box across a 380px screen is barely 210px tall, which is not enough to
   land the line each chapter is built around. */
@media (max-width: 700px) {
  .tw-app { grid-template-columns: 1fr; }
  .tw-side { display: none; }

  /* Portrait has height to spare and width to lose, so the stage gets taller
     rather than the type getting smaller. At 3/4 the scenes were still
     clipping their last row -- the PAID stamp, the change due, the "in
     balance" tick -- which are exactly the lines that make the point. */
  .bk-tour-stage { aspect-ratio: 2 / 3; font-size: 2.9vw; }
  @supports (font-size: 1cqi) { .bk-tour-stage { font-size: 3.05cqi; } }

  .sc-kpis { grid-template-columns: repeat(2, 1fr); }
  .sc-charts, .sc-inv { grid-template-columns: 1fr; }
  .tw-scene { padding: 0.8em 0.9em; gap: 0.6em; }

  /* Sized by height, not width: the charts stack on a phone, and a donut set
     as a share of a full-width card is tall enough on its own to push the end
     of the scene off the stage. */
  .tw-donut { max-height: 7.5em; }
  .tw-donut svg { width: auto; height: 100%; }

  /* Supporting detail, dropped so the point of each chapter still fits: the
     catalogue reads the same at six tiles as at twelve, and the panels marked
     m-hide are context rather than the thing being shown. */
  .pos-tile:nth-child(n + 7) { display: none; }
  .m-hide { display: none; }

  /* The transport is set in rem, so it does not shrink with the stage and
     starts to crowd it. */
  .bk-tour-note { display: none; }
  .bk-tour-panel { border-radius: 12px; }
  .bk-tour-bar { padding: 0.6rem 0.7rem 0.7rem; gap: 0.6rem; }
  .bk-tour-track { padding: 0 0.7rem; }
  .bk-tour-kick { font-size: 0.56rem; letter-spacing: 0.1em; }
  .bk-tour-title { font-size: 0.88rem; }
  .bk-tour-btn { width: 1.85rem; height: 1.85rem; }
  .bk-tour-btn svg { width: 0.78rem; height: 0.78rem; }
  .bk-tour-ctl { gap: 0.25rem; }
  .tw-end h3 { font-size: 1.5em; }
}

/* A short phone in portrait -- an SE, or any handset with its browser chrome
   showing -- cannot be given the full 2:3, because the panel's max-height wins
   and the stage is squeezed under it. Everything inside is sized in `em` off
   one root, so the whole scene is simply drawn a tenth smaller and keeps its
   proportions exactly. This only adjusts that root. */
@media (max-width: 700px) and (max-height: 700px) {
  .bk-tour-stage { font-size: 2.6vw; }
  @supports (font-size: 1cqi) { .bk-tour-stage { font-size: 2.72cqi; } }
}

/* ─── Motion ────────────────────────────────────────────────────────────
   With reduced motion asked for, nothing moves and nothing advances by
   itself: every scene is drawn in its finished state and the reader steps
   through the chapters with the buttons. The tour still works -- it just
   stops being a film. */
@media (prefers-reduced-motion: reduce) {
  .landing .tour-play::before,
  .landing .tour-play::after { animation: none; opacity: 0; }
  .bk-tour, .bk-tour-panel, .tw-scene { transition-duration: 0.001ms !important; }
  .tw-scene.is-live .r,
  .tw-scene.is-live .inv-stamp,
  .tw-scene.is-live .tw-balanced { animation: none; opacity: 1; transform: none; }
  .tw-bar, .tw-donut circle, .lvl i, .tw-step .dot, .tw-step .dot svg { transition-duration: 0.001ms !important; transition-delay: 0ms !important; }
  .bk-tour-seg.now i { animation: none; transform: scaleX(1); }
  .bk-tour-cap.swap { animation: none; }
}


/* ─── Addenda ───────────────────────────────────────────────────────────
   Corrections and helpers that belong with the pieces above but read more
   clearly collected than scattered through them. */

/* The caption sits over the poster's wash, which is a pseudo-element and so
   paints after the button's children unless it is lifted. */
.landing .tour-trigger-meta { z-index: 2; }

/* Two panels side by side -- chapters 4 and 5. */
.sc-two {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 0.6em;
  min-height: 0;
}

/* Cards inside a scene's grid have to be told to fill it and to allow their
   own contents to shrink, or a long table pushes the stage out of 16:9. */
.sc-charts .tw-card,
.sc-inv .tw-card,
.sc-two .tw-card,
.tw-scene > [data-fill] {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* The bars have no intrinsic height of their own -- they are percentages of
   this box. Where the grid row is sized by its content (a phone, where the two
   charts stack) that leaves the box at zero and the chart renders as a bare
   axis, so it needs a floor as well as a share of the space. */
.tw-plot { flex: 1; min-height: 5.5em; }

/* Paused means paused: the transport, and anything still animating on stage.
   Transitions cannot be held this way, but they are all under a second, so by
   the time anyone reaches for the button they have finished. */
.bk-tour.is-paused .tw-scene *,
.bk-tour.is-paused .tw-scene {
  animation-play-state: paused;
}

@media (max-width: 700px) {
  .sc-two { grid-template-columns: 1fr; }
}

/* Stock value, three abreast under the product table (chapter 3). */
.sc-stock { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1.4em; }
@media (max-width: 700px) { .sc-stock { grid-template-columns: 1fr; } }


/* ─── Chapter: the counter ──────────────────────────────────────────────
   Catalogue on the left, cart on the right, the way a register is laid out. */
.sc-pos { display: grid; grid-template-columns: 1.35fr 1fr; gap: 0.6em; min-height: 0; }
.pos-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4em; }
.pos-tile {
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  border: 1px solid var(--tour-line);
  border-radius: 0.5em;
  padding: 0.5em 0.55em;
  font-size: 0.68em;
  color: var(--tour-faint);
  background: #fff;
}
.pos-tile b {
  font-size: 1.02em;
  font-weight: 600;
  color: var(--tour-ink);
  line-height: 1.25;
}
.pos-done {
  display: flex;
  align-items: center;
  gap: 0.35em;
  margin-top: 0.7em;
  font-size: 0.72em;
  font-weight: 700;
  color: var(--tour-green);
}

/* ─── Chapter: the rest of it ───────────────────────────────────────────
   Twelve module tiles. Deliberately plain -- the point is the breadth of the
   list, so anything decorative here would fight it. */
.sc-mods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.45em; }
.mod {
  display: flex;
  flex-direction: column;
  gap: 0.1em;
  border: 1px solid var(--tour-line);
  border-radius: 0.55em;
  padding: 0.6em 0.65em;
  font-size: 0.66em;
  line-height: 1.35;
  color: var(--tour-faint);
  background: #fff;
}
.mod svg {
  width: 1.35em;
  height: 1.35em;
  stroke: var(--tour-violet);
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-bottom: 0.25em;
}
.mod b { font-size: 1.06em; font-weight: 700; color: var(--tour-ink); }
.mods-more { margin-top: 0.7em; font-size: 0.72em; }
.mods-more span:last-child { color: var(--tour-body); font-weight: 600; }

@media (max-width: 700px) {
  .sc-pos { grid-template-columns: 1fr; }
  .pos-grid { grid-template-columns: repeat(3, 1fr); }
  .sc-mods { grid-template-columns: repeat(2, 1fr); }
}

/* The sound toggle shows one icon or the other, never both. */
.bk-tour-btn .ico-loud { display: none; }
.bk-tour.is-loud .bk-tour-btn .ico-loud { display: block; }
.bk-tour.is-loud .bk-tour-btn .ico-mute { display: none; }
.bk-tour.is-loud [data-tour-sound] { background: var(--tour-accent); }
.bk-tour.is-loud [data-tour-sound]:hover { background: #dd7a26; }


/* ─── End-card branding ─────────────────────────────────────────────────
   The tour gets screen recorded and posted, and a clip carries none of the
   page around it. This is the frame a viewer pauses on, so it is the one that
   has to say who this is and where to go. */
.tw-end-brand {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-size: 1.15em;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  margin-bottom: 0.3em;
}
.tw-end-brand em { font-style: normal; color: var(--tour-accent); }
.tw-end-brand .tw-brand-mark { background: #fff; color: var(--tour-brand); }
.tw-end-url {
  margin-top: 1em;
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.72);
}
