/* ╔══════════════════════════════════════════════════════════╗
   ║ MALHADA VILLAGE · interactive tour                        ║
   ║ Paleta natural, painéis em glass morphism, hotspots vivos ║
   ╚══════════════════════════════════════════════════════════╝ */

:root {
  /* Coerente com malhada-villas.netlify.app */
  --bg:           #0e110f;           /* dark base */
  --bg-2:         #161a17;
  --ink:          #f4efe6;           /* cream — texto claro sobre dark */
  --ink-soft:     rgba(244, 239, 230, 0.72);
  --ink-dim:      rgba(244, 239, 230, 0.48);

  --moss:         #2d3a2e;
  --sage:         #5f7264;
  --sage-light:   #8aa18f;
  --sand:         #b89968;           /* accent principal */
  --sand-light:   #d8c5a3;
  --sand-dim:     rgba(184, 153, 104, 0.22);

  /* Glass surfaces */
  --glass:        rgba(14, 17, 15, 0.55);
  --glass-strong: rgba(14, 17, 15, 0.78);
  --glass-light:  rgba(14, 17, 15, 0.15);   /* painel mais transparente */
  --glass-border: rgba(244, 239, 230, 0.16);

  /* Type */
  --display: "Fraunces", "Times New Roman", serif;
  --body:    "Manrope", -apple-system, system-ui, sans-serif;

  /* Layout */
  --panel-w:        clamp(280px, 28vw, 380px);
  --pad-frame:      clamp(20px, 3vw, 40px);

  /* Motion */
  --ease-cinematic: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-soft:      cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast:    220ms;
  --dur-med:     480ms;
  --dur-slow:    900ms;
}

/* ────────────────────────────────────────────────────────── */
/*  Reset & base                                              */
/* ────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

/* ────────────────────────────────────────────────────────── */
/*  Stage — vídeo 4:3 com pan em portrait                     */
/* ────────────────────────────────────────────────────────── */

#scroll-wrapper {
  position: fixed;
  inset: 0;
  background: var(--bg);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  z-index: 1;
  text-align: center;       /* centra inline-block child quando fits */
  white-space: nowrap;
  font-size: 0;             /* remove gap entre inline-blocks */
}

/* Hide scrollbar (we visually communicate scrollability) */
#scroll-wrapper::-webkit-scrollbar { display: none; }
#scroll-wrapper { scrollbar-width: none; }

#aspect-wrapper {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  height: 100vh;
  /* 4:3 aspect: largura = altura * 4/3 */
  aspect-ratio: 4 / 3;
  background: var(--bg);
  font-size: 16px;          /* restaurar font-size dentro */
  white-space: normal;
}

/* Espaçador invisível para vertical-align: middle funcionar */
#scroll-wrapper::before {
  content: "";
  display: inline-block;
  vertical-align: middle;
  height: 100%;
  width: 0;
}

/* Vinheta global (cobre viewport, não o aspect-wrapper) — fica num overlay fixed */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 50%, rgba(14, 17, 15, 0.45) 100%),
    linear-gradient(to right, rgba(14, 17, 15, 0.35) 0%, transparent 35%, transparent 70%, rgba(14, 17, 15, 0.25) 100%);
  z-index: 2;
}

.media-layer {
  position: absolute;
  inset: 0;
}

/* Vídeos do double-buffer */
.media-layer video,
.media-layer canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease-soft);
}

.media-layer video.active,
.media-layer canvas.active {
  opacity: 1;
}

/* ────────────────────────────────────────────────────────── */
/*  Header                                                    */
/* ────────────────────────────────────────────────────────── */

.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: var(--pad-frame);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 30;
  pointer-events: none;
}

.brand {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(15px, 1.2vw, 18px);
  letter-spacing: 0.02em;
  font-style: italic;
  color: var(--ink);
  text-shadow: 0 2px 16px rgba(0,0,0,0.5);
  line-height: 1.2;
}

.brand small {
  display: block;
  font-family: var(--body);
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  font-style: normal;
  margin-top: 4px;
}

.header-left {
  display: flex;
  gap: 14px;
  align-items: center;
  pointer-events: auto;
  min-width: 0;
}

.header-right {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

/* Pill button (glass) */
.pill {
  padding: 10px 18px;
  border-radius: 100px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.05em;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background var(--dur-fast) var(--ease-soft),
              border-color var(--dur-fast) var(--ease-soft),
              transform var(--dur-fast) var(--ease-soft);
}

.pill:hover {
  background: var(--glass-strong);
  border-color: rgba(184, 153, 104, 0.4);
}

.pill:active { transform: scale(0.97); }

.pill svg { width: 14px; height: 14px; }

/* Back-to-site link */
.site-back { text-decoration: none; color: var(--ink); }

/* Lang toggle */
.lang {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--body);
  font-size: 11px;
  letter-spacing: 0.12em;
  font-weight: 500;
}

.lang button {
  padding: 6px 8px;
  color: var(--ink-dim);
  letter-spacing: inherit;
  transition: color var(--dur-fast);
}

