/* 3D PRODUCT LAB — markup is built by js/lab3d.js inside #lab-app.
   Only the :root tokens of css/site.css are used (see _SPEC.md). Class prefix: lab- */

.lab-app {
  --lab-stage-h: min(78vh, 760px);
  --lab-glass: color-mix(in srgb, var(--bg) 72%, transparent);
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  color: var(--tx);
  font-family: var(--f-sans);
}
.lab-app *, .lab-app *::before, .lab-app *::after { box-sizing: border-box; }
:where(.lab-app) button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }   /* zero specificity: component rules below win */
.lab-app :focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---------------------------------------------------------------- sidebar */
.lab-side {
  display: flex; flex-direction: column; min-width: 0;
  height: var(--lab-stage-h); overflow-y: auto;
  padding: 6px 0;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius);
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.lab-cats { position: relative; display: flex; flex-direction: column; }
.lab-cat {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 17px 20px;
  background: none; border: 0; border-top: 1px solid var(--line-soft); cursor: pointer; text-align: left;
  font-family: var(--f-mono); font-size: 12px; line-height: 1.3; letter-spacing: .14em; text-transform: uppercase;
  color: var(--tx-2); transition: color .2s ease;
}
.lab-cat:first-child { border-top: 0; }
.lab-cat.is-on { color: var(--tx); }
.lab-sq { display: inline-block; width: 6px; height: 6px; flex: 0 0 6px; background: var(--tx-3); opacity: .45; }
.lab-cat.is-on .lab-sq { background: var(--red); opacity: 1; }
.lab-cat-name { flex: 1; min-width: 0; }
.lab-cat-n { font-size: 11px; color: var(--tx-3); letter-spacing: .08em; }

.lab-models { position: relative; list-style: none; margin: 0 0 10px; padding: 0 10px; display: flex; flex-direction: column; gap: 2px; }
.lab-models li { margin: 0; padding: 0; }
.lab-model {
  position: relative; display: flex; flex-direction: column; gap: 5px; width: 100%;
  padding: 11px 14px 11px 18px;
  background: none; border: 0; border-radius: 6px; cursor: pointer; text-align: left;
  transition: background-color .2s ease;
}
.lab-model::before { content: ''; position: absolute; left: 0; top: 9px; bottom: 9px; width: 2px; background: var(--red); opacity: 0; transition: opacity .2s ease; }
.lab-model.is-on { background: var(--bg-2); }
.lab-model.is-on::before { opacity: 1; }
.lab-model-t { font-family: var(--f-sans); font-size: 15px; line-height: 1.2; color: var(--tx-2); }
.lab-model.is-on .lab-model-t { color: var(--tx); }
.lab-model-c { font-family: var(--f-mono); font-size: 11px; line-height: 1.3; letter-spacing: .02em; color: var(--tx-3); }

/* ---------------------------------------------------------------- stage */
.lab-stage {
  container: labstage / size;                             /* the overlays below switch to a compact layout on small stages */
  position: relative; min-width: 0; height: var(--lab-stage-h); overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: radial-gradient(ellipse at 60% 45%, #1f2327 0%, #111315 55%, #0b0c0d 100%);
}
.lab-app .lab-stage:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.lab-stage:fullscreen { width: 100vw; height: 100vh; border: 0; border-radius: 0; }
.lab-stage:-webkit-full-screen { width: 100vw; height: 100vh; border: 0; border-radius: 0; }
.lab-view { position: absolute; inset: 0; }
.lab-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; transition: opacity .17s ease; }
.lab-canvas:active { cursor: grabbing; }
.lab-view.is-out .lab-canvas { opacity: 0; }

.lab-tag {
  position: absolute; top: 20px; left: 22px; right: 150px; margin: 0;
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-mono); font-size: 12px; line-height: 1.35; letter-spacing: .14em; text-transform: uppercase; color: var(--tx-2);
  pointer-events: none;
}
.lab-tag .lab-sq { background: var(--red); opacity: 1; }

