/* The Art of Countess — 3D museum overlays (HUD, panels, controls). */

:root {
  --m-bg: #0d0a08;
  --m-text: #f4ece2;
  --m-muted: #b8a596;
  --m-accent: #c9874f;
  --m-accent-dark: #8a5230;
  --m-panel: rgba(22, 16, 12, 0.82);
  --m-line: rgba(220, 195, 170, 0.18);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  background: #000;
  color: var(--m-text);
  font-family: 'Cormorant Garamond', Georgia, serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* --- Top bar --- */
.museum-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
}
.museum-topbar a {
  pointer-events: auto;
  color: inherit;
  text-decoration: none;
}
.museum-brand {
  font-size: 22px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.7);
}
.museum-brand small {
  display: block;
  font-size: 11px;
  letter-spacing: 0.42em;
  color: var(--m-accent);
  margin-top: 2px;
}

/* --- Crosshair --- */
.crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.12);
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s, transform 0.2s, border-color 0.2s;
}
.crosshair.is-active {
  opacity: 1;
}
.crosshair.is-target {
  transform: scale(1.6);
  border-color: var(--m-accent);
  background: rgba(201, 135, 79, 0.35);
}

/* --- Hint --- */
.hud-hint {
  position: fixed;
  left: 50%;
  top: 58%;
  transform: translateX(-50%);
  z-index: 18;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(15, 10, 7, 0.62);
  border: 1px solid var(--m-line);
  color: var(--m-text);
  letter-spacing: 0.06em;
  font-size: 16px;
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}
.hud-hint b {
  display: inline-block;
  min-width: 24px;
  padding: 2px 9px;
  margin-right: 8px;
  border-radius: 6px;
  border: 1px solid var(--m-accent);
  color: var(--m-accent);
  font-weight: 700;
}
.hud-hint.is-visible {
  opacity: 1;
}

/* --- Always-on controls bar --- */
.controls-bar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 19;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(15, 10, 7, 0.55);
  border: 1px solid var(--m-line);
  backdrop-filter: blur(8px);
  color: var(--m-muted);
  font-size: 14px;
  letter-spacing: 0.04em;
  pointer-events: none;
  max-width: calc(100% - 32px);
}
.controls-bar b {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--m-line);
  color: var(--m-text);
  font-weight: 600;
}
@media (pointer: coarse) {
  .controls-bar {
    display: none;
  }
}

/* --- Art info panel (below painting) --- */
.art-panel {
  position: fixed;
  left: 50%;
  bottom: 66px;
  transform: translate(-50%, 16px);
  z-index: 22;
  width: min(680px, calc(100% - 40px));
  display: flex;
  gap: 18px;
  padding: 18px;
  border-radius: 16px;
  background: var(--m-panel);
  border: 1px solid var(--m-line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s, transform 0.35s;
}
.art-panel.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.art-panel-thumb {
  position: relative;
  flex: 0 0 116px;
  width: 116px;
  height: 116px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--m-line);
  cursor: zoom-in;
  background: #1a120c;
}
.art-panel-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.art-panel-thumb .thumb-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  letter-spacing: 0.05em;
}
.art-panel-body {
  flex: 1;
  min-width: 0;
}
.art-panel-titlerow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}
.art-panel-title {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.art-panel-price {
  font-size: 22px;
  color: var(--m-accent);
  white-space: nowrap;
}
.art-panel-size {
  margin: 2px 0 8px;
  font-size: 15px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--m-muted);
}
.art-panel-desc {
  margin: 0 0 14px;
  font-size: 17px;
  line-height: 1.45;
  color: #e7dccf;
}
.art-panel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.art-btn {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: transform 0.12s, background 0.2s, border-color 0.2s;
}
.art-btn:active {
  transform: translateY(1px);
}
.art-btn.primary {
  background: var(--m-accent);
  color: #1a0f08;
  font-weight: 700;
}
.art-btn.primary:hover {
  background: #d9965b;
}
.art-btn.primary.in-cart {
  background: transparent;
  color: var(--m-text);
  border-color: var(--m-accent);
  font-weight: 600;
}
.art-btn.primary.in-cart:hover {
  background: rgba(201, 135, 79, 0.16);
}
.art-btn.ghost {
  background: transparent;
  border-color: var(--m-line);
  color: var(--m-text);
}
.art-btn.ghost:hover {
  border-color: var(--m-accent);
}
.art-btn .key {
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 12px;
  letter-spacing: 0.05em;
  border: 1px solid currentColor;
  opacity: 0.65;
  vertical-align: middle;
}

