
@font-face {
  font-family: NegativMothDisplay;
  src: url('./Negative-Labs-Moth.ttf') format('truetype');
  font-display: swap;
}

/* ---- Demo page only (index.html); the host site provides its own page ---- */
.demo-page { margin: 0; background: #000; }

/* ---- Data Core section: every rule below applies inside #data-core or the
   detail dialog only, so the host site's styles stay untouched. ---- */
.data-core, .data-core *, .details, .details * { box-sizing: border-box; }
.data-core, .details {
  color-scheme: dark;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  color: #e3e6e4;
}
.data-core { min-height: 494svh; background: #000; } /* fallback; controls.js sets 100svh + ~106svh per timeline unit from the instrument count */
/* While inside the section, the scroll container itself is dark too, so no
   paper can flash at the edges during fast scrolling or bar transitions. */
.data-core:has(.core.immersed) { background: #000; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* Placeholders for the host page above and below the section. */
.page-lead, .page-tail {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  min-height: 22svh;
  padding: 38px clamp(22px, 4vw, 66px);
  color: #d9d3c7;
  background: #000;
}
.page-tail { display: flex; flex-direction: column; justify-content: flex-end; min-height: 16svh; }
.brand-name { display: block; font-family: NegativMothDisplay, monospace; font-size: 17px; letter-spacing: .25em; }
.page-kicker { display: block; margin-top: 12px; font-size: 8px; letter-spacing: .55em; color: #8b9490; }

/* Entry: only the large word, no small captions. */
.data-core .entry-title {
  position: absolute; inset: 0; z-index: 1;
  display: grid; place-items: center;
  color: #d9d3c7; pointer-events: none;
  transform: translateY(12svh);
  opacity: var(--entry-copy, 1);
}
.data-core .entry-word { font: clamp(25px, 5vw, 74px)/1.2 NegativMothDisplay, monospace; letter-spacing: .07em; }

.data-core .core {
  position: sticky;
  top: 0;
  isolation: isolate;
  /* Follow the visible height as mobile browser bars appear and disappear;
     with 100svh a paper strip showed above/below the stage. */
  height: 100svh;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

.data-core .stage {
  position: absolute;
  inset: 0;
  height: 100%;
  background: #000;
  touch-action: pan-y;
}
.data-core .stage canvas { display: block; width: 100%; height: 100%; }

/* While WebGL loads the stage is paper, like the entry it leads into; the
   panel image only appears when WebGL is unavailable. */
.data-core .stage:not(.ready) { background: #000; }
.data-core .fallback {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(65vw, 330px); border: 1px solid #becbc766; border-radius: 10px; box-shadow: 0 0 40px #a9c9bb12;
}
.data-core .core:not(.fallback-mode) .fallback { display: none; }
.data-core .core.fallback-mode .stage { background: #000; }
.data-core .stage.ready img, .data-core .stage.ready .loading { display: none; }
.data-core .loading {
  position: absolute; left: 50%; bottom: 18%;
  width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%;
  background: #8b9490;
  animation: loading-pulse 1.4s ease-in-out infinite;
}
.data-core .core.fallback-mode .loading { display: none; }
@keyframes loading-pulse { 50% { opacity: .2; transform: scale(.6); } }

/* Overlay UI inside the section */
.data-core .instrument, .data-core .console {
  position: absolute;
  z-index: 1;
  opacity: var(--scene-ui, 0);
}
.data-core .core:not(.immersed) .console, .data-core .core:not(.immersed) .details-open { visibility: hidden; }
.data-core .core.fallback-mode { --scene-ui: 1 !important; --entry-copy: 0 !important; }

.data-core .instrument {
  left: clamp(22px, 4vw, 66px);
  bottom: max(36px, env(safe-area-inset-bottom));
  max-width: min(360px, 42vw);
  pointer-events: none;
  text-shadow: 0 1px 3px #000, 0 1px 14px #000;
}
.data-core #dc-status {
  display: block;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  color: #c9d0cc;
}
.data-core .instrument-category { margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: #a9b2ad; }
.data-core #dc-plugin-tagline { margin: 4px 0 0; font-size: 13px; line-height: 1.55; color: #c9d0cc; }

.data-core .details-open {
  display: inline-flex;
  gap: 10px;
  width: auto;
  height: 38px;
  margin-top: 16px;
  padding: 0 18px;
  border: 1px solid #59625b80;
  border-radius: 32px;
  background: #060a09e8;
  font: inherit;
  font-size: 12px;
  pointer-events: auto;
  text-shadow: none;
}

.data-core .console {
  bottom: max(28px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 9px;
  align-items: center;
}
.data-core .navigation {
  display: flex;
  align-items: center;
  border: 1px solid #59625b80;
  border-radius: 32px;
  padding: 3px;
  background: #060a09e8;
}
.data-core .navigation-divider { height: 14px; width: 1px; background: #626b634d; }

.data-core button, .details button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #d9e2db;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.data-core button svg, .details button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.2; }
.data-core #dc-sound { border: 1px solid #59625b80; background: #060a09e8; }
.data-core #dc-sound:hover { background: #252e29; }
.data-core #dc-sound .sound-on { display: none; }
.data-core #dc-sound[aria-pressed="true"] .sound-off { display: none; }
.data-core #dc-sound[aria-pressed="true"] .sound-on { display: block; color: #9fdcff; }
.data-core button:hover, .details button:hover { background: #39413d66; color: #fff; }
.data-core button:focus-visible, .details button:focus-visible { outline: 2px solid #c8d5cc; outline-offset: 4px; }

/* Detail dialog */
.details {
  width: min(940px, calc(100vw - 32px));
  max-height: calc(100svh - 32px);
  padding: 0;
  border: 1px solid #59625b80;
  border-radius: 14px;
  background: #050807f5;
  color: #e3e6e4;
  overflow: auto;
}
.details[open] { display: grid; grid-template-columns: 1.35fr 1fr; animation: details-in .28s ease-out; }
.details::backdrop { background: #000a; backdrop-filter: blur(6px); }
@keyframes details-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.details-close-form { position: absolute; top: 10px; right: 10px; z-index: 1; margin: 0; }
.details .details-close { width: 40px; height: 40px; background: #050807cc; border: 1px solid #59625b80; }
.details .details-close svg { width: 18px; height: 18px; }
.details-image { width: 100%; height: 100%; min-height: 280px; object-fit: contain; background: #000; padding: 22px; border-right: 1px solid #59625b55; }
.details-body { display: flex; flex-direction: column; gap: 10px; padding: 44px 30px 26px; }
.details h2 { margin: 0; font: 400 clamp(30px, 4vw, 46px)/1.1 NegativMothDisplay, monospace; letter-spacing: .07em; }
.details-category { font-size: 12px; color: #a9b2ad; }
.details p { margin: 8px 0 0; font-size: 13px; line-height: 1.7; color: #c3cbc6; }
.details-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: auto; padding-top: 18px; }
.details-actions a {
  display: inline-flex; align-items: center; height: 40px; padding: 0 18px;
  border: 1px solid #59625b; border-radius: 32px;
  font-size: 12px; text-decoration: none; color: inherit;
}
.details-primary { background: #e3e6e4; color: #050807 !important; border-color: #e3e6e4 !important; }
.details-actions a[aria-disabled="true"] { opacity: .45; cursor: default; }
.details-actions a:not([aria-disabled]):hover { filter: brightness(1.15); }
.details-actions a:focus-visible { outline: 2px solid #c8d5cc; outline-offset: 3px; }
.details-nav { display: flex; gap: 4px; margin-top: 8px; }
/* Buy row: price and Add to cart (cart.js keeps the cart) */
.details-buy { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: auto; padding-top: 22px; border-top: 1px solid #59625b55; }
.details-price { font-size: 18px; letter-spacing: .02em; }   /* mono: the Moth font has no € */
.details .details-add {
  width: auto; height: 42px; padding: 0 22px; border-radius: 32px;
  background: #e3e6e4; color: #050807; font: inherit; font-size: 12px;
}
.details .details-add:hover { background: #fff; color: #050807; }
.details .details-add:disabled { background: transparent; color: #a9b2ad; border: 1px solid #59625b; cursor: default; }
/* Cart panel */
.cart[open] { display: block; width: min(560px, calc(100vw - 32px)); }
.cart-body { padding: 34px 30px 26px; }
.cart h2 { font-size: clamp(26px, 3vw, 34px); }
.cart-list { list-style: none; margin: 22px 0 0; padding: 0; }
.cart-list li { display: grid; grid-template-columns: 64px 1fr auto auto auto; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid #59625b55; }
.cart-list li:last-child { border-bottom: 1px solid #59625b55; }
.cart-list img { width: 64px; height: 44px; object-fit: contain; }
.cart-name { font: 400 18px/1 NegativMothDisplay, monospace; letter-spacing: .06em; }
.cart-price { font-size: 13px; color: #c3cbc6; }
.cart-checkout { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 32px; background: #e3e6e4; color: #050807; font-size: 12px; text-decoration: none; }
.cart-checkout:hover { background: #fff; }
.details .cart-remove { width: 38px; height: 38px; }
.cart-empty { display: none; margin: 18px 0 0; font-size: 13px; color: #c3cbc6; }
.cart.is-empty .cart-empty { display: block; }
.cart-empty a { display: inline-block; margin-top: 6px; padding: 10px 0; color: #e3e6e4; }
.details-page { display: inline-block; margin-top: 18px; padding: 10px 0; color: #e3e6e4; font-size: 14px; text-decoration: underline; text-underline-offset: 4px; }
.details-page[hidden] { display: none; }
.cart.is-empty .cart-list, .cart.is-empty .cart-note { display: none; }
.cart .cart-note { margin-top: 16px; font-size: 12px; color: #8d9692; }

@media (max-width: 700px) {
  .data-core .instrument { bottom: max(27px, env(safe-area-inset-bottom)); max-width: calc(100vw - 170px); }
  .data-core #dc-status { font-size: 12px; }
  .data-core .instrument-category, .data-core #dc-plugin-tagline { display: none; }
  .data-core .details-open { height: 44px; margin-top: 10px; padding: 0 16px; font-size: 12px; }
  .data-core .console { left: auto; right: 18px; bottom: max(20px, env(safe-area-inset-bottom)); transform: none; gap: 7px; }
  .data-core .navigation { padding: 1px; }
  .data-core button, .details button { width: 44px; height: 44px; }
  .details[open] { grid-template-columns: 1fr; }
  .details-image { min-height: 0; height: auto; max-height: 40svh; padding: 14px; border-right: 0; border-bottom: 1px solid #59625b55; }
  .details-body { padding: 22px 20px 18px; }
  .details h2 { font-size: 30px; }
  .details .details-add { width: auto; height: 44px; }
  .cart-body { padding: 26px 18px 20px; }
  .cart-list li { grid-template-columns: 48px 1fr auto auto; gap: 4px 10px; }
  .cart-list img { width: 48px; height: 34px; grid-row: 1 / 3; }
  .cart-name { grid-column: 2; grid-row: 1; }
  .cart-price { grid-column: 2; grid-row: 2; }
  .cart-checkout { grid-column: 3; grid-row: 1 / 3; }
  .details .cart-remove { grid-column: 4; grid-row: 1 / 3; width: 40px; height: 40px; }
}

@media (max-height: 500px) and (min-width: 701px) {
  .data-core .instrument { bottom: 21px; }
  .data-core .console { bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .data-core html { scroll-behavior: auto; }
  .data-core .loading, .details[open] { animation: none; }
}