.lab-tools { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; }
.lab-btn {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 6px; color: var(--tx-2); cursor: pointer;
  transition: color .2s ease, border-color .2s ease;
}
.lab-btn[aria-pressed="true"] { color: var(--tx); }
.lab-btn[hidden] { display: none; }
.lab-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* spec panel (bottom-left) */
.lab-spec {
  position: absolute; left: 16px; bottom: 16px; width: 340px; max-width: calc(100% - 32px);
  padding: 18px 20px 10px;
  background: var(--lab-glass); border: 1px solid var(--line-soft); border-radius: var(--radius);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.lab-spec-bar { display: none; }
.lab-spec-title { margin: 0 0 12px; font-family: var(--f-sans); font-weight: 400; font-size: 28px; line-height: 1; letter-spacing: -.02em; color: var(--tx); }
.lab-spec-rows { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 20px; margin: 0; }
.lab-spec-rows dt, .lab-spec-rows dd { margin: 0; padding: 7px 0; border-top: 1px solid var(--line-soft); font-family: var(--f-mono); }
.lab-spec-rows dt { padding-top: 9px; font-size: 11px; line-height: 1.3; letter-spacing: .14em; text-transform: uppercase; color: var(--tx-3); }
.lab-spec-rows dd { font-size: 13px; line-height: 1.45; color: var(--tx); }

/* explode (bottom-right) */
.lab-explode {
  position: absolute; right: 16px; bottom: 16px;
  display: flex; align-items: center; gap: 12px; padding: 11px 16px;
  background: var(--lab-glass); border: 1px solid var(--line-soft); border-radius: var(--radius);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.lab-explode[hidden] { display: none; }
.lab-ex-label { font-family: var(--f-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--tx-2); }
.lab-ex-val { min-width: 3.4em; text-align: right; font-family: var(--f-mono); font-size: 11px; letter-spacing: .06em; color: var(--tx-3); }
.lab-range { --p: 0%; -webkit-appearance: none; appearance: none; width: 140px; height: 20px; margin: 0; background: transparent; cursor: pointer; }
.lab-range::-webkit-slider-runnable-track { height: 2px; border-radius: 2px; background: linear-gradient(to right, var(--red) 0 var(--p), var(--line) var(--p) 100%); }
.lab-range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px; border-radius: 50%; background: var(--red); border: 2px solid var(--bg-1); }
.lab-range::-moz-range-track { height: 2px; border-radius: 2px; background: var(--line); }
.lab-range::-moz-range-progress { height: 2px; border-radius: 2px; background: var(--red); }
.lab-range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--red); border: 2px solid var(--bg-1); }
.lab-range:focus-visible { outline-offset: 4px; }

/* loading, hint, message */
.lab-loading {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none;
}
.lab-loading[hidden] { display: none; }
.lab-bar { width: 180px; height: 2px; overflow: hidden; border-radius: 2px; background: var(--line); }
.lab-bar i { display: block; width: 0; height: 100%; background: var(--red); transition: width .2s ease; }
.lab-loading.is-indet .lab-bar i { width: 35%; animation: lab-indet 1.1s ease-in-out infinite; }
@keyframes lab-indet { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
.lab-pct { font-family: var(--f-mono); font-size: 11px; letter-spacing: .14em; color: var(--tx-2); }

.lab-hint {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); margin: 0;
  padding: 9px 14px; border-radius: 6px;
  background: var(--lab-glass); border: 1px solid var(--line-soft);
  font-family: var(--f-mono); font-size: 11px; line-height: 1.2; letter-spacing: .06em; color: var(--tx-2); white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity .6s ease;
}
.lab-hint.is-on { opacity: 1; }
.lab-hint.is-gone { opacity: 0; }

.lab-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: 24px; text-align: center;
}
.lab-msg[hidden] { display: none; }
.lab-msg p { margin: 0; max-width: 36ch; font-size: 15px; font-weight: 300; line-height: 1.5; color: var(--tx-2); }
.lab-retry {
  padding: 10px 16px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--tx);
}
.lab-retry[hidden] { display: none; }

/* ---------------------------------------------------------------- mobile (< 900px) */
@media (max-width: 899px) {
  .lab-app { --lab-stage-h: min(68svh, 640px); grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .lab-side { height: auto; overflow: visible; padding: 0; gap: 8px; background: none; border: 0; border-radius: 0; }
  .lab-cats, .lab-models {
    flex-direction: row; gap: 8px; margin: 0; padding: 0 0 2px;
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  }
  .lab-cats::-webkit-scrollbar, .lab-models::-webkit-scrollbar { display: none; }
  .lab-cat, .lab-cat:first-child {
    flex: 0 0 auto; width: auto; gap: 8px; padding: 13px 14px; white-space: nowrap;
    background: var(--bg-1); border: 1px solid var(--line); border-radius: 6px; font-size: 11px;
  }
  .lab-cat.is-on { background: var(--bg-2); border-color: var(--tx-3); }
  .lab-cat-n { display: none; }
  .lab-models li { flex: 0 0 auto; }
  .lab-model { width: auto; gap: 3px; padding: 8px 13px 8px 15px; border: 1px solid var(--line-soft); white-space: nowrap; }
  .lab-model::before { top: 8px; bottom: 8px; }
  .lab-model-t { font-size: 13px; }
  .lab-model-c { font-size: 12px; }
}
@media (max-width: 899px) and (orientation: landscape) {
  .lab-app { --lab-stage-h: calc(100svh - 72px); }
}
/* one model only (product pages, lab3d.js data-only): no picker, the stage takes the whole width */
.lab-app[data-only] { grid-template-columns: minmax(0, 1fr); }
.lab-app[data-only] .lab-side { display: none; }
@media (max-width: 760px) {
  .lab-spec-bar-c { font-size: 12px; }
}
/* touch screens: bigger buttons and slider thumb */
@media (pointer: coarse) {
  .lab-btn { width: 40px; height: 40px; }
  .lab-range { height: 36px; }
  .lab-range::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -10px; }
  .lab-range::-moz-range-thumb { width: 20px; height: 20px; }
}