/* --- Start screen --- */
.start-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 30%, rgba(40, 26, 18, 0.6), transparent 60%),
    rgba(5, 3, 2, 0.86);
  backdrop-filter: blur(4px);
  transition: opacity 0.6s;
}
.start-screen.is-hidden {
  opacity: 0;
  pointer-events: none;
}
.start-eyebrow {
  font-size: 13px;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--m-accent);
  margin: 0 0 14px;
}
.start-title {
  margin: 0;
  font-size: clamp(38px, 8vw, 78px);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
}
.start-sub {
  margin: 14px 0 26px;
  font-size: clamp(16px, 2.4vw, 20px);
  color: var(--m-muted);
  max-width: 520px;
}
.start-enter {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 17px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 16px 42px;
  border-radius: 999px;
  border: 1px solid var(--m-accent);
  background: var(--m-accent);
  color: #1a0f08;
  font-weight: 700;
  transition: transform 0.15s, background 0.2s;
}
.start-enter:hover {
  transform: translateY(-2px);
  background: #d9965b;
}
.start-enter[disabled] {
  opacity: 0.5;
  cursor: progress;
}
.start-catalog {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  padding: 13px 34px;
  border-radius: 999px;
  border: 1px solid var(--m-line);
  background: rgba(20, 14, 10, 0.4);
  color: var(--m-text);
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.start-catalog:hover {
  border-color: var(--m-accent);
  background: rgba(40, 26, 18, 0.6);
  transform: translateY(-2px);
}
.start-controls {
  margin-top: 30px;
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
  justify-content: center;
  color: var(--m-muted);
  font-size: 15px;
  letter-spacing: 0.05em;
}
.start-controls b {
  display: inline-block;
  min-width: 30px;
  padding: 4px 9px;
  margin-right: 8px;
  border-radius: 7px;
  border: 1px solid var(--m-line);
  color: var(--m-text);
  font-weight: 600;
}
.start-loadbar {
  margin-top: 24px;
  width: 240px;
  height: 4px;
  border-radius: 999px;
  background: rgba(220, 195, 170, 0.18);
  overflow: hidden;
}
.start-loadbar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--m-accent);
  transition: width 0.3s ease;
}

/* --- Pause overlay (desktop, after Esc) --- */
.pause-screen {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 3, 2, 0.6);
  backdrop-filter: blur(3px);
  cursor: pointer;
}
.pause-screen p {
  font-size: 22px;
  letter-spacing: 0.1em;
  color: var(--m-text);
}

/* --- Fullscreen image viewer --- */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 2, 1, 0.94);
  overflow: hidden;
  touch-action: none;
}
.viewer-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  cursor: crosshair;
  touch-action: none;
}
.viewer-stage.is-touch {
  cursor: default;
}
.viewer-img {
  display: block;
  max-width: 92vw;
  max-height: 84vh;
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
}
.viewer-loupe {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  background-color: #000;
  background-repeat: no-repeat;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}
.viewer-tip {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(15, 10, 7, 0.6);
  border: 1px solid var(--m-line);
  color: var(--m-muted);
  font-size: 14px;
  letter-spacing: 0.06em;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.viewer-tip.is-faded {
  opacity: 0;
}
.viewer-close {
  position: absolute;
  appearance: none;
  cursor: pointer;
  color: var(--m-text);
  background: rgba(20, 14, 10, 0.55);
  border: 1px solid var(--m-line);
  border-radius: 999px;
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  top: 22px;
  right: 22px;
  width: 48px;
  height: 48px;
}

/* --- Touch controls --- */
.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 24;
  pointer-events: none;
}
.touch-joystick {
  position: absolute;
  left: 26px;
  bottom: 26px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 1px solid var(--m-line);
  background: rgba(15, 10, 7, 0.4);
  pointer-events: auto;
  touch-action: none;
}
.touch-joystick .knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(201, 135, 79, 0.8);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.touch-hint {
  position: absolute;
  right: 26px;
  bottom: 40px;
  color: var(--m-muted);
  font-size: 14px;
  letter-spacing: 0.05em;
  text-align: right;
  max-width: 150px;
}