.lang button.on { color: var(--sand); }
.lang button:hover { color: var(--ink); }
.lang span { color: var(--ink-dim); }

/* ────────────────────────────────────────────────────────── */
/*  Info panel — desdobra da esquerda quando estás num local  */
/* ────────────────────────────────────────────────────────── */

.info-panel {
  position: fixed;
  left: var(--pad-frame);
  top: 50%;
  transform: translateY(-50%);
  width: var(--panel-w);
  max-height: calc(100vh - 2 * var(--pad-frame));
  padding: 36px 32px 30px;
  z-index: 20;

  /* Glass — 15% opaco, blur reforçado para preservar legibilidade */
  background: var(--glass-light);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  box-shadow:
    0 24px 60px -20px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 0 rgba(244, 239, 230, 0.06);

  /* Animação de "desdobrar" */
  opacity: 0;
  clip-path: inset(0 100% 0 0 round 18px);
  transition:
    opacity var(--dur-med) var(--ease-soft) 120ms,
    clip-path var(--dur-slow) var(--ease-cinematic) 100ms;
  pointer-events: none;
}

.info-panel.show {
  opacity: 1;
  clip-path: inset(0 0% 0 0 round 18px);
  pointer-events: auto;
}

/* Close button (×) no canto superior direito */
.info-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  opacity: 0.7;
  transition: opacity var(--dur-fast),
              background var(--dur-fast),
              transform var(--dur-fast);
}
.info-close:hover {
  opacity: 1;
  background: rgba(244, 239, 230, 0.08);
}
.info-close:active { transform: scale(0.92); }
.info-close svg { width: 16px; height: 16px; }

/* Reopen button — pequeno botão flutuante (i) quando painel está fechado */
.info-reopen {
  position: fixed;
  left: var(--pad-frame);
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--glass-light);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 19;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-med) var(--ease-soft) 200ms,
              background var(--dur-fast),
              transform var(--dur-fast);
}
.info-reopen.show {
  opacity: 1;
  pointer-events: auto;
}
.info-reopen:hover {
  background: rgba(14, 17, 15, 0.4);
  border-color: var(--sand);
}
.info-reopen:active { transform: translateY(-50%) scale(0.94); }
.info-reopen svg { width: 18px; height: 18px; }

.info-panel .eyebrow {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--sand);
  font-weight: 500;
  margin-bottom: 18px;
}

.info-panel h1 {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 6px;
}

.info-panel h1 em {
  font-style: italic;
  color: var(--sand-light);
}

.info-panel .subtitle {
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 22px;
  line-height: 1.4;
}

.info-panel .desc {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-soft);
  margin-bottom: 26px;
  font-weight: 350;
}

.info-panel .metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--glass-border);
}

.metric { display: flex; flex-direction: column; gap: 2px; }

.metric .value {
  font-family: var(--display);
  font-weight: 300;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.metric .label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  font-weight: 500;
}

/* ────────────────────────────────────────────────────────── */
/*  Hotspots                                                  */
/* ────────────────────────────────────────────────────────── */

.hotspot-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease-soft) 600ms;
}

.hotspot.visible { opacity: 1; }

/* Marker shape */
.hotspot .mark {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Outer pulse ring */
.hotspot .mark::before,
.hotspot .mark::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--sand);
  opacity: 0.6;
}

.hotspot .mark::after {
  animation: pulse 2.8s var(--ease-soft) infinite;
}

@keyframes pulse {
  0%   { transform: scale(1);   opacity: 0.6; }
  70%  { transform: scale(2.2); opacity: 0;   }
  100% { transform: scale(2.2); opacity: 0;   }
}

/* Inner dot */
.hotspot .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--sand);
  box-shadow:
    0 0 0 4px rgba(14, 17, 15, 0.5),
    0 4px 16px rgba(0,0,0,0.4);
  transition: transform var(--dur-fast) var(--ease-soft),
              background var(--dur-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hotspot .dot svg {
  width: 9px;
  height: 9px;
  color: var(--bg);
  opacity: 0;
  transition: opacity var(--dur-fast);
}

.hotspot:hover .dot {
  transform: scale(1.15);
  background: var(--sand-light);
}
.hotspot:hover .dot svg { opacity: 1; }

/* Label appears on hover */
.hotspot .label {
  position: absolute;
  top: 100%;
  left: 50%;
  margin-top: 14px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--ink);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  padding: 7px 14px;
  border-radius: 100px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-soft),
              transform var(--dur-fast) var(--ease-soft);
}

.hotspot:hover .label {
  opacity: 1;
  transform: translateX(-50%) translateY(2px);
}

/* "Back" hotspots já não são renderizados como markers — viram botão no header */

/* ────────────────────────────────────────────────────────── */
/*  Spinner controls (next/prev) — bottom centre              */
/* ────────────────────────────────────────────────────────── */

.spinner-controls {
  position: fixed;
  bottom: var(--pad-frame);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 14px;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-med) var(--ease-soft) 400ms;
}

.spinner-controls.show {
  opacity: 1;
  pointer-events: auto;
}