/* ---------------------------------------------------------------- compact stage overlays
   (phones, and desktop stages narrower than 820px or lower than 520px): the spec panel becomes a one-line bar that
   expands, the explode control sits above it, the drag hint moves to a second row */
@container labstage (max-width: 820px) or (max-height: 520px) {
  .lab-tag { top: 15px; left: 14px; right: 150px; align-items: flex-start; font-size: 10.5px; letter-spacing: .12em; }
  .lab-tag .lab-sq { margin-top: 4px; }
  .lab-tools { top: 10px; right: 10px; gap: 6px; }

  .lab-spec { left: 10px; right: 10px; bottom: 10px; width: auto; max-width: none; padding: 0; }
  .lab-spec-bar {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px;
    background: none; border: 0; cursor: pointer; text-align: left;
  }
  .lab-spec-bar-t { font-family: var(--f-sans); font-size: 17px; line-height: 1.1; letter-spacing: -.01em; color: var(--tx); white-space: nowrap; }
  .lab-spec-bar-c { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--f-mono); font-size: 10.5px; color: var(--tx-3); }
  .lab-spec-chev { display: grid; place-items: center; }
  .lab-spec-chev svg { width: 16px; height: 16px; fill: none; stroke: var(--tx-2); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s ease; }
  .lab-spec.is-open .lab-spec-chev svg { transform: rotate(180deg); }
  .lab-spec-body { display: none; max-height: 44cqh; overflow-y: auto; padding: 0 14px 10px; }
  .lab-spec.is-open .lab-spec-body { display: block; }
  .lab-spec-title { display: none; }
  .lab-spec-rows dd { font-size: 12.5px; }

  .lab-explode { right: 10px; bottom: 66px; gap: 10px; padding: 8px 12px; }
  .lab-spec.is-open ~ .lab-explode { visibility: hidden; }   /* keeps its box: the framing measures it */
  .lab-range { width: 110px; }
}
/* the drag hint: second row wherever the top row is too narrow for tag + hint + buttons; not at all on very low stages */
@container labstage (max-width: 940px) { .lab-hint { top: 58px; } }
@container labstage (max-height: 360px) { .lab-hint { display: none; } }

/* short desktop screens: 5 categories + 5 models fit the sidebar without scrolling */
@media (min-width: 900px) and (max-height: 820px) {
  .lab-cat { padding-top: 13px; padding-bottom: 13px; }
  .lab-model { padding-top: 9px; padding-bottom: 9px; }
}
@media (min-width: 900px) and (max-height: 700px) {
  .lab-cat { padding-top: 11px; padding-bottom: 11px; }
  .lab-model { gap: 3px; padding-top: 7px; padding-bottom: 7px; }
}

@media (hover: hover) {
  .lab-cat:hover { color: var(--tx); }
  .lab-model:hover { background: var(--bg-2); }
  .lab-model:hover .lab-model-t { color: var(--tx); }
  .lab-btn:hover { color: var(--tx); border-color: var(--tx-3); }
  .lab-retry:hover { border-color: var(--tx-3); }
}

@media (prefers-reduced-motion: reduce) {
  .lab-app *, .lab-app *::before, .lab-app *::after { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------- translated text in mono-styled slots
   Hangul / kana / hanzi with wide mono tracking and uppercase styling look broken: those slots use the sans face,
   near-normal tracking and a comparable size in ko / ja / zh.  English keeps the mono labels (same approach as the
   end of css/site.css). */
html:not([data-lang="en"]) :is(.lab-cat-name, .lab-spec-rows dt, .lab-hint, .lab-ex-label, .lab-retry) {
  font-family: var(--f-sans); letter-spacing: .01em; text-transform: none;
}
html:not([data-lang="en"]) .lab-cat-name { font-size: 14px; font-weight: 500; }
html:not([data-lang="en"]) .lab-spec-rows dt { font-size: 12.5px; line-height: 1.35; padding-top: 8px; color: var(--tx-2); }
html:not([data-lang="en"]) .lab-hint { font-size: 12.5px; }
html:not([data-lang="en"]) .lab-ex-label { font-size: 12.5px; }
html:not([data-lang="en"]) .lab-retry { font-size: 13px; font-weight: 500; }
@media (max-width: 899px) {
  html:not([data-lang="en"]) .lab-cat-name { font-size: 13px; }
}
