/* hero3d.css — galeria 3D WebGL walkable (hero da home)
   Poster de fallback + lista off-canvas acessível.
   Sizing principal de #hero-3d/.hero-visual vive em styles.css.
   Tokens do DS: petrol/bone/cream/gold + fontes mono/display. Sem hex novo.
   REGRA: zero hex fora de var(--token, #fallback). Usar color-mix() para tons intermediários. */

#hero-3d {
  cursor: default;
  position: relative;
}

#hero-3d canvas {
  outline: none;
}

/* ── Controle de navegação (auto ↔ manual) ────────────────────── */
.hero3d-ctrl {
  position: absolute;
  right: 16px;
  bottom: 52px; /* clearance: ~38px footer + 14px gutter */
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.hero3d-ctrl-toggle {
  pointer-events: auto;
  cursor: pointer;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-on-dark, #f4efe6);
  background: color-mix(in srgb, var(--petrol-900, #0F2A35) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--bone, #F4EFE6) 24%, transparent);
  padding: 8px 14px;
  border-radius: var(--radius-pill, 999px);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition:
    background var(--dur, 250ms) var(--ease-out, cubic-bezier(0.22,1,0.36,1)),
    border-color var(--dur, 250ms) var(--ease-out, cubic-bezier(0.22,1,0.36,1));
}
.hero3d-ctrl-toggle:hover {
  background: color-mix(in srgb, var(--petrol-900, #0F2A35) 88%, transparent);
}
.hero3d-ctrl-toggle:focus-visible {
  outline: 2px solid var(--gold-500, #C8A24B);
  outline-offset: 2px;
}
/* Indica que o modo manual está ativo com borda dourada discreta */
.hero3d-ctrl--manual .hero3d-ctrl-toggle {
  border-color: color-mix(in srgb, var(--gold-500, #C8A24B) 52%, transparent);
}

.hero3d-pad {
  display: none;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(3, 40px);
  gap: 6px;
}
.hero3d-ctrl--manual .hero3d-pad { display: grid; }

.hero3d-pad-btn {
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: var(--fg-on-dark, #f4efe6);
  background: color-mix(in srgb, var(--petrol-900, #0F2A35) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--bone, #F4EFE6) 24%, transparent);
  border-radius: var(--radius-md, 4px);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  user-select: none;
  touch-action: none;
  transition: background var(--dur-fast, 150ms) var(--ease-out, cubic-bezier(0.22,1,0.36,1));
}
.hero3d-pad-btn:active {
  background: var(--gold-500, #C8A24B);
  color: var(--petrol-900, #0F2A35);
}
.hero3d-pad-btn:focus-visible {
  outline: 2px solid var(--gold-500, #C8A24B);
  outline-offset: 2px;
}
.hero3d-pad-F { grid-area: 1 / 2; }
.hero3d-pad-L { grid-area: 2 / 1; }
.hero3d-pad-R { grid-area: 2 / 3; }
.hero3d-pad-B { grid-area: 3 / 2; }

/* ── Poster de fallback (sem WebGL ou erro no GLB) ─────────────── */
#hero-3d.hero3d-fallback {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  background-color: var(--petrol-900, #0F2A35);
  background-image:
    radial-gradient(120% 90% at 78% 18%,
      color-mix(in srgb, var(--gold-500, #C8A24B) 16%, transparent) 0%,
      transparent 55%),
    linear-gradient(160deg,
      color-mix(in srgb, var(--petrol-900, #0F2A35) 92%, black) 0%,
      color-mix(in srgb, var(--petrol-900, #0F2A35) 70%, var(--petrol-700, #1B4858)) 100%);
  background-size: cover;
  background-position: center;
}

#hero-3d.hero3d-fallback::before {
  content: "Galeria Crivo";
  position: absolute;
  left: 28px;
  bottom: 54px; /* clear the .hero-card-foot (~38px) + gutter */
  font-family: var(--font-mono, "IBM Plex Mono", monospace);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--bone) 78%, transparent);
}

#hero-3d.hero3d-fallback::after {
  content: "Corredor de pedras naturais — selecione no índice ao lado.";
  position: absolute;
  left: 28px;
  bottom: 80px; /* clear footer + label ::before */
  max-width: 60%;
  font-family: var(--font-display, "Fraunces", serif);
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  line-height: 1.25;
  color: var(--cream, #efe7da);
}

/* ── Lista off-canvas acessível (1 botão por pedra) ───────────── */
.hero3d-a11y {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Visível ao receber foco por teclado (skip-link pattern) */
.hero3d-a11y:focus-within {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 60;
  width: auto;
  height: auto;
  max-width: 320px;
  margin: 0;
  padding: 16px 18px;
  overflow: auto;
  clip: auto;
  clip-path: none;
  white-space: normal;
  background: var(--bone, #F4EFE6);
  border: 1px solid color-mix(in srgb, var(--petrol-700, #1B4858) 30%, transparent);
  border-radius: var(--radius-md, 4px);
  box-shadow: 0 12px 40px color-mix(in srgb, var(--petrol-900, #0F2A35) 28%, transparent);
}

.hero3d-a11y-title {
  margin: 0 0 10px;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--petrol-700, #1B4858);
}

.hero3d-a11y ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hero3d-a11y-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  font-family: var(--font-mono, "IBM Plex Mono", monospace);
  font-size: 0.78rem;
  color: var(--petrol-900, #0F2A35);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm, 2px);
  cursor: pointer;
}

.hero3d-a11y-link:hover,
.hero3d-a11y-link:focus-visible {
  background: color-mix(in srgb, var(--gold-500, #C8A24B) 22%, transparent);
  outline: 2px solid var(--gold-500, #C8A24B);
  outline-offset: 1px;
}

/* ── Rótulo flutuante no hover ───────────────────────────────────── */
#hero3d-label {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  pointer-events: none;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-on-dark, #F4EFE6);
  background: color-mix(in srgb, var(--petrol-900, #0F2A35) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--bone, #F4EFE6) 20%, transparent);
  padding: 5px 10px 4px;
  border-radius: var(--radius-sm, 2px);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--dur-fast, 150ms) var(--ease-out, cubic-bezier(0.22,1,0.36,1));
  /* Evita salto: começa invisível no canto; JS move antes de revelar. */
  will-change: left, top;
}

#hero3d-label.hero3d-label--visible {
  opacity: 1;
}

/* Em mobile não há hover real — esconde para não aparecer em tap acidental. */
@media (hover: none) {
  #hero3d-label { display: none; }
}

/* ── Estado de carregamento (GLB ~3MB a baixar) ───────────────────── */
#hero-3d.hero3d-loading {
  background-color: var(--petrol-900, #0f2a35);
  background-image: linear-gradient(
    160deg,
    color-mix(in srgb, var(--petrol-900) 96%, black) 0%,
    color-mix(in srgb, var(--petrol-900) 72%, var(--petrol-800, #143847)) 100%
  );
}

#hero-3d.hero3d-loading::before {
  content: "carregando galeria…";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono, "IBM Plex Mono", monospace);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--bone) 55%, transparent);
  animation: hero3d-pulse 1.8s ease-in-out infinite;
  white-space: nowrap;
  pointer-events: none;
}

@keyframes hero3d-pulse {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 1;    }
}

/* ── Polimento mobile/touch ───────────────────────────────────────── */
@media (max-width: 720px) {
  /* Área de toque ≥ 44px (WCAG 2.5.5) */
  .hero3d-pad {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 4px;
  }

  .hero3d-pad-btn {
    font-size: 20px;
    border-radius: var(--radius-md, 4px);
  }

  .hero3d-ctrl-toggle {
    padding: 11px 18px;
    font-size: 11px;
    min-height: 44px;
  }

  .hero3d-ctrl {
    right: 12px;
    bottom: 46px; /* clear mobile footer (~34px) + gutter */
    gap: 8px;
  }
}

/* ── Hero Card — moldura editorial que envolve a galeria 3D ───────────── */
/* Referência: vitrine de galeria / painel de exposição. Moldura dourada,
   cabeçalho e rodapé glassmorphic com tokens do DS. Zero hex novo. */

.hero-card {
  position: relative;
  z-index: 1;
  background: var(--petrol-900, #0F2A35);
  /* Moldura: linha dourada atenuada — arquitetônica, não decorativa */
  border: 1px solid color-mix(in srgb, var(--gold-500, #C8A24B) 36%, transparent);
  border-radius: var(--radius-sm, 2px);
  overflow: hidden;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--petrol-900, #0F2A35) 22%, transparent) inset,
    var(--shadow-xl, 0 24px 64px rgba(15, 42, 53, 0.14));
}

/* Cabeçalho: strip glassmorphic sobreposto ao topo da galeria */
.hero-card-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--petrol-900, #0F2A35) 80%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--gold-500, #C8A24B) 22%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  pointer-events: none;
  user-select: none;
}

.hero-card-title {
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--fg-on-dark, #F4EFE6) 68%, transparent);
}

.hero-card-title::before {
  content: "◈  ";
  color: color-mix(in srgb, var(--gold-500, #C8A24B) 60%, transparent);
  font-size: 0.55rem;
  letter-spacing: 0;
  vertical-align: 1px;
}

.hero-card-num {
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  color: color-mix(in srgb, var(--gold-500, #C8A24B) 62%, transparent);
}

/* Rodapé: instruções de uso, sem pointer-events (arraste passa por baixo) */
.hero-card-foot {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 9px 20px 8px;
  background: color-mix(in srgb, var(--petrol-900, #0F2A35) 80%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--gold-500, #C8A24B) 14%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 0.60rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--fg-on-dark, #F4EFE6) 38%, transparent);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.hero-card-sep {
  color: color-mix(in srgb, var(--gold-500, #C8A24B) 34%, transparent);
  letter-spacing: 0;
}

/* ── Ajuste de controles no modo manual: destaca-se do card ─── */
/* O toggle fica mais visível quando o modo manual está ativo */
.hero3d-ctrl--manual .hero3d-ctrl-toggle {
  /* já tem border-color gold via hero3d.css; reforça sutil glow */
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold-500, #C8A24B) 12%, transparent);
}

/* ── Mobile: card mais compacto ──────────────────────────────── */
@media (max-width: 720px) {
  .hero-card-head {
    padding: 8px 12px;
  }

  .hero-card-title,
  .hero-card-num {
    font-size: 0.60rem;
    letter-spacing: 0.18em;
  }

  .hero-card-foot {
    font-size: 0.55rem;
    gap: 6px;
    padding: 7px 12px 6px;
    letter-spacing: 0.11em;
  }
}