.spin-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: background var(--dur-fast) var(--ease-soft),
              border-color var(--dur-fast) var(--ease-soft),
              transform var(--dur-fast) var(--ease-soft);
}

.spin-btn:hover {
  background: var(--glass);
  border-color: var(--sand);
}

.spin-btn:active { transform: scale(0.94); }

.spin-btn svg { width: 18px; height: 18px; }

.spin-label {
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: 13px;
  color: var(--ink-soft);
  padding: 0 8px;
  min-width: 100px;
  text-align: center;
}

/* ────────────────────────────────────────────────────────── */
/*  Loader                                                    */
/* ────────────────────────────────────────────────────────── */

.loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 28px;
  transition: opacity var(--dur-slow) var(--ease-soft);
}

.loader.hide {
  opacity: 0;
  pointer-events: none;
}

.loader .logo {
  font-family: var(--display);
  font-weight: 300;
  font-style: italic;
  font-size: 30px;
  letter-spacing: -0.01em;
  color: var(--ink);
  animation: breathe 3s var(--ease-soft) infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

.loader .progress {
  width: 120px;
  height: 1px;
  background: rgba(244, 239, 230, 0.15);
  overflow: hidden;
}

.loader .progress::after {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  background: var(--sand);
  animation: slide 1.6s var(--ease-soft) infinite;
}

@keyframes slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ────────────────────────────────────────────────────────── */
/*  Onboarding hint (first visit)                             */
/* ────────────────────────────────────────────────────────── */

.hint {
  position: fixed;
  right: var(--pad-frame);
  bottom: var(--pad-frame);
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: 12px;
  color: var(--ink-dim);
  z-index: 18;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-soft);
}

.hint.show { opacity: 1; }

.hint .arrow {
  width: 24px;
  height: 1px;
  background: var(--ink-dim);
  position: relative;
  animation: arrow-pulse 2.4s var(--ease-soft) infinite;
}

.hint .arrow::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -3px;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--ink-dim);
  border-top: 1px solid var(--ink-dim);
  transform: rotate(45deg);
}

@keyframes arrow-pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* ────────────────────────────────────────────────────────── */
/*  Mobile                                                    */
/* ────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  :root {
    --pad-frame: 14px;
    --panel-w: calc(100vw - 28px);
  }

  /* Header — compact */
  .header { padding: 12px 14px; align-items: center; }
  .header-left { gap: 10px; }
  .brand { font-size: 13px; line-height: 1.15; }
  .brand small { font-size: 8px; letter-spacing: 0.14em; margin-top: 2px; }
  .header-right { gap: 8px; }

  .pill { padding: 8px 12px; font-size: 11px; }
  /* Hide text labels on header pills, keep only icons */
  #btn-restart span,
  #btn-back-label {
    display: none;
  }
  #btn-restart, #btn-back { padding: 9px; }
  #btn-restart svg, #btn-back svg { width: 15px; height: 15px; }

  .lang { padding: 7px 12px; font-size: 10px; }
  .lang button { padding: 4px 5px; }

  /* Info panel — bottom sheet */
  .info-panel {
    top: auto;
    bottom: 14px;
    left: 14px;
    right: 14px;
    width: auto;
    transform: none;
    padding: 22px 22px 20px;
    max-height: 52vh;
    overflow-y: auto;
    /* Mobile dobra desde baixo */
    clip-path: inset(100% 0 0 0 round 18px);
  }
  .info-panel.show { clip-path: inset(0 0 0 0 round 18px); }

  .info-panel h1 { font-size: 24px; }
  .info-panel .eyebrow { margin-bottom: 12px; }
  .info-panel .desc { font-size: 13px; margin-bottom: 18px; }
  .info-panel .metrics { gap: 18px; padding-top: 16px; }
  .metric .value { font-size: 18px; }
  .metric .label { font-size: 9px; }

  /* Reopen — bottom-left when panel closed */
  .info-reopen {
    left: 14px;
    bottom: 14px;
    top: auto;
    transform: none;
  }
  .info-reopen:active { transform: scale(0.94); }

  /* Spinner — top right under header */
  .spinner-controls {
    bottom: auto;
    top: 70px;
    gap: 8px;
  }
  .spin-btn { width: 44px; height: 44px; }
  .spin-btn svg { width: 16px; height: 16px; }
  .spin-label { font-size: 12px; min-width: 72px; }

  .hint { display: none; }

  /* Hotspots — slightly smaller */
  .hotspot .mark { width: 42px; height: 42px; }
  .hotspot .label { font-size: 10px; padding: 6px 10px; }

  /* Pan hint — small ribbon to show scrollability in portrait */
  .pan-hint {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 17;
    pointer-events: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--glass-strong);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-soft);
    opacity: 0;
    animation: pan-fade 4.5s var(--ease-soft);
  }
  .pan-hint.left  { left: 6px;  }
  .pan-hint.right { right: 6px; }
  .pan-hint svg { width: 12px; height: 12px; }

  @keyframes pan-fade {
    0%, 100% { opacity: 0; }
    20%, 70% { opacity: 0.85; }
  }
}
