/* ==========================================================================
   ZygApp Spotlight — module styles.

   Lifted verbatim from the approved prototype. Everything is namespaced under
   .zsp so it cannot collide with the market page's existing styles.

   Two rules here are load-bearing and must not be "tidied":
   - the docked player's 400px width floor (YouTube needs a 200x200 minimum
     viewport and recommends 480x270 for 16:9; below that the controls break)
   - no docking at all below a 520px viewport, for the same reason
   ========================================================================== */

/* ============================================================
   ZYGAPP SPOTLIGHT — drop-in module for /market/
   Zero dependencies. No webfonts. No build step.
   Swap the tokens below to match the live market page theme.
   ============================================================ */

.zsp {
  /* --- tokens: edit these to match zygapp.com --- */
  --zsp-ink:      #08090B;
  --zsp-surface:  #12151A;
  --zsp-raise:    #1A1F26;
  --zsp-line:     #242A33;
  --zsp-text:     #EDF1F5;
  --zsp-muted:    #7E8B99;
  --zsp-cyan:     #00C2CB;
  --zsp-magenta:  #E8407A;

  --zsp-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --zsp-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --zsp-gap: clamp(16px, 2.5vw, 28px);

  background: var(--zsp-ink);
  color: var(--zsp-text);
  font-family: var(--zsp-sans);
  /* Vertical padding deliberately smaller than horizontal. This module used to
     use the same generous clamp on both axes, which on a laptop pushed the
     first market products entirely below the fold. */
  padding: clamp(20px, 2.4vw, 32px) clamp(16px, 4vw, 48px);
  container-type: inline-size;
}

.zsp *, .zsp *::before, .zsp *::after { box-sizing: border-box; }

