/* A madrugada jogável: navegação entre as fases e o layout do palco, do HUD e da caixa de diálogo.
   Carregado depois de styles.css. Como a tela de um RPG: uma faixa de HUD em cima (missão e objetivo
   atual, fases, relógio, nível, tokens), o escritório no meio e a caixa de texto embaixo, sem nada
   cobrindo os personagens, em qualquer tamanho. Sistema pixel: cantos retos, linhas de 2px, sombra
   dura, nada inline. */

.story-track {
  height: 960vh;
}

.story-stage {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'quest nav status skip'
    'world world world world'
    'dialog dialog dialog dialog';
  align-items: center;
  gap: 10px 12px;
  padding: 62px 16px 16px;
  background: var(--bg);
}

/* o escritório, emoldurado como a tela do jogo */
.world {
  grid-area: world;
  align-self: stretch;
  min-height: 0;
  border: var(--bw) solid var(--border-2);
  box-shadow: var(--bevel), var(--shadow-3);
}

.hud,
.hud-quest,
.hud-status,
.story-nav,
.skip-story,
.dialog {
  position: static;
  translate: none;
}

/* missão: o nome e só o objetivo da vez (a barra de fases mostra o resto) */
.hud-quest {
  grid-area: quest;
  width: auto;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  column-gap: 10px;
  padding: 8px 12px;
  box-shadow: var(--bevel), var(--shadow-1);
}
.quest-name {
  margin: 0;
  font-size: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.objectives {
  grid-column: 1 / -1;
  display: block;
  margin-top: 2px;
  font-size: 16px;
}
.objectives li {
  display: none;
}
.objectives li.current {
  display: block;
}

.hud-status {
  grid-area: status;
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.hud-status .panel {
  box-shadow: var(--bevel), var(--shadow-1);
}
.hud-clock {
  padding: 4px 10px;
  font-size: 28px;
}
.hud-xp {
  width: auto;
  min-width: 110px;
  padding: 6px 10px;
  gap: 4px;
}

/* ------------------------------------------------------------------ fases (barra segmentada) */
.story-nav {
  grid-area: nav;
  display: flex;
  gap: 4px;
  padding: 6px;
  background: var(--ink);
  border: var(--bw) solid var(--border-2);
  box-shadow: var(--shadow-1);
}
.story-nav button {
  width: 26px;
  height: 14px;
  padding: 0;
  background: var(--raised);
  border: var(--bw) solid var(--ink);
  cursor: pointer;
}
.story-nav button.done {
  background: var(--accent);
}
.story-nav button.current {
  background: var(--gold);
}
.story-nav button:hover,
.story-nav button:focus-visible {
  outline: var(--bw) solid var(--text);
  outline-offset: 1px;
}

/* ------------------------------------------------------------------ caixa de texto */
.dialog {
  grid-area: dialog;
  width: auto;
  min-width: 0;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 14px;
}
.dialog-face {
  width: 60px;
  height: 80px;
}
.dialog-text {
  min-height: 0;
  font-size: 21px;
}
.dialog.typing .dialog-text {
  cursor: pointer;
}
/* "Próximo" é o convite para seguir a história: maior, com a seta andando e, quando a fala termina,
   um anel dourado piscando em degraus (sem brilho nem desfoque) */
.choice-next {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  min-height: 48px;
  padding: 8px 22px;
  font-size: 24px;
  box-shadow: var(--bevel), var(--shadow-2);
  outline: var(--bw) solid transparent;
  outline-offset: 4px;
}
.choice-next::before {
  content: none;
}
.choice-next::after {
  content: '▶';
  font-size: 18px;
  animation: next-nudge 0.9s steps(2) infinite;
}
.choice-next:hover {
  background: #67e8f9;
}
.dialog:not(.typing) .choice-next {
  animation: next-ring 1.2s steps(1) infinite;
}
/* no fim, o mesmo destaque vira o convite para baixar, com a seta para baixo da tela de título */
.choice-download::after {
  content: '▼';
  animation-name: download-nudge;
}
@keyframes download-nudge {
  50% {
    translate: 0 3px;
  }
}
@keyframes next-nudge {
  50% {
    translate: 4px 0;
  }
}
@keyframes next-ring {
  50% {
    outline-color: var(--gold);
  }
}
@media (prefers-reduced-motion: reduce) {
  .choice-next::after {
    animation: none;
  }
  .dialog:not(.typing) .choice-next {
    animation: none;
    outline-color: var(--gold);
  }
}
/* do tamanho dos cartões de nível e tokens (.hud-xp): borda, 6px de respiro, rótulo, 4px e a barra */
.skip-story {
  grid-area: skip;
  align-self: center;
  justify-content: center;
  min-width: 110px;
  min-height: calc(2 * var(--bw) + 12px * 1.3 + 26px);
}

/* avisos: moram na área do escritório (nunca sobre a faixa do HUD nem sobre a caixa de texto), um de
   cada vez, com um véu sólido só sobre o escritório (sem degradê nem desfoque) */
.story-veil {
  grid-area: world;
  align-self: stretch;
  justify-self: stretch;
  z-index: 3;
  background: rgba(6, 7, 13, 0.6);
  opacity: 0;
  pointer-events: none;
}
.story-veil.flash {
  animation: veil 1.6s steps(8) both;
}
.story-veil.hold {
  opacity: 1;
  animation: none;
}
@keyframes veil {
  0% {
    opacity: 0;
  }
  15%,
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
.scroll-hint {
  top: auto;
  bottom: 24%;
}
.chapter-card,
.levelup,
.toast {
  position: relative;
  grid-area: world;
  top: auto;
  left: auto;
  right: auto;
  translate: none;
  z-index: 4;
}
.chapter-card,
.levelup {
  align-self: center;
  justify-self: center;
}
.chapter-card {
  padding: 10px 24px;
}
.chapter-card.show {
  animation-duration: 1.6s;
}
.chapter-t {
  font-size: clamp(30px, 4vw, 46px);
}
.levelup {
  padding: 18px 28px;
  background: var(--ink);
  border-block: var(--bw) solid var(--gold);
  font-size: clamp(44px, 7vw, 88px);
}
.toast {
  align-self: start;
  justify-self: end;
  margin: 12px;
}

/* telas baixas (notebook pequeno, celular deitado) */
@media (max-height: 760px) {
  .dialog {
    grid-template-columns: 52px minmax(0, 1fr);
    padding: 8px 12px;
  }
  .dialog-face {
    width: 40px;
    height: 54px;
    padding: 2px;
  }
  .dialog-text {
    font-size: 19px;
  }
  .dialog-controls {
    margin-top: 6px;
  }
}
@media (max-height: 540px) {
  .story-stage {
    padding-top: 54px;
    gap: 6px 10px;
  }
  .objectives,
  .dialog-face,
  .scroll-hint {
    display: none;
  }
  .dialog {
    grid-template-columns: minmax(0, 1fr);
  }
  .hud-clock {
    font-size: 22px;
  }
}

/* ------------------------------------------------------------------ celular: tudo em coluna */
@media (max-width: 760px) {
  .story-stage {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      'quest status'
      'nav skip'
      'world world'
      'dialog dialog';
    gap: 6px;
    padding: 58px 8px 8px;
  }
  .hud-quest {
    padding: 6px 10px;
  }
  .hud-quest .hud-label,
  .objectives {
    display: none;
  }
  .quest-name {
    font-size: 17px;
    line-height: 1.2;
  }
  .hud-status {
    gap: 6px;
  }
  .hud-clock {
    padding: 2px 8px;
    font-size: 24px;
  }
  .clock-icon {
    font-size: 16px;
  }
  .hud-xp {
    min-width: 0;
    padding: 4px 8px;
    gap: 3px;
  }
  .hud-xp .xp-bar {
    width: 56px;
    height: 8px;
  }
  .story-nav {
    justify-self: stretch;
    padding: 4px;
  }
  .story-nav button {
    flex: 1;
    width: auto;
    height: 18px;
  }
  .skip-story {
    align-self: stretch;
    min-width: 0;
    min-height: 0;
  }
  .dialog {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
    box-shadow: var(--bevel), var(--shadow-2);
  }
  .dialog-face {
    width: 36px;
    height: 48px;
    padding: 2px;
  }
  .dialog-name {
    margin-bottom: 4px;
  }
  .dialog-text {
    font-size: 18px;
  }
  .dialog-controls {
    gap: 8px;
    margin-top: 8px;
  }
  .dialog-input {
    min-width: 0;
    width: 100%;
    font-size: 18px;
  }
  .choice {
    font-size: 18px;
    padding: 6px 12px;
  }
  .scroll-hint {
    display: none;
  }
  .chapter-card {
    padding: 10px 18px;
  }
  .chapter-t {
    font-size: 34px;
  }
  .toast {
    align-self: end;
    justify-self: stretch;
    width: auto;
    margin: 8px;
  }
  .levelup {
    padding: 12px 18px;
    font-size: 46px;
  }
}
