/* P2 Design — tipografia, empty states, skeletons, mobile nav, tokens auxiliares */

:root {
  --font-ui: "Source Sans 3", "Segoe UI", sans-serif;
  --font-narrative: "Source Serif 4", "Georgia", "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", "Courier New", monospace;
  --gold: var(--warning);
  --accent-cta: var(--accent);
  --accent-cta-strong: var(--accent-strong);
}

body {
  font-family: var(--font-ui);
  letter-spacing: 0.01em;
}

h1, h2, h3, h4, .scene-title, .stories-header h1, .landing-hero h1 {
  font-family: var(--font-ui);
  letter-spacing: 0.04em;
}

.narrative-text,
.narrative-text p,
.scene-body,
.letter-box,
.story-prose,
.ending-copy,
.choice-prompt,
.chat-messages .bubble,
.feedback-comment {
  font-family: var(--font-narrative);
  letter-spacing: 0.01em;
  line-height: 1.75;
}

.ui-terminal,
.terminal,
.code-block,
pre, code,
.typing-effect,
.glitch,
.nav-btn,
.catalog-filters label span,
.landing-kicker,
.continue-card-label,
.story-progress-label {
  font-family: var(--font-mono);
}

.pi-icon {
  display: inline-block;
  vertical-align: -0.2em;
  flex-shrink: 0;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  box-sizing: border-box;
}

.nav-btn-icon {
  width: 16px;
  height: 16px;
  opacity: 0.9;
}

.app-topnav.stories-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow: visible;
  padding-bottom: 0;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 30;
}

.app-topnav.stories-nav > .nav-btn,
.app-topnav.stories-nav > .nav-dropdown {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 40px;
}

.app-topnav.stories-nav .nav-btn,
.app-topnav.stories-nav button.nav-btn {
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0 14px;
  line-height: 1;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(8, 14, 24, 0.78);
  border: 1px solid rgba(148, 193, 227, 0.2);
  border-radius: var(--radius-sm, 8px);
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
  transform: none;
  vertical-align: middle;
}

.app-topnav.stories-nav .nav-btn:hover,
.app-topnav.stories-nav .nav-btn:focus-visible {
  color: var(--heading);
  border-color: var(--secondary);
  background: rgba(25, 183, 255, 0.1);
  transform: none;
  outline: none;
}

.app-topnav.stories-nav .nav-btn.is-active,
.app-topnav.stories-nav .nav-dropdown.is-open > .nav-btn {
  color: var(--heading);
  border-color: var(--secondary);
  background: rgba(25, 183, 255, 0.12);
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  cursor: pointer;
}

.nav-caret {
  width: 0;
  height: 0;
  margin-left: 4px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.7;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.nav-dropdown.is-open .nav-caret {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 4px;
  background: rgba(6, 12, 20, 0.98);
  border: 1px solid var(--border, rgba(99, 132, 160, 0.35));
  border-radius: var(--radius-md, 12px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  z-index: 40;
}

.nav-dropdown-menu--end {
  left: auto;
  right: 0;
}

.nav-dropdown.is-open .nav-dropdown-menu {
  display: flex;
}

.nav-dropdown-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm, 8px);
  color: var(--muted);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}

.nav-dropdown-item:hover,
.nav-dropdown-item:focus-visible {
  color: var(--heading);
  border-color: rgba(25, 183, 255, 0.28);
  background: rgba(25, 183, 255, 0.1);
  outline: none;
}

@media (max-width: 720px) {
  .app-topnav.stories-nav {
    justify-content: center;
  }

  .nav-dropdown-menu,
  .nav-dropdown-menu--end {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    min-width: min(240px, calc(100vw - 32px));
  }
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 48px 28px;
  max-width: 520px;
  margin: 24px auto;
}

.empty-state-art {
  width: 88px;
  height: 88px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 30% 30%, rgba(25, 183, 255, 0.22), transparent 55%),
    radial-gradient(circle at 70% 65%, rgba(255, 79, 109, 0.2), transparent 50%),
    rgba(8, 14, 24, 0.9);
  border: 1px solid var(--border);
}

.empty-state-icon {
  width: 36px;
  height: 36px;
  color: var(--secondary);
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--heading);
  font-size: 1.25rem;
}

.empty-state p {
  color: var(--muted);
  margin: 0 0 20px;
  font-family: var(--font-ui);
}

