/* Products and projects page 3D viewer: one light panel, controls sit inside it like the home page studio. */
.model-viewer { --model-progress: 0%; width: 100%; min-width: 0; position: relative; background: var(--fog); color: var(--ink); }
/* On grey sections the panel turns white so it still reads as one surface. */
.block.alt .model-viewer { background: #fff; }
.model-viewport { position: relative; height: 520px; overflow: hidden; cursor: grab; touch-action: pan-y; outline-offset: -3px; }
.model-viewport.is-dragging { cursor: grabbing; }
.model-canvas { width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .55s; }
.model-ready .model-canvas { opacity: 1; }
.model-fallback-image { position: absolute; inset: 40px 0 70px; height: calc(100% - 110px); width: 100%; object-fit: contain; opacity: .2; transition: opacity .4s; }
.model-ready .model-fallback-image { opacity: 0; visibility: hidden; }
.model-failed .model-fallback-image { opacity: 1; }
.model-failed .model-canvas { display: none; }
.model-loading { position: absolute; inset: 50% 20px auto; margin: 0; font-size: 13px; text-align: center; color: var(--mute); pointer-events: none; }
.model-loading[hidden] { display: none; }

.model-labels { position: absolute; inset: 0; pointer-events: none; }
.model-part-label { position: absolute; display: flex; gap: 8px; align-items: center; white-space: nowrap; transform: translate(8px, -50%); opacity: 0; transition: opacity .2s; font-size: 13px; font-weight: 600; }
.model-part-label.is-left { flex-direction: row-reverse; transform: translate(calc(-100% - 8px), -50%); }
.model-part-label::before { content: ''; height: 1px; width: 24px; background: var(--ink); opacity: .45; }
.model-part-label b { padding: 2px 6px; background: var(--accent); color: #fff; font-family: var(--display); font-size: 12px; }
.model-part-label > span { padding: 2px 8px; background: rgba(255, 255, 255, .9); }

/* Top-right: product photographs, then zoom and reset. Icons only. */
.model-corner { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.model-corner button { width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); background: rgba(255, 255, 255, .92); color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer; transition: background .2s, border-color .2s, color .2s; }
.model-corner button:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.model-corner svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.model-photo { display: block; width: 58px; height: 58px; margin-bottom: 4px; background: #fff; border: 1px solid var(--line); transition: border-color .2s, transform .3s; }
.model-photo img { width: 100%; height: 100%; object-fit: cover; }
.model-photo:hover { border-color: var(--accent); transform: translateY(-2px); }

/* Rotation hint: a small orbit arrow that sways until the first drag. */
.model-hint { position: absolute; left: 50%; bottom: 70px; display: flex; align-items: center; gap: 6px; padding: 6px 12px; transform: translateX(-50%); background: rgba(255, 255, 255, .9); border-radius: 999px; font-family: var(--display); font-weight: 700; font-size: 14px; letter-spacing: .06em; color: var(--ink); pointer-events: none; opacity: 0; transition: opacity .5s; }
.model-hint svg { width: 34px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; animation: model-sway 1.8s ease-in-out infinite; }
.model-ready .model-hint { opacity: 1; }
.model-viewer.has-interacted .model-hint { opacity: 0; }
@keyframes model-sway { 0%, 100% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }

/* Bottom: one action button and the slider, directly on the panel. */
.model-controls { position: absolute; left: 16px; right: 16px; bottom: 14px; display: flex; align-items: center; gap: 18px; }
.model-toggle { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 0; background: #fff; color: var(--accent); cursor: pointer; font-family: var(--display); font-weight: 700; font-size: 14px; letter-spacing: .1em; text-transform: uppercase; box-shadow: 0 6px 18px rgba(10, 14, 20, .08); transition: background .2s, color .2s; }
.model-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.model-toggle:hover, .model-toggle.is-active { background: var(--accent); color: #fff; }
.model-controls input { flex: 1; min-width: 0; appearance: none; -webkit-appearance: none; height: 30px; margin: 0; cursor: ew-resize; background: transparent; }
.model-controls input::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(90deg, var(--accent) var(--model-progress), #cfd5db var(--model-progress)); }
.model-controls input::-moz-range-track { height: 2px; background: #cfd5db; }
.model-controls input::-moz-range-progress { height: 2px; background: var(--accent); }
.model-controls input::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); margin-top: -7px; }
.model-controls input::-moz-range-thumb { box-sizing: border-box; width: 16px; height: 16px; border: 3px solid var(--accent); border-radius: 50%; background: #fff; }
.model-viewer :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.model-viewer button:disabled, .model-viewer input:disabled { opacity: .35; cursor: default; }
.model-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Project cards: the viewer fills the photo column. */
.case-ph .model-viewer { position: absolute; inset: 0; background: var(--fog); }
.case-ph .model-viewport { height: 100%; }
.case-ph .case-no { z-index: 2; }

@media (max-width: 1050px) { .model-viewport { height: 460px; } }
@media (max-width: 760px) { .model-viewport { height: 420px; } }
@media (max-width: 480px) {
  .model-viewport { height: 380px; }
  .model-controls { gap: 12px; left: 12px; right: 12px; }
  .model-toggle { padding: 8px 10px; font-size: 12.5px; }
  .model-photo { width: 48px; height: 48px; }
  .model-part-label > span { display: none; }
  .model-part-label::before { width: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .model-viewer *, .model-viewer *::before { transition: none !important; }
  .model-hint svg { animation: none; }
}

/* Photo lightbox (js/lightbox.js). */
.lightbox { padding: 0; border: 0; max-width: min(94vw, 1200px); max-height: 92vh; background: transparent; overflow: visible; }
.lightbox::backdrop { background: rgba(8, 10, 13, .86); backdrop-filter: blur(4px); }
.lightbox img { display: block; max-width: min(94vw, 1200px); max-height: 92vh; object-fit: contain; background: #fff; }
.lightbox-close { position: absolute; top: -14px; right: -14px; width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: var(--accent); color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.lightbox[open] { animation: lightbox-in .3s var(--motion-ease, ease) both; }
@keyframes lightbox-in { from { opacity: 0; transform: scale(.97); } }
