/* ============================================================
   layout.css — camadas de fundo, descida, seções e estrutura
   ============================================================ */

/* ---------- Camadas de fundo (fixas, atrás de tudo) ---------- */

.bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.bg--base {
  z-index: -4;
  background: linear-gradient(to bottom, #161c2c 0%, var(--bg-surface) 55%, #0a0810 100%);
}

/* As estrelas da superfície somem conforme se desce */
.bg--stars {
  z-index: -3;
  opacity: calc(1 - min(1, var(--depth) * 1.7));
}

.star {
  position: absolute;
  border-radius: 50%;
  background: #cdd5f2;
  animation: twinkle 4.5s ease-in-out infinite;
  animation-delay: var(--tw, 0s);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 0.15; }
}

/* O véu: escurece tudo conforme a profundidade aumenta */
.bg--veil {
  z-index: -2;
  background: var(--bg-deep);
  opacity: calc(min(0.93, var(--depth) * 1.1));
}

/* Um brilho violáceo que emana do fundo do abismo */
.bg--nebula {
  z-index: -1;
  background: radial-gradient(ellipse 90% 55% at 50% 110%, rgba(74, 38, 105, 0.5), transparent 65%);
  opacity: calc(var(--depth) * 0.7);
}

/* Vinheta que se fecha quando o abismo encara de volta */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: radial-gradient(ellipse 70% 62% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.75) 100%);
  opacity: 0;
  transition: opacity 1.6s ease;
}

body.is-finale .vignette {
  opacity: 1;
}

/* ---------- Medidor de profundidade ---------- */

.depth-meter {
  position: fixed;
  left: 1.4rem;
  bottom: 1.4rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-dim);
  opacity: 0;
  transition: opacity 1s ease;
}

body.is-descended .depth-meter {
  opacity: 0.85;
}

.depth-meter__value {
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(216, 160, 74, 0.35);
}

@media (max-width: 700px) {
  .depth-meter {
    display: none;
  }
}

/* ---------- Seções ---------- */

.section {
  position: relative;
  padding: 24vh 1.5rem;
}

.section__inner {
  position: relative;
  z-index: 1;
  max-width: var(--content-w);
  margin: 0 auto;
}

.section__inner--wide {
  max-width: var(--content-w-wide);
}

.section__index {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(216, 160, 74, 0.6);
  margin-bottom: 1rem;
}

.section__index::after {
  content: '';
  flex: 0 0 4rem;
  height: 1px;
  background: linear-gradient(to right, rgba(216, 160, 74, 0.4), transparent);
}

.section__title {
  font-size: clamp(1.9rem, 4.5vw, 2.6rem);
  letter-spacing: 0.02em;
}

.section__flavor {
  font-style: italic;
  color: var(--ink-dim);
  margin-bottom: 3rem;
}

/* Camada onde os olhos ambientes habitam, nas margens da seção */
.watchers {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

@media (max-width: 1023px) {
  .section:not(.finale) .watchers {
    display: none;
  }
}

/* ---------- Hero: a superfície ---------- */

.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.5rem;
}

.hero__name {
  font-size: clamp(2.8rem, 9vw, 5.5rem);
  letter-spacing: 0.05em;
  text-shadow: 0 0 50px rgba(216, 160, 74, 0.14);
}

.hero__role {
  margin-top: 1rem;
  font-size: clamp(0.8rem, 2vw, 1rem);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.hero__tagline {
  margin-top: 1.6rem;
  max-width: 34rem;
  font-size: clamp(1rem, 2.3vw, 1.2rem);
  color: var(--ink);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 2.6rem;
}

.hero__cue {
  position: absolute;
  bottom: 2.4rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-style: italic;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
}

.hero__cue-arrow {
  font-style: normal;
  color: var(--accent);
  animation: cue-bob 2.4s ease-in-out infinite;
}

@keyframes cue-bob {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(9px); opacity: 1; }
}

/* ---------- Finale: o fundo da descida ---------- */

.finale {
  min-height: 110vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.finale .section__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.finale .section__title {
  font-size: clamp(2.1rem, 5.5vw, 3.2rem);
}

.finale__text {
  max-width: 32rem;
  margin: 1.5rem 0 2.8rem;
  color: var(--ink);
}

.finale__return {
  margin-top: 3.5rem;
  font-size: 0.85rem;
  font-style: italic;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
}

.finale__return:hover {
  color: var(--ink-bright);
}

/* ---------- Rodapé ---------- */

.footer {
  padding: 6vh 1.5rem 8vh;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.footer em {
  display: block;
  margin-top: 0.4rem;
  opacity: 0.7;
}

/* ---------- Revelação ao rolar ---------- */

.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity 0.9s ease,
    transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: var(--reveal-delay, 0s);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
  }
}