.empty-state .btn-cta-primary {
  display: inline-flex;
}

/* Skeletons */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin: 18px 0 28px;
}

.skeleton-card,
.skeleton-line,
.skeleton-avatar {
  position: relative;
  overflow: hidden;
  background: rgba(12, 20, 32, 0.9);
  border: 1px solid rgba(99, 132, 160, 0.22);
  border-radius: var(--radius-md);
}

.skeleton-card::after,
.skeleton-line::after,
.skeleton-avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  animation: skeleton-shimmer 1.35s infinite;
}

.skeleton-card {
  min-height: 220px;
  padding: 22px;
}

.skeleton-card .skeleton-line {
  height: 14px;
  margin-bottom: 12px;
  border: 0;
}

.skeleton-card .skeleton-line.lg { height: 22px; width: 70%; }
.skeleton-card .skeleton-line.sm { width: 45%; }
.skeleton-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 0;
}

.chat-skeleton {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}

.chat-skeleton-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 70%;
}

.chat-skeleton-row.mine {
  margin-left: auto;
  flex-direction: row-reverse;
}

.chat-skeleton-bubble {
  height: 54px;
  width: min(280px, 70vw);
  border-radius: 14px;
  border: 0;
}

@keyframes skeleton-shimmer {
  100% { transform: translateX(100%); }
}

.is-loading .stories-grid,
.is-loading .chat-messages-live {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.catalog-shell:not(.is-loading) .catalog-skeleton,
.chat-shell:not(.is-loading) .chat-skeleton {
  display: none;
}

/* Long scenes */
.narrative-text {
  max-width: 68ch;
  overflow-wrap: anywhere;
  hyphens: auto;
}

@media (max-width: 720px) {
  .narrative-text {
    padding: 18px 14px;
    font-size: 1.02rem;
    max-width: 100%;
  }

  .choice-btn {
    min-height: 48px;
  }

  .chat-page .chat-container {
    grid-template-columns: 1fr !important;
    height: auto !important;
  }

  .chat-page .chat-sidebar {
    max-height: none;
  }

  .message {
    max-width: 92% !important;
  }

  .app-topnav.stories-nav {
    padding-left: 12px;
    padding-right: 12px;
    margin-top: 10px;
  }

  .nav-btn-text {
    font-size: 0.72rem;
  }
}

/* Difficulty dots (no emoji) */
.pi-diff {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pi-diff-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.pi-diff-dot.is-easy { background: var(--positive); }
.pi-diff-dot.is-medium { background: var(--warning); }
.pi-diff-dot.is-hard { background: var(--accent); }

/* PWA install — floating chip left; ambient audio fica à direita */
#piPwaInstall {
  position: fixed;
  left: 16px;
  bottom: 16px;
  right: auto;
  top: auto;
  z-index: 45;
  width: auto;
  max-width: min(220px, calc(100vw - 32px));
  margin: 0;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(8, 14, 24, 0.94);
  color: var(--heading);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  overflow: visible;
  transform: none;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

#piPwaInstall[hidden] {
  display: none !important;
}

#piPwaInstall::after {
  content: none;
  display: none;
}

#piPwaInstall:hover {
  border-color: var(--secondary);
  color: var(--secondary);
  background: rgba(10, 18, 30, 0.98);
  transform: none;
  box-shadow: var(--shadow-soft);
}

/* Pagination */
.pi-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 28px 0 8px;
}

.pi-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border, rgba(99,132,160,.35));
  background: rgba(8, 14, 24, 0.88);
  color: var(--heading, #f4f7ff);
  font-family: var(--font-mono, monospace);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
}

.pi-page-btn:hover {
  border-color: var(--secondary, #19b7ff);
  color: var(--secondary, #19b7ff);
}

.pi-page-btn.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.pi-page-status {
  color: var(--muted, #8698ad);
  font-size: 0.85rem;
}

.chat-load-older {
  display: block;
  width: fit-content;
  margin: 0 auto 12px;
}

/* Auth topbar (layout nav=auth) */
.auth-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 20px 8px;
}
.auth-brand {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--heading);
  text-decoration: none;
}
.auth-topnav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.auth-topnav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.auth-topnav a:hover { color: var(--secondary); }
.auth-topnav-cta {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--heading) !important;
}
body.landing-page .auth-topbar,
body.auth-shell .auth-topbar {
  width: 100%;
}