/* --- signature: SMPTE colour bars as the section rule --- */
.zsp-bars {
  display: flex;
  height: 4px;
  margin-bottom: 18px;
  overflow: hidden;
}
.zsp-bars span { flex: 1; }
.zsp-bars span:nth-child(1) { background: #C0C0C0; }
.zsp-bars span:nth-child(2) { background: #C0C000; }
.zsp-bars span:nth-child(3) { background: #00C0C0; }
.zsp-bars span:nth-child(4) { background: #00C000; }
.zsp-bars span:nth-child(5) { background: #C000C0; }
.zsp-bars span:nth-child(6) { background: #C00000; }
.zsp-bars span:nth-child(7) { background: #0000C0; }

/* --- slate strip --- */
.zsp-slate {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 18px;
  font-family: var(--zsp-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--zsp-muted);
  margin-bottom: var(--zsp-gap);
}
.zsp-slate b { color: var(--zsp-text); font-weight: 600; }
.zsp-slate .zsp-sep { color: var(--zsp-line); }
.zsp-live { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; color: var(--zsp-cyan); }
.zsp-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--zsp-cyan);
  animation: zsp-pulse 2.4s ease-in-out infinite;
}
@keyframes zsp-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* --- layout --- */
.zsp-main {
  display: grid;
  /* 1.45fr rather than 1.9fr: the rail now carries the gear cards as well as
     the creator panel, so it needs real width. The player stays dominant but
     stops being the only thing on screen. */
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: var(--zsp-gap);
  align-items: start;
}
@container (max-width: 880px) {
  .zsp-main { grid-template-columns: 1fr; }
}

/* --- the rail: creator panel + the gear from this feature -----------------
   Products sit BESIDE the player, not below it. /market/ has to read as a
   market at first glance: a visitor who lands on a full-bleed video player
   has no way of knowing they are in a shop. */
.zsp-rail {
  display: flex;
  flex-direction: column;
  gap: calc(var(--zsp-gap) * 0.8);
  min-width: 0;
  min-height: 0;          /* lets the card list shrink instead of pushing out */
}
.zsp-rail .zsp-gear { margin-top: 0; min-height: 0; }
/* An empty gear block still contributes its flex gap. Collapse it. */
.zsp-rail .zsp-gear:not(:has(.zsp-card)) { display: none; }

@container (min-width: 881px) {
  /* One card per row — in the rail these are a list, not a grid.
     The cap is an explicit length, NOT a percentage: the rail is a grid item
     whose row height is derived from its own content, so a percentage
     max-height there is circular and resolves to none. Two cards' worth is
     enough to show /market/ is a market; the rest scroll in place rather than
     stretching the module down the page. */
  .zsp-rail .zsp-cards {
    grid-template-columns: 1fr;
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
  }
}

/* --- player facade: click to play, so the view actually counts --- */
.zsp-slot {
  position: relative;
  aspect-ratio: 16 / 9;
}
.zsp-stage {
  position: absolute;
  inset: 0;
  background: var(--zsp-surface);
  border: 1px solid var(--zsp-line);
  overflow: hidden;
}
.zsp-stage iframe { width: 100%; height: 100%; border: 0; display: block; }

/* --- docked state: same node, repositioned. The iframe never moves in
       the DOM, so playback survives.
       Width floor is 400px: YouTube requires an embedded player viewport
       of at least 200x200, and recommends 480x270 for 16:9. Below that
       the controls break. On narrow screens we don't dock at all. --- */
.zsp-stage.is-docked {
  position: fixed;
  inset: auto 20px 20px auto;
  width: clamp(400px, 32vw, 460px);
  aspect-ratio: 16 / 9;
  z-index: 60;
  border-color: var(--zsp-cyan);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.62);
  animation: zsp-dock 220ms ease both;
}
@keyframes zsp-dock {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.zsp-dockbar { display: none; }
.zsp-stage.is-docked .zsp-dockbar {
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 3;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  background: linear-gradient(180deg, rgba(8,9,11,0.92), rgba(8,9,11,0));
  font-family: var(--zsp-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--zsp-muted);
  pointer-events: none;
}
.zsp-dockbar button {
  pointer-events: auto;
  margin-left: auto;
  background: rgba(8,9,11,0.8);
  border: 1px solid var(--zsp-line);
  color: var(--zsp-text);
  font: inherit;
  padding: 3px 7px;
  cursor: pointer;
}
.zsp-dockbar button:hover { border-color: var(--zsp-cyan); color: var(--zsp-cyan); }
.zsp-dockbar button:focus-visible { outline: 2px solid var(--zsp-cyan); outline-offset: 2px; }

@media (max-width: 520px) {
  /* Too narrow to dock without breaking the player's minimum viewport.
     The video simply scrolls away, which is the honest behaviour here. */
  .zsp-stage.is-docked {
    position: absolute;
    inset: 0;
    width: auto;
    box-shadow: none;
    border-color: var(--zsp-line);
    animation: none;
  }
  .zsp-stage.is-docked .zsp-dockbar { display: none; }
}

.zsp-facade {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  padding: 0; margin: 0;
  border: 0; cursor: pointer;
  background: var(--zsp-surface) center/cover no-repeat;
  display: block;
}
.zsp-facade::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(8,9,11,0) 40%, rgba(8,9,11,0.85) 100%);
}
.zsp-play {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: 76px; height: 76px;
  border-radius: 50%;
  background: rgba(8,9,11,0.7);
  border: 1px solid rgba(237,241,245,0.4);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}
.zsp-play svg { width: 22px; height: 22px; fill: var(--zsp-text); margin-left: 3px; }
.zsp-facade:hover .zsp-play,
.zsp-facade:focus-visible .zsp-play {
  transform: translate(-50%, -50%) scale(1.08);
  background: var(--zsp-cyan);
  border-color: var(--zsp-cyan);
}
.zsp-facade:hover .zsp-play svg,
.zsp-facade:focus-visible .zsp-play svg { fill: var(--zsp-ink); }
.zsp-facade:focus-visible { outline: 2px solid var(--zsp-cyan); outline-offset: 3px; }

.zsp-stage-tc {
  position: absolute; left: 12px; bottom: 12px; z-index: 2;
  font-family: var(--zsp-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--zsp-text);
  background: rgba(8,9,11,0.72);
  border: 1px solid var(--zsp-line);
  padding: 4px 8px;
}

/* --- creator panel --- */
.zsp-panel {
  border: 1px solid var(--zsp-line);
  background: var(--zsp-surface);
  padding: clamp(18px, 2.4vw, 26px);
}
.zsp-eyebrow {
  font-family: var(--zsp-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--zsp-magenta);
  margin: 0 0 10px;
}
.zsp-name {
  font-size: clamp(24px, 3.4vw, 34px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 750;
  margin: 0 0 6px;
}
.zsp-handle {
  font-family: var(--zsp-mono);
  font-size: 12px;
  color: var(--zsp-muted);
  margin: 0 0 16px;
}
.zsp-note {
  font-size: 15px;
  line-height: 1.6;
  color: #C3CDD7;
  margin: 0 0 20px;
}
.zsp-note strong { color: var(--zsp-text); font-weight: 600; }

.zsp-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--zsp-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--zsp-ink);
  background: var(--zsp-text);
  padding: 11px 16px;
  transition: background 160ms ease, color 160ms ease;
}
.zsp-btn:hover, .zsp-btn:focus-visible { background: var(--zsp-cyan); }
.zsp-btn:focus-visible { outline: 2px solid var(--zsp-cyan); outline-offset: 3px; }

/* --- gear rail --- */
.zsp-gear { margin-top: calc(var(--zsp-gap) * 1.4); }
.zsp-gear-head {
  display: flex; align-items: baseline; gap: 12px;
  font-family: var(--zsp-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--zsp-muted);
  margin-bottom: 14px;
}
.zsp-gear-head::after {
  content: ""; flex: 1; height: 1px; background: var(--zsp-line);
}
.zsp-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.zsp-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--zsp-surface);
  border: 1px solid var(--zsp-line);
  padding: 14px 15px;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.zsp-card:hover, .zsp-card:focus-visible {
  border-color: var(--zsp-cyan);
  background: var(--zsp-raise);
  transform: translateY(-2px);
}
.zsp-card:focus-visible { outline: 2px solid var(--zsp-cyan); outline-offset: 2px; }
.zsp-card-kind {
  font-family: var(--zsp-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--zsp-muted);
  margin: 0 0 7px;
}
.zsp-card-name { font-size: 14px; line-height: 1.35; font-weight: 600; margin: 0 0 9px; }
.zsp-card-go { font-family: var(--zsp-mono); font-size: 11px; color: var(--zsp-cyan); }

/* --- upcoming filmstrip --- */
.zsp-strip { margin-top: var(--zsp-gap); }

/* --- keep the module from filling a phone screen -------------------------
   Stacked on mobile the player, panel, gear and archive add up to more than a
   viewport, which is the exact problem this layout work exists to fix. Cap the
   two lists rather than hiding anything: everything is still reachable, it
   just scrolls inside its own box instead of pushing the market off-screen. */
@container (max-width: 880px) {
  .zsp-rail { gap: calc(var(--zsp-gap) * 0.75); }
  .zsp-cards { max-height: 200px; overflow-y: auto; scrollbar-width: thin; }
  .zsp-strip { margin-top: calc(var(--zsp-gap) * 0.75); }
}
.zsp-frames {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: thin;
}
/* The archive is a way back to older features, not a gallery. It was 183px
   tall — enough, stacked under the player and the rail, to push the module past
   a laptop viewport on its own. Smaller frames, same content, same scrolling. */
.zsp-frame {
  flex: 0 0 116px;
  background: none; border: 1px solid var(--zsp-line);
  padding: 0; cursor: pointer; text-align: left;
  color: inherit;
  transition: border-color 160ms ease;
}
.zsp-frame:hover, .zsp-frame:focus-visible { border-color: var(--zsp-cyan); }
.zsp-frame:focus-visible { outline: 2px solid var(--zsp-cyan); outline-offset: 2px; }
.zsp-frame[aria-current="true"] { border-color: var(--zsp-magenta); }
.zsp-frame img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.zsp-frame-meta { padding: 6px 8px 7px; }
.zsp-frame-roll {
  font-family: var(--zsp-mono); font-size: 9px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--zsp-muted); margin: 0 0 4px;
}
.zsp-frame-name { font-size: 11.5px; font-weight: 600; line-height: 1.25; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 1; line-clamp: 1;
  -webkit-box-orient: vertical; overflow: hidden; }

