/* ===== BrainPang Detective Agency — portrait-first meta screen ===== */

#screen-hq {
  --hq-tray-height: 278px;
  background: transparent;
  color: var(--color-text, #ffffff);
  overflow: hidden;
}

.hq-topbar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: calc(var(--safe-top, 0px) + 8px) 10px 8px;
  background: transparent;
  pointer-events: none;
}

.hq-topbar > * { pointer-events: auto; }

#btn-hq-back {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 50%;
  background: url('../assets/hq/ui-v2/back-button.png') center / 100% 100% no-repeat;
  color: var(--color-text, #ffffff);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

#btn-hq-back:focus-visible {
  outline: 3px solid var(--color-accent, #ffb703);
  outline-offset: 2px;
}

/* Layered over the room scene (not the flat topbar strip) so it reads as a
   sign in the office rather than a UI label. The aspect-ratio locks the
   container to the panel artwork's native 900:300 shape so it can never be
   stretched off-ratio at any viewport size; the bg and wordmark images then
   scale together inside it via object-fit/percentage width instead of
   fixed pixels. */
.hq-title {
  position: absolute;
  top: calc(var(--safe-top, 0px) + 50px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  margin: 0;
  width: 57.4%;
  max-width: 273px;
  aspect-ratio: 900 / 300;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.hq-title-text {
  position: relative;
  z-index: 1;
  width: 78%;
  color: #fff4cf;
  font-size: clamp(0.8rem, 3.2vw, 1.25rem);
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  text-shadow: 0 2px 0 #4b1d0c, 0 0 4px #4b1d0c;
}

.hq-title-panel-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}


.hq-topbar-stats {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

.hq-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #2d1c19;
}

.hq-scene-layer {
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  transform-origin: 50% 50%;
  transition: filter 240ms ease, opacity 240ms ease;
}

.hq-scene-layer--inactive {
  filter: none;
  opacity: 1;
}

.hq-scene-layer--active { opacity: 1; }

.hq-scene-room {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  z-index: 0;
  transform: translate(-50%, -50%);
}

.hq-object-zone {
  position: absolute;
  left: 2%;
  right: 2%;
  top: 15%;
  bottom: calc(var(--hq-tray-height) + 8px);
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.hq-scene-composition {
  position: absolute;
  inset: 0;
  z-index: 1;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  gap: clamp(8px, 2.5vw, 16px);
  padding: clamp(4px, 1.5vw, 10px);
  pointer-events: none;
}

.hq-scene-composition > .hq-scene-layer {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: none;
}

.hq-scene-composition:not(:has([data-object-size="large"])) > .hq-scene-layer:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  justify-self: center;
}

.hq-scene-composition > .hq-scene-layer[data-object-size="large"] {
  order: 1;
  grid-column: 1 / -1;
}

.hq-scene-composition:has([data-object-size="large"]) {
  grid-template-rows: minmax(0, 45fr) minmax(0, 55fr);
}

.hq-scene-lamp.hq-scene-layer--active {
  filter: drop-shadow(0 0 14px rgba(255, 195, 69, 0.55));
}

@keyframes hq-object-activate {
  0% { opacity: 0.1; filter: brightness(2.2) drop-shadow(0 0 0 rgba(255, 222, 86, 0)); }
  42% { opacity: 1; filter: brightness(1.35) drop-shadow(0 0 24px rgba(255, 222, 86, 0.95)); }
  68% { filter: brightness(1.08) drop-shadow(0 0 12px rgba(255, 222, 86, 0.65)); }
  100% { opacity: 1; }
}

.hq-scene-layer--activating {
  animation: hq-object-activate 760ms cubic-bezier(0.2, 0.85, 0.28, 1) both;
}

.hq-tray {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  box-sizing: border-box;
  display: flex;
  height: var(--hq-tray-height);
  gap: 8px;
  padding: 22px 14px calc(var(--safe-bottom, 0px) + 22px);
  overflow-x: auto;
  background: linear-gradient(180deg, rgba(16, 23, 53, 0) 0%, rgba(16, 23, 53, 0.78) 24%, #101735 100%);
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", "Segoe UI Rounded", sans-serif;
}

.hq-card {
  position: relative;
  box-sizing: border-box;
  flex: 1 1 0;
  min-width: 0;
  min-height: 226px;
  border-radius: 14px;
  padding: 13px 6px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.hq-card[data-object-state="active"] {
  background: url('../assets/hq/ui-v2/object-card-bg-active.png') center / 100% 100% no-repeat;
}

.hq-card[data-object-state="inactive"] {
  background: url('../assets/hq/ui-v2/object-card-bg-inactive.png') center / 100% 100% no-repeat;
}

.hq-card-object {
  display: block;
  position: absolute;
  left: 50%;
  top: 46%;
  width: 133px;
  height: 133px;
  margin: 0;
  transform: translate(-50%, -50%);
  object-fit: contain;
  z-index: 1;
}

.hq-card-completion {
  position: absolute;
  top: -7px;
  left: 50%;
  width: 48px;
  height: 48px;
  transform: translateX(-50%);
  object-fit: contain;
  z-index: 3;
}

.hq-card-price {
  position: relative;
  z-index: 2;
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
  text-shadow: 0 2px 2px rgba(13, 18, 48, 0.72);
}

.hq-card-state {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  margin: 0;
  font-size: 0.72rem;
  color: var(--color-text-dim, #cfc9e8);
}

.hq-card-state--locked {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 2px 6px;
  padding: 3px 4px;
  line-height: 1.2;
  text-align: center;
}

.hq-card-state--locked .hq-status-icon {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.hq-card-lock-reason,
.hq-card-lock-price {
  display: block;
  grid-column: 2;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: normal;
}

@media (max-width: 420px) {
  .hq-card {
    flex: 0 0 142px;
    min-width: 142px;
  }
}

.hq-status-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.hq-icon-check {
  color: var(--color-success, #4dff88);
}

.hq-icon-lock {
  color: var(--color-text-dim, #cfc9e8);
}

.hq-buy-btn {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 44px;
  min-width: 44px;
  border: none;
  border-radius: 10px;
  background: url('../assets/hq/button-green.webp') center / 100% 100% no-repeat;
  color: #132106;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.hq-buy-btn:disabled {
  filter: grayscale(1) brightness(0.65);
  color: rgba(255, 255, 255, 0.7);
  cursor: not-allowed;
}

.hq-buy-btn:focus-visible {
  outline: 3px solid var(--color-accent, #ffb703);
  outline-offset: 2px;
}

@media (min-width: 700px) {
  #screen-hq {
    left: 50%;
    right: auto;
    width: 520px;
    transform: translateX(-50%);
    box-shadow: 0 0 44px rgba(4, 2, 14, 0.72);
  }
}

@media (max-height: 720px) {
  #screen-hq { --hq-tray-height: 246px; }

  .hq-title {
    top: calc(var(--safe-top, 0px) + 54px);
    width: 50.4%;
  }

  .hq-tray {
    padding-top: 18px;
    padding-bottom: calc(var(--safe-bottom, 0px) + 18px);
  }

  .hq-card { min-height: 204px; }
  .hq-card-object { width: 112px; height: 112px; }
}

@media (prefers-reduced-motion: reduce) {
  #screen-hq, .hq-card, .hq-scene-layer, .hq-buy-btn {
    animation: none !important;
    transition: none !important;
  }

  .hq-scene-layer--activating { animation: none !important; }
}