/* --- Mobile exit button --- */
.touch-exit {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 40;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--m-line);
  background: rgba(20, 14, 10, 0.62);
  backdrop-filter: blur(8px);
  color: var(--m-text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.touch-exit:active {
  transform: scale(0.94);
}

/* --- Mobile "examine" button (bottom-right) --- */
.touch-examine {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 26;
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 14px 22px;
  border-radius: 999px;
  border: 1px solid var(--m-accent);
  background: var(--m-accent);
  color: #1a0f08;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  -webkit-tap-highlight-color: transparent;
}
.touch-examine:active {
  transform: scale(0.96);
}

/* --- Rotate-to-landscape hint (mobile) --- */
.rotate-hint {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
  background: rgba(5, 3, 2, 0.92);
  backdrop-filter: blur(7px);
}
.rotate-card {
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}
.rotate-ico {
  position: relative;
  width: 96px;
  height: 96px;
  color: var(--m-accent);
}
.rotate-ico svg {
  position: absolute;
  inset: 0;
  display: block;
}
.rotate-arrow {
  opacity: 0.7;
}
.rotate-phone {
  transform-origin: 50% 50%;
  animation: rotate-phone 2.6s ease-in-out infinite;
}
@keyframes rotate-phone {
  0%, 16% { transform: rotate(0deg); }
  46%, 74% { transform: rotate(-90deg); }
  92%, 100% { transform: rotate(0deg); }
}
.rotate-text {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
  color: var(--m-text);
}
.rotate-ok {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 12px 26px;
  border-radius: 999px;
  border: 1px solid var(--m-line);
  background: transparent;
  color: var(--m-muted);
  -webkit-tap-highlight-color: transparent;
}
.rotate-ok:active {
  transform: scale(0.96);
}
@media (prefers-reduced-motion: reduce) {
  .rotate-phone { animation: none; transform: rotate(-45deg); }
}

/* ===================== Mobile / touch layout ===================== */
@media (pointer: coarse) {
  /* Прячем верхний бренд во время прогулки — место отдаём управлению,
     корзина и выход остаются доступными. */
  .museum-brand {
    font-size: 17px;
  }
  .museum-brand small {
    font-size: 9px;
    letter-spacing: 0.32em;
  }
  .museum-topbar {
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  /* Панель картины уезжает наверх — не конфликтует с джойстиком и
     зоной свайпа, удобна для тапа по кнопкам. */
  .art-panel {
    left: 8px;
    right: 8px;
    bottom: auto;
    top: 64px;
    top: calc(64px + env(safe-area-inset-top));
    width: auto;
    flex-direction: column;
    align-items: stretch;
    transform: translateY(-12px);
    gap: 10px;
    padding: 12px;
    max-height: 52vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .art-panel.is-visible {
    transform: translateY(0);
  }
  .art-panel-thumb {
    width: 100%;
    height: 120px;
    flex-basis: auto;
  }
  .art-panel-title {
    font-size: 22px;
  }
  .art-panel-price {
    font-size: 19px;
  }
  .art-panel-desc {
    font-size: 15px;
    margin-bottom: 10px;
  }
  /* Крупные тап-цели и скрытые подсказки клавиш */
  .art-panel-actions {
    flex-direction: column;
  }
  .art-btn {
    width: 100%;
    text-align: center;
    padding: 13px 18px;
    font-size: 14px;
  }
  .art-btn .key {
    display: none;
  }

  /* Джойстик ниже и в безопасной зоне */
  .touch-joystick {
    left: max(20px, env(safe-area-inset-left));
    bottom: max(24px, env(safe-area-inset-bottom));
  }
  .touch-hint {
    display: none;
  }

  /* Просмотрщик: крупнее элементы, учёт «чёлки» */
  .viewer-close {
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    width: 52px;
    height: 52px;
  }
  .viewer-img {
    max-width: 100vw;
    max-height: 88vh;
  }

  .start-controls {
    display: none;
  }
}

/* Узкие телефоны: панель в одну колонку */
@media (max-width: 620px) {
  .art-panel {
    flex-direction: column;
    align-items: stretch;
  }
  .art-panel-thumb {
    width: 100%;
    height: 132px;
    flex-basis: auto;
  }
  .art-panel-actions {
    flex-direction: column;
  }
  .art-btn {
    width: 100%;
    text-align: center;
  }
}

/* Альбомная ориентация телефона (низкая высота) */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 480px) {
  .art-panel {
    top: 56px;
    max-height: 64vh;
    flex-direction: row;
    align-items: flex-start;
  }
  .art-panel-thumb {
    flex: 0 0 76px;
    width: 76px;
    height: 76px;
  }
  .art-panel-actions {
    flex-direction: row;
  }
  .art-btn {
    width: auto;
  }
  .touch-joystick {
    width: 110px;
    height: 110px;
  }
  .touch-joystick .knob {
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
  }
  .touch-examine {
    bottom: max(20px, env(safe-area-inset-bottom));
    padding: 11px 18px;
    font-size: 13px;
  }
}

