/* ============================================================
   Página: Home (V2 — menu de mundos)
   ------------------------------------------------------------
   Layout responsivo:
     - Mobile  (<768):  header empilhado, grid 2 col × 4 rows
     - Tablet  (≥768):  header em linha, grid 4 col × 2 rows
     - Desktop (≥1024): palco centralizado ~900px, mais respiro

   Camadas (z):
     0 — .home__scenery (sol, nuvens) decorativo, fundo
     1 — .home__header e .home__worlds (conteúdo interativo)

   World card: estados via [data-state]:
     - active           → bolha cheia + respiração leve
     - premium-locked   → bolha colorida + glow dourado + 🔒
     - coming-soon      → bolha desaturada + 🚧 (visualmente "tapado")
   ============================================================ */

.home {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  padding: var(--space-4);
  gap: var(--space-4);
  /* .stage já aplica gradient sky→grass via base.css */
}

/* ============================================================
   Cenário leve (decorativo)
   ============================================================ */
.home__scenery {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.home__scenery > * {
  position: absolute;
  pointer-events: none;
  user-select: none;
}

.home__sun {
  top: 5%;
  right: 6%;
  width: 64px;
  height: 64px;
  animation: home-sun-pulse 4.5s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(255, 214, 110, 0.35));
}

@keyframes home-sun-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

.home__cloud {
  top: 12%;
  font-size: 48px;
  opacity: 0.85;
  animation: home-cloud-drift 90s linear infinite;
}

.home__cloud--1 {
  top: 8%;
  left: -10%;
  animation-duration: 95s;
  animation-delay: -10s;
}

.home__cloud--2 {
  top: 22%;
  left: -10%;
  font-size: 36px;
  animation-duration: 130s;
  animation-delay: -60s;
}

@keyframes home-cloud-drift {
  from { transform: translateX(0); }
  to   { transform: translateX(130vw); }
}

/* ============================================================
   Header — logo (esq) + Pipo (dir)
   ============================================================ */
.home__header {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
}

.home__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.home__logo-badge {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-bubble);
  background: var(--gradient-rainbow-bs);
  display: grid;
  place-items: center;
  color: var(--color-white);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-base);
  letter-spacing: var(--letter-spacing-wide);
  box-shadow: var(--shadow-md);
  outline: 3px solid var(--color-white);
  outline-offset: -3px;
  flex: 0 0 auto;
}

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

.home__logo-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-ink);
  line-height: 1.1;
}

.home__logo-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-ink-soft);
  line-height: 1;
}

/* Pipo header — bem menor que o "hero" da v1 (era 160px+).
   --pipo-emoji-size é lido pelo componente pipo-mascot.css. */
.home__pipo {
  --pipo-emoji-size: 72px;
  flex: 0 0 auto;
}

/* ============================================================
   Grid de mundos — heart desta página
   ============================================================ */
.home__worlds {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
}

/* ============================================================
   World card (botão clicável de cada mundo)
   ============================================================ */
.world-card {
  /* Reset de botão */
  appearance: none;
  background: transparent;
  border: none;
  padding: var(--space-3);
  font: inherit;
  cursor: pointer;

  /* Layout interno */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);

  /* Container: cream card sutil */
  background: var(--color-cream);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform 90ms ease-out, box-shadow 180ms ease-out;
}

.world-card:hover,
.world-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  outline: none;
}

.world-card:active {
  transform: translateY(0) scale(0.98);
}

.world-card:focus-visible .world-card__bubble {
  outline: 3px solid var(--accent, var(--color-barn));
  outline-offset: 4px;
}

/* Bolha do card — onde mora o emoji 3D */
.world-card__bubble {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: var(--radius-bubble);
  background: color-mix(in srgb, var(--accent, var(--color-cream)) 30%, var(--color-white));
  border: 3px solid color-mix(in srgb, var(--accent, var(--color-barn)) 60%, white);
  display: grid;
  place-items: center;
  box-shadow: inset 0 -4px 8px color-mix(in srgb, var(--accent, transparent) 25%, transparent);
}

.world-card__emoji {
  font-size: 56px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.world-card__emoji img.emoji,
.world-card__emoji img.fluent-emoji {
  width: 1em;
  height: 1em;
  display: block;
}

.world-card__name {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-ink);
  text-align: center;
  line-height: 1.2;
}

/* Badge (cadeado ou em obras) — canto superior direito da bolha */
.world-card__badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  background: var(--color-white);
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--color-cream);
}

.world-card__badge img.emoji,
.world-card__badge img.fluent-emoji {
  width: 1em;
  height: 1em;
  display: block;
}

.world-card__badge--lock {
  /* Borda dourada pra destacar premium */
  border-color: var(--color-lock-gold);
  background: color-mix(in srgb, var(--color-lock-gold) 20%, var(--color-white));
}

.world-card__badge--soon {
  /* Borda cinza neutra pra "em obras" — não compete com locked */
  border-color: color-mix(in srgb, var(--color-ink) 20%, transparent);
}

.world-card__badge--vote {
  /* Borda sol pra "novidade interativa" — destaque positivo */
  border-color: var(--color-sun);
  background: color-mix(in srgb, var(--color-sun) 25%, var(--color-white));
  animation: world-card-badge-sparkle 1.8s ease-in-out infinite;
}

@keyframes world-card-badge-sparkle {
  0%, 100% { transform: scale(1)    rotate(0); }
  50%      { transform: scale(1.15) rotate(15deg); }
}

/* ============================================================
   Estados via [data-state]
   ============================================================ */

/* ACTIVE — card livre, brilha mais. Bolha respira lentamente
   (mesma linguagem dos animal-tokens da Fazenda). */
.world-card[data-state="active"] .world-card__bubble {
  animation: world-card-breathe 3.6s ease-in-out infinite;
}