/* --- disclosure --- */
.zsp-disclosure {
  margin-top: var(--zsp-gap);
  padding-top: 14px;
  border-top: 1px solid var(--zsp-line);
  font-size: 12px;
  line-height: 1.6;
  color: var(--zsp-muted);
}

@media (prefers-reduced-motion: reduce) {
  .zsp *, .zsp *::before, .zsp *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── Share control ──────────────────────────────────────────────────────────
   Markup and behaviour are shared with the blog (community/_share_button.html
   + js/share.js); only the colours are local, set through the two custom
   properties share.css reads. */
.zsp-share-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.zsp-share .zyg-share-btn {
  --zyg-share-accent: var(--zsp-cyan, #00d4ff);
  --zyg-share-line: rgba(0, 212, 255, 0.32);
  color: var(--zsp-cyan, #00d4ff);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 12px;
}
.zsp-share .zyg-share-btn:hover {
  background: rgba(0, 212, 255, 0.12);
}

/* ===========================================================================
   THE BOTTOM DOCK

   The Spotlight moved from above the products to the bottom of the market
   page. Products are the main stage; the feature is a sticker in the corner
   until someone opens it, and then it takes the lower part of the screen
   while the product list keeps scrolling above.

   position: sticky, not fixed. The module is the LAST child of .market-stack,
   so it is pulled up to the viewport bottom while the products scroll past
   and settles into place at the end of the page — no manual offsetting, and
   it cannot strand itself over the footer at the end of the document.

   .zsp--docked is added by spotlight.js, never in the markup. With no JS the
   module renders in flow, whole, at the end of the page: crawlers and share
   cards read the same HTML they always did, and no content is collapsed
   behind a control that cannot run.

   SILENT-FAILURE CONSTRAINT: sticky needs every ancestor of .zsp to leave
   overflow alone. The chain is .market-stack -> body (gear.html empties
   base.html's container_wrap). mobile-responsive.css sets
   `body { overflow-x: hidden }`, which is safe only because nothing sets
   overflow on `html` — the used value then propagates to the viewport and
   body stays a non-scroller. Put overflow on html and this pins nothing,
   with no error anywhere.
   =========================================================================== */

.market-stack { position: relative; }

.zsp--docked {
  position: sticky;
  /* --zsp-lift is set by spotlight.js to the height of .app-footer while it
     is showing; that bar is fixed at z-index 9999 and slides up on scroll
     down, which is exactly where and when the dock lives. */
  bottom: var(--zsp-lift, 0px);
  z-index: 40;
  transition: bottom .32s cubic-bezier(.2,.9,.2,1);
}
@media (prefers-reduced-motion: reduce) {
  .zsp--docked { transition: none; }
}

/* --- sticker: the resting state. Small, cornered, out of the way. --- */
.zsp--docked[data-dock="sticker"] {
  width: min(360px, calc(100% - 24px));
  margin-left: auto;
  margin-right: 12px;
  padding: 10px 14px;
  border: 1px solid var(--zsp-line);
  border-radius: 14px;
  box-shadow: 0 18px 44px -18px rgba(0,0,0,.95);
}
.zsp--docked[data-dock="sticker"] .zsp-main,
.zsp--docked[data-dock="sticker"] .zsp-bars { display: none; }
/* Keep the slate to one line at sticker size: the roll number is the useful
   part, the channel line is not. */
.zsp--docked[data-dock="sticker"] .zsp-slate { gap: 4px 10px; font-size: 10.5px; }
.zsp--docked[data-dock="sticker"] .zsp-live { display: none; }

/* --- open: the resting state. Half the width and bottom-right, so the
       product grid stays readable beside it rather than behind it — a
       full-width bar was an obstruction, not a feature.

       Capped and internally scrollable so a long rail can never swallow the
       page. The scroll container is the dock ITSELF, which is allowed: only
       the ANCESTORS of a sticky element have to leave overflow alone. --- */
.zsp--docked[data-dock="open"] {
  width: min(50%, 720px);
  margin-left: auto;
  margin-right: 12px;
  max-height: 68vh;
  max-height: 68dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--zsp-line);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -18px 44px -18px rgba(0,0,0,.95);
}

.zsp-dock-toggle {
  margin-left: auto;
  font-family: var(--zsp-mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--zsp-muted);
  background: transparent;
  border: 1px solid var(--zsp-line);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.zsp-dock-toggle:hover { color: var(--zsp-cyan); border-color: var(--zsp-cyan); }
.zsp-dock-toggle:focus-visible { outline: 2px solid var(--zsp-cyan); outline-offset: 2px; }

/* Half a narrow screen is not a usable player. Below this the dock takes the
   width it needs and the product grid is reached by minimising it. */
@media (max-width: 860px) {
  .zsp--docked[data-dock="open"] {
    width: calc(100% - 16px);
    margin-right: 8px;
    /* THE DOCK ALWAYS RENDERS AT ITS CAP, never below it: the module's
       content (player, creator panel, gear cards) is taller than any cap
       worth setting, so max-height IS the height. This number decides how
       much of the screen the products get.

       45dvh is the floor a usable embed allows, not a preference. YouTube
       wants at least 200x200 and recommends 480x270, so below 860px the
       player has to be near full width, which makes it roughly 33dvh tall on
       its own; slate and padding take it to about 45. Lower and the video
       stops being watchable, higher and the products stop being browsable —
       which is the whole reason the module moved down here.

       The creator panel and gear cards scroll inside the dock rather than
       being hidden: reaching them is a swipe, not a state change. */
    max-height: 45vh;
    max-height: 45dvh;
  }
}

@media (max-width: 560px) {
  .zsp--docked[data-dock="sticker"] {
    width: calc(100% - 16px);
    margin-right: 8px;
    padding: 8px 12px;
  }
}

/* --- mobile -------------------------------------------------------------

   Everything below exists because a phone has no half-width: the dock spans
   the screen, so every pixel it takes is a pixel of products it hides.
   spotlight.js starts narrow and short viewports as a sticker for the same
   reason; these rules make the opened state survivable when someone asks
   for it.
   ----------------------------------------------------------------------- */

/* The home indicator on a notched iPhone sits exactly where a bottom-docked
   bar puts its controls. */
.zsp--docked[data-dock="sticker"],
.zsp--docked[data-dock="open"] {
  padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
}

/* A 24px-tall pill is a miss waiting to happen on a touch screen. */
@media (pointer: coarse) {
  .zsp-dock-toggle {
    min-height: 34px;
    padding: 8px 16px;
    font-size: 11px;
  }
}

@media (max-width: 560px) {
  /* Momentum scrolling inside the opened dock, and no scroll chaining out of
     it into the product list behind. */
  /* Momentum scrolling inside the opened dock, and no scroll chaining out of
     it into the product list behind. The cap is inherited from the 860px
     block above — one number for every screen that gets a full-width dock. */
  .zsp--docked[data-dock="open"] { -webkit-overflow-scrolling: touch; }
}

/* At this width the slate wraps and the toggle drops to a second line, which
   turns a slim sticker into a two-line block. The roll number is the useful
   part; the period is not. */
@media (max-width: 420px) {
  .zsp--docked[data-dock="sticker"] [data-zsp="period"],
  .zsp--docked[data-dock="sticker"] .zsp-sep:last-of-type {
    display: none;
  }
  .zsp--docked[data-dock="sticker"] .zsp-slate { flex-wrap: nowrap; }
}

/* Landscape phones. Wide enough to miss the width breakpoints, with nothing
   to spare vertically — spotlight.js starts these as a sticker, and an
   opened dock still leaves a band of products visible. */
/* Short viewports, which is mostly landscape phones. The player is sized by
   WIDTH — .zsp-slot is a 16:9 box that fills its column — so a full-width
   slot on an 844px-wide landscape phone is 465px tall on a 390px screen: the
   video alone is taller than the display. Capping the dock cannot fix that;
   it would just clip the player. The slot itself has to be capped, which is
   the same width-not-height trick the grader's stage uses and for the same
   reason: cap the height of a fixed-ratio box and it stops being that ratio. */
@media (max-height: 560px) {
  .zsp--docked[data-dock="open"] .zsp-slot {
    max-width: calc(42vh * 16 / 9);
    max-width: calc(42dvh * 16 / 9);
    margin-inline: auto;
  }
}

@media (max-height: 460px) {
  .zsp--docked[data-dock="open"] { max-height: 62vh; max-height: 62dvh; }
  .zsp--docked[data-dock="sticker"] { padding-top: 6px; padding-bottom: 6px; }
}
