/* ===========================================================================
   lab.css — ALL chrome for the BPSO Lab. Self-contained: declares the canonical
   "BPSO Lab 2026" tokens (mirror of blog.css 9-51), the four draw classes
   (.pen/.ink/.field/.frame/.stamp), the dot-grid substrate + brand glow, the
   topbar, the hub card grid, the cover system, the plotter draw-in motion, and
   the funnel hook. Does NOT @import fonts/icons (loaded as <link>s in head.php).
   Dark is default; every token flips under [data-theme="light"].
   =========================================================================== */
:root {
    --brand-blue: #2563eb; --brand-dark: #1e40af; --brand-light: #60a5fa;
    --brand-glow: rgba(37,99,235,.35);
    --bg-dark: #0f172a; --bg-card: #1e293b; --surface-2: #243349;
    --text-main: #f8fafc; --text-muted: #94a3b8;
    --border: rgba(255,255,255,.08);
    --accent-security: #ef4444; --accent-dev: #2563eb; --accent-tools: #8b5cf6; --accent-sites: #0d9488; --accent-warm: #f59e0b;
    --accent: #8b5cf6;                 /* Lab default accent (tools-purple) */
    --cover-bg: #131c30; --cover-grid: rgba(148,163,184,.30); --cover-fill: rgba(139,92,246,.16);
    --page-dot: rgba(148,163,184,.16);  /* substrate dots — faint texture, must not fight body text */
    --r-pill: 999px; --r-card: 16px; --r-input: 10px;
    --shadow-soft: 0 10px 30px -12px rgba(2,6,23,.6);
    --font-head: 'Poppins', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --font-mono: ui-monospace, 'SFMono-Regular', 'Menlo', monospace;
    --ease-std: cubic-bezier(.4,0,.2,1); --ease-expr: cubic-bezier(.16,1,.3,1);
    --page-bg: var(--bg-dark);
}
[data-theme="light"] {
    --brand-glow: rgba(37,99,235,.18);
    --bg-dark: #f1f5f9; --bg-card: #ffffff; --surface-2: #f8fafc;
    --text-main: #0f172a; --text-muted: #475569;
    --border: rgba(15,23,42,.1);
    --cover-bg: #eef2f7; --cover-grid: rgba(15,23,42,.18); --cover-fill: rgba(139,92,246,.12);
    --page-dot: rgba(15,23,42,.10);
    --shadow-soft: 0 10px 30px -14px rgba(15,23,42,.18);
}

