/* Diário dos BNs — Laboratório Digital 3D (estilos isolados, só carregados em /laboratorio-digital/) */
html.lab-page, html.lab-page[data-theme] {
  color-scheme: dark;
  --bg: #07080c; --bg-soft: #070a14; --surface: rgba(10, 14, 28, .72); --surface-2: rgba(16, 22, 42, .8);
  --text: #eef0f6; --muted: #a9b0c4; --subtle: #8e96ac; --line: rgba(210, 220, 255, .12); --line-strong: rgba(210, 220, 255, .24);
  --gold: #f0c674; --accent: #f0c674; --blue: #8fb0ff; --ds-primary: #eef0f6; --ds-primary-ink: #04060d; --ds-primary-hover: #fff;
  --lab-glass: rgba(8, 11, 24, .58);
  background: #07080c;
}
html.lab-page body { background: transparent; color: var(--text); overflow-x: clip; }
html.lab-page .theme-toggle, html.lab-page .ds-progress { display: none !important; }

#lab-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100lvh; display: block; z-index: 0; background: #04060d; }
.lab-body .site-header { background: linear-gradient(180deg, rgba(4, 6, 13, .7), rgba(4, 6, 13, 0)); backdrop-filter: none; -webkit-backdrop-filter: none; border-bottom: 0 !important; }
.lab-body .site-header.is-scrolled { background: rgba(4, 6, 13, .55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

/* ---------- HUD ---------- */
.lab-hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.lab-progress { position: absolute; top: 0; left: 0; right: 0; height: 2px; background: rgba(255, 255, 255, .06); }
.lab-progress span { display: block; height: 100%; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, #8fb0ff, #f0c674 60%, #ff8a5c); box-shadow: 0 0 12px rgba(240, 198, 116, .6); }
.lab-region { position: absolute; left: max(24px, calc((100% - var(--max)) / 2)); bottom: 22px; margin: 0; font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lab-rail { position: absolute; right: 22px; top: 46%; transform: translateY(-50%); display: grid; gap: 6px; pointer-events: auto; }
.lab-rail button {
  position: relative; display: flex; align-items: center; justify-content: flex-end; gap: 10px; width: 180px; height: 30px; padding: 0;
  border: 0; background: none; color: var(--muted); font: 500 .78rem var(--font); cursor: pointer;
}
.lab-rail button::after { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid rgba(220, 228, 255, .5); transition: transform .3s var(--ease-out), background .3s, border-color .3s, box-shadow .3s; }
.lab-rail button span { opacity: 0; transform: translateX(6px); transition: opacity .25s, transform .25s; padding: 3px 8px; border-radius: 6px; background: rgba(4, 6, 13, .6); }
.lab-rail button:hover span, .lab-rail button:focus-visible span, .lab-rail button[aria-current="step"] span { opacity: 1; transform: none; }
.lab-rail button[aria-current="step"] { color: var(--text); }
.lab-rail button[aria-current="step"]::after { background: var(--gold); border-color: var(--gold); transform: scale(1.35); box-shadow: 0 0 14px rgba(240, 198, 116, .8); }
.lab-rail button:hover::after { border-color: #fff; }

/* ---------- Capítulos (conteúdo em HTML sobre a cena) ---------- */
.lab-main { position: relative; z-index: 2; pointer-events: none; }
.lab-chapter { min-height: 190vh; display: flex; align-items: center; padding: 18vh max(24px, calc((100% - var(--max)) / 2)); }
.lab-chapter--intro { min-height: 150vh; align-items: flex-start; padding-top: 15vh; }
.lab-chapter--final { min-height: 230vh; align-items: flex-end; padding-bottom: 12vh; }
.lab-card {
  pointer-events: auto; width: min(480px, 100%); padding: 28px 30px; border-radius: 14px;
  background: var(--lab-glass); border: 1px solid rgba(210, 220, 255, .12);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, .8);
  opacity: 0; transform: translateY(28px); transition: opacity .9s var(--ease-out), transform .9s var(--ease-out);
}
.lab-card.is-in { opacity: 1; transform: none; }
.lab-card--hero { width: min(720px, 100%); background: none; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 0; }
.lab-card--wide { width: min(980px, 100%); }
.lab-kicker { margin: 0 0 12px; font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.lab-card h1, .lab-card h2 { margin: 0 0 14px; color: #fff; outline: none; }
.lab-card h2 { font-size: clamp(1.9rem, 3.6vw, 2.8rem); letter-spacing: -.02em; }
.lab-card h2 em { font-style: italic; font-weight: 420; color: var(--gold); }
.lab-card p { color: #c9cfdf; font-size: 1rem; line-height: 1.65; }
.lab-card h1 { font-size: clamp(3.2rem, 8.2vw, 6.8rem); line-height: .92; letter-spacing: -.045em; font-weight: 500; }
.lab-title-a, .lab-title-b { display: inline-block; }
.lab-title-b { font-style: italic; font-weight: 400; background: linear-gradient(100deg, #f7e2b3, #f0c674 40%, #ff9a6b 75%, #9db7ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lab-card--hero.is-in .lab-title-a { animation: lab-rise 1.4s var(--ease-out) both; }
.lab-card--hero.is-in .lab-title-b { animation: lab-rise 1.4s .18s var(--ease-out) both; }
@keyframes lab-rise { from { opacity: 0; transform: translateY(40px); filter: blur(12px); letter-spacing: .02em; } }
.lab-lede { max-width: 54ch; font-size: clamp(1.02rem, 1.5vw, 1.18rem) !important; color: #d4d9e8 !important; }
.lab-hint { margin-top: 26px; font-family: var(--mono); font-size: .74rem !important; letter-spacing: .04em; color: var(--muted) !important; }
.lab-hint span { display: inline-block; animation: lab-bob 2.4s ease-in-out infinite; }
@keyframes lab-bob { 50% { transform: translateY(4px); } }
.lab-note { padding: 10px 12px; border-left: 2px solid var(--gold); background: rgba(240, 198, 116, .06); font-size: .88rem !important; }

/* ---------- Botões ---------- */
.lab-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.lab-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 22px;
  border: 1px solid rgba(220, 228, 255, .28); border-radius: 999px; background: rgba(8, 11, 24, .35); color: #fff !important;
  font: 600 .93rem var(--font); text-decoration: none; cursor: pointer; overflow: hidden; isolation: isolate;
  transition: border-color .25s, background .25s, transform .15s, box-shadow .35s;
}
.lab-btn::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(120px 60px at var(--mx, 50%) var(--my, 50%), rgba(143, 176, 255, .35), transparent 70%); opacity: 0; transition: opacity .3s; }
.lab-btn:hover { border-color: rgba(220, 228, 255, .6); box-shadow: 0 0 24px -6px rgba(143, 176, 255, .6); }
.lab-btn:hover::before { opacity: 1; }
.lab-btn:active { transform: scale(.97); }
.lab-btn--primary { background: #eef0f6; color: #04060d !important; border-color: #eef0f6; }
.lab-btn--primary:hover { background: #fff; box-shadow: 0 0 34px -4px rgba(240, 198, 116, .75); }
.lab-picks { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 6px; }
.lab-picks button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid rgba(143, 176, 255, .35); background: rgba(143, 176, 255, .08); color: #dfe6ff; font: 500 .86rem var(--font); cursor: pointer;
  transition: background .2s, border-color .2s;
}
.lab-picks button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 10px var(--blue); }
.lab-picks button:hover { background: rgba(143, 176, 255, .2); border-color: rgba(143, 176, 255, .7); }
.lab-links { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(210, 220, 255, .1); }
.lab-links a { color: #fff; font-weight: 600; font-size: .92rem; text-decoration: none; }
.lab-links a:hover { color: var(--gold); }

/* ---------- Portal final ---------- */
.lab-portal { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 22px; }
.lab-portal a { display: grid; gap: 2px; padding: 16px 18px; border: 1px solid rgba(210, 220, 255, .12); border-radius: 10px; background: rgba(6, 9, 20, .7); color: #fff; text-decoration: none; transition: background .25s, border-color .25s, transform .3s var(--ease-out); }
.lab-portal a:hover { border-color: rgba(240, 198, 116, .5); transform: translateY(-2px); }
.lab-portal a b { font-family: var(--display); font-size: 1.08rem; font-weight: 600; }
.lab-portal a span { color: var(--muted); font-size: .84rem; }
.lab-portal a:hover { background: rgba(20, 28, 56, .9); }
.lab-portal a:hover b { color: var(--gold); }
.lab-portal a[hidden] { display: none !important; }

/* ---------- Painel de informações ---------- */
.lab-panel {
  position: fixed; z-index: 20; right: 64px; top: calc(var(--header-h) + 64px); width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - var(--header-h) - 110px); overflow: auto;
  padding: 26px 26px 22px; border-radius: 16px; background: rgba(6, 9, 20, .78); border: 1px solid rgba(143, 176, 255, .28);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); box-shadow: 0 0 0 1px rgba(255, 255, 255, .02), 0 30px 80px -30px rgba(0, 0, 0, .9), 0 0 60px -30px rgba(143, 176, 255, .5);
}
.lab-panel.is-entering { animation: lab-panel-in .45s var(--ease-out); }
@keyframes lab-panel-in { from { opacity: 0; transform: translateX(20px) scale(.98); } }
.lab-panel h2 { margin: 0 0 12px; font-size: 1.7rem; color: #fff; }
.lab-panel ul { margin: 0 0 14px; padding-left: 18px; color: #d8deee; font-size: .92rem; line-height: 1.55; }
.lab-panel p { color: #c5cbdc; font-size: .93rem; line-height: 1.6; }
.lab-panel-close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(220, 228, 255, .2); background: none; color: #fff; font-size: 20px; line-height: 1; cursor: pointer; }
.lab-panel-close:hover { background: rgba(255, 255, 255, .08); }

/* ---------- Dock de controles ---------- */
.lab-dock { position: fixed; z-index: 15; right: max(24px, calc((100% - var(--max)) / 2)); top: calc(var(--header-h) + 12px); display: flex; justify-content: flex-end; flex-wrap: wrap; align-items: center; gap: 8px; }
.lab-icon {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(220, 228, 255, .2); background: rgba(6, 9, 20, .55); color: #dfe4f2; font: 500 .8rem var(--font);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: background .2s, border-color .2s;
}
.lab-icon svg { width: 16px; height: 16px; }
.lab-icon:hover { background: rgba(20, 28, 56, .8); border-color: rgba(220, 228, 255, .5); }
.lab-icon[aria-pressed="true"] { border-color: var(--gold); color: var(--gold); }
.lab-explore-hint { display: flex; align-items: center; gap: 12px; padding: 4px 4px 4px 16px; border-radius: 999px; background: rgba(6, 9, 20, .7); border: 1px solid rgba(143, 176, 255, .3); font-size: .82rem; color: #cfd6ea; }
.lab-explore-hint[hidden] { display: none; }
.lab-explore-hint .lab-btn { min-height: 34px; padding: 0 14px; }

/* ---------- Configurações ---------- */
.lab-settings {
  position: fixed; z-index: 25; right: max(24px, calc((100% - var(--max)) / 2)); top: calc(var(--header-h) + 60px); width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - var(--header-h) - 90px); overflow: auto; display: grid; gap: 14px;
  padding: 22px; border-radius: 16px; background: rgba(6, 9, 20, .9); border: 1px solid rgba(220, 228, 255, .2); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .9); animation: lab-panel-in-b .3s var(--ease-out);
}
.lab-settings[hidden] { display: none; }
@keyframes lab-panel-in-b { from { opacity: 0; transform: translateY(10px); } }
.lab-settings-head { display: flex; justify-content: space-between; align-items: center; }
.lab-settings-head h2 { margin: 0; font-size: 1.2rem; color: #fff; }
.lab-settings-head .lab-panel-close { position: static; }
.lab-settings label { display: grid; gap: 6px; color: #dfe4f2; font-size: .9rem; font-weight: 500; }
.lab-settings .lab-check { display: flex; align-items: center; gap: 10px; font-weight: 400; }
.lab-settings fieldset { margin: 0; padding: 10px 12px; border: 1px solid rgba(220, 228, 255, .15); border-radius: 10px; display: grid; gap: 8px; }
.lab-settings legend { padding: 0 6px; font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lab-settings select { min-height: 40px; padding: 0 10px; background: rgba(4, 6, 13, .8) !important; color: #fff !important; }
.lab-small { margin: -8px 0 0; font-size: .78rem; color: var(--muted); min-height: 1em; }

/* ---------- Tooltip, falha e navegação por capítulos ---------- */
.lab-tooltip { position: fixed; z-index: 30; left: 0; top: 0; padding: 6px 10px; border-radius: 8px; pointer-events: none; background: rgba(6, 9, 20, .85); border: 1px solid rgba(143, 176, 255, .35); color: #fff; font: 500 .8rem var(--font); white-space: nowrap; }
.lab-fallback { position: fixed; z-index: 30; left: 50%; top: 90px; transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); padding: 16px 18px; border-radius: 12px; background: rgba(40, 20, 10, .9); border: 1px solid #f0c674; color: #fff; }
.lab-fallback a { color: var(--gold); }
body.lab-nogl #lab-canvas { background: radial-gradient(ellipse at 70% 30%, #1a1f40, #04060d 60%); }
body.lab-nogl .lab-card { opacity: 1; transform: none; }

.lab-stepper { display: none; }
body.lab-stepped .lab-chapter { display: none; min-height: 0; }
body.lab-stepped .lab-chapter.is-current { display: flex; min-height: 100vh; }
body.lab-stepped .lab-card { opacity: 1; transform: none; }
body.lab-stepped .lab-stepper { position: fixed; z-index: 15; left: 50%; transform: translateX(-50%); bottom: 26px; display: flex; gap: 10px; }

html.lab-exploring .lab-panel { opacity: 0; pointer-events: none; transition: opacity .4s; }
html.lab-exploring .lab-main, html.lab-exploring .lab-rail { opacity: 0; pointer-events: none; transition: opacity .5s; }
html.lab-exploring, html.lab-exploring body { overflow: hidden; }
html.lab-exploring #lab-canvas { cursor: grab; touch-action: none; }


/* ---------- Responsivo ---------- */
@media (max-width: 760px) {
  .lab-rail { right: 8px; }
  .lab-rail button { width: 28px; }
  .lab-rail button span { display: none; }
  .lab-chapter { padding-inline: 16px; align-items: flex-end; padding-bottom: 16vh; }
  .lab-chapter--intro { align-items: flex-start; }
  .lab-card { padding: 18px; max-height: 52vh; overflow-y: auto; overscroll-behavior: contain; background: rgba(6, 9, 20, .5); }
  .lab-card--hero { max-height: none; overflow: visible; background: none; }
  .lab-card h2 { font-size: 1.6rem; }
  .lab-card p { font-size: .94rem; line-height: 1.55; }
  .lab-card--wide { max-height: 70vh; }
  .lab-panel { right: 8px; left: 8px; top: auto; bottom: 96px; transform: none; width: auto; max-height: 56vh; }
  @keyframes lab-panel-in { from { opacity: 0; transform: translateY(20px); } }
  .lab-dock { right: auto; left: 12px; top: auto; bottom: 34px; }
  .lab-region { display: none; }
  .lab-icon span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .lab-settings { left: 8px; right: 8px; width: auto; top: auto; bottom: 84px; max-height: 70vh; overflow: auto; }
  .lab-region { left: 12px; bottom: 16px; }
  body.lab-stepped .lab-stepper { bottom: 84px; }
  .lab-explore-hint span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .lab-card, .lab-card--hero .lab-title-a, .lab-card--hero .lab-title-b { animation: none !important; transition: none !important; opacity: 1; transform: none; }
  .lab-hint span { animation: none; }
}

/* ---------- Controles dos experimentos dentro do painel ---------- */
.lab-panel [data-panel-controls] { display: grid; gap: 14px; margin: 4px 0 16px; padding: 14px; border: 1px solid rgba(143, 176, 255, .22); border-radius: 12px; background: rgba(143, 176, 255, .05); }
.lab-panel [data-panel-controls]:empty { display: none; }
.lab-control { display: grid; gap: 6px; }
.lab-control label { display: grid; gap: 8px; color: #dfe4f2; font-size: .86rem; font-weight: 500; }
.lab-control input[type="range"] { width: 100%; accent-color: #f0c674; min-height: 28px; }
.lab-control output { font-family: var(--mono); font-size: .8rem; color: var(--gold); }
.lab-choice { display: flex; flex-wrap: wrap; gap: 6px; }
.lab-choice button { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(143, 176, 255, .35); background: rgba(143, 176, 255, .08); color: #dfe6ff; font: 600 .9rem var(--font); cursor: pointer; }
.lab-choice button[aria-pressed="true"] { background: #f0c674; border-color: #f0c674; color: #07080c; }
.lab-choice button:hover { border-color: rgba(143, 176, 255, .8); }
html.lab-page .lab-kicker { color: #f0c674; }
