/* Karkhano Gallery — loaded only on /gallery/. Everything is scoped to this standalone page. */
:root { --kmg-bg: #14110e; --kmg-ink: #f6efe4; --kmg-muted: #b9ab97; --kmg-gold: #e8b464; --kmg-orange: #fd7c47; }
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body.kmg { background: var(--kmg-bg); color: var(--kmg-ink); font: 15px/1.5 Figtree, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
.kmg a { color: inherit; }

.kmg-bar { position: fixed; inset: 0 0 auto 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: max(12px, env(safe-area-inset-top)) 16px 12px; background: linear-gradient(#14110eee, #14110e00); }
.kmg-title { margin: 0; font: 600 16px/1.2 Montserrat, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--kmg-gold); }
.kmg-back, .kmg-cart { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid #ffffff2a; border-radius: 999px; background: #ffffff10; text-decoration: none; font-weight: 600; font-size: 14px; backdrop-filter: blur(6px); }
.kmg-back:hover, .kmg-cart:hover { border-color: var(--kmg-gold); }
.kmg-cart span { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--kmg-orange); color: #fff; font-size: 12px; text-align: center; }

/* 3D stage (hidden until WebGL is ready) */
.kmg-stage { display: none; position: fixed; inset: 0; touch-action: none; cursor: grab; }
.kmg-stage.is-hovering { cursor: pointer; }
.kmg-stage.is-dragging { cursor: grabbing; }
/* Pointer-transparent vignette adds depth without intercepting product taps. */
html.kmg-3d .kmg-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 44%, transparent 38%, #080a0b55 100%); }
.kmg-loading, .kmg-hint { z-index: 1; }
html.kmg-3d .kmg-stage { display: block; }
.kmg-canvas { display: block; width: 100%; height: 100%; }
.kmg-loading { position: absolute; inset: 0; display: grid; place-content: center; gap: 14px; justify-items: center; color: var(--kmg-muted); font-size: 14px; background: var(--kmg-bg); transition: opacity 2.5s ease; }
.kmg-loading span { width: 34px; height: 34px; border: 3px solid #ffffff22; border-top-color: var(--kmg-gold); border-radius: 50%; animation: kmg-spin .9s linear infinite; }
.kmg-loading.is-done { opacity: 0; pointer-events: none; }
@keyframes kmg-spin { to { transform: rotate(360deg); } }
.kmg-hint { position: absolute; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); margin: 0; padding: 7px 14px; border-radius: 999px; background: #00000066; color: var(--kmg-ink); font-size: 13px; white-space: nowrap; transition: opacity .8s ease; pointer-events: none; }
.kmg-hint.is-gone { opacity: 0; }

/* Room chips */
.kmg-chips { display: none; position: fixed; inset: auto 0 0 0; z-index: 5; gap: 8px; overflow-x: auto; padding: 14px 16px max(16px, env(safe-area-inset-bottom)); background: linear-gradient(#14110e00, #14110eee); scrollbar-width: none; }
.kmg-chips::-webkit-scrollbar { display: none; }
html.kmg-3d .kmg-chips { display: flex; justify-content: safe center; }
.kmg-chip { flex: none; padding: 9px 16px; border: 1px solid #ffffff2e; border-radius: 999px; background: #ffffff12; color: var(--kmg-ink); font-weight: 600; font-size: 13px; line-height: 1; font-family: inherit; cursor: pointer; backdrop-filter: blur(6px); transition: background .2s, border-color .2s, color .2s; }
.kmg-chip:hover { border-color: var(--kmg-gold); }
.kmg-chip[aria-current="true"] { background: var(--kmg-gold); border-color: var(--kmg-gold); color: #1d160c; }

/* Product card */
.kmg-card { position: fixed; z-index: 6; right: 20px; top: 50%; transform: translateY(-50%); width: min(360px, calc(100vw - 32px)); overflow: hidden; border-radius: 18px; background: #1f1a15f2; border: 1px solid #ffffff1f; box-shadow: 0 24px 60px #000a; backdrop-filter: blur(10px); }
.kmg-card[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) { .kmg-card:not([hidden]) { animation: kmg-card-in .35s cubic-bezier(.2,.8,.3,1); } }
@keyframes kmg-card-in { from { opacity: 0; transform: translate(24px, -50%); } }
.kmg-card__close { position: absolute; top: 10px; right: 10px; z-index: 1; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #000a; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.kmg-card__img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; }
.kmg-card__body { padding: 16px 18px 18px; }
.kmg-card__room { margin: 0 0 4px; color: var(--kmg-gold); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.kmg-card__name { margin: 0 0 8px; font: 600 17px/1.35 Montserrat, system-ui, sans-serif; }
.kmg-card__price { margin: 0 0 14px; font-size: 18px; }
.kmg-card__price del { color: var(--kmg-muted); font-size: 14px; margin-left: 6px; }
.kmg-card__actions { display: flex; gap: 10px; }
.kmg-btn { flex: 1; display: inline-flex; justify-content: center; align-items: center; padding: 11px 14px; border: 1px solid #ffffff33; border-radius: 12px; background: transparent; color: var(--kmg-ink); font-weight: 600; font-size: 14px; line-height: 1.2; font-family: inherit; text-decoration: none; cursor: pointer; }
.kmg-btn--primary { background: var(--kmg-orange); border-color: var(--kmg-orange); color: #fff; }
.kmg-btn[disabled] { opacity: .6; cursor: progress; }
.kmg-card__msg { margin: 12px 0 0; font-size: 13px; color: var(--kmg-muted); }
.kmg-card__msg a { color: var(--kmg-gold); font-weight: 600; }
@media (max-width: 767px) {
	.kmg-card { right: 0; left: 0; top: auto; bottom: 0; transform: none; width: 100%; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
	.kmg-card__img { aspect-ratio: 16 / 10; }
	@keyframes kmg-card-in { from { opacity: 0; transform: translateY(40px); } }
	.kmg-title { font-size: 13px; }
}

/* 2D grid: shown without WebGL / with reduced motion; hidden once the 3D hall runs */
.kmg-grid { padding: 84px 16px 32px; max-width: 1200px; margin: 0 auto; }
html.kmg-3d .kmg-grid { display: none; }
.kmg-room h2 { margin: 28px 0 12px; font: 600 18px/1.3 Montserrat, system-ui, sans-serif; color: var(--kmg-gold); }
.kmg-room h2 a { text-decoration: none; }
.kmg-room ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kmg-room li a { display: block; padding: 8px; border-radius: 12px; background: #ffffff0c; text-decoration: none; }
.kmg-room img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: #fff; }
.kmg-grid__name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 8px; font-size: 13px; }
.kmg-grid__price { display: block; margin-top: 4px; color: var(--kmg-gold); font-weight: 600; font-size: 14px; }
html.km-play-app .is-replica { display: none; }