* { box-sizing: border-box; }
/* [hidden] must always win. A class rule like `.si-alert{display:flex}` has equal
   specificity to the UA `[hidden]{display:none}` and, loaded later from a toy's
   app.css, would override it — leaving toasts/alerts/overlays stuck visible when
   toggled via el.hidden. This one !important rule enforces the invariant for every
   toy (help modal, sd-overlay, si-alert, fi-toast, …). Toggle visibility with the
   `hidden` attribute; never fight this with `display`. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; min-height: 100vh; color: var(--text-main);
    font-family: var(--font-body); line-height: 1.6;
    background-color: var(--page-bg);
    background-image:
        radial-gradient(900px 500px at 85% -10%, var(--brand-glow), transparent 60%),
        radial-gradient(var(--page-dot) 9%, transparent 1.6px);
    background-size: auto, 30px 30px;
    background-attachment: fixed;
    overflow-x: hidden;
    display: flex; flex-direction: column; /* sticky footer: pins .lab-funnel to viewport bottom on short toys */
}
#main { flex: 1 0 auto; width: 100%; }
a { color: inherit; }
.skip-link { position: absolute; left: -999px; top: 0; z-index: 1000; background: var(--brand-blue); color: #fff; padding: .6rem 1rem; border-radius: 0 0 var(--r-input) 0; }
.skip-link:focus { left: 0; }

/* ---- Trilingual chrome: show ONLY the active language. The header skip-link +
   backlink are emitted before ob_start() so they survive bpso_lang_filter() in
   all three languages (mirrors the blog); these rules hide the inactive ones.
   Filtered content/footer leaves only the active block, which these reveal. ---- */
.lang-block { display: none; }
html[data-lang="pt"] .lang-block.lang-pt,
html[data-lang="en"] .lang-block.lang-en,
html[data-lang="es"] .lang-block.lang-es { display: inline; }
html[data-lang="pt"] .lang-block.lang-pt.lang-flow,
html[data-lang="en"] .lang-block.lang-en.lang-flow,
html[data-lang="es"] .lang-block.lang-es.lang-flow { display: block; }

/* ---- Four draw classes (the entire drawing vocabulary) ---- */
.pen   { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ink   { fill: currentColor; stroke: none; }
.field { fill: var(--cover-fill); stroke: none; }
.frame { fill: none; stroke: var(--cover-grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.stamp { font: 600 9px var(--font-mono); letter-spacing: .08em; fill: var(--text-muted); }

/* ---- Topbar (cloned from the blog; styled here so the Lab carries its own copy) ---- */
.topbar { position: sticky; top: 0; z-index: 100; backdrop-filter: blur(10px); background: color-mix(in srgb, var(--bg-dark) 82%, transparent); border-bottom: 1px solid var(--border); }
.topbar__inner { max-width: 1100px; margin: 0 auto; padding: .7rem 1.2rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { font-family: var(--font-head); font-weight: 800; letter-spacing: -.02em; text-decoration: none; display: inline-flex; align-items: baseline; gap: .15em; }
.brand__dot { color: var(--brand-blue); }
.brand-tag { margin-left: .5rem; font: 600 .7rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); padding: .15rem .45rem; border: 1px solid var(--border); border-radius: var(--r-pill); }
.topbar__nav { display: flex; align-items: center; gap: .75rem; }
.backlink { display: inline-flex; align-items: center; gap: .35rem; text-decoration: none; color: var(--text-muted); font-size: .9rem; }
.backlink:hover { color: var(--text-main); }
.lang-switcher { position: relative; }
.lang-toggle-btn, .theme-btn { display: inline-flex; align-items: center; gap: .25rem; background: transparent; border: 1px solid var(--border); color: var(--text-main); border-radius: var(--r-pill); padding: .3rem .6rem; cursor: pointer; font: inherit; min-height: 38px; }
.theme-btn { padding: .35rem .5rem; }
.theme-btn .ri-moon-line { display: none; }
[data-theme="light"] .theme-btn .ri-sun-line { display: none; }
[data-theme="light"] .theme-btn .ri-moon-line { display: inline; }
.lang-dropdown { position: absolute; right: 0; top: calc(100% + .4rem); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-input); box-shadow: var(--shadow-soft); min-width: 160px; padding: .3rem; display: none; }
.lang-switcher.is-open .lang-dropdown { display: block; }
.lang-option { display: flex; align-items: center; justify-content: space-between; padding: .5rem .6rem; border-radius: var(--r-input); text-decoration: none; color: var(--text-main); }
.lang-option:hover { background: var(--surface-2); }
.lang-option .lang-check { opacity: 0; }
.lang-option.is-active .lang-check { opacity: 1; color: var(--brand-blue); }

/* ---- Hub layout ---- */
.lab-hub { max-width: 1100px; margin: 0 auto; padding: clamp(2rem, 6vw, 4rem) 1.2rem; }
.lab-hub__kicker { font: 600 .8rem var(--font-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--accent); margin: 0 0 .6rem; }
.lab-hub__title { font-family: var(--font-head); font-weight: 800; letter-spacing: -.02em; font-size: clamp(2rem, 5vw, 3.2rem); margin: 0 0 .8rem; line-height: 1.05; }
.lab-hub__lead { color: var(--text-muted); max-width: 60ch; font-size: 1.05rem; margin: 0 0 2.4rem; }
.lab-grid { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.toy-card { display: flex; flex-direction: column; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow-soft); transition: transform .25s var(--ease-std), border-color .25s var(--ease-std); }
.toy-card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.toy-card.is-soon { opacity: .62; pointer-events: none; }
.toy-card__body { padding: 1.1rem 1.2rem 1.3rem; }
.toy-card__type { font: 600 .7rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.toy-card__title { font-family: var(--font-head); font-weight: 800; letter-spacing: -.01em; font-size: 1.25rem; margin: .3rem 0 .5rem; }
.toy-card__desc { color: var(--text-muted); font-size: .95rem; margin: 0; }
.toy-card__soon { display: inline-block; margin-top: .7rem; font: 600 .72rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); border: 1px dashed var(--border); border-radius: var(--r-pill); padding: .2rem .6rem; }

/* ---- Cover system (24px dot-grid plate) ---- */
.toy-card__cover { margin: 0; aspect-ratio: 360 / 180; background-color: var(--cover-bg); background-image: radial-gradient(var(--cover-grid) 1px, transparent 1.4px); background-size: 24px 24px; display: block; }
.toy-card__cover svg { display: block; width: 100%; height: 100%; }

/* ---- Plotter draw-in motion (mirror of blog.css 449-459). Gated by html.plot-anim. ---- */
html.plot-anim .draw .pen { stroke-dasharray: var(--len, 1000); stroke-dashoffset: var(--len, 1000); }
html.plot-anim .draw.is-drawn .pen { animation: plot-draw 1.2s var(--ease-expr) forwards; }
html.plot-anim .draw .field, html.plot-anim .draw .ink { opacity: 0; transform: scale(.6); transform-box: fill-box; transform-origin: center; }
html.plot-anim .draw.is-drawn .field { animation: plot-pop .5s var(--ease-expr) .5s forwards; }
html.plot-anim .draw.is-drawn .ink   { animation: plot-pop .5s var(--ease-expr) .8s forwards; }
@keyframes plot-draw { to { stroke-dashoffset: 0; } }
@keyframes plot-pop  { to { opacity: 1; transform: scale(1); } }

/* ---- App-window panel (.interactive) ---- */
.interactive { max-width: min(100%, 960px); margin: clamp(1.4rem, 4vw, 2.4rem) auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-soft); overflow: hidden; }
.interactive__head { display: flex; align-items: center; gap: .5rem; padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.interactive__head .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot--r { background: #ef4444; } .dot--y { background: #eab308; } .dot--g { background: #22c55e; }
.interactive__title { margin-left: .4rem; font: 600 .85rem var(--font-mono); color: var(--text-muted); }
.interactive__body { padding: clamp(1rem, 4vw, 1.8rem); }
.interactive__note { color: var(--text-muted); font-size: .85rem; padding: 0 clamp(1rem,4vw,1.8rem) 1rem; margin: 0; }
.interactive__legend { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.interactive__legend kbd { font: 600 .75rem var(--font-mono); border: 1px solid var(--border); border-radius: 6px; padding: .1rem .4rem; background: var(--surface-2); }

/* ---- Help button ("?") + modal (shared across toys; accent per-toy via var(--accent)) ---- */
.lab-help-btn { margin-left: auto; display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; flex: none; border-radius: 50%; border: 1px solid var(--border);
    background: transparent; color: var(--text-muted); cursor: pointer; font: 700 .85rem var(--font-mono);
    transition: border-color .15s, color .15s; }
.lab-help-btn:hover, .lab-help-btn:focus-visible { border-color: var(--accent); color: var(--accent); }
.lab-help__overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
    background: rgba(2,6,23,.6); padding: 1.2rem; }
[data-theme="light"] .lab-help__overlay { background: rgba(15,23,42,.35); }
.lab-help__panel { position: relative; max-width: 480px; width: 100%; max-height: 80vh; overflow-y: auto;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-card);
    padding: 1.8rem 1.6rem; box-shadow: var(--shadow-soft); }
.lab-help__close { position: absolute; top: .9rem; right: .9rem; width: 32px; height: 32px; border-radius: 50%;
    border: 1px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.lab-help__close:hover { border-color: var(--accent); color: var(--accent); }
.lab-help__title { font-family: var(--font-head); font-weight: 800; font-size: 1.25rem; margin: 0 0 .8rem; padding-right: 2rem; }
.lab-help__body { font-size: .95rem; line-height: 1.6; color: var(--text-main); }
.lab-help__body p { margin: 0 0 .8rem; }
.lab-help__body p:last-child { margin-bottom: 0; }
.lab-help__body b { color: var(--accent); }
.lab-help__body ul { margin: 0 0 .8rem; padding-left: 1.2rem; }
.lab-help__body li { margin-bottom: .3rem; }

/* ---- Daily strip (hub): pills dos toys com desafio diário ---- */
.lab-daily { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; margin: 0 0 1.6rem;
    padding: .65rem .9rem; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--bg-card); }
.lab-daily__label { font: 700 .66rem var(--font-mono); letter-spacing: .18em; color: var(--text-muted); }
.lab-daily__pill { display: inline-flex; align-items: center; gap: .35rem; text-decoration: none;
    font: 600 .82rem var(--font-body); padding: .3rem .75rem; border-radius: var(--r-pill);
    border: 1px solid color-mix(in srgb, var(--pill) 55%, transparent); color: var(--text-main);
    transition: background .15s, border-color .15s; }
.lab-daily__pill:hover { background: color-mix(in srgb, var(--pill) 16%, transparent); border-color: var(--pill); }
.lab-daily__note { margin-left: auto; font-size: .74rem; color: var(--text-muted); }

/* ---- Passaporte do Lab (hub): selos + sequência unificada ---- */
.lab-pass { margin: 0 0 1.6rem; padding: .8rem .95rem; border: 1px solid var(--border);
    border-radius: var(--r-card); background: var(--bg-card); }
.lab-pass__head { display: flex; align-items: center; justify-content: space-between; gap: .6rem;
    flex-wrap: wrap; margin-bottom: .6rem; }
.lab-pass__title { font: 700 .66rem var(--font-mono); letter-spacing: .18em; color: var(--text-muted); }
.lab-pass__meta { font: 600 .74rem var(--font-mono); color: var(--text-main); }
.lab-pass__grid { display: flex; flex-wrap: wrap; gap: .4rem; }
.lab-pass__stamp { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .6rem;
    border-radius: var(--r-pill); border: 1px dashed var(--border); font: 600 .74rem var(--font-body);
    color: var(--text-muted); opacity: .55; cursor: help; }
.lab-pass__stamp .lab-pass__emoji { filter: grayscale(1); }
.lab-pass__stamp.is-ok { opacity: 1; border-style: solid; border-color: color-mix(in srgb, var(--accent) 55%, transparent);
    color: var(--text-main); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.lab-pass__stamp.is-ok .lab-pass__emoji { filter: none; }

/* ---- Bônus: link do hub pra vitrine de Produtos ---- */
.lab-bonus { display: flex; align-items: center; gap: .9rem; margin: 2rem 0 0; padding: 1rem 1.2rem;
    border: 1px solid var(--border); border-radius: var(--r-card); background: var(--bg-card);
    text-decoration: none; color: inherit; transition: border-color .15s, transform .15s var(--ease-std); }
.lab-bonus:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); transform: translateY(-2px); }
.lab-bonus > i { font-size: 1.5rem; color: var(--accent); flex: none; }
.lab-bonus__txt { display: flex; flex-direction: column; gap: .1rem; flex: 1; }
.lab-bonus__txt b { font-family: var(--font-head); font-weight: 700; font-size: 1.02rem; }
.lab-bonus__sub { font-size: .85rem; color: var(--text-muted); }
.lab-bonus__arrow { color: var(--text-muted); flex: none; }

/* ---- Funnel hook (hairline, muted; never a beam banner) ---- */
.lab-funnel { border-top: 1px solid var(--border); margin-top: 3rem; }
.lab-funnel__inner { max-width: 1100px; margin: 0 auto; padding: 1.4rem 1.2rem; }
.lab-funnel__line { color: var(--text-muted); font-size: .95rem; margin: 0; }
.lab-funnel__cta { color: var(--accent); text-decoration: none; font-weight: 600; display: inline-flex; align-items: center; gap: .25rem; }
.lab-funnel__cta:hover { text-decoration: underline; }

/* ---- Home teaser card (rendered on the portfolio home) ---- */
.lab-teaser { display: flex; flex-direction: column; gap: .3rem; padding: 1.2rem 1.4rem; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--bg-card); text-decoration: none; color: inherit; max-width: 420px; }
.lab-teaser__tag { font: 600 .7rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.lab-teaser__title { font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; }
.lab-teaser__cta { color: var(--accent); font-weight: 600; }

/* ---- Small phones: keep the topbar on one row (port of blog.css mobile rules) ---- */
@media (max-width: 480px) {
    .topbar__inner { padding: .6rem .9rem; gap: .5rem; }
    .topbar__nav { gap: .45rem; }
    .backlink .lang-block { display: none !important; } /* icon-only back arrow */
    .brand-tag { margin-left: .35rem; }
}

/* ---- Focus + reduced motion ---- */
:focus-visible { outline: 2px solid var(--brand-light); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
    html.plot-anim .draw .pen { stroke-dashoffset: 0 !important; }
    html.plot-anim .draw .field, html.plot-anim .draw .ink { opacity: 1 !important; transform: none !important; }
}
