/* Sarcômero 3D: tokens nas cores do modelo impresso (amarelo Z, azul actina, rosa miosina, laranja cabeças, verde-água M). */
:root {
  --z: #f2cf3a;
  --actina: #2450c8;
  --miosina: #e8336b;
  --cabeca: #f7792b;
  --m: #23a69a;

  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --ink: #171a2b;
  --muted: #5d6275;
  --line: #e1ddd2;
  --accent: #cc1f5c; /* fundo de botão: 5,4:1 com texto branco */
  --accent-text: #c2185b; /* rosa para texto sobre fundo claro (AA) */
  --accent-ink: #ffffff;
  --focus: #2450c8;

  --stage-1: #1b2040;
  --stage-2: #0b0d1a;
  --stage-ink: #eef0ff;

  --radius: 16px;
  --shadow: 0 12px 32px rgba(15, 18, 34, 0.14);
  --serif: "Fraunces", Georgia, serif;
  --sans: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1222;
    --surface: #181c33;
    --surface-2: #20253f;
    --ink: #eef0ff;
    --muted: #a3a9c6;
    --line: #2b3152;
    --accent-text: #ff7aa0;
    --focus: #8fb0ff;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1222;
  --surface: #181c33;
  --surface-2: #20253f;
  --ink: #eef0ff;
  --muted: #a3a9c6;
  --line: #2b3152;
  --accent-text: #ff7aa0;
  --focus: #8fb0ff;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  overflow-x: clip; /* nenhuma página rola para o lado */
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Topo ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top));
  padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right));
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: relative; z-index: 5;
}
.brand {
  display: flex; align-items: center; gap: 8px; min-height: 44px; min-width: 44px; text-decoration: none;
  font-family: var(--serif); font-weight: 700; font-size: 1.1rem;
}
.brand svg { width: 28px; height: 28px; flex: none; }
.brand em { font-style: normal; color: var(--accent-text); }
.brand span { white-space: nowrap; }
.topbar nav { display: flex; gap: 2px; }
.topbar nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 999px;
  text-decoration: none; font-weight: 500; font-size: 0.95rem; color: var(--muted); white-space: nowrap;
}
.topbar nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }
.topbar nav a.nav-cta { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
/* Celular estreito: a marca vira só o ícone, para o menu (e o "Avaliar") caber inteiro. */
@media (max-width: 419px) {
  .brand span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .topbar nav a { padding: 0 11px; font-size: 0.92rem; }
}

/* ---------- Ícones e botões compartilhados ---------- */
.icon { width: 20px; height: 20px; flex: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%;
  cursor: pointer; background: var(--surface-2); color: var(--ink);
}
.icon-btn:disabled { opacity: 0.35; cursor: default; }

/* ---------- Visualizador ---------- */
body.app { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.viewer { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.stage {
  flex: 1; min-height: 0; position: relative; overflow: hidden; touch-action: none;
  background: radial-gradient(120% 90% at 50% 40%, var(--stage-1), var(--stage-2));
  color: var(--stage-ink);
}
.stage canvas { display: block; cursor: grab; }
.stage canvas:active { cursor: grabbing; }
.labels-layer { position: absolute; inset: 0; pointer-events: none; }
.region-label {
  font: 600 12px/1 var(--sans); color: #fff; background: rgba(10, 12, 26, 0.78);
  padding: 4px 8px; border-radius: 999px; white-space: nowrap; transform: translateY(-140%);
  transition: opacity 0.2s;
}
/* Sobreposições escuras sobre o palco (sempre escuro, nos dois temas). */
.readout {
  position: absolute; top: 12px; left: 12px; z-index: 2; pointer-events: none;
  font-size: 13px; background: rgba(10, 12, 26, 0.72); padding: 6px 12px; border-radius: 999px; color: #c9cde6;
}
.readout b { color: #fff; font-weight: 600; }
.stage-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 50%; cursor: pointer; background: rgba(10, 12, 26, 0.72); color: #eef0ff;
}
.stage-btn:hover { background: rgba(10, 12, 26, 0.9); }
.stage :focus-visible { outline-color: #8fb0ff; }
.hint {
  position: absolute; z-index: 1; left: 50%; bottom: 14px; transform: translateX(-50%); margin: 0; pointer-events: none;
  width: max-content; max-width: calc(100% - 24px); text-align: center;
  font-size: 13px; line-height: 1.35; color: #eef0ff; background: rgba(10, 12, 26, 0.72); padding: 8px 14px; border-radius: 14px;
}
.hint-mouse { display: none; }
@media (hover: hover) and (pointer: fine) { .hint-mouse { display: inline; } .hint-touch { display: none; } }
.tooltip {
  position: absolute; z-index: 3; max-width: 220px; pointer-events: none;
  background: rgba(255, 255, 255, 0.97); color: #171a2b; border-radius: 12px; padding: 8px 12px; box-shadow: var(--shadow);
  font-size: 13px; line-height: 1.35;
}
.tooltip strong { display: block; font-size: 14px; }
.tooltip span { color: #5d6275; }

/* Passeio guiado: embaixo no celular, no alto no desktop (assim não cobre as faixas de medida). */
.tour {
  position: absolute; z-index: 3; left: 8px; right: 8px; bottom: 8px;
  background: rgba(10, 12, 26, 0.88); color: #eef0ff; border-radius: 16px; padding: 10px 12px 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.tour-bar { display: flex; gap: 4px; margin-bottom: 8px; }
.tour-bar span { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.2); }
.tour-bar span.on { background: var(--z); }
.tour-text { margin: 0; font-size: 14px; line-height: 1.4; max-height: 30vh; overflow: auto; }
.tour-title { display: block; color: var(--z); font-size: 15px; margin-bottom: 2px; }
.tour-nav { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.tour .icon-btn { background: rgba(255, 255, 255, 0.12); color: #fff; }
.text-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 0; border-radius: 999px;
  cursor: pointer; font-weight: 600; font-size: 0.95rem;
}
.tour .text-btn { margin-left: auto; background: transparent; color: #eef0ff; }
.tour .text-btn:hover { background: rgba(255, 255, 255, 0.12); }
.stage.touring .hint { display: none; }

/* Painel de informação: lateral no desktop, folha inferior (dentro do palco) no celular. Nunca cobre os controles. */
.info {
  position: absolute; z-index: 4; right: 12px; top: 12px; width: min(360px, calc(100% - 24px));
  max-height: calc(100% - 24px); overflow: auto; overscroll-behavior: contain; background: var(--surface); color: var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; touch-action: pan-y;
}
.info h2 { font: 700 1.3rem/1.2 var(--serif); margin: 2px 52px 6px 0; display: flex; align-items: center; gap: 10px; }
.info-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; order: -1; }
.info-tipo { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.info-resumo { margin: 0 0 10px; color: var(--muted); }
.info dl { margin: 0; }
.info dt { font-weight: 600; font-size: 13px; color: var(--accent-text); margin-top: 10px; }
.info dd { margin: 2px 0 0; font-size: 15px; }
.info-close { position: absolute; top: 8px; right: 8px; }
@media (max-width: 720px) {
  .info {
    left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 58%;
    padding: 14px 16px; animation: sheet 0.2s ease-out;
  }
  .info h2 { font-size: 1.15rem; }
  .info dd { font-size: 14px; }
}
@media (min-width: 721px) {
  .tour { left: 50%; right: auto; bottom: auto; top: 12px; transform: translateX(-50%); width: min(620px, calc(100% - 140px)); padding: 12px 16px 10px; }
  .tour-text { font-size: 15px; }
}
@media (min-width: 721px) and (max-width: 1000px) { .stage.touring .readout { display: none; } }
@keyframes sheet { from { transform: translateY(16px); } }

/* Barra inferior: slider + chips */
.dock {
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom));
  padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right));
  display: flex; flex-direction: column; gap: 8px;
}
.control { display: flex; align-items: center; gap: 14px; }
.play {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; min-width: 128px; min-height: 48px;
  border: 0; cursor: pointer; background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 0 18px 0 14px; border-radius: 999px;
}
.play .icon { width: 20px; height: 20px; }
.slider { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.slider-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); line-height: 1.2; }
.slider input { width: 100%; height: 36px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; scroll-snap-align: start; min-height: 44px;
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 0 14px;
  font-size: 14px; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
@media (min-width: 900px) {
  .dock { flex-direction: row; align-items: center; gap: 16px; }
  .control { flex: 0 0 400px; }
  .chips { flex: 1; flex-wrap: wrap; }
  .chip { min-height: 40px; }
}

/* ---------- Páginas de conteúdo (sobre, questionário, admin) ---------- */
.page { max-width: 720px; margin: 0 auto; padding: 28px 16px 64px; }
.page h1 { font: 700 clamp(1.8rem, 5vw, 2.6rem)/1.1 var(--serif); margin: 0 0 12px; }
.page h2 { font: 700 1.3rem/1.2 var(--serif); margin: 28px 0 8px; }
.lead { font-size: 1.1rem; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 10px 20px; min-height: 44px; border-radius: 999px; font-size: 1rem;
}
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.muted { color: var(--muted); }
footer.foot { text-align: center; font-size: 13px; color: var(--muted); padding: 24px 16px 32px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Carregando / sem WebGL ---------- */
.status3d {
  position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; justify-items: center; gap: 14px;
  padding: 24px; text-align: center; color: #eef0ff;
}
.status-msg { margin: 0; max-width: 34ch; font-size: 15px; line-height: 1.45; color: #c9cde6; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.18); border-top-color: var(--z);
  animation: spin 0.9s linear infinite;
}
.stage[data-state="error"] .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.stage:not([data-state="ready"]) .stage-btn,
.stage:not([data-state="ready"]) .hint { display: none; }
/* Celular deitado: menos altura, então tudo numa linha só para o modelo ficar maior. */
@media (orientation: landscape) and (max-height: 500px) {
  .topbar { padding-top: 2px; padding-bottom: 2px; }
  .dock { flex-direction: row; align-items: center; gap: 12px; padding-top: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .control { flex: 0 0 46%; gap: 10px; }
  .play { min-width: 0; min-height: 44px; }
  .chips { flex: 1; min-width: 0; }
  .info { max-height: calc(100% - 16px); top: 8px; left: auto; width: min(360px, 60%); }
  .tour-text { max-height: 22vh; }
}
