/* Tesseract Explorer - 3D "Unfolding Net" engine styles
   Visual language from the Cyberdelic Nexus core design system: dark-only, glass plates with
   hairline borders, glow as inner radiance, Poppins for UI, JetBrains Mono for data.
   Everything is scoped under .te3d so it cannot leak into other engines.
   The previous version's styles live in tesseract-explorer-2d.css. */

@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap");

/* ===== HOST LAYOUT: the viewport fills the block, no side controls ===== */
.interactive-simulation-container:is([data-engine="TesseractExplorer"], [data-engine="tesseract-explorer"]) {
    display: flex;
    flex-direction: column;
    align-items: stretch !important;
    overflow: hidden;
}
.interactive-simulation-container:is([data-engine="TesseractExplorer"], [data-engine="tesseract-explorer"]) .sim-viewport {
    flex: 1 1 auto;
    width: 100% !important;
    align-self: stretch;
    min-height: clamp(620px, 86vh, 920px);
    background: #000;
    border-radius: 22px;
    position: relative;
    overflow: hidden;
}
.interactive-simulation-container:is([data-engine="TesseractExplorer"], [data-engine="tesseract-explorer"]) .sim-controls:empty {
    display: none !important;
}

/* ===== ROOT ===== */
.te3d {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #000;
    color: #F1EEFB;
    font-family: Poppins, system-ui, sans-serif;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: normal;
    text-align: left;
    -webkit-font-smoothing: antialiased;
    isolation: isolate;
    --p:#4CDCEF;--text:#F1EEFB;--text2:#ABA4C9;--text3:#9890BB;--line:rgba(255,255,255,.11);--line-hi:rgba(180,155,248,.36);
    --blur:blur(22px) saturate(155%);--brand:linear-gradient(100deg,#4CDCEF,#B49BF8 50%,#E562A4);--ease:cubic-bezier(.16,1,.3,1);
}
.te3d *, .te3d *::before, .te3d *::after { box-sizing: border-box; }
/* the lesson page styles headings, paragraphs and labels globally; start from zero in here */
.te3d :is(h1, h2, h3, h4, p, ul, ol, li, label, details, summary) { margin: 0; padding: 0; }
.te3d button { font-family: inherit; }
.te3d canvas.te3d-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.te3d.hovering canvas.te3d-canvas { cursor: pointer; }
.te3d .te3d-status {
    position: absolute; inset: 0; display: grid; place-items: center; padding: 24px;
    font: 500 .86rem Poppins, sans-serif; color: #9890BB; text-align: center;
}
.te3d .te3d-status.error { color: #FF5C72; }

/* ===== SHARED ===== */
.te3d :where(button,summary,[tabindex]):focus-visible {outline:2px solid var(--p);outline-offset:2px}
.te3d .glass {border:1px solid var(--line);background:rgba(15,11,26,.62);backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur)}
.te3d .eb {display:block;font-size:.72rem;font-weight:600;letter-spacing:.18em;text-transform:uppercase;color:var(--p)}
.te3d .bar {display:block;width:64px;height:3px;border-radius:2px;background:var(--brand)}
.te3d .lbl {display:block;font:600 .62rem Poppins,sans-serif;letter-spacing:.16em;text-transform:uppercase;color:var(--text3)}
.te3d .head {position:absolute;top:24px;left:24px;width:300px;pointer-events:none}
.te3d .head h1 {margin:6px 0 10px;font-size:1.7rem;font-weight:700;letter-spacing:-.015em;line-height:1.2;color:var(--text)}
.te3d .head p {margin:12px 0 0;font-size:.82rem;line-height:1.55;color:var(--text3)}

/* ===== DIMENSION NAV (left) ===== */
.te3d .dims {position:absolute;left:24px;top:196px;width:250px;padding:14px;border-radius:22px;display:grid;gap:10px}
.te3d .chips {display:grid;gap:4px}
.te3d .chip {display:flex;align-items:center;gap:10px;width:100%;padding:9px 10px;border-radius:12px;border:1px solid transparent;background:transparent;color:var(--text2);font:500 .82rem Poppins,sans-serif;text-align:left;cursor:pointer;transition:background .25s,border-color .25s,color .25s}
.te3d .chip:hover {background:rgba(255,255,255,.04);color:var(--text)}
.te3d .chip[aria-current=true] {border-color:var(--line-hi);background:rgba(180,155,248,.08);color:var(--text)}
.te3d .chip .ic {width:22px;text-align:center;color:var(--c);font-size:1rem;line-height:1}
.te3d .chip .nm {flex:1;white-space:nowrap}
.te3d .chip .st {width:9px;height:9px;border-radius:50%;border:1.5px solid var(--c);opacity:.5;transition:background .3s,opacity .3s,box-shadow .3s}
.te3d .chip.done .st {background:var(--c);opacity:1;box-shadow:0 0 8px var(--c)}
.te3d .prog {display:flex;align-items:center;gap:10px;padding:2px 4px;font:500 .7rem 'JetBrains Mono',monospace;color:var(--text2)}
.te3d .prog.all {color:#5FDFA6}
.te3d .fold {min-height:36px;border-radius:999px;border:1px solid var(--line);background:rgba(255,255,255,.03);color:var(--text2);font:500 .74rem Poppins,sans-serif;cursor:pointer;transition:border-color .25s,color .25s}
.te3d .fold:hover {border-color:var(--line-hi);color:var(--text)}
.te3d .fold[disabled] {opacity:.4;cursor:default}

/* ===== WORKSPACE PANEL (right; a bottom sheet on tablet and phone) ===== */
.te3d .panel {position:absolute;right:24px;top:24px;bottom:24px;width:380px;border-radius:22px;display:flex;flex-direction:column;overflow:hidden}
.te3d .sheet-head {display:none}
/* min-height:0 lets the list scroll inside the panel instead of growing past it */
.te3d .panel .scroll {flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:20px 18px;display:grid;grid-auto-rows:max-content;align-content:start;gap:12px;scrollbar-width:thin;scrollbar-color:rgba(180,155,248,.35) transparent}
.te3d .panel .scroll::-webkit-scrollbar {width:6px}
.te3d .panel .scroll::-webkit-scrollbar-thumb {background:rgba(180,155,248,.35);border-radius:3px}
.te3d .panel .foot {display:flex;gap:8px;padding:12px 18px 16px;border-top:1px solid var(--line)}
.te3d .panel .foot:empty {display:none}
.te3d .dh {display:flex;align-items:center;gap:10px}
.te3d .dh .ic {font-size:1.4rem;color:var(--c);text-shadow:0 0 14px var(--c)}
.te3d .dh h2 {margin:0;font-size:1.35rem;font-weight:700;color:var(--text)}
.te3d .desc {margin:0;font-size:.82rem;line-height:1.55;color:var(--text2)}
.te3d .q {padding:10px 12px;border-radius:12px;border-left:2px solid var(--c);background:rgba(255,255,255,.03);font-size:.84rem;line-height:1.5;color:var(--text)}
.te3d .rule {font:500 .66rem 'JetBrains Mono',monospace;color:var(--c)}
.te3d .about summary {display:none}
.te3d .opt {display:grid;grid-template-columns:1fr auto;gap:2px 12px;align-items:start;width:100%;padding:11px 13px;border-radius:14px;border:1px solid var(--line);background:rgba(255,255,255,.02);color:var(--text);text-align:left;cursor:pointer;transition:border-color .25s,background .25s}
.te3d .opt:hover {border-color:rgba(255,255,255,.22);background:rgba(255,255,255,.04)}
.te3d .opt b {font:600 .86rem Poppins,sans-serif}
.te3d .opt span {grid-column:1;font-size:.74rem;line-height:1.5;color:var(--text3)}
.te3d .opt i {grid-row:1 / span 2;grid-column:2;align-self:center;width:16px;height:16px;border:1.5px solid rgba(255,255,255,.3);border-radius:4px;transition:background .25s,border-color .25s,box-shadow .25s}
.te3d .opt.single i {border-radius:50%}
.te3d .opt[aria-pressed=true] {border-color:var(--c);background:color-mix(in srgb,var(--c) 10%,transparent)}
.te3d .opt[aria-pressed=true] i {background:var(--c);border-color:var(--c);box-shadow:0 0 10px var(--c)}
.te3d .opt[aria-pressed=true] span {color:var(--text2)}
.te3d .step {border:1px solid var(--line);border-radius:14px;overflow:hidden}
.te3d .step>button {display:flex;align-items:center;gap:10px;width:100%;padding:11px 13px;border:none;background:rgba(255,255,255,.02);color:var(--text);text-align:left;cursor:pointer}
.te3d .step>button small {display:block;font:600 .58rem Poppins,sans-serif;letter-spacing:.14em;text-transform:uppercase;color:var(--c)}
.te3d .step>button em {display:block;font-style:normal;font-size:.84rem;color:var(--text);margin-top:2px}
.te3d .step>button .ok {margin-left:auto;flex:none;width:9px;height:9px;border-radius:50%;border:1.5px solid var(--c);opacity:.5}
.te3d .step>button .chev {flex:none;color:var(--text3);font-size:.7rem;transition:transform .3s var(--ease)}
.te3d .step.open>button .chev {transform:rotate(180deg)}
.te3d .step.done>button .ok {background:var(--c);opacity:1;box-shadow:0 0 8px var(--c)}
.te3d .step.locked>button {cursor:default;opacity:.45}
.te3d .step .body {display:none;padding:4px 12px 12px;gap:8px}
.te3d .step.open .body {display:grid}
.te3d .step .body p {margin:0 0 4px;font-size:.78rem;line-height:1.5;color:var(--text2)}
.te3d .words {display:flex;flex-wrap:wrap;gap:6px}
.te3d .word {min-height:32px;padding:4px 12px;border-radius:999px;border:1px solid var(--line);background:transparent;color:var(--text2);font:500 .74rem Poppins,sans-serif;cursor:pointer;transition:border-color .2s,color .2s,background .2s}
.te3d .word:hover {color:var(--text);border-color:rgba(255,255,255,.25)}
.te3d .word[aria-pressed=true] {border-color:var(--c);color:var(--text);background:color-mix(in srgb,var(--c) 14%,transparent)}
.te3d .btn {flex:1;min-height:38px;padding:0 14px;border-radius:999px;border:1px solid var(--line);background:rgba(255,255,255,.03);color:var(--text2);font:500 .76rem Poppins,sans-serif;cursor:pointer;transition:border-color .25s,color .25s,background .25s;white-space:nowrap}
.te3d .btn:hover {border-color:var(--line-hi);color:var(--text)}
.te3d .btn.pri {border-color:transparent;background:var(--brand);color:#120d22;font-weight:600}
.te3d .btn.fold2 {display:none;flex:0 0 auto}
.te3d .card {display:flex;gap:12px;align-items:flex-start;width:100%;padding:11px 13px;border-radius:14px;border:1px solid var(--line);background:rgba(255,255,255,.02);color:var(--text);text-align:left;cursor:pointer;transition:border-color .25s}
.te3d .card:hover {border-color:var(--c)}
.te3d .card .ic {color:var(--c);font-size:1.1rem;width:22px;text-align:center}
.te3d .card b {display:block;font:600 .84rem Poppins,sans-serif}
.te3d .card span {font-size:.74rem;line-height:1.45;color:var(--text3)}
.te3d .card.bpc {border-color:rgba(180,155,248,.4);background:rgba(180,155,248,.07)}
.te3d .bp h2 {margin:4px 0 0;font-size:1.4rem;line-height:1.25;font-weight:700;background:var(--brand);-webkit-background-clip:text;background-clip:text;color:transparent}
.te3d .bp p {margin:0;font-size:.84rem;line-height:1.62;color:var(--text2)}
.te3d .coh {padding:11px 13px;border-radius:12px;border:1px solid rgba(95,223,166,.35);background:rgba(95,223,166,.06);font-size:.78rem;line-height:1.55;color:var(--text)}
.te3d .coh b {display:block;font:600 .58rem Poppins,sans-serif;letter-spacing:.14em;text-transform:uppercase;color:#5FDFA6;margin-bottom:3px}
.te3d .sumrow {display:flex;flex-wrap:wrap;gap:6px}
.te3d .sumrow span {padding:3px 10px;border-radius:999px;border:1px solid var(--c);font:500 .66rem 'JetBrains Mono',monospace;color:var(--c)}
@keyframes te3d-in {from{opacity:0;transform:translateY(6px)}}
.te3d .scroll>* {animation:te3d-in .45s var(--ease) both}

/* ===== 3D LABELS ===== */
.te3d .labels {position:absolute;inset:0;pointer-events:none;overflow:hidden}
.te3d .lab {position:absolute;left:0;top:0;font:600 .64rem/1 Poppins,sans-serif;letter-spacing:.16em;text-transform:uppercase;color:var(--c);
    text-shadow:0 0 10px #000,0 0 3px #000;white-space:nowrap;opacity:0;transition:opacity .35s}

/* ===== TABLET (<1240px): scene on top, one-row dimension strip, collapsible bottom sheet ===== */
.te3d.te-compact .head {top:18px;left:16px;right:16px;width:auto}
.te3d.te-compact .head h1 {font-size:1.35rem;margin:4px 0 6px}
.te3d.te-compact .head p {display:none}
.te3d.te-compact .dims {top:90px;left:16px;right:16px;width:auto;padding:6px;border-radius:999px;display:flex;align-items:center;gap:6px}
.te3d.te-compact .dims .lbl {display:none}
.te3d.te-compact .chips {display:flex;gap:4px;flex:1;overflow-x:auto;scrollbar-width:none}
.te3d.te-compact .chips::-webkit-scrollbar {display:none}
.te3d.te-compact .chip {width:auto;padding:7px 12px;border-radius:999px;gap:7px}
.te3d.te-compact .chip .st {display:none}
.te3d.te-compact .chip.done {color:var(--text)}
.te3d.te-compact .chip.done .ic {text-shadow:0 0 8px var(--c)}
.te3d.te-compact .prog {white-space:nowrap}
.te3d.te-compact .prog .pw {display:none}
.te3d.te-compact .fold {display:none}
.te3d.te-compact .btn.fold2 {display:block}

.te3d.te-compact .panel {top:auto;left:16px;right:16px;bottom:16px;width:auto;height:auto;max-height:44%;transition:max-height .35s var(--ease)}
.te3d.te-compact .sheet-head {display:flex;align-items:center;gap:12px;width:100%;flex:none;padding:12px 16px;border:none;background:transparent;color:var(--text);text-align:left;cursor:pointer}
.te3d.te-compact .sheet-head .ic {font-size:1.25rem;line-height:1;color:var(--c);text-shadow:0 0 12px var(--c);width:24px;text-align:center;flex:none}
.te3d.te-compact .sheet-head .tx {flex:1;min-width:0}
.te3d.te-compact .sheet-head b {display:block;font:600 .95rem Poppins,sans-serif;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.te3d.te-compact .sheet-head small {display:block;font:500 .7rem Poppins,sans-serif;color:var(--text3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.te3d.te-compact .sheet-head .chev {flex:none;width:30px;height:30px;display:grid;place-items:center;border-radius:50%;border:1px solid var(--line);color:var(--text2);font-size:.7rem;transition:transform .35s var(--ease)}
.te3d.te-compact.sheet-open .sheet-head .chev {transform:rotate(180deg)}
.te3d.te-compact .sheet-head::before {content:"";position:absolute;top:6px;left:50%;width:36px;height:3px;margin-left:-18px;border-radius:2px;background:rgba(255,255,255,.16)}
.te3d.te-compact .panel .scroll {padding:4px 16px 16px;border-top:1px solid var(--line);padding-top:14px}
.te3d.te-compact .panel .foot {padding:10px 16px 12px}
/* collapsed: only the sheet's header row shows, so the tesseract has the screen */
.te3d.te-compact:not(.sheet-open) .panel .scroll,
.te3d.te-compact:not(.sheet-open) .panel .foot {display:none}
/* the header row already names the dimension; the about text folds away */
.te3d.te-compact .scroll .dh {display:none}
.te3d.te-compact .about summary {display:flex;align-items:center;gap:8px;list-style:none;cursor:pointer;font:500 .72rem Poppins,sans-serif;color:var(--text3)}
.te3d.te-compact .about summary::-webkit-details-marker {display:none}
.te3d.te-compact .about summary::after {content:"▾";font-size:.62rem;transition:transform .3s var(--ease)}
.te3d.te-compact .about[open] summary::after {transform:rotate(180deg)}
.te3d.te-compact .about .desc {margin-top:6px}
.te3d.te-compact .opt span {display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.te3d.te-compact .opt[aria-pressed=true] span {display:block}

/* ===== PHONE (<640px) ===== */
.te3d.te-phone .head {top:14px}
.te3d.te-phone .head .eb {font-size:.6rem}
.te3d.te-phone .head h1 {font-size:1.12rem;margin:3px 0 6px}
.te3d.te-phone .dims {top:70px;left:10px;right:10px}
.te3d.te-phone .chip .nm {display:none}
.te3d.te-phone .chips {gap:2px}
.te3d.te-phone .chip {padding:7px 8px;flex:none}
.te3d.te-phone .dims {gap:4px}
.te3d.te-phone .panel {left:10px;right:10px;bottom:10px;max-height:50%}
.te3d.te-phone .sheet-head {padding:12px 12px}
.te3d.te-phone .panel .scroll {padding:12px 12px 14px}
.te3d.te-phone .panel .foot {padding:8px 12px 10px}
.te3d.te-phone .btn {padding:0 10px;font-size:.72rem}
.te3d.te-phone .opt {padding:9px 11px}
.te3d.te-phone .opt span {-webkit-line-clamp:1}
.te3d.te-phone .lab {font-size:.56rem;letter-spacing:.12em}

@media (prefers-reduced-motion: reduce) {
    .te3d .scroll>* {animation:none}
    .te3d *, .te3d *::before, .te3d *::after {transition-duration:.01ms !important}
}
