/*
 * style.css — the store app's own stylesheet (its "form").
 *
 * lux/lmp elements are the function (from the latis engine); their look here is
 * the store's, not the engine's. This is app-specific and lives with the app —
 * latis stays game/app-agnostic. The store does not load a shared theme module.
 */

:root {
  --font: "Trebuchet MS", "Avenir Next", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --ink: #efeaff;
  --muted: #a99fce;
  --violet: #b06bff;
  --violet-soft: rgba(176, 107, 255, 0.55);
  --cyan: #46e7d6;
  --cyan-soft: rgba(70, 231, 214, 0.6);
  --hot: #ff5fbf;
  --glass: rgba(24, 14, 46, 0.55);
  --glass-2: rgba(30, 18, 56, 0.6);
  --radius: 20px;
  --neon-border: linear-gradient(110deg, #d06bff 0%, #7a9bff 42%, #46e7d6 100%);
  /* Cheap translucent fills (alpha only — no backdrop-filter). The neon ring
     is a masked ::before so the gradient never sits in the interior. */
  --fill-a: 0.58;
  --fill-dark: linear-gradient(180deg, rgba(16, 8, 36, var(--fill-a)), rgba(10, 4, 28, 0.50));
  --fill-dark-sel: linear-gradient(180deg, rgba(22, 48, 52, 0.74), rgba(12, 30, 36, 0.66));
  --scroll-thumb: rgba(176, 107, 255, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100dvh; }
html {
  /* Reserve the gutter so showing the thumb never reflows. Thumb is
     transparent until a real scroll (resize must not reveal it). */
  scrollbar-gutter: stable;
}
html, body {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
html.is-scrolling,
body.is-scrolling { scrollbar-color: var(--scroll-thumb) transparent; }
html::-webkit-scrollbar,
body::-webkit-scrollbar { width: 10px; height: 10px; }
html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track { background: transparent; }
html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb { background: transparent; border-radius: 99px; }
html.is-scrolling::-webkit-scrollbar-thumb,
body.is-scrolling::-webkit-scrollbar-thumb { background: var(--scroll-thumb); }
body {
  font-family: var(--font);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  background: #070311;
}

/* Gradient confined to a 2px ring. Interior stays the translucent fill
   (warp shows through). Mask punches the inside so there is no bleed. */
lmp-player,
lux-button {
  position: relative;
}
lmp-player::before,
lux-button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: var(--neon-border);
  pointer-events: none;
  z-index: 2;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}

/* loader + asset declarations are invisible */
lux-loader, lux-asset { display: none !important; }

/* ——— page anatomy (wide = df36a3b sidebar player) ——— */
lux-store {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  /* Wide: logo sits on the pills row, player on the catalog row (same as the
     old hat/head split). lux-head is display:contents so its kids join this grid. */
  grid-template-areas:
    "logo    filters"
    "player  body"
    "foot    body";
  gap: 20px 30px;
  align-items: start;
  max-width: 1200px;
  margin: 0 auto;
  padding: 26px clamp(16px, 3vw, 34px) 22px;
  min-height: 100dvh;
}

lux-pack { grid-area: filters; align-self: center; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
lux-head { display: contents; }
lux-image { grid-area: logo; }
lmp-player { grid-area: player; }
lux-body { grid-area: body; align-self: stretch; min-height: 0; overflow: visible; }
lux-foot {
  grid-area: foot;
  align-self: end;
  display: block;
  text-align: center;
  color: var(--cyan);
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow: 0 0 12px rgba(70, 231, 214, 0.5);
}

/* ——— logo (lux-image: wide wordmark / compact square in portrait) ——— */
lux-image {
  --lux-logo-h: clamp(36px, 5vw, 54px);
  --lux-logo-glow: rgba(176, 107, 255, 0.8);
  display: inline-flex;
  align-items: center;
  justify-self: center;
  align-self: center;
  line-height: 0;
}
lux-image img {
  display: block;
  height: var(--lux-logo-h);
  width: auto;
  filter: drop-shadow(0 0 14px var(--lux-logo-glow));
}

/* ——— category chips: pills via lux-button CSS vars (Safari-safe, no ::part) ——— */
lux-button {
  font: 700 14px/1 var(--font);
  --lux-btn-h: 38px;
  --lux-btn-pad: 0 10px;
  --lux-btn-radius: 99px;
  --lux-btn-color: var(--ink);
  --lux-btn-border: 2px solid transparent;
  --lux-btn-bg: var(--fill-dark) padding-box;
  --lux-btn-shadow: 0 0 14px rgba(120, 70, 220, 0.22);
  --lux-btn-blur: none;
  border-radius: var(--lux-btn-radius);
}
/* Category glyphs slot into <lux-button> (light DOM). The inner shadow <button>
   already uses gap:7px; size/opacity live here so we don't touch the engine. */
lux-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  display: block;
  opacity: 0.85;
  transform: rotate(0deg);
  transition: transform 0.55s ease;
}
lux-button:hover svg { transform: rotate(360deg); }
lux-button[selected] svg { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  lux-button svg { transition: none; }
  lux-button:hover svg { transform: rotate(0deg); }
}
/* Before the engine upgrades <lux-button> (it loads after the catalog paints),
   give the bare element the exact pill box it will have once defined — same
   height/padding/border/radius — so the upgrade swaps in the shadow button with
   zero layout shift (no 14px-text → 38px-pill jump that pushed the grid down). */
lux-button:not(:defined) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: var(--lux-btn-h);
  padding: var(--lux-btn-pad);
  border-radius: var(--lux-btn-radius);
  border: var(--lux-btn-border);
  background: var(--lux-btn-bg);
  color: var(--lux-btn-color);
  white-space: nowrap;
  box-sizing: border-box;
}
lux-button:hover { --lux-btn-shadow: 0 0 16px rgba(70, 231, 214, 0.32); }
lux-button[selected] {
  --lux-btn-color: #eafffb;
  --lux-btn-bg: var(--fill-dark-sel) padding-box;
  --lux-btn-shadow: 0 0 20px var(--cyan-soft), inset 0 0 12px rgba(70, 231, 214, 0.25);
}

/* First paint (before latis defines lux-wide/tall): same show/hide as the
   engine :host rules so we never flash both compositions.
   lux-horiz / lux-vert are aliases of lux-wide / lux-tall. */
lux-wide, lux-horiz { display: contents; }
lux-tall, lux-vert { display: none; }

/* ——— music player (wide = df36a3b glass card) ——— */
lmp-player {
  --lmp-accent: var(--cyan);
  --lmp-track: rgba(255, 255, 255, 0.16);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "art" "title" "seek" "controls" "vol";
  gap: 8px;
  padding: 16px;
  color: var(--ink);
  border: 2px solid transparent;
  background: var(--fill-dark) padding-box;
  border-radius: var(--radius);
  box-shadow: 0 0 30px rgba(150, 80, 240, 0.28), inset 0 0 22px rgba(130, 80, 220, 0.1);
}
lmp-art { grid-area: art; display: block; width: 100%; aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }
lmp-title { grid-area: title; position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; min-height: 26px; font-weight: 800; font-size: 17px; color: #fff; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.85), 0 0 14px rgba(0, 0, 0, 0.55); }
/* EQ sits behind the title (wide) — no reflection. Host opacity 0.62 so the
   engine canvas (its own ~0.55–0.95 alpha) still reads through the glyphs. */
lmp-eq { grid-area: title; align-self: center; justify-self: stretch; z-index: 0; height: 48px; margin: 0; opacity: 0.62; pointer-events: none; -webkit-box-reflect: none; }
/* Engine stays empty until real spectrum, but a stale CDN build can still
   paint a rest-mountain. Stay hidden until the store marks a live graph. */
lmp-player:not(.has-analyser) lmp-eq { visibility: hidden; opacity: 0; }
lmp-artist { grid-area: artist; display: block; text-align: center; font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
/* Wide first paint: lmp's seek / play / volume rows are empty until the
   engine attaches their shadow DOM. Reserve those boxes (43 / 52 / 18)
   so the sidebar card is 300×433 from paint — no 0→populated +113 jump. */
lmp-seek { grid-area: seek; display: block; --lmp-rail: 5px; margin-top: 2px; color: var(--muted); min-height: 43px; }
lmp-controls { grid-area: controls; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 2px; min-height: 52px; }
lmp-prev, lmp-next { color: var(--ink); }
lmp-play {
  color: #05201d;
  --lmp-btn-size: 52px;
  --lmp-btn-bg: linear-gradient(180deg, #7ff2e6, var(--cyan));
  --lmp-btn-hover: linear-gradient(180deg, #8ff6eb, #58ecdb);
  border-radius: 50%;
  box-shadow: 0 0 20px var(--cyan-soft);
}
lmp-vol { grid-area: vol; --lmp-accent: var(--hot); --lmp-rail: 6px; color: var(--muted); margin-top: 2px; min-height: 18px; }

/* ——— game grid ——— */
lux-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
  align-content: start;
}
lux-grid .empty { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 40px 0; }

lux-card {
  display: flex;
  flex-direction: column;
  color: inherit;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(180deg, var(--glass-2), var(--glass));
  border: 1.5px solid var(--cyan-soft);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.18s, border-color 0.18s;
}
lux-card[href] { cursor: pointer; }
/* hover: bold cyan glow all around the tile, no movement */
lux-card:hover {
  border-color: #9dfff2;
  box-shadow: 0 0 0 2px rgba(70, 231, 214, 0.95), 0 0 22px 4px rgba(70, 231, 214, 0.6), 0 0 46px 12px rgba(120, 110, 255, 0.45);
}
.card__media { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #0c0722; }
.card__thumb, .card__hover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card__hover { opacity: 0; transition: opacity 0.3s ease; }
lux-card.has-hover:hover .card__hover { opacity: 1; }
.card__badge {
  position: absolute; top: 10px; left: 10px;
  padding: 4px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.03em;
  color: #1a0a2a; background: linear-gradient(180deg, #ffd36b, #ff9d3d);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.card__body { display: flex; align-items: center; gap: 12px; padding: 13px 15px 15px; }
.card__icon { width: 46px; height: 46px; border-radius: 12px; flex: 0 0 auto; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35); }
.card__text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.card__title { font-weight: 800; font-size: 17px; color: #fff; }
.card__tag { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ——— tall / portrait: mockup neon composition (wide player stays df36a3b) ——— */
@media (orientation: portrait) {
  lux-wide, lux-horiz { display: none; }
  lux-tall, lux-vert { display: contents; }
  lux-store {
    grid-template-columns: 1fr;
    grid-template-areas:
      "head"
      "filters"
      "body"
      "foot";
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 12px;
    padding: 14px clamp(14px, 3vw, 24px) 16px;
  }
  lux-head {
    display: flex;
    grid-area: head;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  lux-image {
    --lux-logo-h: 84px;
    --lux-logo-glow: rgba(176, 107, 255, 0.55);
    flex: 0 0 auto;
    /* Size by height. Width follows the file so the g's left bowl is not cropped. */
    height: auto;
    width: auto;
    max-width: 46vw;
    overflow: visible;
    justify-self: start;
  }
  lux-image picture { display: block; line-height: 0; }
  lux-image img {
    display: block;
    width: auto;
    height: var(--lux-logo-h);
    max-width: 46vw;
    object-fit: contain;
    overflow: visible;
    filter: drop-shadow(0 0 12px var(--lux-logo-glow));
  }
  lux-pack {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
  }
  lux-pack.is-scrolling { scrollbar-color: var(--scroll-thumb) transparent; }
  lux-pack::-webkit-scrollbar { height: 8px; width: 8px; }
  lux-pack::-webkit-scrollbar-track { background: transparent; }
  lux-pack::-webkit-scrollbar-thumb { background: transparent; border-radius: 99px; }
  lux-pack.is-scrolling::-webkit-scrollbar-thumb { background: var(--scroll-thumb); }
  lux-foot { text-align: center; }
  lmp-player {
    --lmp-accent: #7ff6ec;
    --lmp-track: rgba(255, 255, 255, 0.14);
    --lmp-rail: 4px;
    --lmp-btn-size: 24px;
    --lmp-btn-bg: transparent;
    --lmp-btn-hover: rgba(127, 246, 236, 0.12);
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 8px 8px;
    color: #e8fbff;
    /* Squarer than a 999px pill — modest radius, keep the neon border. */
    border-radius: 14px;
    border: 2px solid transparent;
    background: var(--fill-dark) padding-box;
    box-shadow:
      0 0 16px rgba(70, 231, 214, 0.28),
      0 0 28px rgba(176, 107, 255, 0.2);
  }
  lmp-art {
    grid-area: auto;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    aspect-ratio: 1;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  }
  .lmp-copy {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    overflow: hidden;
  }
  /* Tall EQ: title-band only. Bars paint from the canvas bottom — inset:0 put
     them on the control row, so the title line stayed empty. */
  .lmp-copy > lmp-eq {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: auto;
    height: 32px;
    grid-area: auto;
    z-index: 0;
    margin: 0;
    opacity: 0.62;
    pointer-events: none;
    -webkit-box-reflect: none;
  }
  lmp-player:not(.has-analyser) .lmp-copy > lmp-eq { visibility: hidden; opacity: 0; }
  .lmp-row {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
  }
  lmp-title {
    position: relative;
    z-index: 1;
    grid-area: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    min-height: 32px;
    height: 32px;
    font-size: 15px;
    line-height: 32px;
    color: #fff;
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.6);
  }
  /* Beat lmp :host { text-overflow:ellipsis } (0,1,0). The shadow span
     (::part(text)) gets the 32px line-box so glyphs sit in the EQ band. */
  lmp-title:not([hidden]) {
    display: block;
    height: 32px;
    line-height: 32px;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
  }
  lmp-title::part(text) {
    display: inline-block;
    height: 32px;
    line-height: 32px;
    vertical-align: middle;
  }
  lmp-prev, lmp-next {
    flex: 0 0 auto;
    color: #7ff6ec;
    box-shadow: none;
    --lmp-btn-size: 24px;
  }
  /* Circular play — same filled-cyan look as the old desktop button, tap-sized. */
  lmp-play {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #05201d;
    --lmp-btn-size: 32px;
    --lmp-btn-bg: linear-gradient(180deg, #7ff2e6, var(--cyan));
    --lmp-btn-hover: linear-gradient(180deg, #8ff6eb, #58ecdb);
    box-shadow: 0 0 12px var(--cyan-soft);
  }
  lmp-vol {
    grid-area: auto;
    flex: 1 1 auto;
    min-width: 48px;
    margin-left: 2px;
    margin-top: 0;
    --lmp-accent: #7ff6ec;
    color: #7ff6ec;
  }
  lux-grid { grid-template-columns: 1fr; }
}

/* Animated backdrop (bg.js → store warp.js via loadCore backgroundFunc).
   Sits behind everything and fades in once warp is ready — usable before then. */
#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}
#bg.is-live { opacity: 1; }