@keyframes world-card-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

/* PREMIUM-LOCKED — bolha cheia da cor + glow dourado sutil ao
   redor pra chamar atenção positiva ("é especial, pague pra ver").
   Continua interativa (cursor pointer, hover anima). */
.world-card[data-state="premium-locked"] .world-card__bubble {
  box-shadow:
    inset 0 -4px 8px color-mix(in srgb, var(--accent, transparent) 25%, transparent),
    0 0 0 4px color-mix(in srgb, var(--color-lock-gold) 25%, transparent);
}

/* COMING-SOON — desaturado, opacity reduzida, sem respiração.
   Sinaliza "ainda não" sem ser cinza-bloqueado feio. */
.world-card[data-state="coming-soon"] {
  opacity: 0.72;
}

.world-card[data-state="coming-soon"] .world-card__bubble {
  filter: saturate(0.5);
}

.world-card[data-state="coming-soon"] .world-card__name {
  color: var(--color-ink-soft);
}

/* VOTE — card "coringa" (8º slot, "Você decide!"). NÃO desatura,
   NÃO mostra cadeado. Brilho dourado tipo destaque positivo,
   respiração mais rápida que active pra chamar olho. */
.world-card[data-state="vote"] .world-card__bubble {
  animation: world-card-vote-pulse 2.6s ease-in-out infinite;
  box-shadow:
    inset 0 -4px 8px color-mix(in srgb, var(--color-sun) 50%, transparent),
    0 0 0 4px color-mix(in srgb, var(--color-sun) 35%, transparent),
    0 0 18px color-mix(in srgb, var(--color-sun) 45%, transparent);
}

@keyframes world-card-vote-pulse {
  0%, 100% { transform: scale(1)    rotate(-2deg); }
  50%      { transform: scale(1.06) rotate(2deg); }
}

@media (prefers-reduced-motion: reduce) {
  .world-card[data-state="active"] .world-card__bubble,
  .world-card[data-state="vote"] .world-card__bubble,
  .world-card__badge--vote,
  .home__sun,
  .home__cloud {
    animation: none;
  }
}

/* ============================================================
   Footer
   ============================================================ */
.home__footer {
  position: relative;
  z-index: 1;
  margin-block-start: auto;
  text-align: center;
  color: var(--color-ink-muted);
}

/* ============================================================
   Tablet (>= 768px)
   ============================================================ */
@media (min-width: 768px) {
  .home {
    padding: var(--space-6) var(--space-5);
    gap: var(--space-6);
  }

  /* Grid 3 colunas: logo esquerda, Pipo CENTRO, coluna direita
     vazia (libera o canto pro sol decorativo respirar). Antes
     era flex space-between e o Pipo encostava no sol — Pipo
     fritando, criança rindo. */
  .home__header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    /* align-items: end + min-height grande → o logo gruda no TOPO
       (align-self start abaixo) e o Pipo gruda no BOTTOM da row.
       Resultado: logo no lugar, Pipo desce, cards descem junto
       (porque o header ficou mais alto). */
    align-items: end;
    min-height: 200px;
    gap: var(--space-4);
    max-width: 900px;
    margin-inline: auto;
  }

  .home__logo {
    justify-self: start;
    align-self: start;
    /* Desce um pouco pra alinhar com o sol decorativo. */
    margin-top: var(--space-4);
  }

  .home__pipo {
    justify-self: center;
    grid-column: 2;
  }

  .home__logo-badge {
    width: 72px;
    height: 72px;
    font-size: var(--font-size-lg);
  }

  .home__logo-title {
    font-size: var(--font-size-xl);
  }

  .home__pipo {
    --pipo-emoji-size: 88px;
  }

  /* 4 colunas em 2 linhas */
  .home__worlds {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-5);
    max-width: 900px;
  }

  .world-card__bubble {
    width: 110px;
    height: 110px;
  }

  .world-card__emoji {
    font-size: 64px;
  }

  .world-card__name {
    font-size: var(--font-size-lg);
  }

  .home__sun {
    width: 80px;
    height: 80px;
  }

  .home__cloud {
    font-size: 64px;
  }
}

/* ============================================================
   Desktop (>= 1024px) — palco centralizado, mais ar
   ============================================================ */
@media (min-width: 1024px) {
  .home {
    max-width: 1000px;
    margin-inline: auto;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    min-height: calc(100svh - 2 * var(--space-6));
    overflow: hidden;   /* clipa o cenário pra dentro do card */
  }

  .home__pipo {
    --pipo-emoji-size: 96px;
  }

  /* Desktop alto: row do header ainda maior, Pipo desce mais */
  .home__header {
    min-height: 260px;
  }

  .world-card__bubble {
    width: 120px;
    height: 120px;
  }

  .world-card__emoji {
    font-size: 72px;
  }

  .home__sun {
    width: 96px;
    height: 96px;
    top: 4%;
    right: 5%;
  }
}

/* ============================================================
   Notebook curto (Windows 125% scaling, ~695h)
   ============================================================ */
@media (min-width: 1024px) and (max-height: 900px) {
  .home {
    min-height: calc(100svh - 2 * var(--space-4));
    /* bottom 0 compensa o +min-height do header (sem estourar) */
    padding-block: var(--space-4) 0;
    gap: var(--space-4);
  }

  .home__pipo {
    --pipo-emoji-size: 80px;
  }

  /* Notebook curto: row do header um pouco maior pra Pipo descer.
     Conservador pra não estourar (padding-bottom 0 compensa). */
  .home__header {
    min-height: 140px;
  }

  .world-card__bubble {
    width: 100px;
    height: 100px;
  }

  .world-card__emoji {
    font-size: 60px;
  }

  .home__worlds {
    gap: var(--space-4);
  }
}
